Exemple #1
0
 public function setActive($value)
 {
     $active = intval($value);
     $this->active = $active;
     $access_mask = $active == 0 ? 0 : 1;
     $perm = new \Users\UserPermission();
     $permissions = $perm->getListByModule($this->name);
     foreach ($permissions as $permission) {
         $permission->access_mask = $access_mask;
         $this->em->persist($permission);
         $this->em->flush();
     }
 }
Exemple #2
0
 public function saveAction($data_name, $id = null)
 {
     $data = array();
     $fields = explode($this->conf->ac_sep, $_POST['fields']);
     $values = explode($this->conf->ac_sep, $_POST['values']);
     foreach ($fields as $key => $field) {
         $data[$field] = $values[$key];
     }
     switch ($data_name) {
         case 'User':
             if (!empty($data['pass']) && empty($data['pass2']) || empty($data['pass']) && !empty($data['pass2'])) {
                 return 'Пароль нужно ввести дважды';
             }
             if ($data['pass'] != $data['pass2']) {
                 return 'Введенные пароли не совпадают';
             }
             $user = new \Users\User();
             $user->save($data, $id);
             break;
         case 'UserGroup':
             $permissions_active = !empty($_POST['permissions']) ? explode(',', $_POST['permissions']) : array();
             $group = new \Users\UserGroup();
             $group->save($data, $permissions_active, $id);
             break;
         case 'UserPermission':
             $permission = new \Users\UserPermission();
             $permission->save($data, $id);
             break;
     }
 }