Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 50dd577

Browse files
author
Charles Marion
committed
0009680: Add profile information
1 parent f3c7966 commit 50dd577

File tree

21 files changed

+454
-64
lines changed

21 files changed

+454
-64
lines changed

core/configs/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.local.ini
22
*.local.ini.old
3-
*.local.ini.test
3+
*.local.ini.test
4+
termsofservice.txt

core/controllers/UploadController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function simpleuploadAction()
6464
{
6565
throw new Zend_Exception("You have to be logged in to do that");
6666
}
67-
if(!$this->getRequest()->isXmlHttpRequest()&& !$this->isTestingEnv())
67+
if(!$this->getRequest()->isXmlHttpRequest() && !$this->isTestingEnv())
6868
{
6969
throw new Zend_Exception("Error, should be an ajax action.");
7070
}

core/controllers/UserController.php

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,29 @@ function init()
3232
function indexAction()
3333
{
3434
$this->view->header = $this->t("Users");
35-
$this->view->json['user']['createCommunity'] = $this->t('Create a community');
36-
$this->view->json['user']['titleCreateLogin'] = $this->t('Please log in');
37-
$this->view->json['user']['contentCreateLogin'] = $this->t('You need to be logged in to be able to create a community.');
35+
36+
$order = $this->_getParam('order');
37+
$offset = $this->_getParam('offset');
38+
if(!isset($order))
39+
{
40+
$order = 'view';
41+
}
42+
if(!isset($offset))
43+
{
44+
$offset = 0;
45+
}
3846

3947
if($this->logged && $this->userSession->Dao->isAdmin())
4048
{
41-
$users = $this->User->getAll();
49+
$users = $this->User->getAll(false, 100, $order, $offset);
4250
}
4351
else
4452
{
45-
$users = $this->User->getPublicUsers();
53+
$users = $this->User->getAll(true, 100, $order, $offset);
4654
}
47-
48-
$this->Component->Sortdao->field = 'firstname';
49-
$this->Component->Sortdao->order = 'asc';
50-
usort($users, array($this->Component->Sortdao, 'sortByName'));
51-
$users = $this->Component->Sortdao->arrayUniqueDao($users);
5255

56+
$this->view->order = $order;
57+
$this->view->offset = $offset;
5358
$this->view->users = $users;
5459
} //end index
5560

@@ -324,8 +329,16 @@ public function settingsAction()
324329
throw new Zend_Exception("Unable to load user");
325330
}
326331

327-
$accountForm = $this->Form->User->createAccountForm($userDao->getFirstname(), $userDao->getLastname(),
328-
$userDao->getCompany(), $userDao->getPrivacy());
332+
$defaultValue = array();
333+
$defaultValue['firstname'] = $userDao->getFirstname();
334+
$defaultValue['lastname'] = $userDao->getLastname();
335+
$defaultValue['company'] = $userDao->getCompany();
336+
$defaultValue['privacy'] = $userDao->getPrivacy();
337+
$defaultValue['city'] = $userDao->getCity();
338+
$defaultValue['country'] = $userDao->getCountry();
339+
$defaultValue['website'] = $userDao->getWebsite();
340+
$defaultValue['biography'] = $userDao->getBiography();
341+
$accountForm = $this->Form->User->createAccountForm($defaultValue);
329342
$this->view->accountForm = $this->getFormAsArray($accountForm);
330343

331344
if($this->_request->isPost())
@@ -363,6 +376,10 @@ public function settingsAction()
363376
$lastname = trim($this->_getParam('lastname'));
364377
$company = trim($this->_getParam('company'));
365378
$privacy = $this->_getParam('privacy');
379+
$city = $this->_getParam('city');
380+
$country = $this->_getParam('country');
381+
$website = $this->_getParam('website');
382+
$biography = $this->_getParam('biography');
366383

367384
$userDao = $this->User->load($userDao->getKey());
368385

@@ -380,6 +397,22 @@ public function settingsAction()
380397
{
381398
$userDao->setCompany($company);
382399
}
400+
if(isset($city))
401+
{
402+
$userDao->setCity($city);
403+
}
404+
if(isset($country))
405+
{
406+
$userDao->setCountry($country);
407+
}
408+
if(isset($website))
409+
{
410+
$userDao->setWebsite($website);
411+
}
412+
if(isset($biography))
413+
{
414+
$userDao->setBiography($biography);
415+
}
383416
$userDao->setPrivacy($privacy);
384417
$this->User->save($userDao);
385418
if(!isset($userId))

core/controllers/forms/UserForm.php

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,22 @@ public function createRegisterForm()
6161
$email = new Zend_Form_Element_Text('email');
6262
$email->setRequired(true)
6363
->addValidator('NotEmpty', true)
64+
->setAttrib('maxLength', 255)
6465
->addValidator('EmailAddress');
6566

6667

6768
$firstname = new Zend_Form_Element_Text('firstname');
6869
$firstname
6970
->setRequired(true)
7071
->addValidator('NotEmpty', true)
72+
->setAttrib('maxLength', 255)
7173
->addValidator(new Zend_Validate_Alnum());
7274

7375
$lastname = new Zend_Form_Element_Text('lastname');
7476
$lastname
7577
->setRequired(true)
7678
->addValidator('NotEmpty', true)
79+
->setAttrib('maxLength', 255)
7780
->addValidator(new Zend_Validate_Alnum());
7881

7982
$password1 = new Zend_Form_Element_Password('password1');
@@ -98,7 +101,7 @@ public function createRegisterForm()
98101

99102

100103
/** acount form */
101-
public function createAccountForm($firstname_value = null, $lastname_value = null, $company_value = null, $policy_value = null)
104+
public function createAccountForm($defaultValue = array())
102105
{
103106
$form = new Zend_Form;
104107
$form->setAction($this->webroot.'/user/settings')
@@ -108,16 +111,39 @@ public function createAccountForm($firstname_value = null, $lastname_value = nul
108111
$firstname
109112
->setRequired(true)
110113
->addValidator('NotEmpty', true)
114+
->setAttrib('maxLength', 255)
111115
->addValidator(new Zend_Validate_Alnum());
112116

113117
$lastname = new Zend_Form_Element_Text('lastname');
114118
$lastname
115119
->setRequired(true)
116120
->addValidator('NotEmpty', true)
121+
->setAttrib('maxLength', 255)
117122
->addValidator(new Zend_Validate_Alnum());
118123

119124
$company = new Zend_Form_Element_Text('company');
120125
$company
126+
->setAttrib('maxLength', 255)
127+
->addValidator(new Zend_Validate_Alnum());
128+
129+
$city = new Zend_Form_Element_Text('city');
130+
$city
131+
->setAttrib('maxLength', 100)
132+
->addValidator(new Zend_Validate_Alnum());
133+
134+
$country = new Zend_Form_Element_Text('country');
135+
$country
136+
->setAttrib('maxLength', 100)
137+
->addValidator(new Zend_Validate_Alnum());
138+
139+
$validator = new Zend_Validate_Callback(array('Zend_Uri', 'check'));
140+
$website = new Zend_Form_Element_Text('website');
141+
$website
142+
->setAttrib('maxLength', 255)
143+
->addValidator($validator);
144+
145+
$biography = new Zend_Form_Element_Textarea('biography');
146+
$biography
121147
->addValidator(new Zend_Validate_Alnum());
122148

123149
$submit = new Zend_Form_Element_Submit('modifyAccount');
@@ -131,24 +157,40 @@ public function createAccountForm($firstname_value = null, $lastname_value = nul
131157
->setRequired(true)
132158
->setValue(MIDAS_COMMUNITY_PUBLIC);
133159

134-
if($firstname_value != null)
160+
if(isset($defaultValue['firstname']))
161+
{
162+
$firstname->setValue($defaultValue['firstname']);
163+
}
164+
if(isset($defaultValue['lastname']))
165+
{
166+
$lastname->setValue($defaultValue['lastname']);
167+
}
168+
if(isset($defaultValue['company']))
169+
{
170+
$company->setValue($defaultValue['company']);
171+
}
172+
if(isset($defaultValue['privacy']))
173+
{
174+
$privacy->setValue($defaultValue['privacy']);
175+
}
176+
if(isset($defaultValue['city']))
135177
{
136-
$firstname->setValue($firstname_value);
178+
$city->setValue($defaultValue['city']);
137179
}
138-
if($lastname_value != null)
180+
if(isset($defaultValue['country']))
139181
{
140-
$lastname->setValue($lastname_value);
182+
$country->setValue($defaultValue['country']);
141183
}
142-
if($company_value != null)
184+
if(isset($defaultValue['website']))
143185
{
144-
$company->setValue($company_value);
186+
$website->setValue($defaultValue['website']);
145187
}
146-
if($policy_value != null)
188+
if(isset($defaultValue['biography']))
147189
{
148-
$privacy->setValue($policy_value);
190+
$biography->setValue($defaultValue['biography']);
149191
}
150192

151-
$form->addElements(array($firstname, $lastname, $company, $privacy, $submit));
193+
$form->addElements(array($website, $city ,$country, $biography, $firstname, $lastname, $company, $privacy, $submit));
152194

153195
return $form;
154196
}

core/database/upgrade/3.0.15.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
class Upgrade_3_0_15 extends MIDASUpgrade
4+
{
5+
public function preUpgrade()
6+
{
7+
}
8+
9+
public function mysql()
10+
{
11+
}
12+
13+
14+
public function pgsql()
15+
{
16+
}
17+
18+
public function postUpgrade()
19+
{
20+
$this->addTableField('user', 'city', 'varchar(100)', ' character varying(100)', null);
21+
$this->addTableField('user', 'country', 'varchar(100)', ' character varying(100)', null);
22+
$this->addTableField('user', 'website', 'varchar(255)', ' character varying(255)', null);
23+
$this->addTableField('user', 'biography', 'varchar(255)', ' character varying(255)', null);
24+
}
25+
}
26+
?>
27+
28+

core/models/base/UserModelBase.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public function __construct()
3535
'privatefolder_id' => array('type' => MIDAS_DATA),
3636
'view' => array('type' => MIDAS_DATA),
3737
'uuid' => array('type' => MIDAS_DATA),
38+
'city' => array('type' => MIDAS_DATA),
39+
'country' => array('type' => MIDAS_DATA),
40+
'website' => array('type' => MIDAS_DATA),
41+
'biography' => array('type' => MIDAS_DATA),
3842
'folder' => array('type' => MIDAS_MANY_TO_ONE, 'model' => 'Folder', 'parent_column' => 'folder_id', 'child_column' => 'folder_id'),
3943
'public_folder' => array('type' => MIDAS_MANY_TO_ONE, 'model' => 'Folder', 'parent_column' => 'publicfolder_id', 'child_column' => 'folder_id'),
4044
'private_folder' => array('type' => MIDAS_MANY_TO_ONE, 'model' => 'Folder', 'parent_column' => 'privatefolder_id', 'child_column' => 'folder_id'),
@@ -53,10 +57,8 @@ abstract function getUserCommunities($userDao);
5357
abstract function getByUuid($uuid);
5458
/** Returns a user given its folder (either public,private or base folder) */
5559
abstract function getByFolder($folder);
56-
/** Returns all the public users. Limited to 20 by default. */
57-
abstract function getPublicUsers($limit = 20);
5860
/** Returns all the users */
59-
abstract function getAll();
61+
abstract function getAll($onlyPublic = false, $limit = 20, $order = 'lastname', $offset = null);
6062

6163
/** save */
6264
public function save($dao)

core/models/pdo/UserModel.php

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -75,37 +75,48 @@ public function getUserCommunities($userDao)
7575
} // end getUserCommunities
7676

7777
/** Get all */
78-
function getAll()
78+
function getAll($onlyPublic = false, $limit = 20, $order = 'lastname', $offset = null)
7979
{
80-
$rowset = $this->database->fetchAll($this->database->select());
81-
$return = array();
82-
foreach($rowset as $row)
83-
{
84-
$return[] = $this->initDao('User', $row);
85-
}
86-
return $return;
87-
} // end getAll()
88-
89-
/** Get public users
90-
* @return Array of Users Dao */
91-
function getPublicUsers($limit = 20)
92-
{
93-
if(!is_numeric($limit))
80+
$sql = $this->database->select();
81+
if($onlyPublic)
9482
{
95-
throw new Zend_Exception("Error parameter.");
83+
$sql ->where('privacy = ?', MIDAS_USER_PUBLIC);
9684
}
97-
$sql = $this->database->select()->from($this->_name)
98-
->where('privacy = ?', MIDAS_USER_PUBLIC)
99-
->limit($limit);
10085

101-
$rowset = $this->database->fetchAll($sql);
86+
if($offset == null)
87+
{
88+
$sql ->limit($limit);
89+
}
90+
elseif(!is_numeric ($offset))
91+
{
92+
$sql ->where('lastname LIKE ?', $offset.'%');
93+
$sql ->limit($limit);
94+
}
95+
else
96+
{
97+
$sql ->limit($limit, $offset);
98+
}
99+
switch($order)
100+
{
101+
case 'lastname':
102+
$sql->order(array('lastname ASC'));
103+
break;
104+
case 'view':
105+
$sql->order(array('view DESC', 'lastname ASC'));
106+
break;
107+
default:
108+
$sql->order(array('lastname DESC'));
109+
break;
110+
}
111+
$rowset = $this->database->fetchAll($sql);
102112
$return = array();
103113
foreach($rowset as $row)
104114
{
105115
$return[] = $this->initDao('User', $row);
106116
}
107117
return $return;
108-
} // end getPublicUsers()
118+
} // end getAll()
119+
109120

110121

111122
/** Returns a user given its folder (either public,private or base folder) */

core/public/css/common/common.genericPage.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ div.genericThumbnail{
88
}
99

1010
div.genericInfo{
11-
height: 35px;
11+
height: 40px;
1212
}
1313

1414
div.genericAction{

core/public/css/user/user.index.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ div.userList span{
2020
div.userBlock:hover{
2121
background-color: #F6F9FE;
2222
cursor: pointer;
23+
}
24+
25+
.userSubTitle{
26+
margin-top: 0px;
27+
margin-bottom: 5px;
2328
}

0 commit comments

Comments
 (0)