Commit | Line | Data |
---|---|---|
7d8b17cb | 1 | <?php |
2 | /*************************************************************************** | |
179afa7f | 3 | * Copyright (C) 2003-2008 Polytechnique.org * |
7d8b17cb | 4 | * http://opensource.polytechnique.org/ * |
5 | * * | |
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. * | |
10 | * * | |
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. * | |
15 | * * | |
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 * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
22 | class ProfileModule extends PLModule | |
23 | { | |
24 | function handlers() | |
25 | { | |
26 | return array( | |
2398e553 SJ |
27 | 'photo' => $this->make_hook('photo', AUTH_PUBLIC), |
28 | 'photo/change' => $this->make_hook('photo_change', AUTH_MDP), | |
e49018a7 | 29 | |
2398e553 SJ |
30 | 'fiche.php' => $this->make_hook('fiche', AUTH_PUBLIC), |
31 | 'profile' => $this->make_hook('profile', AUTH_PUBLIC), | |
32 | 'profile/private' => $this->make_hook('profile', AUTH_COOKIE), | |
33 | 'profile/ax' => $this->make_hook('ax', AUTH_COOKIE, 'admin'), | |
34 | 'profile/edit' => $this->make_hook('p_edit', AUTH_MDP), | |
35 | 'profile/ajax/address' => $this->make_hook('ajax_address', AUTH_COOKIE, 'user', NO_AUTH), | |
36 | 'profile/ajax/tel' => $this->make_hook('ajax_tel', AUTH_COOKIE, 'user', NO_AUTH), | |
37 | 'profile/ajax/edu' => $this->make_hook('ajax_edu', AUTH_COOKIE, 'user', NO_AUTH), | |
38 | 'profile/ajax/medal' => $this->make_hook('ajax_medal', AUTH_COOKIE, 'user', NO_AUTH), | |
39 | 'profile/networking' => $this->make_hook('networking', AUTH_PUBLIC), | |
40 | 'profile/ajax/job' => $this->make_hook('ajax_job', AUTH_COOKIE, 'user', NO_AUTH), | |
41 | 'profile/ajax/secteur' => $this->make_hook('ajax_secteur', AUTH_COOKIE, 'user', NO_AUTH), | |
c7139c07 | 42 | 'profile/ajax/ssecteur' => $this->make_hook('ajax_ssecteur', AUTH_COOKIE, 'user', NO_AUTH), |
2398e553 SJ |
43 | 'profile/ajax/skill' => $this->make_hook('ajax_skill', AUTH_COOKIE, 'user', NO_AUTH), |
44 | 'profile/ajax/searchname' => $this->make_hook('ajax_searchname', AUTH_COOKIE, 'user', NO_AUTH), | |
f711b03f | 45 | 'javascript/education.js' => $this->make_hook('education_js', AUTH_COOKIE), |
2398e553 SJ |
46 | 'javascript/grades.js' => $this->make_hook('grades_js', AUTH_COOKIE), |
47 | 'profile/medal' => $this->make_hook('medal', AUTH_PUBLIC), | |
48 | 'profile/orange' => $this->make_hook('p_orange', AUTH_MDP), | |
49 | 'profile/usage' => $this->make_hook('p_usage', AUTH_MDP), | |
e49018a7 | 50 | |
2398e553 SJ |
51 | 'referent' => $this->make_hook('referent', AUTH_COOKIE), |
52 | 'emploi' => $this->make_hook('ref_search', AUTH_COOKIE), | |
53 | 'referent/search' => $this->make_hook('ref_search', AUTH_COOKIE), | |
54 | 'referent/ssect' => $this->make_hook('ref_sect', AUTH_COOKIE, 'user', NO_AUTH), | |
55 | 'referent/country' => $this->make_hook('ref_country', AUTH_COOKIE, 'user', NO_AUTH), | |
2f678da1 | 56 | |
2398e553 | 57 | 'groupes-x' => $this->make_hook('xnet', AUTH_COOKIE), |
926f16d7 | 58 | |
2398e553 SJ |
59 | 'vcard' => $this->make_hook('vcard', AUTH_COOKIE, 'user', NO_HTTPS), |
60 | 'admin/binets' => $this->make_hook('admin_binets', AUTH_MDP, 'admin'), | |
61 | 'admin/medals' => $this->make_hook('admin_medals', AUTH_MDP, 'admin'), | |
62 | 'admin/education' => $this->make_hook('admin_education', AUTH_MDP, 'admin'), | |
63 | 'admin/education_field' => $this->make_hook('admin_education_field', AUTH_MDP, 'admin'), | |
64 | 'admin/education_degree' => $this->make_hook('admin_education_degree', AUTH_MDP, 'admin'), | |
043bbacf | 65 | 'admin/education_degree_set' => $this->make_hook('admin_education_degree_set', AUTH_MDP, 'admin'), |
2398e553 SJ |
66 | 'admin/sections' => $this->make_hook('admin_sections', AUTH_MDP, 'admin'), |
67 | 'admin/secteurs' => $this->make_hook('admin_secteurs', AUTH_MDP, 'admin'), | |
68 | 'admin/networking' => $this->make_hook('admin_networking', AUTH_MDP, 'admin'), | |
69 | 'admin/trombino' => $this->make_hook('admin_trombino', AUTH_MDP, 'admin'), | |
70 | 'admin/ss_secteurs' => $this->make_hook('admin_ss_secteurs', AUTH_MDP, 'admin'), | |
71 | 'admin/fonctions' => $this->make_hook('admin_fonctions', AUTH_MDP, 'admin'), | |
4962a9ce SJ |
72 | 'admin/corps_enum' => $this->make_hook('admin_corps_enum', AUTH_MDP, 'admin'), |
73 | 'admin/corps_rank' => $this->make_hook('admin_corps_rank', AUTH_MDP, 'admin'), | |
92423144 | 74 | |
7d8b17cb | 75 | ); |
76 | } | |
77 | ||
e8599c21 | 78 | /* XXX COMPAT */ |
79 | function handler_fiche(&$page) | |
80 | { | |
5e2307dc | 81 | return $this->handler_profile($page, Env::v('user')); |
e8599c21 | 82 | } |
83 | ||
adbdf493 | 84 | function handler_photo(&$page, $x = null, $req = null) |
85 | { | |
954cfb01 | 86 | if (!$x || !($user = User::getSilent($x))) { |
adbdf493 | 87 | return PL_NOT_FOUND; |
88 | } | |
89 | ||
954cfb01 VZ |
90 | // Retrieve the photo and its mime type. |
91 | $photo_data = null; | |
92 | $photo_type = null; | |
adbdf493 | 93 | |
cab08090 | 94 | if ($req && S::logged()) { |
adbdf493 | 95 | include 'validations.inc.php'; |
954cfb01 VZ |
96 | $myphoto = PhotoReq::get_request($user->id()); |
97 | if ($myphoto) { | |
98 | $photo_data = $myphoto->data; | |
99 | $photo_type = $myphoto->mimetype; | |
100 | } | |
adbdf493 | 101 | } else { |
08cce2ff | 102 | $res = XDB::query( |
954cfb01 | 103 | "SELECT attachmime, attach, pub |
adbdf493 | 104 | FROM photo |
954cfb01 VZ |
105 | WHERE uid = {?}", $user->id()); |
106 | list($photo_type, $photo_data, $photo_pub) = $res->fetchOneRow(); | |
107 | if ($photo_pub != 'public' && !S::logged()) { | |
108 | $photo_type = $photo_data = null; | |
adbdf493 | 109 | } |
110 | } | |
954cfb01 VZ |
111 | |
112 | // Display the photo, or a default one when not available. | |
113 | if ($photo_type && $photo_data != null) { | |
114 | header('Content-type: image/' . $photo_type); | |
115 | echo $photo_data; | |
116 | } else { | |
117 | header('Content-type: image/png'); | |
118 | echo file_get_contents(dirname(__FILE__).'/../htdocs/images/none.png'); | |
119 | } | |
adbdf493 | 120 | exit; |
121 | } | |
122 | ||
85cc366b FB |
123 | function handler_medal(&$page, $mid) |
124 | { | |
bd6a5fe3 VZ |
125 | $thumb = ($mid == 'thumb'); |
126 | $mid = $thumb ? @func_get_arg(2) : $mid; | |
127 | ||
85cc366b FB |
128 | $res = XDB::query("SELECT img |
129 | FROM profile_medals | |
130 | WHERE id = {?}", | |
131 | $mid); | |
bd6a5fe3 VZ |
132 | $img = $thumb ? |
133 | dirname(__FILE__).'/../htdocs/images/medals/thumb/' . $res->fetchOneCell() : | |
134 | dirname(__FILE__).'/../htdocs/images/medals/' . $res->fetchOneCell(); | |
85cc366b FB |
135 | $type = mime_content_type($img); |
136 | header("Content-Type: $type"); | |
137 | echo file_get_contents($img); | |
138 | exit; | |
139 | } | |
140 | ||
40176c6c GB |
141 | function handler_networking(&$page, $mid) |
142 | { | |
143 | $res = XDB::query("SELECT icon | |
144 | FROM profile_networking_enum | |
145 | WHERE network_type = {?}", | |
146 | $mid); | |
147 | $img = dirname(__FILE__) . '/../htdocs/images/networking/' . $res->fetchOneCell(); | |
148 | $type = mime_content_type($img); | |
149 | header("Content-Type: $type"); | |
150 | echo file_get_contents($img); | |
151 | exit; | |
152 | } | |
153 | ||
fb9a56cb | 154 | function handler_photo_change(&$page) |
155 | { | |
ebfdf077 | 156 | global $globals; |
8b1f8e12 | 157 | $page->changeTpl('profile/trombino.tpl'); |
fb9a56cb | 158 | |
159 | require_once('validations.inc.php'); | |
160 | ||
54cabe90 | 161 | $trombi_x = '/home/web/trombino/photos' . S::v('promo') . '/' . S::user()->login() . '.jpg'; |
fb9a56cb | 162 | if (Env::has('upload')) { |
8827fc52 VZ |
163 | S::assert_xsrf_token(); |
164 | ||
954cfb01 | 165 | $upload = new PlUpload(S::user()->login(), 'photo'); |
abe7e055 | 166 | if (!$upload->upload($_FILES['userfile']) && !$upload->download(Env::v('photo'))) { |
a7d35093 | 167 | $page->trigError('Une erreur est survenue lors du téléchargement du fichier'); |
abe7e055 | 168 | } else { |
5daf68f6 | 169 | $myphoto = new PhotoReq(S::user(), $upload); |
abe7e055 | 170 | if ($myphoto->isValid()) { |
171 | $myphoto->submit(); | |
fb9a56cb | 172 | } |
fb9a56cb | 173 | } |
174 | } elseif (Env::has('trombi')) { | |
8827fc52 VZ |
175 | S::assert_xsrf_token(); |
176 | ||
954cfb01 | 177 | $upload = new PlUpload(S::user()->login(), 'photo'); |
abe7e055 | 178 | if ($upload->copyFrom($trombi_x)) { |
5daf68f6 | 179 | $myphoto = new PhotoReq(S::user(), $upload); |
abe7e055 | 180 | if ($myphoto->isValid()) { |
181 | $myphoto->commit(); | |
182 | $myphoto->clean(); | |
183 | } | |
fb9a56cb | 184 | } |
5e2307dc | 185 | } elseif (Env::v('suppr')) { |
8827fc52 VZ |
186 | S::assert_xsrf_token(); |
187 | ||
84868ee9 FB |
188 | XDB::execute('DELETE FROM photo |
189 | WHERE uid = {?}', | |
190 | S::v('uid')); | |
191 | XDB::execute('DELETE FROM requests | |
192 | WHERE user_id = {?} AND type="photo"', | |
193 | S::v('uid')); | |
ebfdf077 | 194 | $globals->updateNbValid(); |
5e2307dc | 195 | } elseif (Env::v('cancel')) { |
8827fc52 VZ |
196 | S::assert_xsrf_token(); |
197 | ||
84868ee9 FB |
198 | $sql = XDB::query('DELETE FROM requests |
199 | WHERE user_id={?} AND type="photo"', | |
200 | S::v('uid')); | |
ebfdf077 | 201 | $globals->updateNbValid(); |
fb9a56cb | 202 | } |
203 | ||
84868ee9 FB |
204 | $sql = XDB::query('SELECT COUNT(*) |
205 | FROM requests | |
206 | WHERE user_id={?} AND type="photo"', | |
abe7e055 | 207 | S::v('uid')); |
fb9a56cb | 208 | $page->assign('submited', $sql->fetchOneCell()); |
209 | $page->assign('has_trombi_x', file_exists($trombi_x)); | |
fb9a56cb | 210 | } |
211 | ||
e8599c21 | 212 | function handler_profile(&$page, $x = null) |
213 | { | |
54cabe90 VZ |
214 | // TODO/note for upcoming developers: |
215 | // We currently maintain both $user and $login; $user is the old way of | |
216 | // obtaining information, and eventually everything will be loaded | |
217 | // through $login. That is the reason why in the template $user is named | |
218 | // $x, and $login $user (sorry for the confusion). | |
219 | ||
220 | // Determines which user to display the profile of, and retrieves basic | |
221 | // information on this user. | |
e8599c21 | 222 | if (is_null($x)) { |
223 | return PL_NOT_FOUND; | |
224 | } | |
225 | ||
efe597c5 | 226 | $login = (!is_numeric($x) || S::has_perms()) ? Profile::get($x) : null; |
344234db | 227 | if (!$login) { |
efe597c5 FB |
228 | if (S::logged()) { |
229 | $page->trigError($x . ' inconnu dans l\'annuaire'); | |
230 | } | |
344234db | 231 | return PL_NOT_FOUND; |
e8599c21 | 232 | } |
e8599c21 | 233 | |
54cabe90 VZ |
234 | // Now that we know this is the profile of an existing user, we can |
235 | // switch to the appropriate template. | |
b13048df | 236 | $page->changeTpl('profile/profile.tpl', SIMPLE); |
54cabe90 | 237 | require_once 'user.func.inc.php'; |
e8599c21 | 238 | |
54cabe90 VZ |
239 | // Determines the access level at which the profile will be displayed. |
240 | if (!S::logged() || Env::v('view') == 'public') { | |
241 | $view = 'public'; | |
242 | } else if (S::logged() && Env::v('view') == 'ax') { | |
243 | $view = 'ax'; | |
e8599c21 | 244 | } else { |
54cabe90 | 245 | $view = 'private'; |
e8599c21 | 246 | } |
247 | ||
54cabe90 VZ |
248 | // Determines is the user is registered, and fetches the user infos in |
249 | // the appropriate way. | |
344234db VZ |
250 | $res = XDB::query("SELECT perms IN ('admin','user','disabled') |
251 | FROM auth_user_md5 | |
252 | WHERE user_id = {?}", $login->id()); | |
54cabe90 VZ |
253 | if ($res->fetchOneCell()) { |
254 | $new = Env::v('modif') == 'new'; | |
efe597c5 | 255 | $user = get_user_details($login->hrid(), S::v('uid'), $view); |
54cabe90 VZ |
256 | } else { |
257 | $new = false; | |
258 | $user = array(); | |
ba25f663 | 259 | if (S::logged()) { |
efe597c5 | 260 | pl_redirect('marketing/public/' . $login->hrid()); |
ba25f663 | 261 | } |
e8599c21 | 262 | } |
ba25f663 | 263 | |
54cabe90 | 264 | // Profile view are logged. |
e31c1c3e | 265 | if (S::logged()) { |
efe597c5 | 266 | S::logger()->log('view_profile', $login->hrid()); |
e8599c21 | 267 | } |
268 | ||
54cabe90 VZ |
269 | // Sets the title of the html page. |
270 | $page->setTitle($login->fullName()); | |
e8599c21 | 271 | |
54cabe90 | 272 | // Prepares the display of the user's mugshot. |
efe597c5 | 273 | $photo = 'photo/' . $login->hrid() . ($new ? '/req' : ''); |
54cabe90 VZ |
274 | if (!isset($user['photo_pub']) || !has_user_right($user['photo_pub'], $view)) { |
275 | $photo = ""; | |
276 | } | |
277 | $page->assign('photo_url', $photo); | |
e8599c21 | 278 | |
2f678da1 | 279 | if (!isset($user['y']) and !isset($user['x'])) { |
e8599c21 | 280 | list($user['x'], $user['y']) = getimagesize("images/none.png"); |
281 | } | |
2f678da1 | 282 | if (!isset($user['y']) or $user['y'] < 1) $user['y']=1; |
283 | if (!isset($user['x']) or $user['x'] < 1) $user['x']=1; | |
284 | if ($user['x'] > 240) { | |
e8599c21 | 285 | $user['y'] = (integer)($user['y']*240/$user['x']); |
286 | $user['x'] = 240; | |
287 | } | |
2f678da1 | 288 | if ($user['y'] > 300) { |
e8599c21 | 289 | $user['x'] = (integer)($user['x']*300/$user['y']); |
290 | $user['y'] = 300; | |
291 | } | |
2f678da1 | 292 | if ($user['x'] < 160) { |
e8599c21 | 293 | $user['y'] = (integer)($user['y']*160/$user['x']); |
294 | $user['x'] = 160; | |
295 | } | |
296 | ||
54cabe90 VZ |
297 | // Determines and displays the virtual alias. |
298 | global $globals; | |
efe597c5 FB |
299 | $owner = $login->owner(); |
300 | if ($owner) { | |
301 | $page->assign('virtualalias', $owner->emailAlias()); | |
302 | } | |
54cabe90 VZ |
303 | |
304 | // Adds miscellaneous properties to the display. | |
305 | // Adds the global user property array to the display. | |
306 | $page->assign_by_ref('x', $user); | |
efe597c5 | 307 | $page->assign_by_ref('user', $owner); |
54cabe90 | 308 | $page->assign('logged', has_user_right('private', $view)); |
24f4c06a | 309 | $page->assign('view', $view); |
e8599c21 | 310 | |
c99ef281 | 311 | $page->addJsLink('close_on_esc.js'); |
54cabe90 VZ |
312 | if (isset($user['date'])) { |
313 | header('Last-Modified: ' . date('r', strtotime($user['date']))); | |
314 | } | |
e8599c21 | 315 | } |
316 | ||
5122b820 | 317 | function handler_ax(&$page, $user = null) |
318 | { | |
34ca2048 | 319 | $user = User::get($user); |
5122b820 | 320 | if (!$user) { |
321 | return PL_NOT_FOUND; | |
322 | } | |
34ca2048 VZ |
323 | |
324 | $res = XDB::query("SELECT matricule_ax | |
325 | FROM auth_user_md5 | |
326 | WHERE user_id = {?}", $user->id()); | |
5122b820 | 327 | $mat = $res->fetchOneCell(); |
328 | if (!intval($mat)) { | |
34ca2048 | 329 | $page->kill("Le matricule AX de {$user->login()} est inconnu"); |
5122b820 | 330 | } |
331 | http_redirect("http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&anc_id=$mat"); | |
332 | } | |
333 | ||
46ae38a9 | 334 | function handler_p_edit(&$page, $opened_tab = null, $mode = null) |
2f678da1 | 335 | { |
336 | global $globals; | |
337 | ||
e1635d16 FB |
338 | // AX Synchronization |
339 | require_once 'synchro_ax.inc.php'; | |
2f678da1 | 340 | if (is_ax_key_missing()) { |
341 | $page->assign('no_private_key', true); | |
342 | } | |
5e2307dc | 343 | if (Env::v('synchro_ax') == 'confirm' && !is_ax_key_missing()) { |
b3bf7395 | 344 | ax_synchronize(S::user()->login(), S::v('uid')); |
a7d35093 | 345 | $page->trigSuccess('Ton profil a été synchronisé avec celui du site polytechniciens.com'); |
2f678da1 | 346 | } |
347 | ||
7bff4cb0 | 348 | // Build the page |
c6a7beb2 | 349 | $page->addJsLink('ajax.js'); |
f711b03f | 350 | $page->addJsLink('education.js'); |
46ae38a9 | 351 | $page->addJsLink('grades.js'); |
16594a1a | 352 | $page->addJsLink('profile.js'); |
4b4b4b67 | 353 | $page->addJsLink('jquery.autocomplete.js'); |
6d20fb1d | 354 | $wiz = new PlWizard('Profil', PlPage::getCoreTpl('plwizard.tpl'), true, true); |
460d8f55 | 355 | $this->load('page.inc.php'); |
e1635d16 | 356 | $wiz->addPage('ProfileGeneral', 'Général', 'general'); |
0b14f91d | 357 | $wiz->addPage('ProfileAddresses', 'Adresses personnelles', 'adresses'); |
e1635d16 | 358 | $wiz->addPage('ProfileGroups', 'Groupes X - Binets', 'poly'); |
a7c28fff | 359 | $wiz->addPage('ProfileDecos', 'Décorations - Medailles', 'deco'); |
3950bc21 | 360 | $wiz->addPage('ProfileJobs', 'Informations professionnelles', 'emploi'); |
e1635d16 FB |
361 | $wiz->addPage('ProfileSkills', 'Compétences diverses', 'skill'); |
362 | $wiz->addPage('ProfileMentor', 'Mentoring', 'mentor'); | |
46ae38a9 | 363 | $wiz->apply($page, 'profile/edit', $opened_tab, $mode); |
35aedff2 | 364 | |
7bff4cb0 FB |
365 | // Misc checks |
366 | $res = XDB::query("SELECT user_id | |
367 | FROM auth_user_md5 | |
368 | WHERE user_id = {?} AND naissance = '0000-00-00'", S::i('uid')); | |
369 | if ($res->numRows()) { | |
a7d35093 | 370 | $page->trigWarning("Ta date de naissance n'est pas renseignée, ce qui t'empêcheras de réaliser" |
7bff4cb0 FB |
371 | . " la procédure de récupération de mot de passe si un jour tu le perdais"); |
372 | } | |
373 | ||
46f272fe | 374 | $page->setTitle('Mon Profil'); |
2f678da1 | 375 | } |
376 | ||
f711b03f | 377 | function handler_education_js(&$page) |
46ae38a9 FB |
378 | { |
379 | header('Content-Type: text/javascript; charset=utf-8'); | |
380 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | |
381 | header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT'); | |
382 | header('Cache-Control: no-cache, must-revalidate'); | |
383 | header('Pragma: no-cache'); | |
f711b03f SJ |
384 | $page->changeTpl('profile/education.js.tpl', NO_SKIN); |
385 | require_once "education.func.inc.php"; | |
46ae38a9 FB |
386 | } |
387 | ||
388 | function handler_grades_js(&$page) | |
389 | { | |
390 | header('Content-Type: text/javascript; charset=utf-8'); | |
391 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | |
392 | header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT'); | |
393 | header('Cache-Control: no-cache, must-revalidate'); | |
394 | header('Pragma: no-cache'); | |
395 | $page->changeTpl('profile/grades.js.tpl', NO_SKIN); | |
396 | $res = XDB::iterator("SELECT * | |
397 | FROM profile_medals_grades | |
398 | ORDER BY mid, pos"); | |
399 | $grades = array(); | |
400 | while ($tmp = $res->next()) { | |
401 | $grades[$tmp['mid']][] = $tmp; | |
402 | } | |
403 | $page->assign('grades', $grades); | |
404 | ||
405 | $res = XDB::iterator("SELECT *, FIND_IN_SET('validation', flags) AS validate | |
406 | FROM profile_medals | |
407 | ORDER BY type, text"); | |
408 | $mlist = array(); | |
409 | while ($tmp = $res->next()) { | |
410 | $mlist[$tmp['type']][] = $tmp; | |
411 | } | |
412 | $page->assign('medal_list', $mlist); | |
413 | } | |
414 | ||
c6a7beb2 FB |
415 | function handler_ajax_address(&$page, $adid) |
416 | { | |
46ae38a9 | 417 | header('Content-Type: text/html; charset=utf-8'); |
c6a7beb2 FB |
418 | $page->changeTpl('profile/adresses.address.tpl', NO_SKIN); |
419 | $page->assign('i', $adid); | |
420 | $page->assign('adr', array()); | |
c6a7beb2 FB |
421 | } |
422 | ||
bde2be3b | 423 | function handler_ajax_tel(&$page, $prefid, $prefname, $telid) |
c6a7beb2 | 424 | { |
46ae38a9 | 425 | header('Content-Type: text/html; charset=utf-8'); |
bde2be3b GB |
426 | $page->changeTpl('profile/phone.tpl', NO_SKIN); |
427 | $page->assign('prefid', $prefid); | |
428 | $page->assign('prefname', $prefname); | |
429 | $page->assign('telid', $telid); | |
c6a7beb2 | 430 | $page->assign('tel', array()); |
c6a7beb2 FB |
431 | } |
432 | ||
58acfe8b | 433 | function handler_ajax_edu(&$page, $eduid, $class) |
043bbacf SJ |
434 | { |
435 | header('Content-Type: text/html; charset=utf-8'); | |
436 | $page->changeTpl('profile/edu.tpl', NO_SKIN); | |
437 | $res = XDB::iterator("SELECT id, field | |
438 | FROM profile_education_field_enum | |
439 | ORDER BY field"); | |
440 | $page->assign('edu_fields', $res->fetchAllAssoc()); | |
441 | $page->assign('eduid', $eduid); | |
58acfe8b | 442 | $page->assign('class', $class); |
f711b03f | 443 | require_once "education.func.inc.php"; |
043bbacf SJ |
444 | } |
445 | ||
85cc366b FB |
446 | function handler_ajax_medal(&$page, $id) |
447 | { | |
46ae38a9 | 448 | header('Content-Type: text/html; charset=utf-8'); |
85cc366b FB |
449 | $page->changeTpl('profile/deco.medal.tpl', NO_SKIN); |
450 | $page->assign('id', $id); | |
451 | $page->assign('medal', array('valid' => 0, 'grade' => 0)); | |
85cc366b FB |
452 | } |
453 | ||
2dcac0f5 FB |
454 | function handler_ajax_job(&$page, $id) |
455 | { | |
46ae38a9 | 456 | header('Content-Type: text/html; charset=utf-8'); |
2dcac0f5 FB |
457 | $page->changeTpl('profile/jobs.job.tpl', NO_SKIN); |
458 | $page->assign('i', $id); | |
459 | $page->assign('job', array()); | |
2dcac0f5 | 460 | $page->assign('new', true); |
b814a8b8 SJ |
461 | $res = XDB::query("SELECT id, name AS label |
462 | FROM profile_job_sector_enum"); | |
daa66175 SJ |
463 | $page->assign('secteurs', $res->fetchAllAssoc()); |
464 | $res = XDB::query("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) AS title | |
465 | FROM fonctions_def | |
466 | ORDER BY id"); | |
467 | $page->assign('fonctions', $res->fetchAllAssoc()); | |
06a99865 SJ |
468 | require_once "emails.combobox.inc.php"; |
469 | fill_email_combobox($page); | |
2dcac0f5 FB |
470 | } |
471 | ||
c7139c07 | 472 | function handler_ajax_secteur(&$page, $id, $jobid, $jobpref, $sect, $ssect = -1) |
2dcac0f5 | 473 | { |
46ae38a9 | 474 | header('Content-Type: text/html; charset=utf-8'); |
c7139c07 SJ |
475 | $res = XDB::iterator("SELECT id, name AS label, FIND_IN_SET('optgroup', flags) AS optgroup |
476 | FROM profile_job_subsector_enum | |
477 | WHERE sectorid = {?}", $sect); | |
2dcac0f5 FB |
478 | $page->changeTpl('profile/jobs.secteur.tpl', NO_SKIN); |
479 | $page->assign('id', $id); | |
480 | $page->assign('ssecteurs', $res); | |
481 | $page->assign('sel', $ssect); | |
5fecdf6d SJ |
482 | if ($id != -1) { |
483 | $page->assign('change', 1); | |
484 | $page->assign('jobid', $jobid); | |
485 | $page->assign('jobpref', $jobpref); | |
486 | } | |
c7139c07 SJ |
487 | } |
488 | ||
489 | function handler_ajax_ssecteur(&$page, $id, $ssect, $sssect = -1) | |
490 | { | |
491 | header('Content-Type: text/html; charset=utf-8'); | |
492 | $res = XDB::iterator("SELECT id, name AS label | |
493 | FROM profile_job_subsubsector_enum | |
494 | WHERE subsectorid = {?}", $ssect); | |
495 | $page->changeTpl('profile/jobs.soussecteur.tpl', NO_SKIN); | |
496 | $page->assign('id', $id); | |
497 | $page->assign('sssecteurs', $res); | |
498 | $page->assign('sel', $sssect); | |
2dcac0f5 FB |
499 | } |
500 | ||
f25e1a56 FB |
501 | function handler_ajax_skill(&$page, $cat, $id) |
502 | { | |
46ae38a9 | 503 | header('Content-Type: text/html; charset=utf-8'); |
f25e1a56 | 504 | $page->changeTpl('profile/skill.skill.tpl', NO_SKIN); |
f25e1a56 FB |
505 | $page->assign('cat', $cat); |
506 | $page->assign('id', $id); | |
507 | if ($cat == 'competences') { | |
508 | $page->assign('levels', array('initié' => 'initié', | |
509 | 'bonne connaissance' => 'bonne connaissance', | |
510 | 'expert' => 'expert')); | |
511 | } else { | |
512 | $page->assign('levels', array(1 => 'connaissance basique', | |
513 | 2 => 'maîtrise des bases', | |
514 | 3 => 'maîtrise limitée', | |
515 | 4 => 'maîtrise générale', | |
516 | 5 => 'bonne maîtrise', | |
517 | 6 => 'maîtrise complète')); | |
518 | } | |
519 | } | |
520 | ||
b04882ff PC |
521 | function handler_ajax_searchname(&$page, $snid) |
522 | { | |
523 | header('Content-Type: text/html; charset=utf-8'); | |
524 | $page->changeTpl('profile/general.searchname.tpl', NO_SKIN); | |
525 | $page->assign('i', $snid); | |
526 | $page->assign('sn', array()); | |
527 | $page->assign('newsn', true); | |
528 | } | |
529 | ||
9b0fa329 | 530 | function handler_p_orange(&$page) |
531 | { | |
8b1f8e12 | 532 | $page->changeTpl('profile/orange.tpl'); |
9b0fa329 | 533 | |
534 | require_once 'validations.inc.php'; | |
9b0fa329 | 535 | |
d1319488 | 536 | $res = XDB::query("SELECT e.entry_year, e.grad_year, d.promo, FIND_IN_SET('femme', u.flags) AS sexe |
fb2c09c9 | 537 | FROM auth_user_md5 AS u |
d1319488 | 538 | INNER JOIN profile_display AS d ON (d.pid = u.user_id) |
fb2c09c9 SJ |
539 | INNER JOIN profile_education AS e ON (e.uid = u.user_id AND FIND_IN_SET('primary', e.flags)) |
540 | WHERE u.user_id = {?}", S::v('uid')); | |
9b0fa329 | 541 | |
fb2c09c9 | 542 | list($promo, $promo_sortie_old, $promo_display, $sexe) = $res->fetchOneRow(); |
9b0fa329 | 543 | $page->assign('promo_sortie_old', $promo_sortie_old); |
fb2c09c9 SJ |
544 | $page->assign('promo', $promo); |
545 | $page->assign('promo_display', $promo_display); | |
546 | $page->assign('sexe', $sexe); | |
9b0fa329 | 547 | |
548 | if (!Env::has('promo_sortie')) { | |
fd8f77de | 549 | return; |
8827fc52 VZ |
550 | } else { |
551 | S::assert_xsrf_token(); | |
9b0fa329 | 552 | } |
553 | ||
5e2307dc | 554 | $promo_sortie = Env::i('promo_sortie'); |
9b0fa329 | 555 | |
556 | if ($promo_sortie < 1000 || $promo_sortie > 9999) { | |
fb2c09c9 | 557 | $page->trigError('L\'année de sortie doit être un nombre de quatre chiffres.'); |
9b0fa329 | 558 | } |
559 | elseif ($promo_sortie < $promo + 3) { | |
fb2c09c9 | 560 | $page->trigError('Trop tôt !'); |
9b0fa329 | 561 | } |
562 | elseif ($promo_sortie == $promo_sortie_old) { | |
a7d35093 | 563 | $page->trigWarning('Tu appartiens déjà à la promotion correspondante à cette année de sortie.'); |
9b0fa329 | 564 | } |
565 | elseif ($promo_sortie == $promo + 3) { | |
fb2c09c9 SJ |
566 | XDB::execute("UPDATE profile_education |
567 | SET grad_year = {?} | |
568 | WHERE uid = {?} AND FIND_IN_SET('primary', flags)", $promo_sortie, S::v('uid')); | |
a7d35093 | 569 | $page->trigSuccess('Ton statut "orange" a été supprimé.'); |
9b0fa329 | 570 | $page->assign('promo_sortie_old', $promo_sortie); |
571 | } | |
572 | else { | |
573 | $page->assign('promo_sortie', $promo_sortie); | |
574 | ||
575 | if (Env::has('submit')) { | |
5daf68f6 | 576 | $myorange = new OrangeReq(S::user(), $promo_sortie); |
9b0fa329 | 577 | $myorange->submit(); |
578 | $page->assign('myorange', $myorange); | |
579 | } | |
580 | } | |
9b0fa329 | 581 | } |
582 | ||
2f678da1 | 583 | function handler_referent(&$page, $x = null) |
28e16d4d | 584 | { |
28e16d4d | 585 | require_once 'user.func.inc.php'; |
8b1f8e12 | 586 | $page->changeTpl('profile/fiche_referent.tpl', SIMPLE); |
28e16d4d | 587 | |
b3bf7395 VZ |
588 | $user = User::get($x); |
589 | if ($user == null) { | |
28e16d4d | 590 | return PL_NOT_FOUND; |
591 | } | |
592 | ||
b3bf7395 VZ |
593 | $res = XDB::query("SELECT cv FROM auth_user_md5 WHERE user_id = {?}", $user->id()); |
594 | $cv = $res->fetchOneCell(); | |
28e16d4d | 595 | |
b3bf7395 VZ |
596 | $page->assign_by_ref('user', $user); |
597 | $page->assign('cv', MiniWiki::WikiToHTML($cv, true)); | |
598 | $page->assign('adr_pro', get_user_details_pro($user->id())); | |
28e16d4d | 599 | |
600 | ///// recuperations infos referent | |
601 | ||
602 | //expertise | |
5fecdf6d | 603 | $res = XDB::query("SELECT expertise FROM profile_mentor WHERE uid = {?}", $user->id()); |
28e16d4d | 604 | $page->assign('expertise', $res->fetchOneCell()); |
605 | ||
606 | //secteurs | |
607 | $secteurs = $ss_secteurs = Array(); | |
08cce2ff | 608 | $res = XDB::iterRow( |
f926f2b8 | 609 | "SELECT s.name AS label, ss.name AS label |
5fecdf6d SJ |
610 | FROM profile_mentor_sector AS m |
611 | LEFT JOIN profile_job_sector_enum AS s ON(m.sectorid = s.id) | |
612 | LEFT JOIN profile_job_subsector_enum AS ss ON(m.sectorid = ss.sectorid AND m.subsectorid = ss.id) | |
b3bf7395 | 613 | WHERE uid = {?}", $user->id()); |
28e16d4d | 614 | while (list($sec, $ssec) = $res->next()) { |
615 | $secteurs[] = $sec; | |
616 | $ss_secteurs[] = $ssec; | |
617 | } | |
618 | $page->assign_by_ref('secteurs', $secteurs); | |
619 | $page->assign_by_ref('ss_secteurs', $ss_secteurs); | |
620 | ||
621 | //pays | |
08cce2ff | 622 | $res = XDB::query( |
28e16d4d | 623 | "SELECT gp.pays |
5fecdf6d SJ |
624 | FROM profile_mentor_country AS m |
625 | LEFT JOIN geoloc_pays AS gp ON (m.country = gp.a2) | |
b3bf7395 | 626 | WHERE uid = {?}", $user->id()); |
28e16d4d | 627 | $page->assign('pays', $res->fetchColumn()); |
628 | ||
c99ef281 | 629 | $page->addJsLink('close_on_esc.js'); |
28e16d4d | 630 | } |
631 | ||
ff3eb9b7 | 632 | function handler_ref_search(&$page, $action = null, $subaction = null) |
2f678da1 | 633 | { |
8f201b69 FB |
634 | $wp = new PlWikiPage('Docs.Emploi'); |
635 | $wp->buildCache(); | |
636 | ||
46f272fe | 637 | $page->setTitle('Conseil Pro'); |
2f678da1 | 638 | |
2f678da1 | 639 | //recuperation des noms de secteurs |
5fecdf6d | 640 | $res = XDB::iterRow("SELECT id, name AS label FROM profile_job_sector_enum"); |
2f678da1 | 641 | $secteurs[''] = ''; |
642 | while (list($tmp_id, $tmp_label) = $res->next()) { | |
643 | $secteurs[$tmp_id] = $tmp_label; | |
644 | } | |
645 | $page->assign_by_ref('secteurs', $secteurs); | |
646 | ||
2f678da1 | 647 | // nb de mentors |
5fecdf6d | 648 | $res = XDB::query("SELECT count(*) FROM profile_mentor"); |
2f678da1 | 649 | $page->assign('mentors_number', $res->fetchOneCell()); |
650 | ||
2f678da1 | 651 | // On vient d'un formulaire |
ff3eb9b7 | 652 | $where = array(); |
653 | $pays_sel = XDB::escape(Env::v('pays_sel')); | |
654 | $secteur_sel = XDB::escape(Env::v('secteur')); | |
655 | $ss_secteur_sel = XDB::escape(Env::v('ss_secteur')); | |
656 | $expertise_champ = XDB::escape(Env::v('expertise')); | |
657 | ||
658 | if ($pays_sel != "''") { | |
5fecdf6d | 659 | $where[] = "mp.country = $pays_sel"; |
ff3eb9b7 | 660 | } |
661 | if ($secteur_sel != "''") { | |
5fecdf6d | 662 | $where[] = "ms.sectorid = $secteur_sel"; |
ff3eb9b7 | 663 | if ($ss_secteur_sel != "''") { |
5fecdf6d | 664 | $where[] = "ms.subsectorid = $ss_secteur_sel"; |
2f678da1 | 665 | } |
666 | } | |
ff3eb9b7 | 667 | if ($expertise_champ != "''") { |
668 | $where[] = "MATCH(m.expertise) AGAINST($expertise_champ)"; | |
2f678da1 | 669 | } |
670 | ||
671 | if ($where) { | |
672 | $where = join(' AND ', $where); | |
673 | ||
5fecdf6d SJ |
674 | $set = new UserSet("INNER JOIN profile_mentor AS m ON (m.uid = u.user_id) |
675 | LEFT JOIN profile_mentor_country AS mp ON (mp.uid = m.uid) | |
676 | LEFT JOIN profile_mentor_sector AS ms ON (ms.uid = m.uid)", | |
ff3eb9b7 | 677 | $where); |
678 | $set->addMod('mentor', 'Référents'); | |
679 | $set->apply('referent/search', $page, $action, $subaction); | |
680 | if ($set->count() > 100) { | |
e1635d16 | 681 | $page->assign('recherche_trop_large', true); |
2f678da1 | 682 | } |
ff3eb9b7 | 683 | } |
e1635d16 | 684 | $page->changeTpl('profile/referent.tpl'); |
ff3eb9b7 | 685 | } |
2f678da1 | 686 | |
e1635d16 | 687 | function handler_ref_sect(&$page, $sect) |
ff3eb9b7 | 688 | { |
689 | header('Content-Type: text/html; charset=utf-8'); | |
05cb05c0 | 690 | $page->changeTpl('include/field.select.tpl', NO_SKIN); |
ff3eb9b7 | 691 | $page->assign('onchange', 'setSSecteurs()'); |
692 | $page->assign('id', 'ssect_field'); | |
693 | $page->assign('name', 'ss_secteur'); | |
5fecdf6d SJ |
694 | $it = XDB::iterator("SELECT id, name AS field |
695 | FROM profile_job_subsector_enum | |
696 | WHERE sectorid = {?}", $sect); | |
ff3eb9b7 | 697 | $page->assign('list', $it); |
698 | } | |
2f678da1 | 699 | |
ff3eb9b7 | 700 | function handler_ref_country(&$page, $sect, $ssect = '') |
701 | { | |
702 | header('Content-Type: text/html; charset=utf-8'); | |
05cb05c0 | 703 | $page->changeTpl('include/field.select.tpl', NO_SKIN); |
ff3eb9b7 | 704 | $page->assign('name', 'pays_sel'); |
5fecdf6d | 705 | $where = ($ssect ? ' AND ms.subsectorid = {?}' : ''); |
ff3eb9b7 | 706 | $it = XDB::iterator("SELECT a2 AS id, pays AS field |
5fecdf6d SJ |
707 | FROM geoloc_pays AS g |
708 | INNER JOIN profile_mentor_country AS mp ON (mp.country = g.a2) | |
709 | INNER JOIN profile_mentor_sector AS ms ON (ms.uid = mp.uid) | |
710 | WHERE ms.sectorid = {?} $where | |
711 | GROUP BY a2 | |
712 | ORDER BY pays", $sect, $ssect); | |
ff3eb9b7 | 713 | $page->assign('list', $it); |
2f678da1 | 714 | } |
715 | ||
926f16d7 | 716 | function handler_p_usage(&$page) |
717 | { | |
8b1f8e12 | 718 | $page->changeTpl('profile/nomusage.tpl'); |
926f16d7 | 719 | |
720 | require_once 'validations.inc.php'; | |
926f16d7 | 721 | |
08cce2ff | 722 | $res = XDB::query( |
2f678da1 | 723 | "SELECT u.nom, u.nom_usage, u.flags, e.alias |
926f16d7 | 724 | FROM auth_user_md5 AS u |
2f678da1 | 725 | LEFT JOIN aliases AS e ON(u.user_id = e.id |
726 | AND FIND_IN_SET('usage', e.flags)) | |
cab08090 | 727 | WHERE user_id={?}", S::v('uid')); |
926f16d7 | 728 | |
2f678da1 | 729 | list($nom, $usage_old, $flags, $alias_old) = $res->fetchOneRow(); |
113f6de8 | 730 | $flags = new PlFlagSet($flags); |
926f16d7 | 731 | $page->assign('usage_old', $usage_old); |
732 | $page->assign('alias_old', $alias_old); | |
733 | ||
e1635d16 | 734 | $nom_usage = replace_accent(trim(Env::v('nom_usage'))); |
926f16d7 | 735 | $nom_usage = strtoupper($nom_usage); |
736 | $page->assign('usage_req', $nom_usage); | |
737 | ||
738 | if (Env::has('submit') && ($nom_usage != $usage_old)) { | |
8827fc52 VZ |
739 | S::assert_xsrf_token(); |
740 | ||
926f16d7 | 741 | // on vient de recevoir une requete, differente de l'ancien nom d'usage |
742 | if ($nom_usage == $nom) { | |
44b071c2 SJ |
743 | $page->trigWarning('Le nom d\'usage que tu demandes est identique à ton nom à l\'X, ' |
744 | . 'aucune modification n\'a donc été effectuée.'); | |
926f16d7 | 745 | $page->assign('same', true); |
a7de4ef7 | 746 | } else { // le nom de mariage est distinct du nom à l'X |
926f16d7 | 747 | // on calcule l'alias pour l'afficher |
5e2307dc | 748 | $reason = Env::v('reason'); |
926f16d7 | 749 | if ($reason == 'other') { |
5e2307dc | 750 | $reason = Env::v('other_reason'); |
926f16d7 | 751 | } |
5daf68f6 | 752 | $myusage = new UsageReq(S::user(), $nom_usage, $reason); |
926f16d7 | 753 | $myusage->submit(); |
754 | $page->assign('myusage', $myusage); | |
755 | } | |
756 | } | |
926f16d7 | 757 | } |
758 | ||
a1d79217 | 759 | function handler_xnet(&$page) |
760 | { | |
8b1f8e12 | 761 | $page->changeTpl('profile/groupesx.tpl'); |
46f272fe | 762 | $page->setTitle('Promo, Groupes X, Binets'); |
e1635d16 | 763 | |
a1d79217 | 764 | $req = XDB::query(' |
e1635d16 | 765 | SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo, |
46e1d3ba | 766 | COUNT(e.eid) AS events, mail_domain AS lists |
e1635d16 | 767 | FROM groupex.membres AS m |
46e1d3ba | 768 | INNER JOIN groupex.asso AS a ON(m.asso_id = a.id) |
769 | LEFT JOIN groupex.evenements AS e ON(e.asso_id = m.asso_id AND e.archive = 0) | |
770 | WHERE uid = {?} GROUP BY m.asso_id ORDER BY a.nom', S::i('uid')); | |
a1d79217 | 771 | $page->assign('assos', $req->fetchAllAssoc()); |
772 | } | |
e1635d16 | 773 | |
e49018a7 | 774 | function handler_vcard(&$page, $x = null) |
775 | { | |
776 | if (is_null($x)) { | |
777 | return PL_NOT_FOUND; | |
778 | } | |
779 | ||
780 | global $globals; | |
781 | ||
782 | if (substr($x, -4) == '.vcf') { | |
783 | $x = substr($x, 0, strlen($x) - 4); | |
784 | } | |
785 | ||
5d42c993 FB |
786 | $vcard = new VCard(); |
787 | $vcard->addUser($x); | |
788 | $vcard->show(); | |
e49018a7 | 789 | } |
92423144 | 790 | |
54cabe90 | 791 | function handler_admin_trombino(&$page, $login = null, $action = null) { |
8b1f8e12 | 792 | $page->changeTpl('profile/admin_trombino.tpl'); |
46f272fe | 793 | $page->setTitle('Administration - Trombino'); |
e1635d16 | 794 | |
54cabe90 VZ |
795 | if (!$login || !($user = User::get($login))) { |
796 | return PL_NOT_FOUND; | |
797 | } else { | |
798 | $page->assign_by_ref('user', $user); | |
799 | } | |
e1635d16 | 800 | |
92423144 | 801 | switch ($action) { |
92423144 | 802 | case "original": |
803 | header("Content-type: image/jpeg"); | |
54cabe90 | 804 | readfile("/home/web/trombino/photos" . $user->promo() . "/" . $user->login() . ".jpg"); |
92423144 | 805 | exit; |
806 | break; | |
e1635d16 | 807 | |
92423144 | 808 | case "new": |
8827fc52 VZ |
809 | S::assert_xsrf_token(); |
810 | ||
92423144 | 811 | $data = file_get_contents($_FILES['userfile']['tmp_name']); |
812 | list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']); | |
813 | $mimetype = substr($_FILES['userfile']['type'], 6); | |
814 | unlink($_FILES['userfile']['tmp_name']); | |
815 | XDB::execute( | |
816 | "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}", | |
54cabe90 | 817 | $user->id(), $mimetype, $data, $x, $y); |
92423144 | 818 | break; |
e1635d16 | 819 | |
92423144 | 820 | case "delete": |
8827fc52 VZ |
821 | S::assert_xsrf_token(); |
822 | ||
54cabe90 | 823 | XDB::execute('DELETE FROM photo WHERE uid = {?}', $user->id()); |
92423144 | 824 | break; |
825 | } | |
92423144 | 826 | } |
827 | function handler_admin_binets(&$page, $action = 'list', $id = null) { | |
46f272fe | 828 | $page->setTitle('Administration - Binets'); |
92423144 | 829 | $page->assign('title', 'Gestion des binets'); |
830 | $table_editor = new PLTableEditor('admin/binets', 'binets_def', 'id'); | |
831 | $table_editor->add_join_table('binets_ins','binet_id',true); | |
a7de4ef7 | 832 | $table_editor->describe('text','intitulé',true); |
92423144 | 833 | $table_editor->apply($page, $action, $id); |
834 | } | |
043bbacf | 835 | function handler_admin_education(&$page, $action = 'list', $id = null) { |
46f272fe | 836 | $page->setTitle('Administration - Formations'); |
92423144 | 837 | $page->assign('title', 'Gestion des formations'); |
043bbacf SJ |
838 | $table_editor = new PLTableEditor('admin/education', 'profile_education_enum', 'id'); |
839 | $table_editor->add_join_table('profile_education', 'eduid', true); | |
840 | $table_editor->add_join_table('profile_education_degree', 'eduid', true); | |
841 | $table_editor->describe('name', 'intitulé', true); | |
842 | $table_editor->describe('url', 'site web', false); | |
843 | $table_editor->apply($page, $action, $id); | |
844 | } | |
845 | function handler_admin_education_field(&$page, $action = 'list', $id = null) { | |
846 | $page->setTitle('Administration - Domaines de formation'); | |
847 | $page->assign('title', 'Gestion des domaines de formation'); | |
848 | $table_editor = new PLTableEditor('admin/education_field', 'profile_education_field_enum', 'id', true); | |
849 | $table_editor->add_join_table('profile_education', 'fieldid', true); | |
850 | $table_editor->describe('field', 'domaine', true); | |
851 | $table_editor->apply($page, $action, $id); | |
852 | } | |
853 | function handler_admin_education_degree(&$page, $action = 'list', $id = null) { | |
854 | $page->setTitle('Administration - Niveau de formation'); | |
855 | $page->assign('title', 'Gestion des niveau de formation'); | |
856 | $table_editor = new PLTableEditor('admin/education_degree', 'profile_education_degree_enum', 'id', true); | |
857 | $table_editor->add_join_table('profile_education_degree', 'degreeid', true); | |
858 | $table_editor->add_join_table('profile_education', 'degreeid', true); | |
859 | $table_editor->describe('degree', 'niveau', true); | |
860 | $table_editor->apply($page, $action, $id); | |
861 | } | |
862 | function handler_admin_education_degree_set(&$page, $action = 'list', $id = null) { | |
863 | $page->setTitle('Administration - Correspondances formations - niveau de formation'); | |
864 | $page->assign('title', 'Gestion des correspondances formations - niveau de formation'); | |
865 | $table_editor = new PLTableEditor('admin/education_degree_set', 'profile_education_degree', 'eduid', true); | |
866 | $table_editor->describe('eduid', 'formation', true); | |
867 | $table_editor->describe('degreeid', 'niveau', true); | |
92423144 | 868 | $table_editor->apply($page, $action, $id); |
e1635d16 | 869 | } |
b09690be | 870 | function handler_admin_sections(&$page, $action = 'list', $id = null) { |
46f272fe | 871 | $page->setTitle('Administration - Sections'); |
a20aab02 | 872 | $page->assign('title', 'Gestion des sections'); |
b09690be | 873 | $table_editor = new PLTableEditor('admin/sections','sections','id'); |
874 | $table_editor->describe('text','intitulé',true); | |
875 | $table_editor->apply($page, $action, $id); | |
e1635d16 | 876 | } |
a20aab02 | 877 | function handler_admin_ss_secteurs(&$page, $action = 'list', $id = null) { |
46f272fe | 878 | $page->setTitle('Administration - Sous-secteurs'); |
a20aab02 SJ |
879 | $page->assign('title', 'Gestion des sous-secteurs'); |
880 | $table_editor = new PLTableEditor('admin/ss_secteurs', 'emploi_ss_secteur', 'id', true); | |
881 | $table_editor->describe('label', 'intitulé', true); | |
882 | $table_editor->apply($page, $action, $id); | |
883 | } | |
884 | function handler_admin_fonctions(&$page, $action = 'list', $id = null) { | |
46f272fe | 885 | $page->setTitle('Administration - Fonctions'); |
a20aab02 SJ |
886 | $page->assign('title', 'Gestion des fonctions'); |
887 | $table_editor = new PLTableEditor('admin/fonctions', 'fonctions_def', 'id', true); | |
888 | $table_editor->describe('fonction_fr', 'intitulé', true); | |
889 | $table_editor->describe('fonction_en', 'intitulé (ang)', true); | |
890 | $table_editor->describe('flags', 'titre', true); | |
891 | $table_editor->apply($page, $action, $id); | |
892 | } | |
b09690be | 893 | function handler_admin_secteurs(&$page, $action = 'list', $id = null) { |
46f272fe | 894 | $page->setTitle('Administration - Secteurs'); |
a20aab02 SJ |
895 | $page->assign('title', 'Gestion des secteurs'); |
896 | $table_editor = new PLTableEditor('admin/secteurs', 'emploi_secteur', 'id', true); | |
897 | $table_editor->describe('label', 'intitulé', true); | |
b09690be | 898 | $table_editor->apply($page, $action, $id); |
e1635d16 | 899 | } |
15beefb3 GB |
900 | function handler_admin_networking(&$page, $action = 'list', $id = null) { |
901 | $page->assign('xorg_title', 'Polytechnique.org - Administration - Networking'); | |
902 | $page->assign('title', 'Gestion des types de networking'); | |
903 | $table_editor = new PLTableEditor('admin/networking', 'profile_networking_enum', 'network_type'); | |
904 | $table_editor->describe('name', 'intitulé', true); | |
905 | $table_editor->describe('icon', 'nom de l\'icône', false); | |
dc6378df GB |
906 | $table_editor->describe('filter', 'filtre', true); |
907 | $table_editor->describe('link', 'lien web', true); | |
15beefb3 GB |
908 | $table_editor->apply($page, $action, $id); |
909 | } | |
4962a9ce SJ |
910 | function handler_admin_corps_enum(&$page, $action = 'list', $id = null) { |
911 | $page->setTitle('Administration - Corps'); | |
912 | $page->assign('title', 'Gestion des Corps'); | |
913 | $table_editor = new PLTableEditor('admin/corps_enum', 'profile_corps_enum', 'id'); | |
914 | $table_editor->describe('name', 'intitulé', true); | |
915 | $table_editor->describe('abbreviation', 'abbréviation', true); | |
916 | $table_editor->describe('still_exists', 'existe encore ?', true); | |
917 | $table_editor->apply($page, $action, $id); | |
918 | } | |
919 | function handler_admin_corps_rank(&$page, $action = 'list', $id = null) { | |
920 | $page->setTitle('Administration - Grade dans les Corps'); | |
921 | $page->assign('title', 'Gestion des grade dans les Corps'); | |
922 | $table_editor = new PLTableEditor('admin/corps_rank', 'profile_corps_rank_enum', 'id'); | |
923 | $table_editor->describe('name', 'intitulé', true); | |
924 | $table_editor->describe('abbreviation', 'abbréviation', true); | |
925 | $table_editor->apply($page, $action, $id); | |
926 | } | |
92423144 | 927 | function handler_admin_medals(&$page, $action = 'list', $id = null) { |
46f272fe | 928 | $page->setTitle('Administration - Distinctions'); |
92423144 | 929 | $page->assign('title', 'Gestion des Distinctions'); |
930 | $table_editor = new PLTableEditor('admin/medals','profile_medals','id'); | |
a7de4ef7 | 931 | $table_editor->describe('text', 'intitulé', true); |
92423144 | 932 | $table_editor->describe('img', 'nom de l\'image', false); |
d02b8359 | 933 | $table_editor->describe('flags', 'valider', true); |
92423144 | 934 | $table_editor->apply($page, $action, $id); |
935 | if ($id && $action == 'edit') { | |
8b1f8e12 | 936 | $page->changeTpl('profile/admin_decos.tpl'); |
e1635d16 | 937 | |
92423144 | 938 | $mid = $id; |
e1635d16 | 939 | |
92423144 | 940 | if (Post::v('act') == 'del') { |
75a17710 FB |
941 | XDB::execute('DELETE FROM profile_medals_grades |
942 | WHERE mid={?} AND gid={?}', $mid, Post::i('gid')); | |
92423144 | 943 | } else { |
944 | foreach (Post::v('grades', array()) as $gid=>$text) { | |
154ee23a OLF |
945 | if ($gid === 0) { |
946 | if (!empty($text)) { | |
947 | $res = XDB::query('SELECT MAX(gid) | |
948 | FROM profile_medals_grades | |
949 | WHERE mid = {?}', $mid); | |
950 | $gid = $res->fetchOneCell() + 1; | |
951 | ||
952 | XDB::execute('INSERT INTO profile_medals_grades (mid, gid, text, pos) | |
953 | VALUES ({?}, {?}, {?}, {?})', | |
954 | $mid, $gid, $text, $_POST['pos']['0']); | |
955 | } | |
956 | } else { | |
957 | XDB::execute('UPDATE profile_medals_grades | |
958 | SET pos={?}, text={?} | |
959 | WHERE gid={?} AND mid={?}', $_POST['pos'][$gid], $text, $gid, $mid); | |
960 | } | |
92423144 | 961 | } |
962 | } | |
963 | $res = XDB::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid); | |
964 | $page->assign('grades', $res); | |
965 | } | |
e1635d16 | 966 | } |
7d8b17cb | 967 | } |
968 | ||
a7de4ef7 | 969 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
7d8b17cb | 970 | ?> |