CC-4736: Let non-admin users update their user info
new form
This commit is contained in:
parent
dd5882984e
commit
f12547dfb4
2 changed files with 121 additions and 0 deletions
116
airtime_mvc/application/forms/EditUser.php
Normal file
116
airtime_mvc/application/forms/EditUser.php
Normal file
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
|
||||
class Application_Form_EditUser extends Zend_Form
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
/*
|
||||
$this->addElementPrefixPath('Application_Validate',
|
||||
'../application/validate',
|
||||
'validate');
|
||||
* */
|
||||
|
||||
$currentUser = Application_Model_User::getCurrentUser();
|
||||
$userData = Application_Model_User::GetUserData($currentUser->getId());
|
||||
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
||||
$emailValidator = Application_Form_Helper_ValidationTypes::overrideEmailAddressValidator();
|
||||
/*
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/edit-user.phtml'))));
|
||||
*/
|
||||
$this->setAttrib('id', 'current-user-form');
|
||||
|
||||
$hidden = new Zend_Form_Element_Hidden('cu_user_id');
|
||||
$hidden->setDecorators(array('ViewHelper'));
|
||||
$hidden->setValue($userData["id"]);
|
||||
$this->addElement($hidden);
|
||||
|
||||
$login = new Zend_Form_Element_Text('cu_login');
|
||||
$login->setLabel(_('Username:'));
|
||||
$login->setValue($userData["login"]);
|
||||
$login->setAttrib('class', 'input_text');
|
||||
$login->setRequired(true);
|
||||
$login->addValidator($notEmptyValidator);
|
||||
$login->addFilter('StringTrim');
|
||||
//$login->setDecorators(array('viewHelper'));
|
||||
//$login->addValidator('UserNameValidate');
|
||||
$this->addElement($login);
|
||||
|
||||
$password = new Zend_Form_Element_Password('cu_password');
|
||||
$password->setLabel(_('Password:'));
|
||||
$password->setAttrib('class', 'input_text');
|
||||
$password->setRequired(true);
|
||||
$password->addFilter('StringTrim');
|
||||
$password->addValidator($notEmptyValidator);
|
||||
$this->addElement($password);
|
||||
|
||||
$firstName = new Zend_Form_Element_Text('cu_first_name');
|
||||
$firstName->setLabel(_('Firstname:'));
|
||||
$firstName->setValue($userData["first_name"]);
|
||||
$firstName->setAttrib('class', 'input_text');
|
||||
$firstName->addFilter('StringTrim');
|
||||
$firstName->addValidator($notEmptyValidator);
|
||||
$this->addElement($firstName);
|
||||
|
||||
$lastName = new Zend_Form_Element_Text('cu_last_name');
|
||||
$lastName->setLabel(_('Lastname:'));
|
||||
$lastName->setValue($userData["last_name"]);
|
||||
$lastName->setAttrib('class', 'input_text');
|
||||
$lastName->addFilter('StringTrim');
|
||||
$lastName->addValidator($notEmptyValidator);
|
||||
$this->addElement($lastName);
|
||||
|
||||
$email = new Zend_Form_Element_Text('cu_email');
|
||||
$email->setLabel(_('Email:'));
|
||||
$email->setValue($userData["email"]);
|
||||
$email->setAttrib('class', 'input_text');
|
||||
$email->addFilter('StringTrim');
|
||||
$email->setRequired(true);
|
||||
$email->addValidator($notEmptyValidator);
|
||||
$email->addValidator($emailValidator);
|
||||
$this->addElement($email);
|
||||
|
||||
$cellPhone = new Zend_Form_Element_Text('cu_cell_phone');
|
||||
$cellPhone->setLabel(_('Mobile Phone:'));
|
||||
$cellPhone->setValue($userData["cell_phone"]);
|
||||
$cellPhone->setAttrib('class', 'input_text');
|
||||
$cellPhone->addFilter('StringTrim');
|
||||
$this->addElement($cellPhone);
|
||||
|
||||
$skype = new Zend_Form_Element_Text('cu_skype');
|
||||
$skype->setLabel(_('Skype:'));
|
||||
$skype->setValue($userData["skype_contact"]);
|
||||
$skype->setAttrib('class', 'input_text');
|
||||
$skype->addFilter('StringTrim');
|
||||
$this->addElement($skype);
|
||||
|
||||
$jabber = new Zend_Form_Element_Text('cu_jabber');
|
||||
$jabber->setLabel(_('Jabber:'));
|
||||
$jabber->setValue($userData["jabber_contact"]);
|
||||
$jabber->setAttrib('class', 'input_text');
|
||||
$jabber->addFilter('StringTrim');
|
||||
$jabber->addValidator($emailValidator);
|
||||
$this->addElement($jabber);
|
||||
|
||||
$saveBtn = new Zend_Form_Element_Button('cu_save_user');
|
||||
$saveBtn->setAttrib('class', 'btn btn-small right-floated');
|
||||
$saveBtn->setIgnore(true);
|
||||
$saveBtn->setLabel(_('Save'));
|
||||
$this->addElement($saveBtn);
|
||||
}
|
||||
|
||||
public function validateLogin($p_login, $p_userId) {
|
||||
$count = CcSubjsQuery::create()
|
||||
->filterByDbLogin($p_login)
|
||||
->filterByDbId($p_userId, Criteria::NOT_EQUAL)
|
||||
->count();
|
||||
|
||||
if ($count != 0) {
|
||||
$this->getElement('cu_login')->setErrors(array(_("Login name is not unique.")));
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
<?php echo $this->successMessage ?>
|
||||
<div id="current-user-container">
|
||||
<?php echo $this->form?>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue