Example #1
0
/**
 * Set a user preference
 *
 * By getting the prefs for the project first we deal fairly well with defaults.
 *  If there are currently no prefs for that project, the ALL_PROJECTS prefs will
 *  be returned so we end up storing a new set of prefs for the given project
 *  based on the prefs for ALL_PROJECTS.  If there isn't even an entry for
 *  ALL_PROJECTS, we'd get returned a default UserPreferences object to modify.
 * @param int $p_user_id
 * @param string $p_pref_name
 * @param string $p_pref_value
 * @param int $p_project_id
 * @return true
 */
function user_pref_set_pref( $p_user_id, $p_pref_name, $p_pref_value, $p_project_id = ALL_PROJECTS ) {
	$t_prefs = user_pref_get( $p_user_id, $p_project_id );

	$t_prefs->$p_pref_name = $p_pref_value;

	user_pref_set( $p_user_id, $t_prefs, $p_project_id );

	return true;
}
/**
 * Set a user preference
 *
 * By getting the prefs for the project first we deal fairly well with defaults.
 *  If there are currently no prefs for that project, the ALL_PROJECTS prefs will
 *  be returned so we end up storing a new set of prefs for the given project
 *  based on the prefs for ALL_PROJECTS.  If there isn't even an entry for
 *  ALL_PROJECTS, we'd get returned a default UserPreferences object to modify.
 * @param int $p_user_id
 * @param string $p_pref_name
 * @param string $p_pref_value
 * @param int $p_project_id
 * @return true
 */
function user_pref_set_pref($p_user_id, $p_pref_name, $p_pref_value, $p_project_id = ALL_PROJECTS)
{
    $t_prefs = user_pref_get($p_user_id, $p_project_id);
    if ($t_prefs->{$p_pref_name} != $p_pref_value) {
        $t_prefs->{$p_pref_name} = $p_pref_value;
        user_pref_set($p_user_id, $t_prefs, $p_project_id);
    }
    return true;
}
$t_prefs->email_on_closed_min_severity = gpc_get_int('email_on_closed_min_severity');
$t_prefs->email_on_reopened_min_severity = gpc_get_int('email_on_reopened_min_severity');
$t_prefs->email_on_bugnote_min_severity = gpc_get_int('email_on_bugnote_min_severity');
$t_prefs->email_on_status_min_severity = gpc_get_int('email_on_status_min_severity');
$t_prefs->email_on_priority_min_severity = gpc_get_int('email_on_priority_min_severity');
$t_prefs->bugnote_order = gpc_get_string('bugnote_order');
$t_prefs->email_bugnote_limit = gpc_get_int('email_bugnote_limit');
# make sure the delay isn't too low
if (config_get('min_refresh_delay') > $t_prefs->refresh_delay && $t_prefs->refresh_delay != 0) {
    $t_prefs->refresh_delay = config_get('min_refresh_delay');
}
if (function_exists('timezone_identifiers_list')) {
    $t_timezone = gpc_get_string('timezone');
    if (in_array($t_timezone, timezone_identifiers_list())) {
        if ($t_timezone == config_get_global('default_timezone')) {
            $t_prefs->timezone = '';
        } else {
            $t_prefs->timezone = $t_timezone;
        }
    }
}
event_signal('EVENT_ACCOUNT_PREF_UPDATE', array($f_user_id));
user_pref_set($f_user_id, $t_prefs);
form_security_purge('account_prefs_update');
html_page_top(null, $f_redirect_url);
echo '<br /><div align="center">';
echo lang_get('operation_successful');
echo '<br />';
print_bracket_link($f_redirect_url, lang_get('proceed'));
echo '<br /></div>';
html_page_bottom();
Example #4
0
function user_pref_set_default($p_user_id, $p_project_id = ALL_PROJECTS)
{
    # get a default preferences object
    $t_prefs = new UserPreferences();
    return user_pref_set($p_user_id, $t_prefs, $p_project_id);
}