/** * Perform a multi moderation. * * @param AUTO_LINK The ID of the multi moderation we are performing. * @param AUTO_LINK The ID of the topic we are performing the multi moderation on. * @param LONG_TEXT The reason for performing the multi moderation (may be blank). * @param LONG_TEXT The post text for a post to be added to the topic (blank: do not add a post). * @param BINARY Whether the post is marked emphasised. * @param BINARY Whether to skip showing the posters signature in the post. */ function ocf_perform_multi_moderation($id, $topic_id, $reason, $post_text = '', $is_emphasised = 1, $skip_sig = 0) { $topic_details = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_forum_id', 't_cache_first_title', 't_cache_first_post_id'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $topic_details)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $from = $topic_details[0]['t_forum_id']; if (!ocf_may_perform_multi_moderation($from)) { access_denied('I_ERROR'); } $mm = $GLOBALS['FORUM_DB']->query_select('f_multi_moderations', array('*'), array('id' => $id)); if (!array_key_exists(0, $mm)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } require_code('ocfiltering'); $idlist = ocfilter_to_idlist_using_db($mm[0]['mm_forum_multi_code'], 'id', 'f_forums', 'f_forums', 'f_parent_forum', 'f_parent_forum', 'id', true, true, $GLOBALS['FORUM_DB']); if (!in_array($from, $idlist)) { warn_exit(do_lang_tempcode('MM_APPLY_TWICE')); } $pin_state = $mm[0]['mm_pin_state']; $open_state = $mm[0]['mm_open_state']; $sink_state = $mm[0]['mm_sink_state']; $move_to = $mm[0]['mm_move_to']; $title_suffix = $mm[0]['mm_title_suffix']; //$post_text=$mm[0]['mm_post_text']; We'll allow user to specify the post_text, with this as a default $update_array = array(); if (!is_null($pin_state)) { $update_array['t_pinned'] = $pin_state; } if (!is_null($sink_state)) { $update_array['t_sunk'] = $sink_state; } if (!is_null($open_state)) { $update_array['t_is_open'] = $open_state; } if ($title_suffix != '') { $new_title = $topic_details[0]['t_cache_first_title'] . ' [' . $title_suffix . ']'; $update_array['t_cache_first_title'] = $new_title; $GLOBALS['FORUM_DB']->query_update('f_posts', array('p_title' => $new_title), array('id' => $topic_details[0]['t_cache_first_post_id']), '', 1); } if (count($update_array) != 0) { $GLOBALS['FORUM_DB']->query_update('f_topics', $update_array, array('id' => $topic_id), '', 1); } if (!is_null($move_to)) { require_code('ocf_topics_action'); require_code('ocf_topics_action2'); ocf_move_topics($from, $move_to, array($topic_id)); } if ($post_text != '') { require_code('ocf_posts_action'); require_code('ocf_posts_action2'); require_code('ocf_topics_action'); require_code('ocf_topics_action2'); ocf_make_post($topic_id, '', $post_text, $skip_sig, false, 1, $is_emphasised); $forum_id = is_null($move_to) ? $from : $move_to; handle_topic_ticket_reply($forum_id, $topic_id, $topic_details[0]['t_cache_first_title'], $post_text); } require_code('ocf_general_action2'); ocf_mod_log_it('PERFORM_MULTI_MODERATION', strval($id), strval($topic_id), $reason); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { if (has_no_forum()) { return new ocp_tempcode(); } require_css('news'); // Read in variables $forum_name = array_key_exists('param', $map) ? $map['param'] : 'General chat'; $limit = array_key_exists('limit', $map) ? intval($map['limit']) : 6; $hot = array_key_exists('hot', $map) ? intval($map['hot']) : 0; $date_key = array_key_exists('date_key', $map) ? $map['date_key'] : 'lasttime'; if ($date_key != 'lasttime' && $date_key != 'firsttime') { $date_key = 'firsttime'; } $username_key = array_key_exists('username_key', $map) ? $map['username_key'] : 'firstusername'; if ($username_key != 'lastusername' && $username_key != 'firstusername') { $username_key = 'firstusername'; } $memberid_key = $username_key == 'firstusername' ? 'firstmemberid' : 'lastmemberid'; // Work out exactly what forums we're reading $forum_ids = array(); if (get_forum_type() == 'ocf' && (strpos($forum_name, ',') !== false || strpos($forum_name, '*') !== false || preg_match('#\\d[-\\*\\+]#', $forum_name) != 0 || is_numeric($forum_name))) { require_code('ocfiltering'); $forum_names = ocfilter_to_idlist_using_db($forum_name, 'id', 'f_forums', 'f_forums', 'f_parent_forum', 'f_parent_forum', 'id', true, true, $GLOBALS['FORUM_DB']); } else { $forum_names = explode(',', $forum_name); } foreach ($forum_names as $forum_name) { if (!is_string($forum_name)) { $forum_name = strval($forum_name); } $forum_name = trim($forum_name); if ($forum_name == '<announce>') { $forum_id = NULL; } else { $forum_id = is_numeric($forum_name) ? intval($forum_name) : $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum_name); } if (get_forum_type() == 'ocf' && array_key_exists('check', $map) && $map['check'] == '1') { if (!has_category_access(get_member(), 'forums', strval($forum_id))) { continue; } } if (!is_null($forum_id)) { $forum_ids[$forum_id] = $forum_name; } } // Block title $forum_name = array_key_exists('param', $map) ? $map['param'] : 'General chat'; if (is_numeric($forum_name) && get_forum_type() == 'ocf') { $forum_name = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'f_name', array('id' => intval($forum_name))); if (is_null($forum_name)) { return paragraph(do_lang_tempcode('MISSING_RESOURCE')); } } $_title = do_lang_tempcode('ACTIVE_TOPICS_IN', escape_html($forum_name)); if (array_key_exists('title', $map) && $map['title'] != '') { $_title = protect_from_escaping(escape_html($map['title'])); } // Add topic link if (count($forum_names) == 1 && get_forum_type() == 'ocf' && !is_null($forum_id)) { $submit_url = build_url(array('page' => 'topics', 'type' => 'new_topic', 'id' => $forum_id), get_module_zone('topics')); $add_name = do_lang_tempcode('ADD_TOPIC'); } else { $submit_url = new ocp_tempcode(); $add_name = new ocp_tempcode(); } // Show all topics if (get_forum_type() == 'ocf') { $forum_names_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')); } else { $forum_names_map = NULL; } if (!has_no_forum()) { $max_rows = 0; $topics = $GLOBALS['FORUM_DRIVER']->show_forum_topics($forum_ids, $limit, 0, $max_rows, '', true, $date_key, $hot == 1); $out = new ocp_tempcode(); if (!is_null($topics)) { global $M_SORT_KEY; $M_SORT_KEY = $date_key; usort($topics, 'multi_sort'); $topics = array_reverse($topics, false); if (count($topics) < $limit && $hot == 1) { $more_topics = $GLOBALS['FORUM_DRIVER']->show_forum_topics($forum_ids, $limit, 0, $max_rows, '', true, $date_key); if (is_null($more_topics)) { $more_topics = array(); } $topics = array_merge($topics, $more_topics); } $done = 0; $seen = array(); foreach ($topics as $topic) { if (array_key_exists($topic['id'], $seen)) { continue; } $seen[$topic['id']] = 1; $topic_url = $GLOBALS['FORUM_DRIVER']->topic_url($topic['id'], $forum_name); $topic_url_unread = mixed(); if (get_forum_type() == 'ocf') { $topic_url_unread = build_url(array('page' => 'topicview', 'id' => $topic['id'], 'type' => 'first_unread'), get_module_zone('topicview'), NULL, false, false, false, 'first_unread'); } $title = escape_html($topic['title']); $date = get_timezoned_date($topic[$date_key]); $username = $topic[$username_key]; $member_id = array_key_exists($memberid_key, $topic) ? $topic[$memberid_key] : NULL; if (!is_null($forum_names_map) && !array_key_exists($topic['forum_id'], $forum_names_map)) { continue; } // Maybe Private Topic, slipped in via reference to a missing forum $forum_name = is_null($forum_names_map) ? NULL : $forum_names_map[$topic['forum_id']]; $out->attach(do_template('BLOCK_MAIN_FORUM_TOPICS_TOPIC', array('_GUID' => 'ae4e351b3fa5422bf8ecdfb7e49076d1', 'POST' => $topic['firstpost'], 'FORUM_ID' => is_null($forum_names_map) ? NULL : strval($topic['forum_id']), 'FORUM_NAME' => $forum_name, 'TOPIC_LINK' => $topic_url, 'TOPIC_LINK_UNREAD' => $topic_url_unread, 'TITLE' => $title, 'DATE' => $date, 'DATE_RAW' => strval($topic[$date_key]), 'USERNAME' => $username, 'MEMBER_ID' => is_null($member_id) ? '' : strval($member_id), 'NUM_POSTS' => integer_format($topic['num'])))); $done++; if ($done == $limit) { break; } } } if ($out->is_empty()) { return do_template('BLOCK_NO_ENTRIES', array('_GUID' => 'c76ab018a0746c2875c6cf69c92a01fb', 'HIGH' => false, 'FORUM_NAME' => array_key_exists('param', $map) ? $map['param'] : 'General chat', 'TITLE' => $_title, 'MESSAGE' => do_lang_tempcode($hot == 1 ? 'NO_TOPICS_HOT' : 'NO_TOPICS'), 'ADD_NAME' => $add_name, 'SUBMIT_URL' => $submit_url)); } return do_template('BLOCK_MAIN_FORUM_TOPICS', array('_GUID' => '368b80c49a335ad035b00510681d5008', 'TITLE' => $_title, 'CONTENT' => $out, 'FORUM_NAME' => array_key_exists('param', $map) ? $map['param'] : 'General chat', 'SUBMIT_URL' => $submit_url)); } else { return new ocp_tempcode(); } }
/** * Get a list of post templates that apply to a certain forum. * * @param AUTO_LINK The ID of the forum. * @return array The list of applicable post templates. */ function ocf_get_post_templates($forum_id) { if (!addon_installed('ocf_post_templates')) { return array(); } $all_templates = $GLOBALS['FORUM_DB']->query_select('f_post_templates', array('*')); $apply = array(); foreach ($all_templates as $template) { require_code('ocfiltering'); $idlist = ocfilter_to_idlist_using_db($template['t_forum_multi_code'], 'id', 'f_forums', 'f_forums', 'f_parent_forum', 'f_parent_forum', 'id', true, true, $GLOBALS['FORUM_DB']); if (in_array($forum_id, $idlist)) { if (strpos($template['t_text'], '{') !== false) { require_code('tempcode_compiler'); $e = template_to_tempcode($template['t_text']); $template['t_text'] = $e->evaluate(); } $apply[] = array($template['t_title'], $template['t_text'], $template['t_use_default_forums']); } } return $apply; }
/** * Get tempcode for a news adding/editing form. * * @param ?AUTO_LINK The primary category for the news (NULL: personal) * @param ?array A list of categories the news is in (NULL: not known) * @param SHORT_TEXT The news title * @param LONG_TEXT The news summary * @param SHORT_TEXT The name of the author * @param BINARY Whether the news is validated * @param ?BINARY Whether rating is allowed (NULL: decide statistically, based on existing choices) * @param ?SHORT_INTEGER Whether comments are allowed (0=no, 1=yes, 2=review style) (NULL: decide statistically, based on existing choices) * @param ?BINARY Whether trackbacks are allowed (NULL: decide statistically, based on existing choices) * @param BINARY Whether to show the "send trackback" field * @param LONG_TEXT Notes for the video * @param URLPATH URL to the image for the news entry (blank: use cat image) * @param ?array Scheduled go-live time (NULL: N/A) * @return array A tuple of lots of info (fields, hidden fields, trailing fields) */ function get_form_fields($main_news_category = NULL, $news_category = NULL, $title = '', $news = '', $author = '', $validated = 1, $allow_rating = NULL, $allow_comments = NULL, $allow_trackbacks = NULL, $send_trackbacks = 1, $notes = '', $image = '', $scheduled = NULL) { list($allow_rating, $allow_comments, $allow_trackbacks) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, $allow_trackbacks); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'validated'; if (is_null($main_news_category)) { $NON_CANONICAL_PARAMS[] = 'cat'; $param_cat = get_param('cat', ''); if ($param_cat == '') { $news_category = array(); $main_news_category = NULL; } elseif (strpos($param_cat, ',') === false) { $news_category = array(); $main_news_category = intval($param_cat); } else { require_code('ocfiltering'); $news_category = ocfilter_to_idlist_using_db($param_cat, 'id', 'news_categories', 'news_categories', NULL, 'id', 'id'); $main_news_category = NULL; } $author = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); } $cats1 = nice_get_news_categories($main_news_category, false, true, false, true); $cats2 = nice_get_news_categories(is_null($news_category) || count($news_category) == 0 ? array(get_param_integer('cat', NULL)) : $news_category, false, true, true, false); $fields = new ocp_tempcode(); $fields2 = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_line_comcode(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true)); if ($validated == 0) { $validated = get_param_integer('validated', 0); if ($validated == 1) { attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING')); } } if (has_some_cat_specific_permission(get_member(), 'bypass_validation_' . $this->permissions_require . 'range_content', 'cms_news', $this->permissions_cat_require)) { if (addon_installed('unvalidated')) { $fields2->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1)); } } if ($cats1->is_empty()) { warn_exit(do_lang_tempcode('NO_CATEGORIES')); } if (addon_installed('authors')) { $hidden->attach(form_input_hidden('author', $author)); } $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => (is_null($news_category) || count($news_category) == 0) && $image == '' && (is_null($news_category) || $news_category == array()), 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields2->attach(form_input_text_comcode(do_lang_tempcode('BLOG_NEWS_SUMMARY'), do_lang_tempcode('DESCRIPTION_NEWS_SUMMARY'), 'news', $news, false)); if (get_value('disable_secondary_news') !== '1') { $fields2->attach(form_input_list(do_lang_tempcode('MAIN_CATEGORY'), do_lang_tempcode('DESCRIPTION_MAIN_CATEGORY'), 'main_news_category', $cats1)); } else { $fields2->attach(form_input_hidden('main_news_category', is_null($main_news_category) ? 'personal' : strval($main_news_category))); } if (get_value('disable_secondary_news') !== '1') { $fields2->attach(form_input_multi_list(do_lang_tempcode('SECONDARY_CATEGORIES'), do_lang_tempcode('DESCRIPTION_SECONDARY_CATEGORIES'), 'news_category', $cats2)); } $fields2->attach(form_input_upload(do_lang_tempcode('IMAGE'), do_lang_tempcode('DESCRIPTION_NEWS_IMAGE_OVERRIDE'), 'file', false, $image, NULL, true, str_replace(' ', '', get_option('valid_images')))); //handle_max_file_size($hidden,'image'); Attachments will add this if (addon_installed('calendar') && has_specific_permission(get_member(), 'scheduled_publication_times')) { $fields2->attach(form_input_date__scheduler(do_lang_tempcode('PUBLICATION_TIME'), do_lang_tempcode('DESCRIPTION_PUBLICATION_TIME'), 'schedule', true, true, true, $scheduled, intval(date('Y')) - 1970 + 2, 1970)); } require_code('feedback2'); $fields2->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, $allow_trackbacks == 1, $send_trackbacks == 1, $notes, $allow_comments == 2)); $fields2->attach(get_syndication_option_fields()); return array($fields, $hidden, NULL, NULL, NULL, NULL, make_string_tempcode($fields2->evaluate())); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { if (has_no_forum()) { return new ocp_tempcode(); } require_lang('news'); require_css('news'); require_code('xhtml'); $num_topics = array_key_exists('param', $map) ? intval($map['param']) : 14; $forum_name = array_key_exists('forum', $map) ? $map['forum'] : do_lang('NEWS'); $num_topics = intval($num_topics); $date_key = array_key_exists('date_key', $map) ? $map['date_key'] : 'lasttime'; $rows = array(); $archive_url = NULL; $submit_url = new ocp_tempcode(); $forum_ids = array(); if (get_forum_type() == 'ocf' && (strpos($forum_name, ',') !== false || preg_match('#\\d[-\\*\\+]#', $forum_name) != 0 || is_numeric($forum_name))) { require_code('ocfiltering'); $forum_names = ocfilter_to_idlist_using_db($forum_name, 'id', 'f_forums', 'f_forums', 'f_parent_forum', 'f_parent_forum', 'id', true, true, $GLOBALS['FORUM_DB']); } else { $forum_names = explode(',', $forum_name); } foreach ($forum_names as $forum_name) { $forum_name = is_integer($forum_name) ? strval($forum_name) : trim($forum_name); if ($forum_name == '<announce>') { $forum_id = NULL; } else { $forum_id = is_numeric($forum_name) ? intval($forum_name) : $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum_name); } if (!is_null($forum_id)) { $forum_ids[$forum_id] = $forum_name; if (is_null($archive_url)) { $archive_url = $GLOBALS['FORUM_DRIVER']->forum_url($forum_id); // First forum will count as archive if (get_forum_type() == 'ocf') { $submit_url = build_url(array('page' => 'topics', 'type' => 'new_topic', 'id' => $forum_id), get_module_zone('topics')); } } } } // if ((method_exists($GLOBALS['FORUM_DRIVER'],'supports_multi_show_forum_topics')) && ($GLOBALS['FORUM_DRIVER']->supports_multi_show_forum_topics()) && (count($forum_ids)!=0)) // { $max_rows = 0; $rows = $GLOBALS['FORUM_DRIVER']->show_forum_topics($forum_ids, $num_topics, 0, $max_rows, '', true, $date_key); if (is_null($rows)) { $rows = array(); } /* } else { foreach ($forum_ids as $forum_id=>$forum_name) { $max_rows=0; $t=$GLOBALS['FORUM_DRIVER']->show_forum_topics($forum_name,$num_topics,0,$max_rows,'',true); if (!is_null($t)) $rows=array_merge($rows,$t); } }*/ global $M_SORT_KEY; $M_SORT_KEY = $date_key; usort($rows, 'multi_sort'); $rows = array_reverse($rows, false); $_title = do_lang_tempcode('NEWS'); if (array_key_exists('title', $map) && $map['title'] != '') { $_title = protect_from_escaping(escape_html($map['title'])); } $i = 0; $news_text = new ocp_tempcode(); while (array_key_exists($i, $rows)) { $myrow = $rows[$i]; $id = $myrow['id']; $date = get_timezoned_date($myrow[$date_key]); $author_url = array_key_exists('member_based', $map) && $map['member_based'] == '1' || !addon_installed('authors') ? new ocp_tempcode() : build_url(array('page' => 'authors', 'type' => 'misc', 'author' => $myrow['firstusername']), get_module_zone('authors')); $author = $myrow['firstusername']; $news_title = escape_html($myrow['title']); $news = is_object($myrow['firstpost']) ? $myrow['firstpost'] : make_string_tempcode(xhtmlise_html($myrow['firstpost'])); if (is_null($news)) { $news = ''; } $full_url = $GLOBALS['FORUM_DRIVER']->topic_url($id, ''); $news_text->attach(do_template('NEWS_PIECE_SUMMARY', array('_GUID' => '2edf18daf5510495fd588cad062aec4e', 'TRUNCATE' => false, 'BLOG' => false, 'FIRSTTIME' => strval($myrow['firsttime']), 'LASTTIME' => strval($myrow['lasttime']), 'CLOSED' => strval($myrow['closed']), 'FIRSTUSERNAME' => $myrow['firstusername'], 'LASTUSERNAME' => $myrow['lastusername'], 'FIRSTMEMBERID' => strval($myrow['firstmemberid']), 'LASTMEMBERID' => strval($myrow['lastmemberid']), 'ID' => strval($id), 'FULL_URL' => $full_url, 'SUBMITTER' => strval($myrow['firstmemberid']), 'DATE' => $date, 'DATE_RAW' => strval($myrow[$date_key]), 'NEWS_TITLE' => $news_title, 'CATEGORY' => '', 'IMG' => '', 'AUTHOR' => $author, 'AUTHOR_URL' => $author_url, 'NEWS' => $news))); $i++; if ($i == $num_topics) { break; } } if ($news_text->is_empty()) { return do_template('BLOCK_NO_ENTRIES', array('_GUID' => 'f55c90205b4c80162494fc5e2b565ce6', 'HIGH' => false, 'TITLE' => $_title, 'MESSAGE' => do_lang_tempcode('NO_NEWS'), 'ADD_NAME' => do_lang_tempcode('ADD_TOPIC'), 'SUBMIT_URL' => $submit_url)); } if (is_null($forum_id)) { $archive_url = ''; } return do_template('BLOCK_MAIN_FORUM_NEWS', array('_GUID' => '36b05da9aed5a2056bdb266e2ce4be9f', 'TITLE' => $_title, 'FORUM_NAME' => array_key_exists('forum', $map) ? $map['forum'] : do_lang('NEWS'), 'CONTENT' => $news_text, 'BRIEF' => new ocp_tempcode(), 'ARCHIVE_URL' => $archive_url, 'SUBMIT_URL' => $submit_url, 'RSS_URL' => '', 'ATOM_URL' => '')); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('galleries'); require_code('galleries'); require_css('galleries'); $content = new ocp_tempcode(); $parent_id = array_key_exists('param', $map) ? $map['param'] : 'root'; require_code('ocfiltering'); $parent_ids = ocfilter_to_idlist_using_db($parent_id, 'name', 'galleries', 'galleries', 'parent_id', 'parent_id', 'name', false, false); $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('galleries'); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'max'; $max = get_param_integer('max', 5); if ($max < 1) { $max = 1; } $start = get_param_integer('start', 0); // For all galleries off the given gallery $where = ''; foreach ($parent_ids as $parent_id) { if ($where != '') { $where .= ' OR '; } $where .= db_string_equal_to('parent_id', $parent_id); } $query = 'FROM ' . get_table_prefix() . 'galleries WHERE (' . $where . ') AND name NOT LIKE \'' . db_encode_like('download\\_%') . '\''; $galleries = $GLOBALS['SITE_DB']->query('SELECT * ' . $query . ' ORDER BY add_date DESC', $max, $start); foreach ($galleries as $child) { $url = build_url(array('page' => 'galleries', 'type' => 'misc', 'id' => $child['name']), $zone); $member_id = get_member_id_from_gallery_name($child['name'], $child, true); $is_member = !is_null($member_id); $_title = get_translated_text($child['fullname']); $pic = $child['rep_image']; if ($pic == '' && $is_member) { $pic = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_avatar_url'); } $teaser = get_translated_text($child['teaser']); if ($is_member && get_forum_type() == 'ocf') { require_code('ocf_members'); require_code('ocf_members2'); $member_info = ocf_show_member_box($member_id, true); } else { $member_info = new ocp_tempcode(); } list($num_children, $num_images, $num_videos) = get_recursive_gallery_details($child['name']); if ($num_images == 0 && $num_videos == 0) { continue; } $thumb_order = 'ORDER BY id ASC'; if (array_key_exists('reverse_thumb_order', $map) && $map['reverse_thumb_order'] == '1') { $thumb_order = 'ORDER BY id DESC'; } if ($pic == '') { $pic = $GLOBALS['SITE_DB']->query_value_null_ok('images', 'thumb_url', array('cat' => $child['name']), $thumb_order); } if (is_null($pic)) { $pic = $GLOBALS['SITE_DB']->query_value_null_ok('videos', 'thumb_url', array('cat' => $child['name']), $thumb_order); } if (is_null($pic)) { $pic = ''; } if ($pic != '' && url_is_local($pic)) { $pic = get_custom_base_url() . '/' . $pic; } $add_date = get_timezoned_date($child['add_date'], false); $sub = do_template('GALLERY_TEASE_PIC', array('_GUID' => '37cd5f3fc64ac1c76f85980e69a50154', 'TEASER' => $teaser, 'ADD_DATE' => $add_date, 'NUM_CHILDREN' => integer_format($num_children), 'NUM_IMAGES' => integer_format($num_images), 'NUM_VIDEOS' => integer_format($num_videos), 'MEMBER_INFO' => $member_info, 'URL' => $url, 'PIC' => $pic, 'TITLE' => $_title)); $content->attach($sub); } $page_num = intval(floor(floatval($start) / floatval($max))) + 1; $count = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) ' . $query); $num_pages = intval(ceil(floatval($count) / floatval($max))); if ($num_pages == 0) { $page_num = 0; } $previous_url = $start == 0 ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start - $max), '_SELF'); $next_url = $page_num == $num_pages ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start + $max), '_SELF'); $browse = do_template('NEXT_BROWSER_BROWSE_NEXT', array('_GUID' => '6fb2def18957c246ddb2f19bf74abf9a', 'NEXT_LINK' => $next_url, 'PREVIOUS_LINK' => $previous_url, 'PAGE_NUM' => integer_format($page_num), 'NUM_PAGES' => integer_format($num_pages))); return do_template('BLOCK_MAIN_GALLERY_TEASE', array('_GUID' => '0e7f84042ab0c873155998eae41b8a16', 'CONTENT' => $content, 'BROWSE' => $browse)); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { if (has_no_forum()) { return new ocp_tempcode(); } require_css('news'); require_lang('news'); require_css('side_blocks'); $limit = array_key_exists('param', $map) ? intval($map['param']) : 6; $forum_name = array_key_exists('forum', $map) ? $map['forum'] : do_lang('NEWS'); $date_key = array_key_exists('date_key', $map) ? $map['date_key'] : 'lasttime'; $archive_url = NULL; $submit_url = new ocp_tempcode(); $forum_ids = array(); if (get_forum_type() == 'ocf' && (strpos($forum_name, ',') !== false || preg_match('#\\d[-\\*\\+]#', $forum_name) != 0 || is_numeric($forum_name))) { require_code('ocfiltering'); $forum_names = array_map('strval', ocfilter_to_idlist_using_db($forum_name, 'id', 'f_forums', 'f_forums', 'f_parent_forum', 'f_parent_forum', 'id', true, true, $GLOBALS['FORUM_DB'])); } else { $forum_names = explode(',', $forum_name); } foreach ($forum_names as $forum_name) { $forum_name = trim($forum_name); if ($forum_name == '<announce>') { $forum_id = NULL; } else { $forum_id = is_numeric($forum_name) ? intval($forum_name) : $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum_name); } if (!is_null($forum_id)) { $forum_ids[$forum_id] = $forum_name; } if (!is_null($forum_id)) { $forum_ids[$forum_id] = $forum_name; if (is_null($archive_url)) { $archive_url = $GLOBALS['FORUM_DRIVER']->forum_url($forum_id); // First forum will count as archive if (get_forum_type() == 'ocf') { $submit_url = build_url(array('page' => 'topics', 'type' => 'new_topic', 'id' => $forum_id), get_module_zone('topics')); } } } } $_title = do_lang_tempcode('NEWS'); if (array_key_exists('title', $map) && $map['title'] != '') { $_title = protect_from_escaping(escape_html($map['title'])); } if (get_forum_type() != 'none') { $max_rows = 0; $topics = $GLOBALS['FORUM_DRIVER']->show_forum_topics($forum_ids, $limit, 0, $max_rows, '', false, $date_key); $out = new ocp_tempcode(); if (!is_null($topics)) { global $M_SORT_KEY; $M_SORT_KEY = $date_key; usort($topics, 'multi_sort'); $topics = array_reverse($topics, false); foreach ($topics as $topic) { $topic_url = $GLOBALS['FORUM_DRIVER']->topic_url($topic['id'], $forum_name); $title = $topic['title']; $date = get_timezoned_date($topic[$date_key], false); // $username=$topic['lastusername']; $out->attach(do_template('BLOCK_SIDE_FORUM_NEWS_SUMMARY', array('_GUID' => '4b7f4ce27cf683710fc9958e9606291c', 'REPLIES' => strval($topic['num']), 'FIRSTTIME' => strval($topic['firsttime']), 'LASTTIME' => strval($topic['lasttime']), 'CLOSED' => strval($topic['closed']), 'FIRSTUSERNAME' => $topic['firstusername'], 'LASTUSERNAME' => $topic['lastusername'], 'FIRSTMEMBERID' => strval($topic['firstmemberid']), 'LASTMEMBERID' => strval($topic['lastmemberid']), '_DATE' => strval($topic[$date_key]), 'DATE' => $date, 'FULL_URL' => $topic_url, 'NEWS_TITLE' => escape_html($title)))); } } return do_template('BLOCK_SIDE_FORUM_NEWS', array('_GUID' => '174fa5ce0d35d9b49dca6347c66494a5', 'FORUM_NAME' => array_key_exists('forum', $map) ? $map['forum'] : do_lang('NEWS'), 'TITLE' => $_title, 'CONTENT' => $out, 'SUBMIT_URL' => $submit_url, 'ARCHIVE_URL' => is_null($archive_url) ? '' : $archive_url)); } else { return new ocp_tempcode(); } }