Show
Ignore:
Timestamp:
01/21/10 15:31:55 (2 years ago)
Author:
gbastien
Message:

Corrected some one-liners:

  • Permission error when deleting user role (#689)
  • Patch by Steven Kurylo to remove white spaces from authenticator arguments (#612)
  • Search for stakeholders has now same case-sensitivity as the user's network (#662)
  • Corrected (#613) patch by Hélène Gauthier
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/wifidog/classes/User.php

    r1435 r1438  
    172172        return $object; 
    173173    } 
     174     
     175                /** Instantiate a user object 
     176     * @param $username The username of the user 
     177     * @param $account_origin Network:  The account origin 
     178     * @param &$errMsg An error message will be appended to this if the username is not empty, but the user doesn't exist. 
     179     * @return a User object, or null if there was an error 
     180     */ 
     181    public static function getUserByUsernameOrEmailAndOrigin($usernameOrEmail, Network $account_origin, &$errMsg = null) { 
     182        $db = AbstractDb::getObject(); 
     183        $object = null; 
     184 
     185        $username_str = $db->escapeString($usernameOrEmail); 
     186        $comparison = ($account_origin->getUsernamesCaseSensitive()? '=': 'ILike'); 
     187        $account_origin_str = $db->escapeString($account_origin->getId()); 
     188        $db->execSqlUniqueRes("SELECT user_id FROM users WHERE (username {$comparison} '$username_str' OR email ILike '$username_str') AND account_origin = '$account_origin_str'", $user_info, false); 
     189 
     190        if ($user_info != null) { 
     191            $object = self::getObject($user_info['user_id']); 
     192        } 
     193        else if (!empty($usernameOrEmail)) { 
     194            $errMsg .= sprintf(_("There is no user with username or email %s"),$usernameOrEmail); 
     195        } 
     196        return $object; 
     197    } 
    174198 
    175199    /** Instantiate a user object 
     
    857881            if (!empty ($_REQUEST[$name])) { 
    858882                $username = $_REQUEST[$name]; 
    859                 return self :: getUserByUsernameOrEmail($username, $errMsg); 
     883                return self :: getUserByUsernameOrEmailAndOrigin($username, $network, $errMsg); 
    860884            } else 
    861885            return null;