public function initialize($entity = null, $options = null)
 {
     if (isset($options['edit']) && $options['edit']) {
         $id = new Hidden('id');
     } else {
         $id = new Text('id');
     }
     $this->add($id);
     $this->add(new Text('name'));
     $this->add(new Text('email'));
     $this->add(new Select('group_id', UserGroups::find('active = 1'), array('using' => array('id', 'name'), 'useEmpty' => true, 'emptyText' => '...', 'emptyValue' => '')));
     $this->add(new Select('banned', array(1 => 'Yes', 0 => 'No')));
     $this->add(new Select('suspended', array(1 => 'Yes', 0 => 'No')));
     $this->add(new Select('active', array(1 => 'Yes', 0 => 'No')));
 }
Esempio n. 2
0
 /**
  * Rebuils the access list into a file.
  */
 public function rebuild()
 {
     $acl = new AclAdapter();
     $acl->setDefaultAction(\Phalcon\Acl::DENY);
     //Register roles
     $profiles = UserGroups::find('active = 1');
     foreach ($profiles as $profile) {
         $acl->addRole(new AclRole($profile->name));
     }
     foreach ($this->_privateResources as $resource => $actions) {
         $acl->addResource(new AclResource($resource), $actions);
     }
     //Grant acess to private area to role Users
     foreach ($profiles as $profile) {
         //Grant permissions in "permissions" model
         foreach ($profile->getPermissions() as $permission) {
             $acl->allow($profile->name, $permission->resource, $permission->action);
         }
         //Always grant these permissions
         $acl->allow($profile->name, 'users', 'changePassword');
     }
     if (is_writable(__DIR__ . $this->_filePath)) {
         file_put_contents(__DIR__ . $this->_filePath, serialize($acl));
         //Store the ACL in APC
         if (function_exists('apc_store')) {
             apc_store($this->di->config->cradaUserPlugin->appId, $acl);
         }
     } else {
         $this->flash->error('The user does not have write permissions');
     }
     return $acl;
 }