Ejemplo n.º 1
0
 /**
  * Get the appropriate attention object for the attention item
  *
  * @param mixed $attention_id
  * @param mixed $object_type
  * @param mixed $object_id
  */
 public static function get_attention_object($attention_id, $object_type = false, $object_id = false)
 {
     $data = self::load_attention($attention_id, $object_type, $object_id);
     if (!$data) {
         return false;
     }
     switch ($data['attention_object_type']) {
         case TITANIA_POST:
             titania::_include('objects/attention_types/post', false, 'titania_attention_post');
             $object = new titania_attention_post();
             break;
         case TITANIA_CONTRIB:
             titania::_include('objects/attention_types/contribution', false, 'titania_attention_contribution');
             $object = new titania_attention_contribution();
             break;
         default:
             $object = new titania_attention();
     }
     $object->__set_array($data);
     return $object;
 }
Ejemplo n.º 2
0
 public function report($reason = '')
 {
     // Mark the post as reported
     $this->post_reported = true;
     // Setup the attention object and submit it
     $attention = new titania_attention();
     $attention->__set_array(array('attention_type' => TITANIA_ATTENTION_REPORTED, 'attention_object_type' => TITANIA_POST, 'attention_object_id' => $this->post_id, 'attention_poster_id' => $this->post_user_id, 'attention_post_time' => $this->post_time, 'attention_url' => $this->get_url(), 'attention_title' => $this->post_subject, 'attention_description' => $reason));
     $attention->submit();
     // Update the postcount and mark as reported for the topic and submit it
     $this->update_topic_postcount();
     $this->topic->topic_reported = true;
     $this->topic->submit();
     // Self submission
     parent::submit();
     // Hooks
     titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this);
 }
Ejemplo n.º 3
0
phpbb::$user->add_lang('mcp');
$attention_id = request_var('a', 0);
$object_type = request_var('type', 0);
$object_id = request_var('id', 0);
$close = isset($_POST['close']) ? true : false;
$approve = isset($_POST['approve']) ? true : false;
$disapprove = isset($_POST['disapprove']) ? true : false;
$delete = isset($_POST['delete']) ? true : false;
if ($attention_id || $object_type && $object_id) {
    if ($attention_id) {
        $row = attention_overlord::load_attention($attention_id);
        if (!$row) {
            trigger_error('NO_ATTENTION_ITEM');
        }
        // Setup
        $attention_object = new titania_attention();
        $attention_object->__set_array($row);
        $object_type = (int) $attention_object->attention_object_type;
        $object_id = (int) $attention_object->attention_object_id;
    }
    // Close, approve, or disapprove the items
    if ($close || $approve || $disapprove || $delete) {
        if (!check_form_key('attention')) {
            trigger_error('FORM_INVALID');
        }
        if ($delete) {
            $sql = 'DELETE FROM ' . TITANIA_ATTENTION_TABLE . '
					WHERE attention_object_id = ' . (int) $object_id . '
						AND attention_object_type = ' . (int) $object_type . '
						AND attention_close_time = 0
						AND attention_type = ' . TITANIA_ATTENTION_REPORTED;
Ejemplo n.º 4
0
 public function report($reason = '', $notify_reporter = false, $attention_type = TITANIA_ATTENTION_REPORTED)
 {
     // Setup the attention object and submit it
     $attention = new titania_attention();
     $attention->__set_array(array('attention_type' => $attention_type, 'attention_object_type' => TITANIA_CONTRIB, 'attention_object_id' => $this->contrib_id, 'attention_poster_id' => $this->contrib_user_id, 'attention_post_time' => $this->contrib_last_update, 'attention_url' => $this->get_url(), 'attention_title' => $this->contrib_name, 'attention_description' => $reason, 'notify_reporter' => $notify_reporter));
     $attention->submit();
 }
Ejemplo n.º 5
0
 /**
  * Display the list of attention items
  *
  * @param array $options
  * 	attention_type
  * 	attention_object_id
  * 	only_closed bool only display closed items
  * 	display_closed bool display closed and open items
  * 	template_block string the name of the template block to output to (attention if not sent)
  * @param titania_sort $sort
  */
 public static function display_attention_list($options = array(), $sort = false)
 {
     if ($sort === false) {
         // Setup the sort tool
         $sort = self::build_sort();
     }
     $sort->request();
     $sql_ary = array('SELECT' => '*', 'FROM' => array(TITANIA_ATTENTION_TABLE => 'a'), 'WHERE' => array(), 'ORDER_BY' => $sort->get_order_by());
     // Limit to certain types if requested
     if (isset($options['attention_type']) && $options['attention_type']) {
         $sql_ary['WHERE'][] = 'a.attention_type = ' . (int) $options['attention_type'];
     }
     // Limit to certain item if requested
     if (isset($options['attention_object_id'])) {
         $sql_ary['WHERE'][] = 'a.attention_object_id = ' . (int) $options['attention_object_id'];
     }
     // Do we want the closed ones?
     if (isset($options['only_closed']) && $options['only_closed']) {
         $sql_ary['WHERE'][] = 'a.attention_close_time <> 0';
     } else {
         if (!isset($options['display_closed']) || $options['display_closed'] == false) {
             $sql_ary['WHERE'][] = 'a.attention_close_time = 0';
         }
     }
     $sql_ary['WHERE'] = implode(' AND ', $sql_ary['WHERE']);
     // Main SQL Query
     $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
     // Handle pagination
     if (!$sort->sql_count($sql_ary, 'a.attention_id')) {
         // No results...no need to query more...
         return;
     }
     $sort->build_pagination(titania_url::$current_page, titania_url::$params);
     // Get the data
     $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
     $attention_ids = $user_ids = array();
     while ($row = phpbb::$db->sql_fetchrow($result)) {
         $attention_ids[] = $row['attention_id'];
         $user_ids[] = $row['attention_poster_id'];
         $user_ids[] = $row['attention_requester'];
         $user_ids[] = $row['attention_close_user'];
         if ($row['attention_close_user']) {
             $user_ids[] = $row['attention_close_user'];
         }
         self::$attention_items[$row['attention_id']] = $row;
     }
     phpbb::$db->sql_freeresult($result);
     // Grab some users
     users_overlord::load_users($user_ids);
     // Output time
     $attention = new titania_attention();
     foreach ($attention_ids as $attention_id) {
         $row = self::$attention_items[$attention_id];
         $attention->__set_array($row);
         $output = array_merge($attention->assign_details(true), users_overlord::assign_details($row['attention_poster_id']), users_overlord::assign_details($row['attention_requester'], 'REPORTER_'), users_overlord::assign_details($row['attention_close_user'], 'CLOSER_'));
         // Do we have to?
         if ($row['attention_close_user']) {
             $output = array_merge($output, users_overlord::assign_details($row['attention_close_user'], 'CLOSE_'));
         }
         $template_block = isset($options['template_block']) ? $options['template_block'] : 'attention';
         phpbb::$template->assign_block_vars($template_block, $output);
     }
     unset($attention);
 }
Ejemplo n.º 6
0
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->user = \phpbb::$user;
 }