Beispiel #1
0
 /**
  * publish
  *
  * @throws ValidateException
  * @return void
  */
 public function publish()
 {
     $this->rules = array('username' => 'required|min:3|max:255|alpha_dash|unique:users,username,' . \Sentry\Sentry::user()->id);
     if (array_key_exists('first_name', $this->input)) {
         $rules = array('first_name' => 'min:3|max:255');
         $this->rules = array_merge($this->rules, $rules);
     }
     if (array_key_exists('last_name', $this->input)) {
         $rules = array('last_name' => 'min:3|max:255');
         $this->rules = array_merge($this->rules, $rules);
     }
     $this->validate();
 }
Beispiel #2
0
 /**
  * Update the given group
  *
  * @param   array  fields to be updated
  * @return  bool
  * @throws  SentryGroupException
  */
 public function update(array $fields)
 {
     // make sure a group id is set
     if (empty($this->group['id'])) {
         throw new \SentryGroupException(__('sentry.no_group_selected'));
     }
     // init the update array
     $update = array();
     // update name
     if (array_key_exists('name', $fields) and $fields['name'] != $this->group['name']) {
         // make sure name does not already exist
         if (Sentry::group_exists($fields['name'])) {
             throw new \SentryGroupException(__('sentry.group_already_exists', array('group' => $fields['name'])));
         }
         $update['name'] = $fields['name'];
         unset($fields['name']);
     }
     // update level
     if (array_key_exists('level', $fields)) {
         $update['level'] = $fields['level'];
     }
     // update is_admin
     if (array_key_exists('is_admin', $fields)) {
         $update['is_admin'] = $fields['is_admin'];
     }
     if (empty($update)) {
         return true;
     }
     $update_group = DB::update(static::$table)->set($update)->where('id', $this->group['id'])->execute();
     return $update_group ? true : false;
 }