Example #1
0
 /**
  * Standard modular run function for award hooks. Renders a content box for an award/randomisation.
  *
  * @param  array		The database row for the content
  * @param  ID_TEXT	The zone to display in
  * @return tempcode	Results
  */
 function run($row, $zone)
 {
     unset($zone);
     require_code('ocf_posts2');
     require_code('ocf_forums');
     return ocf_show_isolated_post($row);
 }
Example #2
0
 /**
  * Standard modular run function for rendering a search result.
  *
  * @param  array		The data row stored when we retrieved the result
  * @return tempcode	The output
  */
 function render($row)
 {
     require_code('ocf_posts2');
     return ocf_show_isolated_post($row);
 }
Example #3
0
 /**
  * The UI to make a post.
  *
  * @return tempcode		The UI
  */
 function new_post()
 {
     require_code('ocf_posts2');
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'quote';
     $NON_CANONICAL_PARAMS[] = 'intended_solely_for';
     $topic_id = get_param_integer('id');
     $parent_id = either_param_integer('parent_id', NULL);
     $intended_solely_for = get_param_integer('intended_solely_for', -1);
     $post = post_param('post', NULL);
     // Copy existing post into box (from quick reply 'more options' button)
     if (is_null($post)) {
         $quotes = array();
         $quote = get_param_integer('quote', -1);
         if ($quote == -1) {
             $quotes = $this->get_markers();
         } else {
             $quotes[] = $quote;
         }
         $post = $this->attach_quotes($quotes);
     }
     $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'));
     }
     $forum_id = $topic_info[0]['t_forum_id'];
     $topic_title = $topic_info[0]['t_cache_first_title'];
     if ($topic_title == '') {
         $topic_title = $GLOBALS['FORUM_DB']->query_value_null_ok('f_posts', 'p_title', array('p_topic_id' => $topic_id));
     }
     if (is_null($topic_title)) {
         $topic_title = '';
     }
     if (!is_null($forum_id)) {
         if (!has_category_access(get_member(), 'forums', strval($forum_id))) {
             access_denied('CATEGORY_ACCESS');
         }
         // Can happen if trying to reply to a stated whisper made to you in a forum you don't have access to
     } else {
         // It must be a Private Topic. Do we have access?
         $from = $topic_info[0]['t_pt_from'];
         $to = $topic_info[0]['t_pt_to'];
         if ($from != get_member() && $to != get_member() && !ocf_has_special_pt_access($topic_id) && !has_specific_permission(get_member(), 'view_other_pt')) {
             access_denied('SPECIFIC_PERMISSION', 'view_other_pt');
         }
     }
     $this->handle_topic_breadcrumbs($forum_id, $topic_id, $topic_title, do_lang_tempcode('ADD_POST'));
     if ($topic_info[0]['t_is_open'] == 0) {
         $may_moderate_forum = ocf_may_moderate_forum($forum_id);
         if (!$may_moderate_forum) {
             warn_exit(do_lang_tempcode('TOPIC_IS_CLOSED'));
         }
     }
     $hidden_fields = new ocp_tempcode();
     $hidden_fields->attach(form_input_hidden('topic_id', strval($topic_id)));
     $hidden_fields->attach(form_input_hidden('from_url', get_self_url(true, false, array('type' => get_param('type', 'misc')))));
     $map = array('page' => '_SELF', 'type' => '_add_reply', 'parent_id' => $parent_id);
     $test = get_param_integer('kfs' . (is_null($forum_id) ? '' : strval($forum_id)), -1);
     if ($test != -1 && $test != 0) {
         $map['kfs' . (is_null($forum_id) ? '' : strval($forum_id))] = $test;
     }
     $test = get_param_integer('threaded', -1);
     if ($test != -1) {
         $map['threaded'] = $test;
     }
     $post_url = build_url($map, '_SELF');
     // Certain aspects relating to the posting system
     $specialisation = new ocp_tempcode();
     if (get_option('is_on_post_titles') == '1') {
         $specialisation->attach(form_input_line(do_lang_tempcode('TITLE'), '', 'title', post_param('title', ''), false, 1));
     }
     if (ocf_may_moderate_forum($forum_id, get_member())) {
         $moderation_options = array(array(do_lang_tempcode('EMPHASISED'), 'is_emphasised', false, do_lang_tempcode('DESCRIPTION_EMPHASISED')));
         if (addon_installed('unvalidated')) {
             $moderation_options[] = array(do_lang_tempcode('VALIDATED'), 'validated', true, do_lang_tempcode('DESCRIPTION_VALIDATED'));
         }
         //if ($intended_solely_for==-1) $moderation_options[]=array(do_lang_tempcode('CASCADING'),'cascading',false,do_lang_tempcode('DESCRIPTION_CASCADING'));
     } else {
         $moderation_options = array();
         $hidden_fields->attach(form_input_hidden('validated', '1'));
     }
     $options = array();
     if (!is_guest()) {
         if (get_value('disable_skip_sig') !== '1') {
             if (addon_installed('ocf_signatures')) {
                 $options[] = array(do_lang_tempcode('SKIP_SIGNATURE'), 'skip_sig', false, do_lang_tempcode('DESCRIPTION_SKIP_SIGNATURE'));
             }
         }
         if (get_option('is_on_anonymous_posts') == '1') {
             $options[] = array(do_lang_tempcode('_MAKE_ANONYMOUS_POST'), 'anonymous', false, do_lang_tempcode('MAKE_ANONYMOUS_POST_DESCRIPTION'));
         }
     }
     $specialisation2 = form_input_various_ticks($options, '');
     if (count($moderation_options) != 0) {
         $specialisation2->attach(form_input_various_ticks($moderation_options, '', NULL, do_lang_tempcode('MODERATION_OPTIONS')));
     }
     if (!is_null($forum_id)) {
         $post_templates = $this->post_templates($forum_id);
         $specialisation->attach($post_templates[0]);
         if (is_object($post) && $post->is_empty() || $post === '') {
             $post = $post_templates[1];
         }
     }
     $_intended_solely_for = '';
     if ($intended_solely_for != -1) {
         $_intended_solely_for = $GLOBALS['FORUM_DRIVER']->get_username($intended_solely_for);
         if (is_null($_intended_solely_for)) {
             $_intended_solely_for = '';
         }
     }
     if (ocf_may_make_personal_topic()) {
         if ($_intended_solely_for != '' || get_value('no_inline_pp_advertise') !== '1') {
             $specialisation->attach(form_input_username(do_lang_tempcode('WHISPER'), do_lang_tempcode('DESCRIPTION_WHISPER'), 'intended_solely_for', $_intended_solely_for, false));
         }
     }
     if (is_guest()) {
         $specialisation->attach(form_input_line(do_lang_tempcode('GUEST_NAME'), '', 'poster_name_if_guest', do_lang('GUEST'), true));
     }
     require_code('fields');
     if (has_tied_catalogue('post')) {
         append_form_custom_fields('post', NULL, $specialisation, $hidden_fields);
     }
     $text = new ocp_tempcode();
     if (addon_installed('captcha')) {
         require_code('captcha');
         if (use_captcha()) {
             $specialisation->attach(form_input_captcha());
             $text->attach(paragraph(do_lang_tempcode('FORM_TIME_SECURITY')));
         }
     }
     if (addon_installed('points')) {
         $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => get_self_url(true, true)), get_module_zone('login'));
         $_login_url = escape_html($login_url->evaluate());
         if (is_guest() && (get_forum_type() != 'ocf' || has_actual_page_access(get_member(), 'join'))) {
             $text->attach(paragraph(do_lang_tempcode('NOT_LOGGED_IN_NO_CREDIT', $_login_url)));
         }
     }
     if (!is_null($forum_id) && !has_specific_permission(get_member(), 'bypass_validation_lowrange_content', 'topics', array('forums', $forum_id))) {
         $text->attach(paragraph(do_lang_tempcode('WILL_NEED_VALIDATING')));
     }
     // Awards?
     if (addon_installed('awards')) {
         require_code('awards');
         $specialisation->attach(get_award_fields('post'));
     }
     // Moderator reply
     if (ocf_may_moderate_forum($forum_id, get_member())) {
         require_code('ocf_forums2');
         $specialisation2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('TOPIC_MODERATION'))));
         $specialisation2->attach(form_input_line(do_lang_tempcode('TITLE'), '', 'new_title', $topic_title, false));
         $specialisation2->attach(form_input_tree_list(do_lang_tempcode('DESTINATION_FORUM'), do_lang_tempcode('DESCRIPTION_DESTINATION_FORUM'), 'to', NULL, 'choose_forum', array(), false, is_null($forum_id) ? '' : strval($forum_id)));
         $options = array(array(do_lang_tempcode('OPEN'), 'open', $topic_info[0]['t_is_open'] == 1, do_lang_tempcode('DESCRIPTION_OPEN')), array(do_lang_tempcode('PINNED'), 'pinned', $topic_info[0]['t_pinned'] == 1, do_lang_tempcode('DESCRIPTION_PINNED')));
         if (addon_installed('unvalidated')) {
             if ($topic_info[0]['t_validated'] == 0) {
                 $topic_info[0]['t_validated'] = get_param_integer('validated', 0);
                 if ($topic_info[0]['t_validated'] == 1) {
                     attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING'));
                 }
             }
             $options[] = array(do_lang_tempcode('VALIDATED'), 'topic_validated', $topic_info[0]['t_validated'] == 1, do_lang_tempcode('DESCRIPTION_VALIDATED'));
         }
         if (get_value('disable_sunk') !== '1') {
             $moderation_options[] = array(do_lang_tempcode('SUNK'), 'sunk', $topic_info[0]['t_sunk'] == 1, do_lang_tempcode('DESCRIPTION_SUNK'));
         }
         if (!is_null($forum_id)) {
             $options[] = array(do_lang_tempcode('CASCADING'), 'cascading', $topic_info[0]['t_cascading'] == 1, do_lang_tempcode('DESCRIPTION_CASCADING'));
         }
         $specialisation2->attach(form_input_various_ticks($options, ''));
         if (addon_installed('calendar')) {
             $specialisation2->attach(form_input_date__scheduler(do_lang_tempcode('OCF_PUBLICATION_TIME'), do_lang_tempcode('OCF_DESCRIPTION_PUBLICATION_TIME'), 'schedule', true, true, true));
         }
     }
     $topic_posts = new ocp_tempcode();
     $posts = $GLOBALS['FORUM_DB']->query('SELECT *,p.id AS id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts p LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=p.p_post WHERE p_topic_id=' . strval($topic_id) . ' AND (p_intended_solely_for IS NULL OR p_intended_solely_for=' . strval(get_member()) . ' OR p_poster=' . strval(get_member()) . ') AND p_validated=1 ORDER BY p_time DESC,p.id DESC', 20);
     foreach ($posts as $row) {
         $topic_posts->attach(do_template('OCF_POSTING_SCREEN_POST', array('TITLE' => $row['p_title'], 'ID' => strval($row['id']), 'POSTER' => strval($row['p_poster']), 'POST' => ocf_show_isolated_post($row, true))));
     }
     if (!$topic_posts->is_empty()) {
         $topic_posts = do_template('OCF_POSTING_SCREEN_POSTS', array('_GUID' => '3d3b14cf3a48b2a16eed5b1bd92b1187', 'POSTS' => $topic_posts));
     }
     if (is_object($post)) {
         $post = $post->evaluate();
     }
     $posting_form = get_posting_form(do_lang('ADD_POST'), $post, $post_url, $hidden_fields, $specialisation, NULL, $topic_posts->evaluate(), $specialisation2, NULL, $this->_post_javascript());
     $title = get_page_title('_ADD_POST', true, array(escape_html($topic_title)));
     if (post_param_integer('add_poll', 0) == 1) {
         // Show it worked / Refresh
         $url = build_url(array('page' => '_SELF', 'type' => 'add_poll'), '_SELF');
         return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
     }
     return do_template('POSTING_SCREEN', array('_GUID' => 'ca2eab9a9ffdab267a48eb7be48ccdc0', 'TEXT' => $text, 'TITLE' => $title, 'POSTING_FORM' => $posting_form));
 }
Example #4
0
 /**
  * Standard modular run function for rendering a search result.
  *
  * @param  array		The data row stored when we retrieved the result
  * @return tempcode	The output
  */
 function render($row)
 {
     require_code('ocf_posts2');
     $tpl = ocf_show_isolated_post($row, false);
     $poster = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['p_poster']);
     $date = get_timezoned_date($row['p_time']);
     if ($row['t_cache_first_title'] == '') {
         $row['t_cache_first_title'] = $GLOBALS['FORUM_DB']->query_value('f_posts', 'p_title', array('p_topic_id' => $row['p_topic_id']), 'ORDER BY p_time ASC');
     }
     $link = hyperlink($GLOBALS['FORUM_DRIVER']->topic_url($row['p_topic_id']), $row['t_cache_first_title']);
     $title = do_lang_tempcode('FORUM_POST_SEARCH_RESULT', escape_html($row['id']), $poster, array(escape_html($date), $link));
     return put_in_standard_box($tpl, $title);
 }