Merge commit 'origin/master' into fusionax
[platal.git] / modules / fusionax.php
index 543f66c..ff3e33d 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
+/**
+ * @brief Module to merge data from AX database
+ *
+ * Module to import data from another database of alumni that had
+ * different schemas. The organization that used this db is called AX
+ * hence the name of this module.
+ *
+ * Datas are stored in an external server and you need a private key
+ * to connect to their server.
+ */
 class FusionAxModule extends PLModule{
 
+    /// path ok private key file to connect to AX server
+    var $ax_xorg_rsa_key;
+
+    function __construct()
+    {
+        $this->ax_xorg_rsa_key =
+            dirname(__FILE__).'/../configs/ax_xorg_rsa.pem';
+    }
+
     function handlers()
     {
         return array(
@@ -30,7 +49,8 @@ class FusionAxModule extends PLModule{
             'fusionax/misc'     => $this->make_hook('misc', AUTH_MDP, 'admin'),
         );
     }
-    
+
+
     function handler_index(&$page)
     {
         global $globals;
@@ -57,10 +77,10 @@ class FusionAxModule extends PLModule{
                     'lastimport',
                     "le ".date("d/m/Y à H:i",$globals->fusionax->LastUpdate));
             }
-            if (!file_exists(dirname(__FILE__).'/../configs/ax_xorg_rsa')) {
+            if (!file_exists($this->ax_xorg_rsa_key)) {
                 $page->assign(
                     'keymissing',
-                    realpath(dirname(__FILE__).'/../configs/').'/ax_xorg_rsa');
+                    $this->ax_xorg_rsa_key);
             }
             return;
         }
@@ -82,7 +102,7 @@ class FusionAxModule extends PLModule{
             // copie la clef d'authentification (paire de clef RSA dont la
             // partie publique est sur polytechniciens.com)
             if (!copy(
-                dirname(__FILE__).'/../configs/ax_xorg_rsa',
+                $this->ax_xorg_rsa_key,
                 $tmpdir.'/ax_xorg_rsa'))
                 $report[] = 'Impossible de copier la clef pour se logger '.
                     'au serveur AX';
@@ -345,20 +365,23 @@ class FusionAxModule extends PLModule{
         $page->assign('deceasedErrors',$deceasedErrorsSql->fetchOneCell());
         $page->assign('deceasedMissingInXorg',XDB::iterator(
             'SELECT
-                d.user_id,d.id_ancien,d.nom,d.prenom,d.promo,d.deces_ax
+                d.user_id,d.id_ancien,d.nom,d.prenom,d.promo,d.deces_ax,
+                CONCAT(d.prenom, " ", d.nom) AS display_name
             FROM fusionax_deceased AS d
             WHERE d.deces_xorg = "0000-00-00"
             LIMIT 10'));
         $page->assign('deceasedMissingInAX',XDB::iterator(
             'SELECT
-                d.user_id,d.id_ancien,d.nom,d.prenom,d.promo,d.deces_xorg
+                d.user_id,d.id_ancien,d.nom,d.prenom,d.promo,d.deces_xorg,
+                CONCAT(d.prenom, " ", d.nom) AS display_name
             FROM fusionax_deceased AD d
             WHERE d.deces_ax = "0000-00-00"
             LIMIT 10'));
         $page->assign('deceasedDifferent',XDB::iterator(
             'SELECT
                 d.user_id,d.id_ancien,d.nom,d.prenom,d.promo,
-                d.deces_ax,d.deces_xorg
+                d.deces_ax,d.deces_xorg,
+                CONCAT(d.prenom, " ", d.nom) AS display_name
             FROM fusionax_deceased AS d
             WHERE d.deces_xorg != "0000-00-00" AND d.deces_ax != "0000-00-00"
             LIMIT 10'));