/** * Standard interface stage of pointstore item purchase. * * @return tempcode The UI */ function action() { require_code('database_action'); $class = str_replace('hook_pointstore_', '', strtolower(get_class($this))); $title = get_page_title('OCGIFTS_TITLE'); require_code('form_templates'); $map = NULL; $category = either_param('category', ''); if ($category != '') { $map = array('category' => $category); } $max_rows = $GLOBALS['SITE_DB']->query_value('ocgifts', 'COUNT(*)', $map); $max = get_param_integer('max', 20); $start = get_param_integer('start', 0); require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('OCGIFTS_TITLE'), get_param('id'), $start, 'start', $max, 'max', $max_rows, NULL, NULL, true, true); $rows = $GLOBALS['SITE_DB']->query_select('ocgifts g', array('*', '(SELECT COUNT(*) FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'members_gifts m WHERE m.gift_id=g.id) AS popularity'), $map, 'ORDER BY popularity DESC', $max, $start); $username = get_param('username', ''); $gifts = array(); foreach ($rows as $gift) { $gift_url = build_url(array('page' => 'pointstore', 'type' => 'action_done', 'id' => 'ocgifts', 'gift' => $gift['id'], 'username' => $username), '_SEARCH'); $image_url = ''; if (is_file(get_custom_file_base() . '/' . rawurldecode($gift['image']))) { $image_url = get_custom_base_url() . '/' . $gift['image']; } $gifts[] = array('NAME' => $gift['name'], 'PRICE' => integer_format($gift['price']), 'POPULARITY' => integer_format($gift['popularity']), 'GIFT_URL' => $gift_url, 'IMAGE_URL' => $image_url); } $categories = collapse_1d_complexity('category', $GLOBALS['SITE_DB']->query_select('ocgifts', array('DISTINCT category'), NULL, 'ORDER BY category')); return do_template('POINTSTORE_OCGIFTS_GIFTS', array('TITLE' => $title, 'GIFTS' => $gifts, 'RESULTS_BROWSER' => $results_browser, 'CATEGORY' => $category, 'CATEGORIES' => $categories)); }
/** * Get tempcode to view the downloads in a download category. * * @param AUTO_LINK The download category ID * @param AUTO_LINK The virtual root * @param ?string Force an order (NULL: don't) * @return tempcode The UI */ function get_category_downloads($category_id, $root, $order = NULL) { $max = get_param_integer('max', 30); $start = get_param_integer('start', 0); // How many might there have been? (So we know how to browse pages nicely) $map = array('category_id' => $category_id); if (!has_specific_permission(get_member(), 'see_unvalidated')) { $map['validated'] = 1; } $max_rows = $GLOBALS['SITE_DB']->query_value('download_downloads', 'COUNT(*)', $map); // Quick security check if (is_null($order)) { $order = get_param('order', NULL); if (is_null($order)) { if ($max_rows < 1000) { $order = 't.text_original ASC'; } else { $order = 'num_downloads DESC'; } } } if (strtoupper($order) != strtoupper('t.text_original ASC') && strtoupper($order) != strtoupper('t.text_original DESC') && strtoupper($order) != strtoupper('file_size ASC') && strtoupper($order) != strtoupper('file_size DESC') && strtoupper($order) != strtoupper('num_downloads DESC') && strtoupper($order) != strtoupper('add_date ASC') && strtoupper($order) != strtoupper('add_date DESC')) { log_hack_attack_and_exit('ORDERBY_HACK'); } global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'order'; // Fetch $rows = $GLOBALS['SITE_DB']->query_select('download_downloads d LEFT JOIN ' . get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND d.name=t.id', array('d.*', 'text_original'), $map, 'ORDER BY ' . $order, $max, $start); $out = new ocp_tempcode(); foreach ($rows as $myrow) { if ($GLOBALS['RECORD_LANG_STRINGS_CONTENT'] || is_null($myrow['text_original'])) { $myrow['text_original'] = get_translated_text($myrow['description']); } $out->attach(get_download_html($myrow, true, false)); $out->attach(do_template('BLOCK_SEPARATOR', array('_GUID' => 'ea7sddsdsfds5bsddsdsdsc586e6e6536'))); } if ($out->is_empty()) { return $out; } require_code('templates_results_browser'); $out->attach(results_browser(do_lang_tempcode('SECTION_DOWNLOADS'), $category_id, $start, 'start', $max, 'max', $max_rows, $root, 'misc')); return $out; }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('activities'); require_css('activities'); require_javascript('javascript_activities'); require_javascript('javascript_jquery'); require_javascript('javascript_base64'); if (!array_key_exists('max', $map)) { $map['max'] = '10'; } if (array_key_exists('param', $map)) { $title = $map['param']; } else { $title = do_lang_tempcode('ACTIVITIES_TITLE'); } // See if we're displaying for a specific member if (array_key_exists('member', $map)) { $member_ids = array_map('intval', explode(',', $map['member'])); } else { // No specific user. Use ourselves. $member_ids = array(get_member()); } require_css('side_blocks'); require_lang('activities'); require_code('activities'); require_code('addons_overview'); $mode = array_key_exists('mode', $map) ? $map['mode'] : 'all'; $viewer_id = get_member(); //We'll need this later anyway. $guest_id = $GLOBALS['FORUM_DRIVER']->get_guest_id(); list($proceed_selection, $whereville) = find_activities($viewer_id, $mode, $member_ids); $can_remove_others = has_zone_access($viewer_id, 'adminzone') ? true : false; $content = array(); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'act_start'; $start = get_param_integer('act_start', 0); $max = get_param_integer('act_max', intval($map['max'])); if ($proceed_selection === true) { $max_rows = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'activities WHERE ' . $whereville); require_code('templates_results_browser'); $results_browser = results_browser(do_lang('ACTIVITIES_TITLE'), NULL, $start, 'act_start', $max, 'act_max', $max_rows, NULL, NULL, true, false, 7, NULL, 'tab__activities'); $activities = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'activities WHERE ' . $whereville . ' ORDER BY a_time DESC', $max, $start); if (!is_null($activities) && count($activities) > 0) { foreach ($activities as $row) { list($message, $memberpic, $datetime, $member_url, $lang_string) = render_activity($row); $content[] = array('LANG_STRING' => $lang_string, 'ADDON_ICON' => find_addon_icon($row['a_addon']), 'BITS' => $message, 'MEMPIC' => $memberpic, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($row['a_member_id']), 'DATETIME' => strval($datetime), 'MEMBER_URL' => $member_url, 'LIID' => strval($row['id']), 'ALLOW_REMOVE' => $row['a_member_id'] == $viewer_id || $can_remove_others ? '1' : '0'); } } } else { $results_browser = new ocp_tempcode(); } // No entries return do_template('BLOCK_MAIN_ACTIVITIES', array('TITLE' => $title, 'MODE' => $mode, 'MEMBER_IDS' => implode(',', $member_ids), 'CONTENT' => $content, 'GROW' => array_key_exists('grow', $map) ? $map['grow'] == '1' : true, 'RESULTS_BROWSER' => $results_browser, 'MAX' => $start == 0 ? strval($max) : NULL)); }
/** * View an overview of the members adverts on the system. * * @return tempcode The UI */ function adverts() { require_lang('classifieds'); require_code('catalogues'); require_code('ecommerce'); $member_id = get_param_integer('member_id', get_member()); $title = get_page_title($member_id == get_member() ? 'CLASSIFIED_ADVERTS' : '_CLASSIFIED_ADVERTS', true, array($GLOBALS['FORUM_DRIVER']->get_username($member_id))); if (is_guest()) { access_denied('NOT_AS_GUEST'); } enforce_personal_access($member_id); $start = get_param_integer('start', 0); $max = get_param_integer('max', 30); require_code('templates_results_browser'); $max_rows = $GLOBALS['SITE_DB']->query_value('catalogue_entries e JOIN ' . get_table_prefix() . 'classifieds_prices c ON c.c_catalogue_name=e.c_name', 'COUNT(*)', array('ce_submitter' => $member_id)); $rows = $GLOBALS['SITE_DB']->query_select('catalogue_entries e JOIN ' . get_table_prefix() . 'classifieds_prices c ON c.c_catalogue_name=e.c_name', array('e.*'), array('ce_submitter' => $member_id), 'GROUP BY e.id ORDER BY ce_add_date DESC'); if (count($rows) == 0) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } $ads = array(); foreach ($rows as $row) { $root = get_param_integer('root', NULL); $data_map = get_catalogue_entry_map($row, NULL, 'CATEGORY', 'DEFAULT', $root, NULL, array(0)); $ad_title = $data_map['FIELD_0']; $purchase_url = build_url(array('page' => 'purchase', 'type' => 'misc', 'filter' => 'CLASSIFIEDS_ADVERT', 'id' => $row['id']), get_module_zone('purchase')); // We'll show all transactions against this ad $transaction_details = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'transactions WHERE purchase_id=' . strval($row['id']) . ' AND item LIKE \'' . db_encode_like('CLASSIFIEDS\\_ADVERT\\_%') . '\''); $_transaction_details = array(); foreach ($transaction_details as $t) { list($found, ) = find_product_row($t['item']); if (!is_null($found)) { $item_title = $found[4]; } else { $item_title = $t['item']; } $_transaction_details[] = array('T_ID' => strval($t['id']), 'PURCHASE_ID' => strval($t['purchase_id']), 'STATUS' => $t['status'], 'REASON' => $t['reason'], 'AMOUNT' => float_format($t['amount']), 'T_CURRENCY' => $t['t_currency'], 'LINKED' => $t['linked'], 'T_TIME' => strval($t['t_time']), 'ITEM' => $t['item'], 'ITEM_TITLE' => $item_title, 'PENDING_REASON' => $t['pending_reason'], 'T_MEMO' => $t['t_memo'], 'T_VIA' => $t['t_via']); } $url_map = array('page' => 'catalogues', 'type' => 'entry', 'id' => $row['id'], 'root' => $root); $url = build_url($url_map, '_SELF'); // No known expiry status: put on free, or let expire if ($row['ce_last_moved'] == $row['ce_add_date']) { require_code('classifieds'); initialise_classified_listing($row); } $ads[] = array('AD_TITLE' => $ad_title, 'TRANSACTION_DETAILS' => $_transaction_details, 'DATE' => get_timezoned_date($row['ce_add_date']), 'DATE_RAW' => strval($row['ce_add_date']), 'EXPIRES_DATE' => get_timezoned_date($row['ce_last_moved']), 'EXPIRES_DATE_RAW' => strval($row['ce_last_moved']), 'ACTIVE' => $row['ce_validated'] == 1, 'PURCHASE_URL' => $purchase_url, 'ID' => strval($row['id']), 'URL' => $url, 'NUM_VIEWS' => integer_format($row['ce_views'])); } $results_browser = results_browser(do_lang('_CLASSIFIED_ADVERTS'), NULL, $start, 'start', $max, 'max', $max_rows, NULL, NULL, true); return do_template('CLASSIFIED_ADVERTS_SCREEN', array('TITLE' => $title, 'RESULTS_BROWSER' => $results_browser, 'ADS' => $ads)); }
/** * The UI to either show an existing ticket and allow a reply, or to start a new ticket. * * @return tempcode The UI */ function do_ticket() { require_lang('comcode'); $id = get_param('id', NULL); if ($id == '') { $id = NULL; } if (!is_null($id)) { $_temp = explode('_', $id); if (!isset($_temp[1])) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } // Normal topic, not a ticket! $ticket_owner = intval($_temp[0]); $ticket_id = $_temp[1]; if (is_guest()) { access_denied('NOT_AS_GUEST'); } $this->check_id($id); } else { $ticket_owner = get_member(); $ticket_id = uniqid('', true); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SUPPORT_TICKETS')))); $poster = ''; $new = true; $serialized_options = mixed(); $hash = mixed(); if (!is_guest() || is_null($id)) { $member = get_member(); $new = is_null($id); $num_to_show_limit = get_param_integer('max_comments', intval(get_option('comments_to_show_in_thread'))); $start = get_param_integer('start_comments', 0); if ($new) { $id = strval($member) . '_' . $ticket_id; $title = get_page_title('ADD_TICKET'); } else { $ticket_type = $GLOBALS['SITE_DB']->query_value_null_ok('tickets', 'ticket_type', array('ticket_id' => $id)); $ticket_type_text = get_translated_text($ticket_type); $ticket_type_details = get_ticket_type($ticket_type); $forum = 1; $topic_id = 1; $_ticket_type = 1; // These will be returned by reference $_comments = get_ticket_posts($id, $forum, $topic_id, $_ticket_type, $start, $num_to_show_limit); $_comments_all = get_ticket_posts($id, $forum, $topic_id, $_ticket_type); if (!is_array($_comments) || !array_key_exists(0, $_comments)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $ticket_title = $_comments[0]['title']; if ($ticket_title == '') { $ticket_title = do_lang('UNKNOWN'); } $title = get_page_title('_VIEW_SUPPORT_TICKET', true, array(escape_html($ticket_title), escape_html($ticket_type_text))); breadcrumb_set_self($ticket_title); } $ticket_page_text = comcode_to_tempcode(get_option('ticket_text'), NULL, true); $staff_details = new ocp_tempcode(); $types = $this->build_types_list(get_param('default', '')); $results_browser = NULL; if (!$new) { require_code('templates_internalise_screen'); $test_tpl = internalise_own_screen($title, 30, $_comments_all); if (is_object($test_tpl)) { return $test_tpl; } if (is_null($_comments)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } if (has_specific_permission(get_member(), 'support_operator')) { $staff_details = make_string_tempcode($GLOBALS['FORUM_DRIVER']->topic_url($topic_id, escape_html(get_option('ticket_forum_name')))); } else { $staff_details = new ocp_tempcode(); } require_code('topics'); $renderer = new OCP_Topic(); $renderer->_inject_posts_for_scoring_algorithm($_comments); $renderer->topic_id = $topic_id; // Posts $max_thread_depth = get_param_integer('max_thread_depth', intval(get_option('max_thread_depth'))); list($comments, $serialized_options, $hash) = $renderer->render_posts($num_to_show_limit, $max_thread_depth, true, $ticket_owner, array(), $forum); // Pagination if (!$renderer->is_threaded) { if (count($_comments_all) > $num_to_show_limit) { require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('COMMENTS'), NULL, $start, 'start_comments', $num_to_show_limit, 'max_comments', count($_comments_all), NULL, NULL, true); } } $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $_comments[0]['date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($_comments[0]['user']), 'publisher' => '', 'modified' => '', 'type' => 'Support ticket', 'title' => $_comments[0]['title'], 'identifier' => '_SEARCH:tickets:ticket:' . $id, 'description' => '', 'image' => find_theme_image('bigicons/tickets')); // "Staff only reply" tickbox if (get_forum_type() == 'ocf' && $GLOBALS['FORUM_DRIVER']->is_staff(get_member())) { require_code('form_templates'); $staff_only = form_input_tick(do_lang('TICKET_STAFF_ONLY'), do_lang('TICKET_STAFF_ONLY_DESCRIPTION'), 'staff_only', false); } else { $staff_only = new ocp_tempcode(); } } else { $comments = new ocp_tempcode(); $staff_only = new ocp_tempcode(); $ticket_type_details = get_ticket_type(NULL); } if ($poster == '' || $GLOBALS['FORUM_DRIVER']->get_guest_id() != intval($poster)) { $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser(); require_javascript('javascript_editing'); require_javascript('javascript_validation'); require_javascript('javascript_posting'); require_javascript('javascript_swfupload'); require_css('swfupload'); require_code('form_templates'); list($attachments, $attach_size_field) = get_forum_type() == 'ocf' ? get_attachments('post') : array(NULL, NULL); if (addon_installed('captcha')) { require_code('captcha'); $use_captcha = get_option('captcha_on_feedback') == '1' && use_captcha(); if ($use_captcha) { generate_captcha(); } } else { $use_captcha = false; } $comment_form = do_template('COMMENTS_POSTING_FORM', array('_GUID' => 'aaa32620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'USE_CAPTCHA' => $use_captcha, 'ATTACHMENTS' => $attachments, 'ATTACH_SIZE_FIELD' => $attach_size_field, 'POST_WARNING' => '', 'COMMENT_TEXT' => '', 'GET_EMAIL' => is_guest(), 'EMAIL_OPTIONAL' => is_guest() && $ticket_type_details['guest_emails_mandatory'], 'GET_TITLE' => true, 'EM' => $em, 'DISPLAY' => 'block', 'COMMENT_URL' => '', 'SUBMIT_NAME' => do_lang_tempcode('MAKE_POST'), 'TITLE' => do_lang_tempcode($new ? 'CREATE_TICKET_MAKE_POST' : 'MAKE_POST'))); } else { $comment_form = new ocp_tempcode(); } $post_url = build_url(array('page' => '_SELF', 'id' => $id, 'type' => 'post', 'redirect' => get_param('redirect', NULL)), '_SELF'); require_code('form_templates'); require_code('feedback'); list($warning_details, $ping_url) = handle_conflict_resolution(NULL, true); $other_tickets = new ocp_tempcode(); $our_topic = NULL; if (!is_guest($ticket_owner)) { $tickets_of_member = get_tickets($ticket_owner, NULL, true); if (!is_null($tickets_of_member)) { foreach ($tickets_of_member as $topic) { $ticket_id = extract_topic_identifier($topic['description']); if ($id != $ticket_id) { $url = build_url(array('page' => '_SELF', 'type' => 'ticket', 'id' => $ticket_id), '_SELF'); $_title = $topic['firsttitle']; $date = get_timezoned_date($topic['lasttime']); $ticket_owner_name = $GLOBALS['FORUM_DRIVER']->get_username($ticket_owner); if (is_null($ticket_owner_name)) { $profile_link = ''; } else { $profile_link = $GLOBALS['FORUM_DRIVER']->member_profile_url($ticket_owner, false, true); } $last_poster = $topic['lastusername']; $unclosed = !$GLOBALS['FORUM_DRIVER']->is_staff($topic['lastmemberid']); $params = array('NUM_POSTS' => integer_format($topic['num'] - 1), 'CLOSED' => strval($topic['closed']), 'URL' => $url, 'TITLE' => $_title, 'DATE' => $date, 'DATE_RAW' => strval($topic['lasttime']), 'PROFILE_LINK' => $profile_link, 'LAST_POSTER' => $last_poster, 'UNCLOSED' => $unclosed); $other_tickets->attach(do_template('SUPPORT_TICKET_LINK', $params)); } else { $our_topic = $topic; } } } } $toggle_ticket_closed_url = NULL; if (get_forum_type() == 'ocf' && !$new) { $toggle_ticket_closed_url = build_url(array('page' => '_SELF', 'type' => 'toggle_ticket_closed', 'id' => $id), '_SELF'); } $map = array('page' => '_SELF', 'type' => 'ticket'); if (get_param('default', '') != '') { $map['default'] = get_param('default'); } $add_ticket_url = build_url($map, '_SELF'); return do_template('SUPPORT_TICKET_SCREEN', array('_GUID' => 'd21a9d161008c6c44fe7309a14be2c5b', 'SERIALIZED_OPTIONS' => $serialized_options, 'HASH' => $hash, 'TOGGLE_TICKET_CLOSED_URL' => $toggle_ticket_closed_url, 'CLOSED' => is_null($our_topic) ? '0' : strval($our_topic['closed']), 'OTHER_TICKETS' => $other_tickets, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($ticket_owner), 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'NEW' => $new, 'TICKET_PAGE_TEXT' => $ticket_page_text, 'TYPES' => $types, 'STAFF_ONLY' => $staff_only, 'POSTER' => $poster, 'TITLE' => $title, 'COMMENTS' => $comments, 'COMMENT_FORM' => $comment_form, 'STAFF_DETAILS' => $staff_details, 'URL' => $post_url, 'ADD_TICKET_URL' => $add_ticket_url, 'RESULTS_BROWSER' => $results_browser)); } else { return inform_screen(get_page_title('ADD_TICKET'), do_lang_tempcode('SUCCESS')); } }
/** * The UI for an "regular mode" gallery. * * @param tempcode Rating area * @param tempcode Commenting area * @param ID_TEXT Our gallery ID * @param ID_TEXT Virtual root gallery * @param tempcode The description of the gallery * @param tempcode The tempcode for our visible child galleries * @param boolean Whether may "download this gallery" * @param tempcode The URL to "edit this gallery" * @param tempcode The URL to "add a gallery" * @param tempcode The URL to "submit an image to this gallery" * @param tempcode The URL to "submit a video to this gallery" * @param tempcode The title of the page (our of get_page_title) * @param string The gallery title * @param tempcode Sorting UI * @return tempcode The UI */ function do_gallery_regular_mode($rating_details, $comment_details, $cat, $root, $description, $children, $may_download, $edit_url, $add_gallery_url, $submit_image_url, $submit_video_url, $title, $fullname, $sorting) { $max = get_param_integer('max', get_default_gallery_max()); $start = get_param_integer('start', 0); if ($max < 1) { $max = 1; } $page_num = $max == 0 ? 0 : intval(floor(floatval($start) / floatval($max))) + 1; // Work out totals $num_images = $GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)', array('cat' => $cat)); $num_videos = $GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)', array('cat' => $cat)); $total_rows = $num_images + $num_videos; $total_pages = $max == 0 ? 1 : intval(ceil(floatval($total_rows) / floatval($max))); if ($total_pages == 0) { $total_pages = 1; } list($sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos) = $this->get_sort_order(); $where = db_string_equal_to('cat', $cat); if (!has_specific_permission(get_member(), 'see_unvalidated')) { $where .= ' AND validated=1'; } if (get_param('days', '') != '') { $where .= ' AND add_date>' . strval(time() - get_param_integer('days') * 60 * 60 * 24); } $rows = $GLOBALS['SITE_DB']->query('SELECT *' . $sql_suffix_videos . ' FROM ' . get_table_prefix() . 'videos e WHERE ' . $where . ' ORDER BY ' . $sort, $max, $start); if (count($rows) < $max) { $where = db_string_equal_to('cat', $cat); if (!has_specific_permission(get_member(), 'see_unvalidated')) { $where .= ' AND validated=1'; } $rows2 = $GLOBALS['SITE_DB']->query('SELECT *' . $sql_suffix_images . ' FROM ' . get_table_prefix() . 'images e WHERE ' . $where . ' ORDER BY ' . $sort, $max - count($rows), max(0, $start - $num_videos)); } else { $rows2 = array(); } $entries = new ocp_tempcode(); $image_select = get_param('select', '*'); $video_select = get_param('video_select', '*'); // Display videos foreach ($rows as $row_video) { $view_url = build_url(array('page' => '_SELF', 'type' => 'video', 'root' => $root == 'root' ? NULL : $root, 'wide' => 1, 'id' => $row_video['id'], 'start' => $start == 0 ? NULL : $start, 'max' => $start == get_default_gallery_max() ? NULL : $max, 'days' => get_param('days', '') == '' ? NULL : get_param('days'), 'sort' => $sort == 'add_date DESC' ? NULL : $sort, 'select' => $image_select == '*' ? NULL : $image_select, 'video_select' => $video_select == '*' ? NULL : $video_select), '_SELF'); $thumb_url = ensure_thumbnail($row_video['url'], $row_video['thumb_url'], 'galleries', 'videos', $row_video['id']); if ($thumb_url == '') { $thumb_url = find_theme_image('na'); } $thumb = do_image_thumb($thumb_url, '', true); $this_full_url = $row_video['url']; if (url_is_local($this_full_url)) { $this_full_url = get_custom_base_url() . '/' . $this_full_url; } $entry_rating_details = $row_video['allow_rating'] == 1 ? display_rating(get_self_url(true), get_translated_text($row_video['title']), 'videos', strval($row_video['id']), 'RATING_INLINE_STATIC', $row_video['submitter']) : NULL; $map = array('_GUID' => '395f0aa1212e69da5752d228a6efe54d', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_video['title']), 'DESCRIPTION' => get_translated_tempcode($row_video['comments']), 'CAT' => $cat, 'THUMB_URL' => $thumb_url, 'FULL_URL' => $this_full_url, 'ID' => strval($row_video['id']), 'VIEWS' => strval($row_video['video_views']), 'ADD_DATE_RAW' => strval($row_video['add_date']), 'EDIT_DATE_RAW' => is_null($row_video['edit_date']) ? '' : strval($row_video['edit_date']), 'SUBMITTER' => strval($row_video['submitter']), 'THUMB' => $thumb, 'VIEW_URL' => $view_url, 'VIDEO_DETAILS' => show_video_details($row_video)); $entry = do_template('GALLERY_VIDEO', $map); $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => 'bc0d3de5d0160b00e3250d78658888c1', 'ENTRY' => $entry) + $map)); } // Display images foreach ($rows2 as $row_image) { $view_url = build_url(array('page' => '_SELF', 'type' => 'image', 'root' => $root == 'root' ? NULL : $root, 'wide' => 1, 'id' => $row_image['id'], 'start' => $start == 0 ? NULL : $start, 'max' => $max == get_default_gallery_max() ? NULL : $max, 'days' => get_param('days', '') == '' ? NULL : get_param('days'), 'sort' => $sort == 'add_date DESC' ? NULL : $sort, 'select' => $image_select == '*' ? NULL : $image_select, 'video_select' => $video_select == '*' ? NULL : $video_select), '_SELF'); $thumb_url = ensure_thumbnail($row_image['url'], $row_image['thumb_url'], 'galleries', 'images', $row_image['id']); $thumb = do_image_thumb($thumb_url, '', true); $this_full_url = $row_image['url']; if (url_is_local($this_full_url)) { $file_size = file_exists(get_custom_file_base() . '/' . rawurldecode($this_full_url)) ? strval(filesize(get_custom_file_base() . '/' . rawurldecode($this_full_url))) : ''; $this_full_url = get_custom_base_url() . '/' . $this_full_url; } else { $file_size = ''; } $entry_rating_details = $row_image['allow_rating'] == 1 ? display_rating(get_self_url(true), get_translated_text($row_image['title']), 'images', strval($row_image['id']), 'RATING_INLINE_STATIC', $row_image['submitter']) : NULL; $map = array('_GUID' => 'aa70f543297e25379c49fa25d6dbcac0', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_image['title']), 'DESCRIPTION' => get_translated_tempcode($row_image['comments']), 'FILE_SIZE' => $file_size, 'CAT' => $cat, 'THUMB_URL' => $thumb_url, 'FULL_URL' => $this_full_url, 'ID' => strval($row_image['id']), 'VIEWS' => strval($row_image['image_views']), 'ADD_DATE_RAW' => strval($row_image['add_date']), 'EDIT_DATE_RAW' => is_null($row_image['edit_date']) ? '' : strval($row_image['edit_date']), 'SUBMITTER' => strval($row_image['submitter']), 'THUMB' => $thumb, 'VIEW_URL' => $view_url); $entry = do_template('GALLERY_IMAGE', $map); $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => 'ea12d7acf47eab493b6fb4658b3c0346', 'ENTRY' => $entry) + $map)); } // Member gallery? $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); // Results browser require_code('templates_results_browser'); $_selectors = array_map('intval', explode(',', get_option('gallery_selectors'))); $results_browser = results_browser(do_lang('ENTRY'), $cat, $start, 'start', $max, 'max', $total_rows, $root, 'misc', true, false, 10, $_selectors); return do_template('GALLERY_REGULAR_MODE_SCREEN', array('_GUID' => 'cec405597f47f5079b7c7f581fa6b5c2', 'SORTING' => $sorting, '_TITLE' => $fullname, 'MEMBER_ID' => is_null($member_id) ? '' : strval($member_id), 'RESULTS_BROWSER' => $results_browser, 'TAGS' => get_loaded_tags('galleries'), 'CAT' => $cat, 'MEMBER_DETAILS' => $member_details, 'RATING_DETAILS' => $rating_details, 'COMMENT_DETAILS' => $comment_details, 'ADD_GALLERY_URL' => $add_gallery_url, 'EDIT_URL' => $edit_url, 'CHILDREN' => $children, 'TITLE' => $title, 'DESCRIPTION' => $description, 'IMAGE_URL' => $submit_image_url, 'VIDEO_URL' => $submit_video_url, 'MAY_DOWNLOAD' => $may_download, 'ENTRIES' => $entries)); }
/** * UI to show details of an order * * @return tempcode The interface. */ function order_details() { $id = get_param_integer('id'); $title = get_page_title('MY_ORDER_DETAILS'); $order_title = do_lang('CART_ORDER', $id); //pagination $start = get_param_integer('start', 0); $max = get_param_integer('max', 10); require_code('templates_results_browser'); require_code('templates_results_table'); $sortables = array(); $query_sort = explode(' ', get_param('sort', 'p_name ASC'), 2); if (count($query_sort) == 1) { $query_sort[] = 'ASC'; } list($sortable, $sort_order) = $query_sort; $fields_title = results_field_title(array(do_lang_tempcode('SLNO'), do_lang_tempcode('PRODUCT_NAME'), do_lang_tempcode('THE_PRICE'), do_lang_tempcode('QUANTITY'), do_lang_tempcode('STATUS')), $sortables, 'sort', $sortable . ' ' . $sort_order); $max_rows = $GLOBALS['SITE_DB']->query_value_null_ok('shopping_order_details', 'COUNT(*)', array('order_id' => $id)); $results_browser = results_browser(do_lang_tempcode('ORDERS'), NULL, $start, 'start', $max, 'max', $max_rows, NULL, 'show_orders', true, true); $rows = $GLOBALS['SITE_DB']->query_select('shopping_order_details', array('*'), array('order_id' => $id), 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start); $product_entries = new ocp_tempcode(); breadcrumb_set_parents(array(array('_SEARCH:admin_ecommerce:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:misc', do_lang_tempcode('ORDERS')), array('_SELF:_SELF:show_orders', do_lang_tempcode('ORDER_LIST')))); foreach ($rows as $row) { $product_info_url = build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $row['p_id']), get_module_zone('catalogues')); $product_name = $row['p_name']; $product = hyperlink($product_info_url, $product_name, false, true, do_lang('VIEW')); $product_entries->attach(results_entry(array(escape_html(strval($row['p_id'])), $product, ecommerce_get_currency_symbol() . escape_html(float_format($row['p_price'], 2)), escape_html(strval($row['p_quantity'])), do_lang($row['dispatch_status'])), false, NULL)); } $text = do_lang_tempcode('ORDER_DETAILS_TEXT'); //Collecting order details $rows = $GLOBALS['SITE_DB']->query_select('shopping_order', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $data = $rows[0]; $results_table = results_table(do_lang_tempcode('PRODUCTS'), 0, 'start', $max_rows, 'max', $max_rows, $fields_title, $product_entries, $sortables, $sortable, $sort_order, 'sort', NULL, NULL, 'cart'); $ordered_by_member_id = $data['c_member']; $ordered_by_username = $GLOBALS['FORUM_DRIVER']->get_username($data['c_member']); $self_url = get_self_url(true, true); $ordr_act_submit = build_url(array('page' => '_SELF', 'type' => 'order_act', 'id' => $id, 'redirect' => $self_url), '_SELF'); $order_actions = do_template('ADMIN_ORDER_ACTIONS', array('ORDER_TITLE' => $order_title, 'ORDR_ACT_URL' => $ordr_act_submit, 'ORDER_STATUS' => do_lang($data['order_status']))); //Shipping address display $row = $GLOBALS['SITE_DB']->query_select('shopping_order_addresses', array('*'), array('order_id' => $id), '', 1); if (array_key_exists(0, $row)) { $address = $row[0]; $shipping_address = do_template('SHIPPING_ADDRESS', array('ADDRESS_NAME' => $address['address_name'], 'ADDRESS_STREET' => $address['address_street'], 'ADDRESS_CITY' => $address['address_city'], 'ADDRESS_ZIP' => $address['address_zip'], 'ADDRESS_COUNTRY' => $address['address_country'], 'RECEIVER_EMAIL' => $address['receiver_email'])); } else { $shipping_address = new ocp_tempcode(); } return do_template('ECOM_ADMIN_ORDERS_DETAILS_SCREEN', array('TITLE' => $title, 'TEXT' => $text, 'CURRENCY' => get_option('currency'), 'RESULT_TABLE' => $results_table, 'RESULTS_BROWSER' => $results_browser, 'ORDER_NUMBER' => strval($id), 'ADD_DATE' => get_timezoned_date($data['add_date'], true, false, true, true), 'TOTAL_PRICE' => float_format($data['tot_price'], 2), 'ORDERED_BY_MEMBER_ID' => strval($ordered_by_member_id), 'ORDERED_BY_USERNAME' => $ordered_by_username, 'ORDER_STATUS' => do_lang($data['order_status']), 'NOTES' => $data['notes'], 'PURCHASED_VIA' => $data['purchase_through'], 'ORDER_ACTIONS' => $order_actions, 'SHIPPING_ADDRESS' => $shipping_address)); }
/** * The UI to show the member directory. * * @return tempcode The UI */ function directory() { require_javascript('javascript_ajax'); require_javascript('javascript_ajax_people_lists'); $title = get_page_title('MEMBERS'); require_code('templates_internalise_screen'); $test_tpl = internalise_own_screen($title); if (is_object($test_tpl)) { return $test_tpl; } if (running_script('iframe')) { $get_url = find_script('iframe'); } else { $get_url = find_script('index'); } $hidden = new ocp_tempcode(); $hidden->attach(build_keep_form_fields('_SELF', true, array('filter'))); $hidden->attach(form_input_hidden('zone', get_zone_name())); $start = get_param_integer('md_start', 0); $max = get_param_integer('md_max', 50); $sortables = array('m_username' => do_lang_tempcode('USERNAME'), 'm_primary_group' => do_lang_tempcode('PRIMARY_GROUP'), 'm_cache_num_posts' => do_lang_tempcode('COUNT_POSTS'), 'm_join_time' => do_lang_tempcode('JOIN_DATE')); $default_sort_order = get_value('md_default_sort_order'); if (is_null($default_sort_order)) { $default_sort_order = 'm_join_time DESC'; } $test = explode(' ', get_param('md_sort', $default_sort_order), 2); if (count($test) == 1) { $test[] = 'ASC'; } list($sortable, $sort_order) = $test; if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) { log_hack_attack_and_exit('ORDERBY_HACK'); } global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'md_sort'; $group_filter = get_param('group_filter', ''); $_usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true, false, false, $group_filter == '' ? NULL : array(intval($group_filter))); $usergroups = array(); require_code('ocf_groups2'); foreach ($_usergroups as $group_id => $group) { $num = ocf_get_group_members_raw_count($group_id, true); $usergroups[$group_id] = array('USERGROUP' => $group, 'NUM' => strval($num)); } $query = 'FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id<>' . strval(db_get_first_id()); if (!has_specific_permission(get_member(), 'see_unvalidated')) { $query .= ' AND m_validated=1'; } if ($group_filter != '') { if (is_numeric($group_filter)) { $title = get_page_title('USERGROUP', true, array(escape_html($usergroups[intval($group_filter)]['USERGROUP']))); } require_code('ocfiltering'); $filter = ocfilter_to_sqlfragment($group_filter, 'm_primary_group', 'f_groups', NULL, 'm_primary_group', 'id'); $query .= ' AND ' . $filter; } $search = get_param('filter', ''); $sup = $search != '' ? ' AND m_username LIKE \'' . db_encode_like(str_replace('*', '%', $search)) . '\'' : ''; if ($sortable == 'm_join_time') { $query .= $sup . ' ORDER BY m_join_time ' . $sort_order . ',' . 'id ' . $sort_order; } else { $query .= $sup . ' ORDER BY ' . $sortable . ' ' . $sort_order; } $max_rows = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) ' . $query); $rows = $GLOBALS['FORUM_DB']->query('SELECT * ' . $query, $max, $start); if (count($rows) == 0) { return inform_screen($title, do_lang_tempcode('NO_RESULTS')); } $members = new ocp_tempcode(); $member_boxes = array(); require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('PRIMARY_GROUP'), do_lang_tempcode('COUNT_POSTS'), do_lang_tempcode('JOIN_DATE')), $sortables, 'md_sort', $sortable . ' ' . $sort_order); require_code('ocf_members2'); foreach ($rows as $row) { $link = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['id'], true, $row['m_username']); if ($row['m_validated'] == 0) { $link->attach(do_lang_tempcode('MEMBER_IS_UNVALIDATED')); } if ($row['m_validated_email_confirm_code'] != '') { $link->attach(do_lang_tempcode('MEMBER_IS_UNCONFIRMED')); } $member_primary_group = ocf_get_member_primary_group($row['id']); $primary_group = ocf_get_group_link($member_primary_group); $members->attach(results_entry(array($link, $primary_group, escape_html(integer_format($row['m_cache_num_posts'])), escape_html(get_timezoned_date($row['m_join_time']))))); $member_boxes[] = ocf_show_member_box($row['id'], true); } $results_table = results_table(do_lang_tempcode('MEMBERS'), $start, 'md_start', $max, 'md_max', $max_rows, $fields_title, $members, $sortables, $sortable, $sort_order, 'md_sort'); $results_browser = results_browser(do_lang_tempcode('MEMBERS'), NULL, $start, 'md_start', $max, 'md_max', $max_rows, NULL, NULL, true, true); $symbols = NULL; if (get_option('allow_alpha_search') == '1') { $alpha_query = $GLOBALS['FORUM_DB']->query('SELECT m_username FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id<>' . strval(db_get_first_id()) . ' ORDER BY m_username ASC'); $symbols = array(array('START' => '0', 'SYMBOL' => do_lang('ALL')), array('START' => '0', 'SYMBOL' => '#')); foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z') as $s) { foreach ($alpha_query as $i => $q) { if (strtolower(substr($q['m_username'], 0, 1)) == $s) { break; } } if (substr(strtolower($q['m_username']), 0, 1) != $s) { $i = intval($symbols[count($symbols) - 1]['START']); } $symbols[] = array('START' => strval(intval($max * floor(floatval($i) / floatval($max)))), 'SYMBOL' => $s); } } return do_template('OCF_MEMBER_DIRECTORY_SCREEN', array('_GUID' => '096767e9aaabce9cb3e6591b7bcf95b8', 'MAX' => strval($max), 'RESULTS_BROWSER' => $results_browser, 'MEMBER_BOXES' => $member_boxes, 'USERGROUPS' => $usergroups, 'HIDDEN' => $hidden, 'SYMBOLS' => $symbols, 'SEARCH' => $search, 'GET_URL' => $get_url, 'TITLE' => $title, 'RESULTS_TABLE' => $results_table)); }
/** * List all the buddies of a member. * * @return tempcode The UI */ function buddies_list() { $member_id = get_param_integer('id'); $title = get_page_title('BUDDIES', true, array(escape_html($GLOBALS['FORUM_DRIVER']->get_username($member_id)))); $text_id = do_lang_tempcode('BUDDIES', escape_html($GLOBALS['FORUM_DRIVER']->get_username($member_id))); $mode = get_param('mode', 'both'); // single, both $max = get_param_integer('max', 100); $start = get_param_integer('start', 0); if ($mode == 'both') { $query = $GLOBALS['SITE_DB']->get_table_prefix() . 'chat_buddies a LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'chat_buddies b ON a.member_liked=b.member_likes AND a.member_liked=' . strval($member_id) . ' WHERE (a.member_likes=' . strval(intval($member_id)) . ' OR a.member_liked=' . strval(intval($member_id)) . ') AND b.member_liked IS NULL'; $rows = $GLOBALS['SITE_DB']->query('SELECT a.* FROM ' . $query . ' ORDER BY date_and_time', $max, $start); } else { $query = $GLOBALS['SITE_DB']->get_table_prefix() . 'chat_buddies WHERE member_likes=' . strval(intval($member_id)); $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $query . ' ORDER BY date_and_time', $max, $start); } $max_rows = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $query); $buddies = array(); $blocked = collapse_1d_complexity('member_blocked', $GLOBALS['SITE_DB']->query_select('chat_blocking', array('member_blocked'), array('member_blocker' => $member_id))); $all_usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true); foreach ($rows as $i => $row) { $f_id = $row['member_liked'] == $member_id ? $row['member_likes'] : $row['member_liked']; if ($f_id == $row['member_likes'] || !in_array($f_id, $blocked)) { $appears_twice = $row['member_likes'] == $member_id && !is_null($GLOBALS['SITE_DB']->query_value('chat_buddies', 'member_likes', array('member_liked' => $member_id))); require_code('ocf_members2'); $friend_username = $GLOBALS['FORUM_DRIVER']->get_username($f_id); $friend_usergroup_id = $GLOBALS['FORUM_DRIVER']->get_member_row_field($f_id, 'm_primary_group'); $friend_usergroup = array_key_exists($friend_usergroup_id, $all_usergroups) ? $all_usergroups[$friend_usergroup_id] : do_lang_tempcode('UNKNOWN'); $mutual_label = do_lang('MUTUAL_FRIEND'); $box = ocf_show_member_box($f_id, false, NULL, NULL, true, $f_id == get_member() || $member_id == get_member() ? array($mutual_label => do_lang($appears_twice ? 'YES' : 'NO')) : NULL); if ($box->is_empty()) { continue; } $friend_map = array('USERGROUP' => $friend_usergroup, 'USERNAME' => $friend_username, 'URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($f_id, false, true), 'F_ID' => strval($f_id), 'BOX' => $box); $buddies[] = $friend_map; } } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHAT_LOBBY')))); require_code('templates_results_browser'); $results_browser = results_browser($text_id, NULL, $start, 'start', $max, 'max', $max_rows, NULL, 'buddies_list', true); return do_template('CHAT_BUDDIES_LIST_SCREEN', array('TITLE' => $title, 'BUDDIES' => $buddies, 'RESULTS_BROWSER' => $results_browser)); }
/** * Standard modular render function for profile tab hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return array A triple: The tab title, the tab contents, the suggested tab order */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('FORUM_POSTS'); $order = 20; if ($leave_to_ajax_if_possible) { return array($title, NULL, $order); } require_code('ocf_topics'); require_code('ocf_general'); require_lang('ocf'); $topics = new ocp_tempcode(); if (!has_no_forum()) { require_code('ocf_forumview'); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'post_start'; $NON_CANONICAL_PARAMS[] = 'post_max'; // Last 15 topics that member contributed to $n = get_param_integer('post_max', 10); $start = get_param_integer('post_start', 0); $forum1 = NULL; //$GLOBALS['FORUM_DRIVER']->forum_id_from_name(get_option('comments_forum_name')); $tf = get_option('ticket_forum_name', true); if (!is_null($tf)) { $forum2 = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($tf); } else { $forum2 = NULL; } $where_more = ''; if (!is_null($forum1)) { $where_more .= ' AND p_cache_forum_id<>' . strval((int) $forum1); } if (!is_null($forum2)) { $where_more .= ' AND p_cache_forum_id<>' . strval((int) $forum2); } $rows = $GLOBALS['FORUM_DB']->query('SELECT DISTINCT p_topic_id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE p_poster=' . strval((int) $member_id_of) . $where_more . ' ORDER BY p_time DESC', $n, $start); if (count($rows) != 0) { $max_rows = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(DISTINCT p_topic_id) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE p_poster=' . strval((int) $member_id_of) . $where_more); $where = ''; foreach ($rows as $row) { if ($where != '') { $where .= ' OR '; } $where .= 't.id=' . strval((int) $row['p_topic_id']); } $topic_rows = $GLOBALS['FORUM_DB']->query('SELECT t.*,lan.text_parsed AS _trans_post,l_time FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics t LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_read_logs l ON (t.id=l.l_topic_id AND l.l_member_id=' . strval((int) get_member()) . ') LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate lan ON t.t_cache_first_post=lan.id WHERE ' . $where); $topic_rows_map = array(); foreach ($topic_rows as $topic_row) { if (has_category_access(get_member(), 'forums', strval($topic_row['t_forum_id']))) { $topic_rows_map[$topic_row['id']] = $topic_row; } } $hot_topic_definition = intval(get_option('hot_topic_definition')); foreach ($rows as $row) { if (array_key_exists($row['p_topic_id'], $topic_rows_map)) { $topics->attach(ocf_render_topic(ocf_get_topic_array($topic_rows_map[$row['p_topic_id']], get_member(), $hot_topic_definition, true), false)); } } if (!$topics->is_empty()) { $forum_name = do_lang_tempcode('TOPICS_PARTICIPATED_IN', integer_format($start + 1) . '-' . integer_format($start + $n)); $marker = ''; $tree = new ocp_tempcode(); require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('FORUM_TOPICS'), NULL, $start, 'post_start', $n, 'post_max', $max_rows, NULL, 'view', true, false, 7, NULL, 'tab__posts'); $topics = do_template('OCF_FORUM_TOPIC_WRAPPER', array('_GUID' => '8723270b128b4eea47ab3c756b342e14', 'ORDER' => '', 'MAX' => '15', 'MAY_CHANGE_MAX' => false, 'TREE' => $tree, 'ACTION_URL' => get_self_url(), 'BUTTONS' => '', 'STARTER_TITLE' => '', 'MARKER' => $marker, 'FORUM_NAME' => $forum_name, 'TOPICS' => $topics, 'RESULTS_BROWSER' => $results_browser, 'MODERATOR_ACTIONS' => '')); } } } $content = do_template('OCF_MEMBER_PROFILE_POSTS', array('MEMBER_ID' => strval($member_id_of), 'TOPICS' => $topics)); return array($title, $content, $order); }
/** * The UI to show the edit/delete history of posts (exact history shown depending on GET parameters). * * @return tempcode The UI */ function gui() { check_specific_permission('view_content_history'); $member_id = get_param_integer('member_id', -1); $post_id = get_param_integer('post_id', -1); $topic_id = get_param_integer('topic_id', -1); $where = array(); if ($member_id != -1) { $where['h_owner_member_id'] = $member_id; $title = get_page_title('POST_HISTORY_MEMBER'); } if ($post_id != -1) { $where['h_post_id'] = $post_id; $title = get_page_title('POST_HISTORY_POST'); } if ($topic_id != -1) { $where['h_topic_id'] = $topic_id; $title = get_page_title('POST_HISTORY_TOPIC'); } if (count($where) == 0) { $where = NULL; $title = get_page_title('POST_HISTORY'); } require_code('templates_internalise_screen'); $test_tpl = internalise_own_screen($title); if (is_object($test_tpl)) { return $test_tpl; } $start = get_param_integer('start', 0); $max = get_param_integer('max', 40); $max_rows = $GLOBALS['FORUM_DB']->query_value('f_post_history', 'COUNT(*)', $where); $posts = $GLOBALS['FORUM_DB']->query_select('f_post_history', array('*'), $where, 'ORDER BY h_action_date_and_time DESC', $max, $start); $content = new ocp_tempcode(); foreach ($posts as $post) { $create_date_and_time = get_timezoned_date($post['h_create_date_and_time']); $action_date_and_time = get_timezoned_date($post['h_action_date_and_time']); $owner_member = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($post['h_owner_member_id']); $alterer_member = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($post['h_alterer_member_id']); // Action/Link $topic_exists = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics', 'id', array('id' => $post['h_topic_id'])); if (!is_null($topic_exists)) { if ($post['h_action'] == 'EDIT_POST') { $relates_to = build_url(array('page' => 'topicview', 'type' => 'findpost', 'id' => $post['h_post_id']), get_module_zone('topicview')); $relates_to->attach('#post_' . strval($post['h_post_id'])); $relates_text = do_lang_tempcode('VIEW_POST'); $relates_tooltip = 'post#' . strval($post['h_post_id']); } elseif ($post['h_action'] == 'DELETE_POST') { $relates_to = build_url(array('page' => 'topicview', 'id' => $post['h_topic_id']), get_module_zone('topicview')); $relates_text = do_lang_tempcode('VIEW_TOPIC'); $relates_tooltip = 'topic#' . strval($post['h_topic_id']); } $link = hyperlink($relates_to, $relates_text, false, true, $relates_tooltip); } else { $link = new ocp_tempcode(); } $action = do_lang($post['h_action']); // Buttons $buttons = new ocp_tempcode(); if (has_specific_permission(get_member(), 'delete_content_history')) { $url = build_url(array('page' => '_SELF', 'type' => 'delete', 'h_id' => $post['id']), '_SELF', NULL, true); $buttons->attach(do_template('SCREEN_ITEM_BUTTON', array('_GUID' => '11c9f9ef4a646493544cb29778134960', 'IMMEDIATE' => true, 'URL' => $url, 'IMG' => 'delete', 'TITLE' => do_lang_tempcode('DELETE_HISTORY_POST')))); } if (has_specific_permission(get_member(), 'restore_content_history') && !is_null($topic_exists) && $post['h_action'] == 'DELETE_POST') { $url = build_url(array('page' => '_SELF', 'type' => 'restore', 'h_id' => $post['id']), '_SELF', NULL, true); $buttons->attach(do_template('SCREEN_ITEM_BUTTON', array('_GUID' => '49623e00065f488bb27097bb722232dc', 'IMMEDIATE' => true, 'URL' => $url, 'IMG' => 'restore', 'TITLE' => do_lang_tempcode('RESTORE_HISTORY_POST')))); } if (has_specific_permission(get_member(), 'restore_content_history') && !is_null($topic_exists) && $post['h_action'] == 'EDIT_POST') { $url = build_url(array('page' => '_SELF', 'type' => 'revert', 'h_id' => $post['id']), '_SELF', NULL, true); $buttons->attach(do_template('SCREEN_ITEM_BUTTON', array('_GUID' => '3f41d4d399676972c01ebb14f6ee56db', 'IMMEDIATE' => true, 'URL' => $url, 'IMG' => 'choose', 'TITLE' => do_lang_tempcode('REVERT_HISTORY_POST')))); } $content->attach(do_template('OCF_HISTORY_POST', array('_GUID' => 'f3512689a8b3fcf4215f63f9f340cdac', 'LABEL' => do_lang_tempcode('BEFORE_ACTION'), 'RAND' => uniqid(''), 'LINK' => $link, 'BUTTONS' => $buttons, 'ACTION' => $action, 'ACTION_DATE_AND_TIME' => $action_date_and_time, 'ACTION_DATE_AND_TIME_RAW' => strval($post['h_action_date_and_time']), 'CREATE_DATE_AND_TIME_RAW' => strval($post['h_create_date_and_time']), 'CREATE_DATE_AND_TIME' => $create_date_and_time, 'OWNER_MEMBER' => $owner_member, 'ALTERER_MEMBER' => $alterer_member, 'BEFORE' => $post['h_before']))); } if (count($posts) != 0 && $post_id != -1) { $original_post = $GLOBALS['FORUM_DB']->query_select('f_posts', array('*'), array('id' => $post_id), '', 1); if (array_key_exists(0, $original_post)) { $action = do_lang('CURRENT'); $link = hyperlink(build_url(array('page' => 'topicview', 'type' => 'findpost', 'id' => $post_id), get_module_zone('topicview')), do_lang_tempcode('VIEW_POST'), false, true); $buttons = new ocp_tempcode(); $action_date_and_time = ''; $action_date_and_time_raw = ''; $owner_member = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($original_post[0]['p_poster']); $alterer_member = new ocp_tempcode(); $before = get_translated_text($original_post[0]['p_post'], $GLOBALS['FORUM_DB']); $create_date_and_time = get_timezoned_date($original_post[0]['p_time']); $create_date_and_time_raw = strval($original_post[0]['p_time']); $content2 = do_template('OCF_HISTORY_POST', array('_GUID' => 'a3512689a8b3fcf4215f63f9f340cdac', 'LABEL' => do_lang_tempcode('CURRENT_STATUS'), 'RAND' => uniqid(''), 'LINK' => $link, 'BUTTONS' => $buttons, 'ACTION' => $action, 'ACTION_DATE_AND_TIME' => $action_date_and_time, 'ACTION_DATE_AND_TIME_RAW' => $action_date_and_time_raw, 'CREATE_DATE_AND_TIME_RAW' => $create_date_and_time_raw, 'CREATE_DATE_AND_TIME' => $create_date_and_time, 'OWNER_MEMBER' => $owner_member, 'ALTERER_MEMBER' => $alterer_member, 'BEFORE' => $before)); $content2->attach($content); $content = $content2; } } require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('POST_HISTORY'), NULL, $start, 'start', $max, 'max', $max_rows, NULL, 'misc', true); return do_template('OCF_HISTORY_SCREEN', array('_GUID' => '7dd45ce985fc7222771368336c3f19e4', 'RESULTS_BROWSER' => $results_browser, 'TITLE' => $title, 'CONTENT' => $content)); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_css('galleries'); require_lang('galleries'); require_code('galleries'); require_code('images'); require_code('feedback'); require_code('ocfiltering'); $cat = array_key_exists('param', $map) ? $map['param'] : 'root'; $cat_select = ocfilter_to_sqlfragment($cat, 'cat', 'galleries', 'parent_id', 'cat', 'name', false, false); $title = array_key_exists('title', $map) ? $map['title'] : ''; /*if ((file_exists(get_custom_file_base().'/themes/default/templates_custom/JAVASCRIPT_GALLERIES.tpl')) || (file_exists(get_file_base().'/themes/default/templates/JAVASCRIPT_GALLERIES.tpl'))) require_javascript('javascript_galleries');*/ $max = get_param_integer('mge_max', array_key_exists('max', $map) ? intval($map['max']) : 30); $start = get_param_integer('mge_start', 0); if (!array_key_exists('select', $map)) { $map['select'] = '*'; } $image_select = ocfilter_to_sqlfragment($map['select'], 'id'); if (!array_key_exists('video_select', $map)) { $map['video_select'] = '*'; } $video_select = ocfilter_to_sqlfragment($map['video_select'], 'id'); $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('galleries'); $_days = array_key_exists('days', $map) ? $map['days'] : ''; $days = mixed(); $days = $_days == '' ? NULL : intval($_days); $where_sup = ''; if (!is_null($days)) { $where_sup .= ' AND add_date>=' . strval(time() - $days * 60 * 60 * 24); } $sort = array_key_exists('sort', $map) ? $map['sort'] : 'add_date DESC'; if ($sort != 'random ASC' && $sort != 'fixed_random ASC' && $sort != 'compound_rating DESC' && $sort != 'compound_rating ASC' && $sort != 'add_date DESC' && $sort != 'add_date ASC' && $sort != 'url DESC' && $sort != 'url ASC') { $sort = 'add_date DESC'; } list($_sort, $_dir) = explode(' ', $sort, 2); $total_images = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'images WHERE ' . $cat_select . ' AND ' . $image_select . $where_sup); $total_videos = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'videos WHERE ' . $cat_select . ' AND ' . $video_select . $where_sup); if ($_sort == 'random') { $start = 0; $max = min($total_images + $total_videos, $max); $done_images = '1=1'; $done_videos = '1=1'; $rows_images = array(); $rows_videos = array(); for ($i = 0; $i < $max; $i++) { if (mt_rand(0, 1) == 0 || $total_videos - count($rows_videos) == 0) { $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'images e WHERE ' . $cat_select . ' AND ' . $image_select . $where_sup . ' AND ' . $done_images, 1, mt_rand(0, $total_images - count($rows_images) - 1)); $rows_images[] = $rows[0]; $done_images .= ' AND '; $done_images .= 'id<>' . strval($rows[0]['id']); } else { $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'videos e WHERE ' . $cat_select . ' AND ' . $video_select . $where_sup . ' AND ' . $done_videos, 1, mt_rand(0, $total_videos - count($rows_videos) - 1)); $rows_videos[] = $rows[0]; $done_videos .= ' AND '; $done_videos .= 'id<>' . strval($rows[0]['id']); } } } else { if ($_sort == 'compound_rating') { $rating_sort = ',(SELECT AVG(rating) FROM ' . get_table_prefix() . 'rating WHERE ' . db_string_equal_to('rating_for_type', 'images') . ' AND rating_for_id=e.id) AS compound_rating'; } elseif ($_sort == 'fixed_random') { $rating_sort = ',(MOD(id,3.142)) AS fixed_random'; } else { $rating_sort = ''; } $rows_images = $GLOBALS['SITE_DB']->query('SELECT *' . $rating_sort . ' FROM ' . get_table_prefix() . 'images e WHERE ' . $cat_select . ' AND ' . $image_select . $where_sup . ' ORDER BY ' . $sort, $max + $start); if ($_sort == 'compound_rating') { $rating_sort = ',(SELECT AVG(rating) FROM ' . get_table_prefix() . 'rating WHERE ' . db_string_equal_to('rating_for_type', 'videos') . ' AND rating_for_id=e.id) AS compound_rating'; } elseif ($_sort == 'fixed_random') { $rating_sort = ',(MOD(id,3.142)) AS fixed_random'; } else { $rating_sort = ''; } $rows_videos = $GLOBALS['SITE_DB']->query('SELECT *' . $rating_sort . ' FROM ' . get_table_prefix() . 'videos e WHERE ' . $cat_select . ' AND ' . $video_select . $where_sup . ' ORDER BY ' . $sort, $max + $start); } // Sort $combined = array(); foreach ($rows_images as $row_image) { $combined[] = array($row_image, 'image', $_sort == 'random' ? NULL : $row_image[$_sort]); } foreach ($rows_videos as $row_video) { $combined[] = array($row_video, 'video', $_sort == 'random' ? NULL : $row_video[$_sort]); } if ($_sort == 'random') { shuffle($combined); } else { global $M_SORT_KEY; $M_SORT_KEY = 2; usort($combined, 'multi_sort'); if ($_dir == 'DESC') { $combined = array_reverse($combined); } } // Display $entries = new ocp_tempcode(); foreach ($combined as $i => $c) { if ($i >= $start) { switch ($c[1]) { case 'image': // Display image $row_image = $c[0]; $view_url = build_url(array('page' => 'galleries', 'type' => 'image', 'wide' => 1, 'id' => $row_image['id']), $zone); $thumb_url = ensure_thumbnail($row_image['url'], $row_image['thumb_url'], 'galleries', 'images', $row_image['id']); $thumb = do_image_thumb($thumb_url, '', true); $full_url = $row_image['url']; $file_size = url_is_local($full_url) ? file_exists(get_custom_file_base() . '/' . rawurldecode($full_url)) ? strval(filesize(get_custom_file_base() . '/' . rawurldecode($full_url))) : '' : ''; if (url_is_local($full_url)) { $full_url = get_custom_base_url() . '/' . $full_url; } $thumb_url = $row_image['thumb_url']; if (url_is_local($thumb_url)) { $thumb_url = get_custom_base_url() . '/' . $thumb_url; } $entry_rating_details = $row_image['allow_rating'] == 1 ? display_rating($view_url, get_translated_text($row_image['title']), 'images', strval($row_image['id']), 'RATING_INLINE_STATIC', $row_image['submitter']) : NULL; $entry_map = array('_GUID' => '043ac7d15ce02715ac02309f6e8340ff', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_image['title']), 'DESCRIPTION' => get_translated_tempcode($row_image['comments']), 'ID' => strval($row_image['id']), 'FILE_SIZE' => $file_size, 'SUBMITTER' => strval($row_image['submitter']), 'FULL_URL' => $full_url, 'THUMB_URL' => $thumb_url, 'CAT' => $cat, 'THUMB' => $thumb, 'VIEW_URL' => $view_url, 'VIEWS' => strval($row_image['image_views']), 'ADD_DATE_RAW' => strval($row_image['add_date']), 'EDIT_DATE_RAW' => is_null($row_image['edit_date']) ? '' : strval($row_image['edit_date'])); $entry = do_template('GALLERY_IMAGE', $entry_map); $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => '13134830e1ebea158ab44885eeec0953', 'ENTRY' => $entry) + $entry_map)); break; case 'video': // Display video $row_video = $c[0]; $view_url = build_url(array('page' => 'galleries', 'type' => 'video', 'wide' => 1, 'id' => $row_video['id']), $zone); $thumb_url = $row_video['thumb_url']; if ($thumb_url != '' && url_is_local($thumb_url)) { $thumb_url = get_custom_base_url() . '/' . $thumb_url; } if ($thumb_url == '') { $thumb_url = find_theme_image('na'); } $thumb = do_image_thumb($thumb_url, '', true); $full_url = $row_video['url']; if (url_is_local($full_url)) { $full_url = get_custom_base_url() . '/' . $full_url; } $thumb_url = $row_video['thumb_url']; if ($thumb_url != '' && url_is_local($thumb_url)) { $thumb_url = get_custom_base_url() . '/' . $thumb_url; } $entry_rating_details = $row_video['allow_rating'] == 1 ? display_rating($view_url, get_translated_text($row_video['title']), 'videos', strval($row_video['id']), 'RATING_INLINE_STATIC', $row_video['submitter']) : NULL; $entry_map = array('_GUID' => '66b7fb4d3b61ef79d6803c170d102cbf', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_video['title']), 'DESCRIPTION' => get_translated_tempcode($row_video['comments']), 'ID' => strval($row_video['id']), 'CAT' => $cat, 'THUMB' => $thumb, 'VIEW_URL' => $view_url, 'SUBMITTER' => strval($row_video['submitter']), 'FULL_URL' => $full_url, 'THUMB_URL' => $thumb_url, 'VIDEO_DETAILS' => show_video_details($row_video), 'VIEWS' => strval($row_video['video_views']), 'ADD_DATE_RAW' => strval($row_video['add_date']), 'EDIT_DATE_RAW' => is_null($row_video['edit_date']) ? '' : strval($row_video['edit_date'])); $entry = do_template('GALLERY_VIDEO', $entry_map); $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => 'a0ff010ae7fd1f7b3341993072ed23cf', 'ENTRY' => $entry) + $entry_map)); break; } } $i++; if ($i == $start + $max) { break; } } if (!isset($map['render_if_empty']) || $map['render_if_empty'] != '1') { if ($entries->is_empty()) { if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_galleries', array('galleries', $cat))) { $submit_url = build_url(array('page' => 'cms_galleries', 'type' => 'ad', 'cat' => $cat, 'redirect' => SELF_REDIRECT), get_module_zone('cms_galleries')); } else { $submit_url = new ocp_tempcode(); } return do_template('BLOCK_NO_ENTRIES', array('_GUID' => 'bf84d65b8dd134ba6cd7b1b7bde99de2', 'HIGH' => false, 'TITLE' => do_lang_tempcode('GALLERY'), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('ADD_IMAGE'), 'SUBMIT_URL' => $submit_url)); } } // Results browser require_code('templates_results_browser'); $_selectors = array_map('intval', explode(',', get_option('gallery_selectors'))); $root = get_param('root', 'root'); $results_browser = results_browser(do_lang('ENTRY'), $cat, $start, 'mge_start', $max, 'mge_max', $total_videos + $total_images, $root, 'misc', true, false, 10, $_selectors); $tpl = do_template('BLOCK_MAIN_GALLERY_EMBED', array('_GUID' => 'b7b969c8fe8c398dd6e3af7ee06717ea', 'IMAGE_SELECT' => $map['select'], 'VIDEO_SELECT' => $map['video_select'], 'DAYS' => $_days, 'SORT' => $sort, 'BLOCK_PARAMS' => block_params_arr_to_str($map), 'RESULTS_BROWSER' => $results_browser, 'TITLE' => $title, 'CAT' => $cat, 'IMAGES' => $entries, 'MAX' => strval($max), 'ZONE' => $zone, 'TOTAL_VIDEOS' => strval($total_videos), 'TOTAL_IMAGES' => strval($total_images), 'TOTAL' => strval($total_videos + $total_images))); return $tpl; }
/** * The actualiser of a search. * * @param ID_TEXT Codename for what's being searched (blank: mixed search) * @param string Author name * @param ?AUTO_LINK Author ID (NULL: none given) * @param integer Days to search * @param ID_TEXT Sort key * @param ID_TEXT Sort direction * @set ASC DESC * @param boolean Whether to only search titles * @param string Comma-separated list of categories to search under * @return array A triple: The results, results browser, the number of results */ function results($id, $author, $author_id, $days, $sort, $direction, $only_titles, $search_under) { $title = get_page_title('RESULTS'); cache_module_installed_status(); $cutoff = $days == -1 ? NULL : time() - $days * 24 * 60 * 60; // What we're searching for $content = get_param('content', false, true); // Search keyword highlighting in any loaded Comcode global $SEARCH__CONTENT_BITS; $_content_bits = explode(' ', str_replace('"', '', preg_replace('#(^|\\s)\\+#', '', preg_replace('#(^|\\s)\\-#', '', $content)))); $SEARCH__CONTENT_BITS = array(); require_code('textfiles'); $too_common_words = explode(chr(10), read_text_file('too_common_words', '', true)); foreach ($_content_bits as $content_bit) { $content_bit = trim($content_bit); if ($content_bit == '') { continue; } if (!in_array(strtolower($content_bit), $too_common_words)) { $SEARCH__CONTENT_BITS[] = $content_bit; } } $start = get_param_integer('start', 0); $default_max = 10; if (ini_get('memory_limit') != '-1' && ini_get('memory_limit') != '0') { if (intval(preg_replace('#M$#', '', ini_get('memory_limit'))) < 20) { $default_max = 5; } } $max = get_param_integer('max', $default_max); // Also see get_search_rows $save_title = get_param('save_title', ''); if (!is_guest() && $save_title != '' && $start == 0) { static $saved_search = false; if (!$saved_search) { $GLOBALS['SITE_DB']->query_insert('searches_saved', array('s_title' => $save_title, 's_member_id' => get_member(), 's_time' => time(), 's_primary' => $content, 's_auxillary' => serialize(array_merge($_POST, $_GET)))); $saved_search = true; } } $boolean_operator = get_param('conjunctive_operator', 'OR'); $boolean_search = $this->_is_boolean_search(); $content_where = build_content_where($content, $boolean_search, $boolean_operator); disable_php_memory_limit(); // Search under all hooks we've asked to search under $results = array(); $_hooks = find_all_hooks('modules', 'search'); foreach (array_keys($_hooks) as $hook) { require_code('hooks/modules/search/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_search_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $info = $object->info(); if (is_null($info)) { continue; } $test = get_param_integer('search_' . $hook, 0); if (($test == 1 || get_param_integer('all_defaults', 0) == 1 && $info['default'] || $id == $hook) && ($id == '' || $id == $hook)) { // Category filter if ($search_under != '!' && $search_under != '-1' && array_key_exists('category', $info)) { $cats = explode(',', $search_under); $where_clause = '('; foreach ($cats as $cat) { if (trim($cat) == '') { continue; } if ($where_clause != '(') { $where_clause .= ' OR '; } if ($info['integer_category']) { $where_clause .= (strpos($info['category'], '.') !== false ? '' : 'r.') . $info['category'] . '=' . strval((int) $cat); } else { $where_clause .= db_string_equal_to((strpos($info['category'], '.') !== false ? '' : 'r.') . $info['category'], $cat); } } $where_clause .= ')'; } else { $where_clause = ''; } $only_search_meta = get_param_integer('only_search_meta', 0) == 1; $direction = get_param('direction', 'ASC'); if (function_exists('set_time_limit')) { @set_time_limit(5); } // Prevent errant search hooks (easily written!) taking down a server. Each call given 5 seconds (calling set_time_limit resets the timer). $hook_results = $object->run($content, $only_search_meta, $direction, $max, $start, $only_titles, $content_where, $author, $author_id, $cutoff, $sort, $max, $boolean_operator, $where_clause, $search_under, $boolean_search ? 1 : 0); if (is_null($hook_results)) { continue; } foreach ($hook_results as $i => $result) { $result['object'] = $object; $hook_results[$i] = $result; } $results = sort_search_results($hook_results, $results, $direction); } } if (function_exists('set_time_limit')) { @set_time_limit(15); } global $EXTRA_HEAD; $EXTRA_HEAD->attach('<meta name="robots" content="noindex,nofollow" />'); // XHTMLXHTML // Now glue our templates together $out = build_search_results_interface($results, $start, $max, $direction, $id == ''); if ($out->is_empty()) { if ($days != -1 && $GLOBALS['TOTAL_RESULTS'] == 0) { $ret_maybe = $this->results($id, $author, $author_id, -1, $sort, $direction, $only_titles, $search_under); if (!$ret_maybe[0]->is_empty()) { attach_message(do_lang_tempcode('NO_RESULTS_DAYS', escape_html(integer_format($days))), 'notice'); return $ret_maybe; } } return array(new ocp_tempcode(), new ocp_tempcode(), 0); } require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('RESULTS'), NULL, $start, 'start', $max, 'max', $GLOBALS['TOTAL_RESULTS'], NULL, 'results', true, true); if ($start == 0) { $GLOBALS['SITE_DB']->query_insert('searches_logged', array('s_member_id' => get_member(), 's_time' => time(), 's_primary' => substr($content, 0, 255), 's_auxillary' => serialize(array_merge($_POST, $_GET)), 's_num_results' => count($results))); } return array($out, $results_browser, $GLOBALS['TOTAL_RESULTS']); }
/** * The UI to show a list of catalogues to choose from. * * @return tempcode The UI */ function list_catalogues() { $title = get_page_title('CATALOGUES'); $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=catalogues&filter='; $ecommerce = get_param_integer('ecommerce', NULL); $start = get_param_integer('start', 0); $max = get_param_integer('max', 30); $query = 'FROM ' . get_table_prefix() . 'catalogues c'; if (can_arbitrary_groupby()) { $query .= ' JOIN ' . get_table_prefix() . 'catalogue_entries e ON e.c_name=c.c_name'; } $query .= ' WHERE '; $query .= is_null($ecommerce) ? '1=1' : 'c_ecommerce=' . strval($ecommerce); $query .= ' AND c.c_name NOT LIKE \'' . db_encode_like('\\_%') . '\''; $rows = $GLOBALS['SITE_DB']->query('SELECT c.* ' . $query . (can_arbitrary_groupby() ? ' GROUP BY c.c_name' : ''), $max, $start); $max_rows = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(DISTINCT c.c_name) ' . $query); $out = new ocp_tempcode(); foreach ($rows as $myrow) { $first_category = $GLOBALS['SITE_DB']->query_value_null_ok('catalogue_categories', 'MIN(id)', array('c_name' => $myrow['c_name'], 'cc_parent_id' => NULL)); if (is_null($first_category)) { continue; } if (!has_category_access(get_member(), 'catalogues_catalogue', $myrow['c_name'])) { continue; } if ($myrow['c_is_tree'] == 1) { $url = build_url(array('page' => '_SELF', 'catalogue_name' => $myrow['c_name'], 'type' => 'category', 'id' => $first_category), '_SELF'); } else { $url = build_url(array('page' => '_SELF', 'id' => $myrow['c_name'], 'type' => 'index'), '_SELF'); } $name = get_translated_text($myrow['c_title']); $num_entries = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'COUNT(*)', array('c_name' => $myrow['c_name'], 'ce_validated' => 1)); $num_children = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)', array('c_name' => $myrow['c_name'])); if ($myrow['c_is_tree'] == 1) { $num_children--; } $description = get_translated_tempcode($myrow['c_description']); $display_string = do_lang_tempcode($myrow['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' => '082993547f051894a6b70eea8194df5f', 'NAME' => $name, 'DESCRIPTION' => $description, 'URL' => $url, 'TITLE' => '', 'COUNT' => $display_string))); } require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('CATALOGUES'), NULL, $start, 'start', $max, 'max', $max_rows, NULL, 'misc'); return do_template('INDEX_SCREEN_FANCIER_SCREEN', array('_GUID' => '5af7dcb5bd26550ca6f26c2f9108f478', 'PRE' => '', 'POST' => '', 'RESULTS_BROWSER' => $results_browser, 'TITLE' => $title, 'CONTENT' => $out)); }
/** * Get the tempcode for a results table. * * @param mixed Some text/word describing what is being browsed (Tempcode or string) * @param integer The result number our table starts at (x of n) * @param ID_TEXT The parameter name used to store our position in the results (usually, 'start') * @param integer The total number of results to show per-page * @param ID_TEXT The parameter name used to store the total number of results to show per-page (usually, 'max') * @param integer The maximum number of rows in the entire dataset * @param tempcode The titles of the fields we are showing in our table, presented in preprepared tempcode * @param tempcode The values of the fields we are showing in our table * @param ?array A map of sortable code (usually, db field names), to strings giving the human name for the sort order (NULL: no sortables) * @param ?ID_TEXT The current sortable (NULL: none) * @param ?ID_TEXT The order we are sorting in (NULL: none) * @set ASC DESC * @param ?ID_TEXT The parameter name used to store our sortable (usually 'sort') (NULL: none) * @param ?tempcode Message to show (NULL: auto) * @param ?array Widths to specify to the table (NULL: none sent) * @param ?string The template set to use (NULL: default) * @param integer The maximum number of quick-jump page links to show * @param string GUID to pass to template * @param boolean Whether to skip showing a sort form (useful if there is another form wrapped around this) * @param ?ID_TEXT URL hash component (NULL: none) * @return tempcode The results table */ function results_table($text_id, $start, $start_name, $max, $max_name, $max_rows, $fields_title, $fields, $sortables = NULL, $sortable = NULL, $sort_order = NULL, $sort_name = 'sort', $message = NULL, $widths = NULL, $tplset = NULL, $max_page_links = 8, $guid = '1c8645bc2a3ff5bec2e003142185561f', $skip_sortables_form = false, $hash = NULL) { require_code('templates_results_browser'); if (!is_null($sort_name)) { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = $sort_name; } if (is_null($widths)) { $widths = array(); } if (is_null($message)) { $message = new ocp_tempcode(); if (!is_null($sortables)) { foreach ($sortables as $_sortable => $text) { if (is_object($text)) { $text = $text->evaluate(); } if ($text == do_lang('DATE_TIME')) { $message = paragraph(do_lang_tempcode('CLICK_DATE_FOR_MORE')); } } } } // Sorting if (!is_null($sortables)) { $selectors = new ocp_tempcode(); foreach ($sortables as $_sortable => $text) { $text_ascending = new ocp_tempcode(); $text_ascending->attach($text); $text_ascending->attach(do_lang_tempcode('_ASCENDING')); $text_descending = new ocp_tempcode(); $text_descending->attach($text); $text_descending->attach(do_lang_tempcode('_DESCENDING')); $selector_value = $_sortable . ' ASC'; $selected = $sortable . ' ' . $sort_order == $selector_value; $selectors->attach(do_template('RESULTS_BROWSER_SORTER', array('_GUID' => $guid, 'SELECTED' => $selected, 'NAME' => $text_ascending, 'VALUE' => $selector_value))); $selector_value = $_sortable . ' DESC'; $selected = $sortable . ' ' . $sort_order == $selector_value; $selectors->attach(do_template('RESULTS_BROWSER_SORTER', array('_GUID' => $guid, 'SELECTED' => $selected, 'NAME' => $text_descending, 'VALUE' => $selector_value))); } if (strpos(ocp_srv('REQUEST_URI'), '/iframe.php') !== false) { $sort_url = find_script('iframe') . '?zone=' . get_zone_name(); $url_array = $_GET; foreach ($url_array as $key => $param) { if (is_array($param)) { continue; } if (substr($key, 0, 5) == 'keep_' && skippable_keep($key, $param)) { continue; } if ($key == 'wide_high') { continue; } if ($param === '_SELF') { $param = get_page_name(); } if (get_magic_quotes_gpc()) { $param = stripslashes($param); } $sort_url .= '&' . $key . '=' . urlencode($param); } } else { $sort_url = get_self_url(); } $hidden = build_keep_form_fields('_SELF', true); if ($selectors->is_empty()) { $sort = new ocp_tempcode(); } else { $sort = do_template('RESULTS_BROWSER_SORT', array('_GUID' => $guid, 'HASH' => $hash, 'HIDDEN' => $hidden, 'SORT' => $sort_name, 'RAND' => strval($GLOBALS['INCREMENTAL_ID_GENERATOR']), 'URL' => $sort_url, 'SELECTORS' => $selectors)); } $GLOBALS['INCREMENTAL_ID_GENERATOR']++; } else { $sort = new ocp_tempcode(); } // Results browser $browser = results_browser(is_object($text_id) ? $text_id : make_string_tempcode($text_id), NULL, $start, $start_name, $max, $max_name, $max_rows, NULL, get_param('type', 'misc'), true, true, $max_page_links, NULL, is_null($hash) ? '' : $hash); return do_template(is_null($tplset) ? 'RESULTS_TABLE' : 'RESULTS_' . $tplset . '_TABLE', array('_GUID' => $guid, 'TEXT_ID' => $text_id, 'FIELDS_TITLE' => $fields_title, 'FIELDS' => $fields, 'MESSAGE' => $message, 'SORT' => $skip_sortables_form ? new ocp_tempcode() : $sort, 'BROWSER' => $browser, 'WIDTHS' => $widths), NULL, false, 'RESULTS_TABLE'); }
/** * The UI to show a virtual forum. * * @param SHORT_TEXT The title to show for the v-forum * @param mixed The condition (a fragment of an SQL query that gets embedded in the context of a topic selection query). May be string, or array of strings (separate queries to run and merge; done for performance reasons relating to DB indexing) * @param string The ordering of the results * @param boolean Whether to not show pinning in a separate section * @return tempcode The UI */ function _vforum($title, $condition, $order, $no_pin = false) { $max = get_param_integer('max', intval(get_option('forum_topics_per_page'))); $start = get_param_integer('start', 0); $type = get_param('type', 'misc'); $forum_name = do_lang_tempcode('VIRTUAL_FORUM'); // Find topics $extra = ''; if (!has_specific_permission(get_member(), 'see_unvalidated')) { $extra = 't_validated=1'; } if (!$GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) { $groups = $GLOBALS['FORUM_DRIVER']->get_members_groups(get_member(), false, true); $group_or_list = ''; foreach ($groups as $group) { if ($group_or_list != '') { $group_or_list .= ' OR '; } $group_or_list .= 'group_id=' . strval((int) $group); } if ($extra != '') { $extra .= ' AND '; } $or_list = ''; global $SITE_INFO; if (isset($SITE_INFO['mysql_old']) && $SITE_INFO['mysql_old'] == '1' || !isset($SITE_INFO['mysql_old']) && is_file(get_file_base() . '/mysql_old')) { $forum_access = $GLOBALS['FORUM_DB']->query('SELECT category_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'group_category_access WHERE (' . $group_or_list . ') AND ' . db_string_equal_to('module_the_name', 'forums'), NULL, NULL, false, true); } else { $forum_access = $GLOBALS['FORUM_DB']->query('SELECT category_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'group_category_access WHERE (' . $group_or_list . ') AND ' . db_string_equal_to('module_the_name', 'forums') . ' UNION ALL SELECT category_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'member_category_access WHERE (member_id=' . strval((int) get_member()) . ' AND active_until>' . strval(time()) . ') AND ' . db_string_equal_to('module_the_name', 'forums'), NULL, NULL, false, true); } foreach ($forum_access as $access) { if ($or_list != '') { $or_list .= ' OR '; } $or_list .= 't_forum_id=' . strval((int) $access['category_name']); } $extra .= '(' . $or_list . ')'; } if ($extra != '') { $extra = ' AND (' . $extra . ') '; } $max_rows = 0; $topic_rows = array(); foreach (is_array($condition) ? $condition : array($condition) as $_condition) { $query = ' FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics top LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_read_logs l ON (top.id=l.l_topic_id AND l.l_member_id=' . strval((int) get_member()) . ') LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND top.t_cache_first_post=t.id WHERE ((' . $_condition . ')' . $extra . ') AND t_forum_id IS NOT NULL ORDER BY ' . $order; $topic_rows = array_merge($topic_rows, $GLOBALS['FORUM_DB']->query('SELECT top.*,t.text_parsed AS _trans_post,l_time' . $query, $max, $start)); //if (($start==0) && (count($topic_rows)<$max)) $max_rows+=$max; // We know that they're all on this screen /*else */ $max_rows += $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) ' . $query); } $hot_topic_definition = intval(get_option('hot_topic_definition')); $or_list = ''; foreach ($topic_rows as $topic_row) { if ($or_list != '') { $or_list .= ' OR '; } $or_list .= 'p_topic_id=' . strval((int) $topic_row['id']); } if ($or_list != '') { $involved = $GLOBALS['FORUM_DB']->query('SELECT DISTINCT p_topic_id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE (' . $or_list . ') AND p_poster=' . strval((int) get_member())); $involved = collapse_1d_complexity('p_topic_id', $involved); } $topics_array = array(); foreach ($topic_rows as $topic_row) { $topics_array[] = ocf_get_topic_array($topic_row, get_member(), $hot_topic_definition, in_array($topic_row['id'], $involved)); } // Display topics $topics = new ocp_tempcode(); $pinned = false; require_code('templates_results_browser'); $topic_wrapper = new ocp_tempcode(); $forum_name_map = collapse_2d_complexity('id', 'f_name', $GLOBALS['FORUM_DB']->query('SELECT id,f_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE f_cache_num_posts>0')); foreach ($topics_array as $topic) { if (!$no_pin && $pinned && !in_array('pinned', $topic['modifiers'])) { $topics->attach(do_template('OCF_PINNED_DIVIDER')); } $pinned = in_array('pinned', $topic['modifiers']); $forum_id = array_key_exists('forum_id', $topic) ? $topic['forum_id'] : NULL; $_forum_name = array_key_exists($forum_id, $forum_name_map) ? $forum_name_map[$forum_id] : do_lang_tempcode('PERSONAL_TOPICS'); $topics->attach(ocf_render_topic($topic, true, false, $_forum_name)); } $tree = ocf_forum_breadcrumbs(db_get_first_id(), $title, get_param_integer('keep_forum_root', db_get_first_id())); if (!$topics->is_empty()) { $results_browser = results_browser(do_lang_tempcode('FORUM_TOPICS'), NULL, $start, 'start', $max, 'max', $max_rows, NULL, $type, true); $moderator_actions = ''; $moderator_actions .= '<option value="mark_topics_read">' . do_lang('MARK_READ') . '</option>'; if ($title != do_lang('TOPICS_UNREAD')) { $moderator_actions .= '<option value="mark_topics_unread">' . do_lang('MARK_UNREAD') . '</option>'; } if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($moderator_actions); } $action_url = build_url(array('page' => 'topics', 'redirect' => get_self_url(true)), get_module_zone('topics')); $topic_wrapper = do_template('OCF_FORUM_TOPIC_WRAPPER', array('_GUID' => '67356b4daacbed3e3d960d89a57d0a4a', 'MAX' => strval($max), 'ORDER' => '', 'MAY_CHANGE_MAX' => false, 'TREE' => $tree, 'BUTTONS' => '', 'STARTER_TITLE' => '', 'RESULTS_BROWSER' => $results_browser, 'MODERATOR_ACTIONS' => $moderator_actions, 'ACTION_URL' => $action_url, 'TOPICS' => $topics, 'FORUM_NAME' => $forum_name)); } $_buttons = new ocp_tempcode(); $archive_url = $GLOBALS['FORUM_DRIVER']->forum_url(db_get_first_id(), true); $_buttons->attach(do_template('SCREEN_BUTTON', array('TITLE' => do_lang_tempcode('ROOT_FORUM'), 'IMG' => 'all', 'IMMEDIATE' => false, 'URL' => $archive_url))); breadcrumb_add_segment($tree); return do_template('OCF_FORUM', array('_GUID' => 'd3fa84575727af935eadb2ce2b7c7b3e', 'FILTERS' => '', 'FORUM_NAME' => $forum_name, 'STARTER_TITLE' => '', 'BUTTONS' => $_buttons, 'TOPIC_WRAPPER' => $topic_wrapper, 'CATEGORIES' => '')); }
/** * 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']); }
/** * Standard modular render function for profile tab hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return array A triple: The tab title, the tab contents, the suggested tab order */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { require_lang('news'); $title = do_lang_tempcode('BLOG'); $order = 50; if ($leave_to_ajax_if_possible) { return array($title, NULL, $order); } require_css('news'); $max_rows = 0; $max = get_param_integer('blogs_max', 5); $start = get_param_integer('blogs_start', 0); // Show recent blog posts $recent_blog_posts = new ocp_tempcode(); $rss_url = new ocp_tempcode(); $news_cat = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => $member_id_of), '', 1); if (array_key_exists(0, $news_cat) && has_category_access($member_id_viewing, 'news', strval($news_cat[0]['id']))) { $rss_url = make_string_tempcode(find_script('backend') . '?type=rss2&mode=news&filter=' . strval($news_cat[0]['id'])); // How many results? (not 100% accurate, if a news item is in a primary cat and same secondary cat) $max_rows += $GLOBALS['SITE_DB']->query_value('news', 'COUNT(*)', array('news_category' => $news_cat[0]['id'])); $max_rows += $GLOBALS['SITE_DB']->query_value('news n LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news_category_entries c ON n.id=c.news_entry', 'COUNT(*)', array('news_category' => $news_cat[0]['id'])); // Fetch and sort $news1 = $GLOBALS['SITE_DB']->query_select('news', array('*'), array('news_category' => $news_cat[0]['id']), 'ORDER BY date_and_time DESC', $max + $start); $news2 = $GLOBALS['SITE_DB']->query_select('news n LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news_category_entries c ON n.id=c.news_entry', array('n.*'), array('news_category' => $news_cat[0]['id']), 'ORDER BY date_and_time DESC', $max + $start); $news = array(); foreach ($news1 as $row) { $news[$row['id']] = $row; } foreach ($news2 as $row) { $news[$row['id']] = $row; } unset($news1); unset($news2); global $M_SORT_KEY; $M_SORT_KEY = 'date_and_time'; usort($news, 'multi_sort'); $news = array_reverse($news); // Output $done = 0; foreach ($news as $i => $myrow) { if ($i < $start) { continue; } if ($done == $max) { break; } $news_id = $myrow['id']; $news_date = get_timezoned_date($myrow['date_and_time']); $author_url = ''; $author = $myrow['author']; $news_title = get_translated_tempcode($myrow['title']); $news_summary = get_translated_tempcode($myrow['news']); if ($news_summary->is_empty()) { $news_summary = get_translated_tempcode($myrow['news_article']); $truncate = true; } else { $truncate = false; } $news_full_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $news_id, 'filter' => $news_cat[0]['id'], 'blog' => 1), get_module_zone('news')); $news_img = find_theme_image($news_cat[0]['nc_img']); if (is_null($news_img)) { $news_img = ''; } if ($myrow['news_image'] != '') { $news_img = $myrow['news_image']; if (url_is_local($news_img)) { $news_img = get_custom_base_url() . '/' . $news_img; } } $news_category = get_translated_text($news_cat[0]['nc_title']); $seo_bits = seo_meta_get_for('news', strval($news_id)); $map2 = array('TAGS' => get_loaded_tags('news', explode(',', $seo_bits[0])), 'TRUNCATE' => $truncate, 'BLOG' => false, 'ID' => strval($news_id), 'SUBMITTER' => strval($myrow['submitter']), 'CATEGORY' => $news_category, 'IMG' => $news_img, 'DATE' => $news_date, 'DATE_RAW' => strval($myrow['date_and_time']), 'NEWS_TITLE' => $news_title, 'AUTHOR' => $author, 'AUTHOR_URL' => $author_url, 'NEWS' => $news_summary, 'FULL_URL' => $news_full_url); if (get_option('is_on_comments') == '1' && !has_no_forum() && $myrow['allow_comments'] >= 1) { $map2['COMMENT_COUNT'] = '1'; } $recent_blog_posts->attach(do_template('NEWS_PIECE_SUMMARY', $map2)); $done++; } } // Add link if ($member_id_of == $member_id_viewing) { $add_blog_post_url = build_url(array('page' => 'cms_blogs', 'type' => 'ad'), get_module_zone('cms_blogs')); } else { $add_blog_post_url = new ocp_tempcode(); } // Pagination require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('BLOGS_POSTS'), NULL, $start, 'blogs_start', $max, 'blogs_max', $max_rows, NULL, 'view', true, false, 7, NULL, 'tab__blog'); // Wrap it all up $content = do_template('OCF_MEMBER_PROFILE_BLOG', array('RESULTS_BROWSER' => $results_browser, 'RSS_URL' => $rss_url, 'ADD_BLOG_POST_URL' => $add_blog_post_url, 'MEMBER_ID' => strval($member_id_of), 'RECENT_BLOG_POSTS' => $recent_blog_posts)); return array($title, $content, $order); }
/** * The UI to view subscribers on the newsletter. * * @return tempcode The UI */ function view_subscribers() { $title = get_page_title('VIEW_NEWSLETTER_SUBSCRIBERS'); $lang = choose_language($title); if (is_object($lang)) { return $lang; } $id = either_param('id', NULL); $level = get_param_integer('level', NULL); require_lang('ocf'); // Select newsletter if (is_null($id)) { $fields = new ocp_tempcode(); require_code('form_templates'); // Selection $newsletters = new ocp_tempcode(); $rows = $GLOBALS['SITE_DB']->query_select('newsletters', array('id', 'title')); foreach ($rows as $newsletter) { $newsletters->attach(form_input_list_entry(strval($newsletter['id']), false, get_translated_text($newsletter['title']))); } if (get_forum_type() == 'ocf') { $newsletters->attach(form_input_list_entry('-1', false, do_lang_tempcode('NEWSLETTER_OCF'))); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); foreach ($groups as $group_id => $group) { if ($group_id != db_get_first_id()) { $map = array(); $map['g' . strval($group_id)] = 1; $_c = newsletter_who_send_to($map, $lang, 0, 0); $c6 = $_c[6]['g' . strval($group_id)]; if ($c6 != 0) { $newsletters->attach(form_input_list_entry('g' . strval($group_id), false, do_lang_tempcode('THIS_WITH', do_lang_tempcode('GROUP'), make_string_tempcode(escape_html($group))))); } } } } if ($newsletters->is_empty()) { inform_exit(do_lang_tempcode('NO_CATEGORIES')); } $fields->attach(form_input_list(do_lang_tempcode('NEWSLETTER'), '', 'id', $newsletters)); // CSV option $fields->attach(form_input_tick(do_lang_tempcode('DOWNLOAD_AS_CSV'), do_lang_tempcode('DESCRIPTION_DOWNLOAD_AS_CSV'), 'csv', false)); $submit_name = do_lang_tempcode('VIEW_SUBSCRIBERS'); $post_url = get_self_url(); $prune_url = build_url(array('page' => '_SELF', 'type' => 'bounce_filter_a'), '_SELF'); return do_template('FORM_SCREEN', array('GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'TITLE' => $title, 'TEXT' => do_lang_tempcode('NEWSLETTER_SUBSCRIBERS_FORM', escape_html($prune_url->evaluate())), 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); } // Send to CSV file? $csv = either_param_integer('csv', 0); if ($csv == 1) { $filename = 'subscribers_' . $id . '.csv'; header('Content-type: text/csv'); if (strstr(ocp_srv('HTTP_USER_AGENT'), 'MSIE') !== false) { header('Content-Disposition: filename="' . str_replace(chr(13), '', str_replace(chr(10), '', addslashes($filename))) . '"'); } else { header('Content-Disposition: attachment; filename="' . str_replace(chr(13), '', str_replace(chr(10), '', addslashes($filename))) . '"'); } @ini_set('ocproducts.xss_detect', '0'); } // Show subscribers $levels = is_null($level) ? $id == '-1' || substr($id, 0, 1) == 'g' ? array(4) : array(1, 2, 3, 4) : array($level); $outs = array(); foreach ($levels as $level) { $max = get_param_integer('max_' . (is_null($level) ? '' : strval($level)), 100); $start = get_param_integer('start_' . (is_null($level) ? '' : strval($level)), 0); $max_rows = 0; if (is_null($level)) { $map[$id] = 1; // $id will be -1 $_c = newsletter_who_send_to($map, $lang, 0, 0, true); if (isset($_c[6][$id])) { $max_rows = $_c[6][$id]; } } else { $map[$id] = $level; // We're requesting that we probe subscribers of $id on $level $_c = newsletter_who_send_to($map, $lang, 0, 0, true); if (isset($_c[6][$id])) { $max_rows = $_c[6][$id]; } } $num = 0; $start2 = 0; do { $map = array(); if (is_null($level)) { $map[$id] = 1; // $id will be -1 $_c = newsletter_who_send_to($map, $lang, $start + $start2, $max, true); } else { $map[$id] = $level; // We're requesting that we probe subscribers of $id on $level $_c = newsletter_who_send_to($map, $lang, $start + $start2, $max, true); } $rows = $_c[7]; if ($csv == 1) { if ($start2 == 0) { if (!is_null($level)) { echo '"LEVEL ' . do_lang('NEWSLETTER_' . strval($level)) . '"' . chr(10); } echo '"' . str_replace('"', '""', do_lang('EMAIL_ADDRESS')) . '",' . '"' . str_replace('"', '""', do_lang('FORENAME')) . '",' . '"' . str_replace('"', '""', do_lang('SURNAME')) . '",' . '"' . str_replace('"', '""', do_lang('NAME')) . '",' . '"' . str_replace('"', '""', do_lang('NEWSLETTER_SEND_ID')) . '",' . '"' . str_replace('"', '""', do_lang('NEWSLETTER_HASH')) . '",' . '"' . str_replace('"', '""', do_lang('PASSWORD_HASH')) . '",' . '"' . str_replace('"', '""', do_lang('SALT')) . '",' . '"' . str_replace('"', '""', do_lang('LANGUAGE')) . '",' . '"' . str_replace('"', '""', do_lang('CONFIRM_CODE')) . '",' . '"' . str_replace('"', '""', do_lang('JOIN_DATE')) . '"' . chr(10); } } else { $out = ''; } foreach ($rows as $r) { $email = array_key_exists('email', $r) ? $r['email'] : $r['m_email_address']; $forename = array_key_exists('n_forename', $r) ? $r['n_forename'] : ''; $surname = array_key_exists('n_surname', $r) ? $r['n_surname'] : ''; $name = array_key_exists('m_username', $r) ? $r['m_username'] : ''; $salt = array_key_exists('pass_salt', $r) ? $r['pass_salt'] : ''; $_lang = array_key_exists('language', $r) ? $r['language'] : ''; $confirm_code = array_key_exists('confirm_code', $r) ? $r['confirm_code'] : 0; $join_time = array_key_exists('join_time', $r) ? $r['join_time'] : time(); $send_id = (array_key_exists('m_username', $r) ? 'm' : 'n') . (array_key_exists('id', $r) ? strval($r['id']) : $email); $hash = array_key_exists('the_password', $r) ? $r['the_password'] : ''; $unsub = array_key_exists('the_password', $r) ? best_hash($r['the_password'], 'xunsub') : ''; if ($csv == 1) { echo '"' . str_replace('"', '""', $email) . '",' . '"' . str_replace('"', '""', $forename) . '",' . '"' . str_replace('"', '""', $surname) . '",' . '"' . str_replace('"', '""', $name) . '",' . '"' . str_replace('"', '""', $send_id) . '",' . '"' . str_replace('"', '""', $unsub) . '",' . '"' . str_replace('"', '""', $hash) . '",' . '"' . str_replace('"', '""', $salt) . '",' . '"' . str_replace('"', '""', $_lang) . '",' . '"' . str_replace('"', '""', strval($confirm_code)) . '",' . '"' . str_replace('"', '""', date('Y-m-d h:i:s', $join_time)) . '"' . chr(10); } else { $tpl = do_template('NEWSLETTER_SUBSCRIBER', array('EMAIL' => $email, 'FORENAME' => $forename, 'SURNAME' => $surname, 'NAME' => $name, 'NEWSLETTER_SEND_ID' => $send_id, 'NEWSLETTER_HASH' => $hash)); $out .= $tpl->evaluate(); } } $start2 += $max; } while ($csv == 1 && array_key_exists(0, $rows)); if (count($rows) == 0 && $start2 == 0) { if ($csv == 1) { echo '"(' . do_lang('NONE') . ')"' . chr(10); } else { } } $text = do_lang_tempcode('NEWSLETTER_PEOPLE_ON_LEVEL', is_numeric($level) && intval($level) > 0 ? make_string_tempcode(escape_html(do_lang('NEWSLETTER_' . strval($level)))) : do_lang_tempcode('NA_EM')); if ($csv == 1) { } else { require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('VIEW_NEWSLETTER_SUBSCRIBERS'), NULL, $start, 'start_' . (is_null($level) ? '' : strval($level)), $max, 'max_' . (is_null($level) ? '' : strval($level)), $max_rows, NULL, 'subscribers', true); $outs[] = array('RESULTS_BROWSER' => $results_browser, 'SUB' => $out, 'TEXT' => $text); } } if ($csv == 1) { $GLOBALS['SCREEN_TEMPLATE_CALLED'] = ''; exit; } // Work out stats of what domains are used $domains = array(); $start = 0; do { if (strpos(get_db_type(), 'mysql') !== false) { $rows = $GLOBALS['SITE_DB']->query_select('newsletter', array('email', 'COUNT(*) as cnt'), NULL, 'GROUP BY SUBSTRING_INDEX(email,\'@\',-1)'); // Far less PHP processing } else { $rows = $GLOBALS['SITE_DB']->query_select('newsletter', array('email'), NULL, 500, $start); } foreach ($rows as $row) { $email = $row['email']; if (strpos($email, '@') === false) { continue; } $domain = substr($email, strpos($email, '@') + 1); if (!is_string($domain)) { continue; } $cnt = array_key_exists('cnt', $row) ? $row['cnt'] : 1; if (!array_key_exists($domain, $domains)) { $domains[$domain] = 0; } $domains[$domain] += $cnt; } $start += 500; } while (array_key_exists(0, $rows) && strpos(get_db_type(), 'mysql') === false); arsort($domains); foreach ($domains as $key => $val) { $domains[$key] = strval($val); if (count($domains) > 100) { if ($val == 1) { unset($domains[$key]); } } } return do_template('NEWSLETTER_SUBSCRIBERS_SCREEN', array('_GUID' => '52e5d97d451b622d59f87f021a5b8f01', 'DOMAINS' => $domains, 'SUBSCRIBERS' => $outs, 'TITLE' => $title)); }
/** * Render the OCF forumview. * * @param ?integer Forum ID (NULL: personal topics). * @param string The filter category (blank if no filter) * @param integer Maximum results to show * @param integer Offset for result showing * @param AUTO_LINK Virtual root * @param ?MEMBER The member to show personal topics of (NULL: not showing personal topics) * @return mixed Either Tempcode (an interface that must be shown) or a Tuple: The main Tempcode, a title to use (also Tempcode), breadcrumbs (also Tempcode), the forum name (string). For a PT view, it is always a tuple, never raw Tempcode (as it can go inside a tabset). */ function ocf_render_forumview($id, $current_filter_cat, $max, $start, $root, $of_member_id) { require_css('ocf'); $type = is_null($id) ? 'pt' : 'misc'; if ($type == 'pt') { if (is_guest()) { access_denied('NOT_AS_GUEST'); } require_code('ocf_forumview_pt'); $details = ocf_get_personal_topics($start, $max, $of_member_id); $root_forum_name = $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_name', array('id' => $root)); $tree = hyperlink(build_url(array('page' => '_SELF', 'id' => $root == db_get_first_id() ? NULL : $root), '_SELF'), escape_html($root_forum_name), false, false, do_lang_tempcode('GO_BACKWARDS_TO', $root_forum_name), NULL, NULL, 'up'); $tree->attach(' > '); $pt_username = $GLOBALS['FORUM_DRIVER']->get_username($of_member_id); if (is_null($pt_username)) { $pt_username = do_lang('UNKNOWN'); } $tree->attach(do_lang_tempcode('PERSONAL_TOPICS_OF', escape_html($pt_username))); $details['name'] = do_lang_tempcode('PERSONAL_TOPICS_OF', escape_html($pt_username)); } else { $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=ocf_forumview&filter=' . strval($id); $details = ocf_get_forum_view($start, $max, $id); $tree = ocf_forum_breadcrumbs($id, $details['name'], $details['parent_forum']); if (array_key_exists('question', $details) && is_null(get_bot_type())) { // Was there a question answering attempt? $answer = post_param('answer', '-1#'); if ($answer != '-1#') { if (strtolower(trim($answer)) == strtolower(trim($details['answer']))) { if (!is_guest()) { $GLOBALS['FORUM_DB']->query_insert('f_forum_intro_member', array('i_forum_id' => $id, 'i_member_id' => get_member())); } else { $GLOBALS['FORUM_DB']->query_insert('f_forum_intro_ip', array('i_forum_id' => $id, 'i_ip' => get_ip_address(3))); } } else { $url = get_self_url(); $title = get_page_title('INTRO_QUESTION'); return redirect_screen($title, $url, do_lang_tempcode('INTRO_ANSWER_INCORRECT'), false, 'warn'); } } else { // Ask the question $title = get_page_title($details['answer'] == '' ? 'INTRO_NOTICE' : 'INTRO_QUESTION'); $url = get_self_url(); return do_template('OCF_FORUM_INTRO_QUESTION_SCREEN', array('ANSWER' => $details['answer'], 'TITLE' => $title, 'URL' => $url, 'QUESTION' => $details['question'])); } } } if ($type == 'pt') { $forum_name = do_lang('PERSONAL_TOPICS'); } else { $forum_name = $details['name']; } $may_mass_moderate = array_key_exists('may_move_topics', $details) || array_key_exists('may_delete_topics', $details); // Find categories $categories = new ocp_tempcode(); if ($type != 'pt') { foreach ($details['categories'] as $best => $category) { if (array_key_exists('subforums', $category)) { // Subforums $forums = new ocp_tempcode(); foreach ($category['subforums'] as $subforum) { if (array_key_exists('last_topic_id', $subforum) && !is_null($subforum['last_topic_id'])) { if (!is_null($subforum['last_member_id'])) { if (!is_guest($subforum['last_member_id'])) { //$colour=get_group_colour(ocf_get_member_primary_group($subforum['last_member_id'])); $poster = do_template('OCF_USER_MEMBER', array('_GUID' => '39r932rwefldjfldjlf', 'USERNAME' => $subforum['last_username'], 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($subforum['last_member_id'], false, true))); } else { $poster = protect_from_escaping(escape_html($subforum['last_username'])); } } else { $poster = do_lang_tempcode('NA_EM'); } $topic_url = build_url(array('page' => 'topicview', 'id' => $subforum['last_topic_id'], 'type' => 'first_unread'), get_module_zone('topicview')); $topic_url->attach('#first_unread'); $latest = do_template('OCF_FORUM_LATEST', array('_GUID' => 'dlfsdfkoewfdlfsldfk', 'DATE' => is_null($subforum['last_time']) ? do_lang_tempcode('NA_EM') : protect_from_escaping(escape_html(get_timezoned_date($subforum['last_time']))), 'DATE_RAW' => is_null($subforum['last_time']) ? '' : strval($subforum['last_time']), 'TOPIC_URL' => $topic_url, 'TOPIC_TITLE' => $subforum['last_title'] == '' ? do_lang_tempcode('NA') : $subforum['last_title'], 'POSTER' => $poster, 'MEMBER_ID' => is_null($subforum['last_member_id']) ? '' : strval($subforum['last_member_id']), 'ID' => strval($subforum['last_topic_id']))); } elseif (array_key_exists('protected_last_post', $subforum)) { $latest = do_lang_tempcode('PROTECTED_LAST_POST'); } else { $latest = do_lang_tempcode('NO_POSTS_YET'); } // Work out where the subforum URL is if ($subforum['redirection'] != '' && !is_numeric($subforum['redirection'])) { $subforum_url = $subforum['redirection']; $subforum_num_posts = do_lang_tempcode('NA_EM'); $subforum_num_topics = do_lang_tempcode('NA_EM'); $latest = do_lang_tempcode('NA_EM'); $subforum['has_new'] = false; $subforums = new ocp_tempcode(); $new_post_or_not = 'redirect'; } else { if ($subforum['redirection'] != '') { $subforum_url = build_url(array('page' => '_SELF', 'id' => $subforum['redirection']), '_SELF'); $new_post_or_not = $subforum['has_new'] ? 'new_posts_redirect' : 'no_new_posts_redirect'; } else { $subforum_url = build_url(array('page' => '_SELF', 'id' => $subforum['id']), '_SELF'); $new_post_or_not = $subforum['has_new'] ? 'new_posts' : 'no_new_posts'; } $subforum_num_posts = protect_from_escaping(escape_html(integer_format($subforum['num_posts']))); $subforum_num_topics = protect_from_escaping(escape_html(integer_format($subforum['num_topics']))); // Subsubforums $subforums = new ocp_tempcode(); ksort($subforum['children']); foreach ($subforum['children'] as $child) { // Work out where the subsubforum url is if (is_numeric($child['redirection'])) { $link = hyperlink(build_url(array('page' => '_SELF', 'id' => $child['redirection']), '_SELF'), $child['name'], false, true); } elseif ($child['redirection'] != '') { $link = hyperlink($child['redirection'], $child['name'], false, true); } else { $link = hyperlink(build_url(array('page' => '_SELF', 'id' => $child['id']), '_SELF'), $child['name'], false, true); } if (!$subforums->is_empty()) { $subforums->attach(do_lang_tempcode('LIST_SEP')); } $subforums->attach($link); } } $edit_url = has_actual_page_access(get_member(), 'admin_ocf_forums') ? build_url(array('page' => 'admin_ocf_forums', 'type' => '_ed', 'id' => $subforum['id']), 'adminzone') : new ocp_tempcode(); $forum_rules_url = ''; $intro_question_url = ''; if (!$subforum['intro_question']->is_empty()) { if ($subforum['intro_answer'] == '') { $keep = keep_symbol(array()); $intro_rules_url = find_script('rules') . '?id=' . rawurlencode(strval($subforum['id'])) . $keep; } else { $keep = keep_symbol(array()); $intro_question_url = find_script('rules') . '?id=' . rawurlencode(strval($subforum['id'])) . $keep; } } $forums->attach(do_template('OCF_FORUM_IN_CATEGORY', array('_GUID' => 'slkfjof9jlsdjcsd', 'ID' => strval($subforum['id']), 'NEW_POST_OR_NOT' => $new_post_or_not, 'LANG_NEW_POST_OR_NOT' => do_lang('POST_INDICATOR_' . $new_post_or_not), 'FORUM_NAME' => $subforum['name'], 'FORUM_URL' => $subforum_url, 'DESCRIPTION' => $subforum['description'], 'NUM_POSTS' => $subforum_num_posts, 'NUM_TOPICS' => $subforum_num_topics, 'LATEST' => $latest, 'SUBFORUMS' => $subforums, 'EDIT_URL' => $edit_url, 'FORUM_RULES_URL' => $forum_rules_url, 'INTRO_QUESTION_URL' => $intro_question_url))); } // Category itself if (!array_key_exists('expanded_by_default', $category) || $category['expanded_by_default'] == 1) { $display = 'table'; $expand_type = 'contract'; } else { $display = 'none'; $expand_type = 'expand'; } $category_description = $category['description']; $categories->attach(do_template('OCF_FORUM_CATEGORY', array('_GUID' => 'fc9bae42c680ea0162287e2ed3917bbe', 'CATEGORY_ID' => strval($best), 'EXPAND_TYPE' => $expand_type, 'DISPLAY' => $display, 'CATEGORY_TITLE' => $category['title'], 'CATEGORY_DESCRIPTION' => $category_description, 'FORUMS' => $forums))); } } } // Work out what moderator actions can be performed (also includes marking read/unread) $moderator_actions = ''; if ($type == 'pt' && $of_member_id == get_member() && get_value('disable_pt_filtering') !== '1') { $moderator_actions .= '<option value="categorise_pts">' . do_lang('CATEGORISE_PTS') . '</option>'; } if (get_value('disable_mark_forum_read') !== '1') { $moderator_actions .= '<option value="mark_topics_read">' . do_lang('MARK_READ') . '</option>'; $moderator_actions .= '<option value="mark_topics_unread">' . do_lang('MARK_UNREAD') . '</option>'; } // Mass moderation if ($may_mass_moderate) { $moderator_actions .= '<option value="move_topics">' . do_lang('MOVE_TOPICS') . '</option>'; if (has_specific_permission(get_member(), 'delete_midrange_content', 'topics', array('forums', $id))) { $moderator_actions .= '<option value="delete_topics">' . do_lang('DELETE_TOPICS') . '</option>'; } $moderator_actions .= '<option value="pin_topics">' . do_lang('PIN_TOPIC') . '</option>'; $moderator_actions .= '<option value="unpin_topics">' . do_lang('UNPIN_TOPIC') . '</option>'; $moderator_actions .= '<option value="sink_topics">' . do_lang('SINK_TOPIC') . '</option>'; $moderator_actions .= '<option value="unsink_topics">' . do_lang('UNSINK_TOPIC') . '</option>'; $moderator_actions .= '<option value="cascade_topics">' . do_lang('CASCADE_TOPIC') . '</option>'; $moderator_actions .= '<option value="uncascade_topics">' . do_lang('UNCASCADE_TOPIC') . '</option>'; $moderator_actions .= '<option value="open_topics">' . do_lang('OPEN_TOPIC') . '</option>'; $moderator_actions .= '<option value="close_topics">' . do_lang('CLOSE_TOPIC') . '</option>'; if (!is_null($id)) { $multi_moderations = ocf_list_multi_moderations($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="mmt_' . strval($mm_id) . '">' . $mm_name . '</option>'; } $moderator_actions .= '</optgroup>'; } } } // Find topics $topics = new ocp_tempcode(); $pinned = false; $num_unread = 0; foreach ($details['topics'] as $topic) { if ($pinned && !in_array('pinned', $topic['modifiers'])) { $topics->attach(do_template('OCF_PINNED_DIVIDER')); } $pinned = in_array('pinned', $topic['modifiers']); $topics->attach(ocf_render_topic($topic, $moderator_actions != '', $type == 'pt', NULL)); if (in_array('unread', $topic['modifiers'])) { $num_unread++; } } // Buttons $button_array = array(); if (!is_guest() && $type != 'pt') { if (get_value('disable_mark_forum_read') !== '1') { $read_url = build_url(array('page' => 'topics', 'type' => 'mark_read', 'id' => $id), get_module_zone('topics')); $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('MARK_READ'), 'url' => $read_url, 'img' => 'mark_read'); } } if ($type != 'pt') { if (addon_installed('search')) { $search_url = build_url(array('page' => 'search', 'type' => 'misc', 'id' => 'ocf_posts', 'search_under' => $id), get_module_zone('search')); $button_array[] = array('immediate' => false, 'rel' => 'search', 'title' => do_lang_tempcode('SEARCH'), 'url' => $search_url, 'img' => 'search'); } $new_topic_url = build_url(array('page' => 'topics', 'type' => 'new_topic', 'id' => $id), get_module_zone('topics')); } else { if (addon_installed('search')) { $search_url = build_url(array('page' => 'search', 'type' => 'misc', 'id' => 'ocf_own_pt'), get_module_zone('search')); $button_array[] = array('immediate' => false, 'rel' => 'search', 'title' => do_lang_tempcode('SEARCH'), 'url' => $search_url, 'img' => 'search'); } $new_topic_url = build_url(array('page' => 'topics', 'type' => 'new_pt', 'id' => get_member()), get_module_zone('topics')); } if ($type == 'pt') { //$archive_url=$GLOBALS['FORUM_DRIVER']->forum_url(db_get_first_id()); //$button_array[]=array('immediate'=>false,'title'=>do_lang_tempcode('ROOT_FORUM'),'url'=>$archive_url,'img'=>'forum'); } if (array_key_exists('may_post_topic', $details)) { if ($type == 'pt') { $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('ADD_PERSONAL_TOPIC'), 'url' => $new_topic_url, 'img' => 'send_message'); } else { $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('ADD_TOPIC'), 'url' => $new_topic_url, 'img' => 'new_topic'); } } $buttons = ocf_screen_button_wrap($button_array); $starter_title = $type == 'pt' ? do_lang_tempcode('WITH_TITLING') : new ocp_tempcode(); // Wrap it all up $action_url = build_url(array('page' => 'topics'), get_module_zone('topics'), NULL, false, true); if (!$topics->is_empty()) { if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($moderator_actions); } require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('FORUM_TOPICS'), $type == 'pt' ? $of_member_id : $id, $start, 'start', $max, 'max', $details['max_rows'], NULL, $type == 'pt' && get_page_name() != 'forumview' ? 'view' : $type, true, false, 7, NULL, $type == 'pt' && get_page_name() != 'forumview' ? 'tab__pts' : ''); $order = array_key_exists('order', $details) ? $details['order'] : 'last_post'; $topic_wrapper = do_template('OCF_FORUM_TOPIC_WRAPPER', array('_GUID' => 'e452b81001e5c6b7adb4d82e627bf983', 'TYPE' => $type, 'ID' => is_null($id) ? NULL : strval($id), 'MAX' => strval($max), 'ORDER' => $order, 'MAY_CHANGE_MAX' => array_key_exists('may_change_max', $details), 'ACTION_URL' => $action_url, 'BUTTONS' => $buttons, 'STARTER_TITLE' => $starter_title, 'TREE' => $tree, 'RESULTS_BROWSER' => $results_browser, 'MODERATOR_ACTIONS' => $moderator_actions, 'TOPICS' => $topics, 'FORUM_NAME' => $forum_name)); } else { $topic_wrapper = new ocp_tempcode(); $moderator_actions = ''; } // Filters $filters = new ocp_tempcode(); if (get_value('disable_pt_filtering') !== '1') { if ($type == 'pt') { $filter_cats = ocf_get_filter_cats(true); $filters_arr = array(); foreach ($filter_cats as $fi => $filter_cat) { if ($filter_cat != '') { $filtered_url = build_url(array('page' => '_SELF', 'category' => $filter_cat), '_SELF', NULL, true, false, false, 'tab__pts'); $filter_active = $filter_cat == $current_filter_cat; $filters_arr[] = array('URL' => $filter_active ? new ocp_tempcode() : $filtered_url, 'CAPTION' => $filter_cat, 'HAS_NEXT' => isset($filter_cats[$fi + 1])); } } $filters = do_template('OCF_PT_FILTERS', array('FILTERS' => $filters_arr, 'RESET_URL' => build_url(array('page' => '_SELF', 'category' => NULL), '_SELF', NULL, true))); } } $map = array('_GUID' => '1c14afd9265b1bf69375169dd6faf83c', 'STARTER_TITLE' => $starter_title, 'ID' => is_null($id) ? NULL : strval($id), 'DESCRIPTION' => array_key_exists('description', $details) ? $details['description'] : '', 'FILTERS' => $filters, 'BUTTONS' => $buttons, 'TOPIC_WRAPPER' => $topic_wrapper, 'TREE' => $tree, 'CATEGORIES' => $categories); $content = do_template('OCF_FORUM', $map); $ltitle = do_lang_tempcode('NAMED_FORUM', escape_html($details['name'])); return array($content, $ltitle, $tree, $forum_name); }
/** * Render a comment topic. * * @param ID_TEXT Content type to show topic for * @param ID_TEXT Content ID of content type to show topic for * @param boolean Whether this resource allows comments (if not, this function does nothing - but it's nice to move out this common logic into the shared function) * @param boolean Whether the comment box will be invisible if there are not yet any comments (and you're not staff) * @param ?string The name of the forum to use (NULL: default comment forum) * @param ?string The default post to use (NULL: standard courtesy warning) * @param ?mixed The raw comment array (NULL: lookup). This is useful if we want to pass it through a filter * @param boolean Whether to skip permission checks * @param boolean Whether to reverse the posts * @param ?MEMBER User to highlight the posts of (NULL: none) * @param boolean Whether to allow ratings along with the comment (like reviews) * @return tempcode The tempcode for the comment topic */ function render_as_comment_topic($content_type, $content_id, $allow_comments, $invisible_if_no_comments, $forum_name, $post_warning, $preloaded_comments, $explicit_allow, $reverse, $highlight_by_user, $allow_reviews) { if (get_forum_type() == 'ocf' && !addon_installed('ocf_forum')) { return new ocp_tempcode(); } $topic_id = $GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier($forum_name, $content_type . '_' . $content_id); // Settings we need $max_thread_depth = get_param_integer('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'))); $start = get_param_integer('start_comments', 0); // Load up posts from DB if (is_null($preloaded_comments)) { if (!$this->load_from_topic($topic_id, $num_to_show_limit, $start, $reverse)) { attach_message(do_lang_tempcode('MISSING_FORUM', escape_html($forum_name)), 'warn'); } } else { $this->_inject_posts_for_scoring_algorithm($preloaded_comments); } if (!$this->error) { if (count($this->all_posts_ordered) == 0 && $invisible_if_no_comments) { return new ocp_tempcode(); } $may_reply = has_specific_permission(get_member(), 'comment', get_page_name()); // Prepare review titles global $REVIEWS_STRUCTURE; if ($allow_reviews) { if (array_key_exists($content_type, $REVIEWS_STRUCTURE)) { $this->set_reviews_rating_criteria($REVIEWS_STRUCTURE[$content_type]); } else { $this->set_reviews_rating_criteria(array('')); } } // Load up reviews if (get_forum_type() == 'ocf' && $allow_reviews) { $all_individual_review_ratings = $GLOBALS['SITE_DB']->query_select('review_supplement', array('*'), array('r_topic_id' => $topic_id)); } else { $all_individual_review_ratings = array(); } $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum_name); // Posts list($posts, $serialized_options, $hash) = $this->render_posts($num_to_show_limit, $max_thread_depth, $may_reply, $highlight_by_user, $all_individual_review_ratings, $forum_id); // Pagination $results_browser = NULL; if (!$this->is_threaded && is_null($preloaded_comments)) { if ($this->total_posts > $num_to_show_limit) { require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('COMMENTS'), NULL, $start, 'start_comments', $num_to_show_limit, 'max_comments', $this->total_posts, NULL, NULL, true); } } // Environment meta data $this->inject_rss_url($forum_name, $content_type, $content_id); $this->inject_meta_data(); // Make-a-comment form if ($may_reply) { $post_url = get_self_url(); $form = $this->get_posting_form($content_type, $content_id, $allow_reviews, $post_url, $post_warning); } else { $form = new ocp_tempcode(); } // Existing review ratings $reviews_rating_criteria = array(); if (get_forum_type() == 'ocf' && $allow_reviews) { foreach ($this->reviews_rating_criteria as $review_title) { $_rating = $GLOBALS['SITE_DB']->query_value('review_supplement', 'AVG(r_rating)', array('r_rating_type' => $review_title, 'r_topic_id' => $topic_id)); $rating = mixed(); $rating = is_null($_rating) ? NULL : $_rating; $reviews_rating_criteria[] = array('REVIEW_TITLE' => $review_title, 'REVIEW_RATING' => make_string_tempcode(is_null($rating) ? '' : float_format($rating))); if (!is_null($rating)) { $GLOBALS['META_DATA'] += array('rating' => float_to_raw_string($rating)); } } } // Direct links to forum $forum_url = is_null($topic_id) ? '' : $GLOBALS['FORUM_DRIVER']->topic_url($topic_id, $forum_name, true); if ($GLOBALS['FORUM_DRIVER']->is_staff(get_member()) || $forum_name == get_option('comments_forum_name')) { $authorised_forum_url = $forum_url; } else { $authorised_forum_url = ''; } // Show it all return do_template('COMMENTS_WRAPPER', array('_GUID' => 'a89cacb546157d34vv0994ef91b2e707', 'RESULTS_BROWSER' => $results_browser, 'TYPE' => $content_type, 'ID' => $content_id, 'REVIEW_RATING_CRITERIA' => $reviews_rating_criteria, 'FORUM_LINK' => $forum_url, 'AUTHORISED_FORUM_LINK' => $authorised_forum_url, 'FORM' => $form, 'COMMENTS' => $posts, 'HASH' => $hash, 'SERIALIZED_OPTIONS' => $serialized_options)); } return new ocp_tempcode(); }
/** * The UI to select a news category to view news within. * * @param ?integer What to show (NULL: news and blogs, 0: news, 1: blogs) * @return tempcode The UI */ function news_cat_select($blogs) { $title = get_page_title($blogs === 1 ? 'BLOGS' : ($blogs === 0 ? 'JUST_NEWS_CATEGORIES' : 'NEWS_CATEGORIES')); $start = get_param_integer('start', 0); $max = get_param_integer('max', 30); require_code('ocfiltering'); $filter = get_param('filter', '*'); $q_filter = ocfilter_to_sqlfragment($filter, 'p.news_category', 'news_categories', NULL, 'p.news_category', 'id'); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) if (is_null($blogs)) { $map = array(); $categories = $GLOBALS['SITE_DB']->query_select('news_categories c LEFT JOIN ' . get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=c.nc_title', array('c.*', 'text_original'), $map, 'ORDER BY nc_owner', $max, $start); // Ordered to show non-blogs first (nc_owner=NULL) $max_rows = $GLOBALS['SITE_DB']->query_value('news_categories', 'COUNT(*)', $map); } elseif ($blogs == 1) { $categories = $GLOBALS['SITE_DB']->query('SELECT c.*,text_original FROM ' . get_table_prefix() . 'news_categories c LEFT JOIN ' . get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=c.nc_title WHERE nc_owner IS NOT NULL ORDER BY nc_owner DESC', $max, $start); // Ordered to show newest blogs first $max_rows = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'news_categories WHERE nc_owner IS NOT NULL'); } else { $map = array('nc_owner' => NULL); $categories = $GLOBALS['SITE_DB']->query_select('news_categories c LEFT JOIN ' . get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=c.nc_title', array('c.*', 'text_original'), $map, 'ORDER BY text_original ASC', $max, $start); // Ordered by title (can do efficiently as limited numbers of non-blogs) $max_rows = $GLOBALS['SITE_DB']->query_value('news_categories', 'COUNT(*)', $map); } if ($max_rows == count($categories)) { global $M_SORT_KEY; $M_SORT_KEY = 'text_original'; usort($categories, 'multi_sort'); } $content = new ocp_tempcode(); $join = ' LEFT JOIN ' . get_table_prefix() . 'news_category_entries d ON d.news_entry=p.id'; if ($blogs === 1) { $q_filter .= ' AND c.nc_owner IS NOT NULL'; $join .= ' LEFT JOIN ' . get_table_prefix() . 'news_categories c ON c.id=p.news_category'; } elseif ($blogs === 0) { $q_filter .= ' AND c.nc_owner IS NULL AND c.id IS NOT NULL'; $join .= ' LEFT JOIN ' . get_table_prefix() . 'news_categories c ON c.id=p.news_category'; } $_content = array(); foreach ($categories as $category) { if (has_category_access(get_member(), 'news', strval($category['id']))) { $query = 'SELECT COUNT(*) FROM ' . get_table_prefix() . 'news p' . $join . ' WHERE ' . (!has_specific_permission(get_member(), 'see_unvalidated') ? 'validated=1 AND ' : '') . ' (news_entry_category=' . strval($category['id']) . ' OR news_category=' . strval($category['id']) . ') AND ' . $q_filter . ' ORDER BY date_and_time DESC'; $count = $GLOBALS['SITE_DB']->query_value_null_ok_full($query); if ($count > 0) { if ($GLOBALS['RECORD_LANG_STRINGS_CONTENT'] || is_null($category['text_original'])) { $category['text_original'] = get_translated_text($category['nc_title']); } $url_map = array('page' => '_SELF', 'type' => 'misc', 'id' => $category['id']); if (!is_null($blogs)) { $url_map['blog'] = $blogs; } $url = build_url($url_map, '_SELF'); $name = $category['text_original']; $description = do_lang_tempcode('CATEGORY_SUBORDINATE_2', integer_format($count)); $img = find_theme_image($category['nc_img']); if ($blogs === 1) { $_img = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($category['nc_owner']); if ($_img != '') { $img = $_img; } } if ($img == '') { $img = NULL; } $_content[] = do_template('INDEX_SCREEN_FANCIER_ENTRY', array('_GUID' => 'a15a56dd19bc66e4738fb7cff31137a1', 'OWNER' => is_null($category['nc_owner']) ? '' : strval($category['nc_owner']), 'IMG' => $img, 'TITLE' => '', 'URL' => $url, 'NAME' => $name, 'DESCRIPTION' => $description)); } } } foreach ($_content as $c) { $content->attach($c); } if ($content->is_empty()) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } if (($blogs !== 1 || has_specific_permission(get_member(), 'have_personal_category', 'cms_news')) && has_actual_page_access(NULL, $blogs === 1 ? 'cms_blogs' : 'cms_news', NULL, NULL) && has_submit_permission('high', get_member(), get_ip_address(), 'cms_news')) { $map = array('page' => $blogs === 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(); } require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('NEWS_CATEGORIES'), NULL, $start, 'start', $max, 'max', $max_rows, NULL, get_param('type', 'misc')); return do_template('INDEX_SCREEN_FANCIER_SCREEN', array('_GUID' => 'c61c945e0453c2145a819ca60e8faf09', 'TITLE' => $title, 'SUBMIT_URL' => $submit_url, 'CONTENT' => $content, 'PRE' => '', 'POST' => '', 'RESULTS_BROWSER' => $results_browser)); }