示例#1
0
 /**
  * Assign the details for the attention object
  *
  * @param bool $return True to return the data, false to display it
  */
 public function assign_details($return = false)
 {
     $output = array('ATTENTION_ID' => $this->attention_id, 'ATTENTION_TYPE' => $this->attention_type, 'ATTENTION_TIME' => phpbb::$user->format_date($this->attention_time), 'ATTENTION_POST_TIME' => phpbb::$user->format_date($this->attention_post_time), 'ATTENTION_CLOSE_TIME' => $this->attention_close_time ? phpbb::$user->format_date($this->attention_close_time) : '', 'ATTENTION_TITLE' => $this->attention_title, 'ATTENTION_REASON' => $this->get_reason_string(), 'ATTENTION_DESCRIPTION' => $this->attention_description, 'U_VIEW_ATTENTION' => $this->get_url(), 'U_VIEW_DETAILS' => titania_url::append_url(titania_url::$current_page_url, array('a' => $this->attention_id)), 'S_CLOSED' => $this->attention_close_time ? true : false, 'S_UNAPPROVED' => $this->attention_type == TITANIA_ATTENTION_UNAPPROVED ? true : false, 'S_REPORTED' => $this->attention_type == TITANIA_ATTENTION_REPORTED ? true : false);
     if ($return) {
         return $output;
     }
     phpbb::$template->assign_vars($output);
 }
示例#2
0
 /**
  * Shorten the amount of code required for some places
  *
  * @param mixed $object_type
  * @param mixed $object_id
  * @param mixed $url
  */
 public static function handle_subscriptions($object_type, $object_id, $url)
 {
     if (!phpbb::$user->data['is_registered']) {
         // Cannot currently handle non-registered users
         return;
     }
     $subscribe = request_var('subscribe', '');
     if ($subscribe == 'subscribe' && check_link_hash(request_var('hash', ''), 'subscribe')) {
         titania_subscriptions::subscribe($object_type, $object_id);
     } else {
         if ($subscribe == 'unsubscribe' && check_link_hash(request_var('hash', ''), 'unsubscribe')) {
             titania_subscriptions::unsubscribe($object_type, $object_id);
         }
     }
     if (titania_subscriptions::is_subscribed($object_type, $object_id)) {
         phpbb::$template->assign_vars(array('IS_SUBSCRIBED' => true, 'U_SUBSCRIBE' => titania_url::append_url($url, array('subscribe' => 'unsubscribe', 'hash' => generate_link_hash('unsubscribe')))));
     } else {
         phpbb::$template->assign_vars(array('U_SUBSCRIBE' => titania_url::append_url($url, array('subscribe' => 'subscribe', 'hash' => generate_link_hash('subscribe')))));
     }
 }
示例#3
0
                $new_tag = request_var('id', 0);
                if (!isset($tags[$new_tag])) {
                    trigger_error('NO_TAG');
                }
                $queue->move($new_tag);
            } else {
                // Generate the list of tags we can move it to
                $extra = '<select name="id">';
                foreach ($tags as $tag_id => $row) {
                    $extra .= '<option value="' . $tag_id . '">' . (isset(phpbb::$user->lang[$row['tag_field_name']]) ? phpbb::$user->lang[$row['tag_field_name']] : $row['tag_field_name']) . '</option>';
                }
                $extra .= '</select>';
                phpbb::$template->assign_var('CONFIRM_EXTRA', $extra);
                titania::confirm_box(false, 'MOVE_QUEUE');
            }
            redirect(titania_url::append_url($base_url, array('q' => $queue->queue_id)));
            break;
    }
    // Display the main queue item
    $data = queue_overlord::display_queue_item($queue_id);
    // Handle replying/editing/etc
    $posting_helper = new titania_posting();
    $posting_helper->act('manage/queue_post.html');
    // Display the posts in the queue (after the posting helper acts)
    posts_overlord::display_topic_complete($data['topic']);
    titania::page_header(queue_overlord::$queue[$queue_id]['topic_subject']);
} else {
    // Subscriptions
    titania_subscriptions::handle_subscriptions(TITANIA_QUEUE, $queue_type, titania_url::$current_page_url);
    queue_overlord::display_queue($queue_type, $tag);
    queue_overlord::display_categories($queue_type, $tag);
示例#4
0
             // Subscriptions
             if ($post->topic->topic_last_post_id == $post->post_id) {
                 $email_vars = array('NAME' => $post->topic->topic_subject, 'U_VIEW' => $post->topic->get_url());
                 titania_subscriptions::send_notifications($post->post_type, $post->topic->parent_id, 'subscribe_notify_forum.txt', $email_vars, $post->post_user_id);
             }
         }
         // Notify poster about approval
         if ($post->post_user_id != ANONYMOUS) {
             $lang_path = phpbb::$user->lang_path;
             phpbb::$user->set_custom_lang_path(titania::$config->language_path);
             $messenger = new messenger(false);
             users_overlord::load_users(array($post->post_user_id));
             $email_template = $post->post_id == $post->topic->topic_first_post_id && $post->post_id == $post->topic->topic_last_post_id ? 'topic_approved' : 'post_approved';
             $messenger->template($email_template, users_overlord::get_user($post->post_user_id, 'user_lang'));
             $messenger->to(users_overlord::get_user($post->post_user_id, 'user_email'), users_overlord::get_user($post->post_user_id, '_username'));
             $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode(users_overlord::get_user($post->post_user_id, '_username')), 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post->post_subject)), 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post->topic->topic_subject)), 'U_VIEW_TOPIC' => titania_url::append_url($post->topic->get_url()), 'U_VIEW_POST' => titania_url::append_url($post->get_url())));
             $messenger->send();
             phpbb::$user->set_custom_lang_path($lang_path);
         }
         redirect(titania_url::build_url(titania_url::$current_page));
     }
     users_overlord::load_users(array($post->post_user_id, $post->post_edit_user, $post->post_delete_user));
     users_overlord::assign_details($post->post_user_id, 'POSTER_', true);
     phpbb::$template->assign_vars(array('POST_SUBJECT' => censor_text($post->post_subject), 'POST_DATE' => phpbb::$user->format_date($post->post_time), 'POST_TEXT' => $post->generate_text_for_display(), 'EDITED_MESSAGE' => $post->post_edited ? sprintf(phpbb::$user->lang['EDITED_MESSAGE'], users_overlord::get_user($post->post_edit_user, '_full'), phpbb::$user->format_date($post->post_edited)) : '', 'DELETED_MESSAGE' => $post->post_deleted != 0 ? sprintf(phpbb::$user->lang['DELETED_MESSAGE'], users_overlord::get_user($post->post_delete_user, '_full'), phpbb::$user->format_date($post->post_deleted), $post->get_url('undelete')) : '', 'POST_EDIT_REASON' => censor_text($post->post_edit_reason), 'U_VIEW' => $post->get_url(), 'U_EDIT' => $post->get_url('edit'), 'SECTION_NAME' => '<a href="' . $post->get_url() . '">' . censor_text($post->post_subject) . '</a> - ' . phpbb::$user->lang['ATTENTION']));
     $title = censor_text($post->post_subject);
     break;
 case TITANIA_CONTRIB:
     $contrib = new titania_contribution();
     if (!$contrib->load((int) $object_id)) {
         $attention_object->delete();
         trigger_error('NO_CONTRIB');
示例#5
0
 private function common_delete($post_id, $undelete = false)
 {
     titania::add_lang('posting');
     phpbb::$user->add_lang('posting');
     // Load the stuff we need
     $post_object = $this->load_post($post_id);
     // Check permissions
     if (!$undelete && !$post_object->acl_get('delete') || $undelete && !$post_object->acl_get('undelete')) {
         titania::needs_auth();
     }
     if (titania::confirm_box(true)) {
         if (!$undelete) {
             $redirect_post_id = false;
             // Delete the post
             if (isset($_POST['hard_delete']) || $post_object->post_deleted) {
                 if (!phpbb::$auth->acl_get('u_titania_post_hard_delete')) {
                     titania::needs_auth();
                 }
                 $post_object->hard_delete();
                 // Try to redirect to the next or previous post
                 $redirect_post_id = posts_overlord::next_prev_post_id($post_object->topic_id, $post_object->post_id);
                 if ($redirect_post_id) {
                     redirect(titania_url::append_url($post_object->topic->get_url(), array('p' => $redirect_post_id, '#p' => $redirect_post_id)));
                 }
                 redirect(titania_url::build_url($post_object->topic->topic_url));
             } else {
                 $post_object->soft_delete();
                 if (phpbb::$auth->acl_get('u_titania_mod_post_mod')) {
                     // They can see the post, redirect back to it
                     redirect($post_object->get_url());
                 } else {
                     // They cannot see the post, try to redirect to the next or previous post
                     $redirect_post_id = posts_overlord::next_prev_post_id($post_object->topic_id, $post_object->post_id);
                     if ($redirect_post_id) {
                         redirect(titania_url::append_url($post_object->topic->get_url(), array('p' => $redirect_post_id, '#p' => $redirect_post_id)));
                     }
                 }
             }
             redirect($post_object->topic->get_url());
         } else {
             $post_object->undelete();
             redirect($post_object->get_url());
         }
     } else {
         phpbb::$template->assign_var('S_HARD_DELETE', !$undelete && !$post_object->post_deleted && phpbb::$auth->acl_get('u_titania_post_hard_delete') ? true : false);
         titania::confirm_box(false, !$undelete ? 'DELETE_POST' : 'UNDELETE_POST', '', array(), 'posting/delete_confirm.html');
     }
     redirect($post_object->get_url());
 }
示例#6
0
         // Setup the sort tool to only display the 10 most recent
         $sort = contribs_overlord::build_sort();
         $sort->set_defaults(10);
     }
     // Include the current category in the ones selected
     $child_categories[] = $category_id;
     $data = contribs_overlord::display_contribs('category', $child_categories, $sort);
     // Canonical URL
     $data['sort']->set_url($category_object->get_url());
     phpbb::$template->assign_var('U_CANONICAL', $data['sort']->build_canonical());
 } else {
     // Mark all contribs read
     if (request_var('mark', '') == 'contribs') {
         titania_tracking::track(TITANIA_CONTRIB, 0);
     }
     phpbb::$template->assign_vars(array('CATEGORY_ID' => 0, 'U_MARK_FORUMS' => titania_url::append_url(titania_url::$current_page_url, array('mark' => 'contribs')), 'L_MARK_FORUMS_READ' => phpbb::$user->lang['MARK_CONTRIBS_READ'], 'S_DISPLAY_SEARCHBOX' => true, 'S_SEARCHBOX_ACTION' => titania_url::build_url('find-contribution')));
     // Setup the sort tool to only display the 10 most recent
     $sort = contribs_overlord::build_sort();
     $sort->set_defaults(10);
     $data = contribs_overlord::display_contribs('all', 0, $sort);
     // Canonical URL
     $data['sort']->set_url('');
     phpbb::$template->assign_var('U_CANONICAL', $data['sort']->build_canonical());
 }
 phpbb::$template->assign_vars(array('U_CREATE_CONTRIBUTION' => phpbb::$auth->acl_get('u_titania_contrib_submit') ? titania_url::build_url('author/' . htmlspecialchars_decode(phpbb::$user->data['username_clean']) . '/create') : '', 'S_HAS_CONTRIBS' => $categories_ary && $categories_ary[$category_id]['category_type'] ? true : false));
 if ($category_id != 0) {
     $category_name = isset(phpbb::$user->lang[$category_object->category_name]) ? phpbb::$user->lang[$category_object->category_name] : $category_object->category_name;
     titania::page_header($category_name . ' - ' . phpbb::$user->lang['CUSTOMISATION_DATABASE']);
     titania::page_footer(true, 'index_body.html');
 }
 break;
    function main($id, $mode)
    {
        global $phpbb_root_path;
        define('PHPBB_INCLUDED', true);
        define('USE_PHPBB_TEMPLATE', true);
        define('IN_TITANIA', true);
        if (!defined('PHP_EXT')) {
            define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
        }
        require TITANIA_ROOT . 'common.' . PHP_EXT;
        // Need a few hacks to be used from within phpBB
        titania_url::decode_url(titania::$config->phpbb_script_path);
        titania::$hook->register(array('titania_url', 'build_url'), 'titania_outside_build_url', 'standalone');
        titania::$hook->register(array('titania_url', 'append_url'), 'titania_outside_build_url', 'standalone');
        titania::$hook->register(array('titania', 'page_header'), 'titania_outside_page_header', 'standalone');
        titania::$hook->register(array('titania', 'page_footer'), 'titania_outside_page_footer', 'standalone');
        $this->p_master->assign_tpl_vars(phpbb::append_sid('ucp'));
        // Include some files
        titania::_include('functions_display', 'titania_topic_folder_img');
        // Setup the sort tool
        $sort = new titania_sort();
        $sort->default_limit = phpbb::$config['topics_per_page'];
        $sort->request();
        // Start initial var setup
        $url = $this->u_action;
        add_form_key('ucp_front_subscription');
        // User wants to unsubscribe?
        if (isset($_POST['unsubscribe'])) {
            if (check_form_key('ucp_front_subscription')) {
                $sections = request_var('sections', array(0 => array(0 => 0)));
                $items = request_var('items', array(0 => array(0 => 0)));
                $subscriptions = $sections + $items;
                if (sizeof($subscriptions)) {
                    foreach ($subscriptions as $type => $type_id) {
                        $object_ids = array_keys($type_id);
                        foreach ($object_ids as $object_id) {
                            $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . '
								WHERE watch_user_id = ' . phpbb::$user->data['user_id'] . '
								AND watch_object_type = ' . $type . '
								AND watch_object_id = ' . $object_id;
                            phpbb::$db->sql_query($sql);
                        }
                    }
                } else {
                    $msg = phpbb::$user->lang['NO_SUBSCRIPTIONS_SELECTED'];
                }
            } else {
                $msg = phpbb::$user->lang['FORM_INVALID'];
            }
            if (isset($msg)) {
                meta_refresh(3, $url);
                $message = $msg . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $url . '">', '</a>');
                trigger_error($message);
            }
        }
        switch ($mode) {
            case 'subscription_items':
                $array_items = array(TITANIA_CONTRIB, TITANIA_TOPIC);
                // We prepare pagination stuff
                $sql = 'SELECT COUNT(*) AS subscription_count
					FROM ' . TITANIA_WATCH_TABLE . '
					WHERE ' . phpbb::$db->sql_in_set('watch_object_type', $array_items) . '
						AND watch_user_id = ' . phpbb::$user->data['user_id'];
                phpbb::$db->sql_query($sql);
                $subscription_count = phpbb::$db->sql_fetchfield('subscription_count');
                phpbb::$db->sql_freeresult();
                $sort->total = $subscription_count;
                $sort->build_pagination($url);
                $sql_ary = array('SELECT' => '*,
						CASE w.watch_object_type
							WHEN ' . TITANIA_CONTRIB . ' THEN c.contrib_last_update
							WHEN ' . TITANIA_TOPIC . ' THEN t.topic_last_post_time
						END AS time', 'FROM' => array(TITANIA_WATCH_TABLE => 'w'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => '(w.watch_object_type = ' . TITANIA_CONTRIB . ')
								AND c.contrib_id = w.watch_object_id'), array('FROM' => array(TITANIA_TOPICS_TABLE => 't'), 'ON' => 'w.watch_object_type = ' . TITANIA_TOPIC . '
								AND t.topic_id = w.watch_object_id')), 'WHERE' => 'w.watch_user_id = ' . phpbb::$user->data['user_id'] . '
						AND ' . phpbb::$db->sql_in_set('watch_object_type', $array_items), 'ORDER_BY' => 'time DESC');
                // Additional tracking for support topics
                titania_tracking::get_track_sql($sql_ary, TITANIA_TOPIC, 't.topic_id');
                titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tsa');
                titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 't.parent_id', 'tsc');
                titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt');
                // Tracking for contributions
                titania_tracking::get_track_sql($sql_ary, TITANIA_CONTRIB, 'c.contrib_id', 'tc');
                $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
                // Get the data
                $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
                $user_ids = $rows = array();
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $rows[] = $row;
                    titania_tracking::store_from_db($row);
                    if ($row['watch_object_type'] == TITANIA_TOPIC) {
                        $user_ids[] = $row['topic_first_post_user_id'];
                        $user_ids[] = $row['topic_last_post_user_id'];
                    } else {
                        if ($row['watch_object_type'] == TITANIA_CONTRIB) {
                            $user_ids[] = $row['contrib_user_id'];
                        }
                    }
                }
                phpbb::$db->sql_freeresult($result);
                // Get user data
                users_overlord::load_users($user_ids);
                foreach ($rows as $row) {
                    $folder_img = $folder_alt = '';
                    if ($row['watch_object_type'] == TITANIA_TOPIC) {
                        if (!$row['topic_id']) {
                            // Topic was deleted
                            $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . '
								WHERE watch_object_type = ' . (int) $row['watch_object_type'] . '
									AND watch_object_id = ' . (int) $row['watch_object_id'];
                            phpbb::$db->sql_query($sql);
                            continue;
                        }
                        $topic = new titania_topic();
                        $topic->__set_array($row);
                        $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0);
                        $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true);
                        $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true);
                        $tpl_block = 'items';
                        $subscription_target = '';
                        if ($row['topic_type'] == TITANIA_QUEUE_DISCUSSION) {
                            $subscription_target = phpbb::$user->lang['SUBSCRIPTION_QUEUE_VALIDATION'];
                        }
                        if ($row['topic_type'] == TITANIA_QUEUE) {
                            $subscription_target = phpbb::$user->lang['SUBSCRIPTION_QUEUE'];
                        }
                        if ($row['topic_type'] == TITANIA_SUPPORT) {
                            $subscription_target = phpbb::$user->lang['SUBSCRIPTION_SUPPORT_TOPIC'];
                        }
                        // Tracking check
                        $last_read_mark = titania_tracking::get_track(TITANIA_TOPIC, $topic->topic_id, true);
                        $last_read_mark = max($last_read_mark, titania_tracking::find_last_read_mark($topic->additional_unread_fields, $topic->topic_type, $topic->parent_id));
                        $topic->unread = $topic->topic_last_post_time > $last_read_mark ? true : false;
                        // Get the folder image
                        $topic->topic_folder_img($folder_img, $folder_alt);
                        $vars = array('LAST_POST_IMG' => phpbb::$user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['topic_first_post_user_id'], '_full'), 'SUBSCRIPTION_ID' => $row['topic_id'], 'SUBSCRIPTION_LAST_AUTHOR_FULL' => users_overlord::get_user($row['topic_last_post_user_id'], '_full'), 'SUBSCRIPTION_LAST_TIME' => phpbb::$user->format_date($row['topic_last_post_time']), 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['topic_time']), 'SUBSCRIPTION_TARGET' => $subscription_target, 'SUBSCRIPTION_TITLE' => censor_text($row['topic_subject']), 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'U_VIEW_SUBSCRIPTION' => $topic->get_url(), 'U_VIEW_LAST_POST' => titania_url::append_url($topic->get_url(), array('p' => $topic->topic_last_post_id, '#p' => $topic->topic_last_post_id)), 'S_ACCESS_TEAMS' => $row['topic_access'] == TITANIA_ACCESS_TEAMS || $row['topic_type'] == TITANIA_QUEUE ? true : false, 'S_ACCESS_AUTHORS' => $row['topic_access'] == TITANIA_ACCESS_AUTHORS ? true : false, 'S_TOPIC' => true);
                    } else {
                        if ($row['watch_object_type'] == TITANIA_CONTRIB) {
                            $tpl_block = 'items';
                            $contrib = new titania_contribution();
                            $contrib->__set_array($row);
                            titania_topic_folder_img($folder_img, $folder_alt, 0, titania_tracking::is_unread(TITANIA_CONTRIB, $contrib->contrib_id, $contrib->contrib_last_update));
                            $vars = array('SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['contrib_user_id'], '_full'), 'SUBSCRIPTION_CONTRIB_TYPE' => titania_types::$types[$contrib->contrib_type]->lang, 'SUBSCRIPTION_DOWNLOADS' => $row['contrib_downloads'], 'SUBSCRIPTION_ID' => $row['contrib_id'], 'SUBSCRIPTION_TARGET' => phpbb::$user->lang['SUBSCRIPTION_CONTRIB'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['contrib_last_update']), 'SUBSCRIPTION_TITLE' => $row['contrib_name'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'SUBSCRIPTION_VIEWS' => $row['contrib_views'], 'U_VIEW_SUBSCRIPTION' => $contrib->get_url(), 'S_CONTRIB' => true);
                        }
                    }
                    phpbb::$template->assign_block_vars($tpl_block, array_merge($vars, array('FOLDER_IMG' => phpbb::$user->img($folder_img, $folder_alt), 'FOLDER_IMG_SRC' => phpbb::$user->img($folder_img, $folder_alt, false, '', 'src'), 'FOLDER_IMG_ALT' => phpbb::$user->lang[$folder_alt], 'FOLDER_IMG_WIDTH' => phpbb::$user->img($folder_img, '', false, '', 'width'), 'FOLDER_IMG_HEIGHT' => phpbb::$user->img($folder_img, '', false, '', 'height'))));
                }
                break;
            case 'subscription_sections':
                $array_items = array(TITANIA_SUPPORT, TITANIA_QUEUE, TITANIA_ATTENTION);
                // We prepare pagination stuff
                $sql = 'SELECT COUNT(*) AS subscription_count
					FROM ' . TITANIA_WATCH_TABLE . '
					WHERE ' . phpbb::$db->sql_in_set('watch_object_type', $array_items) . '
					AND watch_user_id = ' . phpbb::$user->data['user_id'];
                phpbb::$db->sql_query($sql);
                $subscription_count = phpbb::$db->sql_fetchfield('subscription_count');
                phpbb::$db->sql_freeresult();
                $sort->total = $subscription_count;
                $sort->build_pagination($url);
                $sql_ary = array('SELECT' => '*,
						CASE w.watch_object_type
							WHEN ' . TITANIA_SUPPORT . ' THEN c.contrib_last_update
						END AS time', 'FROM' => array(TITANIA_WATCH_TABLE => 'w'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => '(w.watch_object_type = ' . TITANIA_SUPPORT . ')
								AND c.contrib_id = w.watch_object_id')), 'WHERE' => 'w.watch_user_id = ' . phpbb::$user->data['user_id'] . '
						AND ' . phpbb::$db->sql_in_set('watch_object_type', $array_items), 'ORDER_BY' => 'time DESC');
                $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
                // Get the data
                $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
                $user_ids = array();
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $rows[] = $row;
                    $user_ids[] = $row['contrib_user_id'];
                }
                phpbb::$db->sql_freeresult($result);
                // Get user data
                users_overlord::load_users($user_ids);
                if (isset($rows)) {
                    foreach ($rows as $row) {
                        if ($row['watch_object_type'] == TITANIA_SUPPORT) {
                            $tpl_block = 'sections';
                            $contrib = new titania_contribution();
                            $contrib->__set_array($row);
                            $vars = array('SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['contrib_user_id'], '_full'), 'SUBSCRIPTION_ID' => $row['watch_object_id'], 'SUBSCRIPTION_TARGET' => phpbb::$user->lang['SUBSCRIPTION_SUPPORT'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['contrib_last_update']), 'SUBSCRIPTION_TITLE' => $row['contrib_name'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'U_VIEW_SUBSCRIPTION' => $contrib->get_url('support'));
                        } else {
                            if ($row['watch_object_type'] == TITANIA_ATTENTION) {
                                $tpl_block = 'sections';
                                $vars = array('SUBSCRIPTION_ID' => $row['watch_object_id'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['watch_mark_time']), 'SUBSCRIPTION_TITLE' => phpbb::$user->lang['SUBSCRIPTION_ATTENTION'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'S_ATTENTION' => true, 'S_ACCESS_TEAMS' => true, 'U_VIEW_SUBSCRIPTION' => titania_url::build_url('manage/attention'));
                            } else {
                                if ($row['watch_object_type'] == TITANIA_QUEUE) {
                                    $tpl_block = 'sections';
                                    $queue_id = $row['watch_object_id'];
                                    // Setup the base url we will use
                                    $base_url = titania_url::build_url('manage/queue');
                                    $vars = array('SUBSCRIPTION_ID' => $queue_id, 'SUBSCRIPTION_TARGET' => titania_types::$types[$queue_id]->lang, 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['watch_mark_time']), 'SUBSCRIPTION_TITLE' => phpbb::$user->lang['SUBSCRIPTION_QUEUE'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'S_QUEUE' => true, 'S_ACCESS_TEAMS' => true, 'U_VIEW_SUBSCRIPTION' => titania_url::append_url($base_url, array('queue' => titania_types::$types[$queue_id]->url)));
                                }
                            }
                        }
                        phpbb::$template->assign_block_vars($tpl_block, $vars);
                    }
                }
                break;
        }
        phpbb::$template->assign_vars(array('S_ACTION' => $url, 'TITANIA_THEME_PATH' => titania::$absolute_path . 'styles/' . titania::$config->style . '/theme/'));
        titania::page_header(phpbb::$user->lang['SUBSCRIPTION_TITANIA']);
        titania::page_footer(true, 'manage/' . $mode . '.html');
    }
示例#8
0
phpbb::$user->add_lang('viewforum');
if ($topic_id) {
    // Subscriptions
    titania_subscriptions::handle_subscriptions(TITANIA_TOPIC, $topic_id, $topic->get_url());
    // Check access level
    if ($topic->topic_access < titania::$access_level || $topic->topic_type == TITANIA_QUEUE_DISCUSSION && !titania::$contrib->is_author && !titania::$contrib->is_active_coauthor && !titania_types::$types[titania::$contrib->contrib_type]->acl_get('queue_discussion')) {
        titania::needs_auth();
    }
    posts_overlord::display_topic_complete($topic);
    titania::page_header(censor_text($topic->topic_subject) . ' - ' . titania::$contrib->contrib_name);
    if (phpbb::$auth->acl_get('u_titania_post')) {
        phpbb::$template->assign_var('U_POST_REPLY', titania_url::append_url($topic->get_url(), array('action' => 'reply')));
    }
    // Canonical URL
    phpbb::$template->assign_var('U_CANONICAL', $topic->get_url());
} else {
    // Subscriptions
    titania_subscriptions::handle_subscriptions(TITANIA_SUPPORT, titania::$contrib->contrib_id, titania::$contrib->get_url('support'));
    // Mark all topics read
    if (request_var('mark', '') == 'topics') {
        titania_tracking::track(TITANIA_SUPPORT, titania::$contrib->contrib_id);
    }
    $data = topics_overlord::display_forums_complete('support', titania::$contrib);
    titania::page_header(titania::$contrib->contrib_name . ' - ' . phpbb::$user->lang['CONTRIB_SUPPORT']);
    if (phpbb::$auth->acl_get('u_titania_topic') && titania::$config->support_in_titania) {
        phpbb::$template->assign_var('U_POST_TOPIC', titania_url::append_url(titania::$contrib->get_url('support'), array('action' => 'post')));
    }
    $data['sort']->set_url(titania::$contrib->get_url('support'));
    phpbb::$template->assign_vars(array('U_MARK_TOPICS' => titania_url::append_url(titania::$contrib->get_url('support'), array('mark' => 'topics')), 'U_CANONICAL' => $data['sort']->build_canonical(), 'S_DISPLAY_SEARCHBOX' => true, 'S_SEARCHBOX_ACTION' => titania_url::build_url('search', array('type' => TITANIA_SUPPORT, 'contrib' => titania::$contrib->contrib_id))));
}
titania::page_footer(true, 'contributions/contribution_support.html');
示例#9
0
            // Update the queue (make visible)
            $revision->update_queue();
            if ($repack && titania::$config->use_queue && titania_types::$types[titania::$contrib->contrib_type]->use_queue) {
                redirect(titania_url::build_url('manage/queue', array('q' => $revision->revision_queue_id)));
            }
            // Subscriptions
            $queue = $revision->get_queue();
            if ($queue) {
                $email_vars = array('NAME' => phpbb::$user->lang['VALIDATION'] . ' - ' . titania::$contrib->contrib_name . ' - ' . $revision->revision_version, 'U_VIEW' => titania_url::build_url('manage/queue', array('q' => $queue->queue_id)));
                titania_subscriptions::send_notifications(TITANIA_QUEUE, titania::$contrib->contrib_type, 'subscribe_notify_forum.txt', $email_vars, phpbb::$user->data['user_id']);
            }
            redirect(titania::$contrib->get_url());
            break;
    }
} while ($try_again);
phpbb::$template->assign_vars(array('ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : '', 'NEXT_STEP' => $next_step, 'REVISION_ID' => $revision_id, 'AGREEMENT_NOTICE' => titania_types::$types[titania::$contrib->contrib_type]->upload_agreement ? isset(phpbb::$user->lang[titania_types::$types[titania::$contrib->contrib_type]->upload_agreement]) ? nl2br(phpbb::$user->lang[titania_types::$types[titania::$contrib->contrib_type]->upload_agreement]) : nl2br(titania_types::$types[titania::$contrib->contrib_type]->upload_agreement) : false, 'QUEUE_ALLOW_REPACK' => true, 'S_POST_ACTION' => $repack ? titania_url::append_url(titania::$contrib->get_url('revision'), array('repack' => $repack)) : titania::$contrib->get_url('revision')));
// Output the available license options
foreach (titania_types::$types[titania::$contrib->contrib_type]->license_options as $option) {
    phpbb::$template->assign_block_vars('license_options', array('NAME' => $option, 'VALUE' => $option));
}
// Display the list of phpBB versions available
/*$allowed_branches = get_allowed_phpbb_branches();
foreach ($phpbb_versions as $version => $name)
{
	if (!isset($allowed_branches[substr($version, 0, 2)]))
	{
		continue;
	}

	$template->assign_block_vars('phpbb_versions', array(
		'VERSION'		=> $name,
示例#10
0
 /**
  * Assign the common items to the template
  *
  * @param bool $return True to return the array of stuff to display and output yourself, false to output to the template automatically
  */
 public function assign_display($return = false)
 {
     $display = array('CATEGORY_NAME' => isset(phpbb::$user->lang[$this->category_name]) ? phpbb::$user->lang[$this->category_name] : $this->category_name, 'CATEGORY_CONTRIBS' => $this->category_contribs, 'CATEGORY_TYPE' => $this->category_type, 'CATEGORY_DESC' => $this->generate_text_for_display(), 'U_MOVE_UP' => titania_url::append_url($this->get_manage_url(), array('action' => 'move_up')), 'U_MOVE_DOWN' => titania_url::append_url($this->get_manage_url(), array('action' => 'move_down')), 'U_EDIT' => titania_url::append_url($this->get_manage_url(), array('action' => 'edit')), 'U_DELETE' => titania_url::append_url($this->get_manage_url(), array('action' => 'delete')), 'U_VIEW_CATEGORY' => $this->get_url(), 'U_VIEW_MANAGE_CATEGORY' => $this->get_manage_url(), 'HAS_CHILDREN' => $this->right_id - $this->left_id > 1 ? true : false);
     if ($return) {
         return $display;
     }
     phpbb::$template->assign_vars($display);
 }
示例#11
0
 /**
  * Build view URL for a faq
  *
  * @param string $action
  * @param int $faq_id
  *
  * @return string
  */
 public function get_url($action = '', $faq_id = false)
 {
     $url = titania::$contrib->get_url('faq');
     $faq_id = $faq_id ? $faq_id : $this->faq_id;
     if ($action == 'create') {
         return titania_url::append_url($url, array('action' => $action));
     } else {
         if (!$action) {
             return titania_url::append_url($url, array('f' => $faq_id));
         }
     }
     return titania_url::append_url($url, array('action' => $action, 'f' => $faq_id));
 }
示例#12
0
 /**
  * Assign details
  *
  * A little different from those in other classes, this one only returns the info ready for output
  */
 public function assign_details()
 {
     // Tracking check
     $last_read_mark = titania_tracking::get_track(TITANIA_TOPIC, $this->topic_id, true);
     $last_read_mark = max($last_read_mark, titania_tracking::find_last_read_mark($this->additional_unread_fields, $this->topic_type, $this->parent_id));
     $this->unread = $this->topic_last_post_time > $last_read_mark ? true : false;
     $folder_img = $folder_alt = '';
     $this->topic_folder_img($folder_img, $folder_alt);
     // To find out if we have any posts that need approval
     $approved = titania_count::from_db($this->topic_posts, titania_count::get_flags(TITANIA_ACCESS_PUBLIC, false, false));
     $total = titania_count::from_db($this->topic_posts, titania_count::get_flags(TITANIA_ACCESS_PUBLIC, false, true));
     $details = array('TOPIC_ID' => $this->topic_id, 'TOPIC_TYPE' => $this->topic_type, 'TOPIC_ACCESS' => $this->topic_access, 'TOPIC_STATUS' => $this->topic_status, 'TOPIC_STICKY' => $this->topic_sticky, 'TOPIC_LOCKED' => $this->topic_locked, 'POSTS_APPROVED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') && $total > $approved ? false : true, 'TOPIC_APPROVED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->topic_approved : true, 'TOPIC_REPORTED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->topic_reported : false, 'TOPIC_ASSIGNED' => $this->topic_assigned, 'TOPIC_REPLIES' => $this->get_postcount() - 1, 'TOPIC_VIEWS' => $this->topic_views, 'TOPIC_SUBJECT' => censor_text($this->topic_subject), 'TOPIC_FIRST_POST_ID' => $this->topic_first_post_id, 'TOPIC_FIRST_POST_USER_ID' => $this->topic_first_post_user_id, 'TOPIC_FIRST_POST_USER_COLOUR' => $this->topic_first_post_user_colour, 'TOPIC_FIRST_POST_USER_FULL' => get_username_string('full', $this->topic_first_post_user_id, $this->topic_first_post_username, $this->topic_first_post_user_colour, false, phpbb::append_sid('memberlist', 'mode=viewprofile')), 'TOPIC_FIRST_POST_TIME' => phpbb::$user->format_date($this->topic_first_post_time), 'TOPIC_LAST_POST_ID' => $this->topic_last_post_id, 'TOPIC_LAST_POST_USER_ID' => $this->topic_last_post_user_id, 'TOPIC_LAST_POST_USER_COLOUR' => $this->topic_last_post_user_colour, 'TOPIC_LAST_POST_USER_FULL' => get_username_string('full', $this->topic_last_post_user_id, $this->topic_last_post_username, $this->topic_last_post_user_colour, false, phpbb::append_sid('memberlist', 'mode=viewprofile')), 'TOPIC_LAST_POST_TIME' => phpbb::$user->format_date($this->topic_last_post_time), 'TOPIC_LAST_POST_SUBJECT' => censor_text($this->topic_last_post_subject), 'U_NEWEST_POST' => $this->unread ? titania_url::append_url($this->get_url(), array('view' => 'unread', '#' => 'unread')) : '', 'U_VIEW_TOPIC' => $this->get_url(), 'U_VIEW_LAST_POST' => titania_url::append_url($this->get_url(), array('p' => $this->topic_last_post_id, '#p' => $this->topic_last_post_id)), 'S_UNREAD_TOPIC' => $this->unread ? true : false, 'S_ACCESS_TEAMS' => $this->topic_access == TITANIA_ACCESS_TEAMS ? true : false, 'S_ACCESS_AUTHORS' => $this->topic_access == TITANIA_ACCESS_AUTHORS ? true : false, 'FOLDER_IMG' => phpbb::$user->img($folder_img, $folder_alt), 'FOLDER_IMG_SRC' => phpbb::$user->img($folder_img, $folder_alt, false, '', 'src'), 'FOLDER_IMG_ALT' => phpbb::$user->lang[$folder_alt], 'FOLDER_IMG_WIDTH' => phpbb::$user->img($folder_img, '', false, '', 'width'), 'FOLDER_IMG_HEIGHT' => phpbb::$user->img($folder_img, '', false, '', 'height'));
     // Hooks
     titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $details, $this);
     return $details;
 }
示例#13
0
 /**
  * Return if there is a preview image and assign block vars if necessary
  */
 public function preview_image()
 {
     foreach ($this->attachments as $attachment_id => $attachment) {
         if (!sizeof($attachment) || !$attachment['is_preview']) {
             continue;
         }
         $block_array = array();
         // Some basics...
         $attachment['extension'] = strtolower(trim($attachment['extension']));
         $filename = titania::$config->upload_path . $attachment['attachment_directory'] . '/' . utf8_basename($attachment['attachment_directory']) . '/' . utf8_basename($attachment['physical_filename']);
         $thumbnail_filename = titania::$config->upload_path . $attachment['attachment_directory'] . '/' . utf8_basename($attachment['attachment_directory']) . '/thumb_' . utf8_basename($attachment['physical_filename']);
         $filesize = get_formatted_filesize($attachment['filesize'], false);
         $comment = bbcode_nl2br(censor_text($attachment['attachment_comment']));
         $block_array += array('FILESIZE' => $filesize['value'], 'SIZE_LANG' => $filesize['unit'], 'DOWNLOAD_NAME' => utf8_basename($attachment['real_filename']), 'COMMENT' => $comment);
         $l_downloaded_viewed = $download_link = '';
         $display_cat = strpos($attachment['mimetype'], 'image') === 0 ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE;
         // @todo Probably should add support for more types...
         if ($display_cat == ATTACHMENT_CATEGORY_IMAGE) {
             if ($attachment['thumbnail']) {
                 $display_cat = ATTACHMENT_CATEGORY_THUMB;
             } else {
                 if (phpbb::$config['img_display_inlined']) {
                     if (phpbb::$config['img_link_width'] || phpbb::$config['img_link_height']) {
                         $dimension = @getimagesize($filename);
                         // If the dimensions could not be determined or the image being 0x0 we display it as a link for safety purposes
                         if ($dimension === false || empty($dimension[0]) || empty($dimension[1])) {
                             $display_cat = ATTACHMENT_CATEGORY_NONE;
                         } else {
                             $display_cat = $dimension[0] <= phpbb::$config['img_link_width'] && $dimension[1] <= phpbb::$config['img_link_height'] ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE;
                         }
                     }
                 } else {
                     $display_cat = ATTACHMENT_CATEGORY_NONE;
                 }
             }
         }
         // Make some descisions based on user options being set.
         if (($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !phpbb::$user->optionget('viewimg')) {
             $display_cat = ATTACHMENT_CATEGORY_NONE;
         }
         $download_link = titania_url::build_url('download', array('id' => $attachment['attachment_id']));
         switch ($display_cat) {
             // Images
             case ATTACHMENT_CATEGORY_IMAGE:
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 $download_link = titania_url::append_url($download_link, array('mode' => 'view'));
                 $block_array += array('S_IMAGE' => true, 'U_INLINE_LINK' => titania_url::append_url($download_link, array('mode' => 'view')));
                 break;
                 // Images, but display Thumbnail
             // Images, but display Thumbnail
             case ATTACHMENT_CATEGORY_THUMB:
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 $download_link = titania_url::append_url($download_link, array('mode' => 'view'));
                 $block_array += array('S_THUMBNAIL' => true, 'THUMB_IMAGE' => titania_url::append_url($download_link, array('mode' => 'view', 'thumb' => 1)));
                 break;
             default:
                 $l_downloaded_viewed = 'DOWNLOAD_COUNT';
                 $block_array += array('S_FILE' => true);
                 break;
         }
         $l_download_count = !isset($attachment['download_count']) || $attachment['download_count'] == 0 ? phpbb::$user->lang[$l_downloaded_viewed . '_NONE'] : ($attachment['download_count'] == 1 ? sprintf(phpbb::$user->lang[$l_downloaded_viewed], $attachment['download_count']) : sprintf(phpbb::$user->lang[$l_downloaded_viewed . 'S'], $attachment['download_count']));
         $block_array += array('U_DOWNLOAD_LINK' => $download_link, 'L_DOWNLOAD_COUNT' => $l_download_count);
     }
     if (!empty($block_array)) {
         phpbb::$template->assign_block_vars('preview', $block_array);
         return true;
     } else {
         return false;
     }
 }
示例#14
0
    /**
     * Display the categories (tags)
     *
     * @param int $type
     */
    public static function display_categories($type, $selected = false)
    {
        $tags = titania::$cache->get_tags(TITANIA_QUEUE);
        $tag_count = array();
        $total = 0;
        $sql = 'SELECT queue_status, COUNT(queue_id) AS cnt FROM ' . TITANIA_QUEUE_TABLE . '
			WHERE queue_type = ' . (int) $type . '
			GROUP BY queue_status';
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $total += $row['queue_status'] > 0 ? $row['cnt'] : 0;
            $tag_count[$row['queue_status']] = $row['cnt'];
        }
        phpbb::$db->sql_freeresult($result);
        phpbb::$template->assign_block_vars('queue_tags', array('TAG_NAME' => phpbb::$user->lang['ALL'], 'TAG_COUNT' => $total, 'U_VIEW_TAG' => titania_url::append_url(titania_url::$current_page_url, array('tag' => 'all', 'start' => '*destroy*')), 'S_SELECTED' => $selected == 0 ? true : false));
        foreach ($tags as $tag_id => $row) {
            if (!isset($tag_count[$tag_id])) {
                // Hide empty ones
                continue;
            }
            phpbb::$template->assign_block_vars('queue_tags', array('TAG_NAME' => isset(phpbb::$user->lang[$row['tag_field_name']]) ? phpbb::$user->lang[$row['tag_field_name']] : $row['tag_field_name'], 'TAG_COUNT' => $tag_count[$tag_id], 'U_VIEW_TAG' => titania_url::append_url(titania_url::$current_page_url, array('tag' => $tag_id, 'start' => '*destroy*')), 'S_SELECTED' => $selected == $tag_id ? true : false));
        }
    }
        if (sizeof($authed) == 1) {
            $queue_type = $authed[0];
        } else {
            foreach ($authed as $type_id) {
                $sql = 'SELECT COUNT(topic_id) AS cnt FROM ' . TITANIA_TOPICS_TABLE . '
				WHERE topic_type = ' . TITANIA_QUEUE_DISCUSSION . '
					AND topic_category = ' . (int) $type_id;
                phpbb::$db->sql_query($sql);
                $cnt = phpbb::$db->sql_fetchfield('cnt');
                phpbb::$db->sql_freeresult();
                phpbb::$template->assign_block_vars('categories', array('U_VIEW_CATEGORY' => titania_url::append_url($base_url, array('queue' => titania_types::$types[$type_id]->url)), 'CATEGORY_NAME' => titania_types::$types[$type_id]->lang, 'CATEGORY_CONTRIBS' => $cnt));
            }
            phpbb::$template->assign_vars(array('S_QUEUE_LIST' => true));
            titania::page_header('QUEUE_DISCUSSION');
            titania::page_footer(true, 'manage/queue.html');
        }
    }
} else {
    if (!titania_types::$types[$queue_type]->acl_get('queue_discussion')) {
        titania::needs_auth();
    }
}
// Add the queue type to the base url
$base_url = titania_url::append_url($base_url, array('queue' => titania_types::$types[$queue_type]->url));
// Add to Breadcrumbs
titania::generate_breadcrumbs(array(titania_types::$types[$queue_type]->lang => $base_url));
topics_overlord::display_forums_complete('queue_discussion', false, array('topic_category' => $queue_type));
// Mark all topics read
phpbb::$template->assign_var('U_MARK_TOPICS', titania_url::append_url($base_url, array('mark' => 'topics')));
titania::page_header('QUEUE_DISCUSSION');
titania::page_footer(true, 'manage/queue_discussion.html');
示例#16
0
                    titania::$contrib->change_permalink($permalink);
                }
            }
            // Submit the changes
            titania::$contrib->submit();
            // Set the coauthors
            titania::$contrib->set_coauthors($active_coauthors_list, $nonactive_coauthors_list, true);
            // Create relations
            titania::$contrib->put_contrib_in_categories($contrib_categories);
            // Update the release topic
            titania::$contrib->update_release_topic();
            if ($change_owner == '') {
                redirect(titania::$contrib->get_url());
            } else {
                $s_hidden_fields = array('submit' => true, 'change_owner' => $change_owner, 'change_owner_id' => $change_owner_id);
                titania::confirm_box(false, sprintf(phpbb::$user->lang['CONTRIB_CONFIRM_OWNER_CHANGE'], '<a href="' . phpbb::append_sid('memberlist', 'mode=viewprofile&amp;u=' . $change_owner_id) . '">' . $change_owner . '</a>'), titania_url::append_url(titania_url::$current_page), $s_hidden_fields);
            }
        }
    } else {
        $sql = 'SELECT category_id
		FROM ' . TITANIA_CONTRIB_IN_CATEGORIES_TABLE . '
		WHERE contrib_id = ' . titania::$contrib->contrib_id;
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $contrib_categories[] = $row['category_id'];
        }
        phpbb::$db->sql_freeresult($result);
        $active_coauthors = $nonactive_coauthors = array();
        foreach (titania::$contrib->coauthors as $row) {
            // User does not exist anymore...
            if (users_overlord::get_user($row['user_id'], 'user_id') != $row['user_id']) {
示例#17
0
 /**
  * Build the quick moderation actions for output for this topic
  *
  * @param mixed $topic
  */
 public static function build_quick_actions($topic)
 {
     // Auth check
     $is_authed = false;
     if (phpbb::$auth->acl_get('u_titania_mod_post_mod')) {
         $is_authed = true;
     } else {
         if (phpbb::$auth->acl_get('u_titania_post_mod_own')) {
             if (is_object(titania::$contrib) && titania::$contrib->contrib_id == $topic->parent_id && titania::$contrib->is_author || titania::$contrib->is_active_coauthor) {
                 $is_authed = true;
             } else {
                 if (!is_object(titania::$contrib) || !titania::$contrib->contrib_id == $topic->parent_id) {
                     $contrib = new titania_contribution();
                     $contrib->load((int) $topic->parent_id);
                     if ($contrib->is_author || $contrib->is_active_coauthor) {
                         $is_authed = true;
                     }
                 }
             }
         }
     }
     if (!$is_authed) {
         return;
     }
     $actions = array('MAKE_NORMAL' => $topic->topic_sticky ? titania_url::append_url(titania_url::$current_page_url, array('action' => 'unsticky_topic')) : false, 'MAKE_STICKY' => !$topic->topic_sticky ? titania_url::append_url(titania_url::$current_page_url, array('action' => 'sticky_topic')) : false, 'LOCK_TOPIC' => !$topic->topic_locked ? titania_url::append_url(titania_url::$current_page_url, array('action' => 'lock_topic')) : false, 'UNLOCK_TOPIC' => $topic->topic_locked ? titania_url::append_url(titania_url::$current_page_url, array('action' => 'unlock_topic')) : false, 'SOFT_DELETE_TOPIC' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'delete_topic')), 'UNDELETE_TOPIC' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'undelete_topic')));
     if (phpbb::$auth->acl_get('u_titania_post_hard_delete')) {
         $actions = array_merge($actions, array('HARD_DELETE_TOPIC' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'hard_delete_topic'))));
     }
     phpbb::$template->assign_var('TOPIC_QUICK_ACTIONS', titania::build_quick_actions($actions));
 }
示例#18
0
 /**
  * Get rating string
  *
  * @return string The rating string ready for output
  */
 public function get_rating_string()
 {
     $can_rate = !$this->cannot_rate && phpbb::$user->data['is_registered'] && phpbb::$auth->acl_get('u_titania_rate') && !$this->rating_id ? true : false;
     $rate_url = titania_url::build_url('rate', array('type' => $this->rating_type, 'id' => $this->rating_object_id));
     // If it has not had any ratings yet, give it 1/2 the max for the rating
     if ($this->rating_count == 0) {
         $this->rating = round(titania::$config->max_rating / 2, 1);
     }
     phpbb::$template->set_filenames(array('rate' => 'common/rate.html'));
     phpbb::$template->assign_vars(array('OBJECT_ID' => $this->rating_object_id, 'OBJECT_RATING' => round($this->rating), 'RATE_URL' => $rate_url, 'S_HAS_RATED' => $this->rating_id ? true : false, 'S_CAN_RATE' => $can_rate, 'UA_GREY_STAR_SRC' => titania::$theme_path . '/images/star_grey.gif', 'UA_GREEN_STAR_SRC' => titania::$theme_path . '/images/star_green.gif', 'UA_RED_STAR_SRC' => titania::$theme_path . '/images/star_red.gif', 'UA_ORANGE_STAR_SRC' => titania::$theme_path . '/images/star_orange.gif', 'UA_REMOVE_STAR_SRC' => titania::$theme_path . '/images/star_remove.gif', 'UA_MAX_RATING' => titania::$config->max_rating));
     // reset the stars block
     phpbb::$template->destroy_block_vars('stars');
     for ($i = 1; $i <= titania::$config->max_rating; $i++) {
         $rating = !$can_rate ? $this->rating : ($this->rating_value ? $this->rating_value : $i);
         phpbb::$template->assign_block_vars('stars', array('ALT' => $rating . '/' . titania::$config->max_rating, 'ID' => $i, 'RATE_URL' => titania_url::append_url($rate_url, array('value' => $i))));
     }
     return phpbb::$template->assign_display('rate', '', true);
 }
示例#19
0
 /**
  * General attachment parsing
  * From phpBB (includes/functions_content.php)
  *
  * @param string &$message The message
  * @param string $tpl The template file to use
  * @param bool $preview true if previewing from the posting page
  * @param string|bool $template_block If not false we will output the parsed attachments to this template block
  *
  * @return array the parsed attachments
  */
 public function parse_attachments(&$message, $tpl = 'common/attachment.html', $preview = false, $template_block = false)
 {
     if (!sizeof($this->attachments)) {
         return array();
     }
     phpbb::$user->add_lang('viewtopic');
     $compiled_attachments = array();
     if ($tpl !== false && !isset(phpbb::$template->filename['titania_attachment_tpl'])) {
         phpbb::$template->set_filenames(array('titania_attachment_tpl' => $tpl));
     }
     // Sort correctly
     if (phpbb::$config['display_order']) {
         // Ascending sort
         krsort($this->attachments);
     } else {
         // Descending sort
         ksort($this->attachments);
     }
     foreach ($this->attachments as $attachment_id => $attachment) {
         if (!sizeof($attachment)) {
             continue;
         }
         // We need to reset/empty the _file block var, because this function might be called more than once
         phpbb::$template->destroy_block_vars('_file');
         $block_array = array();
         // Some basics...
         $attachment['extension'] = strtolower(trim($attachment['extension']));
         $filename = titania::$config->upload_path . $attachment['attachment_directory'] . '/' . utf8_basename($attachment['attachment_directory']) . '/' . utf8_basename($attachment['physical_filename']);
         $thumbnail_filename = titania::$config->upload_path . $attachment['attachment_directory'] . '/' . utf8_basename($attachment['attachment_directory']) . '/thumb_' . utf8_basename($attachment['physical_filename']);
         $filesize = get_formatted_filesize($attachment['filesize'], false);
         if ($preview) {
             $comment = bbcode_nl2br(censor_text(utf8_normalize_nfc(request_var('attachment_comment_' . $attachment_id, (string) $attachment['attachment_comment'], true))));
         } else {
             $comment = bbcode_nl2br(censor_text($attachment['attachment_comment']));
         }
         $block_array += array('FILESIZE' => $filesize['value'], 'SIZE_LANG' => $filesize['unit'], 'DOWNLOAD_NAME' => utf8_basename($attachment['real_filename']), 'COMMENT' => $comment);
         $l_downloaded_viewed = $download_link = '';
         $display_cat = strpos($attachment['mimetype'], 'image') === 0 ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE;
         // @todo Probably should add support for more types...
         if ($display_cat == ATTACHMENT_CATEGORY_IMAGE) {
             if ($attachment['thumbnail']) {
                 $display_cat = ATTACHMENT_CATEGORY_THUMB;
             } else {
                 if (phpbb::$config['img_display_inlined']) {
                     if (phpbb::$config['img_link_width'] || phpbb::$config['img_link_height']) {
                         $dimension = @getimagesize($filename);
                         // If the dimensions could not be determined or the image being 0x0 we display it as a link for safety purposes
                         if ($dimension === false || empty($dimension[0]) || empty($dimension[1])) {
                             $display_cat = ATTACHMENT_CATEGORY_NONE;
                         } else {
                             $display_cat = $dimension[0] <= phpbb::$config['img_link_width'] && $dimension[1] <= phpbb::$config['img_link_height'] ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE;
                         }
                     }
                 } else {
                     $display_cat = ATTACHMENT_CATEGORY_NONE;
                 }
             }
         }
         // Make some descisions based on user options being set.
         if (($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !phpbb::$user->optionget('viewimg')) {
             $display_cat = ATTACHMENT_CATEGORY_NONE;
         }
         if ($display_cat == ATTACHMENT_CATEGORY_FLASH && !phpbb::$user->optionget('viewflash')) {
             $display_cat = ATTACHMENT_CATEGORY_NONE;
         }
         $download_link = titania_url::build_url('download', array('id' => $attachment['attachment_id']));
         switch ($display_cat) {
             // Images
             case ATTACHMENT_CATEGORY_IMAGE:
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 $download_link = titania_url::append_url($download_link, array('mode' => 'view'));
                 $block_array += array('S_IMAGE' => true, 'U_INLINE_LINK' => titania_url::append_url($download_link, array('mode' => 'view')));
                 break;
                 // Images, but display Thumbnail
             // Images, but display Thumbnail
             case ATTACHMENT_CATEGORY_THUMB:
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 $download_link = titania_url::append_url($download_link, array('mode' => 'view'));
                 $block_array += array('S_THUMBNAIL' => true, 'THUMB_IMAGE' => titania_url::append_url($download_link, array('mode' => 'view', 'thumb' => 1)));
                 break;
                 // Windows Media Streams
             // Windows Media Streams
             case ATTACHMENT_CATEGORY_WM:
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 // Giving the filename directly because within the wm object all variables are in local context making it impossible
                 // to validate against a valid session (all params can differ)
                 // $download_link = $filename;
                 $block_array += array('ATTACH_ID' => $attachment['attachment_id'], 'S_WM_FILE' => true);
                 break;
                 // Real Media Streams
             // Real Media Streams
             case ATTACHMENT_CATEGORY_RM:
             case ATTACHMENT_CATEGORY_QUICKTIME:
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 $block_array += array('S_RM_FILE' => $display_cat == ATTACHMENT_CATEGORY_RM ? true : false, 'S_QUICKTIME_FILE' => $display_cat == ATTACHMENT_CATEGORY_QUICKTIME ? true : false, 'ATTACH_ID' => $attachment['attachment_id']);
                 break;
                 // Macromedia Flash Files
             // Macromedia Flash Files
             case ATTACHMENT_CATEGORY_FLASH:
                 list($width, $height) = @getimagesize($filename);
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 $block_array += array('S_FLASH_FILE' => true, 'WIDTH' => $width, 'HEIGHT' => $height, 'U_VIEW_LINK' => titania_url::append_url($download_link, array('view' => 1)));
                 break;
             default:
                 $l_downloaded_viewed = 'DOWNLOAD_COUNT';
                 $block_array += array('S_FILE' => true);
                 break;
         }
         $l_download_count = !isset($attachment['download_count']) || $attachment['download_count'] == 0 ? phpbb::$user->lang[$l_downloaded_viewed . '_NONE'] : ($attachment['download_count'] == 1 ? sprintf(phpbb::$user->lang[$l_downloaded_viewed], $attachment['download_count']) : sprintf(phpbb::$user->lang[$l_downloaded_viewed . 'S'], $attachment['download_count']));
         $block_array += array('U_DOWNLOAD_LINK' => $download_link, 'L_DOWNLOAD_COUNT' => $l_download_count);
         // If a template block is specified, output to that also
         if ($template_block) {
             phpbb::$template->assign_block_vars($template_block, $block_array);
         }
         if ($tpl !== false) {
             phpbb::$template->assign_block_vars('_file', $block_array);
             $compiled_attachments[] = phpbb::$template->assign_display('titania_attachment_tpl');
         }
     }
     $tpl_size = sizeof($compiled_attachments);
     $unset_tpl = array();
     // For inline attachments
     if ($message) {
         preg_match_all('#<!\\-\\- ia([0-9]+) \\-\\->(.*?)<!\\-\\- ia\\1 \\-\\->#', $message, $matches, PREG_PATTERN_ORDER);
         $replace = array();
         foreach ($matches[0] as $num => $capture) {
             // Flip index if we are displaying the reverse way
             $index = phpbb::$config['display_order'] ? $tpl_size - ($matches[1][$num] + 1) : $matches[1][$num];
             $replace['from'][] = $matches[0][$num];
             $replace['to'][] = isset($compiled_attachments[$index]) ? $compiled_attachments[$index] : sprintf(phpbb::$user->lang['MISSING_INLINE_ATTACHMENT'], $matches[2][array_search($index, $matches[1])]);
             $unset_tpl[] = $index;
         }
         if (isset($replace['from'])) {
             $message = str_replace($replace['from'], $replace['to'], $message);
         }
         $unset_tpl = array_unique($unset_tpl);
         // Needed to let not display the inlined attachments at the end of the post again
         foreach ($unset_tpl as $index) {
             unset($compiled_attachments[$index]);
         }
     }
     return $compiled_attachments;
 }
示例#20
0
 /**
  * Generate pagination (similar to phpBB's generate_pagination function, only with some minor tweaks to work in this class better and use proper URLs)
  *
  * @param <string> $base_url
  * @param <int|bool> $num_items Bool false to use $this->total
  * @param <int|bool> $per_page Bool false to use $this->limit
  * @param <int|bool> $start_item Bool false to use $this->start
  * @param <bool> $add_prevnext_text
  * @return <string>
  */
 public function generate_pagination($base_url, $num_items = false, $per_page = false, $start_item = false, $add_prevnext_text = true)
 {
     $num_items = $num_items === false ? $this->total : $num_items;
     $per_page = $per_page === false ? $this->limit : $per_page;
     $start_item = $start_item === false ? $this->start : $start_item;
     $seperator = '<span class="page-sep">' . phpbb::$user->lang['COMMA_SEPARATOR'] . '</span>';
     $total_pages = ceil($num_items / $per_page);
     $on_page = floor($start_item / $per_page) + 1;
     $page_string = '';
     if (!$num_items) {
         return false;
     }
     if ($total_pages > 1) {
         $page_string = $on_page == 1 ? '<strong>1</strong>' : '<a href="' . $base_url . '">1</a>';
         if ($total_pages > 5) {
             $start_cnt = min(max(1, $on_page - 4), $total_pages - 5);
             $end_cnt = max(min($total_pages, $on_page + 4), 6);
             $page_string .= $start_cnt > 1 ? ' ... ' : $seperator;
             for ($i = $start_cnt + 1; $i < $end_cnt; $i++) {
                 $page_string .= $i == $on_page ? '<strong>' . $i . '</strong>' : '<a href="' . titania_url::append_url($base_url, array($this->start_name => ($i - 1) * $per_page)) . '">' . $i . '</a>';
                 if ($i < $end_cnt - 1) {
                     $page_string .= $seperator;
                 }
             }
             $page_string .= $end_cnt < $total_pages ? ' ... ' : $seperator;
         } else {
             $page_string .= $seperator;
             for ($i = 2; $i < $total_pages; $i++) {
                 $page_string .= $i == $on_page ? '<strong>' . $i . '</strong>' : '<a href="' . titania_url::append_url($base_url, array($this->start_name => ($i - 1) * $per_page)) . '">' . $i . '</a>';
                 if ($i < $total_pages) {
                     $page_string .= $seperator;
                 }
             }
         }
         $page_string .= $on_page == $total_pages ? '<strong>' . $total_pages . '</strong>' : '<a href="' . titania_url::append_url($base_url, array($this->start_name => ($total_pages - 1) * $per_page)) . '">' . $total_pages . '</a>';
         if ($add_prevnext_text) {
             if ($on_page == 2) {
                 $page_string = '<a href="' . $base_url . '">' . phpbb::$user->lang['PREVIOUS'] . '</a>&nbsp;&nbsp;' . $page_string;
             } else {
                 if ($on_page != 1) {
                     $page_string = '<a href="' . titania_url::append_url($base_url, array($this->start_name => ($on_page - 2) * $per_page)) . '">' . phpbb::$user->lang['PREVIOUS'] . '</a>&nbsp;&nbsp;' . $page_string;
                 }
             }
             if ($on_page != $total_pages) {
                 $page_string .= '&nbsp;&nbsp;<a href="' . titania_url::append_url($base_url, array($this->start_name => $on_page * $per_page)) . '">' . phpbb::$user->lang['NEXT'] . '</a>';
             }
         }
     }
     if ($num_items == 1) {
         $total_results = isset(phpbb::$user->lang[$this->result_lang . '_ONE']) ? phpbb::$user->lang[$this->result_lang . '_ONE'] : phpbb::$user->lang['TOTAL_RESULTS_ONE'];
     } else {
         $total_results = isset(phpbb::$user->lang[$this->result_lang]) ? sprintf(phpbb::$user->lang[$this->result_lang], $num_items) : sprintf(phpbb::$user->lang['TOTAL_RESULTS'], $num_items);
     }
     phpbb::$template->assign_vars(array($this->template_vars['PER_PAGE'] => $per_page, $this->template_vars['ON_PAGE'] => $on_page, $this->template_vars['PREVIOUS_PAGE'] => $on_page == 2 ? $base_url : ($on_page == 1 ? '' : titania_url::append_url($base_url, array($this->start_name => ($on_page - 2) * $per_page))), $this->template_vars['NEXT_PAGE'] => $on_page == $total_pages ? '' : titania_url::append_url($base_url, array($this->start_name => $on_page * $per_page)), $this->template_vars['TOTAL_PAGES'] => $total_pages, $this->template_vars['TOTAL_ITEMS'] => $num_items, $this->template_vars['TOTAL_RESULTS'] => $total_results));
     return $page_string;
 }
示例#21
0
 /**
  * Titania page_footer
  *
  * @param cron $run_cron
  * @param bool|string $template_body For those lazy like me, send the template body name you want to load (or leave default to ignore and assign it yourself)
  */
 public static function page_footer($run_cron = true, $template_body = false)
 {
     // Because I am lazy most of the time...
     if ($template_body !== false) {
         phpbb::$template->set_filenames(array('body' => $template_body));
     }
     if (!empty(titania::$hook) && titania::$hook->call_hook(array(__CLASS__, __FUNCTION__), $run_cron)) {
         if (titania::$hook->hook_return(array(__CLASS__, __FUNCTION__))) {
             return titania::$hook->hook_return_result(array(__CLASS__, __FUNCTION__));
         }
     }
     // Output page creation time (can not move phpBB side because of a hack we do in here)
     if (defined('DEBUG')) {
         global $starttime;
         $mtime = explode(' ', microtime());
         $totaltime = $mtime[0] + $mtime[1] - $starttime;
         if (!empty($_REQUEST['explain']) && phpbb::$auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists(phpbb::$db, 'sql_report')) {
             // gotta do a rather nasty hack here, but it works and the page is killed after the display output, so no harm to anything else
             $GLOBALS['phpbb_root_path'] = self::$absolute_board;
             phpbb::$db->sql_report('display');
         }
         $debug_output = sprintf('Time : %.3fs | ' . phpbb::$db->sql_num_queries() . ' Queries | GZIP : ' . (phpbb::$config['gzip_compress'] && @extension_loaded('zlib') ? 'On' : 'Off') . (phpbb::$user->load ? ' | Load : ' . phpbb::$user->load : ''), $totaltime);
         if (phpbb::$auth->acl_get('a_') && defined('DEBUG_EXTRA')) {
             if (function_exists('memory_get_usage')) {
                 if ($memory_usage = memory_get_usage()) {
                     global $base_memory_usage;
                     $memory_usage -= $base_memory_usage;
                     $memory_usage = get_formatted_filesize($memory_usage);
                     $debug_output .= ' | Memory Usage: ' . $memory_usage;
                 }
             }
             $debug_output .= ' | <a href="' . titania_url::append_url(titania_url::$current_page, array_merge(titania_url::$params, array('explain' => 1))) . '">Explain</a>';
         }
     }
     phpbb::$template->assign_vars(array('DEBUG_OUTPUT' => defined('DEBUG') ? $debug_output : '', 'U_PURGE_CACHE' => phpbb::$auth->acl_get('a_') ? titania_url::append_url(titania_url::$current_page, array_merge(titania_url::$params, array('cache' => 'purge'))) : ''));
     // Footer hook
     self::$hook->call_hook('titania_page_footer', $run_cron, $template_body);
     // Call the phpBB footer function
     phpbb::page_footer($run_cron);
 }