Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f4a758543a74
Choose a base ref
...
head repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c4b12ce2a1dc
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Oct 11, 2012

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    af99067 View commit details
  2. Use standard error message

    The warning message displayed by user_get_field() when called with user
    ID '0' (aka NO_USER) was not standard. Now referencing message
    ERROR_USER_BY_ID_NOT_FOUND instead.
    
    Affects #14815
    dregad committed Oct 11, 2012
    Copy the full SHA
    c4b12ce View commit details
Showing with 14 additions and 13 deletions.
  1. +14 −13 core/user_api.php
27 changes: 14 additions & 13 deletions core/user_api.php
Original file line number Diff line number Diff line change
@@ -169,7 +169,7 @@ function user_exists( $p_user_id ) {
}

# --------------------
# check to see if project exists by id
# check to see if user exists by id
# if it doesn't exist then error
# otherwise let execution continue undisturbed
function user_ensure_exists( $p_user_id ) {
@@ -719,7 +719,8 @@ function user_get_row( $p_user_id ) {
# return the specified user field for the user id
function user_get_field( $p_user_id, $p_field_name ) {
if( NO_USER == $p_user_id ) {
trigger_error( 'user_get_field() for NO_USER', WARNING );
error_parameters( NO_USER );
trigger_error( ERROR_USER_BY_ID_NOT_FOUND, WARNING );
return '@null@';
}

@@ -1230,47 +1231,47 @@ function user_increment_lost_password_in_progress_count( $p_user_id ) {

/**
* Sets multiple fields on a user
*
*
* @param int $p_user_id
* @param array $p_fields keys are the field names and the values are the field values
*/
function user_set_fields( $p_user_id, $p_fields ) {

$c_user_id = db_prepare_int( $p_user_id );

if ( !array_key_exists('protected', $p_fields) ) {
user_ensure_unprotected( $p_user_id );
}

$t_user_table = db_get_table( 'mantis_user_table' );

$t_query = 'UPDATE ' . $t_user_table;
$t_parameters = Array();

foreach ( $p_fields as $t_field_name => $t_field_value ) {

$c_field_name = db_prepare_string( $t_field_name );

if ( count ( $t_parameters) == 0 )
$t_query .= ' SET '. $c_field_name. '=' . db_param();
else
$t_query .= ' , ' . $c_field_name. '=' . db_param();

array_push( $t_parameters, $t_field_value );
}

$t_query .= ' WHERE id=' . db_param();
array_push ( $t_parameters, $c_user_id );

db_query_bound( $t_query, $t_parameters );

user_clear_cache( $p_user_id );
}

# --------------------
# Set a user field
function user_set_field( $p_user_id, $p_field_name, $p_field_value ) {

user_set_fields($p_user_id, array ( $p_field_name => $p_field_value ) );

# db_query errors on failure so: