gestion des oranges : modification, validation, anniversaires, fiche
authorPascal Corpet <pascal.corpet@m4x.org>
Mon, 18 Apr 2005 20:52:50 +0000 (20:52 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:28:40 +0000 (23:28 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-574

15 files changed:
ChangeLog
htdocs/carnet/notifs.php
htdocs/fiche.php
htdocs/orange.php [new file with mode: 0644]
include/notifs.inc.php
include/profil/assign_general.inc.php
include/profil/get_general.inc.php
include/user.func.inc.php
include/validations/orange.inc.php [new file with mode: 0644]
templates/carnet/notifs.tpl
templates/fiche.tpl
templates/include/form.valid.orange.tpl [new file with mode: 0644]
templates/orange.tpl [new file with mode: 0644]
templates/profil/general.tpl
upgrade/0.9.6/30_auth_user_md5.sql [new file with mode: 0644]

index 5a59d9b..ae42aa0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@ VERSION 0.9.6                                                                                                            -- May 2004
 
 New :
 
+       * Profule :
+               - Stayed down students (orange) management.                                                     -Car
+               
        * Search :
                - Last improvements (clean code for search now !).                                      -MC
 
index 6665995..e8bb1cf 100644 (file)
@@ -25,6 +25,10 @@ require_once('notifs.inc.php');
 
 $watch = new Watch(Session::getInt('uid'));
 
+$res = $globals->xdb->query("SELECT promo_sortie FROM auth_user_md5 WHERE user_id = {?}", Session::getInt('uid', -1));
+$promo_sortie = $res->fetchOneCell();
+$page->assign('promo_sortie', $promo_sortie);
+
 if(Env::has('promo')) {
     if(preg_match('!^ *(\d{4}) *$!', Env::get('promo'), $matches)) {
        $p = intval($matches[1]);
index a7a1bdf..1842dc1 100644 (file)
@@ -77,6 +77,8 @@ if($user['x'] < 160){
 // manage the public fiche
 $page->assign('logged', logged());
 if (!logged()) {
+    // hide the orange status
+    $user['promo_sortie'] = $user['promo'] + 3;
     if ($user['mobile_pub'] != 'public') $user['mobile'] = '';
     if ($user['web_pub'] != 'public') $user['web'] = '';
     if ($user['freetext_pub'] !=  'public') $user['freetext'] = '';
diff --git a/htdocs/orange.php b/htdocs/orange.php
new file mode 100644 (file)
index 0000000..dd1d791
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+require_once("xorg.inc.php");
+require_once("validations.inc.php");
+require_once("xorg.misc.inc.php");
+
+new_skinned_page('orange.tpl', AUTH_MDP);
+
+$res = $globals->xdb->query(
+        "SELECT  u.promo,u.promo_sortie
+           FROM  auth_user_md5  AS u
+          WHERE  user_id={?}", Session::getInt('uid'));
+
+list($promo,$promo_sortie_old) = $res->fetchOneRow();
+$page->assign('promo_sortie_old', $promo_sortie_old);
+$page->assign('promo',  $promo);
+
+$promo_sortie = Env::get('promo_sortie');
+
+if ($promo_sortie) {
+       $sortie_req = false;
+       if (!is_numeric($promo_sortie) || $promo_sortie < 1000 || $promo_sortie > 9999)
+       $page->trig('L\'année de sortie doit être un nombre de quatre chiffres');
+       elseif ($promo_sortie < $promo + 3)
+       $page->trig('Trop tôt');
+       else 
+       $page->assign('promo_sortie', $sortie_req = $promo_sortie);
+
+       if (Env::has('submit') && $sortie_req && ($promo_sortie_old != $sortie_req)) {
+               $myorange = new OrangeReq(Session::getInt('uid'), $sortie_req);
+               $myorange->submit();
+               $page->assign('myorange', $myorange);
+       }
+}
+
+$page->run();
+?>
index 1205a21..b27d4d5 100644 (file)
@@ -65,7 +65,7 @@ function _select_notifs_base($table, $mail, $where)
                 'contact_sql' => '1'
             ),
             'watch_promo'  => Array('wfield' => 'promo',   'ufield' => 'promo',   'need_contact' => true,
-                'freq_sql' => ' AND ( wc.type = "basic" OR wc.type="near" AND (w.promo <= v.promo+1 AND w.promo >= v.promo-1) )',
+                'freq_sql' => ' AND ( wc.type = "basic" OR wc.type="near" AND (u.promo <= v.promo_sortie-2 AND u.promo_sortie >= v.promo+2) )',
                 'contact_sql' => 'NOT (c.contact IS NULL)'
             ),
             'watch_nonins' => Array('wfield' => 'ni_id',   'ufield' => 'user_id', 'need_contact' => false,
index 8f14bc5..1823b75 100644 (file)
@@ -26,6 +26,7 @@ $page->assign('freetext_pub',$freetext_pub);
 $page->assign('nom', $nom);
 $page->assign('prenom', $prenom);
 $page->assign('promo', $promo);
+$page->assign('promo_sortie', $promo_sortie);
 $page->assign('nom_usage', $nom_usage);
 
 $page->assign('nationalite',$nationalite);
index 3200775..2def19a 100644 (file)
@@ -20,7 +20,7 @@
  ***************************************************************************/
 
 // on ramène les données du profil connecté (uid paramètre de session)
-$sql = "SELECT  u.nom, u.prenom, u.nom_ini, u.prenom_ini, u.promo, u.nom_usage, u.nationalite,
+$sql = "SELECT  u.nom, u.prenom, u.nom_ini, u.prenom_ini, u.promo, u.promo_sortie, u.nom_usage, u.nationalite,
                q.profile_mobile, q.profile_mobile_pub, q.profile_web, q.profile_web_pub, q.profile_freetext, q.profile_freetext_pub, q.profile_nick,
                 a1.aid, a1.type, a2.aid, a2.type
           FROM  auth_user_md5   AS u
@@ -30,7 +30,7 @@ $sql = "SELECT  u.nom, u.prenom, u.nom_ini, u.prenom_ini, u.promo, u.nom_usage,
         WHERE  u.user_id = {?}";
 
 $result = $globals->xdb->query($sql, Session::getInt('uid', -1));
-list($nom, $prenom, $nom_ini, $prenom_ini, $promo, $nom_usage, $nationalite,
+list($nom, $prenom, $nom_ini, $prenom_ini, $promo, $promo_sortie, $nom_usage, $nationalite,
        $mobile, $mobile_pub, $web, $web_pub, $freetext, $freetext_pub, $nickname, 
         $appli_id1,$appli_type1, $appli_id2,$appli_type2) = $result->fetchOneRow();
 
index 86cf616..c70a9e8 100644 (file)
@@ -155,7 +155,7 @@ function get_user_forlife($data) {
 function &get_user_details($login, $from_uid = '')
 {
     global $globals;
-    $reqsql = "SELECT  u.user_id, u.promo, u.prenom, u.nom, u.nom_usage, u.date, u.cv,
+    $reqsql = "SELECT  u.user_id, u.promo, u.promo_sortie, u.prenom, u.nom, u.nom_usage, u.date, u.cv,
                        u.perms IN ('admin','user') AS inscrit,  FIND_IN_SET('femme', u.flags) AS sexe, u.deces != 0 AS dcd, u.deces,
                        q.profile_nick AS nickname, q.profile_from_ax, q.profile_mobile AS mobile, q.profile_web AS web, q.profile_freetext AS freetext,
                        q.profile_mobile_pub AS mobile_pub, q.profile_web_pub AS web_pub, q.profile_freetext_pub AS freetext_pub,
diff --git a/include/validations/orange.inc.php b/include/validations/orange.inc.php
new file mode 100644 (file)
index 0000000..4e285a6
--- /dev/null
@@ -0,0 +1,101 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+// {{{ class OrangeReq
+
+class OrangeReq extends Validate
+{
+    // {{{ properties
+
+    var $unique = true;
+
+    var $promo;
+    var $promo_sortie;
+    
+    var $rules = "A priori accepter (la validation sert à repousser les
+    petits malins). Refuse si tu connais la personne et que tu es sure 
+    qu'elle n'est pas orange.";
+
+    // }}}
+    // {{{ constructor
+
+    function OrangeReq($_uid, $_sortie)
+    {
+        global $globals;
+        $this->Validate($_uid, true, 'orange');
+        $this->promo_sortie  = $_sortie;
+        $res = $globals->xdb->query("SELECT promo FROM auth_user_md5 WHERE user_id = {?}", $_uid);
+        $this->promo = $res->fetchOneCell(); 
+    }
+
+    // }}}
+    // {{{ function get_request()
+
+    function get_request($uid)
+    {
+        return parent::get_request($uid,'orange');
+    }
+
+    // }}}
+    // {{{ function formu()
+
+    function formu()
+    { return 'include/form.valid.orange.tpl'; }
+
+    // }}}
+    // {{{ function _mail_subj()
+
+    function _mail_subj()
+    {
+        return "[Polytechnique.org/ORANGE] Changement de nom de promo de sortie";
+    }
+
+    // }}}
+    // {{{ function _mail_body
+
+    function _mail_body($isok)
+    {
+        global $globals;
+        if ($isok) {
+            $res = "  La demande de changement de promo de sortie que tu as demandée vient d'être effectuée.";
+            return $res;
+        } else {
+            return "  La demande de changement de promo de sortie tu avais faite a été refusée.";
+        }
+    }
+
+    // }}}
+    // {{{ function commit()
+
+    function commit()
+    {
+        global $globals;
+        
+        $globals->xdb->execute("UPDATE auth_user_md5 set promo_sortie={?} WHERE user_id={?}",$this->promo_sortie ,$this->uid);
+        return true;
+    }
+
+    // }}}
+}
+// }}}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
index 6f998d6..925efdc 100644 (file)
@@ -41,7 +41,7 @@ S'il n'y a rien 
     {$s.short} {if $s.type eq near}<sup>o</sup>{elseif $s.type eq often}<sup>*</sup>{/if}<br />
     {/foreach}
     <span class='smaller'><sup>*</sup>: ne concerne pas les promos (évènements très fréquents)</span><br />
-    <span class='smaller'><sup>o</sup>: ne concerne que les promos entre {$smarty.session.promo-1} et {$smarty.session.promo+1} que tu surveilles</span>
+    <span class='smaller'><sup>o</sup>: ne concerne que les promos entre {$smarty.session.promo-1} et {$promo_sortie-2} que tu surveilles</span>
   </fieldset>
   <div class='center'>
     <input type='submit' name='subs' value='valider' />
index c16e8fa..aeb1264 100644 (file)
@@ -88,7 +88,13 @@ function chgMainWinLoc( strPage ) {
         {if $x.iso3166}
         <img src='{rel}/images/flags/{$x.iso3166}.gif' alt='{$x.nationalite}' height='14' title='{$x.nationalite}' />&nbsp;
         {/if}
-        X {$x.promo}{if $x.applis_join}&nbsp;-&nbsp;Formation&nbsp;: {$x.applis_join|smarty:nodefaults} {/if}
+        X {$x.promo}
+        {if ($x.promo_sortie-3 > $x.promo)}
+          - X {math equation="a-b" a=$x.promo_sortie b=3}
+        {/if}
+        {if $x.applis_join}
+          &nbsp;-&nbsp;Formation&nbsp;: {$x.applis_join|smarty:nodefaults}
+        {/if}
         {min_auth level="cookie"}
         {if $x.is_referent}
         [<a href="fiche_referent.php?user={$x.forlife}" class='popup2'>Ma fiche référent</a>]
diff --git a/templates/include/form.valid.orange.tpl b/templates/include/form.valid.orange.tpl
new file mode 100644 (file)
index 0000000..377bbf0
--- /dev/null
@@ -0,0 +1,31 @@
+{***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************}
+
+
+<tr class="impair">
+  <td class="titre">Promotion&nbsp;:</td>
+  <td>{$valid->promo}</td>
+</tr>
+<tr class="impair">
+  <td class="titre">Année de sortie&nbsp;:</td>
+  <td>{$valid->promo_sortie} au lieu de {math equation="a + b" a=$valid->promo b=3}</td>
+</tr>
+
+{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/orange.tpl b/templates/orange.tpl
new file mode 100644 (file)
index 0000000..7f0acc3
--- /dev/null
@@ -0,0 +1,59 @@
+{***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************}
+
+
+<h1>
+  Année de sortie
+</h1>
+
+{if $myorange}
+  
+  <p>
+    Tu recevras un mail dès que les changements demandés auront été effectués. 
+    Encore merci de nous faire confiance pour tes e-mails !
+  </p>
+
+{else}
+
+  <p>
+  Afin de pouvoir être considéré(e) à la fois dans ta promotion d'origine et ta
+  ou tes promotions d'adoption tu peux entrer ici ton année de sortie de l'école.
+  Plus précisément, il s'agit de l'année d'entrée en quatrième année ou année d'application. Pour tes cocons d'origine (X{$promo}) il s'agit de l'année {math equation="a + b" a=$promo b=3}.
+  </p>
+
+  <br />
+
+  <form action="{$smarty.server.PHP_SELF}" method="post">
+    <table class="bicol" cellpadding="4" summary="Année de sortie">
+      <tr>
+        <th>Année de sortie</th>
+      </tr>
+      <tr>
+        <td class="center"><input type="text" name="promo_sortie" value="{$promo_sortie_old}" /></td>
+      </tr>
+      <tr>
+        <td class="center"><input type="submit" name="submit" value="Envoyer" /></td>
+      </tr>
+    </table>
+  </form>
+  {/if}
+<p>[<a href="profil.php">Revenir au profil</a>]</p>
+
+{* vim:set et sw=2 sts=2 sws=2: *}
index acf508c..ad8aa76 100644 (file)
@@ -65,7 +65,8 @@
         <span class="titre">Promotion</span>
       </td>
       <td class="cold">
-        <span class="nom">X{$promo}</span>
+        <span class="nom">X{$promo}{if ($promo != $promo_sortie - 3)} - X{math equation="a - b" a=$promo_sortie b=3}{/if}</span>
+        <span class="lien"><a href="orange.php">modifier</a>{if ($promo_sortie -3 == $promo)} pour les oranges{/if}</span>
       </td>
     </tr>     
     <tr>
diff --git a/upgrade/0.9.6/30_auth_user_md5.sql b/upgrade/0.9.6/30_auth_user_md5.sql
new file mode 100644 (file)
index 0000000..61a4fe1
--- /dev/null
@@ -0,0 +1,3 @@
+ALTER TABLE auth_user_md5 ADD promo_sortie SMALLINT(4) UNSIGNED NOT NULL AFTER promo;
+UPDATE auth_user_md5 SET promo_sortie = promo + 3;
+