コード例 #1
0
ファイル: ocf_profiles.php プロジェクト: erico-deh/ocPortal
/**
 * Render a member profile.
 *
 * @param  MEMBER			The ID of the member who is being viewed
 * @param  ?MEMBER		The ID of the member who is doing the viewing (NULL: current member)
 * @param  ?ID_TEXT		The username of the member who is being viewed (NULL: work out from member_id_of)
 * @return tempcode		The rendered profile
 */
function render_profile_tabset($member_id_of, $member_id_viewing = NULL, $username = NULL)
{
    if (is_null($member_id_viewing)) {
        $member_id_viewing = get_member();
    }
    $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
    if (is_null($username) || is_guest($member_id_of)) {
        warn_exit(do_lang_tempcode('USER_NO_EXIST'));
    }
    $tabs = array();
    $hooks = find_all_hooks('systems', 'profiles_tabs');
    if (isset($hooks['edit'])) {
        $hooks = array('edit' => $hooks['edit']) + $hooks;
    }
    foreach (array_keys($hooks) as $hook) {
        require_code('hooks/systems/profiles_tabs/' . $hook);
        $ob = object_factory('Hook_Profiles_Tabs_' . $hook);
        if ($ob->is_active($member_id_of, $member_id_viewing)) {
            $tabs[$hook] = $ob->render_tab($member_id_of, $member_id_viewing, !browser_matches('ie6') && !browser_matches('ie7') && has_js());
        }
    }
    global $M_SORT_KEY;
    $M_SORT_KEY = 2;
    uasort($tabs, 'multi_sort');
    require_javascript('javascript_profile');
    require_javascript('javascript_ajax');
    load_up_all_self_page_permissions($member_id_viewing);
    if (addon_installed('awards')) {
        require_code('awards');
        $awards = find_awards_for('member', strval($member_id_of));
    } else {
        $awards = array();
    }
    $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
    // Get it again, in case it changed
    $title = get_page_title('MEMBER_PROFILE', true, array(escape_html($username)), NULL, $awards);
    $_tabs = array();
    $i = 0;
    foreach ($tabs as $hook => $tab) {
        $_tabs[] = array('TAB_TITLE' => $tab[0], 'TAB_CODE' => $hook, 'TAB_CONTENT' => $tab[1], 'TAB_FIRST' => $i == 0, 'TAB_LAST' => !array_key_exists($i + 1, $tabs));
        $i++;
    }
    return do_template('OCF_MEMBER_PROFILE_SCREEN', array('TITLE' => $title, 'TABS' => $_tabs, 'MEMBER_ID' => strval($member_id_of)));
}
コード例 #2
0
ファイル: galleries.php プロジェクト: erico-deh/ocPortal
 /**
  * The UI to show a video.
  *
  * @param  ?string		Alternate category name to use (NULL: use standard one). This is useful if you are overriding this code to show images in virtual galleries.
  * @param  ?tempcode		Breadcrumbs (NULL: derive in this function).
  * @return tempcode		The UI
  */
 function show_video($category_name = NULL, $tree = NULL)
 {
     $id = get_param_integer('id');
     if (get_param_integer('ajax', 0) == 1) {
         header('Content-type: text/xml');
     }
     list($sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos) = $this->get_sort_order();
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = find_awards_for('video', strval($id));
     } else {
         $awards = array();
     }
     // Pic up some info
     $rows = $GLOBALS['SITE_DB']->query_select('videos', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         return warn_screen(get_page_title('ERROR_OCCURRED'), do_lang_tempcode('MISSING_RESOURCE'));
     }
     $myrow = $rows[0];
     $url = $myrow['url'];
     if (url_is_local($url)) {
         $url = get_custom_base_url() . '/' . $url;
     }
     $cat = $myrow['cat'];
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=galleries&filter=' . urlencode($cat);
     if (get_value('no_individual_gallery_view') === '1' && $GLOBALS['SITE_DB']->query_value('galleries', 'flow_mode_interface', array('name' => $cat)) == '1') {
         require_code('site2');
         assign_refresh(build_url(array('page' => '_SELF', 'type' => 'misc', 'id' => $cat, 'probe_id' => $id, 'probe_type' => 'video'), '_SELF'), 0.0);
     }
     $true_category_name = get_translated_text($GLOBALS['SITE_DB']->query_value('galleries', 'fullname', array('name' => $cat)));
     if (is_null($category_name)) {
         $category_name = $true_category_name;
     }
     if (get_param_integer('slideshow', 0) == 1) {
         $title = get_page_title('VIEW_SLIDESHOW', true, array(escape_html($category_name)));
         global $EXTRA_HEAD;
         $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
         // XHTMLXHTML
     } else {
         $title = get_page_title(get_translated_text($myrow['title']) == '' ? 'VIEW_VIDEO' : '_VIEW_VIDEO', true, array(escape_html(get_translated_text($myrow['title']))), NULL, $awards);
     }
     $root = get_param('root', 'root');
     seo_meta_load_for('video', strval($id));
     $thumb_url = $myrow['thumb_url'];
     if (url_is_local($thumb_url)) {
         $thumb_url = get_custom_base_url() . '/' . $thumb_url;
     }
     if (!has_category_access(get_member(), 'galleries', $cat)) {
         access_denied('CATEGORY_ACCESS');
     }
     // Views
     if (get_db_type() != 'xml') {
         $myrow['video_views']++;
         $GLOBALS['SITE_DB']->query_update('videos', array('video_views' => $myrow['video_views']), array('id' => $id), '', 1, NULL, false, true);
     }
     list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems('videos', strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], $myrow['validated'], $myrow['submitter'], build_url(array('page' => '_SELF', 'type' => 'video', 'id' => $id), '_SELF', NULL, false, false, true), get_translated_text($myrow['title']) == '' ? do_lang('VIEW_VIDEO_IN', $true_category_name) : get_translated_text($myrow['title']), get_value('comment_forum__videos'));
     // Validation
     if ($myrow['validated'] == 0) {
         if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) {
             access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated');
         }
         $warning_details = do_template('WARNING_TABLE', array('_GUID' => 'b32faacba974e648a67e5e91ffd3d8e5', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')));
     } else {
         $warning_details = new ocp_tempcode();
     }
     // Comments
     $comments = get_translated_tempcode($myrow['comments']);
     if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_galleries', array('galleries', $cat))) {
         $edit_url = build_url(array('page' => 'cms_galleries', 'type' => '_ev', 'id' => $id), get_module_zone('cms_galleries'));
     } else {
         $edit_url = new ocp_tempcode();
     }
     $add_date = get_timezoned_date($myrow['add_date']);
     $edit_date = is_null($myrow['edit_date']) ? '' : get_timezoned_date($myrow['edit_date']);
     // Video HTML
     $video = show_gallery_media($url, $thumb_url, $myrow['video_width'], $myrow['video_height'], $myrow['video_length']);
     $extension = get_file_extension($url);
     require_code('mime_types');
     $mime_type = get_mime_type($extension);
     list($n, $x, $nav) = $this->build_set_navigation(db_string_equal_to('cat', $cat), '', $category_name, $id, $root, 'video', get_param_integer('slideshow', 0), get_param_integer('wide_high', 0), get_param_integer('start', 0), get_param_integer('max', get_default_gallery_max()), $cat, $sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos, get_param('select', '*'), get_param('video_select', '*'));
     $member_id = get_member_id_from_gallery_name($cat, NULL, true);
     if (get_forum_type() == 'ocf') {
         require_code('ocf_members');
         require_code('ocf_members2');
     }
     $member_details = is_null($member_id) || get_forum_type() != 'ocf' ? new ocp_tempcode() : ocf_show_member_box($member_id);
     $video_details = show_video_details($myrow);
     if (is_null($tree)) {
         $tree = gallery_breadcrumbs($cat, $root, false, get_module_zone('galleries'));
     }
     breadcrumb_add_segment($tree, do_lang_tempcode('VIEW_VIDEO'));
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'publisher' => '', 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Video', 'title' => get_translated_text($myrow['title']), 'identifier' => '_SEARCH:galleries:video:' . strval($id), 'description' => get_translated_text($myrow['comments']), 'image' => $thumb_url, 'video' => $url, 'video:height' => strval($myrow['video_height']), 'video:width' => strval($myrow['video_width']), 'video:type' => $mime_type);
     return do_template('GALLERY_ENTRY_SCREEN', array('_GUID' => '91e231906ed899513ec2db8a2974dddf', 'MEDIA_TYPE' => 'video', 'E_TITLE' => get_translated_text($myrow['title']), 'CAT' => $cat, 'SLIDESHOW' => get_param_integer('slideshow', 0) == 1, 'TRUE_GALLERY_TITLE' => $true_category_name, 'GALLERY_TITLE' => $category_name, 'MEMBER_ID' => is_null($member_id) ? '' : strval($member_id), 'ID' => strval($id), 'TAGS' => get_loaded_tags('videos'), 'TITLE' => $title, 'SUBMITTER' => strval($myrow['submitter']), 'URL' => $url, 'VIDEO_DETAILS' => $video_details, 'MEMBER_DETAILS' => $member_details, 'X' => integer_format($x), 'N' => integer_format($n), 'VIEWS' => integer_format($myrow['video_views']), 'ADD_DATE_RAW' => strval($myrow['add_date']), 'EDIT_DATE_RAW' => is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']), 'ADD_DATE' => $add_date, 'EDIT_DATE' => $edit_date, 'RATING_DETAILS' => $rating_details, 'TRACKBACK_DETAILS' => $trackback_details, 'COMMENT_DETAILS' => $comment_details, 'EDIT_URL' => $edit_url, 'NAV' => $nav, 'COMMENTS' => $comments, 'VIDEO' => $video, 'WARNING_DETAILS' => $warning_details));
 }
コード例 #3
0
ファイル: topicview.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (get_forum_type() != 'ocf') {
         warn_exit(do_lang_tempcode('NO_OCF'));
     } else {
         ocf_require_all_forum_stuff();
     }
     require_code('ocf_topicview');
     require_css('ocf');
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'max';
     $NON_CANONICAL_PARAMS[] = 'start';
     $NON_CANONICAL_PARAMS[] = 'threaded';
     $start = get_param_integer('start', 0);
     $default_max = intval(get_option('forum_posts_per_page'));
     $max = get_param_integer('max', $default_max);
     if ($max == 0) {
         $max = $default_max;
     }
     if ($max == 0) {
         $max = 1;
     }
     if ($max > 30 && !has_specific_permission(get_member(), 'remove_page_split')) {
         $max = $default_max;
     }
     $first_unread_id = -1;
     global $NON_CANONICAL_PARAMS;
     foreach (array_keys($_GET) as $key) {
         if (substr($key, 0, 3) == 'kfs') {
             $NON_CANONICAL_PARAMS[] = $key;
         }
     }
     $type = get_param('type', 'misc');
     $id = get_param_integer('id', NULL);
     if (is_guest() && is_null($id)) {
         access_denied('NOT_AS_GUEST');
     }
     if ($type == 'findpost') {
         $post_id = get_param_integer('id');
         $redirect = find_post_id_url($post_id);
         require_code('site2');
         assign_refresh($redirect, 0.0);
         return do_template('REDIRECT_SCREEN', array('_GUID' => '76e6d34c20a4f5284119827e41c7752f', 'URL' => $redirect, 'TITLE' => get_page_title('VIEW_TOPIC'), 'TEXT' => do_lang_tempcode('REDIRECTING')));
     } else {
         if ($type == 'first_unread') {
             $redirect = find_first_unread_url($id);
             require_code('site2');
             assign_refresh($redirect, 0.0);
             return do_template('REDIRECT_SCREEN', array('_GUID' => '12c5d16f60e8c4df03536d9a7a932528', 'URL' => $redirect, 'TITLE' => get_page_title('VIEW_TOPIC'), 'TEXT' => do_lang_tempcode('REDIRECTING')));
         }
     }
     if (!is_null($id)) {
         $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=ocf_topicview&filter=' . strval($id);
     }
     $view_poll_results = get_param_integer('view_poll_results', 0);
     // Mark as read
     if (!is_null($id)) {
         if (!is_guest()) {
             $GLOBALS['FORUM_DB']->query_delete('f_read_logs', array('l_member_id' => get_member(), 'l_topic_id' => $id), '', 1);
             $GLOBALS['FORUM_DB']->query_insert('f_read_logs', array('l_member_id' => get_member(), 'l_topic_id' => $id, 'l_time' => time()), false, true);
             // race condition
         }
         $GLOBALS['FORUM_DB']->query('UPDATE ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics SET t_num_views=(t_num_views+1) WHERE id=' . strval((int) $id), 1, NULL, true);
     }
     // Load up topic info
     $topic_info = ocf_read_in_topic($id, $start, $max, $view_poll_results == 1);
     $GLOBALS['META_DATA'] += $topic_info['meta_data'];
     global $SEO_TITLE;
     $SEO_TITLE = do_lang('_VIEW_TOPIC', $topic_info['title']);
     // Render posts according to whether threaded or not
     $threaded = $topic_info['is_threaded'] == 1;
     $may_reply = array_key_exists('may_reply', $topic_info) && ($topic_info['is_open'] || array_key_exists('may_post_closed', $topic_info));
     if (!$threaded) {
         $GLOBALS['META_DATA']['description'] = $topic_info['description'];
         // Poster detail hooks
         $hooks = find_all_hooks('modules', 'topicview');
         $hook_objects = array();
         foreach (array_keys($hooks) as $hook) {
             require_code('hooks/modules/topicview/' . filter_naughty_harsh($hook));
             $object = object_factory('Hook_' . filter_naughty_harsh($hook), true);
             if (is_null($object)) {
                 continue;
             }
             $hook_objects[$hook] = $object;
         }
         // Render non-threaded
         $posts = new ocp_tempcode();
         $replied = false;
         if (is_null($topic_info['forum_id'])) {
             decache('side_ocf_personal_topics', array(get_member()));
             decache('_new_pp', array(get_member()));
         }
         $second_poster = $topic_info['first_poster'];
         foreach ($topic_info['posts'] as $array_id => $_postdetails) {
             if ($array_id == 0) {
                 $description = $topic_info['description'];
             } else {
                 $description = NULL;
             }
             if ($_postdetails['poster'] == get_member()) {
                 $replied = true;
             }
             if ($array_id == 1 && $start == 0 || $array_id == 0 && $start != 0) {
                 $second_poster = $_postdetails['poster'];
             }
             if (array_key_exists('last_edit_time', $_postdetails)) {
                 $last_edited = do_template('OCF_TOPIC_POST_LAST_EDITED', array('_GUID' => '77a28e8bc3cf2ec2211aafdb5ba192bf', 'LAST_EDIT_DATE_RAW' => is_null($_postdetails['last_edit_time']) ? '' : strval($_postdetails['last_edit_time']), 'LAST_EDIT_DATE' => $_postdetails['last_edit_time_string'], 'LAST_EDIT_PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($_postdetails['last_edit_by'], false, true), 'LAST_EDIT_USERNAME' => $_postdetails['last_edit_by_username']));
             } else {
                 $last_edited = new ocp_tempcode();
             }
             $last_edited_raw = array_key_exists('last_edit_time', $_postdetails) ? is_null($_postdetails['last_edit_time']) ? '' : strval($_postdetails['last_edit_time']) : '0';
             $is_spacer_post = $_postdetails['is_spacer_post'];
             // Post buttons
             $buttons = new ocp_tempcode();
             if (!$is_spacer_post) {
                 $buttons = ocf_render_post_buttons($topic_info, $_postdetails, $may_reply);
             }
             // Avatar
             if (array_key_exists('poster_avatar', $_postdetails) && $_postdetails['poster_avatar'] != '') {
                 $post_avatar = do_template('OCF_TOPIC_POST_AVATAR', array('_GUID' => 'd647ada9c11d56eedc0ff7894d33e83c', 'AVATAR' => $_postdetails['poster_avatar']));
             } else {
                 $post_avatar = new ocp_tempcode();
             }
             // Rank images
             $rank_images = new ocp_tempcode();
             if (!$is_spacer_post) {
                 $posters_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($_postdetails['poster'], true);
                 foreach ($posters_groups as $group) {
                     $rank_image = ocf_get_group_property($group, 'rank_image');
                     $group_leader = ocf_get_group_property($group, 'group_leader');
                     $group_name = ocf_get_group_name($group);
                     $rank_image_pri_only = ocf_get_group_property($group, 'rank_image_pri_only');
                     if ($rank_image != '' && ($rank_image_pri_only == 0 || $group == $GLOBALS['FORUM_DRIVER']->get_member_row_field($_postdetails['poster'], 'm_primary_group'))) {
                         $rank_images->attach(do_template('OCF_RANK_IMAGE', array('_GUID' => '0ff7855482b901be95591964d4212c44', 'GROUP_NAME' => $group_name, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($_postdetails['poster']), 'IMG' => $rank_image, 'IS_LEADER' => $group_leader == $_postdetails['poster'])));
                     }
                 }
             }
             // Poster details
             if (!$is_spacer_post) {
                 if (!is_guest($_postdetails['poster'])) {
                     require_code('ocf_members2');
                     $poster_details = ocf_show_member_box($_postdetails, false, $hooks, $hook_objects, false);
                 } else {
                     $custom_fields = new ocp_tempcode();
                     if (array_key_exists('ip_address', $_postdetails)) {
                         $custom_fields->attach(do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('_GUID' => 'd85be094dff0d039a64120d6f8f381bb', 'NAME' => do_lang_tempcode('IP_ADDRESS'), 'VALUE' => $_postdetails['ip_address'])));
                         $poster_details = do_template('OCF_GUEST_DETAILS', array('_GUID' => 'e43534acaf598008602e8da8f9725f38', 'CUSTOM_FIELDS' => $custom_fields));
                     } else {
                         $poster_details = new ocp_tempcode();
                     }
                 }
             } else {
                 $poster_details = new ocp_tempcode();
             }
             if (!is_guest($_postdetails['poster'])) {
                 $poster = do_template('OCF_POSTER_MEMBER', array('_GUID' => 'dbbed1850b6c01a6c9601d85c6aee43f', 'ONLINE' => member_is_online($_postdetails['poster']), 'ID' => strval($_postdetails['poster']), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($_postdetails['poster'], false, true), 'POSTER_USERNAME' => $_postdetails['poster_username'], 'HIGHLIGHT_NAME' => array_key_exists('poster_highlighted_name', $_postdetails) ? strval($_postdetails['poster_highlighted_name']) : NULL));
             } else {
                 $ip_link = array_key_exists('ip_address', $_postdetails) && has_actual_page_access(get_member(), 'admin_lookup') ? build_url(array('page' => 'admin_lookup', 'param' => $_postdetails['ip_address']), get_module_zone('admin_lookup')) : new ocp_tempcode();
                 $poster = do_template('OCF_POSTER_GUEST', array('_GUID' => '36a8e550222cdac5165ef8f722be3def', 'IP_LINK' => $ip_link, 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $_postdetails['poster_username']));
             }
             // Signature
             $signature = new ocp_tempcode();
             if (array_key_exists('signature', $_postdetails) && !$_postdetails['signature']->is_empty()) {
                 $signature = $_postdetails['signature'];
             }
             $post_title = $_postdetails['title'];
             $first_unread = $_postdetails['id'] == $first_unread_id || $first_unread_id < 0 && $array_id == count($topic_info['posts']) - 1 ? do_template('OCF_TOPIC_FIRST_UNREAD') : new ocp_tempcode();
             $unvalidated = $_postdetails['validated'] == 0 ? do_lang_tempcode('UNVALIDATED') : new ocp_tempcode();
             $post_url = $GLOBALS['FORUM_DRIVER']->post_url($_postdetails['id'], is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']), true);
             if (array_key_exists('intended_solely_for', $_postdetails) && $_postdetails['intended_solely_for'] == get_member()) {
                 decache('side_ocf_personal_topics', array(get_member()));
                 decache('_new_pp', array(get_member()));
             }
             $emphasis = ocf_get_post_emphasis($_postdetails);
             require_code('feedback');
             if (!array_key_exists('intended_solely_for', $_postdetails)) {
                 actualise_rating(true, 'post', strval($_postdetails['id']), get_self_url(), $_postdetails['title']);
                 $rating = display_rating(get_self_url(), $_postdetails['title'], 'post', strval($_postdetails['id']), 'RATING_INLINE_DYNAMIC', $_postdetails['poster']);
             } else {
                 $rating = new ocp_tempcode();
             }
             $rendered_post = do_template('OCF_TOPIC_POST', array('_GUID' => 'sacd09wekfofpw2f', 'ID' => $is_spacer_post ? '' : strval($_postdetails['id']), 'TOPIC_FIRST_POST_ID' => is_null($topic_info['first_post_id']) ? '' : strval($topic_info['first_post_id']), 'TOPIC_FIRST_POSTER' => is_null($topic_info['first_poster']) ? '' : strval($topic_info['first_poster']), 'POST_ID' => $is_spacer_post ? '' : (get_value('seq_post_ids') === '1' ? strval($start + $array_id + 1) : strval($_postdetails['id'])), 'URL' => $post_url, 'CLASS' => $_postdetails['is_emphasised'] ? 'ocf_post_emphasis' : (array_key_exists('intended_solely_for', $_postdetails) ? 'ocf_post_personal' : ''), 'EMPHASIS' => $emphasis, 'FIRST_UNREAD' => $first_unread, 'POSTER_TITLE' => $is_spacer_post ? '' : $_postdetails['poster_title'], 'POST_TITLE' => $post_title, 'POST_DATE_RAW' => strval($_postdetails['time']), 'POST_DATE' => $_postdetails['time_string'], 'POST' => $_postdetails['post'], 'TOPIC_ID' => is_null($id) ? '' : strval($id), 'LAST_EDITED_RAW' => $last_edited_raw, 'LAST_EDITED' => $last_edited, 'POSTER_ID' => strval($_postdetails['poster']), 'POSTER' => $is_spacer_post ? '' : $poster, 'POSTER_DETAILS' => $poster_details, 'POST_AVATAR' => $post_avatar, 'RANK_IMAGES' => $rank_images, 'BUTTONS' => $buttons, 'SIGNATURE' => $signature, 'UNVALIDATED' => $unvalidated, 'DESCRIPTION' => $description, 'RATING' => $rating));
             $posts->attach($rendered_post);
         }
         $serialized_options = mixed();
         $hash = mixed();
     } else {
         require_code('topics');
         $threaded_topic_ob = new OCP_Topic();
         // Load some settings into the renderer
         $threaded_topic_ob->first_post_id = $topic_info['first_post_id'];
         $threaded_topic_ob->topic_description = $topic_info['description'];
         $threaded_topic_ob->topic_description_link = $topic_info['description_link'];
         $threaded_topic_ob->topic_title = $topic_info['title'];
         $threaded_topic_ob->topic_info = $topic_info;
         // Other settings we need
         $max_thread_depth = intval(get_option('max_thread_depth'));
         $num_to_show_limit = get_param_integer('max_comments', intval(get_option('comments_to_show_in_thread')));
         // Load posts
         $threaded_topic_ob->load_from_topic($id, $num_to_show_limit, $start, false, NULL, true);
         $threaded_topic_ob->is_threaded = true;
         // Render posts
         list($posts, $serialized_options, $hash) = $threaded_topic_ob->render_posts($num_to_show_limit, $max_thread_depth, $may_reply, $topic_info['first_poster'], array(), $topic_info['forum_id'], NULL, false);
         $GLOBALS['META_DATA']['description'] = $threaded_topic_ob->topic_description;
         // Get other gathered details
         $replied = $threaded_topic_ob->replied;
         if (!is_null($threaded_topic_ob->topic_title)) {
             // Updated topic title
             $topic_info['title'] = $threaded_topic_ob->topic_title;
         }
         $topic_info['max_rows'] = $threaded_topic_ob->total_posts;
         $second_poster = $GLOBALS['FORUM_DRIVER']->get_guest_id();
         // No definitive post orders
     }
     // Buttons for topic as whole
     $button_array = array();
     if (!is_null($id)) {
         if (get_value('no_threaded_buttons') !== '1') {
             if ($threaded) {
                 $view_as_linear_url = get_self_url(false, false, array('threaded' => 0));
                 $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('VIEW_AS_LINEAR'), 'url' => $view_as_linear_url, 'img' => 'linear');
             } else {
                 $view_as_threaded_url = get_self_url(false, false, array('threaded' => 1));
                 $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('VIEW_AS_THREADED'), 'url' => $view_as_threaded_url, 'img' => 'threaded');
             }
         }
         if (!is_guest()) {
             $too_old = $topic_info['last_time'] < time() - 60 * 60 * 24 * intval(get_option('post_history_days'));
             if (get_value('disable_mark_topic_unread') !== '1' && !$too_old) {
                 $map = array('page' => 'topics', 'type' => 'mark_unread_topic', 'id' => $id);
                 $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
                 if ($test != -1 && $test != 0) {
                     $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
                 }
                 $test = get_param_integer('threaded', -1);
                 if ($test != -1) {
                     $map['threaded'] = $test;
                 }
                 $mark_unread_url = build_url($map, get_module_zone('topics'));
                 $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('MARK_UNREAD'), 'url' => $mark_unread_url, 'img' => 'mark_unread');
             }
         }
         if ($may_reply && is_null(get_bot_type())) {
             $reply_prevented = false;
             // "Staff-only" reply for support tickets
             if ($GLOBALS['FORUM_DRIVER']->is_staff(get_member()) && addon_installed('tickets')) {
                 require_code('tickets');
                 if (is_ticket_forum($topic_info['forum_id'])) {
                     if (is_guest($second_poster)) {
                         $reply_prevented = true;
                     }
                     require_lang('tickets');
                     $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id, 'intended_solely_for' => $GLOBALS['FORUM_DRIVER']->get_guest_id());
                     $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
                     if ($test != -1 && $test != 0) {
                         $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
                     }
                     $test = get_param_integer('threaded', -1);
                     if ($test != -1) {
                         $map['threaded'] = $test;
                     }
                     $new_post_url = build_url($map, get_module_zone('topics'));
                     $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('TICKET_STAFF_ONLY_REPLY'), 'url' => $new_post_url, 'img' => 'staff_only_reply');
                 }
             }
             if (!$reply_prevented) {
                 if ($topic_info['is_threaded'] == 0) {
                     $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id);
                     $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
                     if ($test != -1 && $test != 0) {
                         $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
                     }
                     $test = get_param_integer('threaded', -1);
                     if ($test != -1) {
                         $map['threaded'] = $test;
                     }
                     $new_post_url = build_url($map, get_module_zone('topics'));
                     $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode($topic_info['is_open'] ? 'REPLY' : 'CLOSED'), 'url' => $new_post_url, 'img' => $topic_info['is_open'] ? 'reply' : 'closed');
                 }
             } else {
                 unset($topic_info['may_use_quick_reply']);
             }
         } elseif ((is_null($topic_info['forum_id']) || has_specific_permission(get_member(), 'submit_lowrange_content', 'topics', array('forums', $topic_info['forum_id']))) && $topic_info['last_poster'] == get_member() && !is_guest() && ocf_may_edit_post_by(get_member(), $topic_info['forum_id'])) {
             $map = array('page' => 'topics', 'type' => 'edit_post', 'id' => $topic_info['last_post_id']);
             $test = get_param_integer('kfs' . strval($topic_info['forum_id']), -1);
             if ($test != -1 && $test != 0) {
                 $map['kfs' . strval($topic_info['forum_id'])] = $test;
             }
             $test = get_param_integer('threaded', -1);
             if ($test != -1) {
                 $map['threaded'] = $test;
             }
             $new_post_url = build_url($map, get_module_zone('topics'));
             $button_array[] = array('immediate' => false, 'rel' => 'edit', 'title' => do_lang_tempcode('LAST_POST'), 'url' => $new_post_url, 'img' => 'amend');
         }
         if (!is_null($topic_info['forum_id'])) {
             if (get_value('disable_add_topic_btn_in_topic') !== '1') {
                 if (ocf_may_post_topic($topic_info['forum_id'], get_member())) {
                     $new_topic_url = build_url(array('page' => 'topics', 'type' => 'new_topic', 'id' => $topic_info['forum_id']), get_module_zone('topics'));
                     $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('ADD_TOPIC'), 'url' => $new_topic_url, 'img' => 'new_topic');
                 }
             }
         } else {
             $invite_url = build_url(array('page' => 'topics', 'type' => 'invite_member', 'id' => $id), get_module_zone('topics'));
             $button_array[] = array('immediate' => false, 'title' => do_lang_tempcode('INVITE_MEMBER_TO_PT'), 'url' => $invite_url, 'img' => 'invite_member');
         }
     }
     $buttons = ocf_screen_button_wrap($button_array);
     // Poll
     if (array_key_exists('poll', $topic_info)) {
         $_poll = $topic_info['poll'];
         $voted_already = $_poll['voted_already'];
         $poll_results = array_key_exists(0, $_poll['answers']) && array_key_exists('num_votes', $_poll['answers'][0]);
         $answers = new ocp_tempcode();
         $real_button = false;
         if ($_poll['is_open']) {
             if ($poll_results) {
                 $button = new ocp_tempcode();
             } elseif ($_poll['requires_reply'] && !$replied) {
                 $button = do_lang_tempcode('POLL_REQUIRES_REPLY');
             } else {
                 if (!has_specific_permission(get_member(), 'vote_in_polls') || is_guest()) {
                     $button = do_lang_tempcode('VOTE_DENIED');
                 } else {
                     if (!is_null($voted_already)) {
                         $button = do_lang_tempcode('NOVOTE');
                     } else {
                         require_lang('polls');
                         $map = array('page' => 'topicview', 'id' => $id, 'view_poll_results' => 1, 'start' => $start == 0 ? NULL : $start, 'max' => $max == $default_max ? NULL : $max);
                         $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
                         if ($test != -1 && $test != 0) {
                             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
                         }
                         $test = get_param_integer('threaded', -1);
                         if ($test != -1) {
                             $map['threaded'] = $test;
                         }
                         $results_url = build_url($map, get_module_zone('topics'));
                         $button = do_template('OCF_TOPIC_POLL_BUTTON', array('_GUID' => '94b932fd01028df8f67bb5864d9235f9', 'RESULTS_URL' => $results_url));
                         $real_button = true;
                     }
                 }
             }
         } else {
             $button = do_lang_tempcode('TOPIC_POLL_CLOSED');
         }
         foreach ($_poll['answers'] as $answer) {
             if ($poll_results && ($_poll['requires_reply'] == 0 || $replied)) {
                 $num_votes = $answer['num_votes'];
                 $total_votes = $_poll['total_votes'];
                 if ($total_votes != 0) {
                     $width = intval(round(70.0 * floatval($num_votes) / floatval($total_votes)));
                 } else {
                     $width = 0;
                 }
                 $answer_tpl = do_template('OCF_TOPIC_POLL_ANSWER_RESULTS', array('_GUID' => 'b32f4c526e147abf20ca0d668e40d515', 'ID' => strval($_poll['id']), 'NUM_VOTES' => integer_format($num_votes), 'WIDTH' => strval($width), 'ANSWER' => $answer['answer'], 'I' => strval($answer['id'])));
             } else {
                 $answer_tpl = do_template('OCF_TOPIC_POLL_ANSWER' . ($_poll['maximum_selections'] == 1 ? '_RADIO' : ''), array('REAL_BUTTON' => $real_button, 'ID' => strval($_poll['id']), 'ANSWER' => $answer['answer'], 'I' => strval($answer['id'])));
             }
             $answers->attach($answer_tpl);
         }
         $map = array('page' => 'topics', 'type' => 'vote_poll', 'id' => $id, 'start' => $start == 0 ? NULL : $start, 'max' => $max == $default_max ? NULL : $max);
         $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
         if ($test != -1 && $test != 0) {
             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
         }
         $test = get_param_integer('threaded', -1);
         if ($test != -1) {
             $map['threaded'] = $test;
         }
         $vote_url = build_url($map, get_module_zone('topics'));
         if ($_poll['is_private']) {
             $private = paragraph(do_lang_tempcode('TOPIC_POLL_IS_PRIVATE'), 'dfgsdgdsgs');
         } else {
             $private = new ocp_tempcode();
         }
         if ($_poll['maximum_selections'] > 1) {
             $num_choices = paragraph($_poll['minimum_selections'] == $_poll['maximum_selections'] ? do_lang_tempcode('POLL_NOT_ENOUGH_ERROR_2', integer_format($_poll['minimum_selections'])) : do_lang_tempcode('POLL_NOT_ENOUGH_ERROR', integer_format($_poll['minimum_selections']), integer_format($_poll['maximum_selections'])), 'dsfsdfsdfs');
         } else {
             $num_choices = new ocp_tempcode();
         }
         $poll = do_template('OCF_TOPIC_POLL' . ($poll_results ? '_VIEW_RESULTS' : ''), array('ID' => strval($_poll['id']), 'NUM_CHOICES' => $num_choices, 'PRIVATE' => $private, 'QUESTION' => $_poll['question'], 'ANSWERS' => $answers, 'REAL_BUTTON' => $real_button, 'BUTTON' => $button, 'VOTE_URL' => $vote_url, 'MINIMUM_SELECTIONS' => integer_format($_poll['minimum_selections']), 'MAXIMUM_SELECTIONS' => integer_format($_poll['maximum_selections'])));
     } else {
         $poll = new ocp_tempcode();
     }
     // Forum nav tree
     if (!is_null($topic_info['forum_id'])) {
         $tree = ocf_forum_breadcrumbs($topic_info['forum_id'], NULL, NULL, false);
     } else {
         $tree = new ocp_tempcode();
         $tree->attach(hyperlink(build_url(array('page' => 'members'), get_module_zone('members')), do_lang_tempcode('MEMBERS'), false, false, do_lang_tempcode('GO_BACKWARDS_TO', do_lang_tempcode('MEMBERS')), NULL, NULL, 'up'));
         $tree->attach(do_template('BREADCRUMB_ESCAPED'));
         if (has_specific_permission(get_member(), 'view_other_pt')) {
             $of_member = $topic_info['pt_from'] == get_member() ? $topic_info['pt_from'] : $topic_info['pt_to'];
         } else {
             $of_member = get_member();
         }
         $of_username = $GLOBALS['FORUM_DRIVER']->get_username($of_member);
         if (is_null($of_username)) {
             $of_username = do_lang('UNKNOWN');
         }
         $personal_topic_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $of_member), get_module_zone('members'), NULL, true, false, false, 'tab__pts');
         $tree->attach(hyperlink($personal_topic_url, do_lang_tempcode('MEMBER_PROFILE', escape_html($of_username)), false, false, do_lang_tempcode('GO_BACKWARDS_TO', do_lang_tempcode('MEMBERS')), NULL, NULL, 'up'));
     }
     // Quick reply
     if (array_key_exists('may_use_quick_reply', $topic_info) && $may_reply && !is_null($id)) {
         $map = array('page' => 'topics', 'type' => '_add_reply', 'topic_id' => $id);
         $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
         if ($test != -1 && $test != 0) {
             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
         }
         $test = get_param_integer('threaded', -1);
         if ($test != -1) {
             $map['threaded'] = $test;
         }
         $_post_url = build_url($map, get_module_zone('topics'));
         $post_url = $_post_url->evaluate();
         $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id);
         if ($test != -1 && $test != 0) {
             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
         }
         $more_url = build_url($map, get_module_zone('topics'));
         $_postdetails = array_key_exists('first_post', $topic_info) ? get_translated_tempcode($topic_info['first_post'], $GLOBALS['FORUM_DB']) : new ocp_tempcode();
         $first_post = $_postdetails;
         $first_post_url = $GLOBALS['FORUM_DRIVER']->post_url($topic_info['first_post_id'], is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']), true);
         $display = 'block';
         $expand_type = 'contract';
         if ($topic_info['max_rows'] > $start + $max) {
             $display = 'none';
             $expand_type = 'expand';
         }
         $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
         require_javascript('javascript_editing');
         require_javascript('javascript_validation');
         if (addon_installed('captcha')) {
             require_code('captcha');
             $use_captcha = use_captcha();
             if ($use_captcha) {
                 generate_captcha();
             }
         } else {
             $use_captcha = false;
         }
         $post_warning = '';
         if ($topic_info['is_really_threaded'] == 1) {
             $post_warning = do_lang('THREADED_REPLY_NOTICE', $post_warning);
         }
         $quick_reply = do_template('COMMENTS_POSTING_FORM', array('_GUID' => '4c532620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'USE_CAPTCHA' => $use_captcha, 'GET_EMAIL' => false, 'EMAIL_OPTIONAL' => true, 'GET_TITLE' => false, 'POST_WARNING' => $post_warning, 'COMMENT_TEXT' => '', 'EM' => $em, 'EXPAND_TYPE' => $expand_type, 'DISPLAY' => $display, 'FIRST_POST_URL' => $first_post_url, 'FIRST_POST' => $first_post, 'MORE_URL' => $more_url, 'COMMENT_URL' => $post_url, 'TITLE' => do_lang_tempcode('QUICK_REPLY'), 'SUBMIT_NAME' => do_lang_tempcode('MAKE_POST')));
     } else {
         $quick_reply = new ocp_tempcode();
     }
     $action_url = build_url(array('page' => 'topics', 'id' => $id), get_module_zone('topics'));
     if (!is_null($id)) {
         // Moderation options
         $moderator_actions = '';
         if (is_null($topic_info['forum_id'])) {
             $moderator_actions .= '<option value="categorise_pts">' . do_lang('_CATEGORISE_PTS') . '</option>';
         }
         if (array_key_exists('may_multi_moderate', $topic_info) && array_key_exists('forum_id', $topic_info)) {
             $multi_moderations = ocf_list_multi_moderations($topic_info['forum_id']);
             if (count($multi_moderations) != 0) {
                 $moderator_actions .= '<optgroup label="' . do_lang('MULTI_MODERATIONS') . '">';
                 foreach ($multi_moderations as $mm_id => $mm_name) {
                     $moderator_actions .= '<option value="mm_' . strval($mm_id) . '">' . $mm_name . '</option>';
                 }
                 $moderator_actions .= '</optgroup>';
             }
         }
         if (array_key_exists('may_move_topic', $topic_info)) {
             $moderator_actions .= '<option value="move_topic">' . do_lang('MOVE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_edit_topic', $topic_info)) {
             $moderator_actions .= '<option value="edit_topic">' . do_lang('EDIT_TOPIC') . '</option>';
         }
         if (array_key_exists('may_delete_topic', $topic_info)) {
             $moderator_actions .= '<option value="delete_topic">' . do_lang('DELETE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_pin_topic', $topic_info)) {
             $moderator_actions .= '<option value="pin_topic">' . do_lang('PIN_TOPIC') . '</option>';
         }
         if (array_key_exists('may_unpin_topic', $topic_info)) {
             $moderator_actions .= '<option value="unpin_topic">' . do_lang('UNPIN_TOPIC') . '</option>';
         }
         if (array_key_exists('may_sink_topic', $topic_info)) {
             $moderator_actions .= '<option value="sink_topic">' . do_lang('SINK_TOPIC') . '</option>';
         }
         if (array_key_exists('may_unsink_topic', $topic_info)) {
             $moderator_actions .= '<option value="unsink_topic">' . do_lang('UNSINK_TOPIC') . '</option>';
         }
         if (array_key_exists('may_cascade_topic', $topic_info)) {
             $moderator_actions .= '<option value="cascade_topic">' . do_lang('CASCADE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_uncascade_topic', $topic_info)) {
             $moderator_actions .= '<option value="uncascade_topic">' . do_lang('UNCASCADE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_open_topic', $topic_info)) {
             $moderator_actions .= '<option value="open_topic">' . do_lang('OPEN_TOPIC') . '</option>';
         }
         if (array_key_exists('may_close_topic', $topic_info)) {
             $moderator_actions .= '<option value="close_topic">' . do_lang('CLOSE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_edit_poll', $topic_info)) {
             $moderator_actions .= '<option value="edit_poll">' . do_lang('EDIT_TOPIC_POLL') . '</option>';
         }
         if (array_key_exists('may_delete_poll', $topic_info)) {
             $moderator_actions .= '<option value="delete_poll">' . do_lang('DELETE_TOPIC_POLL') . '</option>';
         }
         if (array_key_exists('may_attach_poll', $topic_info)) {
             $moderator_actions .= '<option value="add_poll">' . do_lang('ADD_TOPIC_POLL') . '</option>';
         }
         if (has_specific_permission(get_member(), 'view_content_history') && $GLOBALS['FORUM_DB']->query_value('f_post_history', 'COUNT(*)', array('h_topic_id' => $id)) != 0) {
             $moderator_actions .= '<option value="topic_history">' . do_lang('POST_HISTORY') . '</option>';
         }
         if (array_key_exists('may_make_personal', $topic_info) && !is_null($topic_info['forum_id'])) {
             $moderator_actions .= '<option value="make_personal">' . do_lang('MAKE_PERSONAL') . '</option>';
         }
         if ($GLOBALS['XSS_DETECT']) {
             ocp_mark_as_escaped($moderator_actions);
         }
         // Marked post actions
         $map = array('page' => 'topics', 'id' => $id);
         $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
         if ($test != -1 && $test != 0) {
             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
         }
         $test = get_param_integer('threaded', -1);
         if ($test != -1) {
             $map['threaded'] = $test;
         }
         $action_url = build_url($map, get_module_zone('topics'), NULL, false, true);
         $marked_post_actions = '';
         if (array_key_exists('may_move_posts', $topic_info)) {
             $marked_post_actions .= '<option value="move_posts_a">' . do_lang('MERGE_POSTS') . '</option>';
             $marked_post_actions .= '<option value="move_posts_b">' . do_lang('SPLIT_POSTS') . '</option>';
         }
         if (array_key_exists('may_delete_posts', $topic_info)) {
             $marked_post_actions .= '<option value="delete_posts">' . do_lang('DELETE_POSTS') . '</option>';
         }
         if (array_key_exists('may_validate_posts', $topic_info)) {
             $marked_post_actions .= '<option value="validate_posts">' . do_lang('VALIDATE_POSTS') . '</option>';
         }
         if (get_value('disable_multi_quote') !== '1') {
             if ($may_reply) {
                 $marked_post_actions .= '<option value="new_post">' . do_lang('QUOTE_POSTS') . '</option>';
             }
         }
         if ($GLOBALS['XSS_DETECT']) {
             ocp_mark_as_escaped($marked_post_actions);
         }
     } else {
         $moderator_actions = '';
         $marked_post_actions = '';
     }
     $max_rows = $topic_info['max_rows'];
     if ($max_rows > $max && !$threaded) {
         require_code('templates_results_browser');
         $results_browser = results_browser(do_lang_tempcode('FORUM_POSTS'), $id, $start, 'start', $max, 'max', $max_rows, NULL, 'misc', true, false, 7, array(10, 20, 30));
     } else {
         $results_browser = new ocp_tempcode();
     }
     // Members viewing this topic
     $members = is_null($id) ? array() : get_members_viewing('topicview', '', strval($id), true);
     $num_guests = 0;
     $num_members = 0;
     if (is_null($members)) {
         $members_viewing = new ocp_tempcode();
     } else {
         $members_viewing = new ocp_tempcode();
         foreach ($members as $member_id => $at_details) {
             $username = $at_details['mt_cache_username'];
             if (is_guest($member_id)) {
                 $num_guests++;
             } else {
                 $num_members++;
                 $profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, false, true);
                 $map = array('PROFILE_URL' => $profile_url, 'USERNAME' => $username);
                 if (has_specific_permission(get_member(), 'show_user_browsing') || in_array($at_details['the_page'], array('topics', 'topicview')) && $at_details['the_id'] == strval($id)) {
                     $map['AT'] = escape_html($at_details['the_title']);
                 }
                 $map['COLOUR'] = get_group_colour(ocf_get_member_primary_group($member_id));
                 $members_viewing->attach(do_template('OCF_USER_MEMBER', $map));
             }
         }
         if ($members_viewing->is_empty()) {
             $members_viewing = do_lang_tempcode('NONE_EM');
         }
     }
     if (!is_null($id)) {
         breadcrumb_add_segment($tree, do_lang_tempcode(is_null($topic_info['forum_id']) ? 'VIEW_PERSONAL_TOPIC' : 'VIEW_TOPIC'));
     }
     if (is_null($id)) {
         $root_forum_name = $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_name', array('id' => db_get_first_id()));
         $tree = hyperlink(build_url(array('page' => 'forumview', 'id' => db_get_first_id()), get_module_zone('forumview')), escape_html($root_forum_name), false, false, do_lang('GO_BACKWARDS_TO'));
         breadcrumb_add_segment($tree, do_lang('INLINE_PERSONAL_POSTS'));
     }
     if ($topic_info['validated'] == 0) {
         $warning_details = do_template('WARNING_TABLE', array('WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')));
     } else {
         $warning_details = new ocp_tempcode();
     }
     $topic_tpl = do_template('OCF_TOPIC_WRAP', array('_GUID' => 'bb201d5d59559e5e2bd60e7cf2e6f7e9', 'SERIALIZED_OPTIONS' => $serialized_options, 'HASH' => $hash, 'ID' => strval($id), 'TITLE' => $topic_info['title'], 'MAY_DOUBLE_POST' => has_specific_permission(get_member(), 'double_post'), 'LAST_POSTER' => array_key_exists('last_poster', $topic_info) ? is_null($topic_info['last_poster']) ? '' : strval($topic_info['last_poster']) : '', 'WARNING_DETAILS' => $warning_details, 'MAX' => strval($max), 'MAY_CHANGE_MAX' => array_key_exists('may_change_max', $topic_info), 'ACTION_URL' => $action_url, 'NUM_GUESTS' => integer_format($num_guests), 'NUM_MEMBERS' => integer_format($num_members), 'MEMBERS_VIEWING' => $members_viewing, 'RESULTS_BROWSER' => $results_browser, 'MODERATOR_ACTIONS' => $moderator_actions, 'MARKED_POST_ACTIONS' => $marked_post_actions, 'QUICK_REPLY' => $quick_reply, 'TREE' => $tree, 'POLL' => $poll, 'SCREEN_BUTTONS' => $buttons, 'POSTS' => $posts, 'THREADED' => $threaded));
     if (is_null($id)) {
         $title = get_page_title('INLINE_PERSONAL_POSTS');
     } else {
         if (is_null($topic_info['forum_id'])) {
             $title = get_page_title(do_lang_tempcode('NAMED_PERSONAL_TOPIC', escape_html($topic_info['title'])), false, NULL, do_lang_tempcode('READING_PERSONAL_TOPIC'));
         } else {
             if (addon_installed('awards')) {
                 require_code('awards');
                 $awards = find_awards_for('topic', strval($id));
             } else {
                 $awards = array();
             }
             $title = get_page_title(do_lang_tempcode('NAMED_TOPIC', escape_html($topic_info['title'])), false, NULL, NULL, $awards);
         }
     }
     return ocf_wrapper($title, $topic_tpl, true, false, $topic_info['forum_id']);
 }
コード例 #4
0
ファイル: downloads.php プロジェクト: erico-deh/ocPortal
 /**
  * The UI to view a download.
  *
  * @return tempcode		The UI
  */
 function dloadinfo_screen()
 {
     $id = get_param_integer('id');
     $root = get_param_integer('root', db_get_first_id(), true);
     // Basic Init
     $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         return warn_screen(get_page_title('SECTION_DOWNLOADS'), do_lang_tempcode('MISSING_RESOURCE'));
     }
     $myrow = $rows[0];
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=downloads&filter=' . strval($myrow['category_id']);
     if (!has_category_access(get_member(), 'downloads', strval($myrow['category_id']))) {
         access_denied('CATEGORY_ACCESS');
     }
     $name = get_translated_text($myrow['name']);
     list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems(get_page_name(), strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], $myrow['validated'], $myrow['submitter'], build_url(array('page' => '_SELF', 'type' => 'entry', 'id' => $id), '_SELF', NULL, false, false, true), $name, get_value('comment_forum__downloads'));
     // Views
     if (get_db_type() != 'xml') {
         $myrow['download_views']++;
         $GLOBALS['SITE_DB']->query_update('download_downloads', array('download_views' => $myrow['download_views']), array('id' => $id), '', 1, NULL, false, true);
     }
     // Tree
     $tree = download_breadcrumbs($myrow['category_id'], $root, false, get_zone_name());
     $title_to_use = do_lang_tempcode('DOWNLOAD_TITLE', escape_html($name));
     $title_to_use_2 = do_lang('DOWNLOAD_TITLE', $name);
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = find_awards_for('download', strval($id));
     } else {
         $awards = array();
     }
     $title = get_page_title($title_to_use, false, NULL, NULL, $awards);
     seo_meta_load_for('downloads_download', strval($id), $title_to_use_2);
     $warning_details = new ocp_tempcode();
     // Validation
     if ($myrow['validated'] == 0) {
         if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) {
             access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated');
         }
         $warning_details->attach(do_template('WARNING_TABLE', array('_GUID' => '5b1781b8fbb1ef9b8f47693afcff02b9', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))));
     }
     // Cost warning
     if ($myrow['download_cost'] != 0 && addon_installed('points')) {
         require_lang('points');
         $warning_details->attach(do_template('WARNING_TABLE', array('_GUID' => '05fc448bf79b373385723c5af5ec93af', 'WARNING' => do_lang_tempcode('WILL_COST', integer_format($myrow['download_cost'])))));
     }
     // Admin functions
     $edit_url = new ocp_tempcode();
     $add_img_url = new ocp_tempcode();
     if (has_actual_page_access(NULL, 'cms_downloads', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_downloads', array('downloads', $myrow['category_id']))) {
         $edit_url = build_url(array('page' => 'cms_downloads', 'type' => '_ed', 'id' => $id), get_module_zone('cms_downloads'));
     }
     if (addon_installed('galleries')) {
         if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_galleries', array('galleries', 'download_' . strval($id)))) {
             require_lang('galleries');
             $add_img_url = build_url(array('page' => 'cms_galleries', 'type' => 'ad', 'cat' => 'download_' . strval($id)), get_module_zone('cms_galleries'));
         }
     }
     // Outmoding
     if (!is_null($myrow['out_mode_id'])) {
         $outmode_url = build_url(array('page' => '_SELF', 'type' => 'entry', 'id' => $myrow['out_mode_id'], 'root' => $root == db_get_first_id() ? NULL : $root), '_SELF');
     } else {
         $outmode_url = new ocp_tempcode();
     }
     // Stats
     $add_date = get_timezoned_date($myrow['add_date'], false);
     // Additional information
     $additional_details = get_translated_tempcode($myrow['comments']);
     // Edit date
     if (!is_null($myrow['edit_date'])) {
         $edit_date = make_string_tempcode(get_timezoned_date($myrow['edit_date'], false));
     } else {
         $edit_date = new ocp_tempcode();
     }
     $images_details = new ocp_tempcode();
     $image_url = '';
     $counter = 0;
     if (addon_installed('galleries')) {
         // Images
         require_lang('galleries');
         $cat = 'download_' . strval($id);
         $map = array('cat' => $cat);
         if (!has_specific_permission(get_member(), 'see_unvalidated')) {
             $map['validated'] = 1;
         }
         $rows = $GLOBALS['SITE_DB']->query_select('images', array('*'), $map, 'ORDER BY id', 200);
         $div = 2;
         $_out = new ocp_tempcode();
         $_row = new ocp_tempcode();
         require_code('images');
         while (array_key_exists($counter, $rows)) {
             $row = $rows[$counter];
             //		$view_url=build_url(array('page'=>'galleries','type'=>'image','wide'=>1,'id'=>$row['id']),get_module_zone('galleries'));
             $view_url = $row['url'];
             if ($image_url == '') {
                 $image_url = $row['url'];
             }
             if (url_is_local($view_url)) {
                 $view_url = get_custom_base_url() . '/' . $view_url;
             }
             $thumb_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'galleries', 'images', $row['id']);
             $comment = get_translated_tempcode($row['comments']);
             $thumb = do_image_thumb($thumb_url, '');
             if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $row['submitter'], 'cms_galleries', array('galleries', 'download_' . strval($id)))) {
                 $iedit_url = build_url(array('page' => 'cms_galleries', 'type' => '_ed', 'id' => $row['id']), get_module_zone('cms_galleries'));
             } else {
                 $iedit_url = new ocp_tempcode();
             }
             $_content = do_template('DOWNLOAD_SCREEN_IMAGE', array('_GUID' => 'fba0e309aa0ae04891e32c65a625b177', 'ID' => strval($row['id']), 'VIEW_URL' => $view_url, 'EDIT_URL' => $iedit_url, 'THUMB' => $thumb, 'COMMENT' => $comment));
             $_row->attach(do_template('DOWNLOAD_GALLERY_IMAGE_CELL', array('_GUID' => '8400a832dbed64bb63f264eb3a038895', 'CONTENT' => $_content)));
             if ($counter % $div == 1 && $counter != 0) {
                 $_out->attach(do_template('DOWNLOAD_GALLERY_ROW', array('_GUID' => '205c4f5387e98c534d5be1bdfcccdd7d', 'CELLS' => $_row)));
                 $_row = new ocp_tempcode();
             }
             $counter++;
         }
         if (!$_row->is_empty()) {
             $_out->attach(do_template('DOWNLOAD_GALLERY_ROW', array('_GUID' => 'e9667ca2545ac72f85a873f236cbbd6f', 'CELLS' => $_row)));
         }
         $images_details = $_out;
     }
     // Download link
     $author = $myrow['author'];
     $author_url = addon_installed('authors') ? build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $author), get_module_zone('authors')) : new ocp_tempcode();
     // Licence
     $licence_title = NULL;
     $licence_url = NULL;
     $licence_hyperlink = NULL;
     $licence = $myrow['download_licence'];
     if (!is_null($licence)) {
         $licence_title = $GLOBALS['SITE_DB']->query_value_null_ok('download_licences', 'l_title', array('id' => $licence));
         if (!is_null($licence_title)) {
             $keep = symbol_tempcode('KEEP');
             $licence_url = find_script('download_licence') . '?id=' . strval($licence) . $keep->evaluate();
             $licence_hyperlink = do_template('HYPERLINK_POPUP_WINDOW', array('_GUID' => '10582f28c37ee7e9e462fdbd6a2cb8dd', 'TITLE' => '', 'CAPTION' => $licence_title, 'URL' => $licence_url, 'WIDTH' => '600', 'HEIGHT' => '500', 'REL' => 'license'));
         } else {
             $licence = NULL;
             // Orphaned
         }
     }
     breadcrumb_add_segment($tree, $title_to_use);
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => $myrow['author'], 'publisher' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Download', 'title' => get_translated_text($myrow['name']), 'identifier' => '_SEARCH:downloads:view:' . strval($id), 'description' => get_translated_text($myrow['description']), 'image' => $image_url);
     return do_template('DOWNLOAD_SCREEN', array('_GUID' => 'a9af438f84783d0d38c20b5f9a62dbdb', 'ORIGINAL_FILENAME' => $myrow['original_filename'], 'URL' => $myrow['url'], 'NUM_IMAGES' => strval($counter), 'TAGS' => get_loaded_tags('downloads'), 'LICENCE' => is_null($licence) ? NULL : strval($licence), 'LICENCE_TITLE' => $licence_title, 'LICENCE_HYPERLINK' => $licence_hyperlink, 'SUBMITTER' => strval($myrow['submitter']), 'EDIT_DATE' => $edit_date, 'EDIT_DATE_RAW' => is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']), 'VIEWS' => integer_format($myrow['download_views']), 'NAME' => $name, 'DATE' => $add_date, 'DATE_RAW' => strval($myrow['add_date']), 'NUM_DOWNLOADS' => integer_format($myrow['num_downloads']), 'TITLE' => $title, 'OUTMODE_URL' => $outmode_url, 'WARNING_DETAILS' => $warning_details, 'EDIT_URL' => $edit_url, 'ADD_IMG_URL' => $add_img_url, 'DESCRIPTION' => get_translated_tempcode($myrow['description']), 'ADDITIONAL_DETAILS' => $additional_details, 'IMAGES_DETAILS' => $images_details, 'ID' => strval($id), 'FILE_SIZE' => clean_file_size($myrow['file_size']), 'AUTHOR_URL' => $author_url, 'AUTHOR' => $author, 'TRACKBACK_DETAILS' => $trackback_details, 'RATING_DETAILS' => $rating_details, 'COMMENTS_DETAILS' => $comment_details));
 }
コード例 #5
0
ファイル: catalogues.php プロジェクト: erico-deh/ocPortal
/**
 * Display a catalogue entry
 *
 * @param  AUTO_LINK		Entry ID
 * @param  boolean		Whether to skip rendering a title
 * @return tempcode		Tempcode interface to display an entry
 */
function render_catalogue_entry_screen($id, $no_title = false)
{
    require_code('feedback');
    if (addon_installed('ecommerce')) {
        require_code('ecommerce');
    }
    require_code('images');
    require_css('catalogues');
    require_lang('catalogues');
    $entries = $GLOBALS['SITE_DB']->query_select('catalogue_entries', array('*'), array('id' => $id), '', 1);
    if (!array_key_exists(0, $entries)) {
        return warn_screen(get_page_title('CATALOGUES'), do_lang_tempcode('MISSING_RESOURCE'));
    }
    $entry = $entries[0];
    $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('*'), array('id' => $entry['cc_id']), '', 1);
    if (!array_key_exists(0, $categories)) {
        warn_exit(do_lang_tempcode('CAT_NOT_FOUND', strval($entry['cc_id'])));
    }
    $category = $categories[0];
    $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=catalogues&filter=' . strval($entry['cc_id']);
    $catalogue_name = $category['c_name'];
    $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue_name), '', 1);
    if (!array_key_exists(0, $catalogues)) {
        warn_exit(do_lang_tempcode('CATALOGUE_NOT_FOUND', $catalogue_name));
    }
    $catalogue = $catalogues[0];
    // Permission for here?
    if (!has_category_access(get_member(), 'catalogues_catalogue', $catalogue_name)) {
        access_denied('CATALOGUE_ACCESS');
    }
    if (get_value('disable_cat_cat_perms') !== '1' && !has_category_access(get_member(), 'catalogues_category', strval($entry['cc_id']))) {
        access_denied('CATEGORY_ACCESS');
    }
    $ecommerce = is_ecommerce_catalogue($catalogue_name);
    if ($ecommerce) {
        $tpl_set = 'products';
    } else {
        $tpl_set = $catalogue_name;
    }
    $root = get_param_integer('root', NULL);
    $map = get_catalogue_entry_map($entry, $catalogue, 'PAGE', $tpl_set, $root, NULL, NULL, true, true);
    if (get_db_type() != 'xml') {
        $entry['ce_views']++;
        $GLOBALS['SITE_DB']->query_update('catalogue_entries', array('ce_views' => $entry['ce_views']), array('id' => $id), '', 1, NULL, false, true);
    }
    // Validation
    if ($entry['ce_validated'] == 0) {
        if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) {
            access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated');
        }
        $map['WARNINGS'] = do_template('WARNING_TABLE', array('_GUID' => 'bf604859a572ca53e969bec3d91f9cfb', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')));
    } else {
        $map['WARNINGS'] = '';
    }
    //Finding any hook exists for this product--------------------
    if (addon_installed('ecommerce')) {
        $object = find_product(strval($id));
        if (is_object($object) && method_exists($object, 'get_custom_product_map_fields')) {
            $object->get_custom_product_map_fields($id, $map);
        }
    }
    //------------------------------------------------------------
    $map['ENTRY'] = do_template('CATALOGUE_' . $tpl_set . '_ENTRY', $map, NULL, false, 'CATALOGUE_DEFAULT_ENTRY');
    $map['ADD_DATE'] = get_timezoned_date($entry['ce_add_date']);
    $map['ADD_DATE_RAW'] = strval($entry['ce_add_date']);
    $map['EDIT_DATE'] = is_null($entry['ce_edit_date']) ? '' : get_timezoned_date($entry['ce_edit_date']);
    $map['EDIT_DATE_RAW'] = is_null($entry['ce_edit_date']) ? '' : strval($entry['ce_edit_date']);
    $map['VIEWS'] = integer_format($entry['ce_views']);
    $title_to_use = do_lang_tempcode($catalogue_name . '__CATALOGUE_ENTRY', $map['FIELD_0']);
    $title_to_use_2 = do_lang($catalogue_name . '__CATALOGUE_ENTRY', $map['FIELD_0_PLAIN'], NULL, NULL, NULL, false);
    if (is_null($title_to_use_2)) {
        $title_to_use = do_lang_tempcode('DEFAULT__CATALOGUE_ENTRY', $map['FIELD_0']);
        $title_to_use_2 = do_lang('DEFAULT__CATALOGUE_ENTRY', $map['FIELD_0_PLAIN']);
    }
    if ($no_title) {
        $map['TITLE'] = new ocp_tempcode();
    } else {
        if (addon_installed('awards')) {
            require_code('awards');
            $awards = find_awards_for('catalogue_entry', strval($id));
        } else {
            $awards = array();
        }
        $map['TITLE'] = get_page_title($title_to_use, false, NULL, NULL, $awards);
    }
    $map['SUBMITTER'] = strval($entry['ce_submitter']);
    require_code('seo2');
    if (is_object($title_to_use_2)) {
        $title_to_use_2 = $title_to_use_2->evaluate();
    }
    seo_meta_load_for('catalogue_entry', strval($id), strip_tags($title_to_use_2));
    if ($map['TREE'] === '') {
        $map['TREE'] = new ocp_tempcode();
        $url = build_url(array('page' => '_SELF', 'type' => 'index', 'id' => $catalogue_name), '_SELF');
        $map['TREE']->attach(hyperlink($url, escape_html(get_translated_text($catalogue['c_title'])), false, false, do_lang('INDEX')));
        $map['TREE']->attach(do_template('BREADCRUMB_ESCAPED'));
        $url = build_url(array('page' => '_SELF', 'type' => 'category', 'id' => $category['id']), '_SELF');
        $map['TREE']->attach(hyperlink($url, escape_html(get_translated_text($category['cc_title'])), false, false, do_lang('GO_BACKWARDS_TO', get_translated_text($category['cc_title'])), NULL, NULL, 'up'));
    }
    $map['CATEGORY_TITLE'] = get_translated_text($category['cc_title']);
    $map['CAT'] = strval($entry['cc_id']);
    $map['TAGS'] = get_loaded_tags('catalogue_entries');
    breadcrumb_add_segment($map['TREE'], $title_to_use);
    if (is_null($root)) {
        breadcrumb_set_parents(array(array('_SELF:_SELF:misc' . ($ecommerce ? ':ecommerce=1' : ''), do_lang('CATALOGUES'))));
    }
    $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $entry['ce_add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($entry['ce_submitter']), 'publisher' => '', 'modified' => is_null($entry['ce_edit_date']) ? '' : date('Y-m-d', $entry['ce_edit_date']), 'type' => get_translated_text($catalogue['c_title']) . ' entry', 'title' => comcode_escape($title_to_use_2), 'identifier' => '_SEARCH:catalogues:entry:' . strval($id), 'description' => '');
    return do_template('CATALOGUE_' . $tpl_set . '_ENTRY_SCREEN', $map, NULL, false, 'CATALOGUE_DEFAULT_ENTRY_SCREEN');
}
コード例 #6
0
ファイル: quiz.php プロジェクト: erico-deh/ocPortal
 /**
  * The UI for doing a quiz.
  *
  * @return tempcode	The result of execution.
  */
 function do_quiz()
 {
     $id = get_param_integer('id');
     $quizzes = $GLOBALS['SITE_DB']->query_select('quizzes', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $quizzes)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $quiz = $quizzes[0];
     $this->enforcement_checks($quiz);
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = find_awards_for('quiz', strval($id));
     } else {
         $awards = array();
     }
     $quiz_name = get_translated_text($quiz['q_name']);
     $title_to_use = do_lang_tempcode('THIS_WITH', do_lang_tempcode($quiz['q_type']), make_string_tempcode(escape_html($quiz_name)));
     $title_to_use_2 = do_lang('THIS_WITH_SIMPLE', do_lang($quiz['q_type']), $quiz_name);
     $title = get_page_title($title_to_use, false, NULL, NULL, $awards);
     seo_meta_load_for('quiz', strval($id), $title_to_use_2);
     $last_visit_time = $GLOBALS['SITE_DB']->query_value_null_ok('quiz_member_last_visit', 'v_time', array('v_quiz_id' => $id, 'v_member_id' => get_member()), 'ORDER BY v_time DESC');
     if (!is_null($last_visit_time)) {
         $timer_offset = time() - $last_visit_time;
         if (is_null($quiz['q_timeout']) || $timer_offset >= $quiz['q_timeout'] * 60) {
             $GLOBALS['SITE_DB']->query_delete('quiz_member_last_visit', array('v_member_id' => get_member(), 'v_quiz_id' => $id));
             $GLOBALS['SITE_DB']->query_insert('quiz_member_last_visit', array('v_quiz_id' => $id, 'v_time' => time(), 'v_member_id' => get_member()));
             $timer_offset = 0;
         }
     } else {
         $GLOBALS['SITE_DB']->query_insert('quiz_member_last_visit', array('v_quiz_id' => $id, 'v_time' => time(), 'v_member_id' => get_member()));
         $timer_offset = 0;
     }
     $questions = $GLOBALS['SITE_DB']->query_select('quiz_questions', array('*'), array('q_quiz' => $id), 'ORDER BY q_order');
     // If a test/quiz, randomly order questions
     //		if ($quiz['q_type']!='SURVEY') shuffle($questions);			No, could cause problems
     foreach ($questions as $i => $question) {
         $answers = $GLOBALS['SITE_DB']->query_select('quiz_question_answers', array('*'), array('q_question' => $question['id']), 'ORDER BY q_order');
         // If a test/quiz, randomly order answers
         if ($quiz['q_type'] != 'SURVEY') {
             shuffle($answers);
         }
         $questions[$i]['answers'] = $answers;
     }
     require_code('quiz');
     $fields = render_quiz($questions);
     breadcrumb_set_self(make_string_tempcode(escape_html(get_translated_text($quiz['q_name']))));
     // Validation
     if ($quiz['q_validated'] == 0) {
         if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) {
             access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated');
         }
         $warning_details = do_template('WARNING_TABLE', array('WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')));
     } else {
         $warning_details = new ocp_tempcode();
     }
     $type = 'Quiz';
     switch ($quiz['q_type']) {
         case 'COMPETITION':
             $type = 'Competition';
             break;
         case 'SURVEY':
             $type = 'Survey';
             break;
         case 'TEST':
             $type = 'Test';
             break;
     }
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $quiz['q_add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($quiz['q_submitter']), 'publisher' => '', 'modified' => '', 'type' => $type, 'title' => get_translated_text($quiz['q_name']), 'identifier' => '_SEARCH:quiz:do:' . strval($id), 'description' => get_translated_text($quiz['q_start_text']), 'image' => find_theme_image('bigicons/quiz'));
     $edit_url = new ocp_tempcode();
     if (has_actual_page_access(NULL, 'cms_quiz', NULL, NULL) && has_edit_permission('mid', get_member(), $quiz['q_submitter'], 'cms_quiz', array('quiz', $id))) {
         $edit_url = build_url(array('page' => 'cms_quiz', 'type' => '_ed', 'id' => $id), get_module_zone('cms_quiz'));
     }
     // Display UI: start text, questions. Including timeout
     $start_text = get_translated_tempcode($quiz['q_start_text']);
     $post_url = build_url(array('page' => '_SELF', 'type' => '_do', 'id' => $id), '_SELF');
     return do_template('QUIZ_SCREEN', array('_GUID' => 'f390877672938ba62f79f9528bef742f', 'EDIT_URL' => $edit_url, 'TAGS' => get_loaded_tags('quiz'), 'ID' => strval($id), 'WARNING_DETAILS' => $warning_details, 'URL' => $post_url, 'TITLE' => $title, 'START_TEXT' => $start_text, 'FIELDS' => $fields, 'TIMEOUT' => is_null($quiz['q_timeout']) ? '' : strval($quiz['q_timeout'] * 60 - $timer_offset)));
 }
コード例 #7
0
ファイル: calendar.php プロジェクト: erico-deh/ocPortal
 /**
  * View an event.
  *
  * @return tempcode		The UI
  */
 function view_event()
 {
     check_specific_permission('view_calendar');
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'back';
     $id = get_param_integer('id');
     $filter = $this->get_filter();
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=calendar&filter=' . implode(',', $this->get_and_filter());
     $rows = $GLOBALS['SITE_DB']->query_select('calendar_events e LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'calendar_types t ON t.id=e.e_type', array('*'), array('e.id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $event = $rows[0];
     if ($event['e_is_public'] == 0) {
         enforce_personal_access($event['e_submitter'], 'view_personal_events');
     }
     if (!has_category_access(get_member(), 'calendar', strval($event['e_type']))) {
         access_denied('CATEGORY_ACCESS');
     }
     // Validation
     $warning_details = new ocp_tempcode();
     if ($event['validated'] == 0 && $event['e_is_public'] == 1) {
         if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) {
             access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated');
         }
         $warning_details->attach(do_template('WARNING_TABLE', array('_GUID' => '332faacba974e648a67e5e91ffd3d8e5', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))));
     }
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = find_awards_for('event', strval($id));
     } else {
         $awards = array();
     }
     $_title = get_translated_text($event['e_title']);
     $title_to_use = do_lang_tempcode('CALENDAR_EVENT_VCAL', escape_html($_title));
     $title_to_use_2 = do_lang('CALENDAR_EVENT', $_title);
     $title = get_page_title($title_to_use, false, NULL, NULL, $awards);
     seo_meta_load_for('event', strval($id), $title_to_use_2);
     $content = $event['e_type'] == db_get_first_id() ? make_string_tempcode(get_translated_text($event['e_content'])) : get_translated_tempcode($event['e_content']);
     $type = get_translated_text($event['t_title']);
     $subscribed = new ocp_tempcode();
     if (has_specific_permission(get_member(), 'view_event_subscriptions') && cron_installed()) {
         $subscriptions = $GLOBALS['SITE_DB']->query_select('calendar_reminders', array('DISTINCT n_member_id'), array('e_id' => $id), '', 100);
         if (count($subscriptions) < 100) {
             foreach ($subscriptions as $subscription) {
                 $username = $GLOBALS['FORUM_DRIVER']->get_username($subscription['n_member_id']);
                 if (!is_null($username)) {
                     $member_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($subscription['n_member_id'], false, true);
                     $subscribed->attach(do_template('CALENDAR_SCREEN_SUBSCRIPTION', array('_GUID' => 'c756b8b3f0c57494fd46a94e9abce029', 'MEMBER_URL' => $member_url, 'USERNAME' => $username)));
                 }
             }
         }
     }
     $__first_date = mktime($event['e_start_hour'], $event['e_start_minute'], 0, $event['e_start_month'], $event['e_start_day'], $event['e_start_year']);
     $_first_date = cal_utctime_to_usertime($__first_date, $event['e_timezone'], $event['e_do_timezone_conv'] == 1);
     $first_date = date('Y-m-d', $_first_date);
     $date = get_param('date', $first_date);
     // It's year 10,000 compliant when it comes to year display ;).
     $back_type = get_param('back', 'day');
     $map = array_merge($filter, array('page' => '_SELF', 'type' => 'misc', 'view' => $back_type, 'id' => $date));
     if (get_param_integer('member_id', get_member()) != get_member()) {
         $map['member_id'] = get_param_integer('member_id');
     }
     $back_url = build_url($map, '_SELF');
     list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems('events', strval($id) . ($event['e_seg_recurrences'] == 1 ? '_' . $date : ''), $event['allow_rating'], $event['allow_comments'], $event['allow_trackbacks'], get_option('is_on_strong_forum_tie') == '0' || $event['e_is_public'] == 1 ? 1 : 0, $event['e_submitter'], build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $id), '_SELF', NULL, false, false, true), $_title, get_value('comment_forum__calendar'));
     $_subscriptions = new ocp_tempcode();
     if (is_guest() || !cron_installed()) {
         $subscribe_url = new ocp_tempcode();
     } else {
         $subscriptions = $GLOBALS['SITE_DB']->query_select('calendar_reminders', array('id', 'n_seconds_before'), array('e_id' => $id, 'n_member_id' => get_member()));
         foreach ($subscriptions as $subscription) {
             $time = display_time_period(intval($subscription['n_seconds_before']));
             $unsubscribe_url = build_url(array('page' => '_SELF', 'type' => 'unsubscribe_event', 'id' => $id, 'reminder_id' => $subscription['id']), '_SELF');
             $_subscriptions->attach(do_template('CALENDAR_SCREEN_PERSONAL_SUBSCRIPTION', array('_GUID' => 'cc36c75ea516abfab1c65328c0e290fc', 'UNSUBSCRIBE_URL' => $unsubscribe_url, 'TIME' => $time)));
         }
         $subscribe_url = build_url(array('page' => '_SELF', 'type' => 'subscribe_event', 'id' => $id), '_SELF');
     }
     if (has_actual_page_access(NULL, 'cms_calendar', NULL, NULL) && has_edit_permission($event['e_is_public'] == 0 ? 'low' : 'mid', get_member(), $event['e_submitter'], 'cms_calendar', array('calendar', $event['e_type']))) {
         $edit_url = build_url(array('page' => 'cms_calendar', 'type' => '_ed', 'id' => $id), get_module_zone('cms_calendar'));
     } else {
         $edit_url = new ocp_tempcode();
     }
     if ($event['e_seg_recurrences'] == 0) {
         $NON_CANONICAL_PARAMS[] = 'day';
         $NON_CANONICAL_PARAMS[] = 'date';
     }
     $day = get_param('day', '');
     if ($day != '') {
         $explode = explode('-', $day);
         if (count($explode) == 3) {
             if (is_null($event['e_start_hour'])) {
                 if (is_null($event['e_end_year']) || is_null($event['e_end_month']) || is_null($event['e_end_day'])) {
                     $event['e_end_day'] = $event['e_start_day'];
                     $event['e_end_month'] = $event['e_start_month'];
                     $event['e_end_year'] = $event['e_start_year'];
                 }
             }
             if (!is_null($event['e_end_year']) && !is_null($event['e_end_month']) && !is_null($event['e_end_day'])) {
                 $event['e_end_year'] += intval($explode[0]) - $event['e_start_year'];
                 $event['e_end_month'] += intval($explode[1]) - $event['e_start_month'];
                 $event['e_end_day'] += intval($explode[2]) - $event['e_start_day'];
             }
             $event['e_start_year'] = intval($explode[0]);
             $event['e_start_month'] = intval($explode[1]);
             $event['e_start_day'] = intval($explode[2]);
         }
     }
     $time_raw = cal_get_start_utctime_for_event($event['e_timezone'], $event['e_start_year'], $event['e_start_month'], $event['e_start_day'], $event['e_start_hour'], $event['e_start_minute'], $event['e_do_timezone_conv'] == 1);
     $from = cal_utctime_to_usertime($time_raw, $event['e_timezone'], $event['e_do_timezone_conv'] == 1);
     $day_formatted = locale_filter(date(do_lang('calendar_date'), $from));
     if (!is_null($event['e_end_year']) && !is_null($event['e_end_month']) && !is_null($event['e_end_day'])) {
         $to_raw = cal_get_end_utctime_for_event($event['e_timezone'], $event['e_end_year'], $event['e_end_month'], $event['e_end_day'], $event['e_end_hour'], $event['e_end_minute'], $event['e_do_timezone_conv'] == 1);
         $to = cal_utctime_to_usertime($to_raw, $event['e_timezone'], $event['e_do_timezone_conv'] == 1);
         $to_day_formatted = locale_filter(date(do_lang('calendar_date'), $to));
         $time2 = date_range($from, $to, !is_null($event['e_start_hour']));
     } else {
         $to_raw = NULL;
         $time2 = is_null($event['e_start_hour']) ? '' : locale_filter(my_strftime(do_lang('calendar_minute'), $from));
         $to = NULL;
         $to_day_formatted = NULL;
     }
     $priority = $event['e_priority'];
     $is_public = $event['e_is_public'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO');
     $recurrence = do_lang_tempcode('NA_EM');
     if ($event['e_recurrence'] != 'none' && $event['e_recurrence'] != '') {
         $l_code = explode(' ', strtoupper($event['e_recurrence']));
         $recurrence = do_lang_tempcode($l_code[0]);
         if (!is_null($event['e_recurrences'])) {
             $recurrence = do_lang_tempcode('RECURRENCE_ITERATION', $recurrence, make_string_tempcode(integer_format($event['e_recurrences'])));
         }
     } elseif ($day == '') {
         $day = $first_date;
     }
     $priority_lang = do_lang_tempcode('PRIORITY_' . strval($priority));
     // Views
     if (get_db_type() != 'xml') {
         $event['e_views']++;
         $GLOBALS['SITE_DB']->query_update('calendar_events', array('e_views' => $event['e_views']), array('id' => $id), '', 1, NULL, false, true);
     }
     breadcrumb_set_parents(array(array($back_url, do_lang_tempcode('CALENDAR'))));
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $event['e_add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($event['e_submitter']), 'publisher' => '', 'modified' => is_null($event['e_edit_date']) ? '' : date('Y-m-d', $event['e_edit_date']), 'type' => 'Calendar event', 'title' => get_translated_text($event['e_title']), 'identifier' => '_SEARCH:calendar:view:' . strval($id), 'description' => get_translated_text($event['e_content']), 'image' => find_theme_image('bigicons/calendar'));
     $map = array('TITLE' => $title, '_TITLE' => get_translated_text($event['e_title']), 'ID' => strval($id), 'TAGS' => get_loaded_tags('calendar'), 'WARNING_DETAILS' => $warning_details, 'SUBMITTER' => strval($event['e_submitter']), 'ADD_DATE' => get_timezoned_date($event['e_add_date']), 'ADD_DATE_RAW' => strval($event['e_add_date']), 'EDIT_DATE_RAW' => is_null($event['e_edit_date']) ? '' : strval($event['e_edit_date']), 'VIEWS' => integer_format($event['e_views']), 'LOGO' => $event['t_logo'], 'DAY' => $day_formatted, 'TO_DAY' => $to_day_formatted, 'RECURRENCE' => $recurrence, 'IS_PUBLIC' => $is_public, 'PRIORITY' => strval($priority), 'PRIORITY_LANG' => $priority_lang, 'TYPE' => $type, 'TIME' => $time2, 'TIME_RAW' => strval($time_raw), 'TIME_VCAL' => date('Y-m-d', $time_raw) . ' ' . date('H:i:s', $time_raw), 'TO_TIME_VCAL' => is_null($to_raw) ? NULL : date('Y-m-d', $to_raw) . ' ' . date('H:i:s', $to_raw), 'EDIT_URL' => $edit_url, 'SUBSCRIPTIONS' => $_subscriptions, 'SUBSCRIBE_URL' => $subscribe_url, 'BACK_URL' => $back_url, 'CONTENT' => $content, 'SUBSCRIBED' => $subscribed, 'RATING_DETAILS' => $rating_details, 'TRACKBACK_DETAILS' => $trackback_details, 'COMMENT_DETAILS' => $comment_details, '_GUID' => '602e6f86f586ef0a24efed950eafd426');
     if ($event['e_do_timezone_conv'] == 0) {
         $timezone_map = get_timezone_list();
         $map['TIMEZONE'] = $timezone_map[$event['e_timezone']];
     }
     return do_template('CALENDAR_SCREEN', $map);
 }
コード例 #8
0
ファイル: forumview.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (get_forum_type() != 'ocf') {
         warn_exit(do_lang_tempcode('NO_OCF'));
     } else {
         ocf_require_all_forum_stuff();
     }
     require_code('ocf_forumview');
     global $NON_CANONICAL_PARAMS;
     foreach (array_keys($_GET) as $key) {
         if (substr($key, 0, 3) == 'kfs') {
             $NON_CANONICAL_PARAMS[] = $key;
         }
     }
     $NON_CANONICAL_PARAMS[] = 'order';
     $type = get_param('type', 'misc');
     $current_filter_cat = get_param('category', '');
     $default_max = intval(get_option('forum_topics_per_page'));
     $max = get_param_integer('max', $default_max);
     if ($max > 50 && !has_specific_permission(get_member(), 'remove_page_split')) {
         $max = $default_max;
     }
     $root = get_param_integer('keep_forum_root', db_get_first_id());
     if ($type == 'pt') {
         $id = NULL;
         $start = get_param_integer('start', get_param_integer('kfs', 0));
         $of_member_id = get_param_integer('id', get_member());
     } else {
         $id = get_param_integer('id', db_get_first_id());
         $start = get_param_integer('start', get_param_integer('kfs' . strval($id), 0));
         $of_member_id = NULL;
     }
     $test = ocf_render_forumview($id, $current_filter_cat, $max, $start, $root, $of_member_id);
     if (is_array($test)) {
         list($content, $ltitle, $tree, $forum_name) = $test;
     } else {
         return $test;
     }
     if ($type != 'pt') {
         global $SEO_TITLE;
         $SEO_TITLE = $forum_name;
         breadcrumb_add_segment($tree);
     }
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = is_null($id) ? array() : find_awards_for('forum', strval($id));
     } else {
         $awards = array();
     }
     $title = get_page_title($ltitle, false, NULL, NULL, $awards);
     $ret = ocf_wrapper($title, $content, true, $type != 'pt', $id);
     return $ret;
 }
コード例 #9
0
ファイル: authors.php プロジェクト: erico-deh/ocPortal
 /**
  * The UI to view an author.
  *
  * @return tempcode		The UI
  */
 function show_author()
 {
     $author = get_param('id', NULL);
     if (is_null($author)) {
         if (is_guest()) {
             global $EXTRA_HEAD;
             $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
             // XHTMLXHTML
             warn_exit(do_lang_tempcode('USER_NO_EXIST'));
         }
         $author = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
     }
     if (is_null($author) || $author == '') {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     // Really don't want to have to search on this
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = find_awards_for('author', $author);
     } else {
         $awards = array();
     }
     $title = get_page_title('_AUTHOR', true, array(escape_html($author)), NULL, $awards);
     seo_meta_load_for('authors', $author);
     $rows = $GLOBALS['SITE_DB']->query_select('authors', array('url', 'description', 'skills'), array('author' => $author), '', 1);
     if (!array_key_exists(0, $rows)) {
         if (has_actual_page_access(get_member(), 'cms_authors') && has_edit_author_permission(get_member(), $author)) {
             $GLOBALS['HTTP_STATUS_CODE'] = '404';
             if (!headers_sent()) {
                 if (!browser_matches('ie') && strpos(ocp_srv('SERVER_SOFTWARE'), 'IIS') === false) {
                     header('HTTP/1.0 404 Not Found');
                 }
             }
             $_author_add_url = build_url(array('page' => 'cms_authors', 'type' => '_ad', 'author' => $author), get_module_zone('cms_authors'));
             $author_add_url = $_author_add_url->evaluate();
             $message = do_lang_tempcode('NO_SUCH_AUTHOR_CONFIGURE_ONE', escape_html($author), escape_html($author_add_url));
             attach_message($message, 'inform');
         } else {
             $message = do_lang_tempcode('NO_SUCH_AUTHOR', escape_html($author));
         }
         $details = array('author' => $author, 'url' => '', 'forum_handle' => $GLOBALS['FORUM_DRIVER']->get_member_from_username($author), 'description' => NULL, 'skills' => NULL);
         //return inform_screen($title,$message);
     } else {
         $details = $rows[0];
     }
     // Links associated with the mapping between the author and a forum member
     $handle = get_author_id_from_name($author);
     if (!is_null($handle)) {
         $forum_details = do_template('AUTHOR_SCREEN_POTENTIAL_ACTION_ENTRY', array('ACTION' => hyperlink($GLOBALS['FORUM_DRIVER']->member_profile_url($handle, true, true), do_lang_tempcode('AUTHOR_PROFILE'), false, false, '', NULL, NULL, 'me')));
         if (addon_installed('points')) {
             $give_points_url = build_url(array('page' => 'points', 'type' => 'member', 'id' => $handle), get_module_zone('points'));
             $point_details = do_template('AUTHOR_SCREEN_POTENTIAL_ACTION_ENTRY', array('ACTION' => hyperlink($give_points_url, do_lang_tempcode('AUTHOR_POINTS'))));
         } else {
             $point_details = new ocp_tempcode();
         }
     } else {
         $forum_details = new ocp_tempcode();
         $point_details = new ocp_tempcode();
     }
     // Homepage
     $url = $details['url'];
     if (strlen($url) > 0) {
         $url_details = do_template('AUTHOR_SCREEN_POTENTIAL_ACTION_ENTRY', array('ACTION' => hyperlink($url, do_lang_tempcode('AUTHOR_HOMEPAGE'), false, false, '', NULL, NULL, 'me')));
     } else {
         $url_details = new ocp_tempcode();
     }
     // (Self?) description
     $description = is_null($details['description']) ? new ocp_tempcode() : get_translated_tempcode($details['description']);
     // Skills
     $skills = is_null($details['skills']) ? new ocp_tempcode() : get_translated_tempcode($details['skills']);
     // Edit link, for staff
     if (has_edit_author_permission(get_member(), $author)) {
         $edit_author_url = build_url(array('page' => 'cms_authors', 'type' => '_ad', 'author' => $author), get_module_zone('cms_authors'));
         $staff_details = do_template('AUTHOR_SCREEN_POTENTIAL_ACTION_ENTRY', array('ACTION' => hyperlink($edit_author_url, do_lang_tempcode('DEFINE_AUTHOR'), false)));
     } else {
         $staff_details = new ocp_tempcode();
     }
     // Search link
     if (addon_installed('search')) {
         $search_url = build_url(array('page' => 'search', 'author' => $author), get_module_zone('search'));
         $search_details = do_template('AUTHOR_SCREEN_POTENTIAL_ACTION_ENTRY', array('ACTION' => hyperlink($search_url, do_lang_tempcode('SEARCH'), false)));
     } else {
         $search_details = new ocp_tempcode();
     }
     // Downloads
     $downloads_released = new ocp_tempcode();
     if (addon_installed('downloads')) {
         require_code('downloads');
         require_lang('downloads');
         $count = $GLOBALS['SITE_DB']->query_value('download_downloads', 'COUNT(*)', array('author' => $author, 'validated' => 1));
         if ($count > 50) {
             $downloads_released = paragraph(do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM'));
         } else {
             $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('*'), array('author' => $author, 'validated' => 1));
             require_code('downloads');
             foreach ($rows as $i => $myrow) {
                 if ($i != 0) {
                     $downloads_released->attach(do_template('BLOCK_SEPARATOR', array('_GUID' => 'ea789367b15bsddsdsdsc586e6e6536')));
                 }
                 if (has_category_access(get_member(), 'downloads', strval($myrow['category_id']))) {
                     $downloads_released->attach(get_download_html($myrow));
                 }
             }
         }
     }
     // News
     $news_released = new ocp_tempcode();
     if (addon_installed('news')) {
         require_lang('news');
         $count = $GLOBALS['SITE_DB']->query_value('news', 'COUNT(*)', array('author' => $author, 'validated' => 1));
         if ($count > 50) {
             $news_released = paragraph(do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM'));
         } else {
             $rows = $GLOBALS['SITE_DB']->query_select('news', array('*'), array('author' => $author, 'validated' => 1));
             foreach ($rows as $i => $row) {
                 if (has_category_access(get_member(), 'news', strval($row['news_category']))) {
                     $url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), get_module_zone('news'));
                     $_title = get_translated_tempcode($row['title']);
                     $title_plain = get_translated_text($row['title']);
                     $seo_bits = seo_meta_get_for('news', strval($row['id']));
                     $map = array('ID' => strval($row['id']), 'TAGS' => get_loaded_tags('news', explode(',', $seo_bits[0])), 'SUBMITTER' => strval($row['submitter']), 'DATE' => get_timezoned_date($row['date_and_time']), 'DATE_RAW' => strval($row['date_and_time']), 'URL' => $url, 'TITLE_PLAIN' => $title_plain, 'TITLE' => $_title);
                     if (get_option('is_on_comments') == '1' && !has_no_forum() && $row['allow_comments'] >= 1) {
                         $map['COMMENT_COUNT'] = '1';
                     }
                     $tpl = do_template('NEWS_BRIEF', $map);
                     $news_released->attach($tpl);
                 }
             }
         }
     }
     // Edit link
     $edit_url = new ocp_tempcode();
     if (has_edit_author_permission(get_member(), $author)) {
         $edit_url = build_url(array('page' => 'cms_authors', 'type' => '_ad', 'id' => $author), 'cms');
     }
     return do_template('AUTHOR_SCREEN', array('_GUID' => 'ea789367b15bc90fc28d1c586e6e6536', 'TAGS' => get_loaded_tags(), 'TITLE' => $title, 'EDIT_URL' => $edit_url, 'AUTHOR' => $author, 'NEWS_RELEASED' => $news_released, 'DOWNLOADS_RELEASED' => $downloads_released, 'STAFF_DETAILS' => $staff_details, 'POINT_DETAILS' => $point_details, 'SEARCH_DETAILS' => $search_details, 'URL_DETAILS' => $url_details, 'FORUM_DETAILS' => $forum_details, 'SKILLS' => $skills, 'DESCRIPTION' => $description));
 }
コード例 #10
0
ファイル: catalogues.php プロジェクト: erico-deh/ocPortal
 /**
  * The UI to show the index of a catalogue.
  *
  * @return tempcode		The UI
  */
 function view_catalogue_index()
 {
     $catalogue_name = get_param('id');
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=catalogues&filter=' . $catalogue_name;
     $catalogue_rows = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue_name), '', 1);
     if (!array_key_exists(0, $catalogue_rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $catalogue = $catalogue_rows[0];
     //$tpl_set=$catalogue_name;
     $description = get_translated_tempcode($catalogue['c_description']);
     $description_2 = get_translated_text($catalogue['c_description']);
     $title_to_use = do_lang_tempcode($catalogue_name . '__CATALOGUE_INDEX', escape_html(get_translated_text($catalogue['c_title'])));
     $title_to_use_2 = do_lang($catalogue_name . '__CATALOGUE_INDEX', escape_html(get_translated_text($catalogue['c_title'])), NULL, NULL, NULL, false);
     if (is_null($title_to_use_2)) {
         $title_to_use = do_lang_tempcode('DEFAULT__CATALOGUE_INDEX', escape_html(get_translated_text($catalogue['c_title'])));
     }
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = find_awards_for('catalogue', $catalogue_name);
     } else {
         $awards = array();
     }
     $title = get_page_title($title_to_use, false, NULL, NULL, $awards);
     if (!has_category_access(get_member(), 'catalogues_catalogue', $catalogue_name)) {
         access_denied('CATALOGUE_ACCESS');
     }
     if ($GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)', array('c_name' => $catalogue_name)) > 1000) {
         warn_exit(do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM'));
     }
     $rows_subcategories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('*'), array('c_name' => $catalogue_name));
     foreach ($rows_subcategories as $i => $subcategory) {
         $rows_subcategories[$i]['cc_title'] = get_translated_text($subcategory['cc_title']);
     }
     global $M_SORT_KEY;
     $M_SORT_KEY = 'cc_title';
     usort($rows_subcategories, 'multi_sort');
     $out = new ocp_tempcode();
     foreach ($rows_subcategories as $myrow) {
         if (get_value('disable_cat_cat_perms') !== '1' && !has_category_access(get_member(), 'catalogues_category', strval($myrow['id']))) {
             continue;
         }
         //		$count=$GLOBALS['SITE_DB']->query_value_null_ok('catalogue_entries','COUNT(*)',array('cc_id'=>$myrow['id'],'ce_validated'=>1));
         //		if (!($count>0)) continue;
         $url = build_url(array('page' => '_SELF', 'id' => $myrow['id'], 'type' => 'category'), '_SELF');
         $name = $myrow['cc_title'];
         $description = get_translated_tempcode($myrow['cc_description']);
         $child_counts = count_catalogue_category_children($myrow['id']);
         $num_children = $child_counts['num_children'];
         $num_entries = $child_counts['num_entries_children'];
         $display_string = do_lang_tempcode($catalogue['c_is_tree'] == 1 ? 'CATEGORY_SUBORDINATE' : 'CATEGORY_SUBORDINATE_2', integer_format($num_entries), integer_format($num_children));
         $out->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('_GUID' => 'f2550f5be8765b5d0349ee5523f739cb', 'NAME' => $name, 'DESCRIPTION' => $description, 'URL' => $url, 'TITLE' => '', 'COUNT' => $display_string)));
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc' . ($catalogue['c_ecommerce'] == 1 ? ':ecommerce=1' : ''), do_lang_tempcode('CATALOGUES'))));
     breadcrumb_set_self(make_string_tempcode(escape_html(get_translated_text($catalogue['c_title']))));
     $edit_url = build_url(array('page' => 'cms_catalogues', 'type' => '_edit_catalogue', 'id' => $catalogue_name), get_module_zone('cms_catalogues'));
     if (has_actual_page_access(NULL, 'cms_catalogues', NULL, array('catalogues_catalogue', $catalogue_name), 'submit_cat_midrange_content')) {
         $add_cat_url = build_url(array('page' => 'cms_catalogues', 'type' => 'add_category', 'catalogue_name' => $catalogue_name), get_module_zone('cms_catalogues'));
     } else {
         $add_cat_url = new ocp_tempcode();
     }
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $catalogue['c_add_date']), 'creator' => '', 'publisher' => '', 'modified' => '', 'type' => 'Catalogue', 'title' => get_translated_text($catalogue['c_title']), 'identifier' => '_SEARCH:catalogues:index:' . $catalogue_name, 'description' => $description_2);
     $catalogue_description = get_translated_tempcode($catalogue['c_description']);
     return do_template('INDEX_SCREEN_FANCIER_SCREEN', array('_GUID' => '9ac6f5967177b020bebfe8b4ace35eff', 'PRE' => $catalogue_description, 'POST' => '', 'TITLE' => $title, 'CATALOGUE' => $catalogue_name, 'DESCRIPTION' => $description, 'ADD_CAT_URL' => $add_cat_url, 'CONTENT' => $out, 'EDIT_URL' => $edit_url));
 }
コード例 #11
0
ファイル: news.php プロジェクト: erico-deh/ocPortal
 /**
  * The UI to view a news entry.
  *
  * @return tempcode		The UI
  */
 function view_news()
 {
     $id = get_param_integer('id');
     $blog = get_param_integer('blog', NULL);
     $filter = get_param('filter', '*');
     $filter_and = get_param('filter_and', '*');
     if ($blog === 1) {
         $first_bc = array('_SELF:_SELF:blog_select', do_lang_tempcode('BLOGS'));
     } elseif ($blog === 0) {
         $first_bc = array('_SELF:_SELF:cat_select', do_lang_tempcode('JUST_NEWS_CATEGORIES'));
     } else {
         $first_bc = array('_SELF:_SELF:select', do_lang_tempcode('NEWS_CATEGORIES'));
     }
     if ($blog === 1) {
         $parent_title = do_lang_tempcode('BLOG_NEWS_ARCHIVE');
     } else {
         if (is_numeric($filter)) {
             $news_cat_title = $GLOBALS['SITE_DB']->query_select('news_categories', array('nc_title'), array('id' => intval($filter)), '', 1);
             if (array_key_exists(0, $news_cat_title)) {
                 $news_cat_title[0]['text_original'] = get_translated_text($news_cat_title[0]['nc_title']);
                 $parent_title = make_string_tempcode(escape_html($news_cat_title[0]['text_original']));
             } else {
                 $parent_title = do_lang_tempcode('NEWS_ARCHIVE');
             }
         } else {
             $parent_title = do_lang_tempcode('NEWS_ARCHIVE');
         }
     }
     breadcrumb_set_parents(array($first_bc, array('_SELF:_SELF:misc' . ($blog === 1 ? ':blog=1' : ($blog === 0 ? ':blog=0' : '')) . ($filter == '*' ? '' : (is_numeric($filter) ? ':id=' . $filter : ':filter=' . $filter)) . ($filter_and == '*' ? '' : ':filter_and=' . $filter_and), $parent_title)));
     $rows = $GLOBALS['SITE_DB']->query_select('news', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         return warn_screen(get_page_title('NEWS'), do_lang_tempcode('MISSING_RESOURCE'));
     }
     $myrow = $rows[0];
     if (!has_category_access(get_member(), 'news', strval($myrow['news_category']))) {
         access_denied('CATEGORY_ACCESS');
     }
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = find_awards_for('news', strval($id));
     } else {
         $awards = array();
     }
     $_title = get_translated_tempcode($myrow['title']);
     $title_to_use = do_lang_tempcode($blog === 1 ? 'BLOG__NEWS' : '_NEWS', $_title);
     $title = get_page_title($title_to_use, false, NULL, NULL, $awards);
     seo_meta_load_for('news', strval($id), do_lang($blog === 1 ? 'BLOG__NEWS' : '_NEWS', get_translated_text($myrow['title'])));
     // Rating and comments
     $self_url_map = array('page' => '_SELF', 'type' => 'view', 'id' => $id);
     /*if ($filter!='*') $self_url_map['filter']=$filter;		Potentially makes URL too long for content topic to store, and we probably don't want to store this assumptive context anyway
     		if (($filter_and!='*') && ($filter_and!='')) $self_url_map['filter_and']=$filter_and;*/
     if (!is_null($blog)) {
         $self_url_map['blog'] = $blog;
     }
     list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems(get_page_name(), strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], $myrow['validated'], $myrow['submitter'], build_url($self_url_map, '_SELF', NULL, false, false, true), get_translated_text($myrow['title']), get_value('comment_forum__news'));
     $date = get_timezoned_date($myrow['date_and_time']);
     $author_url = addon_installed('authors') ? build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $myrow['author']), get_module_zone('authors')) : new ocp_tempcode();
     $author = $myrow['author'];
     $news_full = get_translated_tempcode($myrow['news_article']);
     $news_full_plain = get_translated_text($myrow['news_article']);
     if ($news_full->is_empty()) {
         $news_full = get_translated_tempcode($myrow['news']);
         $news_full_plain = get_translated_text($myrow['news']);
     }
     if (has_actual_page_access(NULL, $blog === 1 ? 'cms_blogs' : 'cms_news', NULL, NULL) && has_edit_permission('high', get_member(), $myrow['submitter'], $blog === 1 ? 'cms_blogs' : 'cms_news', array('news', $myrow['news_category']))) {
         $edit_url = build_url(array('page' => $blog === 1 ? 'cms_blogs' : 'cms_news', 'type' => '_ed', 'id' => $id), get_module_zone($blog === 1 ? 'cms_blogs' : 'cms_news'));
     } else {
         $edit_url = new ocp_tempcode();
     }
     $tmp = array('page' => '_SELF', 'type' => 'misc');
     if ($filter != '*') {
         $tmp[is_numeric($filter) ? 'id' : 'filter'] = $filter;
     }
     if ($filter_and != '*' && $filter_and != '') {
         $tmp['filter_and'] = $filter_and;
     }
     if (!is_null($blog)) {
         $tmp['blog'] = $blog;
     }
     $archive_url = build_url($tmp, '_SELF');
     // Validation
     if ($myrow['validated'] == 0) {
         if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) {
             access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated');
         }
         $warning_details = do_template('WARNING_TABLE', array('_GUID' => '5fd82328dc2ac9695dc25646237065b0', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')));
     } else {
         $warning_details = new ocp_tempcode();
     }
     // Views
     if (get_db_type() != 'xml') {
         $myrow['news_views']++;
         $GLOBALS['SITE_DB']->query_update('news', array('news_views' => $myrow['news_views']), array('id' => $id), '', 1, NULL, false, true);
     }
     if (($blog !== 1 || has_specific_permission(get_member(), 'have_personal_category', 'cms_news')) && has_actual_page_access(NULL, $blog === 1 ? 'cms_blogs' : 'cms_news', NULL, NULL) && has_submit_permission('high', get_member(), get_ip_address(), 'cms_news', array('news', $myrow['news_category']))) {
         $map = array('page' => $blog === 1 ? 'cms_blogs' : 'cms_news', 'type' => 'ad');
         if (is_numeric($filter)) {
             $map['cat'] = $filter;
         }
         $submit_url = build_url($map, get_module_zone('cms_news'));
     } else {
         $submit_url = new ocp_tempcode();
     }
     $news_cats = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'news_categories WHERE nc_owner IS NULL OR id=' . strval($myrow['news_category']));
     $news_cats = list_to_map('id', $news_cats);
     $img = find_theme_image($news_cats[$myrow['news_category']]['nc_img']);
     if (is_null($img)) {
         $img = '';
     }
     if ($myrow['news_image'] != '') {
         $img = $myrow['news_image'];
         if (url_is_local($img)) {
             $img = get_custom_base_url() . '/' . $img;
         }
     }
     $category = get_translated_text($news_cats[$myrow['news_category']]['nc_title']);
     $categories = array(strval($myrow['news_category']) => $category);
     $all_categories_for_this = $GLOBALS['SITE_DB']->query_select('news_category_entries', array('*'), array('news_entry' => $id));
     $NEWS_CATS = array();
     foreach ($all_categories_for_this as $category_for_this) {
         if (!array_key_exists($category_for_this['news_entry_category'], $news_cats)) {
             $_news_cats = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('id' => $category_for_this['news_entry_category']), '', 1);
             if (array_key_exists(0, $_news_cats)) {
                 $NEWS_CATS[$category_for_this['news_entry_category']] = $_news_cats[0];
             }
         }
         if (array_key_exists($category_for_this['news_entry_category'], $news_cats)) {
             $categories[strval($category_for_this['news_entry_category'])] = get_translated_text($news_cats[$category_for_this['news_entry_category']]['nc_title']);
         }
     }
     $newsletter_url = new ocp_tempcode();
     if (addon_installed('newsletter')) {
         require_lang('newsletter');
         if (has_actual_page_access(get_member(), 'admin_newsletter')) {
             $newsletter_url = build_url(array('page' => 'admin_newsletter', 'type' => 'new', 'from_news' => $id), get_module_zone('admin_newsletter'));
         }
     }
     breadcrumb_set_self(get_translated_tempcode($myrow['title']));
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['date_and_time']), 'creator' => $myrow['author'], 'publisher' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'News article', 'title' => get_translated_text($myrow['title']), 'identifier' => '_SEARCH:news:view:' . strval($id), 'image' => $img, 'description' => strip_comcode(get_translated_text($myrow['news'])));
     return do_template('NEWS_FULL_SCREEN', array('_GUID' => '7686b23934e22c493d4ac10ba6c475c4', 'ID' => strval($id), 'CATEGORY_ID' => strval($myrow['news_category']), 'BLOG' => $blog === 1, '_TITLE' => $_title, 'TAGS' => get_loaded_tags('news'), 'CATEGORIES' => $categories, 'NEWSLETTER_URL' => $newsletter_url, 'ADD_DATE_RAW' => strval($myrow['date_and_time']), 'EDIT_DATE_RAW' => is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']), 'SUBMITTER' => strval($myrow['submitter']), 'CATEGORY' => $category, 'IMG' => $img, 'TITLE' => $title, 'VIEWS' => integer_format($myrow['news_views']), 'COMMENT_DETAILS' => $comment_details, 'RATING_DETAILS' => $rating_details, 'TRACKBACK_DETAILS' => $trackback_details, 'DATE' => $date, 'AUTHOR' => $author, 'AUTHOR_URL' => $author_url, 'NEWS_FULL' => $news_full, 'NEWS_FULL_PLAIN' => $news_full_plain, 'EDIT_URL' => $edit_url, 'ARCHIVE_URL' => $archive_url, 'SUBMIT_URL' => $submit_url, 'WARNING_DETAILS' => $warning_details));
 }