Merge branch '2.5.x' into CC-5293-calendar-pref
This commit is contained in:
commit
0dd5458269
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
require_once( __DIR__ . '/../validate/NotDemoValidate.php');
|
||||
|
||||
class Application_Form_AddUser extends Zend_Form
|
||||
{
|
||||
|
@ -12,6 +13,7 @@ class Application_Form_AddUser extends Zend_Form
|
|||
* */
|
||||
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
||||
$emailValidator = Application_Form_Helper_ValidationTypes::overrideEmailAddressValidator();
|
||||
$notDemoValidator = new Application_Validate_NotDemoValidate();
|
||||
|
||||
$this->setAttrib('id', 'user_form');
|
||||
|
||||
|
@ -42,6 +44,7 @@ class Application_Form_AddUser extends Zend_Form
|
|||
$passwordVerify->setRequired(true);
|
||||
$passwordVerify->addFilter('StringTrim');
|
||||
$passwordVerify->addValidator($notEmptyValidator);
|
||||
$passwordVerify->addValidator($notDemoValidator);
|
||||
$this->addElement($passwordVerify);
|
||||
|
||||
$firstName = new Zend_Form_Element_Text('first_name');
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
require_once( __DIR__ . '/../validate/NotDemoValidate.php');
|
||||
|
||||
class Application_Form_EditUser extends Zend_Form
|
||||
{
|
||||
|
@ -16,6 +17,7 @@ class Application_Form_EditUser extends Zend_Form
|
|||
$userData = Application_Model_User::GetUserData($currentUserId);
|
||||
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
||||
$emailValidator = Application_Form_Helper_ValidationTypes::overrideEmailAddressValidator();
|
||||
$notDemoValidator = new Application_Validate_NotDemoValidate();
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/edit-user.phtml', "currentUser" => $currentUser->getLogin()))));
|
||||
|
@ -52,6 +54,7 @@ class Application_Form_EditUser extends Zend_Form
|
|||
$passwordVerify->setRequired(true);
|
||||
$passwordVerify->addFilter('StringTrim');
|
||||
$passwordVerify->addValidator($notEmptyValidator);
|
||||
$passwordVerify->addValidator($notDemoValidator);
|
||||
$passwordVerify->setDecorators(array('viewHelper'));
|
||||
$this->addElement($passwordVerify);
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
class Application_Validate_NotDemoValidate extends Zend_Validate_Abstract
|
||||
{
|
||||
const NOTDEMO = 'notdemo';
|
||||
|
||||
protected $_messageTemplates = array(
|
||||
self::NOTDEMO => "Cannot be changed in demo mode"
|
||||
);
|
||||
|
||||
public function isValid($value)
|
||||
{
|
||||
$this->_setValue($value);
|
||||
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
if (isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1) {
|
||||
$this->_error(self::NOTDEMO);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue