Convert source code to UTF-8
[platal.git] / include / profil / get_mentor.inc.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
5ddeb07c 3 * Copyright (C) 2003-2007 Polytechnique.org *
0337d704 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
22require_once('geoloc.inc.php');
23require_once('secteur.emploi.inc.php');
24
25$max_mentor_pays = 10;
26$max_mentor_secteurs = 10;
27
28//recuperation de l'expertise
cab08090 29$res = XDB::query("SELECT expertise FROM mentor WHERE uid = {?}", S::v('uid',-1));
0337d704 30
31$mentor_expertise = $res->fetchOneCell();
32$mentor_expertise_bd = $mentor_expertise;
33
34//suppression eventuelle d'un pays
5e2307dc 35if(Post::v('mentor_pays_op', '') == 'retirer') {
0337d704 36 if(Post::has('mentor_pays_id')) {
5e2307dc 37 $id_supprimee = Post::v('mentor_pays_id', '00');
cab08090 38 XDB::execute("DELETE FROM mentor_pays WHERE uid = {?} AND pid = {?} LIMIT 1", S::v('uid', -1), $id_supprimee);
0337d704 39 }
40}
41
42//recuperation des pays
08cce2ff 43$res = XDB::iterRow("SELECT m.pid, p.pays
0337d704 44 FROM mentor_pays AS m
cab08090 45 LEFT JOIN geoloc_pays AS p ON(m.pid = p.a2) WHERE m.uid = {?} LIMIT {?}", S::v('uid', -1), $max_mentor_pays);
0337d704 46$nb_mentor_pays = $res->total();
47$mentor_pid = $mentor_pays = Array();
48for($i = 1; $i <= $nb_mentor_pays ; $i++) list($mentor_pid[$i], $mentor_pays[$i]) = $res->next();
49
50//ajout eventuel d'un pays
5e2307dc 51if((Post::v('mentor_pays_op', '') == 'ajouter') && ($nb_mentor_pays < $max_mentor_pays)) {
52 if(Post::v('mentor_pays_id', '00') != '00') {
53 $id_ajoutee = Post::v('mentor_pays_id', '00');
cab08090 54 XDB::execute("INSERT INTO mentor_pays(uid, pid) VALUES({?}, {?})", S::v('uid', -1), $id_ajoutee);
0337d704 55 $nb_mentor_pays++;
56 $mentor_pid[$nb_mentor_pays] = $id_ajoutee;
5e2307dc 57 $mentor_pays[$nb_mentor_pays] = Post::v('mentor_pays_name', '');
0337d704 58 }
59}
60
61
62
63//suppression d'un secteur / ss-secteur
5e2307dc 64if(Post::v('mentor_secteur_op', '') == 'retirer') {
0337d704 65 if(Post::has('mentor_secteur_id')) {
5e2307dc 66 $id_supprimee = Post::v('mentor_secteur_id', '');
cab08090 67 XDB::execute("DELETE FROM mentor_secteurs WHERE uid = {?} AND secteur = {?} LIMIT 1", S::v('uid', -1), $id_supprimee);
0337d704 68 }
69}
70
71//recuperation des secteurs
08cce2ff 72$res = XDB::iterRow("SELECT m.secteur, s.label, m.ss_secteur, ss.label
0337d704 73 FROM mentor_secteurs AS m
74 LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id)
75 LEFT JOIN emploi_ss_secteur AS ss ON(s.id = ss.secteur AND m.ss_secteur = ss.id)
76 WHERE m.uid = {?}
cab08090 77 LIMIT {?}", S::v('uid', -1), $max_mentor_pays);
0337d704 78$nb_mentor_secteurs = $res->total();
79$mentor_sid = $mentor_secteur = $mentor_ssid = $mentor_ss_secteur = Array();
80for($i = 1; $i <= $nb_mentor_secteurs ; $i++)
81 list($mentor_sid[$i], $mentor_secteur[$i], $mentor_ssid[$i], $mentor_ss_secteur[$i]) = $res->next();
82
83//ajout d'un secteur
84$mentor_secteur_id_new = '';
5e2307dc 85if((Post::v('mentor_secteur_op', '')== 'ajouter') && ($nb_mentor_secteurs < $max_mentor_secteurs)) {
86 if(Post::v('mentor_secteur_id', '') != '')
0337d704 87 {
5e2307dc 88 $sid_ajoutee = Post::v('mentor_secteur_id', '');
0337d704 89 if(Post::has('mentor_ss_secteur_id'))
5e2307dc 90 $ssid_ajoutee = Post::v('mentor_ss_secteur_id', '');
08cce2ff 91 XDB::execute("INSERT INTO mentor_secteurs (uid, secteur, ss_secteur)
cab08090 92 VALUES({?}, {?}, {?})", S::v('uid', -1), $sid_ajoutee, ($ssid_ajoutee == '')?null:$ssid_ajoutee);
0337d704 93 $nb_mentor_secteurs++;
94 $mentor_sid[$nb_mentor_secteurs] = $sid_ajoutee;
5e2307dc 95 $mentor_secteur[$nb_mentor_secteurs] = Post::v('mentor_secteur_name', '');
0337d704 96 $mentor_ssid[$nb_mentor_secteurs] = $ssid_ajoutee;
5e2307dc 97 $mentor_ss_secteur[$nb_mentor_secteurs] = Post::v('mentor_ss_secteur_name', '');
0337d704 98 }
99} elseif(Post::has('mentor_secteur_id_new')){
5e2307dc 100 $mentor_secteur_id_new = Post::v('mentor_secteur_id_new', '');
0337d704 101}
a7de4ef7 102// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
0337d704 103?>