you can now add decorations, medals and stuff in the profile
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Sat, 15 Jan 2005 22:42:11 +0000 (22:42 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:40 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-348

htdocs/images/medals/croix_cc.jpg [new file with mode: 0644]
include/profil/assign_deco.inc.php [new file with mode: 0644]
include/profil/get_deco.inc.php [new file with mode: 0644]
include/profil/update_deco.inc.php [new file with mode: 0644]
include/profil/verif_deco.inc.php [new file with mode: 0644]
include/tabs.inc.php
templates/profil.tpl
templates/profil/deco.tpl [new file with mode: 0644]
templates/profil/poly.tpl
upgrade/0.9.4/80_medals.sql

diff --git a/htdocs/images/medals/croix_cc.jpg b/htdocs/images/medals/croix_cc.jpg
new file mode 100644 (file)
index 0000000..3d16ef2
Binary files /dev/null and b/htdocs/images/medals/croix_cc.jpg differ
diff --git a/include/profil/assign_deco.inc.php b/include/profil/assign_deco.inc.php
new file mode 100644 (file)
index 0000000..fc1cdc2
--- /dev/null
@@ -0,0 +1,43 @@
+<?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                *
+ ***************************************************************************/
+
+
+$res    = $globals->xdb->iterator("SELECT * FROM profile_medals_grades ORDER BY mid, pos");
+$grades = Array();
+while ($tmp = $res->next()) {
+    $grades[$tmp['mid']][] = $tmp;
+}
+
+$res    = $globals->xdb->iterator("SELECT * FROM profile_medals ORDER BY type, text");
+$mlist  = Array();
+while ($tmp = $res->next()) {
+    $mlist[$tmp['type']][] = $tmp;
+}
+
+$trad = Array('ordre' => 'Ordres ...', 'croix' => 'Croix ...', 'militaire' => 'Médailles militaires ...',
+        'honneur' => 'Médailles d\'honneur', 'resistance' => 'Médailles de la résistance ...');
+
+$page->gassign('grades');
+$page->gassign('medals');
+$page->gassign('trad');
+$page->assign('medal_list', $mlist);
+
+?>
diff --git a/include/profil/get_deco.inc.php b/include/profil/get_deco.inc.php
new file mode 100644 (file)
index 0000000..01853a2
--- /dev/null
@@ -0,0 +1,45 @@
+<?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                *
+ ***************************************************************************/
+
+if (Env::has('medal_op')) {
+    if (Env::get('medal_op')=='retirer' && Env::getInt('medal_id')) {
+        $globals->xdb->execute("DELETE FROM profile_medals_sub WHERE uid = {?} AND mid = {?}", Session::getInt('uid', -1), Env::getInt('medal_id', -1));
+    }
+
+    if (Env::get('medal_op')=='ajouter' && Env::getInt('medal_id')) {
+        $globals->xdb->execute("INSERT INTO profile_medals_sub (uid,mid) VALUES ({?}, {?})", Session::getInt('uid', -1), Env::getInt('medal_id'));
+    }
+}
+
+foreach (Post::getMixed('grade') as $mid=>$gid) {
+    $globals->xdb->execute('UPDATE profile_medals_sub SET gid={?} WHERE uid={?} AND mid={?}', $gid, Session::getInt('uid'), $mid);
+}
+
+$res    = $globals->xdb->query(
+       "SELECT  m.id, m.text AS medal, m.type, m.img, s.gid
+           FROM  profile_medals_sub    AS s
+     INNER JOIN  profile_medals        AS m ON ( s.mid = m.id )
+          WHERE  s.uid = {?}", Session::getInt('uid', -1));
+
+$medals = $res->fetchAllAssoc();
+
+?>
diff --git a/include/profil/update_deco.inc.php b/include/profil/update_deco.inc.php
new file mode 100644 (file)
index 0000000..330b130
--- /dev/null
@@ -0,0 +1,22 @@
+<?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                *
+ ***************************************************************************/
+
+?>
diff --git a/include/profil/verif_deco.inc.php b/include/profil/verif_deco.inc.php
new file mode 100644 (file)
index 0000000..85452e9
--- /dev/null
@@ -0,0 +1,21 @@
+<?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                *
+ ***************************************************************************/
+?>
index 81f2a58..559179f 100644 (file)
@@ -24,6 +24,7 @@ $tabname_array = Array(
     "general"  => "Informations\ngénérales",
     "adresses" => "Adresses\npersonnelles",
     "poly"     => "Informations\npolytechniciennes",
+    "deco"     => "Décorations\nMédailles",
     "emploi"   => "Informations\nprofessionnelles",
     "skill"    => "Compétences\ndiverses",
     "mentor"   => "Mentoring"
index 538bdd4..5f30478 100644 (file)
@@ -43,10 +43,6 @@ tel qu'elle appara
           {/if}
           {/foreach}
         </ul>
-        <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" />
         <input type="hidden" value="{$onglet}" name="old_tab" />
         <input type="hidden" value="" name="adresse_flag" />
       </td>
diff --git a/templates/profil/deco.tpl b/templates/profil/deco.tpl
new file mode 100644 (file)
index 0000000..aa575d9
--- /dev/null
@@ -0,0 +1,115 @@
+{***************************************************************************
+ *  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                *
+ ***************************************************************************}
+
+
+{literal}
+<script type="text/javascript">//<![CDATA[
+  function medal_add()
+  {
+    var selid = document.forms.prof_annu.medal_sel.selectedIndex;
+    document.forms.prof_annu.medal_id.value = document.forms.prof_annu.medal_sel.options[selid].value;
+    document.forms.prof_annu.medal_op.value = "ajouter";
+    document.forms.prof_annu.submit();
+  }
+
+  function medal_del( id )
+  {
+    document.forms.prof_annu.medal_id.value = id;
+    document.forms.prof_annu.medal_op.value = "retirer";
+    document.forms.prof_annu.submit();
+  }
+  //]]>
+</script>
+{/literal}
+
+<div class="blocunite_tab">
+  <input type="hidden" value="" name="medal_op" />
+  <input type="hidden" value="" name="medal_id" />
+  <table class="bicol" cellspacing="0" cellpadding="0">
+    <tr>
+      <th colspan="3">
+        Médailles, Décorations, Prix, ...
+      </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">
+              ne peut être ni public ni transmis à l'AX
+            </td>
+          </tr>
+        </table>
+      </td>
+    </tr>
+    {foreach from=$medals item=m}
+    <tr>
+      <td class="colg">
+        <img src='{rel}/images/medals/{$m.img}' width="32" alt="{$m.medal}" title="{$m.medal}" />
+      </td>
+      <td class="colm">
+        <span class="valeur">{$m.medal}</span><br />
+        {if $grades[$m.id]|@count}
+        <select name="grade[{$m.id}]">
+          <option value='0'>-- non précisé --</option>
+          {foreach from=$grades[$m.id] item=g}
+          <option value='{$g.gid}' {if $g.gid eq $m.gid}selected='selected'{/if}>{$g.text}</option>
+          {/foreach}
+        </select>
+        {else}
+        -- non précisé --
+        {/if}
+      </td>
+      <td class="cold">
+        <span class="lien">
+          <a href="javascript:medal_del({$m.id});">retirer</a>
+        </span>
+      </td>
+    </tr>
+    {/foreach}
+    <tr>
+      <td class="colg">
+        &nbsp;
+      </td>
+      <td class="colm">
+        <select name="medal_sel">
+          <option value=''></option>
+          {foreach from=$medal_list key=type item=list}
+          <optgroup label="{$trad[$type]}">
+            {foreach from=$list item=m}
+            <option value="{$m.id}">{$m.text}</option>
+            {/foreach}
+          </optgroup>
+          {/foreach}
+        </select>
+      </td>
+      <td class="cold">
+        <span class="lien">
+          <a href="javascript:medal_add();">ajouter</a>
+        </span>
+      </td>
+    </tr>
+  </table>
+</div>
+
+{* vim:set et sw=2 sts=2 sws=2: *}
index 9d9ba73..d7aebc5 100644 (file)
 </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>
index 8e36a07..d48ccbe 100644 (file)
@@ -20,6 +20,14 @@ create table profile_medals_grades (
         primary key (mid, gid)
 );
 
+drop table if exists profile_medals_sub;
+create table profile_medals_sub (
+        uid int not null,
+        mid int not null,
+        gid int not null,
+        primary key (uid,mid)
+);
+
 insert into profile_medals (type, text, img)
      values ('ordre',     'Ordre Nationnal de la Legion d\'Honneur',    'ordre_onlh.jpg'),
             ('ordre',     'Ordre de la libération',                     'ordre_lib.jpg'),