Exemple #1
0
 /**
  * Standard modular render function for profile tabs edit 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 tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set)
  */
 function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false)
 {
     $title = do_lang_tempcode('DELETE_MEMBER');
     $order = 200;
     // Actualiser
     $delete_account = post_param_integer('delete', 0);
     if ($delete_account == 1) {
         if (is_guest($member_id_of)) {
             warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
         }
         ocf_delete_member($member_id_of);
         inform_exit(do_lang_tempcode('SUCCESS'));
     }
     if ($leave_to_ajax_if_possible) {
         return NULL;
     }
     // UI fields
     $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
     $text = do_lang_tempcode('_DELETE_MEMBER' . ($member_id_of == get_member() ? '_SUICIDAL' : ''), escape_html($username));
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false));
     $javascript = '';
     return array($title, $fields, $text, $javascript, $order);
 }
Exemple #2
0
 /**
  * Standard modular run function for newsletter hooks.
  *
  * @param  TIME				The time that the entries found must be newer than
  * @param  LANGUAGE_NAME	The language the entries found must be in
  * @param  string				Category filter to apply
  * @param  BINARY				Whether to use full article instead of summary
  * @return array				Tuple of result details
  */
 function run($cutoff_time, $lang, $filter, $in_full = 1)
 {
     if (!addon_installed('news')) {
         return array();
     }
     require_lang('news');
     $new = new ocp_tempcode();
     require_code('ocfiltering');
     $or_list = ocfilter_to_sqlfragment($filter, 'news_category');
     $or_list_2 = ocfilter_to_sqlfragment($filter, 'news_entry_category');
     $rows = $GLOBALS['SITE_DB']->query('SELECT title,news,news_article,id,date_and_time,submitter FROM ' . get_table_prefix() . 'news LEFT JOIN ' . get_table_prefix() . 'news_category_entries ON news_entry=id WHERE validated=1 AND date_and_time>' . strval((int) $cutoff_time) . ' AND ((' . $or_list . ') OR (' . $or_list_2 . ')) ORDER BY date_and_time DESC', 300);
     if (count($rows) == 300) {
         return array();
     }
     $rows = remove_duplicate_rows($rows, 'id');
     foreach ($rows as $row) {
         $_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), get_module_zone('news'), NULL, false, false, true);
         $url = $_url->evaluate();
         $name = get_translated_text($row['title'], NULL, $lang);
         $description = get_translated_text($row[$in_full == 1 ? 'news_article' : 'news'], NULL, $lang);
         if ($description == '') {
             $description = get_translated_text($row[$in_full == 1 ? 'news' : 'news_article'], NULL, $lang);
         }
         $member_id = is_guest($row['submitter']) ? NULL : strval($row['submitter']);
         $new->attach(do_template('NEWSLETTER_NEW_RESOURCE_FCOMCODE', array('_GUID' => '4eaf5ec00db1f0b89cef5120c2486521', 'MEMBER_ID' => $member_id, 'URL' => $url, 'NAME' => $name, 'DESCRIPTION' => $description)));
     }
     return array($new, do_lang('NEWS', '', '', '', $lang));
 }
Exemple #3
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (get_forum_type() != 'ocf') {
         warn_exit(do_lang_tempcode('NO_OCF'));
     } else {
         ocf_require_all_forum_stuff();
     }
     require_code('ocf_forumview');
     if (is_guest()) {
         access_denied('NOT_AS_GUEST');
     }
     require_css('ocf');
     $type = get_param('type', 'misc');
     if ($type == 'misc') {
         list($title, $content) = $this->new_posts();
     } elseif ($type == 'unread') {
         list($title, $content) = $this->unread_topics();
     } elseif ($type == 'recently_read') {
         list($title, $content) = $this->recently_read();
     } else {
         $title = new ocp_tempcode();
         $content = new ocp_tempcode();
     }
     $ret = ocf_wrapper($title, do_template('OCF_VFORUM', array('_GUID' => '8dca548982d65500ab1800ceec2ddc61', 'CONTENT' => $content)));
     return $ret;
 }
 function get_content()
 {
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (!isloggedin() || is_guest($this->context)) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->footer = '';
     $this->content->icons = array();
     if (!$this->import_checklist_plugin()) {
         $this->content->items = array(get_string('nochecklistplugin', 'block_checklist'));
         return $this->content;
     }
     if (!empty($this->config->checklistoverview)) {
         return $this->show_checklist_overview();
     }
     if (!empty($this->config->checklistid)) {
         return $this->show_single_checklist($this->config->checklistid);
     }
     // No checklist configured.
     $this->content->items = array(get_string('nochecklist', 'block_checklist'));
     return $this->content;
 }
Exemple #5
0
/**
 * Find whether a member may attach a poll to a detailed topic.
 *
 * @param  AUTO_LINK The topic.
 * @param  ?MEMBER	The topic owner (NULL: ask the DB for it).
 * @param  ?boolean  Whether the topic already has a poll (NULL: ask the DB for it).
 * @param  ?MEMBER	The forum the topic is in (NULL: ask the DB for it).
 * @param  ?MEMBER	The member we are checking for (NULL: current member).
 * @return boolean	The answer.
 */
function ocf_may_attach_poll($topic_id, $topic_owner = NULL, $has_poll_already = NULL, $forum_id = NULL, $member_id = NULL)
{
    if (is_null($topic_owner)) {
        $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('*'), array('id' => $topic_id), '', 1);
        if (!array_key_exists(0, $topic_info)) {
            warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
        }
        $topic_owner = $topic_info[0]['t_cache_first_member_id'];
        $has_poll_already = !is_null($topic_info[0]['t_poll_id']);
        $forum_id = $topic_info[0]['t_forum_id'];
    }
    if (is_null($member_id)) {
        $member_id = get_member();
    }
    if ($has_poll_already) {
        return false;
    }
    if ($topic_owner == $member_id && !is_guest($member_id)) {
        return true;
    }
    if (ocf_may_moderate_forum($forum_id, $member_id)) {
        return true;
    }
    return false;
}
Exemple #6
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     unset($map);
     $forum = get_forum_type();
     $out = new ocp_tempcode();
     if ($forum != 'none') {
         // Standard welcome back vs into greeting
         $member = get_member();
         if (is_guest($member)) {
             $redirect = get_self_url(true, true);
             $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => $redirect), get_module_zone('login'));
             $join_url = $GLOBALS['FORUM_DRIVER']->join_url();
             $join_bits = do_template('JOIN_OR_LOGIN', array('LOGIN_URL' => $login_url, 'JOIN_URL' => $join_url));
             $p = do_lang_tempcode('WELCOME', $join_bits);
             $out->attach(paragraph($p, 'hhrt4dsgdsgd'));
         } else {
             $out->attach(paragraph(do_lang_tempcode('WELCOME_BACK', escape_html($GLOBALS['FORUM_DRIVER']->get_username($member))), 'gfgdf9gjd'));
         }
     }
     $message = get_option('welcome_message');
     if (has_actual_page_access(get_member(), 'admin_config')) {
         if ($message != '') {
             $message .= ' [[page="_SEARCH:admin_config:category:SITE#group_GENERAL"]' . do_lang('EDIT') . '[/page]]';
         }
     }
     $out->attach(comcode_to_tempcode($message, NULL, true));
     return $out;
 }
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     unset($map);
     if (get_forum_type() != 'ocf') {
         return new ocp_tempcode();
     }
     if (is_guest()) {
         return new ocp_tempcode();
     }
     require_css('side_blocks');
     ocf_require_all_forum_stuff();
     require_code('ocf_notifications');
     // Only show what's new in week. Some forums may want to tweak this, but forums themselves only mark unread topics for a week.
     $rows = ocf_get_pp_rows();
     //		if (count($rows)==0) return new ocp_tempcode();
     require_lang('ocf');
     $out = new ocp_tempcode();
     foreach ($rows as $topic) {
         $topic_url = build_url(array('page' => 'topicview', 'id' => $topic['id'], 'type' => 'findpost'), get_module_zone('topicview'));
         $topic_url->attach('#post_' . strval($topic['id']));
         $title = $topic['t_cache_first_title'];
         $date = get_timezoned_date($topic['t_cache_last_time'], true);
         $username = $topic['t_cache_last_username'];
         $member_link = $GLOBALS['OCF_DRIVER']->member_profile_url($topic['t_cache_last_member_id'], false, true);
         $num_posts = $topic['t_cache_num_posts'];
         $out->attach(do_template('TOPIC_LIST', array('_GUID' => '55ae21a9f8d67ba6237c118a18b9657b', 'USER_LINK' => $member_link, 'TOPIC_LINK' => $topic_url, 'TITLE' => $title, 'DATE' => $date, 'DATE_RAW' => strval($topic['t_cache_last_time']), 'USERNAME' => $username, 'NUM_POSTS' => integer_format($num_posts))));
     }
     $send_url = build_url(array('page' => 'topics', 'type' => 'new_pt', 'redirect' => SELF_REDIRECT), get_module_zone('topics'));
     if (!ocf_may_make_personal_topic()) {
         $send_url = new ocp_tempcode();
     }
     $view_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => get_member()), get_module_zone('members'), NULL, true, false, false, 'tab__pts');
     return do_template('BLOCK_SIDE_OCF_PERSONAL_TOPICS', array('_GUID' => '9376cd47884a78f3d1914c176b67ee28', 'SEND_URL' => $send_url, 'VIEW_URL' => $view_url, 'CONTENT' => $out, 'FORUM_NAME' => do_lang_tempcode('PERSONAL_TOPICS')));
 }
Exemple #8
0
 /**
  * Standard modular run function.
  *
  * @param  MEMBER		The ID of the member we are getting link hooks for
  * @return array		List of tuples for results. Each tuple is: type,title,url
  */
 function run($member_id)
 {
     if (!addon_installed('chat')) {
         return array();
     }
     $modules = array();
     if (has_actual_page_access(get_member(), 'chat', get_page_zone('chat'))) {
         if (!is_guest() && $member_id != get_member()) {
             require_lang('chat');
             require_code('chat');
             if (!$GLOBALS['FORUM_DRIVER']->is_staff($member_id)) {
                 if (!member_blocked($member_id)) {
                     $modules[] = array('contact', do_lang_tempcode('EXPLAINED_BLOCK_MEMBER'), build_url(array('page' => 'chat', 'type' => 'blocking_add', 'member_id' => $member_id, 'redirect' => get_self_url(true)), get_module_zone('chat')));
                     if (has_specific_permission(get_member(), 'start_im')) {
                         $modules[] = array('contact', do_lang_tempcode('START_IM'), build_url(array('page' => 'chat', 'type' => 'misc', 'enter_im' => $member_id), get_module_zone('chat')));
                     }
                 } else {
                     $modules[] = array('contact', do_lang_tempcode('EXPLAINED_UNBLOCK_MEMBER'), build_url(array('page' => 'chat', 'type' => 'blocking_remove', 'member_id' => $member_id, 'redirect' => get_self_url(true)), get_module_zone('chat')));
                 }
             }
             if (!member_befriended($member_id)) {
                 $modules[] = array('contact', do_lang_tempcode('MAKE_BUDDY'), build_url(array('page' => 'chat', 'type' => 'buddy_add', 'member_id' => $member_id, 'redirect' => get_self_url(true)), get_module_zone('chat')));
             } else {
                 $modules[] = array('contact', do_lang_tempcode('DUMP_BUDDY'), build_url(array('page' => 'chat', 'type' => 'buddy_remove', 'member_id' => $member_id, 'redirect' => get_self_url(true)), get_module_zone('chat')));
             }
         }
     }
     return $modules;
 }
Exemple #9
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     require_lang('bookmarks');
     require_code('bookmarks');
     require_css('bookmarks');
     if (is_guest()) {
         access_denied('NOT_AS_GUEST');
     }
     // Decide what we're doing
     $type = get_param('type', 'misc');
     if ($type == 'misc') {
         return $this->manage_bookmarks();
     }
     if ($type == '_manage') {
         return $this->_manage_bookmarks();
     }
     if ($type == '_edit') {
         return $this->_edit_bookmark();
     }
     if ($type == 'ad') {
         return $this->ad();
     }
     if ($type == '_ad') {
         return $this->_ad();
     }
     return new ocp_tempcode();
 }
Exemple #10
0
 /**
  * Standard modular run function for realtime-rain hooks.
  *
  * @param  TIME			Start of time range.
  * @param  TIME			End of time range.
  * @return array			A list of template parameter sets for rendering a 'drop'.
  */
 function run($from, $to)
 {
     $drops = array();
     if (has_actual_page_access(get_member(), 'chat')) {
         require_code('chat');
         $rows = $GLOBALS['SITE_DB']->query('SELECT ip_address,the_message,user_id AS member_id,date_and_time AS timestamp,room_id FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'chat_messages WHERE system_message=0 AND date_and_time BETWEEN ' . strval($from) . ' AND ' . strval($to));
         foreach ($rows as $row) {
             if (!check_chatroom_access($row['room_id'], true)) {
                 continue;
             }
             $timestamp = $row['timestamp'];
             $member_id = $row['member_id'];
             $message = get_translated_text($row['the_message']);
             if (strpos($message, '[private') !== false) {
                 continue;
             }
             $message = strip_comcode($message);
             if ($message == '') {
                 continue;
             }
             $drops[] = rain_get_special_icons($row['ip_address'], $timestamp, NULL, $message) + array('TYPE' => 'chat', 'FROM_MEMBER_ID' => strval($member_id), 'TO_MEMBER_ID' => NULL, 'TITLE' => rain_truncate_for_title($message), 'IMAGE' => is_guest($member_id) ? rain_get_country_image($row['ip_address']) : $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id), 'TIMESTAMP' => strval($timestamp), 'RELATIVE_TIMESTAMP' => strval($timestamp - $from), 'TICKER_TEXT' => $message, 'URL' => build_url(array('page' => 'points', 'type' => 'member', 'id' => $member_id), '_SEARCH'), 'IS_POSITIVE' => false, 'IS_NEGATIVE' => false, 'FROM_ID' => 'member_' . strval($member_id), 'TO_ID' => NULL, 'GROUP_ID' => 'room_' . strval($row['room_id']));
         }
     }
     return $drops;
 }
 /**
  * Do any security checks needed for the passed action
  *
  * @param string $action
  */
 public function require_capability($action)
 {
     global $PAGE;
     require_capability('mod/hsuforum:viewdiscussion', $PAGE->context);
     if (is_guest($PAGE->context)) {
         print_error('noguest');
     }
 }
Exemple #12
0
 /**
  * Standard modular run function for RSS hooks.
  *
  * @param  string			A list of categories we accept from
  * @param  TIME			Cutoff time, before which we do not show results from
  * @param  string			Prefix that represents the template set we use
  * @set    RSS_ ATOM_
  * @param  string			The standard format of date to use for the syndication type represented in the prefix
  * @param  integer		The maximum number of entries to return, ordering by date
  * @return ?array			A pair: The main syndication section, and a title (NULL: error)
  */
 function run($_filters, $cutoff, $prefix, $date_string, $max)
 {
     if (!addon_installed('tickets')) {
         return NULL;
     }
     if (!has_actual_page_access(get_member(), 'tickets')) {
         return NULL;
     }
     if (is_guest()) {
         return NULL;
     }
     require_code('tickets');
     require_code('tickets2');
     $ticket_types = ocfilter_to_idlist_using_callback($_filters, '', NULL, NULL, NULL, NULL, false);
     if (count($ticket_types) != 0) {
         $rows = array();
         foreach ($ticket_types as $ticket_type) {
             if (!has_category_access(get_member(), 'tickets', get_translated_text($ticket_type))) {
                 continue;
             }
             $rows = array_merge($rows, get_tickets(get_member(), $ticket_type, false, false, true));
         }
     } else {
         $rows = get_tickets(get_member(), NULL, false, false, true);
     }
     require_code('feedback');
     $content = new ocp_tempcode();
     foreach ($rows as $i => $row) {
         if ($i == $max) {
             break;
         }
         if ($row['lasttime'] < $cutoff) {
             continue;
         }
         $ticket_id = extract_topic_identifier($row['description']);
         $ticket_type = $GLOBALS['SITE_DB']->query_value_null_ok('tickets', 'ticket_type', array('ticket_id' => $ticket_id));
         $author = $row['firstusername'];
         $date = date($date_string, $row['firsttime']);
         $edit_date = date($date_string, $row['lasttime']);
         $title = xmlentities($row['firsttitle']);
         $summary = xmlentities($row['firstpost']->evaluate());
         $category = '';
         $category_raw = '';
         if (!is_null($ticket_type)) {
             $category = get_translated_text($ticket_type);
             $category_raw = strval($ticket_type);
         }
         $view_url = build_url(array('page' => 'tickets', 'type' => 'ticket', 'id' => $ticket_id), get_module_zone('tickets'), NULL, false, false, true);
         if ($prefix == 'RSS_' && get_option('is_on_comments') == '1') {
             $if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => 'b4f25f5cf68304f8d402bb06851489d6', 'COMMENT_URL' => $view_url, 'ID' => strval($ticket_id)));
         } else {
             $if_comments = new ocp_tempcode();
         }
         $content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $ticket_id, 'NEWS' => '', 'DATE' => $date)));
     }
     require_lang('tickets');
     return array($content, do_lang('SUPPORT_TICKETS'));
 }
Exemple #13
0
 /**
  * Standard modular entry-point finder function.
  *
  * @return ?array	A map of entry points (type-code=>language-code) (NULL: disabled).
  */
 function get_entry_points()
 {
     if (get_forum_type() == 'ocf') {
         return array();
     }
     if (is_guest()) {
         return array();
     }
     return array('misc' => 'NOTIFICATIONS');
 }
Exemple #14
0
 /**
  * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX.
  *
  * @return tempcode  The snippet
  */
 function run()
 {
     if (!is_guest()) {
         require_code('menus');
         $built = build_stored_menu('popup', '_bookmarks');
         if (is_null($built)) {
             return new ocp_tempcode();
         }
         return $built;
     }
     return new ocp_tempcode();
 }
Exemple #15
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     // Find review, if there is one
     $individual_review_ratings = array();
     $review_rating = post_param('review_rating', '');
     if ($review_rating != '') {
         $individual_review_ratings[''] = array('REVIEW_TITLE' => '', 'REVIEW_RATING' => $review_rating);
     }
     $poster_name = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
     $post = comcode_to_tempcode(post_param('post'));
     // OCF renderings of poster
     static $hooks = NULL;
     if (is_null($hooks)) {
         $hooks = find_all_hooks('modules', 'topicview');
     }
     static $hook_objects = NULL;
     if (is_null($hook_objects)) {
         $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;
         }
     }
     if (!is_guest()) {
         require_code('ocf_members2');
         $poster_details = ocf_show_member_box(get_member(), false, $hooks, $hook_objects, false);
     } else {
         $custom_fields = new ocp_tempcode();
         $poster_details = new ocp_tempcode();
     }
     if (addon_installed('ocf_forum')) {
         if (!is_guest()) {
             $poster = do_template('OCF_POSTER_MEMBER', array('ONLINE' => true, 'ID' => strval(get_member()), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url(get_member(), false, true), 'POSTER_USERNAME' => $poster_name));
         } else {
             $poster = do_template('OCF_POSTER_GUEST', array('IP_LINK' => '', 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $poster_name));
         }
     } else {
         $poster = make_string_tempcode(escape_html($poster_name));
         // Should never happen actually, as applies discounts hook from even running
     }
     $highlight = false;
     $datetime_raw = time();
     $datetime = get_timezoned_date(time());
     $poster_url = $GLOBALS['FORUM_DRIVER']->member_profile_url(get_member());
     $title = post_param('title', '');
     $tpl = do_template('POST', array('INDIVIDUAL_REVIEW_RATINGS' => $individual_review_ratings, 'HIGHLIGHT' => $highlight, 'TITLE' => $title, 'TIME_RAW' => strval($datetime_raw), 'TIME' => $datetime, 'POSTER_URL' => $poster_url, 'POSTER_NAME' => $poster_name, 'POST' => $post, 'POSTER_ID' => strval(get_member()), 'POSTER' => $poster, 'POSTER_DETAILS' => $poster_details, 'ID' => '', 'CHILDREN' => '', 'RATING' => '', 'EMPHASIS' => '', 'BUTTONS' => '', 'TOPIC_ID' => '', 'UNVALIDATED' => '', 'IS_SPACER_POST' => false, 'NUM_TO_SHOW_LIMIT' => '0'));
     return array($tpl, NULL);
 }
Exemple #16
0
 /**
  * Standard modular run function for realtime-rain hooks.
  *
  * @param  TIME			Start of time range.
  * @param  TIME			End of time range.
  * @return array			A list of template parameter sets for rendering a 'drop'.
  */
 function run($from, $to)
 {
     $drops = array();
     if (has_actual_page_access(get_member(), 'admin_ocf_join') && get_forum_type() == 'ocf') {
         $rows = $GLOBALS['FORUM_DB']->query('SELECT i_email_address,i_inviter AS member_id,i_time AS timestamp FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_invites WHERE i_time BETWEEN ' . strval($from) . ' AND ' . strval($to));
         foreach ($rows as $row) {
             $timestamp = $row['timestamp'];
             $member_id = $row['member_id'];
             $invited_member = $GLOBALS['FORUM_DB']->query_value_null_ok('f_members', 'id', array('m_email_address' => $row['i_email_address']));
             $drops[] = rain_get_special_icons(NULL, $timestamp) + array('TYPE' => 'recommend', 'FROM_MEMBER_ID' => strval($member_id), 'TO_MEMBER_ID' => is_null($invited_member) ? '' : strval($invited_member), 'TITLE' => do_lang('RECOMMEND_SITE'), 'IMAGE' => is_guest($member_id) ? find_theme_image('recommend') : $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id), 'TIMESTAMP' => strval($timestamp), 'RELATIVE_TIMESTAMP' => strval($timestamp - $from), 'TICKER_TEXT' => NULL, 'URL' => build_url(array('page' => 'points', 'type' => 'member', 'id' => $member_id), '_SEARCH'), 'IS_POSITIVE' => true, 'IS_NEGATIVE' => false, 'FROM_ID' => 'member_' . strval($member_id), 'TO_ID' => is_null($invited_member) ? '' : 'member_' . strval($invited_member), 'GROUP_ID' => NULL);
         }
     }
     return $drops;
 }
Exemple #17
0
 /**
  * Standard modular run function for realtime-rain hooks.
  *
  * @param  TIME			Start of time range.
  * @param  TIME			End of time range.
  * @return array			A list of template parameter sets for rendering a 'drop'.
  */
 function run($from, $to)
 {
     $drops = array();
     if (has_actual_page_access(get_member(), 'admin_security')) {
         $rows = $GLOBALS['SITE_DB']->query('SELECT id,reason,ip,the_user AS member_id,date_and_time AS timestamp FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'hackattack WHERE date_and_time BETWEEN ' . strval($from) . ' AND ' . strval($to));
         foreach ($rows as $row) {
             require_lang('security');
             $timestamp = $row['timestamp'];
             $member_id = $row['member_id'];
             $drops[] = rain_get_special_icons($row['ip'], $timestamp) + array('TYPE' => 'security', 'FROM_MEMBER_ID' => strval($member_id), 'TO_MEMBER_ID' => NULL, 'TITLE' => rain_truncate_for_title(do_lang('HACKER_DETECTED', do_lang($row['reason']))), 'IMAGE' => is_guest($member_id) ? rain_get_country_image($row['ip']) : $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id), 'TIMESTAMP' => strval($timestamp), 'RELATIVE_TIMESTAMP' => strval($timestamp - $from), 'TICKER_TEXT' => NULL, 'URL' => build_url(array('page' => 'admin_security', 'type' => 'view', 'id' => $row['id']), '_SEARCH'), 'IS_POSITIVE' => false, 'IS_NEGATIVE' => true, 'FROM_ID' => 'member_' . strval($member_id), 'TO_ID' => NULL, 'GROUP_ID' => 'hack_type_' . $row['reason']);
         }
     }
     return $drops;
 }
Exemple #18
0
 /**
  * Standard modular run function.
  *
  * @param  MEMBER		The ID of the member we are getting link hooks for
  * @return array		List of tuples for results. Each tuple is: type,title,url
  */
 function run($member_id)
 {
     require_lang('ocgifts');
     if (is_guest()) {
         return array();
     }
     if (!has_actual_page_access(get_member(), 'pointstore', get_module_zone('pointstore'))) {
         return array();
     }
     if ($member_id == get_member()) {
         return array();
     }
     return array(array('contact', do_lang_tempcode('GIFT_GIFT'), build_url(array('page' => 'pointstore', 'type' => 'action', 'id' => 'ocgifts', 'username' => $GLOBALS['FORUM_DRIVER']->get_username($member_id)), get_module_zone('pointstore'))));
 }
Exemple #19
0
 /**
  * Standard modular run function for search results.
  *
  * @param  string			Search string
  * @param  boolean		Whether to only do a META (tags) search
  * @param  ID_TEXT		Order direction
  * @param  integer		Start position in total results
  * @param  integer		Maximum results to return in total
  * @param  boolean		Whether only to search titles (as opposed to both titles and content)
  * @param  string			Where clause that selects the content according to the main search string (SQL query fragment) (blank: full-text search)
  * @param  SHORT_TEXT	Username/Author to match for
  * @param  ?MEMBER		Member-ID to match for (NULL: unknown)
  * @param  TIME			Cutoff date
  * @param  string			The sort type (gets remapped to a field in this function)
  * @set    title add_date
  * @param  integer		Limit to this number of results
  * @param  string			What kind of boolean search to do
  * @set    or and
  * @param  string			Where constraints known by the main search code (SQL query fragment)
  * @param  string			Comma-separated list of categories to search under
  * @param  boolean		Whether it is a boolean search
  * @return array			List of maps (template, orderer)
  */
 function run($content, $only_search_meta, $direction, $max, $start, $only_titles, $content_where, $author, $author_id, $cutoff, $sort, $limit_to, $boolean_operator, $where_clause, $search_under, $boolean_search)
 {
     unset($limit_to);
     require_lang('calendar');
     $remapped_orderer = '';
     switch ($sort) {
         case 'title':
             $remapped_orderer = 'e_title';
             break;
         case 'add_date':
             $remapped_orderer = 'e_add_date';
             break;
     }
     // Calculate our where clause (search)
     $where_clause .= ' AND ';
     $where_clause .= '(e_is_public=1';
     if (!is_guest()) {
         $where_clause .= ' OR e_submitter=' . strval(get_member());
     }
     $where_clause .= ')';
     $sq = build_search_submitter_clauses('e_submitter', $author_id, $author);
     if (is_null($sq)) {
         return array();
     } else {
         $where_clause .= $sq;
     }
     if (!is_null($cutoff)) {
         $where_clause .= ' AND ';
         $where_clause .= 'e_add_date>' . strval(intval($cutoff));
     }
     $where_clause .= ' AND ';
     $where_clause .= 'e_type<>' . strval(db_get_first_id());
     if (!has_specific_permission(get_member(), 'see_unvalidated')) {
         $where_clause .= ' AND ';
         $where_clause .= 'validated=1';
     }
     // Calculate and perform query
     $rows = get_search_rows('event', 'id', $content, $boolean_search, $boolean_operator, $only_search_meta, $direction, $max, $start, $only_titles, 'calendar_events r', array('r.e_title', 'r.e_content'), $where_clause, $content_where, $remapped_orderer, 'r.*', NULL, 'calendar', 'e_type');
     $out = array();
     foreach ($rows as $i => $row) {
         $out[$i]['data'] = $row;
         unset($rows[$i]);
         if ($remapped_orderer != '' && array_key_exists($remapped_orderer, $row)) {
             $out[$i]['orderer'] = $row[$remapped_orderer];
         } elseif (substr($remapped_orderer, 0, 7) == '_rating') {
             $out[$i]['orderer'] = $row['compound_rating'];
         }
     }
     return $out;
 }
Exemple #20
0
 /**
  * Standard modular run function for RSS hooks.
  *
  * @param  string			A list of categories we accept from
  * @param  TIME			Cutoff time, before which we do not show results from
  * @param  string			Prefix that represents the template set we use
  * @set    RSS_ ATOM_
  * @param  string			The standard format of date to use for the syndication type represented in the prefix
  * @param  integer		The maximum number of entries to return, ordering by date
  * @return ?array			A pair: The main syndication section, and a title (NULL: error)
  */
 function run($_filters, $cutoff, $prefix, $date_string, $max)
 {
     if (!addon_installed('ocf_forum')) {
         return NULL;
     }
     if (get_forum_type() != 'ocf') {
         return NULL;
     }
     if (!has_actual_page_access(get_member(), 'forumview')) {
         return NULL;
     }
     $filters = ocfilter_to_sqlfragment($_filters, 'p_topic_id', 'f_forums', 'f_parent_forum', 'p_cache_forum_id', 'id', true, true, $GLOBALS['FORUM_DB']);
     $cutoff = max($cutoff, time() - 60 * 60 * 24 * 60);
     if (!is_guest()) {
         $filters .= ' AND (p_poster<>' . strval(get_member()) . ')';
     }
     $rows = $GLOBALS['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE p_time>' . strval($cutoff) . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND p_validated=1 ' : '') . ' AND ' . $filters . ' ORDER BY p_time DESC,id DESC', $max);
     $categories = list_to_map('id', $GLOBALS['FORUM_DB']->query('SELECT id,t_cache_first_title,t_pt_from,t_pt_to FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE t_cache_last_time>' . strval((int) $cutoff)));
     $content = new ocp_tempcode();
     foreach ($rows as $row) {
         if (!array_key_exists($row['p_topic_id'], $categories)) {
             continue;
         }
         $category = $categories[$row['p_topic_id']]['t_cache_first_title'];
         if ((!is_null($row['p_cache_forum_id']) || $categories[$row['p_topic_id']]['t_pt_from'] == get_member() || $categories[$row['p_topic_id']]['t_pt_to'] == get_member()) && (is_null($row['p_intended_solely_for']) || $row['p_intended_solely_for'] == get_member()) && has_category_access(get_member(), 'forums', strval($row['p_cache_forum_id']))) {
             $id = strval($row['id']);
             $author = $row['p_poster_name_if_guest'];
             $news_date = date($date_string, $row['p_time']);
             $edit_date = is_null($row['p_last_edit_time']) ? '' : date($date_string, $row['p_last_edit_time']);
             if ($edit_date == $news_date) {
                 $edit_date = '';
             }
             $news_title = xmlentities($row['p_title']);
             $_summary = get_translated_tempcode($row['p_post'], $GLOBALS['FORUM_DB']);
             $summary = xmlentities($_summary->evaluate());
             $news = '';
             $category_raw = strval($row['p_topic_id']);
             $view_url = build_url(array('page' => 'topicview', 'type' => 'findpost', 'id' => $row['id']), get_module_zone('forumview'), NULL, false, false, true);
             if ($prefix == 'RSS_') {
                 $if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => 'ed06bc8f174a5427e1789820666fdd81', 'COMMENT_URL' => $view_url, 'ID' => strval($row['p_topic_id'])));
             } else {
                 $if_comments = new ocp_tempcode();
             }
             $content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date)));
         }
     }
     require_lang('ocf');
     return array($content, do_lang('FORUM_TOPICS'));
 }
 /**
  * Standard modular run function for RSS hooks.
  *
  * @param  string			A list of categories we accept from
  * @param  TIME			Cutoff time, before which we do not show results from
  * @param  string			Prefix that represents the template set we use
  * @set    RSS_ ATOM_
  * @param  string			The standard format of date to use for the syndication type represented in the prefix
  * @param  integer		The maximum number of entries to return, ordering by date
  * @return ?array			A pair: The main syndication section, and a title (NULL: error)
  */
 function run($_filters, $cutoff, $prefix, $date_string, $max)
 {
     if (get_forum_type() != 'ocf') {
         return NULL;
     }
     if (is_guest()) {
         return NULL;
     }
     $member_id = get_member();
     if (get_forum_type() != 'ocf') {
         return NULL;
     }
     if (!has_actual_page_access($member_id, 'forumview')) {
         return NULL;
     }
     if (is_guest()) {
         return NULL;
     }
     require_code('ocf_notifications');
     $rows = ocf_get_pp_rows($max);
     $content = new ocp_tempcode();
     foreach ($rows as $row) {
         $id = strval($row['p_id']);
         $author = $row['t_cache_first_username'];
         $news_date = date($date_string, $row['t_cache_first_time']);
         $edit_date = date($date_string, $row['t_cache_last_time']);
         if ($edit_date == $news_date) {
             $edit_date = '';
         }
         $news_title = xmlentities($row['t_cache_first_title']);
         $_summary = get_translated_tempcode($row['t_cache_first_post'], $GLOBALS['FORUM_DB']);
         $summary = xmlentities($_summary->evaluate());
         $news = '';
         $category = do_lang('NA');
         $category_raw = '';
         $_view_url = build_url(array('page' => 'topicview', 'id' => $row['t_id']), get_module_zone('forumview'));
         $view_url = $_view_url->evaluate();
         $view_url .= '#' . strval($row['p_id']);
         if ($prefix == 'RSS_') {
             $if_comments = do_template('RSS_ENTRY_COMMENTS', array('COMMENT_URL' => $view_url, 'ID' => strval($row['p_id'])));
         } else {
             $if_comments = new ocp_tempcode();
         }
         $content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date)));
     }
     require_lang('ocf');
     return array($content, do_lang('PERSONAL_TOPICS'));
 }
Exemple #22
0
/**
 * Find whether the current member is logged in via httpauth. For Facebook/OpenID we put in a bit of extra code to notify that the session must also be auto-marked as confirmed (which is why the function is called in some cases).
 *
 * @return boolean		Whether the current member is logged in via httpauth
 */
function is_httpauth_login()
{
    if (get_forum_type() != 'ocf') {
        return false;
    }
    if (is_guest()) {
        return false;
    }
    $ret = non_overrided__is_httpauth_login();
    $compat = $GLOBALS['FORUM_DRIVER']->get_member_row_field(get_member(), 'm_password_compat_scheme');
    if ($compat == 'facebook' || $compat == 'openid') {
        global $SESSION_CONFIRMED;
        $SESSION_CONFIRMED = 1;
    }
    return $ret;
}
Exemple #23
0
/**
 * Get an SQL 'WHERE' clause for the posts in a topic.
 *
 * @param  AUTO_LINK		The ID of the topic we are getting details of.
 * @param  ?MEMBER		The member doing the lookup (NULL: current member).
 * @return string			The WHERE clause.
 */
function ocf_get_topic_where($topic_id, $member_id = NULL)
{
    if (is_null($member_id)) {
        $member_id = get_member();
    }
    $where = 'p_topic_id=' . strval((int) $topic_id);
    if (is_guest()) {
        $where .= ' AND p_intended_solely_for IS NULL';
    } elseif (!has_specific_permission($member_id, 'view_other_pt')) {
        $where .= ' AND (p_intended_solely_for=' . strval((int) $member_id) . ' OR p_poster=' . strval((int) $member_id) . ' OR p_intended_solely_for IS NULL)';
    }
    if (!has_specific_permission($member_id, 'see_unvalidated')) {
        $where .= ' AND (p_validated=1 OR ((p_poster<>' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' OR ' . db_string_equal_to('p_ip_address', get_ip_address()) . ') AND p_poster=' . strval((int) $member_id) . '))';
    }
    return $where;
}
 function run($param)
 {
     $value = '';
     if (get_forum_type() == 'ocf') {
         if (!is_guest()) {
             require_code('facebook_connect');
             global $FACEBOOK_CONNECT;
             if (!is_null($FACEBOOK_CONNECT)) {
                 $value = strval($FACEBOOK_CONNECT->getAccessToken());
                 if ($value == '0') {
                     $value = '';
                 }
             }
         }
     }
     return $value;
 }
Exemple #25
0
 /**
  * Transfer gift-points into the specified member's account, courtesy of the system.
  *
  * @param  SHORT_TEXT	The reason for the transfer
  * @param  integer		The size of the transfer
  * @param  MEMBER			The member the transfer is to
  */
 function system_gift_transfer($reason, $amount, $member_id)
 {
     require_lang('points');
     require_code('points');
     if (is_guest($member_id)) {
         return;
     }
     if ($amount == 0) {
         return;
     }
     $GLOBALS['SITE_DB']->query_insert('gifts', array('date_and_time' => time(), 'amount' => $amount, 'gift_from' => $GLOBALS['FORUM_DRIVER']->get_guest_id(), 'gift_to' => $member_id, 'reason' => insert_lang_comcode($reason, 4), 'anonymous' => 1));
     $_before = point_info($member_id);
     $before = array_key_exists('points_gained_given', $_before) ? $_before['points_gained_given'] : 0;
     $new = strval($before + $amount);
     $GLOBALS['FORUM_DRIVER']->set_custom_field($member_id, 'points_gained_given', $new);
     global $TOTAL_POINTS_CACHE, $POINT_INFO_CACHE;
     if (array_key_exists($member_id, $TOTAL_POINTS_CACHE)) {
         $TOTAL_POINTS_CACHE[$member_id] += $amount;
     }
     if (array_key_exists($member_id, $POINT_INFO_CACHE) && array_key_exists('points_gained_given', $POINT_INFO_CACHE[$member_id])) {
         $POINT_INFO_CACHE[$member_id]['points_gained_given'] += $amount;
     }
     //start add to mentor points if needed
     //$mentor_id=$GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id,'u_mentor');
     $mentor_id = $GLOBALS['SITE_DB']->query_value_null_ok('members_mentors', 'mentor_id', array('member_id' => $member_id), '', true);
     if (isset($mentor_id) && !is_null($mentor_id) && intval($mentor_id) != 0) {
         //give points to mentor too
         $GLOBALS['SITE_DB']->query_insert('gifts', array('date_and_time' => time(), 'amount' => $amount, 'gift_from' => $GLOBALS['FORUM_DRIVER']->get_guest_id(), 'gift_to' => $mentor_id, 'reason' => insert_lang_comcode($reason, 4), 'anonymous' => 1));
         $_before = point_info($mentor_id);
         $before = array_key_exists('points_gained_given', $_before) ? $_before['points_gained_given'] : 0;
         $new = strval($before + $amount);
         $GLOBALS['FORUM_DRIVER']->set_custom_field($mentor_id, 'points_gained_given', $new);
         if (array_key_exists($mentor_id, $TOTAL_POINTS_CACHE)) {
             $TOTAL_POINTS_CACHE[$mentor_id] += $amount;
         }
         if (array_key_exists($mentor_id, $POINT_INFO_CACHE) && array_key_exists('points_gained_given', $POINT_INFO_CACHE[$mentor_id])) {
             $POINT_INFO_CACHE[$mentor_id]['points_gained_given'] += $amount;
         }
     }
     if (get_forum_type() == 'ocf') {
         require_code('ocf_posts_action');
         require_code('ocf_posts_action2');
         ocf_member_handle_promotion($member_id);
     }
 }
Exemple #26
0
 /**
  * Find whether this hook is active.
  *
  * @param  MEMBER			The ID of the member who is being viewed
  * @param  MEMBER			The ID of the member who is doing the viewing
  * @return boolean		Whether this hook is active
  */
 function is_active($member_id_of, $member_id_viewing)
 {
     if (is_guest($member_id_viewing)) {
         return false;
     }
     if (!($member_id_of == $member_id_viewing || has_specific_permission($member_id_viewing, 'assume_any_member') || has_specific_permission($member_id_viewing, 'member_maintenance'))) {
         return false;
     }
     $hooks = find_all_hooks('systems', 'profiles_tabs_edit');
     foreach (array_keys($hooks) as $hook) {
         require_code('hooks/systems/profiles_tabs_edit/' . $hook);
         $ob = object_factory('Hook_Profiles_Tabs_Edit_' . $hook);
         if ($ob->is_active($member_id_of, $member_id_viewing)) {
             return true;
         }
     }
     return false;
 }
Exemple #27
0
/**
 * Render a member profile.
 *
 * @param  MEMBER			The ID of the member who is being viewed
 * @param  ?MEMBER		The ID of the member who is doing the viewing (NULL: current member)
 * @param  ?ID_TEXT		The username of the member who is being viewed (NULL: work out from member_id_of)
 * @return tempcode		The rendered profile
 */
function render_profile_tabset($member_id_of, $member_id_viewing = NULL, $username = NULL)
{
    if (is_null($member_id_viewing)) {
        $member_id_viewing = get_member();
    }
    $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
    if (is_null($username) || is_guest($member_id_of)) {
        warn_exit(do_lang_tempcode('USER_NO_EXIST'));
    }
    $tabs = array();
    $hooks = find_all_hooks('systems', 'profiles_tabs');
    if (isset($hooks['edit'])) {
        $hooks = array('edit' => $hooks['edit']) + $hooks;
    }
    foreach (array_keys($hooks) as $hook) {
        require_code('hooks/systems/profiles_tabs/' . $hook);
        $ob = object_factory('Hook_Profiles_Tabs_' . $hook);
        if ($ob->is_active($member_id_of, $member_id_viewing)) {
            $tabs[$hook] = $ob->render_tab($member_id_of, $member_id_viewing, !browser_matches('ie6') && !browser_matches('ie7') && has_js());
        }
    }
    global $M_SORT_KEY;
    $M_SORT_KEY = 2;
    uasort($tabs, 'multi_sort');
    require_javascript('javascript_profile');
    require_javascript('javascript_ajax');
    load_up_all_self_page_permissions($member_id_viewing);
    if (addon_installed('awards')) {
        require_code('awards');
        $awards = find_awards_for('member', strval($member_id_of));
    } else {
        $awards = array();
    }
    $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
    // Get it again, in case it changed
    $title = get_page_title('MEMBER_PROFILE', true, array(escape_html($username)), NULL, $awards);
    $_tabs = array();
    $i = 0;
    foreach ($tabs as $hook => $tab) {
        $_tabs[] = array('TAB_TITLE' => $tab[0], 'TAB_CODE' => $hook, 'TAB_CONTENT' => $tab[1], 'TAB_FIRST' => $i == 0, 'TAB_LAST' => !array_key_exists($i + 1, $tabs));
        $i++;
    }
    return do_template('OCF_MEMBER_PROFILE_SCREEN', array('TITLE' => $title, 'TABS' => $_tabs, 'MEMBER_ID' => strval($member_id_of)));
}
Exemple #28
0
 /**
  * Handle hooks supported bot commands. Note multiple bots may support the same commands, and all respond. It is recommended all bots support the command 'help'.
  *
  * @param  AUTO_LINK		The ID of the chat room
  * @param  string			The command used. This is just the chat message, so you can encode and recognise your own parameter scheme if you like.
  * @return ?string		Bot reply (NULL: bot does not handle the command)
  */
 function handle_commands($room_id, $command)
 {
     switch ($command) {
         case 'help':
             $out = do_lang('CHAT_HELP_BOTMSG');
             return do_lang('CHAT_WEBSITE_HELPER_BOT', $out);
         case 'users_online':
             // On the site
             $count = 0;
             $members = get_online_members(true, NULL, $count);
             if (is_null($members)) {
                 return do_lang('TOO_MANY_USERS_ONLINE');
             }
             $guests = 0;
             $site_members = '';
             foreach ($members as $member) {
                 if (is_guest($member['the_user']) || is_null($member['cache_username'])) {
                     $guests++;
                 } else {
                     if ($site_members != '') {
                         $site_members .= ', ';
                     }
                     $site_members .= '{{' . $member['cache_username'] . '}}';
                 }
             }
             // In this room
             $room_members = get_chatters_in_room($room_id);
             $_room_members = '';
             foreach ($room_members as $room_member) {
                 if ($_room_members != '') {
                     $_room_members .= ', ';
                 }
                 $_room_members .= '{{' . $room_member . '}}';
             }
             // Show our complete result
             $out = do_lang('CHAT_USERSONLINE_BOTMSG', $site_members, $_room_members);
             return do_lang('CHAT_WEBSITE_HELPER_BOT', $out);
         case 'time':
             $out = do_lang('CHAT_TIME_BOTMSG', get_timezoned_date(time(), true, true, true, true));
             return do_lang('CHAT_WEBSITE_HELPER_BOT', $out);
     }
     return NULL;
 }
Exemple #29
0
 /**
  * Standard modular run function for newsletter hooks.
  *
  * @param  TIME				The time that the entries found must be newer than
  * @param  LANGUAGE_NAME	The language the entries found must be in
  * @param  string				Category filter to apply
  * @return array				Tuple of result details
  */
 function run($cutoff_time, $lang, $filter)
 {
     if (!addon_installed('galleries')) {
         return array();
     }
     require_lang('galleries');
     $new = new ocp_tempcode();
     $count = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'galleries WHERE name NOT LIKE \'' . db_encode_like('download\\_%') . '\'');
     if ($count < 500) {
         $_galleries = $GLOBALS['SITE_DB']->query('SELECT name,fullname FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'galleries WHERE name NOT LIKE \'' . db_encode_like('download\\_%') . '\'', 300);
         if (count($_galleries) == 300) {
             return array();
         }
         foreach ($_galleries as $i => $_gallery) {
             $_galleries[$i]['text_original'] = get_translated_text($_gallery['fullname']);
         }
         $galleries = collapse_2d_complexity('name', 'text_original', $_galleries);
     } else {
         $galleries = array();
     }
     require_code('ocfiltering');
     $or_list = ocfilter_to_sqlfragment($filter, 'cat', NULL, NULL, NULL, NULL, false);
     $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'videos WHERE add_date>' . strval((int) $cutoff_time) . ' AND validated=1 AND (' . $or_list . ') ORDER BY add_date DESC', 300);
     if (count($rows) == 300) {
         return array();
     }
     foreach ($rows as $row) {
         $_url = build_url(array('page' => 'galleries', 'type' => 'video', 'id' => $row['id']), get_module_zone('galleries'), NULL, false, false, true);
         $url = $_url->evaluate();
         if (!array_key_exists($row['cat'], $galleries)) {
             $galleries[$row['cat']] = get_translated_text($GLOBALS['SITE_DB']->query_value('galleries', 'fullname', array('name' => $row['cat'])));
         }
         $name = $galleries[$row['cat']];
         $_name = get_translated_text($row['title']);
         if ($_name != '') {
             $name = $_name;
         }
         $description = get_translated_text($row['comments'], NULL, $lang);
         $member_id = is_guest($row['submitter']) ? NULL : strval($row['submitter']);
         $new->attach(do_template('NEWSLETTER_NEW_RESOURCE_FCOMCODE', array('_GUID' => 'dfe5850aa67c0cd00ff7d465248b87a5', 'MEMBER_ID' => $member_id, 'URL' => $url, 'NAME' => $name, 'DESCRIPTION' => $description)));
     }
     return array($new, do_lang('GALLERIES', '', '', '', $lang));
 }
 /**
  * Standard modular run function for RSS hooks.
  *
  * @param  string			A list of categories we accept from
  * @param  TIME			Cutoff time, before which we do not show results from
  * @param  string			Prefix that represents the template set we use
  * @set    RSS_ ATOM_
  * @param  string			The standard format of date to use for the syndication type represented in the prefix
  * @param  integer		The maximum number of entries to return, ordering by date
  * @return ?array			A pair: The main syndication section, and a title (NULL: error)
  */
 function run($_filters, $cutoff, $prefix, $date_string, $max)
 {
     if (get_forum_type() != 'ocf') {
         return NULL;
     }
     if (!has_actual_page_access(get_member(), 'forumview')) {
         return NULL;
     }
     if (is_guest()) {
         return NULL;
     }
     $condition = 'l_time<t_cache_last_time OR (l_time IS NULL AND t_cache_last_time>' . strval(time() - 60 * 60 * 24 * intval(get_option('post_history_days'))) . ')';
     $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 . ') AND t_forum_id IS NOT NULL ' . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND t_validated=1 ' : '') . ' ORDER BY t_cache_last_time DESC';
     $rows = $GLOBALS['FORUM_DB']->query('SELECT *,top.id AS t_id ' . $query, $max);
     $categories = 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'));
     $content = new ocp_tempcode();
     foreach ($rows as $row) {
         if ((!is_null($row['t_forum_id']) || $row['t_pt_to'] == get_member()) && has_category_access(get_member(), 'forums', strval($row['t_forum_id']))) {
             $id = strval($row['id']);
             $author = $row['t_cache_first_username'];
             $news_date = date($date_string, $row['t_cache_first_time']);
             $edit_date = date($date_string, $row['t_cache_last_time']);
             if ($edit_date == $news_date) {
                 $edit_date = '';
             }
             $news_title = xmlentities($row['t_cache_first_title']);
             $_summary = get_translated_tempcode($row['t_cache_first_post'], $GLOBALS['FORUM_DB']);
             $summary = xmlentities($_summary->evaluate());
             $news = '';
             $category = array_key_exists($row['t_forum_id'], $categories) ? $categories[$row['t_forum_id']] : do_lang('NA');
             $category_raw = strval($row['t_forum_id']);
             $view_url = build_url(array('page' => 'topicview', 'id' => $row['t_id']), get_module_zone('topicview'));
             if ($prefix == 'RSS_') {
                 $if_comments = do_template('RSS_ENTRY_COMMENTS', array('COMMENT_URL' => $view_url, 'ID' => strval($row['t_id'])));
             } else {
                 $if_comments = new ocp_tempcode();
             }
             $content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date)));
         }
     }
     require_lang('ocf');
     return array($content, do_lang('TOPICS_UNREAD'));
 }