示例#1
0
/**
 * Update the spacer post of a comment topic, after an edit.
 *
 * @param  boolean		Whether this resource allows comments (if not, this function does nothing - but it's nice to move out this common logic into the shared function)
 * @param  ID_TEXT		The type (download, etc) that this commenting is for
 * @param  ID_TEXT		The ID of the type that this commenting is for
 * @param  mixed			The URL to where the commenting will pass back to (to put into the comment topic header) (URLPATH or Tempcode)
 * @param  ?string		The title to where the commenting will pass back to (to put into the comment topic header) (NULL: don't know, but not first post so not important)
 * @param  ?string		The name of the forum to use (NULL: default comment forum)
 * @param  ?AUTO_LINK	ID of spacer post (NULL: unknown)
 */
function update_spacer_post($allow_comments, $content_type, $content_id, $content_url, $content_title, $forum = NULL, $post_id = NULL)
{
    if (get_option('is_on_comments') == '0' || !$allow_comments) {
        return;
    }
    if (get_forum_type() != 'ocf') {
        return;
    }
    $home_link = is_null($content_title) ? new ocp_tempcode() : hyperlink($content_url, escape_html($content_title));
    if (is_null($forum)) {
        $forum = get_option('comments_forum_name');
    }
    if (!is_integer($forum)) {
        $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum);
        if (is_null($forum_id)) {
            return;
        }
    } else {
        $forum_id = (int) $forum;
    }
    $content_title = strip_comcode($content_title);
    if (is_null($post_id)) {
        $topic_id = $GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier($forum_id, $content_type . '_' . $content_id);
        if (is_null($topic_id)) {
            return;
        }
        $post_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_posts', 'MIN(id)', array('p_topic_id' => $topic_id));
        if (is_null($post_id)) {
            return;
        }
    } else {
        $topic_id = $GLOBALS['FORUM_DB']->query_value('f_posts', 'p_topic_id', array('id' => $post_id));
    }
    $spacer_title = is_null($content_title) ? $content_type . '_' . $content_id : $content_title . ' (#' . $content_type . '_' . $content_id . ')';
    $spacer_post = '[semihtml]' . do_lang('SPACER_POST', $home_link->evaluate(), '', '', get_site_default_lang()) . '[/semihtml]';
    if (get_forum_type() == 'ocf') {
        require_code('ocf_posts_action3');
        ocf_edit_post($post_id, 1, is_null($content_title) ? $spacer_title : $content_title, $spacer_post, 0, 0, NULL, false, false, '', false);
        require_code('ocf_topics_action2');
        ocf_edit_topic($topic_id, do_lang('COMMENT') . ': #' . $content_type . '_' . $content_id, NULL, NULL, NULL, NULL, NULL, NULL, '', NULL, $home_link->evaluate(), false);
    }
}
示例#2
0
 /**
  * The actualiser to close a topic.
  *
  * @return tempcode		The UI
  */
 function close_topic()
 {
     $topic_id = get_param_integer('id');
     require_code('ocf_topics_action');
     require_code('ocf_topics_action2');
     ocf_edit_topic($topic_id, NULL, NULL, NULL, 0, NULL, NULL, NULL, '');
     return $this->redirect_to('CLOSE_TOPIC', $topic_id);
 }