Changeset 51

Show
Ignore:
Timestamp:
10/22/05 23:02:18 (7 years ago)
Author:
mat
Message:

Filtre tous les champs pour le FOAF. Pas terrible (copie du tableau tout ca)
mais on verra a faire mieux plus tard, au moins j'utilise une fonction qui
pourra etre re-utilisable.

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/inc_xml/foaf.inc.php

    r43 r51  
    4040// Filtre chaque partie du profile, ne laisse que les infos accessibles par tout  
    4141// le monde 
    42 foreach($user['contact'] as $key => $value) 
    43 { 
    44         // on a pas ca dans access? dans le doute, on laisse. 
    45         if (!array_key_exists($key, $access['contact'])) 
    46                 continue; 
    47         if (access_weight($access['contact'][$key]) < access_weight($weight)) 
    48         {        
    49                 // on a pas le droit de l'afficher: on le planque. 
    50                 unset($user['contact'][$key]); 
    51         } 
    52 } 
     42$user['contact'] = filter_table_with_weight($user['contact'], $access['contact'], $weight); 
     43$user['professionel'] = filter_table_with_weight($user['professionel'], $access['professionel'], $weight); 
     44$user['general'] = filter_table_with_weight($user['general'], $access['general'], $weight); 
    5345 
    5446$friends_r = $db->query('SELECT user_contact.email AS email, user.fname AS fname, user.lname AS lname, user.login AS login, user.id AS id FROM user_contact LEFT JOIN user_general USING(id) LEFT JOIN user USING(id) LEFT JOIN  relation USING(id) WHERE relation.id_friend=?', array($id)); 
  • trunk/includes/functions.inc.php

    r36 r51  
    240240} 
    241241 
     242// Il faudrait avoir un objet pour gerer les profiles, ca permettrait 
     243// de gerer ca beaucoup plus facilement/efficacement. 
     244function filter_table_with_weight($table, $access, $weight) 
     245{        
     246        foreach ($table as $key => $value) 
     247        { 
     248                // on a pas ca dans access? dans le doute, on laisse. 
     249                if (!array_key_exists($key, $access)) 
     250                        continue; 
     251                if (access_weight($access[$key]) < access_weight($weight)) 
     252                {        
     253                        // on a pas le droit de l'afficher: on le planque. 
     254                        unset($table[$key]); 
     255                } 
     256        } 
     257        return $table; 
     258} 
     259 
     260 
    242261function get_relation_type($my_id, $my_friends_id, $user_id, $user_friends_id) 
    243262{