Example #1
0
 /**
  * Remove one or more owners
  *
  * @param   string  $what  Owner type to remove
  * @param   mixed   $data  integer|string|array
  * @return  object
  */
 public function remove($what, $data)
 {
     $data = $this->_toArray($data);
     $what = strtolower($what);
     switch ($what) {
         case 'advisory':
         case 'individuals':
             $tbl = new Tables\Owner($this->_db);
             break;
         case 'groups':
             $tbl = new Tables\OwnerGroup($this->_db);
             break;
         default:
             throw new \InvalidArgumentException(Lang::txt('Owner type not supported.'));
             break;
     }
     foreach ($data as $result) {
         switch ($what) {
             case 'advisory':
             case 'individuals':
                 $user_id = (int) $this->_userId($result);
                 if (!$tbl->delete_owner($this->get('id'), $user_id, $this->config('group', 'hubadmin'))) {
                     $this->setError($tbl->getError());
                     continue;
                 }
                 break;
             case 'groups':
                 $group_id = (int) $this->_groupId($result);
                 if (!$tbl->delete_owner_group($this->get('id'), $group_id, $this->config('group', 'hubadmin'))) {
                     $this->setError($tbl->getError());
                     continue;
                 }
                 break;
         }
     }
     // Reset the owners lists
     $this->_cache['owners.list0'] = null;
     $this->_cache['owners.list1'] = null;
     return $this;
 }