Start working on the "polytechnique" page
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 31 Aug 2007 21:33:51 +0000 (23:33 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 31 Aug 2007 21:33:51 +0000 (23:33 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
modules/profile/groups.inc.php [new file with mode: 0644]
modules/profile/page.inc.php
templates/profile/adresses.address.tpl
templates/profile/poly.tpl

diff --git a/modules/profile/groups.inc.php b/modules/profile/groups.inc.php
new file mode 100644 (file)
index 0000000..40b8b61
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2007 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 ProfileGroups extends ProfilePage
+{
+    protected $pg_template = 'profile/poly.tpl';
+
+    public function __construct(PlWizard &$wiz)
+    {
+        parent::__construct($wiz);
+        $this->settings['section'] = $this->settings['binets']
+                                   = $this->settings['groupesx']
+                                   = null;
+    }
+
+    protected function fetchData()
+    {
+        parent::fetchData();
+    }
+
+    public function prepare(PlatalPage &$page)
+    {
+        parent::prepare($page);
+    }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
index 0d8b29c..4566a10 100644 (file)
@@ -225,6 +225,7 @@ abstract class ProfilePage implements PlWizardPage
 
 require_once dirname(__FILE__) . '/general.inc.php';
 require_once dirname(__FILE__) . '/addresses.inc.php';
+require_once dirname(__FILE__) . '/groups.inc.php';
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index 09d13b0..2f58968 100644 (file)
@@ -53,7 +53,9 @@
   </tr>
   <tr>
     <td>
-      <div>{include file="include/flags.radio.tpl" name="`$adpref`[pub]" notable=true val=$adr.pub}</div>
+      <div style="margin-bottom: 0.2em">
+        {include file="include/flags.radio.tpl" name="`$adpref`[pub]" notable=true val=$adr.pub}
+      </div>
       <div style="clear: both"></div>
       <div style="float: left">{include file="geoloc/form.address.tpl" name=$adpref id=$adid adr=$adr}</div>
       <div style="float: left">
index c914139..866d6a0 100644 (file)
 
 {literal}
 <script type="text/javascript">//<![CDATA[
-  /** defgroup user_profile Gestion du profil utilisateur */
+  var gdt = new Date();
+  var year = gdt.getYear();
+  if (year < 1000) {
+    year += 1900;
+  }
 
-  /** ajout d'un binet au profil de l'utilisateur en base de données
-  * le binet est déterminé par binet_id qui est sélectionné dans un SELECT
-  * @ingroup user_profile
-  * @return VOID
-  */
-  function binet_add()
-  {
-    var selid = document.forms.prof_annu.binet_sel.selectedIndex;
-    document.forms.prof_annu.binet_id.value = document.forms.prof_annu.binet_sel.options[selid].value;
-    document.forms.prof_annu.binet_op.value = "ajouter";
-    document.forms.prof_annu.submit();
-  } // function binet_add()
-
-
-
-  /** suppression d'un binet du profil de l'utilisateur en base de données
-  * @ingroup user_profile
-  * @param id INT id du binet
-  * @return VOID
-  */
-  function binet_del( id )
-  {
-    document.forms.prof_annu.binet_id.value = id;
-    document.forms.prof_annu.binet_op.value = "retirer";
-    document.forms.prof_annu.submit();
-  } // END function binet_del( id )
+  var oldMate = year >= {/literal}{$smarty.session.promo_sortie}{literal};
 
-
-
-  /** ajout d'un groupeX au profil de l'utilisateur en base de données
-  * le groupeX est déterminé par groupex_id qui est sélectionné dans un SELECT
-  * @ingroup user_profile
-  * @return VOID
-  */
-  function groupex_add()
+  function printTitle(text)
   {
-    var selid = document.forms.prof_annu.groupex_sel.selectedIndex;
-    document.forms.prof_annu.groupex_id.value = document.forms.prof_annu.groupex_sel.options[selid].value;
-    document.forms.prof_annu.groupex_op.value = "ajouter";
-    document.forms.prof_annu.submit();
-  } // END function groupex_add()
+    if (oldMate) {
+      document.write("ex-" + text);
+    } else {
+      document.write(text);
+    }
+  }
 
-  /** suppression d'un groupeX du profil de l'utilisateur en base de données
-  * @ingroup user_profile
-  * @param id INT id du groupeX
-  * @return VOID
-  */
-  function groupex_del( id )
+  function update(type)
   {
-    document.forms.prof_annu.groupex_id.value = id;
-    document.forms.prof_annu.groupex_op.value = 'retirer';
-    document.forms.prof_annu.submit();
-  } // END function groupex_del( id )
+    if (document.forms.prof_annu[type + '_sel'].value == '0') {
+      document.getElementById(type + '_add').style.display = 'none';
+    } else {
+      document.getElementById(type + '_add').style.display = '';
+    }
+  }
 
   //]]>
 </script>
 {/literal}
-<div class="blocunite_tab">
-  <input type="hidden" value="" name="binet_op" />
-  <input type="hidden" value="" name="binet_id" />
-  <input type="hidden" value="" name="groupex_op" />
-  <input type="hidden" value="" name="groupex_id" />
-  <table class="bicol" cellspacing="0" cellpadding="0" 
-    summary="Profil: Informations Polytechniciennes">
-    <tr>
-      <th colspan="3">
-        Informations polytechniciennes
-      </th>
-    </tr>
-    <tr>
-      <td colspan="3" class="pflags">
-        <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
-          <tr>
-            <td class="rouge">
-              <input type="checkbox" name="accesX" checked="checked" disabled="disabled" />
-            </td>
-            <td class="texte">
-              privé
-            </td>
-          </tr>
-        </table>
-      </td>
-    </tr>
-    <tr class="top">
-      <td class="colg">
-        <span class="titre">(ex-)Section</span>
-      </td>
-      <td class="colm">
-        <select name="section">
-          {select_db_table table="sections" valeur=$section}
-        </select>
-      </td>
-      <td class="cold">
-        &nbsp;
-      </td>
-    </tr>
-    <!-- Binets -->
-    <tr class="top">
-      <td class="colg">
-        <span class="titre">(ex-)Binet(s)</span>
-      </td>
-      {foreach from=$binets item=b}
-      <td class="colm">
-        <span class="valeur">{$b.text}</span>
-      </td>
-      <td class="cold">
-        <span class="lien">
-          <a href="javascript:binet_del({$b.id});">retirer</a>
-        </span>
-      </td>
-    </tr>
-    <tr>
-      <td class="colg">
-        &nbsp;
-      </td>
-      {/foreach}
-      <td class="colm">
-        <select name="binet_sel">
-          {select_db_table table="binets_def" valeur=0 champ="text" pad='1'}
-        </select>
-      </td>
-      <td class="cold">
-        <span class="lien">
-          <a href="javascript:binet_add();">ajouter</a>
-        </span>
-      </td>
-    </tr>
-    <!-- Groupes X -->
-    <tr class="top">
-      <td class="colg">
-        <span class="titre">Groupe(s) X</span>
-      </td>
-      {foreach from=$groupesx item=g}
-      <td class="colm">
-        <span class="valeur">{$g.text}</span>
-      </td>
-      <td class="cold">
-        <span class="lien">
-          <a href="javascript:groupex_del({$g.id});">retirer</a>
-        </span>
-      </td>
-    </tr>
-    <tr>
-      <td class="colg">
-        &nbsp;
-      </td>
-      {/foreach}
-      <td class="colm">
-        <select name="groupex_sel">
-          {select_db_table table="groupesx_def" valeur=0 champ="text" pad='1'}
-        </select>
-      </td>
-      <td class="dcold">
-        <span class="lien">
-          <a href="javascript:groupex_add();">ajouter</a>
-        </span>
-      </td>
-    </tr>
-  </table>
-</div>
+
+<table class="bicol" summary="Profil: Informations Polytechniciennes">
+  <tr>
+    <th colspan="2">
+      Informations polytechniciennes
+    </th>
+  </tr>
+  <tr>
+    <td colspan="2" class="flags">
+      <span class="rouge"><input type="checkbox" name="accesX" checked="checked" disabled="disabled" /></span>
+      <span class="texte">privé</span>
+    </td>
+  </tr>
+  <tr class="top">
+    <td class="titre">
+      <script type="text/javascript">printTitle("Section")</script>
+    </td>
+    <td>
+      <select name="section">
+        {select_db_table table="sections" valeur=$section}
+      </select>
+    </td>
+  </tr>
+  <!-- Binets -->
+  <tr>
+    <td class="titre">
+      <script type="text/javascript">printTitle("Binet(s)")</script>
+    </td>
+    <td>
+      <select name="binet_sel" onchange="update('binet')">
+        {select_db_table table="binets_def" valeur=0 champ="text" pad='1'}
+      </select>
+      <a id="binet_add" href="javascript:addBinet()">{icon name="add" title="Ajouter ce binet"}</a>
+    </td>
+  </tr>
+  <!-- Groupes X -->
+  <tr>
+    <td class="titre">Groupe(s) X</td>
+    <td>
+      <select name="groupex_sel" onchange="update('groupex')">
+        {select_db_table table="groupesx_def" valeur=0 champ="text" pad='1'}
+      </select>
+      <a id="groupex_add" href="javascript:addGroupex()">{icon name="add" title="Ajouter ce groupe X"}</a>
+    </td>
+  </tr>
+</table>
+
+<script type="text/javascript">
+update('groupex');
+update('binet');
+</script>
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}