Changeset 1278

Show
Ignore:
Timestamp:
08/04/07 19:25:41 (5 years ago)
Author:
drazzib
Message:

2007-08-05 Damien Raude-Morvan <drazzib@…>

  • Security.php : A permission can be acquired by a user via multiples roles, this means that, for the moment, we have to use DISTINCT to check if a user had correct permission (otherwise the SQL request is invalid : subrequest return more than one line).
  • Locale.php : If the browser send Accept-Value header without any quality (i.e. q=x.y) we have to use order of the locales to select between them (and don't use a rand() number).
Location:
trunk/wifidog-auth
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/CHANGELOG

    r1277 r1278  
    11# $Id$ 
     22007-08-05 Damien Raude-Morvan <drazzib@drazzib.com> 
     3        * Security.php : A permission can be acquired by a user via multiples roles, this means 
     4        that, for the moment, we have to use DISTINCT to check if a user had correct permission 
     5        (otherwise the SQL request is invalid : subrequest return more than one line). 
     6        * Locale.php : If the browser send Accept-Value header without any quality (i.e. q=x.y) 
     7        we have to use order of the locales to select between them (and don't use a rand() number). 
     8 
    292007-06-04 Benoit Grégoire  <bock@step.polymtl.ca> 
    310        * Portugese (from portugal) translation contributed by MiguelCMA 
  • trunk/wifidog-auth/wifidog/classes/Locale.php

    r1246 r1278  
    173173 
    174174                $browser_preferences = array(); 
     175                // $appendIdx help differentiation between same quality locales 
     176                // first locale in string get better quality than next 
     177                $appendIdx = 9999; 
    175178                foreach(explode(',', empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? DEFAULT_LANG : $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $lang) { 
    176179                        //echo $lang."\n"; 
    177180                        if (preg_match('/^\s*([a-z_-]+).*?(?:;\s*q=([0-9.]+))?/i', $lang.';q=1.0', $split)) { 
    178                                 $browser_preferences[sprintf('%f%d', $split[2], rand(0,9999))] = strtolower($split[1]); 
     181                                $browser_preferences[sprintf('%f%d', $split[2], $appendIdx)] = strtolower($split[1]); 
    179182                        } 
     183                        $appendIdx--; 
    180184                } 
    181185 
  • trunk/wifidog-auth/wifidog/classes/Security.php

    r1270 r1278  
    8989                $table = strtolower($objectClass).'_stakeholders'; 
    9090                $permissionIdStr = $db->escapeString($permission->getId()); 
    91                 $sqlSelect = "SELECT permission_id FROM $table JOIN role_has_permissions USING (role_id) WHERE user_id='{$user->getId()}' $objectSqlAnd AND permission_id = '$permissionIdStr'"; 
     91                $sqlSelect = "SELECT DISTINCT permission_id FROM $table JOIN role_has_permissions USING (role_id) WHERE user_id='{$user->getId()}' $objectSqlAnd AND permission_id = '$permissionIdStr'"; 
    9292                if($operator == 'OR') { 
    9393                    $first?$sql .= " ($sqlSelect)\n":$sql .= ", ($sqlSelect)\n";