/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $type = get_param('type'); if (!has_zone_access(get_member(), 'adminzone')) { return new ocp_tempcode(); } decache('main_staff_checklist'); require_lang('staff_checklist'); switch ($type) { case 'add': $recurinterval = get_param_integer('recurinterval', 0); $task_title = get_param('tasktitle', false, true); $id = $GLOBALS['SITE_DB']->query_insert('customtasks', array('tasktitle' => $task_title, 'datetimeadded' => time(), 'recurinterval' => $recurinterval, 'recurevery' => get_param('recurevery'), 'taskisdone' => NULL), true); require_code('notifications'); $subject = do_lang('CT_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $task_title); $mail = do_lang('CT_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($task_title)); dispatch_notification('checklist_task', NULL, $subject, $mail); return do_template('BLOCK_MAIN_STAFF_CHECKLIST_CUSTOM_TASK', array('TASKTITLE' => comcode_to_tempcode(get_param('tasktitle', false, true)), 'DATETIMEADDED' => display_time_period(time()), 'RECURINTERVAL' => $recurinterval == 0 ? '' : integer_format($recurinterval), 'RECUREVERY' => get_param('recurevery'), 'TASKDONE' => 'not_completed', 'ID' => strval($id))); case 'delete': $GLOBALS['SITE_DB']->query_delete('customtasks', array('id' => get_param_integer('id')), '', 1); break; case 'mark_done': $GLOBALS['SITE_DB']->query_update('customtasks', array('taskisdone' => time()), array('id' => get_param_integer('id')), '', 1); break; case 'mark_undone': $GLOBALS['SITE_DB']->query_update('customtasks', array('taskisdone' => NULL), array('id' => get_param_integer('id')), '', 1); break; } return new ocp_tempcode(); }
/** * 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; }
/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { if (get_option('is_on_rating') == '0') { return do_lang_tempcode('INTERNAL_ERROR'); } // Has there actually been any rating? if (strtoupper(ocp_srv('REQUEST_METHOD')) == 'POST' || ocp_srv('HTTP_REFERER') == '') { $rating = either_param_integer('rating', NULL); } else { $rating = post_param_integer('rating'); // Will fail } $content_type = get_param('content_type'); $type = get_param('type', ''); $content_id = get_param('id'); $content_url = get_param('content_url', '', true); $content_title = get_param('content_title', '', true); require_code('feedback'); actualise_specific_rating($rating, get_page_name(), get_member(), $content_type, $type, $content_id, $content_url, $content_title); actualise_give_rating_points(); $template = get_param('template', NULL); if ($template !== '') { if (is_null($template)) { $template = 'RATING_BOX'; } return display_rating($content_url, $content_title, $content_type, $content_id, $template); } return do_lang_tempcode('THANKYOU_FOR_RATING_SHORT'); }
/** * 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('cedi')) { return NULL; } if (!has_actual_page_access(get_member(), 'cedi')) { return NULL; } $filters = ocfilter_to_sqlfragment($_filters, 'id', 'seedy_children', 'parent_id', 'parent_id', 'child_id'); $content = new ocp_tempcode(); $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'seedy_pages WHERE ' . $filters . ' AND add_date>' . strval((int) $cutoff) . ' ORDER BY add_date DESC', $max); foreach ($rows as $row) { $id = strval($row['id']); if (!has_category_access(get_member(), 'seedy_page', strval($row['id']))) { continue; } $author = ''; $news_date = date($date_string, $row['add_date']); $edit_date = ''; $news_title = xmlentities(escape_html(get_translated_text($row['title']))); $_summary = get_translated_tempcode($row['description']); $summary = xmlentities($_summary->evaluate()); $news = ''; $category = ''; $category_raw = ''; $view_url = build_url(array('page' => 'cedi', 'type' => 'misc', 'id' => $row['id'] == db_get_first_id() ? NULL : $row['id']), get_module_zone('cedi'), NULL, false, false, true); $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('cedi'); return array($content, do_lang('CEDI_PAGES')); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_code('downloads'); require_css('downloads'); require_lang('downloads'); require_code('ocfiltering'); $number = array_key_exists('param', $map) ? intval($map['param']) : 10; $filter = array_key_exists('filter', $map) ? $map['filter'] : '*'; $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('downloads'); $sql_filter = ocfilter_to_sqlfragment($filter, 'p.category_id', 'download_categories', 'parent_id', 'p.category_id', '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) $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'download_downloads p WHERE validated=1 AND (' . $sql_filter . ') ORDER BY add_date DESC', $number); $title = do_lang_tempcode('RECENT', make_string_tempcode(integer_format($number)), do_lang_tempcode('SECTION_DOWNLOADS')); if (array_key_exists('title', $map) && $map['title'] != '') { $title = protect_from_escaping(escape_html($map['title'])); } $out = new ocp_tempcode(); foreach ($rows as $i => $row) { if ($i != 0) { $out->attach(do_template('BLOCK_SEPARATOR')); } $out->attach(get_download_html($row, true, true, $zone)); } if ($out->is_empty()) { if (has_actual_page_access(NULL, 'cms_downloads', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_downloads')) { $submit_url = build_url(array('page' => 'cms_downloads', 'type' => 'ad', 'redirect' => SELF_REDIRECT), get_module_zone('cms_downloads')); } else { $submit_url = new ocp_tempcode(); } return do_template('BLOCK_NO_ENTRIES', array('_GUID' => '74399763a51102bdd6e6d92c2c11354f', 'HIGH' => false, 'TITLE' => $title, 'MESSAGE' => do_lang_tempcode('NO_DOWNLOADS_YET'), 'ADD_NAME' => do_lang_tempcode('ADD_DOWNLOAD'), 'SUBMIT_URL' => $submit_url)); } return do_template('BLOCK_MAIN_RECENT_DOWNLOADS', array('_GUID' => '257fa1b83d1b6fe3acbceb2b618e6d7f', 'TITLE' => $title, 'CONTENT' => $out, 'NUMBER' => integer_format($number))); }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { if (!has_specific_permission(get_member(), 'comcode_dangerous')) { exit; } require_code('zones2'); require_code('zones3'); $bparameters = ''; $bparameters_xml = ''; $block = post_param('block'); $parameters = get_block_parameters($block); $parameters[] = 'failsafe'; $parameters[] = 'cache'; $parameters[] = 'quick_cache'; foreach ($parameters as $parameter) { $value = post_param($parameter, NULL); if (is_null($value)) { if (post_param_integer('tick_on_form__' . $parameter, NULL) === NULL) { continue; } // If not on form, continue, otherwise must be 0 $value = '0'; } if ($value != '' && ($parameter != 'failsafe' || $value == '1') && ($parameter != 'cache' || $value != block_cache_default($block)) && ($parameter != 'quick_cache' || $value == '1')) { $bparameters .= ' ' . $parameter . '="' . str_replace('"', '\\"', $value) . '"'; $bparameters_xml = '<blockParam key="' . escape_html($parameter) . '" val="' . escape_html($value) . '" />'; } } $comcode = '[block' . $bparameters . ']' . $block . '[/block]'; $preview = comcode_to_tempcode($comcode); return array($preview, NULL); }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { require_code('uploads'); $urls = get_url('', 'file', 'uploads/iotds', 0, OCP_UPLOAD_IMAGE, true, '', 'file2'); if ($urls[0] == '') { if (!is_null(post_param_integer('id', NULL))) { $rows = $GLOBALS['SITE_DB']->query_select('iotds', array('url', 'thumb_url'), array('id' => post_param_integer('id')), '', 1); $urls = $rows[0]; $url = $urls['url']; $thumb_url = $urls['thumb_url']; } else { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD')); } } else { $url = $urls[0]; $thumb_url = $urls[1]; } $caption = comcode_to_tempcode(post_param('caption', '')); $title = comcode_to_tempcode(post_param('title', '')); require_code('images'); $thumb = do_image_thumb(url_is_local($thumb_url) ? get_custom_base_url() . '/' . $thumb_url : $thumb_url, $caption, true); $url = url_is_local($url) ? get_custom_base_url() . '/' . $url : $url; $preview = do_template('IOTD', array('ID' => '', 'IMAGE_URL' => $url, 'SUBMITTER' => strval(get_member()), 'VIEW_URL' => $url, 'IMAGE' => $thumb, 'CAPTION' => $title)); return array($preview, NULL); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_code('catalogues'); require_lang('catalogues'); require_css('catalogues'); $number = array_key_exists('param', $map) ? intval($map['param']) : 10; $catalogue = array_key_exists('catalogue', $map) ? $map['catalogue'] : 'faqs'; $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('catalogues'); $root = array_key_exists('root', $map) && $map['root'] != '' ? intval($map['root']) : NULL; $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue), '', 1); if (!array_key_exists(0, $catalogues)) { return do_lang_tempcode('MISSING_RESOURCE', escape_html($catalogue)); } $catalogue_row = $catalogues[0]; $entries = $GLOBALS['SITE_DB']->query_select('catalogue_entries', array('*'), array('c_name' => $catalogue, 'ce_validated' => 1), 'ORDER BY ce_add_date DESC', $number); $tpl_set = $catalogue; $display_type = array_key_exists('display_type', $map) ? intval($map['display_type']) : NULL; list($content, , ) = get_catalogue_category_entry_buildup(db_get_first_id(), $catalogue, $catalogue_row, 'SEARCH', $tpl_set, $number, 0, NULL, $root, $display_type, false, $entries); $catalogue_title = get_translated_text($catalogue_row['c_title']); if ($content->is_empty()) { if (has_actual_page_access(NULL, 'cms_catalogues', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_catalogues')) { $submit_url = build_url(array('page' => 'cms_catalogues', 'type' => 'add_entry', 'catalogue_name' => $catalogue, 'redirect' => SELF_REDIRECT), get_module_zone('cms_catalogues')); } else { $submit_url = new ocp_tempcode(); } return do_template('BLOCK_NO_ENTRIES', array('HIGH' => false, 'TITLE' => do_lang_tempcode('RECENT', escape_html(integer_format($number)), escape_html($catalogue_title)), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('CATALOGUE_GENERIC_ADD', escape_html($catalogue_title)), 'SUBMIT_URL' => $submit_url)); } return do_template('BLOCK_MAIN_RECENT_CC_ENTRIES', array('_GUID' => 'a57fa1b83d1b6fe3acbceb2b618e6d7f', 'CATALOGUE_TITLE' => $catalogue_title, 'CATALOGUE' => $catalogue, 'CONTENT' => $content, 'NUMBER' => integer_format($number))); }
/** * 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); require_lang('custom_comcode'); $tags = array(); $wmap = array('tag_enabled' => 1); if (!has_specific_permission(get_member(), 'comcode_dangerous')) { $wmap['tag_dangerous_tag'] = 0; } $tags = array_merge($tags, $GLOBALS['SITE_DB']->query_select('custom_comcode', array('tag_title', 'tag_description', 'tag_example', 'tag_parameters', 'tag_replace', 'tag_tag', 'tag_dangerous_tag', 'tag_block_tag', 'tag_textual_tag'), $wmap)); if (isset($GLOBALS['FORUM_DB']) && $GLOBALS['FORUM_DB']->connection_write != $GLOBALS['SITE_DB']->connection_write && get_forum_type() == 'ocf') { $tags = array_merge($tags, $GLOBALS['FORUM_DB']->query_select('custom_comcode', array('tag_title', 'tag_description', 'tag_example', 'tag_parameters', 'tag_replace', 'tag_tag', 'tag_dangerous_tag', 'tag_block_tag', 'tag_textual_tag'), $wmap)); } // From Comcode hooks $hooks = find_all_hooks('systems', 'comcode'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/comcode/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_comcode_' . filter_naughty_harsh($hook), true); $tags[] = $object->get_tag(); } if (!array_key_exists(0, $tags)) { return paragraph(do_lang_tempcode('NONE_EM'), '', 'nothing_here'); } $content = new ocp_tempcode(); foreach ($tags as $tag) { $content->attach(do_template('CUSTOM_COMCODE_TAG_ROW', array('_GUID' => '28c257f5d0c596aa828fd9556b0df4a9', 'TITLE' => is_string($tag['tag_title']) ? $tag['tag_title'] : get_translated_text($tag['tag_title']), 'DESCRIPTION' => is_string($tag['tag_description']) ? $tag['tag_description'] : get_translated_text($tag['tag_description']), 'EXAMPLE' => $tag['tag_example']))); } return do_template('BLOCK_MAIN_CUSTOM_COMCODE_TAGS', array('_GUID' => 'b8d3436e6e5fe679ae9b0a368e607610', 'TAGS' => $content)); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('news'); $categories = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL)); $content = new ocp_tempcode(); $categories2 = array(); foreach ($categories as $category) { if (has_category_access(get_member(), 'news', strval($category['id']))) { $join = ' LEFT JOIN ' . get_table_prefix() . 'news_category_entries d ON d.news_entry=p.id'; $count = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'news p' . $join . ' WHERE validated=1 AND (news_entry_category=' . strval($category['id']) . ' OR news_category=' . strval($category['id']) . ') ORDER BY date_and_time DESC'); if ($count > 0) { $category['_nc_title'] = get_translated_text($category['nc_title']); $categories2[] = $category; } } } if (count($categories2) == 0) { global $M_SORT_KEY; $M_SORT_KEY = '_nc_title'; usort($categories2, 'multi_sort'); foreach ($categories as $category) { if (has_category_access(get_member(), 'news', strval($category['id']))) { $categories2[] = $category; } } } foreach ($categories2 as $category) { $url = build_url(array('page' => 'news', 'type' => 'misc', 'id' => $category['id']), get_module_zone('news')); $name = $category['_nc_title']; $content->attach(do_template('BLOCK_SIDE_NEWS_CATEGORIES_CATEGORY', array('_GUID' => 'fee49cac370ec00fc59d2e9c66b6255a', 'URL' => $url, 'NAME' => $name, 'COUNT' => integer_format($count)))); } return do_template('BLOCK_SIDE_NEWS_CATEGORIES', array('_GUID' => 'b47a0047247096373e5aa626348c4ebb', 'CONTENT' => $content, 'PRE' => '', 'POST' => '')); }
/** * 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; }
/** * Standard modular info function for award hooks. Provides information to allow task reporting, randomisation, and add-screen linking, to function. * * @param ?ID_TEXT Catalogue we'll be using (NULL: unknown). * @return ?array Map of award content-type info (NULL: disabled). */ function info($catalogue_name = NULL) { $info = array(); $info['connection'] = $GLOBALS['SITE_DB']; $info['table'] = 'catalogue_entries'; $info['date_field'] = 'ce_add_date'; $info['id_field'] = 'id'; $info['add_url'] = has_submit_permission('mid', get_member(), get_ip_address(), 'cms_catalogues') ? build_url(array('page' => 'cms_catalogues', 'type' => 'add_entry', 'catalogue_name' => $catalogue_name), get_module_zone('cms_catalogues')) : new ocp_tempcode(); $info['category_field'] = array('c_name', 'cc_id'); $info['category_type'] = array('catalogues_catalogue', 'catalogues_category'); $info['parent_spec__table_name'] = 'catalogue_categories'; $info['parent_spec__parent_name'] = 'cc_parent_id'; $info['parent_spec__field_name'] = 'id'; $info['parent_field_name'] = 'cc_id'; $info['submitter_field'] = 'ce_submitter'; $info['id_is_string'] = false; require_lang('catalogues'); $info['title'] = do_lang_tempcode('CATALOGUE_ENTRIES'); $info['validated_field'] = 'ce_validated'; $info['category_is_string'] = array(true, false); $info['archive_url'] = build_url(array('page' => 'catalogues'), get_module_zone('catalogues')); $info['cms_page'] = 'cms_catalogues'; $info['views_field'] = 'ce_views'; return $info; }
function testAddbanner() { $this->banner_name = 'Goodmorning'; add_banner($this->banner_name, 'http://ocportal.com/themes/ocproducts/images/newlogo.gif', 'Good morning', 'Welcome', 10, 'http://ocportal.com', 3, 'test notes', 1, 1329153480, get_member(), 1, $this->banner_type); //make sure the banner is created with given name $this->assertTrue('http://ocportal.com/themes/ocproducts/images/newlogo.gif' == $GLOBALS['FORUM_DB']->query_value('banners', 'img_url', array('name' => $this->banner_name))); }
/** * Standard function to create the standardised category tree * * @param ID_TEXT Notification code * @param ?ID_TEXT The ID of where we're looking under (NULL: N/A) * @return array Tree structure */ function create_category_tree($notification_code, $id) { $pagelinks = array(); $notification_category = get_param('id', NULL); $done_in_url = is_null($notification_category); $types = $GLOBALS['SITE_DB']->query_select('chat_buddies', array('member_liked'), array('member_likes' => get_member())); // Only show options for friends to simplify $types2 = $GLOBALS['SITE_DB']->query_select('notifications_enabled', array('l_code_category'), array('l_notification_code' => substr($notification_code, 0, 80), 'l_member_id' => get_member())); // Already monitoring members who may not be friends foreach ($types2 as $type) { $types[] = array('member_liked' => intval($type['l_code_category'])); } foreach ($types as $type) { $username = $GLOBALS['FORUM_DRIVER']->get_username($type['member_liked']); if (!is_null($username)) { $pagelinks[$type['member_liked']] = array('id' => strval($type['member_liked']), 'title' => $username); if (!$done_in_url) { if (strval($type['member_liked']) == $notification_category) { $done_in_url = true; } } } } if (!$done_in_url) { $pagelinks[] = array('id' => $notification_category, 'title' => $GLOBALS['FORUM_DRIVER']->get_username(intval($notification_category))); } global $M_SORT_KEY; $M_SORT_KEY = 'title'; usort($pagelinks, 'multi_sort'); return array_values($pagelinks); }
/** * Standard modular run function. * * @return array An array of tuples: The task row to show, the number of seconds until it is due (or NULL if not on a timer), the number of things to sort out (or NULL if not on a queue), The name of the config option that controls the schedule (or NULL if no option). */ function run() { if (!addon_installed('tickets')) { return array(); } require_lang('tickets'); require_code('tickets'); require_code('tickets2'); $outstanding = 0; $tickets = get_tickets(get_member(), NULL, false, true); if (!is_null($tickets)) { foreach ($tickets as $topic) { if ($topic['closed'] == 0) { $outstanding++; } } } if ($outstanding > 0) { $status = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_0', array('_GUID' => 'g578142633c6f3d37776e82a869deb91')); } else { $status = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_1', array('_GUID' => 'h578142633c6f3d37776e82a869deb91')); } $url = build_url(array('page' => 'tickets', 'type' => 'misc'), get_module_zone('tickets')); $tpl = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM', array('URL' => $url, 'STATUS' => $status, 'TASK' => do_lang_tempcode('SUPPORT_TICKETS'), 'INFO' => do_lang_tempcode('NUM_QUEUE', escape_html(integer_format($outstanding))))); return array(array($tpl, NULL, $outstanding, NULL)); }
/** * Log permission checks to the permission_checks.log file * * @param MEMBER The user checking against * @param ID_TEXT The function that was called to check a permission * @param array Parameters to this permission-checking function * @param boolean Whether the permission was held */ function _handle_permission_check_logging($member, $op, $params, $result) { global $PERMISSION_CHECK_LOGGER; if ($op == 'has_specific_permission') { require_all_lang(); $params[0] = $params[0] . ' ("' . do_lang('PT_' . $params[0]) . '")'; } $str = $op; if (count($params) != 0) { $str .= ': '; foreach ($params as $i => $p) { if ($i != 0) { $str .= ','; } $str .= is_string($p) ? $p : (is_null($p) ? '' : strval($p)); } } if ($PERMISSION_CHECK_LOGGER !== false && !$result) { fwrite($PERMISSION_CHECK_LOGGER, "\t" . $str); $username = $GLOBALS['FORUM_DRIVER']->get_username($member); if (is_null($username)) { $username = do_lang('UNKNOWN'); } if ($member != get_member()) { fwrite($PERMISSION_CHECK_LOGGER, ' -- ' . $username); } // fwrite($PERMISSION_CHECK_LOGGER,' --> '.($result?do_lang('YES'):do_lang('NO')).chr(10)); fwrite($PERMISSION_CHECK_LOGGER, chr(10)); sync_file(get_custom_file_base() . '/data_custom/permissioncheckslog.php'); } if (function_exists('fb') && get_param_integer('keep_firephp', 0) == 1 && !headers_sent()) { fb('Permission check ' . ($result ? 'PASSED' : 'FAILED') . ': ' . $str); } }
/** * Whether the current member may use invites (doesn't check if they have any left though!) * * @return boolean Whether they may */ function may_use_invites() { if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) { return true; } return get_option('is_on_invites') == '1'; }
/** * Standard modular run function. * * @param MEMBER The ID of the member we are getting detail hooks for * @return ?tempcode Results (NULL: no action) */ function run($member_id) { global $OCWORLD_MEMBER_CACHE; if (!isset($OCWORLD_MEMBER_CACHE)) { $OCWORLD_MEMBER_CACHE = array(); } if (array_key_exists($member_id, $OCWORLD_MEMBER_CACHE)) { return $OCWORLD_MEMBER_CACHE[$member_id]; } $zone = get_page_zone('ocworld', false); if (is_null($zone)) { return NULL; } if (!has_zone_access(get_member(), $zone)) { return NULL; } $rows = $GLOBALS['SITE_DB']->query_select('w_members m LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'w_realms r ON m.location_realm=r.id', array('*'), array('m.id' => $member_id), '', 1, 0, true); if (!is_null($rows) && array_key_exists(0, $rows)) { $row = $rows[0]; $room = $GLOBALS['SITE_DB']->query_value_null_ok('w_rooms', 'name', array('location_x' => $row['location_x'], 'location_y' => $row['location_y'], 'location_realm' => $row['location_realm'])); if (is_null($room)) { return NULL; } require_lang('ocworld'); $a = do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('_GUID' => '3d36d5ae8bcb66d59a0676200571fb1a', 'NAME' => do_lang_tempcode('_W_ROOM'), 'VALUE' => do_lang_tempcode('W_ROOM_COORD', escape_html($room), strval($row['location_realm']), array(strval($row['location_x']), strval($row['location_y']))))); $b = do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('_GUID' => '72c62771f7796d69d1f1a616c2591206', 'NAME' => do_lang_tempcode('_W_REALM'), 'VALUE' => $row['name'])); $a->attach($b); $OCWORLD_MEMBER_CACHE[$member_id] = $a; return $a; } return NULL; }
/** * Standard modular run function for symbol hooks. Searches for tasks to perform. * * @param array Symbol parameters * @return string Result */ function run($param) { require_code('points'); $member = isset($param[0]) ? intval($param[0]) : get_member(); $value = strval(total_points($member) - non_overrided__total_points($member)); return $value; }
/** * 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) { require_lang('activities'); require_code('activities'); list(, $whereville) = find_activities(get_member(), $_filters == '' ? 'all' : 'some_members', $_filters == '' ? NULL : array_map('intval', explode(',', $_filters))); $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'activities WHERE (' . $whereville . ') AND a_time>' . strval($cutoff) . ' ORDER BY a_time DESC', $max, 0); $content = new ocp_tempcode(); foreach ($rows as $row) { $id = strval($row['id']); $author = $GLOBALS['FORUM_DRIVER']->get_username($row['a_member_id']); if (is_null($author)) { $author = do_lang('UNKNOWN'); } $news_date = date($date_string, $row['a_time']); $edit_date = ''; list($_title, ) = render_activity($row); $news_title = xmlentities($_title->evaluate()); $summary = xmlentities(''); $news = ''; $category = ''; $category_raw = ''; $view_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $row['a_member_id']), get_module_zone('members'), NULL, false, false, true); $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))); } return array($content, do_lang('ACTIVITIES_TITLE')); }
/** * Standard modular run function for attachment hooks. They see if permission to an attachment of an ID relating to this content is present for the current member. * * @param ID_TEXT The ID * @param object The database connection to check on * @return boolean Whether there is permission */ function run($id, $connection) { if ($connection->connection_write != $GLOBALS['SITE_DB']->connection_write) { return false; } return has_category_access(get_member(), 'seedy_page', strval($id)); }
/** * 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(), 'polls')) { $rows = $GLOBALS['SITE_DB']->query('SELECT b.option1,b.option2,b.option3,b.option4,b.option5,b.option6,b.option7,b.option8,b.option9,b.option10,b.votes1,b.votes2,b.votes3,b.votes4,b.votes5,b.votes6,b.votes7,b.votes8,b.votes9,b.votes10,b.question,b.id,b.submitter AS member_id,a.date_and_time AS timestamp FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'poll a LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'poll b ON a.date_and_time>b.date_and_time WHERE NOT EXISTS(SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'poll x WHERE x.id<>a.id AND x.id<>b.id AND x.date_and_time BETWEEN b.date_and_time AND a.date_and_time) AND b.date_and_time IS NOT NULL AND b.date_and_time BETWEEN ' . strval($from) . ' AND ' . strval($to)); foreach ($rows as $row) { require_lang('polls'); $timestamp = $row['timestamp']; $member_id = $row['member_id']; $best = NULL; $best_num = -1; for ($i = 1; $i <= 10; $i++) { if ($row['votes' . strval($i)] > $best_num) { $best = $row['option' . strval($i)]; $best_num = $row['votes' . strval($i)]; } } if ($best_num == -1) { continue; } $ticker_text = do_lang('VOTES_ARE_IN', strip_comcode(get_translated_text($row['question'])), strip_comcode(get_translated_text($best))); $drops[] = rain_get_special_icons(NULL, $timestamp, NULL, $ticker_text) + array('TYPE' => 'polls', 'FROM_MEMBER_ID' => strval($member_id), 'TO_MEMBER_ID' => NULL, 'TITLE' => rain_truncate_for_title(get_translated_text($row['question'])), 'IMAGE' => find_theme_image('bigicons/polls'), 'TIMESTAMP' => strval($timestamp), 'RELATIVE_TIMESTAMP' => strval($timestamp - $from), 'TICKER_TEXT' => $ticker_text, 'URL' => build_url(array('page' => 'polls', 'type' => 'view', 'id' => $row[1]['id']), '_SEARCH'), 'IS_POSITIVE' => false, 'IS_NEGATIVE' => false, 'FROM_ID' => 'member_' . strval($member_id), 'TO_ID' => NULL, 'GROUP_ID' => 'poll_' . strval($row['id'])); } } return $drops; }
/** * Standard modular info function for award hooks. Provides information to allow task reporting, randomisation, and add-screen linking, to function. * * @return ?array Map of award content-type info (NULL: disabled). */ function info() { $info = array(); $info['connection'] = $GLOBALS['SITE_DB']; $info['table'] = 'videos'; $info['date_field'] = 'add_date'; $info['id_field'] = 'id'; $info['add_url'] = has_submit_permission('mid', get_member(), get_ip_address(), 'cms_galleries') ? build_url(array('page' => 'cms_galleries', 'type' => 'av'), get_module_zone('cms_galleries')) : new ocp_tempcode(); $info['category_field'] = 'cat'; $info['category_type'] = 'galleries'; $info['parent_spec__table_name'] = 'galleries'; $info['parent_spec__parent_name'] = 'parent_id'; $info['parent_spec__field_name'] = 'name'; $info['parent_field_name'] = 'cat'; $info['submitter_field'] = 'submitter'; $info['id_is_string'] = false; require_lang('galleries'); $info['title'] = do_lang_tempcode('VIDEOS'); $info['validated_field'] = 'validated'; $info['category_is_string'] = true; $info['archive_url'] = build_url(array('page' => 'galleries'), get_module_zone('galleries')); $info['cms_page'] = 'cms_galleries'; $info['where'] = 'cat NOT LIKE \'' . db_encode_like('download\\_%') . '\''; $info['views_field'] = 'video_views'; $info['supports_custom_fields'] = true; return $info; }
/** * Whether a certain member may give formal warnings to other members. * * @param ?MEMBER The member (NULL: current member). * @return boolean Answer. */ function ocf_may_warn_members($member_id = NULL) { if (is_null($member_id)) { $member_id = get_member(); } return has_specific_permission($member_id, 'warn_members'); }
/** * Standard modular info function for award hooks. Provides information to allow task reporting, randomisation, and add-screen linking, to function. * * @return ?array Map of award content-type info (NULL: disabled). */ function info() { $info = array(); $info['connection'] = $GLOBALS['SITE_DB']; $info['table'] = 'download_downloads'; $info['date_field'] = 'add_date'; $info['id_field'] = 'id'; $info['add_url'] = has_submit_permission('mid', get_member(), get_ip_address(), 'cms_downloads') ? build_url(array('page' => 'cms_downloads', 'type' => 'ad'), get_module_zone('cms_downloads')) : new ocp_tempcode(); $info['category_field'] = 'category_id'; $info['category_type'] = 'downloads'; $info['parent_spec__table_name'] = 'download_categories'; $info['parent_spec__parent_name'] = 'parent_id'; $info['parent_spec__field_name'] = 'id'; $info['parent_field_name'] = 'id'; $info['submitter_field'] = 'submitter'; $info['id_is_string'] = false; require_lang('downloads'); $info['title'] = do_lang_tempcode('SECTION_DOWNLOADS'); $info['validated_field'] = 'validated'; $info['category_is_string'] = false; $info['archive_url'] = build_url(array('page' => 'downloads'), get_module_zone('downloads')); $info['cms_page'] = 'cms_downloads'; $info['views_field'] = 'download_views'; $info['supports_custom_fields'] = true; return $info; }
/** * 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); }
function setUp() { parent::setUp(); require_code('ecommerce'); require_code('autosave'); require_code('shopping'); require_code('form_templates'); require_lang('ecommerce'); $this->access_mapping = array(db_get_first_id() => 4); // Creating cms catalogues object require_code('adminzone/pages/modules/admin_ecommerce.php'); $this->admin_ecom = new Module_admin_ecommerce(); /*require_code('adminzone/pages/modules/admin_shipping.php'); $this->admin_shipping = new Module_admin_shipping(); $this->admin_shipping->run_start('misc');*/ /*require_code('adminzone/pages/modules_custom/admin_credits.php'); $this->admin_credits = new Module_admin_credits();*/ require_code('adminzone/pages/modules/admin_orders.php'); $this->admin_orders = new Module_admin_orders(); $this->admin_orders->run(); $GLOBALS['SITE_DB']->query_insert('shopping_order', array('c_member' => get_member(), 'session_id' => get_session_id(), 'add_date' => time(), 'tot_price' => 0.0, 'order_status' => 'NEW', 'notes' => '', 'transaction_id' => 'ddfsfdsdfsdfs', 'purchase_through' => 'paypal', 'tax_opted_out' => 0)); /*require_code('adminzone/pages/modules/admin_permissions_products.php'); $this->admin_permission_products = new Module_admin_permissions_products(); $this->admin_permission_products->run();*/ }
/** * 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('galleries')) { return NULL; } if (!has_actual_page_access(get_member(), 'galleries')) { return NULL; } $filters_1 = ocfilter_to_sqlfragment($_filters, 'name', 'galleries', 'parent_id', 'name', 'name', false, false); // 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) $filters = ocfilter_to_sqlfragment($_filters, 'cat', 'galleries', 'parent_id', 'cat', 'name', false, false); // 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) require_lang('galleries'); $content = new ocp_tempcode(); $_galleries = array(); if ($GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'galleries WHERE ' . $filters_1) < 3000) { $_galleries = $GLOBALS['SITE_DB']->query('SELECT fullname,name FROM ' . get_table_prefix() . 'galleries WHERE ' . $filters_1); foreach ($_galleries as $i => $_gallery) { $_galleries[$i]['text_original'] = get_translated_text($_gallery['fullname']); } } $galleries = collapse_2d_complexity('name', 'text_original', $_galleries); $rows1 = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'videos WHERE add_date>' . strval((int) $cutoff) . ' AND ' . $filters . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' ORDER BY add_date DESC', $max); $rows2 = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'images WHERE add_date>' . strval((int) $cutoff) . ' AND ' . $filters . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' ORDER BY add_date DESC', $max); $rows = array_merge($rows1, $rows2); foreach ($rows as $row) { $id = strval($row['id']); $author = $GLOBALS['FORUM_DRIVER']->get_username($row['submitter']); if (is_null($author)) { $author = ''; } $news_date = date($date_string, $row['add_date']); $edit_date = is_null($row['edit_date']) ? '' : date($date_string, $row['edit_date']); $news_title = xmlentities(do_lang('THIS_WITH_SIMPLE', array_key_exists('video_views', $row) ? do_lang('VIDEO') : do_lang('IMAGE'), strval($row['id']))); $_summary = get_translated_tempcode($row['comments']); $summary = xmlentities($_summary->evaluate()); $news = ''; if (!array_key_exists($row['cat'], $galleries)) { $_fullname = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'fullname', array('name' => $row['cat'])); if (is_null($_fullname)) { continue; } $galleries[$row['cat']] = get_translated_text($_fullname); } $category = $galleries[$row['cat']]; $category_raw = $row['cat']; $view_url = build_url(array('page' => 'galleries', 'type' => array_key_exists('video_views', $row) ? 'video' : 'image', 'id' => $row['id']), get_module_zone('galleries'), NULL, false, false, true); if ($prefix == 'RSS_' && get_option('is_on_comments') == '1' && $row['allow_comments'] >= '1') { $if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => '65dc0cec8c75f565c58c95fa1667aa1e', 'COMMENT_URL' => $view_url, 'ID' => strval($row['id']))); } else { $if_comments = new ocp_tempcode(); } require_code('images'); $enclosure_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'galleries', array_key_exists('video_views', $row) ? 'videos' : 'images', $row['id']); list($enclosure_length, $enclosure_type) = get_enclosure_details($row['url'], $enclosure_url); $content->attach(do_template($prefix . 'ENTRY', array('ENCLOSURE_URL' => $enclosure_url, 'ENCLOSURE_LENGTH' => $enclosure_length, 'ENCLOSURE_TYPE' => $enclosure_type, '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('galleries'); return array($content, do_lang('GALLERIES')); }
/** * Standard modular info function for award hooks. Provides information to allow task reporting, randomisation, and add-screen linking, to function. * * @return ?array Map of award content-type info (NULL: disabled). */ function info() { $info = array(); $info['connection'] = $GLOBALS['SITE_DB']; $info['table'] = 'seedy_posts'; $info['date_field'] = 'date_and_time'; $info['id_field'] = 'id'; $info['add_url'] = has_submit_permission('low', get_member(), get_ip_address(), 'cedi') ? build_url(array('page' => 'cedi', 'type' => 'add_post'), get_module_zone('cedi')) : new ocp_tempcode(); $info['category_field'] = 'page_id'; $info['category_type'] = 'seedy_page'; $info['parent_spec__table_name'] = 'seedy_children'; $info['parent_spec__parent_name'] = 'parent_id'; $info['parent_spec__field_name'] = 'child_id'; $info['parent_field_name'] = 'page_id'; $info['submitter_field'] = 'the_user'; $info['id_is_string'] = false; require_lang('cedi'); $info['title'] = do_lang_tempcode('CEDI_POSTS'); $info['validated_field'] = 'validated'; $info['category_is_string'] = false; $info['archive_url'] = build_url(array('page' => 'cedi'), get_module_zone('cedi')); $info['cms_page'] = 'cedi'; $info['supports_custom_fields'] = true; return $info; }