From e7ae7df9ae05251891de4f101d31af256777f852 Mon Sep 17 00:00:00 2001 From: x2001corpet Date: Wed, 26 Jul 2006 09:44:19 +0000 Subject: [PATCH] nouveau table-editor (exit celui de diogenes), migration des dernieres pages admin git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@661 839d8a87-29fc-0310-9880-83ba4fa771e5 --- ChangeLog | 6 +- classes/PLTableEditor.php | 182 ++++++++++++++++++++++++++++++++ htdocs/admin_old/gerer_applis.php | 36 ------- htdocs/admin_old/gerer_auth-groupex.php | 35 ------ htdocs/admin_old/gerer_binets.php | 34 ------ htdocs/admin_old/gerer_coupure.php | 37 ------- htdocs/admin_old/gerer_decos.php | 54 ---------- htdocs/admin_old/gerer_groupesx.php | 35 ------ htdocs/admin_old/gerer_paiement.php | 41 ------- htdocs/admin_old/gerer_skins.php | 36 ------- htdocs/admin_old/logger_actions.php | 35 ------ htdocs/admin_old/newsletter_cats.php | 34 ------ htdocs/admin_old/postfix_blacklist.php | 35 ------ htdocs/admin_old/postfix_whitelist.php | 34 ------ include/xorg.inc.php | 11 -- include/xorg.table-editor.inc.php | 42 -------- modules/admin.php | 175 +++++++++++++++++++++++++++--- templates/admin/gerer_decos.tpl | 6 +- templates/admin/index.tpl | 24 ++--- templates/table-editor.tpl | 132 ++++++++--------------- 20 files changed, 410 insertions(+), 614 deletions(-) create mode 100644 classes/PLTableEditor.php delete mode 100644 htdocs/admin_old/gerer_applis.php delete mode 100644 htdocs/admin_old/gerer_auth-groupex.php delete mode 100644 htdocs/admin_old/gerer_binets.php delete mode 100644 htdocs/admin_old/gerer_coupure.php delete mode 100644 htdocs/admin_old/gerer_decos.php delete mode 100644 htdocs/admin_old/gerer_groupesx.php delete mode 100644 htdocs/admin_old/gerer_paiement.php delete mode 100644 htdocs/admin_old/gerer_skins.php delete mode 100644 htdocs/admin_old/logger_actions.php delete mode 100644 htdocs/admin_old/newsletter_cats.php delete mode 100644 htdocs/admin_old/postfix_blacklist.php delete mode 100644 htdocs/admin_old/postfix_whitelist.php delete mode 100644 include/xorg.table-editor.inc.php diff --git a/ChangeLog b/ChangeLog index 418c414..cae0545 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,7 +4,8 @@ VERSION 0.9.11 ?? ???? 2006 New: * Admin: - - Switch to the new URI scheme. -Car + - New table editor. -Car + - Switch to the new URI scheme. -Car * Auth: - Switch to the new URI scheme. -MC @@ -70,6 +71,9 @@ New: Bug/Wish: + * Admin: + - #430: Specify date format on downtime admin page. -Car + * Carnet: - #435: Calendar contains yearly events for all the contacts. -FRU diff --git a/classes/PLTableEditor.php b/classes/PLTableEditor.php new file mode 100644 index 0000000..16d1e95 --- /dev/null +++ b/classes/PLTableEditor.php @@ -0,0 +1,182 @@ +pl = $plname; + $this->table = $table; + $this->idfield = $idfield; + $this->idfield_editable = $editid; + $r = XDB::iterator("SHOW COLUMNS FROM $table"); + $this->vars = array(); + while ($a = $r->next()) { + // desc will be the title of the column + $a['desc'] = $a['Field']; + $a['display'] = true; + + if (substr($a['Type'],0,8) == 'varchar(') { + // limit editing box size + $a['Size'] = $a['Maxlength'] = substr($a['Type'], 8, strlen($a['Type']) - 9); + if ($a['Size'] > 40) $a['Size'] = 40; + // if too big, put a textarea + $a['Type'] = ($a['Maxlength']<200)?'varchar':'varchar200'; + } + elseif ($a['Type'] == 'text' || $a['Type'] == 'mediumtext') + $a['Type'] = 'textarea'; + elseif (substr($a['Type'],0,4) == 'set(') { + // get the list of options + $a['List'] = explode('§',str_replace("','","§",substr($a['Type'], 5, strlen($a['Type']) - 7))); + $a['Type'] = 'set'; + } + elseif (substr($a['Type'],0,5) == 'enum(') { + // get the list of options + $a['List'] = explode('§',str_replace("','","§",substr($a['Type'], 6, strlen($a['Type']) - 8))); + $a['Type'] = 'enum'; + } + elseif (substr($a['Type'],0,10) == 'timestamp(') { + $a['Type'] = 'timestamp'; + } + + $this->vars[$a['Field']] = $a; + } + $this->vars[$idfield]['desc'] = 'id'; + } + // called before editing $entry + function prepare_edit(&$entry) { + foreach ($this->vars as $field => $descr) { + if ($descr['Type'] == 'set') { + // get the list of options selected + $selected = explode(',', $entry[$field]); + $entry[$field] = array(); + foreach ($selected as $option) + $entry[$field][$option] = 1; + } + if ($descr['Type'] == 'timestamp') { + // set readable timestamp + $date =& $entry[$field]; + $date = preg_replace('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', '\3/\2/\1 \4:\5:\6', $date); + } + } + return $entry; + } + // change display of a field + function describe($name, $desc, $display) { + $this->vars[$name]['desc'] = $desc; + $this->vars[$name]['display'] = $display; + } + // add a join table, when deleting a row corresponding entries will be deleted in these tables + function add_join_table($name,$joinid,$joindel,$joinextra="") { + if ($joindel) + $this->jtables[$name] = array("joinid" => $joinid,"joinextra" => $joinextra?(" AND ".$joinextra):""); + } + // call when done + function apply(&$page, $action, $id = false) { + $page->changeTpl('table-editor.tpl'); + $list = true; + if ($action == 'delete') { + foreach ($this->jtables as $table => $j) + XDB::execute("DELETE FROM {$table} WHERE {$j['joinid']} = {?}{$j['joinextra']}", $id); + XDB::execute("DELETE FROM {$this->table} WHERE {$this->idfield} = {?}",$id); + $page->trig("L'entrée ".$id." a été supprimée."); + } + if ($action == 'edit') { + $r = XDB::query("SELECT * FROM {$this->table} WHERE {$this->idfield} = {?}",$id); + $entry = $r->fetchOneAssoc(); + $page->assign('entry', $this->prepare_edit($entry)); + $page->assign('id', $id); + $list = false; + } + if ($action == 'new') { + if (!$this->idfield_editable) { + $r = XDB::query("SELECT MAX({$this->idfield})+1 FROM {$this->table}"); + $page->assign('id', $r->fetchOneCell()); + } + $list = false; + } + if ($action == 'update') { + $values = ""; + $cancel = false; + foreach ($this->vars as $field => $descr) { + if ($values) $values .= ','; + if (($field == $this->idfield) && !$this->idfield_editable) + $val = "'".addslashes($id)."'"; + elseif ($descr['Type'] == 'set') { + $val = ""; + if (Post::has($field)) foreach (Post::v($field) as $option) { + if ($val) $val .= ','; + $val .= $option; + } + $val = "'".addslashes($val)."'"; + } elseif (Post::has($field)) { + $val = Post::v($field); + if ($descr['Type'] == 'timestamp') { + $val = preg_replace('/([0-9]{2})\/([0-9]{2})\/([0-9]{4}) ([0-9]{2}):([0-9]{2}):([0-9]{2})/', '\3\2\1\4\5\6', $val); + } + $val = "'".addslashes($val)."'"; + } else { + $cancel = true; + $page->trig("Il manque le champ ".$field); + } + $values .= $val; + } + if (!$cancel) { + if ($this->idfield_editable && ($id != Post::v($this->idfield)) && $action != 'new') + XDB::execute("UPDATE {$this->table} SET {$this->idfield} = {?} WHERE {$this->idfield} = {?}", Post::v($this->idfield), $id); + XDB::execute("REPLACE INTO {$this->table} VALUES ($values)"); + if ($id !== false) + $page->trig("L'entrée ".$id." a été mise à jour."); + else + $page->trig("Une nouvelle entrée a été créée."); + } else + $page->trig("Impossible de mette à jour."); + } + if ($list) { + $it = XDB::iterator("SELECT * FROM {$this->table}"); + $this->nbfields = 0; + foreach ($this->vars as $field => $descr) + if ($descr['display']) $this->nbfields++; + $page->assign('list', $it); + } + $page->assign('t', $this); + } +} + +?> diff --git a/htdocs/admin_old/gerer_applis.php b/htdocs/admin_old/gerer_applis.php deleted file mode 100644 index db36e85..0000000 --- a/htdocs/admin_old/gerer_applis.php +++ /dev/null @@ -1,36 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Formations'); -$editor->add_join_table('applis_ins','aid',true); - -$editor->describe('text','intitulé',true); -$editor->describe('type','type',true,'set'); -$editor->describe('url','site web',false); - -$editor->assign('title', 'Gestion des formations'); - -$editor->run(); -?> diff --git a/htdocs/admin_old/gerer_auth-groupex.php b/htdocs/admin_old/gerer_auth-groupex.php deleted file mode 100644 index 7b8d6c6..0000000 --- a/htdocs/admin_old/gerer_auth-groupex.php +++ /dev/null @@ -1,35 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Auth groupes X'); - -$editor->describe('name','nom',true); -$editor->describe('privkey','clé privée',false); -$editor->describe('datafields','champs renvoyés',true); - -$editor->assign('title', 'Gestion de l\'authentification centralisée'); - -$editor->run(); -?> diff --git a/htdocs/admin_old/gerer_binets.php b/htdocs/admin_old/gerer_binets.php deleted file mode 100644 index 26fb8b0..0000000 --- a/htdocs/admin_old/gerer_binets.php +++ /dev/null @@ -1,34 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Groupes X'); - -$editor->add_join_table('binets_ins','binet_id',true); - -$editor->describe('text','intitulé',true); -$editor->assign('title', 'Gestion des binets'); - -$editor->run(); -?> diff --git a/htdocs/admin_old/gerer_coupure.php b/htdocs/admin_old/gerer_coupure.php deleted file mode 100644 index 809f6cf..0000000 --- a/htdocs/admin_old/gerer_coupure.php +++ /dev/null @@ -1,37 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Coupures'); - -$editor->describe('debut','date',true,'timestamp'); -$editor->describe('duree','durée',false); -$editor->describe('resume','résumé',true); -$editor->describe('services','services affectés',true,'set'); -$editor->describe('description','description',false,'textarea'); - -$editor->assign('title', 'Gestion des coupures'); - -$editor->run(); -?> diff --git a/htdocs/admin_old/gerer_decos.php b/htdocs/admin_old/gerer_decos.php deleted file mode 100644 index ecd4f07..0000000 --- a/htdocs/admin_old/gerer_decos.php +++ /dev/null @@ -1,54 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Distinctions'); - -$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::v('frm_id')) { - $page->changeTpl('admin/gerer_decos.tpl'); - - $mid = Post::i('frm_id'); - - if (Post::v('act') == 'del') { - XDB::execute('DELETE FROM profile_medals_grades WHERE mid={?} AND gid={?}', $mid, Post::i('gid')); - } elseif (Post::v('act') == 'new') { - XDB::execute('INSERT INTO profile_medals_grades (mid,gid) VALUES({?},{?})', - $mid, max(array_keys(Post::v('grades', array(0))))+1); - } else { - foreach (Post::v('grades', array()) as $gid=>$text) { - XDB::execute('UPDATE profile_medals_grades SET pos={?}, text={?} WHERE gid={?}', $_POST['pos'][$gid], $text, $gid); - } - } - $res = 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/htdocs/admin_old/gerer_groupesx.php b/htdocs/admin_old/gerer_groupesx.php deleted file mode 100644 index 79479bc..0000000 --- a/htdocs/admin_old/gerer_groupesx.php +++ /dev/null @@ -1,35 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Groupes X'); -$editor->add_join_table('groupesx_ins','gid',true); - -$editor->describe('text','intitulé',true); -$editor->describe('url','site web',false); - -$editor->assign('title', 'Gestion des Groupes X'); - -$editor->run(); -?> diff --git a/htdocs/admin_old/gerer_paiement.php b/htdocs/admin_old/gerer_paiement.php deleted file mode 100644 index d27149b..0000000 --- a/htdocs/admin_old/gerer_paiement.php +++ /dev/null @@ -1,41 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Paiements'); - -$editor->add_join_table('paiement.transactions','ref',true); - -$editor->describe('text','intitulé',true); -$editor->describe('url','site web',false); -$editor->describe('montant_def','montant par défaut',false); -$editor->describe('montant_min','montant minimum',false); -$editor->describe('montant_max','montant maximum',false); -$editor->describe('mail','email contact',true); -$editor->describe('confirmation','message confirmation',false,'textarea'); -$editor->describe('flags','flags', true, 'set'); - -$editor->assign('title', 'Gestion des télépaiements'); -$editor->run(); -?> diff --git a/htdocs/admin_old/gerer_skins.php b/htdocs/admin_old/gerer_skins.php deleted file mode 100644 index 075a3f0..0000000 --- a/htdocs/admin_old/gerer_skins.php +++ /dev/null @@ -1,36 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Skins'); -$editor->describe('name','nom',true); -$editor->describe('skin_tpl','nom du template',true); -$editor->describe('auteur','auteur',false); -$editor->describe('comment','commentaire',true,'textarea'); -$editor->describe('date','date',false); -$editor->describe('ext','extension du screenshot',false); - -$editor->assign('title', 'Gestion des skins'); -$editor->run(); -?> diff --git a/htdocs/admin_old/logger_actions.php b/htdocs/admin_old/logger_actions.php deleted file mode 100644 index 326a920..0000000 --- a/htdocs/admin_old/logger_actions.php +++ /dev/null @@ -1,35 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Actions'); -$editor->add_join_table('logger.events','action',true); - -$editor->describe('text','intitulé',true); -$editor->describe('description','description',true); - -$editor->assign('title', 'Gestion des actions de logger'); - -$editor->run(); -?> diff --git a/htdocs/admin_old/newsletter_cats.php b/htdocs/admin_old/newsletter_cats.php deleted file mode 100644 index 6ad9a59..0000000 --- a/htdocs/admin_old/newsletter_cats.php +++ /dev/null @@ -1,34 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Newsletter : Catégories'); - -$editor->describe('titre','intitulé',true); -$editor->describe('pos','position',true); - -$editor->assign('title', 'Gestion des catégories de la newsletter'); - -$editor->run(); -?> diff --git a/htdocs/admin_old/postfix_blacklist.php b/htdocs/admin_old/postfix_blacklist.php deleted file mode 100644 index 6592a74..0000000 --- a/htdocs/admin_old/postfix_blacklist.php +++ /dev/null @@ -1,35 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Postfix : Blacklist'); - -$editor->assign('title', 'Blacklist de postfix'); -$editor->hide_id(); - -$editor->describe('email','email',true); -$editor->describe('reject_text','Texte de rejet',true); - -$editor->run(); -?> diff --git a/htdocs/admin_old/postfix_whitelist.php b/htdocs/admin_old/postfix_whitelist.php deleted file mode 100644 index d157dbc..0000000 --- a/htdocs/admin_old/postfix_whitelist.php +++ /dev/null @@ -1,34 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Postfix : Whitelist'); - -$editor->assign('title', 'Whitelist de postfix'); -$editor->hide_id(); - -$editor->describe('email','email',true); - -$editor->run(); -?> diff --git a/include/xorg.inc.php b/include/xorg.inc.php index 52cd829..6bf7752 100644 --- a/include/xorg.inc.php +++ b/include/xorg.inc.php @@ -93,17 +93,6 @@ function new_admin_page($tpl_name) } // }}} -// {{{ function new_admin_table_editor() - -function new_admin_table_editor($table, $idfield, $idedit=false) -{ - global $editor; - new_admin_page('table-editor.tpl'); - require_once('xorg.table-editor.inc.php'); - $editor = new XOrgAdminTableEditor($table, $idfield, $idedit); -} - -// }}} // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: ?> diff --git a/include/xorg.table-editor.inc.php b/include/xorg.table-editor.inc.php deleted file mode 100644 index e1ba802..0000000 --- a/include/xorg.table-editor.inc.php +++ /dev/null @@ -1,42 +0,0 @@ -DiogenesTableEditor($table,$idfield,$editid); - } - - function assign($var_name, $contenu) { - global $page; - $page->assign($var_name, $contenu); - } - - function run() { - global $page; - $page->fakeDiogenes(); - parent::run($page); - $page->run(); - } -} - -?> diff --git a/modules/admin.php b/modules/admin.php index 9ab54fa..451b74e 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -25,24 +25,34 @@ class AdminModule extends PLModule { return array( 'admin' => $this->make_hook('default', AUTH_MDP, 'admin'), - 'admin/postfix/delayed' => $this->make_hook('postfix_delayed', AUTH_MDP, 'admin'), - 'admin/postfix/regexp_bounces' => $this->make_hook('postfix_regexpsbounces', AUTH_MDP, 'admin'), - 'admin/logger' => $this->make_hook('logger', AUTH_MDP, 'admin'), - 'admin/logger/actions' => $this->make_hook('logger_action', AUTH_MDP, 'admin'), - 'admin/user' => $this->make_hook('user', AUTH_MDP, 'admin'), - 'admin/homonyms' => $this->make_hook('homonyms', AUTH_MDP, 'admin'), + 'admin/auth-groupes-x' => $this->make_hook('authgroupesx', AUTH_MDP, 'admin'), 'admin/ax-xorg' => $this->make_hook('ax_xorg', AUTH_MDP, 'admin'), + 'admin/binets' => $this->make_hook('binets', AUTH_MDP, 'admin'), 'admin/deaths' => $this->make_hook('deaths', AUTH_MDP, 'admin'), - 'admin/synchro_ax' => $this->make_hook('synchro_ax', AUTH_MDP, 'admin'), + 'admin/medals' => $this->make_hook('medals', AUTH_MDP, 'admin'), + 'admin/downtime' => $this->make_hook('downtime', AUTH_MDP, 'admin'), 'admin/events' => $this->make_hook('events', AUTH_MDP, 'admin'), 'admin/formations' => $this->make_hook('formations', AUTH_MDP, 'admin'), - 'admin/newsletter' => $this->make_hook('newsletter', AUTH_MDP, 'admin'), - 'admin/newsletter/edit' => $this->make_hook('newsletter_edit', AUTH_MDP, 'admin'), - 'admin/lists' => $this->make_hook('lists', AUTH_MDP, 'admin'), - 'admin/validate' => $this->make_hook('validate', AUTH_MDP, 'admin'), 'admin/geoloc' => $this->make_hook('geoloc', AUTH_MDP, 'admin'), 'admin/geoloc/dynamap' => $this->make_hook('geoloc_dynamap', AUTH_MDP, 'admin'), + 'admin/groupes-x' => $this->make_hook('groupesx', AUTH_MDP, 'admin'), + 'admin/homonyms' => $this->make_hook('homonyms', AUTH_MDP, 'admin'), + 'admin/lists' => $this->make_hook('lists', AUTH_MDP, 'admin'), + 'admin/logger' => $this->make_hook('logger', AUTH_MDP, 'admin'), + 'admin/logger/actions' => $this->make_hook('logger_actions', AUTH_MDP, 'admin'), + 'admin/newsletter' => $this->make_hook('newsletter', AUTH_MDP, 'admin'), + 'admin/newsletter/categories' => $this->make_hook('newsletter_cat', AUTH_MDP, 'admin'), + 'admin/newsletter/edit' => $this->make_hook('newsletter_edit', AUTH_MDP, 'admin'), + 'admin/payments' => $this->make_hook('payments', AUTH_MDP, 'admin'), + 'admin/postfix/blacklist' => $this->make_hook('postfix_blacklist', AUTH_MDP, 'admin'), + 'admin/postfix/delayed' => $this->make_hook('postfix_delayed', AUTH_MDP, 'admin'), + 'admin/postfix/regexp_bounces' => $this->make_hook('postfix_regexpsbounces', AUTH_MDP, 'admin'), + 'admin/postfix/whitelist' => $this->make_hook('postfix_whitelist', AUTH_MDP, 'admin'), + 'admin/skins' => $this->make_hook('skins', AUTH_MDP, 'admin'), + 'admin/synchro_ax' => $this->make_hook('synchro_ax', AUTH_MDP, 'admin'), 'admin/trombino' => $this->make_hook('trombino', AUTH_MDP, 'admin'), + 'admin/user' => $this->make_hook('user', AUTH_MDP, 'admin'), + 'admin/validate' => $this->make_hook('validate', AUTH_MDP, 'admin'), ); } @@ -710,7 +720,148 @@ class AdminModule extends PLModule $page->assign('forlife', $forlife); } - + + function handler_binets(&$page, $action = 'list', $id = null) { + require_once('../classes/PLTableEditor.php'); + $page->assign('xorg_title','Polytechnique.org - Administration - Binets'); + $page->assign('title', 'Gestion des binets'); + $table_editor = new PLTableEditor('admin/binets', 'binets_def', 'id'); + $table_editor->add_join_table('binets_ins','binet_id',true); + $table_editor->describe('text','intitulé',true); + $table_editor->apply($page, $action, $id); + } + function handler_formations(&$page, $action = 'list', $id = null) { + require_once('../classes/PLTableEditor.php'); + $page->assign('xorg_title','Polytechnique.org - Administration - Formations'); + $page->assign('title', 'Gestion des formations'); + $table_editor = new PLTableEditor('admin/formations','applis_def','id'); + $table_editor->add_join_table('applis_ins','aid',true); + $table_editor->describe('text','intitulé',true); + $table_editor->describe('url','site web',false); + $table_editor->apply($page, $action, $id); + } + function handler_groupesx(&$page, $action = 'list', $id = null) { + require_once('../classes/PLTableEditor.php'); + $page->assign('xorg_title','Polytechnique.org - Administration - Groupes X'); + $page->assign('title', 'Gestion des Groupes X'); + $table_editor = new PLTableEditor('admin/groupes-x','groupesx_def','id'); + $table_editor->add_join_table('groupesx_ins','gid',true); + $table_editor->describe('text','intitulé',true); + $table_editor->describe('url','site web',false); + $table_editor->apply($page, $action, $id); + } + function handler_skins(&$page, $action = 'list', $id = null) { + require_once('../classes/PLTableEditor.php'); + $page->assign('xorg_title','Polytechnique.org - Administration - Skins'); + $page->assign('title', 'Gestion des skins'); + $table_editor = new PLTableEditor('admin/skins','skins','id'); + $table_editor->describe('name','nom',true); + $table_editor->describe('skin_tpl','nom du template',true); + $table_editor->describe('auteur','auteur',false); + $table_editor->describe('comment','commentaire',true); + $table_editor->describe('date','date',false); + $table_editor->describe('ext','extension du screenshot',false); + $table_editor->apply($page, $action, $id); + } + function handler_authgroupesx(&$page, $action = 'list', $id = null) { + require_once('../classes/PLTableEditor.php'); + $page->assign('xorg_title','Polytechnique.org - Administration - Auth groupes X'); + $page->assign('title', 'Gestion de l\'authentification centralisée'); + $table_editor = new PLTableEditor('admin/auth-groupes-x','groupesx_auth','id'); + $table_editor->describe('name','nom',true); + $table_editor->describe('privkey','clé privée',false); + $table_editor->describe('datafields','champs renvoyés',true); + $table_editor->apply($page, $action, $id); + } + function handler_postfix_blacklist(&$page, $action = 'list', $id = null) { + require_once('../classes/PLTableEditor.php'); + $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Blacklist'); + $page->assign('title', 'Blacklist de postfix'); + $table_editor = new PLTableEditor('admin/postfix/blacklist','postfix_blacklist','email', true); + $table_editor->describe('reject_text','Texte de rejet',true); + $table_editor->describe('email','email',true); + $table_editor->apply($page, $action, $id); + } + function handler_postfix_whitelist(&$page, $action = 'list', $id = null) { + require_once('../classes/PLTableEditor.php'); + $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Whitelist'); + $page->assign('title', 'Whitelist de postfix'); + $table_editor = new PLTableEditor('admin/postfix/whitelist','postfix_whitelist','email', true); + $table_editor->describe('email','email',true); + $table_editor->apply($page, $action, $id); + } + function handler_logger_actions(&$page, $action = 'list', $id = null) { + require_once('../classes/PLTableEditor.php'); + $page->assign('xorg_title','Polytechnique.org - Administration - Actions'); + $page->assign('title', 'Gestion des actions de logger'); + $table_editor = new PLTableEditor('admin/logger/actions','logger.actions','id'); + $table_editor->describe('text','intitulé',true); + $table_editor->describe('description','description',true); + $table_editor->apply($page, $action, $id); + } + function handler_downtime(&$page, $action = 'list', $id = null) { + require_once('../classes/PLTableEditor.php'); + $page->assign('xorg_title','Polytechnique.org - Administration - Coupures'); + $page->assign('title', 'Gestion des coupures'); + $table_editor = new PLTableEditor('admin/downtime','coupures','id'); + $table_editor->describe('debut','date',true); + $table_editor->describe('duree','durée',false); + $table_editor->describe('resume','résumé',true); + $table_editor->describe('services','services affectés',true); + $table_editor->describe('description','description',false); + $table_editor->apply($page, $action, $id); + } + function handler_newsletter_cat(&$page, $action = 'list', $id = null) { + require_once('../classes/PLTableEditor.php'); + $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Catégories'); + $page->assign('title', 'Gestion des catégories de la newsletter'); + $table_editor = new PLTableEditor('admin/newsletter/categories','newsletter_cat','cid'); + $table_editor->describe('titre','intitulé',true); + $table_editor->describe('pos','position',true); + $table_editor->apply($page, $action, $id); + } + function handler_payments(&$page, $action = 'list', $id = null) { + require_once('../classes/PLTableEditor.php'); + $page->assign('xorg_title','Polytechnique.org - Administration - Paiements'); + $page->assign('title', 'Gestion des télépaiements'); + $table_editor = new PLTableEditor('admin/payments','paiement.paiements','id'); + $table_editor->add_join_table('paiement.transactions','ref',true); + $table_editor->describe('text','intitulé',true); + $table_editor->describe('url','site web',false); + $table_editor->describe('montant_def','montant par défaut',false); + $table_editor->describe('montant_min','montant minimum',false); + $table_editor->describe('montant_max','montant maximum',false); + $table_editor->describe('mail','email contact',true); + $table_editor->describe('confirmation','message confirmation',false); + $table_editor->apply($page, $action, $id); + } + function handler_medals(&$page, $action = 'list', $id = null) { + require_once('../classes/PLTableEditor.php'); + $page->assign('xorg_title','Polytechnique.org - Administration - Distinctions'); + $page->assign('title', 'Gestion des Distinctions'); + $table_editor = new PLTableEditor('admin/medals','profile_medals','id'); + $table_editor->describe('text', 'intitulé', true); + $table_editor->describe('img', 'nom de l\'image', false); + $table_editor->apply($page, $action, $id); + if ($id && $action == 'edit') { + $page->changeTpl('admin/gerer_decos.tpl'); + + $mid = $id; + + if (Post::v('act') == 'del') { + XDB::execute('DELETE FROM profile_medals_grades WHERE mid={?} AND gid={?}', $mid, Post::i('gid')); + } elseif (Post::v('act') == 'new') { + XDB::execute('INSERT INTO profile_medals_grades (mid,gid) VALUES({?},{?})', + $mid, max(array_keys(Post::v('grades', array(0))))+1); + } else { + foreach (Post::v('grades', array()) as $gid=>$text) { + XDB::execute('UPDATE profile_medals_grades SET pos={?}, text={?} WHERE gid={?}', $_POST['pos'][$gid], $text, $gid); + } + } + $res = XDB::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid); + $page->assign('grades', $res); + } + } } ?> diff --git a/templates/admin/gerer_decos.tpl b/templates/admin/gerer_decos.tpl index f2cf673..4bb456d 100644 --- a/templates/admin/gerer_decos.tpl +++ b/templates/admin/gerer_decos.tpl @@ -45,7 +45,7 @@ {/literal} -
+ @@ -58,7 +58,7 @@ Nouveau ... {iterate from=$grades item=g} @@ -71,7 +71,7 @@ {/iterate} diff --git a/templates/admin/index.tpl b/templates/admin/index.tpl index 41a8ad7..3cda717 100644 --- a/templates/admin/index.tpl +++ b/templates/admin/index.tpl @@ -27,9 +27,9 @@
id - nouveau + nouveau{icon name=add title='nouveau grade'}
- suppr. + {icon name=delete title='supprimer grade'}
Postfix :   - Blacklist + Blacklist   |   - Whitelist + Whitelist   |   Retardés   |   @@ -41,7 +41,7 @@ Sécurité :   Logs des sessions   |   - Actions + Actions
@@ -67,21 +67,21 @@ Infos dynamiques :   - Coupures + Coupures Champs profil :   - Formations + Formations   |   - Binets + Binets   |   - Groupes X + Groupes X   |   - Skins + Skins   |   - Décorations + Décorations @@ -89,13 +89,13 @@ Newsletter :   Liste   |   - Catégories + Catégories Administrer :   - Auth Groupes X + Auth Groupes X   |   Listes @@ -113,7 +113,7 @@ Trésorerie :   Comptes   |   - Paiements + Paiements diff --git a/templates/table-editor.tpl b/templates/table-editor.tpl index 8f50cb5..6601c7d 100644 --- a/templates/table-editor.tpl +++ b/templates/table-editor.tpl @@ -24,87 +24,50 @@

{$title}

-{if !$doedit} -{if !$readonly} - -{literal} - -{/literal} -{/if} - - -
- - -
-
+{if $list} - {if $idsum}{/if} - {foreach from=$vars item=myval} - {if $myval.sum}{/if} - {/foreach} + {foreach from=$t->vars item=myval}{if $myval.display} + + {/if}{/foreach} {if !$hideactions} {/if} {if !$readonly} - + {/if} -{foreach from=$rows item=myrow}{assign var="myarr" value=$myrow[1]} +{iterate from=$list item=myrow} - {if $idsum}{/if} -{foreach from=$vars key=mykey item=myval} -{if $myval.sum} +{foreach from=$t->vars item=myval}{if $myval.display} -{/if} -{/foreach} +{/if}{/foreach} {if !$hideactions} {/if} -{/foreach} +{/iterate}
id{$myval.desc}{$myval.desc}action
nouvelle entréenouvelle entrée - create + créer{icon name=add title='nouvelle entrée'}
{$myrow[0]} - {if $myval.type=="timestamp"} - {$myarr.$mykey|date_format:"%x %X"} - {elseif $myval.type=="set" and $myval.trans} - {$myval.trans[$myval.value]} - {elseif $myval.type=="ext"} - {extval table=$table field=$mykey value=$myarr.$mykey vtable=$myval.vtable vjoinid=$myval.vjoinid vfield=$myval.vfield} - {else} - {$myarr.$mykey} - {/if} + {assign var="myfield" value=$myval.Field} + {if $myfield eq $t->idfield} + {assign var="idval" value=$myrow.$myfield} + {/if} + {if $myval.Type eq 'timestamp'} + {$myrow.$myfield|date_format:"%x %X"} + {else} + {$myrow.$myfield} + {/if} {if !$readonly} - edit - delete + {icon name=date_edit title='éditer'} + {icon name=delete title='supprimer'} {/if} - {foreach from=$myrow[2] item=myaction} - {a lnk=$myaction} - {/foreach}
{if ($p_prev > -1) || ($p_next > -1)} @@ -116,50 +79,45 @@ {else} -
+ - {foreach from=$vars key=mykey item=myval} + {foreach from=$t->vars item=myval}{assign var="myfield" value=$myval.Field}{if ($myfield neq $t->idfield) or ($t->idfield_editable)} - {/foreach} + {/if}{/foreach}
- - {if $id!=''} - modification de l'entrée - + {if $id} + modification de l'entrée {else} - nouvelle entrée + nouvelle entrée {/if}
{$myval.desc} - {if $myval.type=="password"}
(blank=no change){/if}
- {if $myval.edit} - {if $myval.type=="textarea"} - - {elseif $myval.type=="set"} - {if $myval.trans} - {flags table=$table field=$mykey name="$prefix$mykey" selected=$myval.trans[$myval.value] trans=$myval.trans} - {else} - {flags table=$table field=$mykey name="$prefix$mykey" selected=$myval.value} - {/if} - {elseif $myval.type=="ext"} - {extval table=$table field=$mykey name="$prefix$mykey" vtable=$myval.vtable vjoinid=$myval.vjoinid vfield=$myval.vfield selected=$myval.value} - {elseif $myval.type=="timestamp"} - - {elseif $myval.type=="password"} - - {else} - - {/if} + {if $myval.Type eq 'set'} + + {elseif $myval.Type eq 'enum'} + + {elseif ($myval.Type eq 'textarea') or ($myval.Type eq 'varchar200')} + {else} - {$myval.value} + + {if $myval.Type eq 'timestamp'}jj/mm/aaaa hh:mm:ss{/if} + {if $myval.Type eq 'time'}hh:mm:ss{/if} {/if}

@@ -169,7 +127,7 @@

-back +back

{/if} -- 2.1.4