root/trunk/inc/_profile/general.inc.php

Revision 1, 9.4 KB (checked in by anonymous, 7 years ago)

initial import

Line 
1<?php
2/****************************************************** Open .node ***
3 * Description:   
4 * Status:        Stable.
5 * Author:        Alexandre Dath <alexandre@dotnode.com>
6 * $Id$
7 *
8 * Copyright (C) 2005 Alexandre Dath <alexandre@dotnode.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ******************** http://opensource.ikse.net/projects/dotnode ***/
24
25// Recuperation du profil general *******************
26$t_name = 'user_general';
27$user_access['general'] = get_access_list($url_id, $t_name); // Access List *****************************
28
29$t_fields = implode(',', array_keys($table_fields[$t_name]));
30$user_general = $db->query('SELECT !  FROM ! WHERE id=?', array($t_fields, $t_name, $url_id) );
31
32if(!DB::isError($user_general) )
33{
34    $table_info = $user_general->tableInfo();                                       // Recuperation des infos de la table
35    $profile = $user_general->FetchRow();                                           // On recupere le profil
36    foreach($table_info as $item)                                                   // Pour chaque colonne de la table
37    {
38        if(  array_key_exists($item['name'], $user_access['general']) && (access_weight($user_access['general'][$item['name']]) <= access_weight($user['relation_type'])  )  )
39            continue;
40        elseif($profile[$item['name']] == NULL || $profile[$item['name']] == "")    // Si la colonne ne contient rien, on arrete la et on passe aus suivant
41            continue;
42        elseif($item['type'] == 'date')
43        {
44            list($year, $month, $day) = explode('-', $profile[$item['name']]);
45            $date = getdate(mktime (0,0,0,$month,$day,$year));
46            $value = $date['mday'].' '._($date['month']).' '.$date['year'];
47        }
48        elseif(ereg('set', $item['flags']))                                     // Si c'est un colonne de type 'SET' (liste a choix multiples)
49        {
50            $translated_thing = array();                                    // declaration du tableau qui va recevoir les chaines traduites
51            $things = explode(',', $profile[$item['name']]);                // on separe ce qu'il y a en base dans un tableau $things
52            foreach($things as $thing)                                      // pour chaque elements du SET
53                array_push($translated_thing, _($labels['profile'][$item['name']][$thing])); // on ajoute dans le tableau $translated_thing la traduction du label de la valeur, trouv�ans labels.inc.php
54            $value = implode(", ", $translated_thing);                      // on reforme un truc affichable et on le mets dans $value
55        }
56        else
57        {
58            if(array_key_exists( $profile[$item['name']], (array)$labels['profile'][$item['name']]) )
59                $value = _($labels['profile'][$item['name']][$profile[$item['name']]]);
60            else
61                $value = $profile[$item['name']];
62                                            // par defaut, on prend le champs de $profile correspondant a la colonne courante $item['name']
63        }
64
65        $key = $table_fields['user_general'][$item['name']];                    // on genere la cle qui sera utilis�ans le tableau export� Smarty, ca sera le label traduit a partir du nom de la colonne (trouv�ans labels.inc.php)
66        $user['general'][$key] = _($value);                            // enfin, on attribue la valeur trouv�raduite...
67    }
68}
69else
70    error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' | '.$user_general->getUserInfo());
71
72// Recuperation du profile 'interets'
73$t_name = 'user_interests';
74$user_access['interests'] = get_access_list($url_id, $t_name); // Access List *****************************
75
76$t_fields = implode(',', array_keys($table_fields[$t_name]));
77$user_interests = $db->query('SELECT ! FROM ! WHERE id=?', array($t_fields, $t_name, $url_id) );
78
79if(!DB::isError($user_interests) )
80{
81    $table_info = $user_interests->tableInfo();                                       // Recuperation des infos de la table
82    $profile = $user_interests->FetchRow();                                           // On recupere le profil
83    foreach($table_info as $item)                                                   // Pour chaque colonne de la table
84    {
85        if( isset($user_access['interests']) && array_key_exists($item['name'], $user_access['interests']) && (access_weight($user_access['interests'][$item['name']]) <= access_weight($user['relation_type'])  )  )
86            continue;
87        elseif($profile[$item['name']] == NULL || $profile[$item['name']] == "")    // Si la colonne ne contient rien, on arrete la et on passe aus suivant
88            continue;
89        elseif($item['type'] == 'date')
90        {
91            list($year, $month, $day) = explode('-', $profile[$item['name']]);
92            $date = getdate(mktime (0,0,0,$month,$day,$year));
93            $value = $date['mday'].' '._($date['month']).' '.$date['year'];
94        }
95        elseif(ereg('set', $item['flags']))                                     // Si c'est un colonne de type 'SET' (liste a choix multiples)
96        {
97            $translated_thing = array();                                    // declaration du tableau qui va recevoir les chaines traduites
98            $things = explode(',', $profile[$item['name']]);                // on separe ce qu'il y a en base dans un tableau $things
99            foreach($things as $thing)                                      // pour chaque elements du SET
100                array_push($translated_thing, _($labels['profile'][$item['name']][$thing])); // on ajoute dans le tableau $translated_thing la traduction du label de la valeur, trouv�ans labels.inc.php
101            $value = implode(", ", $translated_thing);                      // on reforme un truc affichable et on le mets dans $value
102        }
103        else
104        {
105            if(array_key_exists( $profile[$item['name']], (array)$labels['profile'][$item['name']]) )
106                $value = _($labels['profile'][$item['name']][$profile[$item['name']]]);
107            else
108                $value = $profile[$item['name']];
109                                            // par defaut, on prend le champs de $profile correspondant a la colonne courante $item['name']
110        }
111
112        $key = $table_fields['user_interests'][$item['name']];                    // on genere la cle qui sera utilis�ans le tableau export� Smarty, ca sera le label traduit a partir du nom de la colonne (trouv�ans labels.inc.php)
113        $user['interests'][$key] = _($value);                            // enfin, on attribue la valeur trouv�raduite...
114    }
115}
116else
117    error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' | '.$user_interests->getUserInfo());
118
119// Recuperation du profile contact
120$t_name = 'user_contact';
121$user_access['contact'] = get_access_list($url_id, $t_name); // Access List *****************************
122
123$t_fields = implode(',', array_keys($table_fields[$t_name]));
124$user_contact = $db->query('SELECT ! FROM ! WHERE id=?', array($t_fields, $t_name, $url_id) );
125
126if(!DB::isError($user_contact) )
127{
128    $table_info = $user_contact->tableInfo();                                       // Recuperation des infos de la table
129    $profile = $user_contact->FetchRow();                                           // On recupere le profil
130    foreach($table_info as $item)                                                   // Pour chaque colonne de la table
131    {
132        if(  isset($user_access['contact']) && array_key_exists($item['name'], $user_access['contact']) && (access_weight($user_access['contact'][$item['name']]) <= access_weight($user['relation_type'])  )  )
133            continue;
134        elseif($profile[$item['name']] == NULL || $profile[$item['name']] == "")    // Si la colonne ne contient rien, on arrete la et on passe aus suivant
135            continue;
136        elseif($item['type'] == 'date')
137        {
138            list($year, $month, $day) = explode('-', $profile[$item['name']]);
139            $date = getdate(mktime (0,0,0,$month,$day,$year));
140            $value = $date['mday'].' '._($date['month']).' '.$date['year'];
141        }
142        elseif(ereg('set', $item['flags']))                                     // Si c'est un colonne de type 'SET' (liste a choix multiples)
143        {
144            $translated_thing = array();                                    // declaration du tableau qui va recevoir les chaines traduites
145            $things = explode(',', $profile[$item['name']]);                // on separe ce qu'il y a en base dans un tableau $things
146            foreach($things as $thing)                                      // pour chaque elements du SET
147                array_push($translated_thing, _($labels['profile'][$item['name']][$thing])); // on ajoute dans le tableau $translated_thing la traduction du label de la valeur, trouv�ans labels.inc.php
148            $value = implode(", ", $translated_thing);                      // on reforme un truc affichable et on le mets dans $value
149        }
150        else
151        {
152            if(array_key_exists( $profile[$item['name']], (array)$labels['profile'][$item['name']]) )
153                $value = _($labels['profile'][$item['name']][$profile[$item['name']]]);
154            else
155                $value = $profile[$item['name']];
156                                            // par defaut, on prend le champs de $profile correspondant a la colonne courante $item['name']
157        }
158
159        $user['contact'][$item['name']]['key'] = $table_fields['user_contact'][$item['name']];
160        $user['contact'][$item['name']]['value'] = $value;                          // enfin, on attribue la valeur trouv�raduite...
161
162    }
163}
164else
165    error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' | '.$user_contact->getUserInfo());
166?>
Note: See TracBrowser for help on using the browser.