| 1 | <?php |
| 2 | /*************************************************************************** |
| 3 | * Copyright (C) 2003-2004 Polytechnique.org * |
| 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 | |
| 23 | require_once("xorg.inc.php"); |
| 24 | new_admin_page('admin/synchro_ax.tpl'); |
| 25 | $page->assign('xorg_title','Polytechnique.org - Administration - Synchro AX'); |
| 26 | |
| 27 | require_once('user.func.inc.php'); |
| 28 | require_once('synchro_ax.inc.php'); |
| 29 | |
| 30 | if (Env::has('user')) { |
| 31 | $login = get_user_forlife(Env::get('user')); |
| 32 | if ($login === false) { |
| 33 | $page->kill(""); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | if (Env::has('mat')) { |
| 38 | $res = $globals->xdb->query( |
| 39 | "SELECT alias |
| 40 | FROM aliases AS a |
| 41 | INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie') |
| 42 | WHERE matricule={?}", Env::getInt('mat')); |
| 43 | $login = $res->fetchOneCell(); |
| 44 | } |
| 45 | |
| 46 | if ($login) { |
| 47 | $new = Env::get('modif') == 'new'; |
| 48 | $user = get_user_details($login, Session::getInt('uid')); |
| 49 | $userax= get_user_ax($user['user_id']); |
| 50 | |
| 51 | if (Env::has('importe')) { |
| 52 | |
| 53 | $adr_dels = array(); |
| 54 | foreach ($user['adr'] as $adr) { |
| 55 | if (Env::has('del_address'.$adr['adrid'])) { |
| 56 | $adr_dels[] = $adr['adrid']; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | $adr_adds = array(); |
| 61 | foreach ($userax['adr'] as $i => $adr) { |
| 62 | if (Env::has('add_address'.$i)) { |
| 63 | $adr_adds[] = $i; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | $pro_dels = array(); |
| 68 | foreach ($user['adr_pro'] as $pro) { |
| 69 | if (Env::has('del_pro'.$pro['entrid'])) { |
| 70 | $pro_dels[] = $pro['entrid']; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | $pro_adds = array(); |
| 75 | foreach ($userax['adr_pro'] as $i => $pro) { |
| 76 | if (Env::has('add_pro'.$i)) { |
| 77 | $pro_adds[] = $i; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | import_from_ax($userax, Env::has('nom_usage'), Env::has('mobile'), $adr_dels, $adr_adds, $pro_dels, $pro_adds, Env::has('nationalite')); |
| 82 | |
| 83 | } |
| 84 | |
| 85 | $user = get_user_details($login, Session::getInt('uid')); |
| 86 | |
| 87 | if ($userax) { |
| 88 | $user['matricule_ax'] = $userax['matricule_ax']; |
| 89 | unset($userax['matricule_ax']); |
| 90 | $user['nom'] = ucwords(strtolower($user['nom'])); |
| 91 | $user['nom_usage'] = ucwords(strtolower($user['nom_usage'])); |
| 92 | } |
| 93 | |
| 94 | $page->assign('watch_champs',array('nom', 'nom_usage', 'prenom', 'nationalite', 'mobile')); |
| 95 | $page->assign('modifiables', array(0,1,0,1,1)); |
| 96 | |
| 97 | $page->assign('x', $user); |
| 98 | $page->assign('ax', $userax); |
| 99 | } |
| 100 | $page->run(); |
| 101 | |
| 102 | // vim:set et sts=4 sws=4 sw=4: |
| 103 | ?> |