Inheritance: extends Gc\Db\AbstractTable
Ejemplo n.º 1
0
 /**
  * List all roles
  *
  * @return \Zend\View\Model\ViewModel|array
  */
 public function indexAction()
 {
     $roleCollection = new Role\Collection();
     $roles = array();
     foreach ($roleCollection->getRoles() as $role) {
         if ($role->getName() !== Role\Model::PROTECTED_NAME) {
             $roles[] = $role;
         }
     }
     return array('roles' => $roles);
 }
Ejemplo n.º 2
0
 /**
  * Initialize User form
  *
  * @return void
  */
 public function init()
 {
     $inputFilterFactory = new InputFilterFactory();
     $inputFilter = $inputFilterFactory->createInputFilter(array('email' => array('required' => true, 'validators' => array(array('name' => 'not_empty'), array('name' => 'email_address'))), 'login' => array('required' => true, 'validators' => array(array('name' => 'not_empty'), array('name' => 'db\\no_record_exists', 'options' => array('table' => 'user', 'field' => 'login', 'adapter' => $this->getAdapter())))), 'lastname' => array('required' => true, 'validators' => array(array('name' => 'not_empty'))), 'firstname' => array('required' => true, 'validators' => array(array('name' => 'not_empty'))), 'user_acl_role_id' => array('required' => true, 'validators' => array(array('name' => 'not_empty'))), 'active' => array('allow_empty' => true)));
     $this->setInputFilter($inputFilter);
     $email = new Element\Text('email');
     $email->setLabel('Email')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('class', 'form-control')->setAttribute('id', 'email');
     $this->add($email);
     $login = new Element\Text('login');
     $login->setLabel('Login')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('class', 'form-control')->setAttribute('id', 'login');
     $this->add($login);
     $password = new Element\Password('password');
     $password->setLabel('Password')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('class', 'form-control')->setAttribute('autocomplete', 'off')->setAttribute('id', 'password');
     $this->add($password);
     $passwordConfirm = new Element\Password('password_confirm');
     $passwordConfirm->setLabel('Password Confirm')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('class', 'form-control')->setAttribute('autocomplete', 'off')->setAttribute('id', 'password_confirm');
     $this->add($passwordConfirm);
     $lastname = new Element\Text('lastname');
     $lastname->setLabel('Lastname')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('class', 'form-control')->setAttribute('id', 'lastname');
     $this->add($lastname);
     $firstname = new Element\Text('firstname');
     $firstname->setLabel('Firstname')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('class', 'form-control')->setAttribute('id', 'firstname');
     $this->add($firstname);
     $active = new Element\Checkbox('active');
     $active->setLabel('Is active')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('class', 'input-checkbox')->setAttribute('id', 'active')->setCheckedValue('1');
     $this->add($active);
     $role = new Element\Select('user_acl_role_id');
     $role->setLabel('Role')->setLabelAttributes(array('class' => 'required control-label col-lg-2'));
     $roleCollection = new RoleCollection();
     $rolesList = $roleCollection->getRoles();
     $selectOptions = array();
     foreach ($rolesList as $roleModel) {
         $selectOptions[$roleModel->getId()] = $roleModel->getName();
     }
     $role->setValueOptions($selectOptions)->setAttribute('class', 'form-control');
     $this->add($role);
 }