From 33ae80b59e0231b8fb6fa34cbe600078383b52a8 Mon Sep 17 00:00:00 2001 From: x2001corpet Date: Sun, 18 Jun 2006 00:08:32 +0000 Subject: [PATCH] pas d'erreur s'il manque la cle privee pour l'ax : enleve la fonctionnalite git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@321 839d8a87-29fc-0310-9880-83ba4fa771e5 --- htdocs/admin/synchro_ax.php | 8 +++++++- htdocs/profil.php | 7 +++++-- include/synchro_ax.inc.php | 5 +++++ include/webservices/ax/config.inc | 2 +- templates/admin/synchro_ax.tpl | 8 +++++++- templates/profil/general.tpl | 2 ++ 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/synchro_ax.php b/htdocs/admin/synchro_ax.php index 45205aa..dccb972 100644 --- a/htdocs/admin/synchro_ax.php +++ b/htdocs/admin/synchro_ax.php @@ -24,9 +24,15 @@ require_once("xorg.inc.php"); new_admin_page('admin/synchro_ax.tpl'); $page->assign('xorg_title','Polytechnique.org - Administration - Synchro AX'); -require_once('user.func.inc.php'); require_once('synchro_ax.inc.php'); +if (is_ax_key_missing()) { + $page->assign('no_private_key', true); + $page->run(); +} + +require_once('user.func.inc.php'); + if (Env::has('user')) { $login = get_user_forlife(Env::get('user')); if ($login === false) { diff --git a/htdocs/profil.php b/htdocs/profil.php index d8455df..42727de 100644 --- a/htdocs/profil.php +++ b/htdocs/profil.php @@ -31,8 +31,11 @@ if (Post::has('register_from_ax_question')) { $globals->xdb->query('UPDATE auth_user_quick SET profile_from_ax = 1 WHERE user_id = {?}', Session::getInt('uid')); } -if (Env::get('synchro_ax') == 'confirm') { - require_once('synchro_ax.inc.php'); +require_once('synchro_ax.inc.php'); +if (is_ax_key_missing()) + $page->assign('no_private_key', true); + +if (Env::get('synchro_ax') == 'confirm' && !is_ax_key_missing()) { ax_synchronize(Session::get('bestalias'), Session::getInt('uid')); $page->trig('Ton profil a été synchronisé avec celui du site polytechniciens.com'); } diff --git a/include/synchro_ax.inc.php b/include/synchro_ax.inc.php index b0b5b2f..ab0c8b6 100644 --- a/include/synchro_ax.inc.php +++ b/include/synchro_ax.inc.php @@ -24,6 +24,11 @@ require_once("xorg.inc.php"); require_once('user.func.inc.php'); +function is_ax_key_missing() { + global $globals; + return !$globals->webservice->private_key_ax || !is_file($globals->webservice->private_key_ax); +} + function get_user_ax($matricule_ax, $raw=false) { require_once('webservices/ax/client.inc'); diff --git a/include/webservices/ax/config.inc b/include/webservices/ax/config.inc index 88b9813..199e7e9 100755 --- a/include/webservices/ax/config.inc +++ b/include/webservices/ax/config.inc @@ -2,7 +2,7 @@ global $globals; //chemin de stockage de la clé privée A MODIFIER - $chemin_cle_privee = $globals->spoolroot."/configs/cle_privee_ax.pem"; + $chemin_cle_privee = $globals->webservice->private_key_ax; //phrase cryptant la clé privée $phrase = $globals->webservice->pass_ax; // "Cryptage de la cle pour polytechnique.org"; diff --git a/templates/admin/synchro_ax.tpl b/templates/admin/synchro_ax.tpl index b8239f7..4e1c406 100644 --- a/templates/admin/synchro_ax.tpl +++ b/templates/admin/synchro_ax.tpl @@ -24,6 +24,11 @@ Synchronisation depuis l'AX +{if $no_private_key} +

+ Impossible d'utiliser ce service, il manque la clef privée AX dans la configuration de plat/al. +

+{else}
@@ -37,8 +42,9 @@
+{/if} -{if $x} +{if $x and !no_private_key}
{if $x.profile_from_ax}
diff --git a/templates/profil/general.tpl b/templates/profil/general.tpl index 0429a4d..1144e68 100644 --- a/templates/profil/general.tpl +++ b/templates/profil/general.tpl @@ -139,6 +139,7 @@
+{if !$no_private_key}
@@ -176,6 +177,7 @@
+{/if}