Automation of the management of associations' mailing lists (Closes #817), Updates...
[platal.git] / include / webservices / manageurs.server.inc.php
index ee8820b..50a5854 100644 (file)
@@ -17,14 +17,11 @@ $error_key = "You didn't provide me with a valid cipher key...";
 function get_annuaire_infos($method, $params) {
     global $error_mat, $error_key, $globals;
 
-      
-
     //verif du mdp
     if(!isset($params[0]) || ($params[0] != $globals->manageurs->manageurs_pass)){return false;}
-    //si on a adresse == -1 => on ne recupère aucune adresse
+    //si on a adresse == -1 => on ne recupère aucune adresse
     if(isset($params[2]) && ($params[2] == -1)) unset($params[2]);
 
-
     if( !empty($params[1]) ){ // on verifie qu'on a bien un matricule
 
         //on ne recupere pas les adresses inutilement
@@ -78,11 +75,11 @@ function get_annuaire_infos($method, $params) {
                         $i++;
                     }
                 }
-                
-                // on rajoute les numéros de tél
+
+                // on rajoute les numéros de tél
                 $adrid_index = array();
                 foreach ($array['adresse'] as $i => $a) $adrid_index[$a['adrid']] = $i;
-                // on rajoute les numéros de tels
+                // on rajoute les numéros de tels
                 $restel = XDB::iterator(
                     "SELECT t.tel, t.tel_type, t.adrid
                        FROM tels AS t
@@ -92,10 +89,10 @@ function get_annuaire_infos($method, $params) {
                 foreach ($array['adresse'] as $i => $adr) {
                     unset($lasttel);
                     foreach($adr['tels'] as $j => $t){
-                        if (!isset($array['adresse'][$i]['tel']) && (strpos($t['tel_type'], 'Tél') === 0)) $array['adresse'][$i]['tel'] = $t['tel']; 
+                        if (!isset($array['adresse'][$i]['tel']) && (strpos($t['tel_type'], 'Tél') === 0)) $array['adresse'][$i]['tel'] = $t['tel'];
                         elseif (!isset($array['adresse'][$i]['fax']) && (strpos($t['tel_type'], 'Fax') === 0)) $array['adresse'][$i]['fax'] = $t['tel'];
                         else $lasttel = $t['tel'];
-                        if (isset($array['adresse'][$i]['tel']) && isset($array['adresse'][$i]['fax'])) break; 
+                        if (isset($array['adresse'][$i]['tel']) && isset($array['adresse'][$i]['fax'])) break;
                     }
                     if (!isset($array['adresse'][$i]['tel']) && isset($lasttel))
                         $array['adresse'][$i]['tel'] = $lasttel;
@@ -110,9 +107,9 @@ function get_annuaire_infos($method, $params) {
             }
         }
 
-        if ($array) { // on a bien eu un résultat : le matricule etait bon
+        if ($array) { // on a bien eu un résultat : le matricule etait bon
 
-            //on n'envoit que l'age à manageurs le format est YYYY-MM-DD 0123-56-89
+            //on n'envoit que l'age à manageurs le format est YYYY-MM-DD 0123-56-89
             $year  = (int) substr($array['age'],0,4);
             $month = (int) substr($array['age'],5,2);
             $day   = (int) substr($array['age'],8,2);
@@ -140,9 +137,9 @@ function get_annuaire_infos($method, $params) {
         $args  = array("erreur" => 1, "erreurstring" => $error_mat);
         $reply = xmlrpc_encode_request(NULL,$args);
     }
-            
-    return $reply; 
-} 
+
+    return $reply;
+}
 
 function get_nouveau_infos($method, $params) {
     global $error_mat, $error_key, $globals;
@@ -151,14 +148,15 @@ function get_nouveau_infos($method, $params) {
     if( !empty($params[1]) ){ // on verifie qu'on a bien un matricule
 
         $res = XDB::query(
-                "SELECT  a.nom, a.nom_usage,a.prenom,a.flags='femme' as femme ,a.deces!= 0 as decede ,a.naissance,a.promo,al.alias as mail 
-                FROM  auth_user_md5 AS a
-                INNER JOIN aliases as al ON a.user_id=al.id
-                WHERE al.flags='bestalias' and  a.matricule = {?}",$params[1]);
+            "SELECT  a.nom, a.nom_usage,a.prenom, FIND_IN_SET('femme', a.flags) as femme ,a.deces!= 0 as decede ,
+            a.naissance, a.promo, concat(al.alias, '@m4x.org') as mail
+            FROM  auth_user_md5 AS a
+            INNER JOIN aliases as al ON a.user_id=al.id
+            WHERE al.flags='bestalias' and  a.matricule = {?}",$params[1]);
         $data=$res->fetchOneAssoc();
         //$data['mail'].='@polytechnique.org';
 
-        
+
         //on commence le cryptage des donnees
         if (manageurs_encrypt_init($params[1]) == 1) {//on a pas trouve la cle pour crypter
             $args  = array("erreur" => 3, "erreurstring" => $error_key);
@@ -176,4 +174,5 @@ function get_nouveau_infos($method, $params) {
 
 }
 
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>