Exemplo n.º 1
0
/**
 * A page is not validated, so show a warning.
 *
 * @param  ID_TEXT		The zone the page is being loaded from
 * @param  ID_TEXT		The codename of the page
 * @param  tempcode		The edit URL (blank if no edit access)
 * @return tempcode		The warning
 */
function get_page_warning_details($zone, $codename, $edit_url)
{
    $warning_details = new ocp_tempcode();
    if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) {
        access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated');
    }
    $uv_warning = do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT');
    // Wear sun cream
    if (!$edit_url->is_empty()) {
        $menu_links = $GLOBALS['SITE_DB']->query('SELECT DISTINCT i_menu FROM ' . get_table_prefix() . 'menu_items WHERE ' . db_string_equal_to('i_url', $zone . ':' . $codename) . ' OR ' . db_string_equal_to('i_url', '_SEARCH:' . $codename));
        if (count($menu_links) != 0) {
            $menu_items_linking = new ocp_tempcode();
            foreach ($menu_links as $menu_link) {
                if (!$menu_items_linking->is_empty()) {
                    $menu_items_linking->attach(do_lang_tempcode('LIST_SEP'));
                }
                $menu_edit_url = build_url(array('page' => 'admin_menus', 'type' => 'edit', 'id' => $menu_link['i_menu']), get_module_zone('admin_menus'));
                $menu_items_linking->attach(hyperlink($menu_edit_url, $menu_link['i_menu'], false, true));
            }
            $uv_warning = do_lang_tempcode('UNVALIDATED_TEXT_STAFF', $menu_items_linking);
        }
    }
    $warning_details->attach(do_template('WARNING_TABLE', array('WARNING' => $uv_warning)));
    return $warning_details;
}
 /**
  * Standard modular run function for CRON hooks. Searches for tasks to perform.
  */
 function run()
 {
     if (!addon_installed('catalogues')) {
         return;
     }
     if (function_exists('set_time_limit')) {
         @set_time_limit(0);
     }
     $catalogue_categories = $GLOBALS['SITE_DB']->query('SELECT id,cc_move_target,cc_move_days_lower,cc_move_days_higher FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'catalogue_categories WHERE cc_move_target IS NOT NULL');
     foreach ($catalogue_categories as $row) {
         $changed = false;
         $start = 0;
         do {
             $entries = $GLOBALS['SITE_DB']->query_select('catalogue_entries', array('id', 'ce_submitter', 'ce_last_moved'), array('cc_id' => $row['id']), '', 1000, $start);
             foreach ($entries as $entry) {
                 $higher = has_specific_permission($entry['ce_submitter'], 'high_catalogue_entry_timeout');
                 $time_diff = time() - $entry['ce_last_moved'];
                 $move_days = $higher ? $row['cc_move_days_higher'] : $row['cc_move_days_lower'];
                 if ($time_diff / (60 * 60 * 24) > $move_days) {
                     $GLOBALS['SITE_DB']->query_update('catalogue_entries', array('ce_last_moved' => time(), 'cc_id' => $row['cc_move_target']), array('id' => $entry['id']), '', 1);
                     $changed = true;
                 }
             }
             $start += 1000;
         } while (count($entries) == 1000);
         if ($changed) {
             require_code('catalogues2');
             calculate_category_child_count_cache($row['cc_move_target']);
             calculate_category_child_count_cache($row['id']);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Get a URL to a forum member's member profile.
  *
  * @param  MEMBER			The forum member
  * @param  boolean		Whether to be insistent that we go to the profile, rather than possibly starting an IM which can link to the profile
  * @param  boolean		Whether it is okay to return the result using Tempcode (more efficient, and allows keep_* parameters to propagate which you almost certainly want!)
  * @return mixed			The URL
  */
 function member_profile_url($id, $definitely_profile = false, $tempcode_okay = false)
 {
     $url = mixed();
     if (!$definitely_profile && $id != $this->get_guest_id() && addon_installed('chat') && has_specific_permission(get_member(), 'start_im')) {
         $username_click_im = get_option('username_click_im', true);
         if ($username_click_im == '1') {
             $url = build_url(array('page' => 'chat', 'type' => 'misc', 'enter_im' => $id), get_module_zone('chat'));
             if (!$tempcode_okay) {
                 $url = $url->evaluate();
             }
             return $url;
         }
     }
     $url = $this->_member_profile_url($id, $tempcode_okay);
     if ($tempcode_okay && !is_object($url)) {
         $url = make_string_tempcode($url);
     }
     if (get_forum_type() != 'none' && get_forum_type() != 'ocf' && get_option('forum_in_portal', true) == '1') {
         $url = build_url(array('page' => 'forums', 'url' => $url), get_module_zone('forums'));
         if (!$tempcode_okay) {
             $url = $url->evaluate();
         }
     }
     return $url;
 }
Exemplo n.º 4
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;
 }
 /**
  * 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));
 }
Exemplo n.º 6
0
 /**
  * Standard actualisation stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action_done()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     if (get_option('is_on_' . $class . '_buy') == '0' || get_forum_type() != 'ocf') {
         return new ocp_tempcode();
     }
     if ($GLOBALS['FORUM_DRIVER']->get_member_row_field(get_member(), 'm_highlighted_name') == 1) {
         warn_exit(do_lang_tempcode('_ALREADY_HAVE'));
     }
     $title = get_page_title('NAME_HIGHLIGHTING');
     post_param_integer('confirm');
     // To make sure we're not being passed by a GET
     // Check points
     $cost = intval(get_option($class));
     $points_left = available_points(get_member());
     if ($points_left < $cost && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left)));
     }
     // Actuate
     $GLOBALS['FORUM_DB']->query_update('f_members', array('m_highlighted_name' => 1), array('id' => get_member()), '', 1);
     require_code('points2');
     charge_member(get_member(), $cost, do_lang('NAME_HIGHLIGHTING'));
     $GLOBALS['SITE_DB']->query_insert('sales', array('date_and_time' => time(), 'memberid' => get_member(), 'purchasetype' => 'NAME_HIGHLIGHTING', 'details' => '', 'details2' => ''));
     // Show message
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('ORDER_GENERAL_DONE'));
 }
Exemplo n.º 7
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('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'));
 }
Exemplo n.º 8
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @param  boolean		Whether to look deep into the database (or whatever else might be time-intensive) for links
  * @return array			Array of links and where to show
  */
 function run($exhaustive = false)
 {
     if (!addon_installed('catalogues')) {
         return array();
     }
     $ret = array();
     if (has_specific_permission(get_member(), 'submit_cat_highrange_content', 'cms_catalogues')) {
         $ret[] = array('cms', 'catalogues', array('cms_catalogues', array('type' => 'misc'), get_module_zone('cms_catalogues')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('CATALOGUES'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'COUNT(*)', NULL, '', true))))), 'DOC_CATALOGUES');
     }
     if ($exhaustive) {
         $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('c_name', 'c_title', 'c_description', 'c_ecommerce'), NULL, '', 10, NULL, true);
         if (!is_null($catalogues)) {
             $ret2 = array();
             foreach ($catalogues as $row) {
                 if (substr($row['c_name'], 0, 1) == '_') {
                     continue;
                 }
                 if ($row['c_ecommerce'] == 0 || addon_installed('shopping')) {
                     if (has_submit_permission('mid', get_member(), get_ip_address(), 'cms_catalogues', array('catalogues_catalogue', $row['c_name']))) {
                         $ret2[] = array('cms', 'of_catalogues', array('cms_catalogues', array('type' => 'misc', 'catalogue_name' => $row['c_name']), get_module_zone('cms_catalogues')), do_lang_tempcode('ITEMS_HERE', escape_html(get_translated_text($row['c_title'])), escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('catalogue_entries', 'COUNT(*)', array('c_name' => $row['c_name']), '', true)))), get_translated_text($row['c_description']));
                     }
                 }
             }
             if (count($ret2) < 10) {
                 $ret = array_merge($ret, $ret2);
             }
         }
     }
     return $ret;
 }
Exemplo n.º 9
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('news')) {
         return NULL;
     }
     if (!has_actual_page_access(get_member(), 'news')) {
         return NULL;
     }
     $filters_1 = ocfilter_to_sqlfragment($_filters, 'p.news_category', 'news_categories', NULL, 'p.news_category', 'id');
     // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set)
     $filters_2 = ocfilter_to_sqlfragment($_filters, 'd.news_entry_category', 'news_categories', NULL, 'd.news_category', 'id');
     // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set)
     $filters = '(' . $filters_1 . ' OR ' . $filters_2 . ')';
     $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news p LEFT JOIN ' . get_table_prefix() . 'news_category_entries d ON d.news_entry=p.id WHERE date_and_time>' . strval($cutoff) . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' AND ' . $filters . (can_arbitrary_groupby() ? ' GROUP BY p.id' : '') . ' ORDER BY date_and_time DESC', $max);
     $rows = remove_duplicate_rows($rows, 'id');
     $_categories = $GLOBALS['SITE_DB']->query_select('news_categories', array('id', 'nc_title'), array('nc_owner' => NULL));
     foreach ($_categories as $i => $_category) {
         $_categories[$i]['text_original'] = get_translated_text($_category['nc_title']);
     }
     $categories = collapse_2d_complexity('id', 'text_original', $_categories);
     $content = new ocp_tempcode();
     foreach ($rows as $row) {
         if (has_category_access(get_member(), 'news', strval($row['news_category']))) {
             $id = strval($row['id']);
             $author = $row['author'];
             $news_date = date($date_string, $row['date_and_time']);
             $edit_date = is_null($row['edit_date']) ? '' : date($date_string, $row['edit_date']);
             $_title = get_translated_tempcode($row['title']);
             $news_title = xmlentities($_title->evaluate());
             $_summary = get_translated_tempcode($row['news']);
             if ($_summary->is_empty()) {
                 $_summary = get_translated_tempcode($row['news_article']);
             }
             $summary = xmlentities($_summary->evaluate());
             if (!is_null($row['news_article'])) {
                 $_news = get_translated_tempcode($row['news_article']);
                 if ($_news->is_empty()) {
                     $news = '';
                 } else {
                     $news = xmlentities($_news->evaluate());
                 }
             } else {
                 $news = '';
             }
             if (!array_key_exists($row['news_category'], $categories)) {
                 $categories[$row['news_category']] = get_translated_text($GLOBALS['SITE_DB']->query_value('news_categories', 'nc_title', array('id' => $row['news_category'])));
             }
             $category = $categories[$row['news_category']];
             $category_raw = strval($row['news_category']);
             $view_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), get_module_zone('news'), 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' => 'b4f25f5cf68304f8d402bb06851489d6', 'COMMENT_URL' => $view_url, 'ID' => strval($row['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)));
         }
     }
     return array($content, do_lang('NEWS'));
 }
Exemplo n.º 10
0
 /**
  * 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);
 }
Exemplo n.º 11
0
/**
 * Add a forum poll.
 *
 * @param  AUTO_LINK		The ID of the topic to add the poll to.
 * @param  SHORT_TEXT	The question.
 * @param  BINARY			Whether the result tallies are kept private until the poll is made non-private.
 * @param  BINARY			Whether the poll is open for voting.
 * @param  integer		The minimum number of selections that may be made.
 * @param  integer		The maximum number of selections that may be made.
 * @param  BINARY			Whether members must have a post in the topic before they made vote.
 * @param  array			A list of pairs of the potential voteable answers and the number of votes.
 * @param  boolean		Whether to check there are permissions to make the poll.
 * @return AUTO_LINK 	The ID of the newly created forum poll.
 */
function ocf_make_poll($topic_id, $question, $is_private, $is_open, $minimum_selections, $maximum_selections, $requires_reply, $answers, $check_permissions = true)
{
    require_code('ocf_polls');
    if ($check_permissions && !ocf_may_attach_poll($topic_id)) {
        access_denied('I_ERROR');
    }
    $poll_id = $GLOBALS['FORUM_DB']->query_insert('f_polls', array('po_question' => $question, 'po_cache_total_votes' => 0, 'po_is_private' => $is_private, 'po_is_open' => $is_open, 'po_minimum_selections' => $minimum_selections, 'po_maximum_selections' => $maximum_selections, 'po_requires_reply' => $requires_reply), true);
    foreach ($answers as $answer) {
        if (is_array($answer)) {
            list($answer, $num_votes) = $answer;
        } else {
            $num_votes = 0;
        }
        $GLOBALS['FORUM_DB']->query_insert('f_poll_answers', array('pa_poll_id' => $poll_id, 'pa_answer' => $answer, 'pa_cache_num_votes' => $num_votes));
    }
    $map = array('t_poll_id' => $poll_id);
    // Now make the topic validated if this is attaching immediately
    if (get_param_integer('re_validate', 0) == 1) {
        $forum_id = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_forum_id', array('id' => $topic_id));
        if (is_null($forum_id) || has_specific_permission(get_member(), 'bypass_validation_midrange_content', 'topics', array('forums', $forum_id))) {
            $map['t_validated'] = 1;
        }
    }
    $GLOBALS['FORUM_DB']->query_update('f_topics', $map, array('id' => $topic_id), '', 1);
    return $poll_id;
}
Exemplo n.º 12
0
/**
 * 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');
}
Exemplo n.º 13
0
/**
 * Get a do-next manager for bookings.
 *
 * @return tempcode	Booking do-next manager.
 */
function booking_do_next()
{
    require_lang('calendar');
    require_code('templates_donext');
    require_code('fields');
    return do_next_manager(get_page_title('BOOKINGS'), comcode_lang_string('DOC_BOOKING'), array(has_specific_permission(get_member(), 'submit_cat_highrange_content', 'cms_booking') ? array('bookable', array('_SELF', array('type' => 'ad'), '_SELF'), do_lang('ADD_BOOKABLE')) : NULL, has_specific_permission(get_member(), 'edit_cat_highrange_content', 'cms_booking') ? array('bookable', array('_SELF', array('type' => 'ed'), '_SELF'), do_lang('EDIT_BOOKABLE')) : NULL, has_specific_permission(get_member(), 'submit_cat_highrange_content', 'cms_booking') ? array('supplement', array('_SELF', array('type' => 'av'), '_SELF'), do_lang('ADD_BOOKABLE_SUPPLEMENT')) : NULL, has_specific_permission(get_member(), 'edit_cat_highrange_content', 'cms_booking') ? array('supplement', array('_SELF', array('type' => 'ev'), '_SELF'), do_lang('EDIT_BOOKABLE_SUPPLEMENT')) : NULL, has_specific_permission(get_member(), 'submit_cat_highrange_content', 'cms_booking') ? array('blacked', array('_SELF', array('type' => 'ac'), '_SELF'), do_lang('ADD_BOOKABLE_BLACKED')) : NULL, has_specific_permission(get_member(), 'edit_cat_highrange_content', 'cms_booking') ? array('blacked', array('_SELF', array('type' => 'ec'), '_SELF'), do_lang('EDIT_BOOKABLE_BLACKED')) : NULL, has_specific_permission(get_member(), 'submit_highrange_content', 'cms_booking') ? array('booking', array('_SELF', array('type' => 'ab'), '_SELF'), do_lang('ADD_BOOKING')) : NULL, has_specific_permission(get_member(), 'edit_highrange_content', 'cms_booking') ? array('booking', array('_SELF', array('type' => 'eb'), '_SELF'), do_lang('EDIT_BOOKING')) : NULL, has_actual_page_access(get_member(), 'calendar') ? array('calendar', array('calendar', array('type' => 'misc', 'view' => 'month'), '_SEARCH'), do_lang('CALENDAR')) : NULL), do_lang('BOOKINGS'));
}
Exemplo n.º 14
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 (!has_actual_page_access(get_member(), 'members')) {
         return NULL;
     }
     $rows = $GLOBALS['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'f_members p WHERE m_join_time>' . strval($cutoff) . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND m_validated=1 AND m_validated_email_confirm_code=\'\' ' : '') . ' ORDER BY m_join_time DESC', $max);
     $categories = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true);
     $content = new ocp_tempcode();
     foreach ($rows as $row) {
         $id = strval($row['id']);
         $author = '';
         $news_date = date($date_string, $row['m_join_time']);
         $edit_date = '';
         $news_title = xmlentities($row['m_username']);
         $summary = '';
         $news = '';
         $category = array_key_exists($row['m_primary_group'], $categories) ? $categories[$row['m_primary_group']] : '';
         $category_raw = strval($row['m_primary_group']);
         $view_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $row['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)));
     }
     require_lang('ocf');
     return array($content, do_lang('MEMBERS'));
 }
Exemplo n.º 15
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     require_code('templates_donext');
     require_code('menus');
     require_all_lang();
     if ((!has_specific_permission(get_member(), 'avoid_simplified_adminzone_look') || $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) && num_staff_icons() < MIN_STAFF_ICONS_BEFORE_COLLAPSE) {
         return do_next_manager_admin_simplified();
     }
     return do_next_manager_hooked('CMS_ZONE', 'DOC_CMS', 'cms', 'MODULE_TRANS_NAME_cms');
 }
Exemplo n.º 16
0
 /**
  * Get syndication field UI.
  *
  * @return tempcode		Syndication fields (or empty)
  */
 function get_syndication_option_fields()
 {
     $fields = new ocp_tempcode();
     if (has_specific_permission(get_member(), 'syndicate_site_activity') && has_external_site_wide_syndication()) {
         require_lang('activities');
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SYNDICATION'))));
         $fields->attach(form_input_tick(do_lang_tempcode('SYNDICATE_THIS'), do_lang_tempcode('DESCRIPTION_SYNDICATE_THIS'), 'syndicate_this', true));
     }
     return $fields;
 }
Exemplo n.º 17
0
 /**
  * Standard actualisation stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action_done()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     if (get_option('is_on_' . $class . '_buy') == '0') {
         return new ocp_tempcode();
     }
     $amount = post_param_integer('amount', -1);
     $title = get_page_title('GAMBLING');
     // Check points
     $cost = intval(get_option('minimum_gamble_amount'));
     $points_left = available_points(get_member());
     $max = min(intval(get_option('maximum_gamble_amount')), $points_left);
     if (!has_specific_permission(get_member(), 'give_points_self') || $amount < 0) {
         if ($amount < $cost || $amount > $max) {
             warn_exit(do_lang_tempcode('INVALID_GAMBLE_AMOUNT'));
         }
         if ($points_left < $amount) {
             return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left)));
         }
     }
     // Calculate
     $average_gamble_multiplier = floatval(get_option('average_gamble_multiplier')) / 100.0;
     $maximum_gamble_multiplier = floatval(get_option('maximum_gamble_multiplier')) / 100.0;
     $above_average = mt_rand(0, 10) < 5;
     if ($above_average) {
         //			$winnings=round($average_gamble_multiplier*$amount+mt_rand(0,round($maximum_gamble_multiplier*$amount-$average_gamble_multiplier*$amount)));	  Even distribution is NOT wise
         $peak = $maximum_gamble_multiplier * $amount;
         $under = 0.0;
         $number = intval(round($average_gamble_multiplier * $amount + mt_rand(0, intval(round($maximum_gamble_multiplier * $amount - $average_gamble_multiplier * $amount)))));
         for ($x = 1; $x < intval($peak); $x++) {
             $p = $peak * (1.0 / pow(floatval($x) + 0.4, 2.0) - 1.0 / pow($maximum_gamble_multiplier * floatval($amount), 2.0));
             // Using a 1/x^2 curve. 0.4 is a bit of a magic number to get the averaging right
             $under += $p;
             if ($under > floatval($number)) {
                 break;
             }
         }
         $winnings = intval(round($average_gamble_multiplier * $amount + $x * 1.1));
         // 1.1 is a magic number to make it seem a bit fairer
     } else {
         $winnings = mt_rand(0, intval(round($average_gamble_multiplier * $amount)));
     }
     // Actuate
     require_code('points2');
     charge_member(get_member(), $amount - $winnings, do_lang('GAMBLING'));
     $GLOBALS['SITE_DB']->query_insert('sales', array('date_and_time' => time(), 'memberid' => get_member(), 'purchasetype' => 'GAMBLING', 'details' => strval($amount), 'details2' => ''));
     // Show message
     if ($winnings > $amount) {
         $result = do_lang_tempcode('GAMBLE_CONGRATULATIONS', integer_format($winnings - $amount), integer_format($amount));
     } else {
         $result = do_lang_tempcode('GAMBLE_COMMISERATIONS', integer_format($amount - $winnings), integer_format($amount));
     }
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, $result);
 }
Exemplo n.º 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)
 {
     if (!has_actual_page_access(get_member(), 'classifieds', get_module_zone('classifieds'))) {
         return array();
     }
     require_lang('classifieds');
     $result = array();
     if ($member_id == get_member() || has_specific_permission(get_member(), 'assume_any_member')) {
         $result[] = array('content', do_lang('CLASSIFIED_ADVERTS'), build_url(array('page' => 'classifieds', 'type' => 'adverts', 'member_id' => $member_id), get_module_zone('classifieds')));
     }
     return $result;
 }
Exemplo n.º 19
0
/**
 * Add a topic.
 *
 * @param  ?AUTO_LINK	The ID of the forum the topic will be in (NULL: Private Topic).
 * @param  SHORT_TEXT	Description of the topic.
 * @param  SHORT_TEXT	The theme image code of the emoticon for the topic.
 * @param  ?BINARY		Whether the topic is validated (NULL: detect whether it should be).
 * @param  BINARY			Whether the topic is open.
 * @param  BINARY			Whether the topic is pinned.
 * @param  BINARY			Whether the topic is sunk.
 * @param  BINARY			Whether the topic is cascading.
 * @param  ?MEMBER		If it is a Private Topic, who is it 'from' (NULL: not a Private Topic).
 * @param  ?MEMBER		If it is a Private Topic, who is it 'to' (NULL: not a Private Topic).
 * @param  boolean		Whether to check the poster has permissions for the given topic settings.
 * @param  integer		The number of times the topic has been viewed.
 * @param  ?AUTO_LINK	Force an ID (NULL: don't force an ID)
 * @param  SHORT_TEXT	Link related to the topic (e.g. link to view a ticket).
 * @return AUTO_LINK		The ID of the newly created topic.
 */
function ocf_make_topic($forum_id, $description = '', $emoticon = '', $validated = NULL, $open = 1, $pinned = 0, $sunk = 0, $cascading = 0, $pt_from = NULL, $pt_to = NULL, $check_perms = true, $num_views = 0, $id = NULL, $description_link = '')
{
    if (is_null($pinned)) {
        $pinned = 0;
    }
    if (is_null($sunk)) {
        $sunk = 0;
    }
    if (is_null($description)) {
        $description = '';
    }
    if (is_null($num_views)) {
        $num_views = 0;
    }
    if ($check_perms) {
        require_code('ocf_topics');
        if (!ocf_may_post_topic($forum_id, get_member())) {
            access_denied('I_ERROR');
        }
        if (!is_null($pt_to)) {
            decache('side_ocf_personal_topics', array($pt_to));
            decache('_new_pp', array($pt_to));
        }
        if (!is_null($forum_id)) {
            require_code('ocf_posts_action');
            ocf_decache_ocp_blocks($forum_id);
        }
        require_code('ocf_forums');
        if (!ocf_may_moderate_forum($forum_id)) {
            $pinned = 0;
            $sunk = 0;
            $open = 1;
            $cascading = 0;
        }
    }
    if (is_null($validated) || $check_perms && $validated == 1) {
        if (!is_null($forum_id) && !has_specific_permission(get_member(), 'bypass_validation_midrange_content', 'topics', array('forums', $forum_id))) {
            $validated = 0;
        } else {
            $validated = 1;
        }
    }
    if (!addon_installed('unvalidated')) {
        $validated = 1;
    }
    $map = array('t_pinned' => $pinned, 't_sunk' => $sunk, 't_cascading' => $cascading, 't_forum_id' => $forum_id, 't_pt_from' => $pt_from, 't_pt_to' => $pt_to, 't_description' => substr($description, 0, 255), 't_description_link' => substr($description_link, 0, 255), 't_emoticon' => $emoticon, 't_num_views' => $num_views, 't_validated' => $validated, 't_is_open' => $open, 't_poll_id' => NULL, 't_cache_first_post_id' => NULL, 't_cache_first_post' => NULL, 't_cache_first_time' => NULL, 't_cache_first_title' => '', 't_cache_first_username' => '', 't_cache_first_member_id' => NULL, 't_cache_last_post_id' => NULL, 't_cache_last_time' => NULL, 't_cache_last_title' => '', 't_cache_last_username' => '', 't_cache_last_member_id' => NULL, 't_cache_num_posts' => 0, 't_pt_from_category' => '', 't_pt_to_category' => '');
    if (!is_null($id)) {
        $map['id'] = $id;
    }
    return $GLOBALS['FORUM_DB']->query_insert('f_topics', $map, true);
}
Exemplo n.º 20
0
/**
 * Get extra do-next icon for managing custom fields for a content type.
 *
 * @param  ID_TEXT		Award hook codename
 * @return array			Extra do-next icon (single item array, or empty array if catalogues not installed)
 */
function manage_custom_fields_donext_link($content_type)
{
    if (addon_installed('catalogues')) {
        require_lang('fields');
        require_code('hooks/systems/awards/' . $content_type);
        $ob = object_factory('Hook_awards_' . $content_type);
        $info = $ob->info();
        if (array_key_exists('supports_custom_fields', $info) && $info['supports_custom_fields'] && has_specific_permission(get_member(), 'submit_cat_highrange_content', 'cms_catalogues') && has_specific_permission(get_member(), 'edit_cat_highrange_content', 'cms_catalogues')) {
            $exists = !is_null($GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => '_' . $content_type)));
            return array(array('edit_one_catalogue', array('cms_catalogues', array('type' => $exists ? '_edit_catalogue' : 'add_catalogue', 'id' => '_' . $content_type, 'redirect' => get_self_url(true)), get_module_zone('cms_catalogues')), do_lang('EDIT_CUSTOM_FIELDS', $info['title'])));
        }
    }
    return array();
}
Exemplo n.º 21
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('calendar')) {
         return array();
     }
     if (!has_specific_permission(get_member(), 'assume_any_member')) {
         return array();
     }
     if (!has_actual_page_access(get_member(), 'calendar', get_module_zone('calendar'))) {
         return array();
     }
     require_lang('calendar');
     return array(array('views', do_lang_tempcode('CALENDAR'), build_url(array('page' => 'calendar', 'type' => 'misc', 'member_id' => $member_id), get_module_zone('calendar'))));
 }
Exemplo n.º 22
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'));
 }
Exemplo n.º 23
0
/**
 * @license		http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
 * @copyright	ocProducts Ltd
 * @package		activity_feed
 */
function activities_addon_syndicate_described_activity($a_language_string_code = '', $a_label_1 = '', $a_label_2 = '', $a_label_3 = '', $a_pagelink_1 = '', $a_pagelink_2 = '', $a_pagelink_3 = '', $a_addon = '', $a_is_public = 1, $a_member_id = NULL, $sitewide_too = false, $a_also_involving = NULL)
{
    require_code('activities');
    require_lang('activities');
    if (get_db_type() == 'xml' && get_param_integer('keep_testing_logging', 0) != 1) {
        return NULL;
    }
    $stored_id = 0;
    if (is_null($a_member_id)) {
        $a_member_id = get_member();
    }
    if (is_guest($a_member_id)) {
        return NULL;
    }
    $go = array('a_language_string_code' => $a_language_string_code, 'a_label_1' => $a_label_1, 'a_label_2' => $a_label_2, 'a_label_3' => $a_label_3, 'a_is_public' => $a_is_public);
    $stored_id = mixed();
    // Check if this has been posted previously (within the last 10 minutes) to
    // stop spamming but allow generalised repeat status messages.
    $test = $GLOBALS['SITE_DB']->query_select('activities', array('a_language_string_code', 'a_label_1', 'a_label_2', 'a_label_3', 'a_is_public'), NULL, 'WHERE a_time>' . strval(time() - 600), 1);
    if (!array_key_exists(0, $test) || $test[0] != $go || running_script('execute_temp')) {
        // Log the activity
        $row = $go + array('a_member_id' => $a_member_id, 'a_also_involving' => $a_also_involving, 'a_pagelink_1' => $a_pagelink_1, 'a_pagelink_2' => $a_pagelink_2, 'a_pagelink_3' => $a_pagelink_3, 'a_time' => time(), 'a_addon' => $a_addon, 'a_is_public' => $a_is_public);
        $stored_id = $GLOBALS['SITE_DB']->query_insert('activities', $row, true);
        // Update the latest activity file
        log_newest_activity($stored_id, 1000);
        // External places
        if ($a_is_public == 1 && !$GLOBALS['IS_ACTUALLY_ADMIN']) {
            $dests = find_all_hooks('systems', 'syndication');
            foreach (array_keys($dests) as $hook) {
                require_code('hooks/systems/syndication/' . $hook);
                $ob = object_factory('Hook_Syndication_' . $hook);
                if ($ob->is_available()) {
                    $ob->syndicate_user_activity($a_member_id, $row);
                    if ($sitewide_too && has_specific_permission(get_member(), 'syndicate_site_activity') && post_param_integer('syndicate_this', 0) == 1) {
                        $ob->syndicate_site_activity($row);
                    }
                }
            }
        }
        list($message) = render_activity($row, false);
        require_code('notifications');
        $username = $GLOBALS['FORUM_DRIVER']->get_username($a_member_id);
        $subject = do_lang('ACTIVITY_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $username, html_entity_decode(strip_tags($message->evaluate()), ENT_QUOTES, get_charset()));
        $mail = do_lang('ACTIVITY_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($username), array('[semihtml]' . $message->evaluate() . '[/semihtml]'));
        dispatch_notification('activity', strval($a_member_id), $subject, $mail);
    }
    return $stored_id;
}
Exemplo n.º 24
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;
 }
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     $page = array_key_exists('param', $map) && $map['param'] != '' ? $map['param'] : get_page_name();
     $zone = array_key_exists('zone', $map) ? $map['zone'] : post_param('zone', get_comcode_zone($page, false));
     if ($zone == '_SEARCH') {
         $zone = NULL;
     }
     $qmap = array('p_parent_page' => $page);
     if (!is_null($zone)) {
         $qmap['the_zone'] = $zone;
     }
     if (!has_specific_permission(get_member(), 'see_unvalidated')) {
         $qmap['p_validated'] = 1;
     }
     $children = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('the_page', 'the_zone'), $qmap);
     foreach ($children as $i => $child) {
         $_title = $GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages', 'cc_page_title', array('the_page' => $child['the_page'], 'the_zone' => $child['the_zone']));
         if (!is_null($_title)) {
             $title = get_translated_text($_title, NULL, NULL, true);
             if (is_null($title)) {
                 $title = '';
             }
         } else {
             $title = '';
             if (get_option('is_on_comcode_page_cache') == '1') {
                 request_page($child['the_page'], false, $child['the_zone'], NULL, true);
                 $_title = $GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages', 'cc_page_title', array('the_page' => $child['the_page'], 'the_zone' => $child['the_zone']));
                 if (!is_null($_title)) {
                     $title = get_translated_text($_title);
                 }
             }
         }
         if ($title == '') {
             $title = escape_html(ucwords(str_replace('_', ' ', $child['the_page'])));
         }
         $child['TITLE'] = $title;
         $child['PAGE'] = $child['the_page'];
         $child['ZONE'] = $child['the_zone'];
         $children[$i] = $child;
     }
     $GLOBALS['M_SORT_KEY'] = 'TITLE';
     usort($children, 'multi_sort');
     return do_template('BLOCK_MAIN_COMCODE_PAGE_CHILDREN', array('_GUID' => '375aa1907fc6b2ca6b23ab5b5139aaef', 'CHILDREN' => $children, 'THE_PAGE' => $page, 'THE_ZONE' => $zone));
 }
Exemplo n.º 26
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, 't_forum_id', 'f_forums', 'f_parent_forum', 't_forum_id', 'id', true, true, $GLOBALS['FORUM_DB']);
     // 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['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE t_cache_last_time>' . strval($cutoff) . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND t_validated=1 ' : '') . ' AND ' . $filters . ' ORDER BY t_cache_last_time DESC', $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['id']), get_module_zone('forumview'), NULL, false, false, true);
             if ($prefix == 'RSS_') {
                 $if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => 'f5dd7ba612b989bba5e2d496da5bf161', 'COMMENT_URL' => $view_url, 'ID' => strval($row['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('SECTION_FORUMS'));
 }
Exemplo n.º 27
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 (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'));
 }
Exemplo n.º 28
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     require_code('templates_donext');
     require_code('menus');
     require_all_lang();
     $type = get_param('type', 'misc');
     if ((!has_specific_permission(get_member(), 'avoid_simplified_adminzone_look') || $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) && num_staff_icons() < MIN_STAFF_ICONS_BEFORE_COLLAPSE) {
         if ($type == 'misc') {
             return do_next_manager_admin_simplified();
         }
     }
     // Warning about whether the Setup Wizard still needs running
     if (get_param_integer('cancel_sw_warn', 0) == 1 || !addon_installed('setupwizard')) {
         set_value('setup_wizard_completed', '1');
     } else {
         $_done_sw_once = get_value('setup_wizard_completed');
         $done_sw_once = !is_null($_done_sw_once);
         if (!$done_sw_once && get_param('page', '') != 'admin_setupwizard' && has_actual_page_access(get_member(), 'admin_setupwizard')) {
             $setup_wizard_url = build_url(array('page' => 'admin_setupwizard'), get_module_zone('admin_setupwizard'));
             $cancel_sw_url = get_self_url(false, false, array('cancel_sw_warn' => 1));
             attach_message(do_lang_tempcode('SETUP_WIZARD_NOT_RUN', escape_html($setup_wizard_url->evaluate()), escape_html($cancel_sw_url->evaluate())), 'notice');
         }
     }
     switch ($type) {
         case 'misc':
             return do_next_manager_hooked('ADMIN_ZONE', 'DOC_ADMIN_ZONE', '');
         case 'structure':
             return do_next_manager_hooked('STRUCTURE', 'DOC_STRUCTURE', 'structure');
         case 'usage':
             return do_next_manager_hooked('USAGE', 'DOC_USAGE', 'usage');
         case 'style':
             return do_next_manager_hooked('STYLE', 'DOC_STYLE', 'style');
         case 'setup':
             return do_next_manager_hooked('SETUP', 'DOC_SETUP', 'setup');
         case 'tools':
             return do_next_manager_hooked('TOOLS', 'DOC_TOOLS', 'tools');
         case 'security':
             return do_next_manager_hooked('SECURITY', 'DOC_SECURITY', 'security');
         case 'search':
             return $this->search();
     }
     return new ocp_tempcode();
 }
Exemplo n.º 29
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)
 {
     return $member_id_of == $member_id_viewing || has_specific_permission($member_id_viewing, 'assume_any_member') || has_specific_permission($member_id_viewing, 'member_maintenance');
 }
Exemplo n.º 30
0
/**
 * Invite a member to a PT.
 *
 * @param  MEMBER			Member getting access
 * @param  AUTO_LINK		The topic
 */
function ocf_invite_to_pt($member_id, $topic_id)
{
    $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'));
    }
    if ($topic_info[0]['t_pt_from'] != get_member() && $topic_info[0]['t_pt_to'] != get_member() && !has_specific_permission(get_member(), 'view_other_pt')) {
        warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
    }
    if ($topic_info[0]['t_pt_from'] == $member_id || $topic_info[0]['t_pt_to'] == $member_id) {
        warn_exit(do_lang_tempcode('NO_INVITE_SENSE'));
    }
    $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_special_pt_access', 's_member_id', array('s_member_id' => $member_id, 's_topic_id' => $topic_id));
    if (!is_null($test)) {
        warn_exit(do_lang_tempcode('NO_INVITE_SENSE_ALREADY'));
    }
    $GLOBALS['FORUM_DB']->query_insert('f_special_pt_access', array('s_member_id' => $member_id, 's_topic_id' => $topic_id));
    $current_username = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
    $_topic_url = build_url(array('page' => 'topicview', 'type' => 'view', 'id' => $topic_id), get_module_zone('topicview'), NULL, false, false, true);
    $topic_url = $_topic_url->evaluate();
    $topic_title = $topic_info[0]['t_cache_first_title'];
    require_code('ocf_posts_action');
    $post = do_lang('INVITED_TO_PT', $GLOBALS['FORUM_DRIVER']->get_username($member_id), $current_username);
    ocf_make_post($topic_id, '', $post, 0, false, 1, 1, do_lang('SYSTEM'), NULL, NULL, db_get_first_id(), NULL, NULL, NULL, false);
    require_code('notifications');
    $subject = do_lang('INVITED_TO_TOPIC_SUBJECT', get_site_name(), $topic_title, get_lang($member_id));
    $mail = do_lang('INVITED_TO_TOPIC_BODY', get_site_name(), comcode_escape($topic_title), array(comcode_escape($current_username), $topic_url), get_lang($member_id));
    dispatch_notification('ocf_topic_invite', NULL, $subject, $mail, array($member_id));
}