2 /***************************************************************************
3 * Copyright (C) 2003-2011 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 function education_options($current = 0)
24 $html = '<option value="-1"> </option>';
25 $res = XDB
::iterator("SELECT e.id AS id, gc.country,
26 IF(CHAR_LENGTH(e.name) > 76, e.abbreviation, e.name) AS name
27 FROM profile_education_enum AS e
28 LEFT JOIN geoloc_countries AS gc ON (e.country = gc.iso_3166_1_a2)
29 WHERE EXISTS (SELECT *
30 FROM profile_education_degree AS d
31 WHERE e.id = d.eduid) AND e.name != {?}
32 ORDER BY gc.country, e.name",
35 while ($arr_edu = $res->next()) {
36 if ($arr_edu["country"] != $country) {
38 $html .= '</optgroup>';
40 $country = $arr_edu["country"];
41 $html .= '<optgroup label="' . $country . '">';
43 $html .= '<option value="' . $arr_edu["id"] . '"';
44 if ($arr_edu["id"] == $current) {
45 $html .= " selected='selected'";
47 $html .= '>' . htmlspecialchars($arr_edu["name"]) . "</option>\n";
50 $html .= '</optgroup>';
55 /** pour appeller education_options depuis smarty
57 function _education_options_smarty($params)
59 if(!isset($params['selected'])) {
60 $params['selected'] = 0;
62 return education_options($params['selected']);
64 Platal
::page()->register_function('education_options', '_education_options_smarty');
66 /** affiche un Array javascript contenant les diplômes de chaque formation
68 function education_degree()
71 $res = XDB
::iterRow("SELECT eduid, degreeid
72 FROM profile_education_degree
74 $edu_degree = $res->next();
75 for ($eduid = 1; $edu_degree; ++
$eduid) {
77 if ($edu_degree['0'] == $eduid) {
78 $html .= $edu_degree['1'];
79 $edu_degree = $res->next();
80 while ($edu_degree['0'] == $eduid) {
81 $html .= ',' . $edu_degree['1'];
82 $edu_degree = $res->next();
92 Platal
::page()->register_function('education_degree', 'education_degree');
94 /** affiche tous les types possibles de diplômes
96 function education_degree_all()
98 $res = XDB
::query("SELECT id
99 FROM profile_education_degree_enum
101 return implode(',', $res->fetchColumn());
103 Platal
::page()->register_function('education_degree_all', 'education_degree_all');
105 /** affiche les noms de tous les diplômes possibles
107 function education_degree_name()
109 $res = XDB
::query("SELECT degree
110 FROM profile_education_degree_enum
112 return '"' . implode('","', $res->fetchColumn()) . '"';
114 Platal
::page()->register_function('education_degree_name', 'education_degree_name');
116 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: