'admin/icons' => $this->make_hook('icons', AUTH_MDP, 'admin'),
'admin/accounts' => $this->make_hook('accounts', AUTH_MDP, 'admin'),
'admin/account/types' => $this->make_hook('account_types', AUTH_MDP, 'admin'),
+ 'admin/jobs' => $this->make_hook('jobs', AUTH_MDP, 'admin'),
);
}
// Loads the user identity using the environment.
$user = User::get($login);
+ if (!$user) {
+ return;
+ }
+
$login = $user->login();
$registered = ($user->state != 'pending');
}
if (!Post::blank('hashpass')) {
$to_update['password'] = Post::s('hashpass');
+ // TODO: Propagate the password update to GoogleApps, when required. Eg:
+ // $account = new GoogleAppsAccount($user);
+ // if ($account->active() && $account->sync_password) {
+ // $account->set_password($pass_encrypted);
+ // }
}
if (!Post::blank('weak_password')) {
$to_update['weak_password'] = Post::s('weak_password');
}
}
if (!empty($to_update)) {
+ // TODO: fetch the initial values of the fields, and eventually send
+ // a summary of the changes to an admin.
$set = array();
foreach ($to_update as $k => $value) {
$set[] = XDB::format($k . ' = {?}', $value);
$page->assign('emails', $redirect->emails);
}
- $page->assign('mr', $mr);
$page->assign('user', $user);
// Displays forum bans.
$page->assign('bans', $bans);
}
- function getHruid($line, $key)
+ function getHruid($line, $partial_result, $key)
{
- var_dump($line);
- if (!isset($line['nom']) || !isset($line['prenom']) || !isset($line['promo'])) {
+ if (!isset($partial_result['nom']) ||
+ !isset($partial_result['prenom']) ||
+ !isset($partial_result['promo'])) {
return null;
}
- return make_forlife($line['prenom'], $line['nom'], $line['promo']);
+ return make_forlife($partial_result['prenom'], $partial_result['nom'], $partial_result['promo']);
}
function getMatricule($line, $key)
$fields = array('hruid', 'nom', 'nom_ini', 'prenom', 'naissance_ini',
'prenom_ini', 'promo', 'promo_sortie', 'flags',
'matricule', 'matricule_ax', 'perms');
- $importer->forceValue('hruid', array($this, 'getHruid'));
$importer->forceValue('promo', $promo);
$importer->forceValue('promo_sortie', $promo + 3);
+ // The hruid generation callback is set last, so that it is called once 'promo'
+ // has already been computed for that line.
+ $importer->forceValue('hruid', array($this, 'getHruid'));
break;
case 'ax':
$fields = array('matricule', 'matricule_ax');
WHERE a.is_admin
ORDER BY a.hruid'));
}
+
+ function handler_jobs(&$page, $id = -1)
+ {
+ $page->changeTpl('admin/jobs.tpl');
+
+ if (Env::has('search')) {
+ $res = XDB::query("SELECT e.id, e.name, e.acronym
+ FROM profile_job_enum AS e
+ WHERE e.name LIKE CONCAT('% ', {?}, '%') OR e.acronym LIKE CONCAT('% ', {?}, '%')",
+ Env::t('job'), Env::t('job'));
+
+ if ($res->numRows() <= 20) {
+ $page->assign('jobs', $res->fetchAllAssoc());
+ } else {
+ $page->trigError("Il y a trop d'entreprises correspondant à ton choix. Affine-le !");
+ }
+
+ $page->assign('askedJob', Env::v('job'));
+ return;
+ }
+
+ if (Env::has('edit')) {
+ S::assert_xsrf_token();
+ $selectedJob = Env::has('selectedJob');
+
+ if (Env::has('change')) {
+ XDB::execute('UPDATE profile_job
+ SET jobid = {?}
+ WHERE jobid = {?}',
+ Env::i('newJobId'), $id);
+ XDB::execute('DELETE FROM profile_job_enum
+ WHERE id = {?}',
+ $id);
+
+ $page->trigSuccess("L'entreprise a bien été remplacée.");
+ } else {
+ XDB::execute('UPDATE profile_job_enum
+ SET name = {?}, acronym = {?}, url = {?}, email = {?},
+ NAF_code = {?}, AX_code = {?}, holdingid = {?}
+ WHERE id = {?}',
+ Env::t('name'), Env::t('acronym'), Env::t('url'), Env::t('email'),
+ Env::t('NAF_code'), Env::i('AX_code'), Env::i('holdingId'), $id);
+
+ $page->trigSuccess("L'entreprise a bien été mise à jour.");
+ }
+ }
+
+ if (!Env::has('change') && $id != -1) {
+ $res = XDB::query('SELECT e.id, e.name, e.acronym, e.url, e.email, e.NAF_code, e.AX_code,
+ h.id AS holdingId, h.name AS holdingName, h.acronym AS holdingAcronym
+ FROM profile_job_enum AS e
+ LEFT JOIN profile_job_enum AS h ON (e.holdingid = h.id)
+ WHERE e.id = {?}',
+ $id);
+
+ if ($res->numRows() == 0) {
+ $page->trigError('Auncune entreprise ne correspond à cet identifiant.');
+ } else {
+ $page->assign('selectedJob', $res->fetchOneAssoc());
+ }
+ }
+ }
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: