Beispiel #1
0
 /**
  * 
  * @param integer $role_id
  * @return Form
  */
 public function create($role_id)
 {
     $form = new Form();
     $form->enableLocalized();
     $role = $this->roles->getRole($role_id);
     $this->role_id = $role_id;
     $form->addText('name')->setRequired('errors.fill_role_name')->setValue($role->name)->setAttribute('class', 'form-control')->setAttribute('placeholder', 'role_name');
     $form->addTextArea('access', 'role_access')->setValue($role->access)->setAttribute('class', 'form-control');
     $form->addTextArea('description', 'description')->setValue($role->description)->setAttribute('class', 'form-control');
     $form->addTextArea('access_ban', 'access_ban')->setValue($role->access_ban)->setAttribute('class', 'form-control');
     $form->addSubmit('submit', 'edit')->setAttribute('class', 'btn btn-primary btn-purple btn-flat');
     $form->onSuccess[] = $this->success_form_add;
     return $form;
 }
Beispiel #2
0
 /**
  * 
  * @param integer $user_id
  * @param array $values
  */
 public function updateUser($user_id, $name = null, $email = null, $password = null, $role = null, \Nette\Http\FileUpload $file = null)
 {
     $user = $this->getUser($user_id);
     if ($name) {
         $user->name = $name;
     }
     if ($email) {
         $user->email = $email;
     }
     if ($password) {
         $user->password = Passwords::hash($password);
     }
     if ($role) {
         $user->role = $this->role->getRole($role);
     }
     if ($file) {
         $user->img_base64 = $this->getImageBase64($file);
     }
     $this->em->persist($user);
     $this->em->flush();
 }