Esempio n. 1
0
/**
 * Sets the value of the given configuration option to the given value
 * If the configuration option does not exist, an ERROR is triggered
 *
 * @param string  $p_option  Configuration option name.
 * @param string  $p_value   Configuration option value.
 * @param integer $p_user    A user identifier. Defaults to NO_USER.
 * @param integer $p_project A project identifier. Defaults to ALL_PROJECTS.
 * @param integer $p_access  Access level. Defaults to DEFAULT_ACCESS_LEVEL.
 * @return boolean
 */
function config_set($p_option, $p_value, $p_user = NO_USER, $p_project = ALL_PROJECTS, $p_access = DEFAULT_ACCESS_LEVEL)
{
    if ($p_access == DEFAULT_ACCESS_LEVEL) {
        $p_access = config_get_global('admin_site_threshold');
    }
    if (is_array($p_value) || is_object($p_value)) {
        $t_type = CONFIG_TYPE_COMPLEX;
        $c_value = json_encode($p_value);
    } else {
        if (is_float($p_value)) {
            $t_type = CONFIG_TYPE_FLOAT;
            $c_value = (double) $p_value;
        } else {
            if (is_int($p_value) || is_numeric($p_value)) {
                $t_type = CONFIG_TYPE_INT;
                $c_value = (int) $p_value;
            } else {
                $t_type = CONFIG_TYPE_STRING;
                $c_value = $p_value;
            }
        }
    }
    if (config_can_set_in_database($p_option)) {
        # before we set in the database, ensure that the user and project id exist
        if ($p_project !== ALL_PROJECTS) {
            project_ensure_exists($p_project);
        }
        if ($p_user !== NO_USER) {
            user_ensure_exists($p_user);
        }
        $t_query = 'SELECT COUNT(*) from {config}
				WHERE config_id = ' . db_param() . ' AND
					project_id = ' . db_param() . ' AND
					user_id = ' . db_param();
        $t_result = db_query($t_query, array($p_option, (int) $p_project, (int) $p_user));
        $t_params = array();
        if (0 < db_result($t_result)) {
            $t_set_query = 'UPDATE {config}
					SET value=' . db_param() . ', type=' . db_param() . ', access_reqd=' . db_param() . '
					WHERE config_id = ' . db_param() . ' AND
						project_id = ' . db_param() . ' AND
						user_id = ' . db_param();
            $t_params = array((string) $c_value, $t_type, (int) $p_access, $p_option, (int) $p_project, (int) $p_user);
        } else {
            $t_set_query = 'INSERT INTO {config}
					( value, type, access_reqd, config_id, project_id, user_id )
					VALUES
					(' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ',' . db_param() . ' )';
            $t_params = array((string) $c_value, $t_type, (int) $p_access, $p_option, (int) $p_project, (int) $p_user);
        }
        db_query($t_set_query, $t_params);
    }
    config_set_cache($p_option, $c_value, $t_type, $p_user, $p_project, $p_access);
    return true;
}
Esempio n. 2
0
 * @uses print_api.php
 * @uses project_api.php
 */
require_once 'core.php';
require_api('access_api.php');
require_api('authentication_api.php');
require_api('config_api.php');
require_api('form_api.php');
require_api('gpc_api.php');
require_api('helper_api.php');
require_api('html_api.php');
require_api('lang_api.php');
require_api('print_api.php');
require_api('project_api.php');
form_security_validate('manage_user_proj_delete');
auth_reauthenticate();
$f_project_id = gpc_get_int('project_id');
$f_user_id = gpc_get_int('user_id');
user_ensure_exists($f_user_id);
$t_user = user_get_row($f_user_id);
access_ensure_project_level(config_get('project_user_threshold'), $f_project_id);
access_ensure_project_level($t_user['access_level'], $f_project_id);
$t_project_name = project_get_name($f_project_id);
# Confirm with the user
helper_ensure_confirmed(lang_get('remove_user_sure_msg') . '<br/>' . lang_get('project_name_label') . lang_get('word_separator') . $t_project_name, lang_get('remove_user_button'));
project_remove_user($f_project_id, $f_user_id);
form_security_purge('manage_user_proj_delete');
$t_redirect_url = 'manage_user_edit_page.php?user_id=' . $f_user_id;
html_page_top(null, $t_redirect_url);
html_operation_successful($t_redirect_url);
html_page_bottom();
Esempio n. 3
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;
}
Esempio n. 4
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;
}
Esempio n. 5
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;
}
Esempio n. 6
0
/**
 * Sets the value of the given config option to the given value
 *  If the config option does not exist, an ERROR is triggered
 *
 * @param string $p_option config option
 * @param string $p_value config value
 * @param int $p_user user id
 * @param int $p_project project id
 * @param int $p_access access level
 * @return bool
 */
function config_set($p_option, $p_value, $p_user = NO_USER, $p_project = ALL_PROJECTS, $p_access = DEFAULT_ACCESS_LEVEL)
{
    if ($p_access == DEFAULT_ACCESS_LEVEL) {
        $p_access = config_get_global('admin_site_threshold');
    }
    if (is_array($p_value) || is_object($p_value)) {
        $t_type = CONFIG_TYPE_COMPLEX;
        $c_value = serialize($p_value);
    } else {
        if (is_float($p_value)) {
            $t_type = CONFIG_TYPE_FLOAT;
            $c_value = (double) $p_value;
        } else {
            if (is_int($p_value) || is_numeric($p_value)) {
                $t_type = CONFIG_TYPE_INT;
                $c_value = (int) $p_value;
            } else {
                $t_type = CONFIG_TYPE_STRING;
                $c_value = $p_value;
            }
        }
    }
    if (config_can_set_in_database($p_option)) {
        # before we set in the database, ensure that the user and project id exist
        if ($p_project !== ALL_PROJECTS) {
            project_ensure_exists($p_project);
        }
        if ($p_user !== NO_USER) {
            user_ensure_exists($p_user);
        }
        $t_config_table = db_get_table('config');
        $t_query = "SELECT COUNT(*) from {$t_config_table}\n\t\t\t\tWHERE config_id = " . db_param() . " AND\n\t\t\t\t\tproject_id = " . db_param() . " AND\n\t\t\t\t\tuser_id = " . db_param();
        $t_result = db_query_bound($t_query, array($p_option, (int) $p_project, (int) $p_user));
        $t_params = array();
        if (0 < db_result($t_result)) {
            $t_set_query = "UPDATE {$t_config_table}\n\t\t\t\t\tSET value=" . db_param() . ", type=" . db_param() . ", access_reqd=" . db_param() . "\n\t\t\t\t\tWHERE config_id = " . db_param() . " AND\n\t\t\t\t\t\tproject_id = " . db_param() . " AND\n\t\t\t\t\t\tuser_id = " . db_param();
            $t_params = array($c_value, $t_type, (int) $p_access, $p_option, (int) $p_project, (int) $p_user);
        } else {
            $t_set_query = "INSERT INTO {$t_config_table}\n\t\t\t\t\t( value, type, access_reqd, config_id, project_id, user_id )\n\t\t\t\t\tVALUES\n\t\t\t\t\t(" . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ',' . db_param() . ' )';
            $t_params = array($c_value, $t_type, (int) $p_access, $p_option, (int) $p_project, (int) $p_user);
        }
        $result = db_query_bound($t_set_query, $t_params);
    }
    config_set_cache($p_option, $c_value, $t_type, $p_user, $p_project, $p_access);
    return true;
}
Esempio n. 7
0
$f_offset = gpc_get_int('offset', 0);
$f_user_id = gpc_get_int('user_id');
$f_committer_id = gpc_get_int('committer_id');
$f_branch = gpc_get_string('branch');
$f_message = gpc_get_string('message');
$t_changeset = SourceChangeset::load($f_changeset_id);
$t_repos = SourceRepo::load_by_changesets($t_changeset);
if (count($t_repos) < 1) {
    trigger_error(ERROR_GENERIC, ERROR);
}
$t_repo = array_shift($t_repos);
$t_repo->load_branches();
if ($f_user_id == 0 || user_ensure_exists($f_user_id)) {
    $t_changeset->user_id = $f_user_id;
}
if ($f_committer_id == 0 || user_ensure_exists($f_committer_id)) {
    $t_changeset->committer_id = $f_committer_id;
}
if (in_array($f_branch, $t_repo->branches)) {
    $t_changeset->branch = $f_branch;
}
if (plugin_config_get('enable_porting')) {
    $f_ported = gpc_get_string('ported', '');
    if (0 == $f_ported || in_array($f_ported, $t_repo->branches)) {
        $t_changeset->ported = $f_ported;
    }
}
if (!is_blank($f_message)) {
    $t_changeset->message = $f_message;
}
$t_changeset->save();