Пример #1
0
/**
 * Attach a tag to a bug.
 * @param integer Tag ID
 * @param integer Bug ID
 * @param integer User ID
 */
function tag_bug_attach($p_tag_id, $p_bug_id, $p_user_id = null)
{
    access_ensure_bug_level(config_get('tag_attach_threshold'), $p_bug_id, $p_user_id);
    tag_ensure_exists($p_tag_id);
    if (tag_bug_is_attached($p_tag_id, $p_bug_id)) {
        trigger_error(TAG_ALREADY_ATTACHED, ERROR);
    }
    if (null == $p_user_id) {
        $p_used_id = auth_get_current_user_id();
    } else {
        user_ensure_exists($p_user_id);
    }
    $c_tag_id = db_prepare_int($p_tag_id);
    $c_bug_id = db_prepare_int($p_bug_id);
    $c_user_id = db_prepare_int($p_user_id);
    $c_date_attached = db_now();
    $t_bug_tag_table = config_get('mantis_bug_tag_table');
    $query = "INSERT INTO {$t_bug_tag_table}\r\n\t\t\t\t\t( tag_id,\r\n\t\t\t\t\t  bug_id,\r\n\t\t\t\t\t  user_id,\r\n\t\t\t\t\t  date_attached\r\n\t\t\t\t\t)\r\n\t\t\t\t\tVALUES\r\n\t\t\t\t\t( '{$c_tag_id}',\r\n\t\t\t\t\t  '{$c_bug_id}',\r\n\t\t\t\t\t  '{$c_user_id}',\r\n\t\t\t\t\t  " . $c_date_attached . "\r\n\t\t\t\t\t)";
    db_query($query);
    $t_tag_name = tag_get_field($p_tag_id, 'name');
    history_log_event_special($p_bug_id, TAG_ATTACHED, $t_tag_name);
    return true;
}
Пример #2
0
/**
 * Attach a tag to a bug.
 * @param integer Tag ID
 * @param integer Bug ID
 * @param integer User ID
 */
function tag_bug_attach($p_tag_id, $p_bug_id, $p_user_id = null)
{
    access_ensure_bug_level(config_get('tag_attach_threshold'), $p_bug_id, $p_user_id);
    tag_ensure_exists($p_tag_id);
    if (tag_bug_is_attached($p_tag_id, $p_bug_id)) {
        trigger_error(TAG_ALREADY_ATTACHED, ERROR);
    }
    if (null == $p_user_id) {
        $p_used_id = auth_get_current_user_id();
    } else {
        user_ensure_exists($p_user_id);
    }
    $c_tag_id = db_prepare_int($p_tag_id);
    $c_bug_id = db_prepare_int($p_bug_id);
    $c_user_id = db_prepare_int($p_user_id);
    $t_bug_tag_table = db_get_table('bug_tag');
    $query = "INSERT INTO {$t_bug_tag_table}\n\t\t\t\t\t( tag_id,\n\t\t\t\t\t  bug_id,\n\t\t\t\t\t  user_id,\n\t\t\t\t\t  date_attached\n\t\t\t\t\t)\n\t\t\t\t\tVALUES\n\t\t\t\t\t( " . db_param() . ",\n\t\t\t\t\t  " . db_param() . ",\n\t\t\t\t\t  " . db_param() . ",\n\t\t\t\t\t  " . db_param() . "\n\t\t\t\t\t)";
    db_query_bound($query, array($c_tag_id, $c_bug_id, $c_user_id, db_now()));
    $t_tag_name = tag_get_field($p_tag_id, 'name');
    history_log_event_special($p_bug_id, TAG_ATTACHED, $t_tag_name);
    # updated the last_updated date
    bug_update_date($p_bug_id);
    return true;
}
Пример #3
0
/**
 * Attach a tag to a bug.
 * @param integer $p_tag_id  The tag ID to attach.
 * @param integer $p_bug_id  The bug ID to attach.
 * @param integer $p_user_id The user ID to attach.
 * @return boolean
 */
function tag_bug_attach($p_tag_id, $p_bug_id, $p_user_id = null)
{
    antispam_check();
    access_ensure_bug_level(config_get('tag_attach_threshold'), $p_bug_id, $p_user_id);
    tag_ensure_exists($p_tag_id);
    if (tag_bug_is_attached($p_tag_id, $p_bug_id)) {
        trigger_error(TAG_ALREADY_ATTACHED, ERROR);
    }
    if (null == $p_user_id) {
        $p_user_id = auth_get_current_user_id();
    } else {
        user_ensure_exists($p_user_id);
    }
    $t_query = 'INSERT INTO {bug_tag}
					( tag_id, bug_id, user_id, date_attached )
					VALUES
					( ' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ')';
    db_query($t_query, array($p_tag_id, $p_bug_id, $p_user_id, db_now()));
    $t_tag_name = tag_get_field($p_tag_id, 'name');
    history_log_event_special($p_bug_id, TAG_ATTACHED, $t_tag_name);
    # updated the last_updated date
    bug_update_date($p_bug_id);
    return true;
}