Пример #1
0
 /**
  * Deletes a moderator
  *
  * @return	mixed	The number of affected rows
  */
 function delete($doquery = true)
 {
     $params = array();
     $params[vB_dB_Query::TYPE_KEY] = vB_dB_Query::QUERY_METHOD;
     $params['condition'] = $this->condition;
     $moderator = $this->assertor->getRow('getModeratorInfo', $params);
     if ($moderator) {
         if ($moderator['usergroupid'] == 7 and !($morenodes = $this->assertor->getRow($this->table, array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, '#filters' => array(array('field' => 'userid', 'value' => $moderator[userid], 'operator' => 'EQ'), array('field' => 'moderatorid', 'value' => $moderator[moderatorid], 'operator' => 'NE'), array('field' => 'nodeid', 'value' => 0, 'operator' => 'NE')))))) {
             $userdata = new vB_Datamanager_User($this->registry, vB_DataManager_Constants::ERRTYPE_SILENT);
             if (!$this->info['user']) {
                 $userinfo = fetch_userinfo($this->fetch_field('userid'));
                 $userdata->set_existing($userinfo);
             } else {
                 $userdata->set_existing($this->info['user']);
             }
             $userdata->set_failure_callback(array(&$this, 'update_user_failed_update'));
             $userdata->set('usergroupid', 2);
             $userdata->set('displaygroupid', $moderator['displaygroupid'] == 7 ? 0 : $moderator['displaygroupid']);
             if ($userdata->errors) {
                 $this->errors = array_merge($this->errors, $userdata->errors);
                 return 0;
             }
             $userdata->save();
         }
         // Legacy Hook 'moderatordata_delete' Removed //
         return $this->db_delete(TABLE_PREFIX, $this->table, $this->condition, $doquery);
     } else {
         $this->error('user_no_longer_moderator');
     }
 }