* Admin:
- Show last contact date on marketing validation -Fal/FRU
+ - New page to add users in the database -FRU
* Core:
- New mailer -FRU
private $user_functions = array();
private $field_desc = array();
+ private $field_value = array();
public function CSVImporter($table, $key = 'id', $do_sql = true)
{
{
$array = split($this->separator, $line);
if (is_null($this->index)) {
- $this->index = $array;
+ $this->index = array_map('strtolower', $array);
return true;
}
public function registerFunction($name, $desc, $callback)
{
- if (is_callable($callback)) {
+ if (is_callable($callback, false, $ref)) {
$this->user_functions['func_' . $name] = array('desc' => $desc, 'callback' => $callback);
return true;
}
$this->field_desc[$name] = $desc;
}
+ public function forceValue($name, $value)
+ {
+ $this->field_value[$name] = $value;
+ }
+
/** Handle insertion form
* @param $page PlatalPage to process
* @param $url URI of the page
if (is_null($fields)) {
return false;
}
+ foreach ($this->field_value as $key=>$value) {
+ unset($fields[$key]);
+ }
$current = Env::v('csv_page');
if (empty($current)) {
$update[$key] = $insert[$key];
}
}
+ foreach ($this->field_value as $key=>$value) {
+ $insert[$key] = $value;
+ }
if ($current == 'valid' && Env::has('csv_valid')) {
$this->run(Env::v('csv_action'), $insert, $update);
$page->assign('csv_done', true);
}
}
$page->assign('csv_index', $this->index);
- $page->assign('csv_funtions', $this->user_functions);
+ $page->assign('csv_functions', $this->user_functions);
$page->assign('csv_field_desc', $this->field_desc);
$page->assign('csv_page', $next);
$page->assign('csv_path', $url);
'admin/skins' => $this->make_hook('skins', AUTH_MDP, 'admin'),
'admin/synchro_ax' => $this->make_hook('synchro_ax', AUTH_MDP, 'admin'),
'admin/user' => $this->make_hook('user', AUTH_MDP, 'admin'),
+ 'admin/promo' => $this->make_hook('promo', AUTH_MDP, 'admin'),
'admin/validate' => $this->make_hook('validate', AUTH_MDP, 'admin'),
'admin/validate/answers' => $this->make_hook('validate_answers', AUTH_MDP, 'admin'),
'admin/wiki' => $this->make_hook('wiki', AUTH_MDP, 'admin'),
$page->assign('mr',$mr);
}
}
+
+ function getMatricule($line, $key)
+ {
+ $mat = $line['matricule'];
+ $year = intval(substr($mat, 0, 3));
+ $rang = intval(substr($mat, 3, 3));
+ if ($year > 200) { $year /= 10; };
+ if ($year < 96) {
+ return null;
+ } else {
+ return sprintf('%04u%04u', 1900+$year, $rang);
+ }
+ }
+
+ function handler_promo(&$page, $action = null, $promo = null)
+ {
+ if (Env::has('promo')) {
+ if(Env::i('promo') > 1900 && Env::i('promo') < 2050) {
+ $action = Env::v('valid_promo') == 'Ajouter des membres' ? 'add' : 'ax';
+ pl_redirect('admin/promo/' . $action . '/' . Env::i('promo'));
+ } else {
+ $page->trig('Promo non valide');
+ }
+ }
+
+ $page->changeTpl('admin/promo.tpl');
+ if ($promo > 1900 && $promo < 2050 && ($action == 'add' || $action == 'ax')) {
+ $page->assign('promo', $promo);
+ } else {
+ return;
+ }
+
+ $importer = new CSVImporter('auth_user_md5', 'matricule');
+ $importer->registerFunction('matricule', 'matricle Ecole vers X.org', array($this, 'getMatricule'));
+ switch ($action) {
+ case 'add':
+ $fields = array('nom', 'nom_ini', 'prenom',
+ 'prenom_ini', 'promo', 'promo_sortie', 'flags',
+ 'matricule', 'matricule_ax', 'perms');
+ $importer->forceValue('promo', $promo);
+ $importer->forceValue('promo_sortie', $promo + 3);
+ break;
+ case 'ax':
+ $fields = array('matricule', 'matricule_ax');
+ break;
+ }
+ $importer->apply($page, "admin/promo/$action/$promo", $fields);
+ }
+
function handler_homonyms(&$page, $op = 'list', $target = null) {
$page->changeTpl('admin/homonymes.tpl');
$page->assign('xorg_title','Polytechnique.org - Administration - Homonymes');
<tr class="impair">
<td>
<strong>Utilisateurs :</strong>
+ <a href="admin/promo">Ajout</a>
+ |
<a href="admin/user">Edit/Su/Logs</a>
|
<a href="admin/homonyms">Homonymes</a>
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2006 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>Mise à jour de l'annuaire</h1>
+
+<form action="{$platal->pl_self()}" method="post">
+<table class="tinybicol">
+ <tr>
+ <td class="center">
+ <strong>Promotion :</strong>
+ <input type="text" size="4" name="promo" value="{$promo}" /><br />
+ <input type="submit" name="valid_promo" value="Ajouter des membres" />
+ <input type="submit" name="valid_promo" value="Mettre à jour les matricules AX" />
+ <td>
+ </tr>
+</table>
+</form>
+
+{if $promo}
+{include file="include/csv-importer.tpl"}
+{/if}
+
+{* vim:set et sw=2 sts=2 sws=2: *}