Example #1
0
/**
* Adds tags to a thread. Errors are silently ignored, but returned.
*
* @param	array			Array of thread info
* @param	string|array	List of tags to add (comma delimited, or an array as is). If array, ensure there are no commas.
*
* @return	array			Array of errors, if any
*/
function add_tags_to_thread($threadinfo, $taglist)
{
    global $vbulletin;
    $threadid = intval($threadinfo['threadid']);
    if (!$threadid) {
        return array();
    }
    $taglist = fetch_valid_tags($threadinfo, $taglist, $errors);
    if (!$taglist) {
        return $errors;
    }
    insert_tags_thread($threadid, $taglist);
    return $errors;
}
Example #2
0
        print_stop_message('no_polls_found');
    }
    print_form_header('thread', 'dovotes');
    print_table_header($vbphrase['who_voted']);
    print_label_row($vbphrase['poll'], "<select name=\"pollid\" class=\"bginput\" tabindex=\"1\" onchange=\"js_fetch_thread_title(this.form,this.options[this.selectedIndex].value)\">{$polloptions}</select>", '', 'top', 'pollid');
    print_label_row($vbphrase['thread'], "<input type=\"text\" tabindex=\"1\" class=\"bginput\" size=\"50\" name=\"threadtitle\" value=\"{$firsttitle}\" readonly=\"readonly\" disabled=\"disabled\" />", '', 'top', 'threadtitle');
    print_submit_row($vbphrase['who_voted'], 0);
}
// ########################################################################
if ($_POST['do'] == 'taginsert') {
    $vbulletin->input->clean_array_gpc('p', array('tagtext' => TYPE_NOHTML));
    if ($db->query_first("\n\t\tSELECT tagid\n\t\tFROM " . TABLE_PREFIX . "tag\n\t\tWHERE tagtext = '" . $db->escape_string($vbulletin->GPC['tagtext']) . "'\n\t")) {
        print_stop_message('tag_exists');
    }
    require_once DIR . '/includes/functions_newpost.php';
    $valid = fetch_valid_tags(array(), array($vbulletin->GPC['tagtext']), $errors, false);
    if ($errors) {
        print_stop_message('generic_error_x', implode('<br /><br />', $errors));
    }
    if (!empty($valid)) {
        $db->query_write("\n\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "tag\n\t\t\t\t(tagtext, dateline)\n\t\t\tVALUES\n\t\t\t\t('" . $db->escape_string($valid[0]) . "', " . TIMENOW . ")\n\t\t");
    }
    define('CP_REDIRECT', 'thread.php?do=tags');
    print_stop_message('tag_saved');
}
// ########################################################################
if ($_POST['do'] == 'tagkill') {
    $vbulletin->input->clean_array_gpc('p', array('tag' => TYPE_ARRAY_KEYS_INT));
    if ($vbulletin->GPC['tag']) {
        $tags_result = $vbulletin->db->query_read("\n\t\t\tSELECT tagtext\n\t\t\tFROM " . TABLE_PREFIX . "tag\n\t\t\tWHERE tagid IN (" . implode(',', $vbulletin->GPC['tag']) . ")\n\t\t");
        $tagstodelete = array();