/[drupal]/contributions/modules/abuse/abuse.admin.inc
ViewVC logotype

Diff of /contributions/modules/abuse/abuse.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.1 by btmash, Fri Apr 11 20:01:56 2008 UTC revision 1.1.2.2 by btmash, Wed May 14 19:13:19 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2    // $Id$
3    
4  // A LIST OF ALL THE ADMIN FUNCTIONS  /**
5     * @file
6     * A list of all administration functions
7     */
8    
9  function abuse_admin_settings(&$form_state) {  function abuse_admin_settings(&$form_state) {
10    $form = array();    $form = array();
# Line 176  function abuse_admin_reason_settings(&$f Line 180  function abuse_admin_reason_settings(&$f
180        );        );
181        $form['reason_list']["field$count"]['edit'] = array(        $form['reason_list']["field$count"]['edit'] = array(
182          '#type' => 'item',          '#type' => 'item',
183          '#value' => l('Edit reason', 'admin/settings/abuse/reasons/edit/'.$reason->arid)          '#value' => l('Edit reason', "admin/settings/abuse/reasons/edit/$reason->arid"),
184        );        );
185        $form['reason_list']['field'. $count]['reason'] = array(        $form['reason_list']['field'. $count]['reason'] = array(
186          '#type' => 'item',          '#type' => 'item',
# Line 263  function abuse_admin_reason_settings_sub Line 267  function abuse_admin_reason_settings_sub
267      db_query("INSERT INTO {abuse_reasons} (reason, description, argumentation) VALUES ('%s', '%s', '%s', %d)",      db_query("INSERT INTO {abuse_reasons} (reason, description, argumentation) VALUES ('%s', '%s', '%s', %d)",
268        $values['short_form'], $values['description'], $values['email_notice']);        $values['short_form'], $values['description'], $values['email_notice']);
269      drupal_set_message(t("Added new reason to list"));      drupal_set_message(t("Added new reason to list"));
270    }  elseif ($op == t('Remove')) {    }
271      elseif ($op == t('Remove')) {
272      foreach ($values as $key => $value) {      foreach ($values as $key => $value) {
273        if (strpos($key, 'arid') === 0 && $value === 1) {        if (strpos($key, 'arid') === 0 && $value === 1) {
274          db_query("DELETE FROM {abuse_reasons} WHERE arid=%d", str_replace('arid', '', $key));          db_query("DELETE FROM {abuse_reasons} WHERE arid=%d", str_replace('arid', '', $key));
# Line 293  function abuse_admin_edit_reason_submit( Line 298  function abuse_admin_edit_reason_submit(
298    $values = $form_state['values'];    $values = $form_state['values'];
299    $op = $form_state['clicked_button']['#value'];    $op = $form_state['clicked_button']['#value'];
300    if ($op == t('Save')) {    if ($op == t('Save')) {
301      db_query("UPDATE {abuse_reasons} SET reason='%s', description='%s', argumentation='%s', WHERE arid=%d",      db_query("UPDATE {abuse_reasons} SET reason='%s', description='%s', argumentation='%s' WHERE arid=%d",
302        $values['short_form'], $values['description'], $values['email_notice'], $values['arid']);        $values['short_form'], $values['description'], $values['email_notice'], $values['arid']);
303      drupal_set_message(t('Reason edit '.$values['arid'].' saved'));      drupal_set_message(t('Reason edit '. $values['arid'] .' saved'));
304    }    }
305    $form_state['redirect'] = 'admin/settings/abuse/reasons';    $form_state['redirect'] = 'admin/settings/abuse/reasons';
306  }  }
# Line 310  function abuse_admin_moderate($status = Line 315  function abuse_admin_moderate($status =
315    $content = '';    $content = '';
316    $query = "SELECT type, oid, status, assigned_to_uid FROM {abuse_status} WHERE (status=". implode(' OR status=', $status) .")";    $query = "SELECT type, oid, status, assigned_to_uid FROM {abuse_status} WHERE (status=". implode(' OR status=', $status) .")";
317    if ($assigned_to_uid) {    if ($assigned_to_uid) {
318      $query .= " AND assigned_to_uid=".$user->uid;      $query .= " AND assigned_to_uid=$user->uid";
319    }    }
320    $query .= " ORDER BY oid ASC";    $query .= " ORDER BY oid ASC";
321    $result = pager_query($query, $limit, 0, NULL);    $result = pager_query($query, $limit, 0, NULL);
# Line 326  function abuse_admin_moderate($status = Line 331  function abuse_admin_moderate($status =
331  function abuse_admin_default_callback() {  function abuse_admin_default_callback() {
332    if (variable_get('abuse_assigned_moderators', FALSE)) {    if (variable_get('abuse_assigned_moderators', FALSE)) {
333      return abuse_admin_moderate(array(ABUSE_PENDING, ABUSE_HIDDEN), TRUE);      return abuse_admin_moderate(array(ABUSE_PENDING, ABUSE_HIDDEN), TRUE);
334    } else {    }
335      else {
336      return abuse_admin_moderate(array(ABUSE_PENDING));      return abuse_admin_moderate(array(ABUSE_PENDING));
337    }    }
338  }  }
# Line 343  function abuse_admin_status($type, $oid) Line 349  function abuse_admin_status($type, $oid)
349    }    }
350    if (sizeof($reports) > 0) {    if (sizeof($reports) > 0) {
351      $content = theme('abuse_page', $reports);      $content = theme('abuse_page', $reports);
352    } else {    }
353      else {
354      $anchor = NULL;      $anchor = NULL;
355      if ('comment' == strtolower($type)) {      if ('comment' == strtolower($type)) {
356        $nid = db_result(db_query("SELECT nid FROM {comments} WHERE cid=%d", $oid));        $nid = db_result(db_query("SELECT nid FROM {comments} WHERE cid=%d", $oid));
357        $anchor = "comment-$oid";        $anchor = "comment-$oid";
358      } else {      }
359        else {
360        $nid = $oid;        $nid = $oid;
361      }      }
362      $content = t('No abuse reports for this particular piece of content - view %content', array('%content' => l(t('content'), "node/$nid", array('fragment' => $anchor))));      $content = t('No abuse reports for this particular piece of content - view %content', array('%content' => l(t('content'), "node/$nid", array('fragment' => $anchor))));
# Line 421  function abuse_admin_warn_user($type, $o Line 429  function abuse_admin_warn_user($type, $o
429    $message = t('Sorry, the user could not be warned and the operation could not be carried out');    $message = t('Sorry, the user could not be warned and the operation could not be carried out');
430    if ($object->oid) {    if ($object->oid) {
431      $account = user_load(array('uid' => $object->uid));      $account = user_load(array('uid' => $object->uid));
432      $to = $account->name ."<".$account->mail.">";      $to = check_plain($account->name) ."<$account->mail>";
433      $params = array();      $params = array();
434      $params['object'] = $object;      $params['object'] = $object;
435      $params['account'] = $account;      $params['account'] = $account;
# Line 565  function abuse_admin_moderate_content(&$ Line 573  function abuse_admin_moderate_content(&$
573        'class' => 'abuse-report-warn-and-remove'        'class' => 'abuse-report-warn-and-remove'
574      ),      ),
575    );    );
   var_dump(variable_get('abuse_warn_subject', t('Abuse warning')));  
576    $form['warn']['allow']['allow_subject'] = $form['warn']['remove']['remove_subject'] = array(    $form['warn']['allow']['allow_subject'] = $form['warn']['remove']['remove_subject'] = array(
577      '#type' => 'textfield',      '#type' => 'textfield',
578      '#title' => t('Warning subject'),      '#title' => t('Warning subject'),
# Line 587  function abuse_admin_moderate_content(&$ Line 594  function abuse_admin_moderate_content(&$
594    foreach ($reasons as $key => $reason) {    foreach ($reasons as $key => $reason) {
595      $tmp_content .= "<!-- $reason->reason -->\n";      $tmp_content .= "<!-- $reason->reason -->\n";
596      $tmp_content .= "<dt class=\"warning-reason-title\"><a href='#'>". check_plain($reason->reason) ."</a></dt>\n";      $tmp_content .= "<dt class=\"warning-reason-title\"><a href='#'>". check_plain($reason->reason) ."</a></dt>\n";
597      $tmp_content .= "<dd class=\"warning-reason-email\">". check_markup($reason->argumentation) . "</dd>\n";      $tmp_content .= "<dd class=\"warning-reason-email\">". check_markup($reason->argumentation) ."</dd>\n";
598    }    }
599    $tmp_content .= '</dl></div>';    $tmp_content .= '</dl></div>';
600    
# Line 608  function abuse_admin_moderate_content(&$ Line 615  function abuse_admin_moderate_content(&$
615    if ($user->uid !== $object->uid && $object->uid > 1) {    if ($user->uid !== $object->uid && $object->uid > 1) {
616      $form['ban'] = array(      $form['ban'] = array(
617        '#type' => 'fieldset',        '#type' => 'fieldset',
618        '#title' => t('Ban !user?', array('!user' => $object->name)),        '#title' => t('Ban !user?', array('!user' => check_plain($object->name))),
619        '#collapsible' => TRUE,        '#collapsible' => TRUE,
620        '#collapsed' => TRUE,        '#collapsed' => TRUE,
621      );      );
622      $form['ban']['confirmation_message'] = array(      $form['ban']['confirmation_message'] = array(
623        '#type' => 'item',        '#type' => 'item',
624        '#value' => t('Are you sure you want to ban !name?', array('!name' => '<em>'. $object->name .'</em>'))        '#value' => t('Are you sure you want to ban !name?', array('!name' => '<em>'. check_plain($object->name) .'</em>'))
625      );      );
626      $form['ban']['ban'] = array(      $form['ban']['ban'] = array(
627        '#type' => 'submit',        '#type' => 'submit',
# Line 655  function abuse_admin_moderate_content_js Line 662  function abuse_admin_moderate_content_js
662    
663  function _abuse_admin_moderate_content_shared($values, $op) {  function _abuse_admin_moderate_content_shared($values, $op) {
664    $message = array('status' => FALSE, 'data' => t('Sorry, could not perform requested operation.'));    $message = array('status' => FALSE, 'data' => t('Sorry, could not perform requested operation.'));
665    switch($op) {    switch ($op) {
666      case t('allow'):      case t('allow'):
667        $message = abuse_admin_allow($values['object_type'], $values['object_oid']);        $message = abuse_admin_allow($values['object_type'], $values['object_oid']);
668        break;        break;
# Line 690  function abuse_admin_ban(&$form_state, $ Line 697  function abuse_admin_ban(&$form_state, $
697        '#type' => 'item',        '#type' => 'item',
698        '#value' => t('Sorry, you are not allowed to ban this user'),        '#value' => t('Sorry, you are not allowed to ban this user'),
699      );      );
700    } else {    }
701      else {
702      if ($inline) {      if ($inline) {
703        $form['message'] = array(        $form['message'] = array(
704          '#title' => t('Ban !user', array('!user' => $account->name)),          '#title' => t('Ban !user', array('!user' => $account->name)),
# Line 746  function abuse_admin_ban_submit($form, & Line 754  function abuse_admin_ban_submit($form, &
754    $account = user_load(array('uid' => $values['uid']));    $account = user_load(array('uid' => $values['uid']));
755    if ($values['redirect']) {    if ($values['redirect']) {
756      $form_state['redirect'] = $values['redirect'];      $form_state['redirect'] = $values['redirect'];
757    } else {    }
758      else {
759      $form_state['redirect'] = 'admin/content/abuse';      $form_state['redirect'] = 'admin/content/abuse';
760    }    }
761    if ($user->uid > 1 && $user->uid !== $account->uid && t('Yes') == $op) {    if ($user->uid > 1 && $user->uid !== $account->uid && t('Yes') == $op) {
# Line 837  function template_preprocess_abuse_repor Line 846  function template_preprocess_abuse_repor
846    
847    $variables['moderate'] = drupal_get_form('abuse_admin_moderate_content'. $counter++, $object->type, $object->oid, TRUE);    $variables['moderate'] = drupal_get_form('abuse_admin_moderate_content'. $counter++, $object->type, $object->oid, TRUE);
848  }  }
   
 ?>  

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

  ViewVC Help
Powered by ViewVC 1.1.3