'y']; protected function _initElements() { $this->_initProfileInfoElements(); $this->_initAclResourcesElement(); $this->_initPasswordElements(); $authAdapter = new App_Admin_AuthAdapter(); $auth = App_Admin_Auth::getInstance(); if ($authAdapter->isRemoteAuthEnabled() && $auth->getSuMode()) { $this->addElement( 'checkbox', 'remoteAuthEnabled', [ 'label' => 'Support Account (Remote Authorization)', 'decoration' => 'simple', ] ); } if ('y' == $this->_getData('remoteAuthEnabled')) { $this->getElement('password')->setAttrib('disabled', 'disabled'); $this->getElement('password')->setDescription( 'This is support account. You can not change this password.' ); $this->getElement('confirmPassword')->setAttrib('disabled', 'disabled'); } else { $this->getElement('password')->addValidator('ConfirmPassword', true, ['confirmPassword']); } if ($auth->getSuMode()) { $this->addElement( 'checkbox', 'stsLoginEnabled', [ 'label' => 'STS (Remote Authorization)', 'decoration' => 'simple', ] ); } return $this; } protected function _initAclResourcesElement() { $this->addElement( 'multiCheckbox', 'aclResources', [ 'required' => true, 'label' => 'Permissions', 'columns' => 2, 'multiOptions' => Qs_Array::fetchPairs(App_Admin_Acl::getAclResources(), ['id', 'title']) ] ); return $this; } protected function _initPasswordElements() { $this->addElement( 'password', 'password', ['label' => 'Password', 'attribs' => ['autocomplete' => 'off']] ); $this->addElement( 'password', 'confirmPassword', ['label' => 'Confirm Password', 'attribs' => ['autocomplete' => 'off']] ); $this->getElement('password')->setAllowEmpty(false); $this->getElement('confirmPassword')->setAllowEmpty(false); $this->getElement('password')->addValidator('NotEmptyDependent', true, ['confirmPassword']); $this->getElement('confirmPassword')->addValidator('NotEmptyDependent', true, ['password']); return $this; } protected function _initProfileInfoElements() { $table = new Qs_Db_Table('Admin'); $primaryKey = $this->_getData('id'); $this->addElement('text', 'firstName', ['label' => 'First Name', 'required' => true]); $this->addElement('text', 'lastName', ['label' => 'Last Name', 'required' => true]); $this->addElement('phone', 'phone', ['label' => 'Phone Number']); $this->addElement('email', 'email', ['label' => 'Email', 'required' => false]); $emailUniqueValidator = new Qs_Validate_Unique($table, 'email', $primaryKey); $emailUniqueValidator->setMessage('Email must be unique', Qs_Validate_Unique::NOT_UNIQUE); $this->getElement('email')->addValidator($emailUniqueValidator); $this->addElement( 'text', 'login', ['label' => 'Login', 'required' => true, 'attribs' => ['autocomplete' => 'off']] ); $loginValidator = new Qs_Validate_Unique($table, 'login', $primaryKey); $loginValidator->setMessage('Login must be unique', Qs_Validate_Unique::NOT_UNIQUE); $this->getElement('login')->addValidator($loginValidator); return $this; } public function getDefaults() { return $this->_getDefaults(); } }