Commit | Line | Data |
---|---|---|
7d8b17cb | 1 | <?php |
2 | /*************************************************************************** | |
9f5bd98e | 3 | * Copyright (C) 2003-2010 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), | |
541e8d03 SJ |
41 | 'profile/ajax/sector' => $this->make_hook('ajax_sector', AUTH_COOKIE, 'user', NO_AUTH), |
42 | 'profile/ajax/sub_sector' => $this->make_hook('ajax_sub_sector', AUTH_COOKIE, 'user', NO_AUTH), | |
07e72582 | 43 | 'profile/ajax/alternates' => $this->make_hook('ajax_alternates', AUTH_COOKIE, 'user', NO_AUTH), |
2398e553 SJ |
44 | 'profile/ajax/skill' => $this->make_hook('ajax_skill', AUTH_COOKIE, 'user', NO_AUTH), |
45 | 'profile/ajax/searchname' => $this->make_hook('ajax_searchname', AUTH_COOKIE, 'user', NO_AUTH), | |
6e32823c | 46 | 'profile/ajax/buildnames' => $this->make_hook('ajax_buildnames', AUTH_COOKIE, 'user', NO_AUTH), |
3ac45f10 PC |
47 | 'profile/ajax/tree/jobterms' => $this->make_hook('ajax_tree_job_terms', AUTH_COOKIE, 'user', NO_AUTH), |
48 | 'profile/jobterms' => $this->make_hook('jobterms', AUTH_COOKIE, 'user', NO_AUTH), | |
f711b03f | 49 | 'javascript/education.js' => $this->make_hook('education_js', AUTH_COOKIE), |
2398e553 SJ |
50 | 'javascript/grades.js' => $this->make_hook('grades_js', AUTH_COOKIE), |
51 | 'profile/medal' => $this->make_hook('medal', AUTH_PUBLIC), | |
70c65f3a | 52 | 'profile/name_info' => $this->make_hook('name_info', AUTH_PUBLIC), |
e49018a7 | 53 | |
2398e553 SJ |
54 | 'referent' => $this->make_hook('referent', AUTH_COOKIE), |
55 | 'emploi' => $this->make_hook('ref_search', AUTH_COOKIE), | |
bac2d162 | 56 | 'jobs' => $this->make_hook('ref_search', AUTH_COOKIE), |
2398e553 SJ |
57 | 'referent/search' => $this->make_hook('ref_search', AUTH_COOKIE), |
58 | 'referent/ssect' => $this->make_hook('ref_sect', AUTH_COOKIE, 'user', NO_AUTH), | |
59 | 'referent/country' => $this->make_hook('ref_country', AUTH_COOKIE, 'user', NO_AUTH), | |
3ac45f10 | 60 | 'referent/autocomplete' => $this->make_hook('ref_autocomplete', AUTH_COOKIE, 'user', NO_AUTH), |
2f678da1 | 61 | |
2398e553 | 62 | 'groupes-x' => $this->make_hook('xnet', AUTH_COOKIE), |
1dc71da1 | 63 | 'groupes-x/logo' => $this->make_hook('xnetlogo', AUTH_PUBLIC), |
926f16d7 | 64 | |
2398e553 SJ |
65 | 'vcard' => $this->make_hook('vcard', AUTH_COOKIE, 'user', NO_HTTPS), |
66 | 'admin/binets' => $this->make_hook('admin_binets', AUTH_MDP, 'admin'), | |
67 | 'admin/medals' => $this->make_hook('admin_medals', AUTH_MDP, 'admin'), | |
68 | 'admin/education' => $this->make_hook('admin_education', AUTH_MDP, 'admin'), | |
69 | 'admin/education_field' => $this->make_hook('admin_education_field', AUTH_MDP, 'admin'), | |
70 | 'admin/education_degree' => $this->make_hook('admin_education_degree', AUTH_MDP, 'admin'), | |
043bbacf | 71 | 'admin/education_degree_set' => $this->make_hook('admin_education_degree_set', AUTH_MDP, 'admin'), |
2398e553 | 72 | 'admin/sections' => $this->make_hook('admin_sections', AUTH_MDP, 'admin'), |
2398e553 SJ |
73 | 'admin/networking' => $this->make_hook('admin_networking', AUTH_MDP, 'admin'), |
74 | 'admin/trombino' => $this->make_hook('admin_trombino', AUTH_MDP, 'admin'), | |
b6e9d1ca | 75 | 'admin/sectors' => $this->make_hook('admin_sectors', AUTH_MDP, 'admin'), |
4962a9ce SJ |
76 | 'admin/corps_enum' => $this->make_hook('admin_corps_enum', AUTH_MDP, 'admin'), |
77 | 'admin/corps_rank' => $this->make_hook('admin_corps_rank', AUTH_MDP, 'admin'), | |
b62db02e | 78 | 'admin/names' => $this->make_hook('admin_names', AUTH_MDP, 'admin'), |
7d8b17cb | 79 | ); |
80 | } | |
81 | ||
7a12b2ca SJ |
82 | /* Function needed for compatibility reasons. |
83 | * TODO: removes calls to fiche.php?user=blah.machin.2083 and then removes this. | |
84 | */ | |
e8599c21 | 85 | function handler_fiche(&$page) |
86 | { | |
5e2307dc | 87 | return $this->handler_profile($page, Env::v('user')); |
e8599c21 | 88 | } |
89 | ||
adbdf493 | 90 | function handler_photo(&$page, $x = null, $req = null) |
91 | { | |
706f830d | 92 | if (!$x || !($profile = Profile::get($x))) { |
adbdf493 | 93 | return PL_NOT_FOUND; |
94 | } | |
95 | ||
954cfb01 | 96 | // Retrieve the photo and its mime type. |
cab08090 | 97 | if ($req && S::logged()) { |
adbdf493 | 98 | include 'validations.inc.php'; |
c710b211 | 99 | $myphoto = PhotoReq::get_request($profile->id()); |
833a6e86 | 100 | $photo = PlImage::fromData($myphoto->data, $myphoto->mimetype); |
adbdf493 | 101 | } else { |
7988f7d6 | 102 | $photo = $profile->getPhoto(true, true); |
adbdf493 | 103 | } |
954cfb01 VZ |
104 | |
105 | // Display the photo, or a default one when not available. | |
833a6e86 | 106 | $photo->send(); |
adbdf493 | 107 | } |
108 | ||
85cc366b FB |
109 | function handler_medal(&$page, $mid) |
110 | { | |
bd6a5fe3 VZ |
111 | $thumb = ($mid == 'thumb'); |
112 | $mid = $thumb ? @func_get_arg(2) : $mid; | |
113 | ||
85cc366b | 114 | $res = XDB::query("SELECT img |
5c8a71f2 | 115 | FROM profile_medal_enum |
85cc366b FB |
116 | WHERE id = {?}", |
117 | $mid); | |
bd6a5fe3 VZ |
118 | $img = $thumb ? |
119 | dirname(__FILE__).'/../htdocs/images/medals/thumb/' . $res->fetchOneCell() : | |
120 | dirname(__FILE__).'/../htdocs/images/medals/' . $res->fetchOneCell(); | |
3cb500d5 | 121 | pl_cached_content_headers(mime_content_type($img)); |
85cc366b FB |
122 | echo file_get_contents($img); |
123 | exit; | |
124 | } | |
125 | ||
70c65f3a SJ |
126 | function handler_name_info(&$page) |
127 | { | |
e5ef8615 | 128 | pl_content_headers("text/html"); |
70c65f3a SJ |
129 | $page->changeTpl('profile/name_info.tpl', SIMPLE); |
130 | $res = XDB::iterator("SELECT name, explanations, | |
131 | FIND_IN_SET('public', flags) AS public, | |
132 | FIND_IN_SET('has_particle', flags) AS has_particle | |
97a98687 | 133 | FROM profile_name_enum |
70c65f3a SJ |
134 | WHERE NOT FIND_IN_SET('not_displayed', flags) |
135 | ORDER BY NOT FIND_IN_SET('public', flags)"); | |
136 | $page->assign('types', $res); | |
137 | } | |
138 | ||
40176c6c GB |
139 | function handler_networking(&$page, $mid) |
140 | { | |
141 | $res = XDB::query("SELECT icon | |
142 | FROM profile_networking_enum | |
1f5cd004 | 143 | WHERE nwid = {?}", |
40176c6c GB |
144 | $mid); |
145 | $img = dirname(__FILE__) . '/../htdocs/images/networking/' . $res->fetchOneCell(); | |
e5ef8615 | 146 | pl_cached_content_headers(mime_content_type($img)); |
40176c6c GB |
147 | echo file_get_contents($img); |
148 | exit; | |
149 | } | |
150 | ||
c710b211 RB |
151 | /** Tries to return the correct user from given hrpid |
152 | * Will redirect to $returnurl$hrpid if $hrpid was empty | |
153 | */ | |
154 | private function findProfile($returnurl, $hrpid = null) | |
155 | { | |
156 | if (is_null($hrpid)) { | |
157 | $user = S::user(); | |
158 | if (!$user->hasProfile()) { | |
159 | return PL_NOT_FOUND; | |
160 | } else { | |
161 | pl_redirect($returnurl . $user->profile()->hrid()); | |
162 | } | |
163 | } else { | |
164 | $profile = Profile::get($hrpid); | |
165 | if (!$profile) { | |
166 | return PL_NOT_FOUND; | |
167 | } else if (!S::user()->canEdit($profile) && Platal::notAllowed()) { | |
168 | return PL_FORBIDDEN; | |
169 | } | |
170 | } | |
171 | return $profile; | |
172 | } | |
173 | ||
174 | function handler_photo_change(&$page, $hrpid = null) | |
fb9a56cb | 175 | { |
ebfdf077 | 176 | global $globals; |
c710b211 RB |
177 | $profile = $this->findProfile('photo/change/', $hrpid); |
178 | if (! ($profile instanceof Profile) && ($profile == PL_NOT_FOUND || $profile == PL_FORBIDDEN)) { | |
179 | return $profile; | |
180 | } | |
181 | ||
8b1f8e12 | 182 | $page->changeTpl('profile/trombino.tpl'); |
c710b211 | 183 | $page->assign('hrpid', $profile->hrid()); |
fb9a56cb | 184 | |
185 | require_once('validations.inc.php'); | |
186 | ||
c710b211 | 187 | $trombi_x = '/home/web/trombino/photos' . $profile->promo() . '/' . $profile->hrid() . '.jpg'; |
fb9a56cb | 188 | if (Env::has('upload')) { |
8827fc52 VZ |
189 | S::assert_xsrf_token(); |
190 | ||
c710b211 | 191 | $upload = new PlUpload($profile->hrid(), 'photo'); |
abe7e055 | 192 | if (!$upload->upload($_FILES['userfile']) && !$upload->download(Env::v('photo'))) { |
a7d35093 | 193 | $page->trigError('Une erreur est survenue lors du téléchargement du fichier'); |
abe7e055 | 194 | } else { |
c710b211 | 195 | $myphoto = new PhotoReq(S::user(), $profile, $upload); |
abe7e055 | 196 | if ($myphoto->isValid()) { |
197 | $myphoto->submit(); | |
fb9a56cb | 198 | } |
fb9a56cb | 199 | } |
200 | } elseif (Env::has('trombi')) { | |
8827fc52 VZ |
201 | S::assert_xsrf_token(); |
202 | ||
c710b211 | 203 | $upload = new PlUpload($profile->hrid(), 'photo'); |
abe7e055 | 204 | if ($upload->copyFrom($trombi_x)) { |
c710b211 | 205 | $myphoto = new PhotoReq(S::user(), $profile, $upload); |
abe7e055 | 206 | if ($myphoto->isValid()) { |
207 | $myphoto->commit(); | |
208 | $myphoto->clean(); | |
209 | } | |
fb9a56cb | 210 | } |
5e2307dc | 211 | } elseif (Env::v('suppr')) { |
8827fc52 VZ |
212 | S::assert_xsrf_token(); |
213 | ||
5c4ea53f FB |
214 | XDB::execute('DELETE FROM profile_photos |
215 | WHERE pid = {?}', | |
c710b211 | 216 | $profile->id()); |
257ae408 | 217 | XDB::execute("DELETE FROM requests |
c710b211 RB |
218 | WHERE pid = {?} AND type = 'photo'", |
219 | $profile->id()); | |
ebfdf077 | 220 | $globals->updateNbValid(); |
716dedc5 | 221 | $page->trigSuccess("Ta photo a bien été supprimée. Elle ne sera plus visible sur le site dans au plus une heure."); |
5e2307dc | 222 | } elseif (Env::v('cancel')) { |
8827fc52 VZ |
223 | S::assert_xsrf_token(); |
224 | ||
257ae408 | 225 | $sql = XDB::query("DELETE FROM requests |
c710b211 RB |
226 | WHERE pid = {?} AND type = 'photo'", |
227 | $profile->id()); | |
ebfdf077 | 228 | $globals->updateNbValid(); |
fb9a56cb | 229 | } |
230 | ||
257ae408 | 231 | $sql = XDB::query("SELECT COUNT(*) |
84868ee9 | 232 | FROM requests |
c710b211 RB |
233 | WHERE pid = {?} AND type = 'photo'", |
234 | $profile->id()); | |
fb9a56cb | 235 | $page->assign('submited', $sql->fetchOneCell()); |
236 | $page->assign('has_trombi_x', file_exists($trombi_x)); | |
fb9a56cb | 237 | } |
238 | ||
9b09e3fb | 239 | function handler_profile(&$page, $id = null) |
e8599c21 | 240 | { |
9b09e3fb SJ |
241 | // Checks if the identifier corresponds to an actual profile. Numeric |
242 | // identifiers canonly be user by logged users. | |
243 | if (is_null($id)) { | |
e8599c21 | 244 | return PL_NOT_FOUND; |
245 | } | |
23ff6dd6 | 246 | $pid = (!is_numeric($id) || S::admin()) ? Profile::getPID($id) : null; |
9b09e3fb | 247 | if (is_null($pid)) { |
efe597c5 | 248 | if (S::logged()) { |
9b09e3fb | 249 | $page->trigError($id . " inconnu dans l'annuaire."); |
efe597c5 | 250 | } |
344234db | 251 | return PL_NOT_FOUND; |
e8599c21 | 252 | } |
e8599c21 | 253 | |
9b09e3fb SJ |
254 | // Now that we know this is an existing profile, we can switch to the |
255 | // appropriate template. | |
b13048df | 256 | $page->changeTpl('profile/profile.tpl', SIMPLE); |
e8599c21 | 257 | |
54cabe90 VZ |
258 | // Determines the access level at which the profile will be displayed. |
259 | if (!S::logged() || Env::v('view') == 'public') { | |
260 | $view = 'public'; | |
261 | } else if (S::logged() && Env::v('view') == 'ax') { | |
262 | $view = 'ax'; | |
e8599c21 | 263 | } else { |
54cabe90 | 264 | $view = 'private'; |
e8599c21 | 265 | } |
266 | ||
7e019d24 RB |
267 | // Display pending picture |
268 | if (S::logged() && Env::v('modif') == 'new') { | |
269 | $page->assign('with_pending_pic', true); | |
270 | } | |
271 | ||
9b09e3fb SJ |
272 | // Fetches profile's and profile's owner information and redirects to |
273 | // marketing if the owner has not subscribed and the requirer has logged in. | |
d1095b1d | 274 | $profile = Profile::get($pid, Profile::FETCH_ALL, $view); |
9b09e3fb SJ |
275 | $owner = $profile->owner(); |
276 | if (S::logged() && !is_null($owner) && $owner->state == 'pending') { | |
277 | pl_redirect('marketing/public/' . $profile->hrid()); | |
e8599c21 | 278 | } |
ba25f663 | 279 | |
54cabe90 | 280 | // Profile view are logged. |
e31c1c3e | 281 | if (S::logged()) { |
9b09e3fb | 282 | S::logger()->log('view_profile', $profile->hrid()); |
e8599c21 | 283 | } |
284 | ||
54cabe90 | 285 | // Sets the title of the html page. |
9b09e3fb | 286 | $page->setTitle($profile->fullName()); |
e8599c21 | 287 | |
54cabe90 | 288 | // Determines and displays the virtual alias. |
8446dbd3 | 289 | if (!is_null($owner) && $profile->alias_pub == 'public') { |
efe597c5 FB |
290 | $page->assign('virtualalias', $owner->emailAlias()); |
291 | } | |
54cabe90 | 292 | |
68f988a8 RB |
293 | $page->assign_by_ref('profile', $profile); |
294 | $page->assign_by_ref('owner', $owner); | |
bdce53bb | 295 | $page->assign('view', $view); |
e859bdaf | 296 | $page->assign('logged', S::logged()); |
e8599c21 | 297 | |
c99ef281 | 298 | $page->addJsLink('close_on_esc.js'); |
9b09e3fb | 299 | header('Last-Modified: ' . date('r', strtotime($profile->last_change))); |
e8599c21 | 300 | } |
301 | ||
5122b820 | 302 | function handler_ax(&$page, $user = null) |
303 | { | |
c52d86d1 | 304 | $user = Profile::get($user); |
5122b820 | 305 | if (!$user) { |
306 | return PL_NOT_FOUND; | |
307 | } | |
c52d86d1 FB |
308 | if (!$user->ax_id) { |
309 | $page->kill("Le matricule AX de {$user->hrid()} est inconnu"); | |
5122b820 | 310 | } |
e46cf8c4 | 311 | http_redirect("http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&ancc_id=" . $user->ax_id); |
5122b820 | 312 | } |
313 | ||
c710b211 | 314 | function handler_p_edit(&$page, $hrpid = null, $opened_tab = null, $mode = null, $success = null) |
2f678da1 | 315 | { |
316 | global $globals; | |
317 | ||
c710b211 RB |
318 | $profile = $this->findProfile('profile/edit/', $hrpid); |
319 | if (! ($profile instanceof Profile) && ($profile == PL_NOT_FOUND || $profile == PL_FORBIDDEN)) { | |
320 | return $profile; | |
3af21f99 FB |
321 | } |
322 | ||
7bff4cb0 | 323 | // Build the page |
c6a7beb2 | 324 | $page->addJsLink('ajax.js'); |
6dc215d1 SJ |
325 | $page->addJsLink('education.js', false); /* dynamic content */ |
326 | $page->addJsLink('grades.js', false); /* dynamic content */ | |
16594a1a | 327 | $page->addJsLink('profile.js'); |
4b4b4b67 | 328 | $page->addJsLink('jquery.autocomplete.js'); |
e5bcd851 | 329 | $wiz = new PlWizard('Profil', PlPage::getCoreTpl('plwizard.tpl'), true, true, false); |
c710b211 RB |
330 | $wiz->addUserData('profile', $profile); |
331 | $wiz->addUserData('owner', $profile->owner()); | |
460d8f55 | 332 | $this->load('page.inc.php'); |
12bcf04b RB |
333 | $wiz->addPage('ProfileSettingGeneral', 'Général', 'general'); |
334 | $wiz->addPage('ProfileSettingAddresses', 'Adresses personnelles', 'adresses'); | |
335 | $wiz->addPage('ProfileSettingGroups', 'Groupes X - Binets', 'poly'); | |
336 | $wiz->addPage('ProfileSettingDecos', 'Décorations - Medailles', 'deco'); | |
337 | $wiz->addPage('ProfileSettingJobs', 'Informations professionnelles', 'emploi'); | |
338 | $wiz->addPage('ProfileSettingSkills', 'Compétences diverses', 'skill'); | |
339 | $wiz->addPage('ProfileSettingMentor', 'Mentoring', 'mentor'); | |
c710b211 | 340 | $wiz->apply($page, 'profile/edit/' . $profile->hrid(), $opened_tab, $mode); |
35aedff2 | 341 | |
c710b211 | 342 | if (!$profile->birthdate) { |
a7d35093 | 343 | $page->trigWarning("Ta date de naissance n'est pas renseignée, ce qui t'empêcheras de réaliser" |
6e32823c | 344 | . " la procédure de récupération de mot de passe si un jour tu le perdais."); |
7bff4cb0 FB |
345 | } |
346 | ||
46f272fe | 347 | $page->setTitle('Mon Profil'); |
eb563236 SJ |
348 | if (isset($success) && $success) { |
349 | $page->trigSuccess('Ton profil a bien été mis à jour.'); | |
350 | } | |
2f678da1 | 351 | } |
352 | ||
f711b03f | 353 | function handler_education_js(&$page) |
46ae38a9 | 354 | { |
3cb500d5 | 355 | pl_cached_content_headers("text/javascript", "utf-8"); |
f711b03f | 356 | $page->changeTpl('profile/education.js.tpl', NO_SKIN); |
ee718651 | 357 | require_once 'education.func.inc.php'; |
46ae38a9 FB |
358 | } |
359 | ||
360 | function handler_grades_js(&$page) | |
361 | { | |
3cb500d5 | 362 | pl_cached_content_headers("text/javascript", "utf-8"); |
46ae38a9 FB |
363 | $page->changeTpl('profile/grades.js.tpl', NO_SKIN); |
364 | $res = XDB::iterator("SELECT * | |
c6d16b24 | 365 | FROM profile_medal_grade_enum |
46ae38a9 FB |
366 | ORDER BY mid, pos"); |
367 | $grades = array(); | |
368 | while ($tmp = $res->next()) { | |
369 | $grades[$tmp['mid']][] = $tmp; | |
370 | } | |
371 | $page->assign('grades', $grades); | |
372 | ||
373 | $res = XDB::iterator("SELECT *, FIND_IN_SET('validation', flags) AS validate | |
5c8a71f2 | 374 | FROM profile_medal_enum |
46ae38a9 FB |
375 | ORDER BY type, text"); |
376 | $mlist = array(); | |
377 | while ($tmp = $res->next()) { | |
378 | $mlist[$tmp['type']][] = $tmp; | |
379 | } | |
380 | $page->assign('medal_list', $mlist); | |
381 | } | |
382 | ||
041a5cec | 383 | function handler_ajax_address(&$page, $id) |
c6a7beb2 | 384 | { |
3cb500d5 | 385 | pl_content_headers("text/html"); |
c6a7beb2 | 386 | $page->changeTpl('profile/adresses.address.tpl', NO_SKIN); |
041a5cec SJ |
387 | $page->assign('i', $id); |
388 | $page->assign('address', array()); | |
c6a7beb2 FB |
389 | } |
390 | ||
bde2be3b | 391 | function handler_ajax_tel(&$page, $prefid, $prefname, $telid) |
c6a7beb2 | 392 | { |
3cb500d5 | 393 | pl_content_headers("text/html"); |
bde2be3b GB |
394 | $page->changeTpl('profile/phone.tpl', NO_SKIN); |
395 | $page->assign('prefid', $prefid); | |
396 | $page->assign('prefname', $prefname); | |
397 | $page->assign('telid', $telid); | |
c6a7beb2 | 398 | $page->assign('tel', array()); |
c6a7beb2 FB |
399 | } |
400 | ||
58acfe8b | 401 | function handler_ajax_edu(&$page, $eduid, $class) |
043bbacf | 402 | { |
e5ef8615 | 403 | pl_content_headers("text/html"); |
2700a4f5 | 404 | $page->changeTpl('profile/general.edu.tpl', NO_SKIN); |
043bbacf SJ |
405 | $res = XDB::iterator("SELECT id, field |
406 | FROM profile_education_field_enum | |
407 | ORDER BY field"); | |
408 | $page->assign('edu_fields', $res->fetchAllAssoc()); | |
409 | $page->assign('eduid', $eduid); | |
58acfe8b | 410 | $page->assign('class', $class); |
f711b03f | 411 | require_once "education.func.inc.php"; |
043bbacf SJ |
412 | } |
413 | ||
85cc366b FB |
414 | function handler_ajax_medal(&$page, $id) |
415 | { | |
3cb500d5 | 416 | pl_content_headers("text/html"); |
85cc366b FB |
417 | $page->changeTpl('profile/deco.medal.tpl', NO_SKIN); |
418 | $page->assign('id', $id); | |
419 | $page->assign('medal', array('valid' => 0, 'grade' => 0)); | |
85cc366b FB |
420 | } |
421 | ||
2dcac0f5 FB |
422 | function handler_ajax_job(&$page, $id) |
423 | { | |
3cb500d5 | 424 | pl_content_headers("text/html"); |
2dcac0f5 FB |
425 | $page->changeTpl('profile/jobs.job.tpl', NO_SKIN); |
426 | $page->assign('i', $id); | |
427 | $page->assign('job', array()); | |
2dcac0f5 | 428 | $page->assign('new', true); |
2992a284 | 429 | $res = XDB::query("SELECT id, name AS label |
b814a8b8 | 430 | FROM profile_job_sector_enum"); |
541e8d03 | 431 | $page->assign('sectors', $res->fetchAllAssoc()); |
06a99865 SJ |
432 | require_once "emails.combobox.inc.php"; |
433 | fill_email_combobox($page); | |
2dcac0f5 FB |
434 | } |
435 | ||
541e8d03 | 436 | function handler_ajax_sector(&$page, $id, $jobid, $jobpref, $sect, $ssect = -1) |
2dcac0f5 | 437 | { |
3cb500d5 | 438 | pl_content_headers("text/html"); |
541e8d03 | 439 | $res = XDB::iterator("SELECT id, name, FIND_IN_SET('optgroup', flags) AS optgroup |
c7139c07 SJ |
440 | FROM profile_job_subsector_enum |
441 | WHERE sectorid = {?}", $sect); | |
541e8d03 | 442 | $page->changeTpl('profile/jobs.sector.tpl', NO_SKIN); |
2dcac0f5 | 443 | $page->assign('id', $id); |
541e8d03 | 444 | $page->assign('subSectors', $res); |
2dcac0f5 | 445 | $page->assign('sel', $ssect); |
5fecdf6d SJ |
446 | if ($id != -1) { |
447 | $page->assign('change', 1); | |
448 | $page->assign('jobid', $jobid); | |
449 | $page->assign('jobpref', $jobpref); | |
450 | } | |
c7139c07 | 451 | } |
541e8d03 | 452 | function handler_ajax_sub_sector(&$page, $id, $ssect, $sssect = -1) |
c7139c07 | 453 | { |
e5ef8615 | 454 | pl_content_headers("text/html"); |
541e8d03 | 455 | $res = XDB::iterator("SELECT id, name |
c7139c07 SJ |
456 | FROM profile_job_subsubsector_enum |
457 | WHERE subsectorid = {?}", $ssect); | |
541e8d03 | 458 | $page->changeTpl('profile/jobs.sub_sector.tpl', NO_SKIN); |
c7139c07 | 459 | $page->assign('id', $id); |
541e8d03 | 460 | $page->assign('subSubSectors', $res); |
c7139c07 | 461 | $page->assign('sel', $sssect); |
2dcac0f5 FB |
462 | } |
463 | ||
3ac45f10 PC |
464 | /** |
465 | * Page for url "profile/ajax/tree/jobterms". Display a JSon page containing | |
466 | * the sub-branches of a branch in the job terms tree. | |
467 | * @param $page the Platal page | |
468 | * @param $filter filter helps to display only jobterms that are contained in jobs or in mentors | |
469 | * | |
470 | * @param Env::i('jtid') job term id of the parent branch, if none trunk will be used | |
471 | * @param Env::v('attrfunc') the name of a javascript function that will be called when a branch | |
472 | * is chosen | |
473 | * @param Env::v('treeid') tree id that will be given as first argument of attrfunc function | |
474 | * the second argument will be the chosen job term id and the third one the chosen job full name. | |
475 | */ | |
476 | function handler_ajax_tree_job_terms(&$page, $filter = JobTerms::ALL) | |
477 | { | |
478 | JobTerms::ajaxGetBranch(&$page, $filter); | |
479 | } | |
480 | ||
07e72582 SJ |
481 | function handler_ajax_alternates(&$page, $id, $sssect) |
482 | { | |
e5ef8615 | 483 | pl_content_headers("text/html"); |
07e72582 SJ |
484 | $res = XDB::iterator('SELECT name |
485 | FROM profile_job_alternates | |
486 | WHERE subsubsectorid = {?} | |
487 | ORDER BY id', | |
488 | $sssect); | |
489 | $page->changeTpl('profile/jobs.alternates.tpl', NO_SKIN); | |
ee199bc8 SJ |
490 | $alternates = ''; |
491 | if ($res->total() > 0) { | |
492 | $alternate = $res->next(); | |
493 | $alternates = $alternate['name']; | |
494 | while ($alternate = $res->next()) { | |
495 | $alternates .= ', ' . $alternate['name']; | |
496 | } | |
07e72582 SJ |
497 | } |
498 | $page->assign('alternates', $alternates); | |
499 | } | |
500 | ||
f25e1a56 FB |
501 | function handler_ajax_skill(&$page, $cat, $id) |
502 | { | |
3cb500d5 | 503 | pl_content_headers("text/html"); |
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 | ||
04e200e0 | 521 | function handler_ajax_searchname(&$page, $id, $isFemale) |
b04882ff | 522 | { |
e5ef8615 | 523 | pl_content_headers("text/html"); |
b04882ff | 524 | $page->changeTpl('profile/general.searchname.tpl', NO_SKIN); |
6e32823c | 525 | $res = XDB::query("SELECT id, name, FIND_IN_SET('public', flags) AS pub |
97a98687 | 526 | FROM profile_name_enum |
6e32823c SJ |
527 | WHERE NOT FIND_IN_SET('not_displayed', flags) |
528 | AND NOT FIND_IN_SET('always_displayed', flags)"); | |
529 | $page->assign('sn_type_list', $res->fetchAllAssoc()); | |
04e200e0 | 530 | $page->assign('isFemale', $isFemale); |
6e32823c | 531 | $page->assign('i', $id); |
b04882ff | 532 | } |
6e32823c | 533 | |
e8a7cf31 | 534 | function handler_ajax_buildnames(&$page, $data, $isFemale) |
6e32823c | 535 | { |
e5ef8615 | 536 | pl_content_headers("text/html"); |
6e32823c SJ |
537 | $page->changeTpl('profile/general.buildnames.tpl', NO_SKIN); |
538 | require_once 'name.func.inc.php'; | |
e8a7cf31 | 539 | $page->assign('names', build_javascript_names($data, $isFemale)); |
b04882ff | 540 | } |
6e32823c | 541 | |
eccb9b82 | 542 | function handler_referent(&$page, $pf) |
28e16d4d | 543 | { |
8b1f8e12 | 544 | $page->changeTpl('profile/fiche_referent.tpl', SIMPLE); |
28e16d4d | 545 | |
eccb9b82 RB |
546 | $pf = Profile::get($pf); |
547 | if (!$pf) { | |
28e16d4d | 548 | return PL_NOT_FOUND; |
549 | } | |
550 | ||
eccb9b82 | 551 | $page->assign_by_ref('profile', $pf); |
28e16d4d | 552 | |
553 | ///// recuperations infos referent | |
554 | ||
541e8d03 SJ |
555 | // Sectors |
556 | $sectors = $subSectors = Array(); | |
08cce2ff | 557 | $res = XDB::iterRow( |
f926f2b8 | 558 | "SELECT s.name AS label, ss.name AS label |
5fecdf6d SJ |
559 | FROM profile_mentor_sector AS m |
560 | LEFT JOIN profile_job_sector_enum AS s ON(m.sectorid = s.id) | |
561 | LEFT JOIN profile_job_subsector_enum AS ss ON(m.sectorid = ss.sectorid AND m.subsectorid = ss.id) | |
eccb9b82 | 562 | WHERE pid = {?}", $pf->id()); |
541e8d03 SJ |
563 | while (list($sector, $subSector) = $res->next()) { |
564 | $sectors[] = $sector; | |
565 | $subSectors[] = $subSector; | |
28e16d4d | 566 | } |
541e8d03 SJ |
567 | $page->assign_by_ref('sectors', $sectors); |
568 | $page->assign_by_ref('subSectors', $subSectors); | |
28e16d4d | 569 | |
e4cd7a1f | 570 | // Countries. |
08cce2ff | 571 | $res = XDB::query( |
e4cd7a1f | 572 | "SELECT gc.countryFR |
5fecdf6d | 573 | FROM profile_mentor_country AS m |
e4cd7a1f | 574 | LEFT JOIN geoloc_countries AS gc ON (m.country = gc.iso_3166_1_a2) |
eccb9b82 | 575 | WHERE pid = {?}", $pf->id()); |
28e16d4d | 576 | $page->assign('pays', $res->fetchColumn()); |
577 | ||
c99ef281 | 578 | $page->addJsLink('close_on_esc.js'); |
28e16d4d | 579 | } |
580 | ||
ff3eb9b7 | 581 | function handler_ref_search(&$page, $action = null, $subaction = null) |
2f678da1 | 582 | { |
8f201b69 FB |
583 | $wp = new PlWikiPage('Docs.Emploi'); |
584 | $wp->buildCache(); | |
585 | ||
75691c60 | 586 | $page->setTitle('Emploi et Carrières'); |
2f678da1 | 587 | |
2f678da1 | 588 | // nb de mentors |
3ac45f10 | 589 | $res = XDB::query("SELECT count(distinct pid) FROM profile_mentor_term"); |
2f678da1 | 590 | $page->assign('mentors_number', $res->fetchOneCell()); |
591 | ||
3ac45f10 PC |
592 | $page->addJsLink('jquery.autocomplete.js'); |
593 | ||
2f678da1 | 594 | // On vient d'un formulaire |
307c3710 RB |
595 | require_once 'ufbuilder.inc.php'; |
596 | $ufb = new UFB_MentorSearch(); | |
597 | if (!$ufb->isEmpty()) { | |
598 | require_once 'userset.inc.php'; | |
599 | $ufc = $ufb->getUFC(); | |
600 | $set = new ProfileSet($ufc); | |
82110d15 | 601 | $set->addMod('mentor', 'Référents'); |
ff3eb9b7 | 602 | $set->apply('referent/search', $page, $action, $subaction); |
603 | if ($set->count() > 100) { | |
e1635d16 | 604 | $page->assign('recherche_trop_large', true); |
2f678da1 | 605 | } |
ff3eb9b7 | 606 | } |
307c3710 | 607 | |
e1635d16 | 608 | $page->changeTpl('profile/referent.tpl'); |
ff3eb9b7 | 609 | } |
2f678da1 | 610 | |
e1635d16 | 611 | function handler_ref_sect(&$page, $sect) |
ff3eb9b7 | 612 | { |
3cb500d5 | 613 | pl_content_headers("text/html"); |
05cb05c0 | 614 | $page->changeTpl('include/field.select.tpl', NO_SKIN); |
541e8d03 | 615 | $page->assign('onchange', 'setSSectors()'); |
ff3eb9b7 | 616 | $page->assign('id', 'ssect_field'); |
541e8d03 | 617 | $page->assign('name', 'subSector'); |
75691c60 FB |
618 | $it = XDB::iterator("SELECT pjsse.id, pjsse.name AS field |
619 | FROM profile_job_subsector_enum AS pjsse | |
620 | INNER JOIN profile_mentor_sector AS pms ON (pms.sectorid = pjsse.sectorid AND pms.subsectorid = pjsse.id) | |
621 | WHERE pjsse.sectorid = {?} | |
622 | GROUP BY pjsse.id | |
623 | ORDER BY pjsse.name", $sect); | |
ff3eb9b7 | 624 | $page->assign('list', $it); |
625 | } | |
2f678da1 | 626 | |
ff3eb9b7 | 627 | function handler_ref_country(&$page, $sect, $ssect = '') |
628 | { | |
3cb500d5 | 629 | pl_content_headers("text/html"); |
05cb05c0 | 630 | $page->changeTpl('include/field.select.tpl', NO_SKIN); |
ff3eb9b7 | 631 | $page->assign('name', 'pays_sel'); |
5fecdf6d | 632 | $where = ($ssect ? ' AND ms.subsectorid = {?}' : ''); |
e4cd7a1f SJ |
633 | $it = XDB::iterator("SELECT gc.iso_3166_1_a2 AS id, gc.countryFR AS field |
634 | FROM geoloc_countries AS gc | |
635 | INNER JOIN profile_mentor_country AS mp ON (mp.country = gc.iso_3166_1_a2) | |
ce0b2c6f | 636 | INNER JOIN profile_mentor_sector AS ms ON (ms.pid = mp.pid) |
e4cd7a1f SJ |
637 | WHERE ms.sectorid = {?} " . $where . " |
638 | GROUP BY iso_3166_1_a2 | |
639 | ORDER BY countryFR", $sect, $ssect); | |
ff3eb9b7 | 640 | $page->assign('list', $it); |
2f678da1 | 641 | } |
642 | ||
3ac45f10 PC |
643 | /** |
644 | * Page for url "referent/autocomplete". Display an "autocomplete" page (plain/text with values | |
645 | * separated by "|" chars) for jobterms in referent (mentor) search. | |
646 | * @see handler_jobterms | |
647 | */ | |
648 | function handler_ref_autocomplete(&$page) | |
649 | { | |
650 | $this->handler_jobterms(&$page, 'mentor'); | |
651 | } | |
652 | ||
653 | /** | |
654 | * Page for url "profile/jobterms" (function also used for "referent/autocomplete" @see | |
655 | * handler_ref_autocomplete). Displays an "autocomplete" page (plain text with values | |
656 | * separated by "|" chars) for jobterms to add in profile. | |
657 | * @param $page the Platal page | |
658 | * @param $type set to 'mentor' to display the number of mentors for each term and order | |
659 | * by descending number of mentors. | |
660 | * | |
661 | * @param Env::v('q') the text that has been typed and to complete automatically | |
662 | */ | |
663 | function handler_jobterms(&$page, $type = 'nomentor') | |
664 | { | |
665 | pl_content_headers("text/plain"); | |
666 | ||
667 | $q = Env::v('q').'%'; | |
668 | $tokens = JobTerms::tokenize($q); | |
669 | if (count($tokens) == 0) { | |
670 | exit; | |
671 | } | |
672 | sort($tokens); | |
673 | $q_normalized = implode(' ', $tokens); | |
674 | ||
675 | // try to look in cached results | |
676 | $cache = XDB::query('SELECT result | |
677 | FROM search_autocomplete | |
678 | WHERE name = {?} AND | |
679 | query = {?} AND | |
680 | generated > NOW() - INTERVAL 1 DAY', | |
681 | $type, $q_normalized); | |
682 | if ($res = $cache->fetchOneCell()) { | |
683 | echo $res; | |
684 | die(); | |
685 | } | |
686 | ||
687 | $joins = JobTerms::token_join_query($tokens, 'e'); | |
688 | if ($type == 'mentor') { | |
689 | $count = ', COUNT(DISTINCT pid) AS nb'; | |
690 | $countjoin = ' LEFT JOIN profile_job_term_relation AS r ON(r.jtid_1 = e.jtid) LEFT JOIN profile_mentor_term AS m ON(r.jtid_2 = m.jtid)'; | |
691 | $countorder = 'nb DESC, '; | |
692 | } else { | |
693 | $count = $countjoin = $countorder = ''; | |
694 | } | |
695 | $list = XDB::iterator('SELECT e.jtid AS id, e.full_name AS field'.$count.' | |
696 | FROM profile_job_term_enum AS e '.$joins.$countjoin.' | |
697 | GROUP BY e.jtid | |
698 | ORDER BY '.$countorder.'field | |
699 | LIMIT 11'); | |
700 | $nbResults = 0; | |
701 | $res = ''; | |
702 | while ($result = $list->next()) { | |
703 | $nbResults++; | |
704 | if ($nbResults == 11) { | |
705 | $res .= $q."|-1\n"; | |
706 | } else { | |
707 | $res .= $result['field'].'|'; | |
708 | if ($count) { | |
709 | $res .= $result['nb'].'|'; | |
710 | } | |
711 | $res .= $result['id']; | |
712 | } | |
713 | $res .= "\n"; | |
714 | } | |
715 | XDB::query('REPLACE INTO search_autocomplete | |
716 | VALUES ({?}, {?}, {?}, NOW())', | |
717 | $type, $q_normalized, $res); | |
718 | echo $res; | |
719 | exit(); | |
720 | } | |
721 | ||
a1d79217 | 722 | function handler_xnet(&$page) |
723 | { | |
8b1f8e12 | 724 | $page->changeTpl('profile/groupesx.tpl'); |
46f272fe | 725 | $page->setTitle('Promo, Groupes X, Binets'); |
e1635d16 | 726 | |
a1d79217 | 727 | $req = XDB::query(' |
e1635d16 | 728 | SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo, |
46e1d3ba | 729 | COUNT(e.eid) AS events, mail_domain AS lists |
eb41eda9 FB |
730 | FROM group_members AS m |
731 | INNER JOIN groups AS a ON(m.asso_id = a.id) | |
732 | LEFT JOIN group_events AS e ON(e.asso_id = m.asso_id AND e.archive = 0) | |
46e1d3ba | 733 | WHERE uid = {?} GROUP BY m.asso_id ORDER BY a.nom', S::i('uid')); |
a1d79217 | 734 | $page->assign('assos', $req->fetchAllAssoc()); |
735 | } | |
e1635d16 | 736 | |
23fb3e6f SJ |
737 | function handler_xnetlogo(&$page, $id) |
738 | { | |
739 | if (is_null($id)) { | |
740 | return PL_NOT_FOUND; | |
741 | } | |
742 | ||
743 | $res = XDB::query('SELECT logo, logo_mime | |
eb41eda9 | 744 | FROM groups |
23fb3e6f SJ |
745 | WHERE id = {?}', $id); |
746 | list($logo, $logo_mime) = $res->fetchOneRow(); | |
747 | ||
748 | if (!empty($logo)) { | |
3cb500d5 | 749 | pl_cached_dynamic_content_headers($logo_mime); |
23fb3e6f SJ |
750 | echo $logo; |
751 | } else { | |
3cb500d5 | 752 | pl_cached_dynamic_content_headers("image/jpeg"); |
23fb3e6f SJ |
753 | readfile(dirname(__FILE__) . '/../htdocs/images/dflt_carre.jpg'); |
754 | } | |
755 | ||
756 | exit; | |
757 | } | |
758 | ||
e49018a7 | 759 | function handler_vcard(&$page, $x = null) |
760 | { | |
761 | if (is_null($x)) { | |
762 | return PL_NOT_FOUND; | |
763 | } | |
764 | ||
765 | global $globals; | |
766 | ||
767 | if (substr($x, -4) == '.vcf') { | |
768 | $x = substr($x, 0, strlen($x) - 4); | |
769 | } | |
770 | ||
5d42c993 | 771 | $vcard = new VCard(); |
07d7f498 | 772 | $vcard->addProfile(Profile::get($x)); |
5d42c993 | 773 | $vcard->show(); |
e49018a7 | 774 | } |
92423144 | 775 | |
54cabe90 | 776 | function handler_admin_trombino(&$page, $login = null, $action = null) { |
8b1f8e12 | 777 | $page->changeTpl('profile/admin_trombino.tpl'); |
46f272fe | 778 | $page->setTitle('Administration - Trombino'); |
e1635d16 | 779 | |
54cabe90 VZ |
780 | if (!$login || !($user = User::get($login))) { |
781 | return PL_NOT_FOUND; | |
782 | } else { | |
783 | $page->assign_by_ref('user', $user); | |
784 | } | |
e1635d16 | 785 | |
92423144 | 786 | switch ($action) { |
92423144 | 787 | case "original": |
5c4ea53f | 788 | PlImage::fromFile("/home/web/trombino/photos" . $user->promo() . "/" . $user->login() . ".jpg", "image/jpeg")->send(); |
92423144 | 789 | exit; |
e1635d16 | 790 | |
92423144 | 791 | case "new": |
8827fc52 VZ |
792 | S::assert_xsrf_token(); |
793 | ||
92423144 | 794 | $data = file_get_contents($_FILES['userfile']['tmp_name']); |
795 | list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']); | |
796 | $mimetype = substr($_FILES['userfile']['type'], 6); | |
797 | unlink($_FILES['userfile']['tmp_name']); | |
798 | XDB::execute( | |
5c4ea53f FB |
799 | "REPLACE INTO profile_photos SET pid={?}, attachmime = {?}, attach={?}, x={?}, y={?}", |
800 | $user->profile()->id(), $mimetype, $data, $x, $y); | |
92423144 | 801 | break; |
e1635d16 | 802 | |
92423144 | 803 | case "delete": |
8827fc52 VZ |
804 | S::assert_xsrf_token(); |
805 | ||
5c4ea53f | 806 | XDB::execute('DELETE FROM profile_photos WHERE pid = {?}', $user->profile()->id()); |
92423144 | 807 | break; |
808 | } | |
92423144 | 809 | } |
b62db02e SJ |
810 | function handler_admin_names(&$page, $action = 'list', $id = null) { |
811 | $page->setTitle('Administration - Types de noms'); | |
812 | $page->assign('title', 'Gestion des types de noms'); | |
813 | $table_editor = new PLTableEditor('admin/names', 'profile_name_enum', 'id', true); | |
814 | $table_editor->describe('name', 'Nom', true); | |
815 | $table_editor->describe('explanations', 'Explications', true); | |
816 | $table_editor->describe('type', 'Type', true); | |
817 | $table_editor->describe('flags', 'Flags', true); | |
818 | $table_editor->describe('score', 'Score', true); | |
819 | $table_editor->apply($page, $action, $id); | |
820 | } | |
92423144 | 821 | function handler_admin_binets(&$page, $action = 'list', $id = null) { |
46f272fe | 822 | $page->setTitle('Administration - Binets'); |
92423144 | 823 | $page->assign('title', 'Gestion des binets'); |
5c8a71f2 FB |
824 | $table_editor = new PLTableEditor('admin/binets', 'profile_binet_enum', 'id'); |
825 | $table_editor->add_join_table('profile_binets','binet_id',true); | |
a7de4ef7 | 826 | $table_editor->describe('text','intitulé',true); |
92423144 | 827 | $table_editor->apply($page, $action, $id); |
828 | } | |
043bbacf | 829 | function handler_admin_education(&$page, $action = 'list', $id = null) { |
46f272fe | 830 | $page->setTitle('Administration - Formations'); |
92423144 | 831 | $page->assign('title', 'Gestion des formations'); |
043bbacf SJ |
832 | $table_editor = new PLTableEditor('admin/education', 'profile_education_enum', 'id'); |
833 | $table_editor->add_join_table('profile_education', 'eduid', true); | |
834 | $table_editor->add_join_table('profile_education_degree', 'eduid', true); | |
835 | $table_editor->describe('name', 'intitulé', true); | |
836 | $table_editor->describe('url', 'site web', false); | |
837 | $table_editor->apply($page, $action, $id); | |
838 | } | |
839 | function handler_admin_education_field(&$page, $action = 'list', $id = null) { | |
840 | $page->setTitle('Administration - Domaines de formation'); | |
841 | $page->assign('title', 'Gestion des domaines de formation'); | |
842 | $table_editor = new PLTableEditor('admin/education_field', 'profile_education_field_enum', 'id', true); | |
843 | $table_editor->add_join_table('profile_education', 'fieldid', true); | |
844 | $table_editor->describe('field', 'domaine', true); | |
845 | $table_editor->apply($page, $action, $id); | |
846 | } | |
847 | function handler_admin_education_degree(&$page, $action = 'list', $id = null) { | |
848 | $page->setTitle('Administration - Niveau de formation'); | |
849 | $page->assign('title', 'Gestion des niveau de formation'); | |
0355d91b | 850 | $table_editor = new PLTableEditor('admin/education_degree', 'profile_education_degree_enum', 'id'); |
043bbacf SJ |
851 | $table_editor->add_join_table('profile_education_degree', 'degreeid', true); |
852 | $table_editor->add_join_table('profile_education', 'degreeid', true); | |
853 | $table_editor->describe('degree', 'niveau', true); | |
854 | $table_editor->apply($page, $action, $id); | |
855 | } | |
856 | function handler_admin_education_degree_set(&$page, $action = 'list', $id = null) { | |
857 | $page->setTitle('Administration - Correspondances formations - niveau de formation'); | |
858 | $page->assign('title', 'Gestion des correspondances formations - niveau de formation'); | |
859 | $table_editor = new PLTableEditor('admin/education_degree_set', 'profile_education_degree', 'eduid', true); | |
00f0e0b0 PC |
860 | $table_editor->describe('eduid', 'id formation', true); |
861 | $table_editor->describe('degreeid', 'id niveau', true); | |
862 | ||
863 | // Adds fields to show the names of education | |
864 | $table_editor->add_option_table('profile_education_enum','profile_education_enum.id = eduid'); | |
865 | $table_editor->add_option_field('profile_education_enum.name', 'edu_name', 'formation', null, 'degreeid'); | |
866 | // Adds fields to show the names of degrees | |
867 | $table_editor->add_option_table('profile_education_degree_enum','profile_education_degree_enum.id = t.degreeid'); | |
868 | $table_editor->add_option_field('profile_education_degree_enum.degree', 'degree_name', 'niveau'); | |
869 | ||
92423144 | 870 | $table_editor->apply($page, $action, $id); |
e1635d16 | 871 | } |
b09690be | 872 | function handler_admin_sections(&$page, $action = 'list', $id = null) { |
46f272fe | 873 | $page->setTitle('Administration - Sections'); |
a20aab02 | 874 | $page->assign('title', 'Gestion des sections'); |
5c8a71f2 | 875 | $table_editor = new PLTableEditor('admin/sections','profile_section_enum','id'); |
b09690be | 876 | $table_editor->describe('text','intitulé',true); |
877 | $table_editor->apply($page, $action, $id); | |
e1635d16 | 878 | } |
b6e9d1ca SJ |
879 | function handler_admin_sectors(&$page, $action = 'list', $id = null) { |
880 | $page->setTitle('Administration - Secteurs'); | |
881 | $page->assign('title', 'Gestion des secteurs'); | |
882 | $table_editor = new PLTableEditor('admin/sectors', 'profile_job_subsubsector_enum', 'id', true); | |
883 | $table_editor->describe('sectorid', 'id du secteur', false); | |
884 | $table_editor->describe('subsectorid', 'id du sous-secteur', false); | |
885 | $table_editor->describe('name', 'nom', true); | |
886 | $table_editor->describe('flags', 'affichage', true); | |
a20aab02 SJ |
887 | $table_editor->apply($page, $action, $id); |
888 | } | |
15beefb3 GB |
889 | function handler_admin_networking(&$page, $action = 'list', $id = null) { |
890 | $page->assign('xorg_title', 'Polytechnique.org - Administration - Networking'); | |
891 | $page->assign('title', 'Gestion des types de networking'); | |
1f5cd004 | 892 | $table_editor = new PLTableEditor('admin/networking', 'profile_networking_enum', 'nwid'); |
15beefb3 GB |
893 | $table_editor->describe('name', 'intitulé', true); |
894 | $table_editor->describe('icon', 'nom de l\'icône', false); | |
dc6378df GB |
895 | $table_editor->describe('filter', 'filtre', true); |
896 | $table_editor->describe('link', 'lien web', true); | |
15beefb3 GB |
897 | $table_editor->apply($page, $action, $id); |
898 | } | |
4962a9ce SJ |
899 | function handler_admin_corps_enum(&$page, $action = 'list', $id = null) { |
900 | $page->setTitle('Administration - Corps'); | |
901 | $page->assign('title', 'Gestion des Corps'); | |
902 | $table_editor = new PLTableEditor('admin/corps_enum', 'profile_corps_enum', 'id'); | |
903 | $table_editor->describe('name', 'intitulé', true); | |
904 | $table_editor->describe('abbreviation', 'abbréviation', true); | |
905 | $table_editor->describe('still_exists', 'existe encore ?', true); | |
906 | $table_editor->apply($page, $action, $id); | |
907 | } | |
908 | function handler_admin_corps_rank(&$page, $action = 'list', $id = null) { | |
909 | $page->setTitle('Administration - Grade dans les Corps'); | |
910 | $page->assign('title', 'Gestion des grade dans les Corps'); | |
911 | $table_editor = new PLTableEditor('admin/corps_rank', 'profile_corps_rank_enum', 'id'); | |
912 | $table_editor->describe('name', 'intitulé', true); | |
913 | $table_editor->describe('abbreviation', 'abbréviation', true); | |
914 | $table_editor->apply($page, $action, $id); | |
915 | } | |
92423144 | 916 | function handler_admin_medals(&$page, $action = 'list', $id = null) { |
46f272fe | 917 | $page->setTitle('Administration - Distinctions'); |
92423144 | 918 | $page->assign('title', 'Gestion des Distinctions'); |
5c8a71f2 | 919 | $table_editor = new PLTableEditor('admin/medals','profile_medal_enum','id'); |
a7de4ef7 | 920 | $table_editor->describe('text', 'intitulé', true); |
92423144 | 921 | $table_editor->describe('img', 'nom de l\'image', false); |
d02b8359 | 922 | $table_editor->describe('flags', 'valider', true); |
92423144 | 923 | $table_editor->apply($page, $action, $id); |
924 | if ($id && $action == 'edit') { | |
8b1f8e12 | 925 | $page->changeTpl('profile/admin_decos.tpl'); |
e1635d16 | 926 | |
92423144 | 927 | $mid = $id; |
e1635d16 | 928 | |
92423144 | 929 | if (Post::v('act') == 'del') { |
c6d16b24 | 930 | XDB::execute('DELETE FROM profile_medal_grade_enum |
75a17710 | 931 | WHERE mid={?} AND gid={?}', $mid, Post::i('gid')); |
92423144 | 932 | } else { |
933 | foreach (Post::v('grades', array()) as $gid=>$text) { | |
154ee23a OLF |
934 | if ($gid === 0) { |
935 | if (!empty($text)) { | |
936 | $res = XDB::query('SELECT MAX(gid) | |
c6d16b24 | 937 | FROM profile_medal_grade_enum |
154ee23a OLF |
938 | WHERE mid = {?}', $mid); |
939 | $gid = $res->fetchOneCell() + 1; | |
940 | ||
c6d16b24 | 941 | XDB::execute('INSERT INTO profile_medal_grade_enum (mid, gid, text, pos) |
154ee23a OLF |
942 | VALUES ({?}, {?}, {?}, {?})', |
943 | $mid, $gid, $text, $_POST['pos']['0']); | |
944 | } | |
945 | } else { | |
c6d16b24 | 946 | XDB::execute('UPDATE profile_medal_grade_enum |
154ee23a OLF |
947 | SET pos={?}, text={?} |
948 | WHERE gid={?} AND mid={?}', $_POST['pos'][$gid], $text, $gid, $mid); | |
949 | } | |
92423144 | 950 | } |
951 | } | |
c6d16b24 | 952 | $res = XDB::iterator('SELECT gid, text, pos FROM profile_medal_grade_enum WHERE mid={?} ORDER BY pos', $mid); |
92423144 | 953 | $page->assign('grades', $res); |
954 | } | |
e1635d16 | 955 | } |
7d8b17cb | 956 | } |
957 | ||
a7de4ef7 | 958 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
7d8b17cb | 959 | ?> |