Example #1
0
/**
 * Returns whether the given forum ID is for a ticket forum (subforum of the root ticket forum).
 *
 * @param  AUTO_LINK		The forum ID
 * @return boolean		Whether the given forum is a ticket forum
 */
function is_ticket_forum($forum_id)
{
    $root_forum_id = get_ticket_forum_id(NULL, NULL, false, true);
    if ($forum_id === $root_forum_id) {
        return true;
    }
    $query = 'SELECT COUNT(*) AS cnt FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE id=' . strval((int) $forum_id) . ' AND f_parent_forum IN (SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE id=' . strval((int) $root_forum_id) . ' OR f_parent_forum IN (SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE id=' . strval((int) $root_forum_id) . '))';
    $rows = $GLOBALS['FORUM_DB']->query($query);
    return $rows[0]['cnt'] != 0;
}
Example #2
0
/**
 * Add a new post to a ticket, or create a new ticket if a ticket with the given ID doesn't exist.
 * It has the same return value as make_post_forum_topic().
 *
 * @param  AUTO_LINK		The member ID
 * @param  string			The ticket ID (doesn't have to exist)
 * @param  integer		The ticket type (-1 reply to ticket)
 * @param  LONG_TEXT		The post title
 * @param  LONG_TEXT		The post content in Comcode format
 * @param  string			The home URL
 * @param  boolean		Whether the reply is staff only (invisible to ticket owner, only on OCF)
 */
function ticket_add_post($member, $ticket_id, $ticket_type, $title, $post, $ticket_url, $staff_only = false)
{
    // Get the forum ID first
    $fid = $GLOBALS['SITE_DB']->query_value_null_ok('tickets', 'forum_id', array('ticket_id' => $ticket_id));
    if (is_null($fid)) {
        $fid = get_ticket_forum_id($member, $ticket_type == -1 ? NULL : $ticket_type);
    }
    $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($fid, $ticket_id, $member, $title, $post, $title, do_lang('SUPPORT_TICKET'), $ticket_url, NULL, NULL, 1, 1, false, '', NULL, $staff_only);
    $topic_id = $GLOBALS['LAST_TOPIC_ID'];
    $is_new = $GLOBALS['LAST_TOPIC_IS_NEW'];
    if ($is_new && $ticket_type != -1) {
        $GLOBALS['SITE_DB']->query_insert('tickets', array('ticket_id' => $ticket_id, 'forum_id' => $fid, 'topic_id' => $topic_id, 'ticket_type' => $ticket_type));
    }
}