public function initialize()
 {
     $conditions = "deleted = :deleted: AND hidden = :hidden:";
     $parameters = array("deleted" => 0, "hidden" => 0);
     $languages = array();
     foreach (Languages::find(array($conditions, "bind" => $parameters)) as $languageRow) {
         $languages[$languageRow->shorttitle] = $languageRow->title;
     }
     $this->config->languages = $languages;
 }
 public function initialize()
 {
     if (intval($this->session->get('auth')['superuser']) !== 1) {
         throw new Exception('Access denied');
     }
     $conditions = "deleted = :deleted: AND hidden = :hidden:";
     $parameters = array("deleted" => 0, "hidden" => 0);
     $languages = array();
     foreach (Languages::find(array($conditions, "bind" => $parameters)) as $languageRow) {
         $languages[$languageRow->shorttitle] = $languageRow->title;
     }
     $this->config->languages = $languages;
 }
Пример #3
0
 public function initialize($entity = null, $options = null)
 {
     // In edition the id is hidden
     if (isset($options['edit']) && $options['edit']) {
         $uid = new Hidden('uid');
     } else {
         $uid = new Text('uid');
     }
     $this->add($uid);
     $username = new Text('username', array());
     $username->addValidators(array(new PresenceOf(array('message' => 'The name is required'))));
     $this->add($username);
     $password = new Password('password', array());
     $password->addValidators(array(new PresenceOf(array('message' => 'Password is required'))));
     $this->add($password);
     $last_name = new Text('last_name', array());
     $last_name->addValidators(array(new PresenceOf(array('message' => 'The lastname is required'))));
     $this->add($last_name);
     $first_name = new Text('first_name', array());
     $first_name->addValidators(array(new PresenceOf(array('message' => 'The firstname is required'))));
     $this->add($first_name);
     $title = new Text('title', array());
     $title->addValidators(array(new PresenceOf(array('message' => 'The title is required'))));
     $this->add($title);
     $email = new Text('email', array());
     $email->addValidators(array(new PresenceOf(array('message' => 'The email is required')), new Email(array('message' => 'The email is not valid'))));
     $this->add($email);
     $phone = new Text('phone', array());
     $this->add($phone);
     $address = new Text('address', array());
     $this->add($address);
     $city = new Text('city', array());
     $this->add($city);
     $zip = new Text('zip', array());
     $this->add($zip);
     $company = new Text('company', array());
     $this->add($company);
     $this->add(new Select("profileuid", Profiles::find(array('conditions' => 'deleted=0 AND hidden=0')), array('using' => array('uid', 'title'))));
     $this->add(new Select("usergroup", Usergroups::find(array('conditions' => 'deleted=0 AND hidden=0')), array('using' => array('uid', 'title'))));
     $this->add(new Select("userlanguage", Languages::find(array('conditions' => 'deleted=0 AND hidden=0')), array('using' => array('uid', 'title'))));
     $this->add(new Select('superuser', array('0' => ControllerBase::translate('no'), '1' => ControllerBase::translate('yes'))));
 }
 public function createAction()
 {
     if ($this->request->isPost()) {
         $time = time();
         $feuser = new Feusers();
         $feuser->assign(array("pid" => 0, 'tstamp' => $time, 'crdate' => $time, 'cruser_id' => $this->session->get('auth')['uid'], 'deleted' => 0, 'hidden' => 0, 'username' => $this->request->getPost('username'), 'password' => $this->myhash($this->request->getPost('password'), $this->unique_salt()), 'first_name' => $this->request->getPost('first_name'), 'last_name' => $this->request->getPost('last_name'), 'title' => $this->request->getPost('title'), 'email' => $this->request->getPost('email'), 'phone' => $this->request->getPost('phone'), 'address' => $this->request->getPost('address'), 'city' => $this->request->getPost('city'), 'zip' => $this->request->getPost('zip'), 'company' => $this->request->getPost('company'), 'profileid' => $this->request->getPost('profileuid'), 'usergroup' => $this->request->getPost('usergroup'), 'superuser' => $this->request->getPost('superuser'), 'userlanguage' => $this->request->getPost('userlanguage')));
         if (!$feuser->save()) {
             $this->flashSession->error($feuser->getMessages());
         } else {
             $this->flashSession->success("Feuser was created successfully");
         }
         /*Forces to rewrite ACL list on next request*/
         unlink('../app/cache/acl/data.txt');
     }
     $profiles = Profiles::find(array('conditions' => 'deleted=0 AND hidden=0'));
     $languages = Languages::find(array('conditions' => 'deleted=0 AND hidden=0'));
     $usergroups = Usergroups::find(array('conditions' => 'deleted=0 AND hidden=0'));
     $this->view->setVar('profiles', $profiles);
     $this->view->setVar('languages', $languages);
     $this->view->setVar('usergroups', $usergroups);
 }