root/trunk/inc/_profile/all.inc.php

Revision 15, 16.6 KB (checked in by alexx, 7 years ago)
  • fix last bug in communities (see [14])
  • execute a "conversion smarty style" script ;) : for i in find . -type f | grep "\.php$" | grep -v "\.svn"; do perl -pi -e "s/\\\$smarty->assign\((.*),(.*)\);/\\\$_SMARTY\[\$1\] = \$2;/" $i; done
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 summary *******************
26
27if($rss_blog = $db->getRow('SELECT id_blog, title, link, rss FROM rss_blog WHERE id=?', array($url_id)) )
28{
29        $ticket = $db->getRow('SELECT id_ticket, title, description, link, date, description, content FROM rss_blog_ticket WHERE id=? ORDER BY date DESC LIMIT 1', array($url_id));
30        $_SMARTY['blog_rss'] = $ticket;
31}
32else
33{
34        $blog = $db->getRow('SELECT blog.id as id, id_blog, blog.id_cat,title, chapeau, ticket, date, status, blog_categorie.name as categorie, nb_comments  FROM blog LEFT JOIN blog_categorie USING (id,id_cat) WHERE blog.id=? AND blog.status=? ORDER BY date DESC LIMIT 1', array($url_id, 'online') );
35        $_SMARTY['blog'] = $blog;
36}
37
38#$blog = $db->getRow('SELECT id_blog, title, chapeau, ticket, nb_comments FROM blog WHERE id=? AND status=? ORDER BY date DESC LIMIT 0,1', array($url_id, 'online'));
39#$_SMARTY['blog'] =  $blog;
40
41$bookmarks_r = $db->query('SELECT link, comment FROM bookmarks WHERE id=? ORDER BY date DESC LIMIT 0,4', array($url_id));
42while($bookmark = $bookmarks_r->fetchRow())
43    $bookmarks[] = $bookmark;
44$_SMARTY['bookmarks'] = $bookmarks;
45
46$albums_r = $db->query('SELECT caption,id_image, width, height FROM album WHERE id=? ORDER BY date DESC LIMIT 0,3', array($url_id));
47while($photo = $albums_r->fetchRow())
48{
49    $photo['thumb_path'] = build_album_thumb_url($url_id, $photo['id_image']);
50        $albums[] = $photo;
51}
52$_SMARTY['albums'] = $albums;
53
54
55// Recuperation du profil general *******************
56$t_name = 'user_general';
57$user_access['general'] = get_access_list($url_id, $t_name); // Access List *****************************
58
59$t_fields = implode(',', array_keys($table_fields[$t_name]));
60$user_general = $db->query('SELECT !  FROM ! WHERE id=?', array($t_fields, $t_name, $url_id) );
61
62if(!DB::isError($user_general) )
63{
64    $table_info = $user_general->tableInfo();                                       // Recuperation des infos de la table
65    $profile = $user_general->FetchRow();                                           // On recupere le profil
66    foreach($table_info as $item)                                                   // Pour chaque colonne de la table
67    {
68        if(  array_key_exists($item['name'], $user_access['general']) && (access_weight($user_access['general'][$item['name']]) <= access_weight($user['relation_type'])  )  )
69            continue;
70        elseif($profile[$item['name']] == NULL || $profile[$item['name']] == "")    // Si la colonne ne contient rien, on arrete la et on passe aus suivant
71            continue;
72        elseif($item['type'] == 'date')
73        {
74            list($year, $month, $day) = explode('-', $profile[$item['name']]);
75            $date = getdate(mktime (0,0,0,$month,$day,$year));
76            $value = $date['mday'].' '._($date['month']).' '.$date['year'];
77        }
78        elseif(ereg('set', $item['flags']))                                     // Si c'est un colonne de type 'SET' (liste a choix multiples)
79        {
80            $translated_thing = array();                                    // declaration du tableau qui va recevoir les chaines traduites
81            $things = explode(',', $profile[$item['name']]);                // on separe ce qu'il y a en base dans un tableau $things
82            foreach($things as $thing)                                      // pour chaque elements du SET
83                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
84            $value = implode(", ", $translated_thing);                      // on reforme un truc affichable et on le mets dans $value
85        }
86        else
87        {
88            if(array_key_exists( $profile[$item['name']], (array)$labels['profile'][$item['name']]) )
89                $value = _($labels['profile'][$item['name']][$profile[$item['name']]]);
90            else
91                $value = $profile[$item['name']];
92                                            // par defaut, on prend le champs de $profile correspondant a la colonne courante $item['name']
93        }
94
95        $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)
96        $user['general'][$key] = _($value);                            // enfin, on attribue la valeur trouv�raduite...
97    }
98}
99else
100    error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' | '.$user_general->getUserInfo());
101
102// Recuperation du profile 'interets'
103$t_name = 'user_interests';
104$user_access['interests'] = get_access_list($url_id, $t_name); // Access List *****************************
105
106$t_fields = implode(',', array_keys($table_fields[$t_name]));
107$user_interests = $db->query('SELECT ! FROM ! WHERE id=?', array($t_fields, $t_name, $url_id) );
108
109if(!DB::isError($user_interests) )
110{
111    $table_info = $user_interests->tableInfo();                                       // Recuperation des infos de la table
112    $profile = $user_interests->FetchRow();                                           // On recupere le profil
113    foreach($table_info as $item)                                                   // Pour chaque colonne de la table
114    {
115        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'])  )  )
116            continue;
117        elseif($profile[$item['name']] == NULL || $profile[$item['name']] == "")    // Si la colonne ne contient rien, on arrete la et on passe aus suivant
118            continue;
119        elseif($item['type'] == 'date')
120        {
121            list($year, $month, $day) = explode('-', $profile[$item['name']]);
122            $date = getdate(mktime (0,0,0,$month,$day,$year));
123            $value = $date['mday'].' '._($date['month']).' '.$date['year'];
124        }
125        elseif(ereg('set', $item['flags']))                                     // Si c'est un colonne de type 'SET' (liste a choix multiples)
126        {
127            $translated_thing = array();                                    // declaration du tableau qui va recevoir les chaines traduites
128            $things = explode(',', $profile[$item['name']]);                // on separe ce qu'il y a en base dans un tableau $things
129            foreach($things as $thing)                                      // pour chaque elements du SET
130                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
131            $value = implode(", ", $translated_thing);                      // on reforme un truc affichable et on le mets dans $value
132        }
133        else
134        {
135            if(array_key_exists( $profile[$item['name']], (array)$labels['profile'][$item['name']]) )
136                $value = _($labels['profile'][$item['name']][$profile[$item['name']]]);
137            else
138                $value = $profile[$item['name']];
139                                            // par defaut, on prend le champs de $profile correspondant a la colonne courante $item['name']
140        }
141
142        $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)
143        $user['interests'][$key] = _($value);                            // enfin, on attribue la valeur trouv�raduite...
144    }
145}
146else
147    error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' | '.$user_interests->getUserInfo());
148
149// Recuperation du profile contact
150$t_name = 'user_contact';
151$user_access['contact'] = get_access_list($url_id, $t_name); // Access List *****************************
152
153$t_fields = implode(',', array_keys($table_fields[$t_name]));
154$user_contact = $db->query('SELECT ! FROM ! WHERE id=?', array($t_fields, $t_name, $url_id) );
155
156if(!DB::isError($user_contact) )
157{
158    $table_info = $user_contact->tableInfo();                                       // Recuperation des infos de la table
159    $profile = $user_contact->FetchRow();                                           // On recupere le profil
160    foreach($table_info as $item)                                                   // Pour chaque colonne de la table
161    {
162        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'])  )  )
163            continue;
164        elseif($profile[$item['name']] == NULL || $profile[$item['name']] == "")    // Si la colonne ne contient rien, on arrete la et on passe aus suivant
165            continue;
166        elseif($item['type'] == 'date')
167        {
168            list($year, $month, $day) = explode('-', $profile[$item['name']]);
169            $date = getdate(mktime (0,0,0,$month,$day,$year));
170            $value = $date['mday'].' '._($date['month']).' '.$date['year'];
171        }
172        elseif(ereg('set', $item['flags']))                                     // Si c'est un colonne de type 'SET' (liste a choix multiples)
173        {
174            $translated_thing = array();                                    // declaration du tableau qui va recevoir les chaines traduites
175            $things = explode(',', $profile[$item['name']]);                // on separe ce qu'il y a en base dans un tableau $things
176            foreach($things as $thing)                                      // pour chaque elements du SET
177                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
178            $value = implode(", ", $translated_thing);                      // on reforme un truc affichable et on le mets dans $value
179        }
180        else
181        {
182            if(array_key_exists( $profile[$item['name']], (array)$labels['profile'][$item['name']]) )
183                $value = _($labels['profile'][$item['name']][$profile[$item['name']]]);
184            else
185                $value = $profile[$item['name']];
186                                            // par defaut, on prend le champs de $profile correspondant a la colonne courante $item['name']
187        }
188
189        $user['contact'][$item['name']]['key'] = $table_fields['user_contact'][$item['name']];
190        $user['contact'][$item['name']]['value'] = $value;                          // enfin, on attribue la valeur trouv�raduite...
191
192    }
193}
194else
195    error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' | '.$user_contact->getUserInfo());
196
197
198// Recuperation du profil general *******************
199$t_name = 'user_professional';
200$user_access['professional'] = get_access_list($url_id, $t_name); // Access List *****************************
201
202$t_fields = implode(',', array_keys($table_fields[$t_name]));
203$user_professional = $db->query('SELECT ! FROM ! WHERE id=?', array($t_fields, $t_name, $url_id) );
204
205if(!DB::isError($user_professional) )
206{
207    $table_info = $user_professional->tableInfo();                                       // Recuperation des infos de la table
208    $profile = $user_professional->FetchRow();                                           // On recupere le profil
209    foreach($table_info as $item)                                                   // Pour chaque colonne de la table
210    {
211        if(  array_key_exists($item['name'], $user_access['professional']) && (access_weight($user_access['professional'][$item['name']]) > access_weight($user['relation_type'])  )  )
212            continue;
213        elseif($profile[$item['name']] == NULL || $profile[$item['name']] == "")    // Si la colonne ne contient rien, on arrete la et on passe aus suivant
214            continue;
215        elseif($item['type'] == 'date')
216        {
217            list($year, $month, $day) = explode('-', $profile[$item['name']]);
218            $date = getdate(mktime (0,0,0,$month,$day,$year));
219            $value = $date['mday'].' '._($date['month']).' '.$date['year'];
220        }
221        elseif(ereg('set', $item['flags']))                                     // Si c'est un colonne de type 'SET' (liste a choix multiples)
222        {
223            $translated_thing = array();                                    // declaration du tableau qui va recevoir les chaines traduites
224            $things = explode(',', $profile[$item['name']]);                // on separe ce qu'il y a en base dans un tableau $things
225            foreach($things as $thing)                                      // pour chaque elements du SET
226                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
227            $value = implode(", ", $translated_thing);                      // on reforme un truc affichable et on le mets dans $value
228        }
229        else
230        {
231            if(array_key_exists( $profile[$item['name']], (array)$labels['profile'][$item['name']]) )
232                $value = _($labels['profile'][$item['name']][$profile[$item['name']]]);
233            else
234                $value = $profile[$item['name']];
235                                            // par defaut, on prend le champs de $profile correspondant a la colonne courante $item['name']
236        }
237
238        $key = $table_fields['user_professional'][$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)
239        $user['professional'][$key] = _($value);                            // enfin, on attribue la valeur trouv�raduite...
240    }
241}
242else
243    error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' | '.$user_professional->getUserInfo());
244
245// Recuperation du profil general *******************
246$t_name = 'user_personal';
247$user_access['personal'] = get_access_list($url_id, $t_name); // Access List *****************************
248
249$t_fields = implode(',', array_keys($table_fields[$t_name]));
250$user_personal = $db->query('SELECT ! FROM ! WHERE id=?', array($t_fields, $t_name, $url_id) );
251
252if(!DB::isError($user_personal) )
253{
254    $table_info = $user_personal->tableInfo();                                       // Recuperation des infos de la table
255    $profile = $user_personal->FetchRow();                                           // On recupere le profil
256    foreach($table_info as $item)                                                   // Pour chaque colonne de la table
257    {
258        if(  array_key_exists($item['name'], $user_access['personal']) && (access_weight($user_access['personal'][$item['name']]) > access_weight($user['relation_type'])  )  )
259            continue;
260        elseif($profile[$item['name']] == NULL || $profile[$item['name']] == "")    // Si la colonne ne contient rien, on arrete la et on passe aus suivant
261            continue;
262        elseif($item['type'] == 'date')
263        {
264            list($year, $month, $day) = explode('-', $profile[$item['name']]);
265            $date = getdate(mktime (0,0,0,$month,$day,$year));
266            $value = $date['mday'].' '._($date['month']).' '.$date['year'];
267        }
268        elseif(ereg('set', $item['flags']))                                     // Si c'est un colonne de type 'SET' (liste a choix multiples)
269        {
270            $translated_thing = array();                                    // declaration du tableau qui va recevoir les chaines traduites
271            $things = explode(',', $profile[$item['name']]);                // on separe ce qu'il y a en base dans un tableau $things
272            foreach($things as $thing)                                      // pour chaque elements du SET
273                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
274            $value = implode(", ", $translated_thing);                      // on reforme un truc affichable et on le mets dans $value
275        }
276        else
277        {
278            if(array_key_exists( $profile[$item['name']], (array)$labels['profile'][$item['name']]) )
279                $value = _($labels['profile'][$item['name']][$profile[$item['name']]]);
280            else
281                $value = $profile[$item['name']];
282                                            // par defaut, on prend le champs de $profile correspondant a la colonne courante $item['name']
283        }
284
285        $key = $table_fields['user_personal'][$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)
286        $user['personal'][$key] = _($value);                            // enfin, on attribue la valeur trouv�raduite...
287    }
288}
289else
290    error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' | '.$user_personal->getUserInfo());
291
292?>
Note: See TracBrowser for help on using the browser.