Definition

_abuse_load($type, $oid)
abuse/abuse.module, line 918

Description

load an abuse 'object'

Code

<?php
function _abuse_load($type, $oid) {
  $object->type = $type;
  $object->oid = $oid;
  switch ($type) {
    case 'node' :
      $node = node_load(array('nid' => $oid));
      if (!$node->nid) {
        return false;
      }
      $object->title = $node->title;
      $object->uid = $node->uid;
      $object->name = $node->name;
      $object->description = $node->teaser;
      if (variable_get(ABUSE_CONTENT_NODE_TYPE . $node->type, 0)) {
        $object->content = $node->body;
      }
      else {
        return false;
      }
      $object->status = $node->status;
      
      $object->path = array('URL' => 'node/'. $node->nid, 'QUERY' => NULL, 'BREADCRUMB' => NULL);
      $object->link = l($object->title, 'node/'. $node->nid, array(), NULL, NULL, TRUE);
      break;
    case 'comment':
      $result = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d', $oid);
      $comment = db_fetch_object($result);
      $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
      $comment = drupal_unpack($comment);
      if (!$comment->cid) {
        return false;
      }
      $object->title = $comment->subject;
      $object->name = $comment->name;
      $object->uid = $comment->uid;
      $object->description = $comment->comment;
      $object->content = $comment->comment;
      $object->status = ( $comment->status == 0);
      $object->path = array('URL' => 'node/'. $comment->nid, 'QUERY' => NULL, 'BREADCRUMB' => 'comment-'. $comment->cid);
      $object->link = l($object->title, 'node/'. $comment->nid, array(), NULL, 'comment-'. $comment->cid, TRUE);
      break;
  }
  $object->reports = _abuse_load_reports($type, $oid);
  return $object;
}
?>