All pastes #502799 Raw Edit

chx

public php v1 · immutable
·published 2007-05-22 16:54 UTC
rendered paste body
<?phpfunction node_ban_menu($may_cache) {  $items = array();  if (!$may_cache) {    if (arg(0) == 'admin' && arg(1) == 'node_ban' && is_numeric(arg(2))) {      $items[] = array(        'path' => 'node_ban/'. arg(2),        'callback' => 'node_ban',        'access' => user_access('administer nodes'),        'title' => t('Blocks author and deletes node'),      );    }  }  return $items;}function node_ban($nid) {  $output = '';  $node = node_load($nid);  if (empty($node)) {    $output .= t('There is no node with nid @nid', array('@nid' => $nid));  }  else {    $user = user_load($node->uid);    $user->status = 0;    user_save($user);    node_delete($nid);    $output .= t("The node %title has been deleted and it's author %user has been blocked", array('%title' => $node->title, '%user' => $user->name));    watchdog('node ban', t("The node %title has been deleted and it's author %user has been blocked", array('%title' => $node->title, '%user' => $user->name)));  }  return $output;}function node_ban_link($type, $node = NULL, $teaser = FALSE) {  if ($type == 'node' && user_access('administer nodes')) {    return array(      'href' => 'node_ban/'. $node->nid,      'title' => t('Block author and delete node'),    );  }}