2010-12-17 23:56:01 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Application_Form_AddUser extends Zend_Form
|
|
|
|
{
|
|
|
|
public function init()
|
|
|
|
{
|
2011-02-09 19:03:46 +01:00
|
|
|
/*
|
|
|
|
$this->addElementPrefixPath('Application_Validate',
|
|
|
|
'../application/validate',
|
|
|
|
'validate');
|
|
|
|
* */
|
2012-11-27 23:11:29 +01:00
|
|
|
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
|
|
|
$emailValidator = Application_Form_Helper_ValidationTypes::overrideEmailAddressValidator();
|
2013-09-26 22:23:22 +02:00
|
|
|
$notDemoValidator = new Application_Validate_NotDemoValidate();
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2012-10-27 00:09:30 +02:00
|
|
|
$this->setAttrib('id', 'user_form');
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2011-02-09 19:03:46 +01:00
|
|
|
$hidden = new Zend_Form_Element_Hidden('user_id');
|
2021-10-11 16:10:47 +02:00
|
|
|
$hidden->setDecorators(['ViewHelper']);
|
2011-02-09 19:03:46 +01:00
|
|
|
$this->addElement($hidden);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->addElement('hash', 'csrf', [
|
|
|
|
'salt' => 'unique',
|
|
|
|
]);
|
2014-10-01 21:36:36 +02:00
|
|
|
|
2011-02-09 19:03:46 +01:00
|
|
|
$login = new Zend_Form_Element_Text('login');
|
2012-11-15 16:59:06 +01:00
|
|
|
$login->setLabel(_('Username:'));
|
2011-02-09 19:03:46 +01:00
|
|
|
$login->setAttrib('class', 'input_text');
|
|
|
|
$login->setRequired(true);
|
2012-11-27 23:11:29 +01:00
|
|
|
$login->addValidator($notEmptyValidator);
|
2011-02-09 19:03:46 +01:00
|
|
|
$login->addFilter('StringTrim');
|
2022-03-14 11:15:04 +01:00
|
|
|
// $login->addValidator('UserNameValidate');
|
2011-02-09 19:03:46 +01:00
|
|
|
$this->addElement($login);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2011-02-09 19:03:46 +01:00
|
|
|
$password = new Zend_Form_Element_Password('password');
|
2012-11-15 16:59:06 +01:00
|
|
|
$password->setLabel(_('Password:'));
|
2011-02-09 19:03:46 +01:00
|
|
|
$password->setAttrib('class', 'input_text');
|
|
|
|
$password->setRequired(true);
|
|
|
|
$password->addFilter('StringTrim');
|
2012-11-27 23:11:29 +01:00
|
|
|
$password->addValidator($notEmptyValidator);
|
2011-02-09 19:03:46 +01:00
|
|
|
$this->addElement($password);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2013-01-10 23:51:25 +01:00
|
|
|
$passwordVerify = new Zend_Form_Element_Password('passwordVerify');
|
|
|
|
$passwordVerify->setLabel(_('Verify Password:'));
|
|
|
|
$passwordVerify->setAttrib('class', 'input_text');
|
|
|
|
$passwordVerify->setRequired(true);
|
|
|
|
$passwordVerify->addFilter('StringTrim');
|
|
|
|
$passwordVerify->addValidator($notEmptyValidator);
|
2013-09-26 22:23:22 +02:00
|
|
|
$passwordVerify->addValidator($notDemoValidator);
|
2013-01-10 23:51:25 +01:00
|
|
|
$this->addElement($passwordVerify);
|
|
|
|
|
2011-02-09 19:03:46 +01:00
|
|
|
$firstName = new Zend_Form_Element_Text('first_name');
|
2012-11-15 16:59:06 +01:00
|
|
|
$firstName->setLabel(_('Firstname:'));
|
2011-02-09 19:03:46 +01:00
|
|
|
$firstName->setAttrib('class', 'input_text');
|
|
|
|
$firstName->addFilter('StringTrim');
|
|
|
|
$this->addElement($firstName);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2011-02-09 19:03:46 +01:00
|
|
|
$lastName = new Zend_Form_Element_Text('last_name');
|
2012-11-15 16:59:06 +01:00
|
|
|
$lastName->setLabel(_('Lastname:'));
|
2011-02-09 19:03:46 +01:00
|
|
|
$lastName->setAttrib('class', 'input_text');
|
|
|
|
$lastName->addFilter('StringTrim');
|
|
|
|
$this->addElement($lastName);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2011-02-12 00:13:26 +01:00
|
|
|
$email = new Zend_Form_Element_Text('email');
|
2012-11-15 16:59:06 +01:00
|
|
|
$email->setLabel(_('Email:'));
|
2011-02-12 00:13:26 +01:00
|
|
|
$email->setAttrib('class', 'input_text');
|
|
|
|
$email->addFilter('StringTrim');
|
2012-06-14 22:11:14 +02:00
|
|
|
$email->setRequired(true);
|
2012-11-27 23:11:29 +01:00
|
|
|
$email->addValidator($notEmptyValidator);
|
|
|
|
$email->addValidator($emailValidator);
|
2011-02-12 00:13:26 +01:00
|
|
|
$this->addElement($email);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-06-13 19:39:54 +02:00
|
|
|
$cellPhone = new Zend_Form_Element_Text('cell_phone');
|
2012-11-15 16:59:06 +01:00
|
|
|
$cellPhone->setLabel(_('Mobile Phone:'));
|
2012-06-13 19:39:54 +02:00
|
|
|
$cellPhone->setAttrib('class', 'input_text');
|
|
|
|
$cellPhone->addFilter('StringTrim');
|
|
|
|
$this->addElement($cellPhone);
|
2011-02-12 00:13:26 +01:00
|
|
|
|
|
|
|
$skype = new Zend_Form_Element_Text('skype');
|
2012-11-15 16:59:06 +01:00
|
|
|
$skype->setLabel(_('Skype:'));
|
2011-02-12 00:13:26 +01:00
|
|
|
$skype->setAttrib('class', 'input_text');
|
|
|
|
$skype->addFilter('StringTrim');
|
|
|
|
$this->addElement($skype);
|
|
|
|
|
|
|
|
$jabber = new Zend_Form_Element_Text('jabber');
|
2012-11-15 16:59:06 +01:00
|
|
|
$jabber->setLabel(_('Jabber:'));
|
2011-02-12 00:13:26 +01:00
|
|
|
$jabber->setAttrib('class', 'input_text');
|
|
|
|
$jabber->addFilter('StringTrim');
|
2012-11-27 23:11:29 +01:00
|
|
|
$jabber->addValidator($emailValidator);
|
2011-02-12 00:13:26 +01:00
|
|
|
$this->addElement($jabber);
|
|
|
|
|
2011-02-09 19:03:46 +01:00
|
|
|
$select = new Zend_Form_Element_Select('type');
|
2012-11-15 16:59:06 +01:00
|
|
|
$select->setLabel(_('User Type:'));
|
2011-02-09 19:03:46 +01:00
|
|
|
$select->setAttrib('class', 'input_select');
|
|
|
|
$select->setAttrib('style', 'width: 40%');
|
2021-10-11 16:10:47 +02:00
|
|
|
$select->setMultiOptions([
|
|
|
|
'G' => _('Guest'),
|
|
|
|
'H' => _('DJ'),
|
|
|
|
'P' => _('Program Manager'),
|
|
|
|
'A' => _('Admin'),
|
|
|
|
]);
|
2014-06-17 23:40:55 +02:00
|
|
|
$select->setRequired(false);
|
2011-02-09 19:03:46 +01:00
|
|
|
$this->addElement($select);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-10-27 00:09:30 +02:00
|
|
|
$saveBtn = new Zend_Form_Element_Button('save_user');
|
2015-08-31 21:25:17 +02:00
|
|
|
$saveBtn->setAttrib('class', 'btn right-floated');
|
2012-10-27 00:09:30 +02:00
|
|
|
$saveBtn->setIgnore(true);
|
2012-11-15 16:59:06 +01:00
|
|
|
$saveBtn->setLabel(_('Save'));
|
2012-10-27 00:09:30 +02:00
|
|
|
$this->addElement($saveBtn);
|
2011-02-09 19:03:46 +01:00
|
|
|
}
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
public function validateLogin($data)
|
|
|
|
{
|
|
|
|
if (strlen($data['user_id']) == 0) {
|
2011-02-09 19:03:46 +01:00
|
|
|
$count = CcSubjsQuery::create()->filterByDbLogin($data['login'])->count();
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
if ($count != 0) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->getElement('login')->setErrors([_('Login name is not unique.')]);
|
2012-08-29 05:04:55 +02:00
|
|
|
|
2011-02-09 19:03:46 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2011-02-09 19:03:46 +01:00
|
|
|
return true;
|
2010-12-17 23:56:01 +01:00
|
|
|
}
|
2013-01-14 18:07:17 +01:00
|
|
|
|
2013-01-14 18:17:33 +01:00
|
|
|
// We need to add the password identical validator here in case
|
|
|
|
// Zend version is less than 1.10.5
|
2021-10-11 16:10:47 +02:00
|
|
|
public function isValid($data)
|
|
|
|
{
|
2013-01-14 18:07:17 +01:00
|
|
|
$passwordIdenticalValidator = Application_Form_Helper_ValidationTypes::overridePasswordIdenticalValidator(
|
2021-10-11 16:10:47 +02:00
|
|
|
$data['password']
|
|
|
|
);
|
2013-01-14 18:07:17 +01:00
|
|
|
$this->getElement('passwordVerify')->addValidator($passwordIdenticalValidator);
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-01-14 18:07:17 +01:00
|
|
|
return parent::isValid($data);
|
|
|
|
}
|
2010-12-17 23:56:01 +01:00
|
|
|
}
|