closes FS#210
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Sun, 16 Jan 2005 14:09:49 +0000 (14:09 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:42 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-354

ChangeLog
htdocs/admin/gerer_decos.php [new file with mode: 0644]
templates/admin/gerer_decos.tpl [new file with mode: 0644]

index 769a1ea..b43e46b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -73,6 +73,7 @@ Bug/Wish :
                - #65 : Add professionnal cellphone.                                                            -Car
                - #170 : Remove region display for french departments.                          -Car
                - #204 : Add nicknames (searchable too).                                                        -MC
+               - #210 : Add medals and orders.                                                                         -MC
 
        * Search :
                - #249, #251, #253 : Some tweaks to be more accurate.                           -MC
diff --git a/htdocs/admin/gerer_decos.php b/htdocs/admin/gerer_decos.php
new file mode 100644 (file)
index 0000000..6c1a5b4
--- /dev/null
@@ -0,0 +1,51 @@
+<?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');
+new_admin_table_editor('profile_medals', 'id');
+
+$editor->describe('type', 'type', true, 'set');
+$editor->describe('text', 'intitulé',  true);
+$editor->describe('img',  'nom de l\'image', false);
+
+$editor->assign('title',  'Gestion des Distinctions');
+
+if (Post::get('frm_id')) {
+    $page->changeTpl('admin/gerer_decos.tpl');
+
+    $mid = Post::getInt('frm_id');
+
+    if (Post::get('act') == 'del') {
+        $globals->xdb->execute('DELETE FROM profile_medals_grades WHERE mid={?} AND gid={?}', $mid, Post::getInt('gid'));
+    } elseif (Post::get('act') == 'new') {
+        $globals->xdb->execute('INSERT INTO profile_medals_grades (mid,gid) VALUES({?},{?})',
+                $mid, max(array_keys(Post::getMixed('grades', Array(0))))+1);
+    } else {
+        foreach (Post::getMixed('grades', Array()) as $gid=>$text) {
+            $globals->xdb->execute('UPDATE profile_medals_grades SET pos={?}, text={?} WHERE gid={?}', $_POST['pos'][$gid], $text, $gid);
+        }
+    }
+    $res = $globals->xdb->iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid);
+    $page->assign('grades', $res);
+}
+
+$editor->run();
+?>
diff --git a/templates/admin/gerer_decos.tpl b/templates/admin/gerer_decos.tpl
new file mode 100644 (file)
index 0000000..28eefcb
--- /dev/null
@@ -0,0 +1,88 @@
+{***************************************************************************
+ *  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                *
+ ***************************************************************************}
+
+{include file=table-editor.tpl}
+
+<h1>Administration Polytechnique.org</h1>
+
+{literal}
+<script type="text/javascript">
+  <!--
+  function new_grade() {
+    document.forms.form_grade.act.value = "new";
+    document.forms.form_grade.submit();
+    return true;
+  }
+
+  function del_grade( myid ) {
+    if (confirm ("You are about to delete this entry. Do you want to proceed?")) {
+      document.forms.form_grade.act.value = "del";
+      document.forms.form_grade.gid.value = myid;
+      document.forms.form_grade.submit();
+      return true;
+    }
+  }
+  // -->
+</script>
+{/literal}
+
+<form method="post" action='#form_grade' id='form_grade'>
+  <table class='bicol'>
+    <tr>
+      <th>id</th>
+      <th>intitulé</th>
+      <th>ordre</th>
+      <th>&nbsp;</th>
+    </tr>
+    <tr>
+      <td colspan='3'>
+        Nouveau ...
+      </td>
+      <td  class='action'>
+        <a href='javascript:new_grade()'>nouveau</a>
+      </td>
+    </tr>
+    {iterate from=$grades item=g}
+    <tr class="{cycle values="pair,impair"}">
+      <td>{$g.gid}</td>
+      <td>
+        <input type='text' size='65' value="{$g.text}" name="grades[{$g.gid}]" />
+      </td>
+      <td>
+        <input type='text' maxlength='2' value="{$g.pos}" name="pos[{$g.gid}]" />
+      </td>
+      <td class='action'>
+        <a href='javascript:del_grade({$g.gid})'>suppr.</a>
+      </td>
+    </tr>
+    {/iterate}
+    <tr class="{cycle values="impair,pair"}">
+      <td colspan='4' class="center">
+        <input type='hidden' name='frm_id' value='{$smarty.post.frm_id}' />
+        <input type='hidden' name='action' value='{$smarty.post.action}' />
+        <input type='hidden' name='act' value='' />
+        <input type='hidden' name='gid' value='' />
+        <input type='submit' name='gr_sub' value='Sauver' />
+      </td>
+    </tr>
+  </table>
+</form>
+
+{* vim:set et sw=2 sts=2 sws=2: *}