{
return array(
'phpinfo' => $this->make_hook('phpinfo', AUTH_MDP, 'admin'),
- 'get_rights' => $this->make_hook('get_rights', AUTH_MDP, 'admin'),
+ 'get_rights' => $this->make_hook('get_rights', AUTH_COOKIE, 'admin'),
+ 'set_skin' => $this->make_hook('set_skin', AUTH_COOKIE, 'admin'),
'admin' => $this->make_hook('default', AUTH_MDP, 'admin'),
'admin/dead-but-active' => $this->make_hook('dead_but_active', AUTH_MDP, 'admin'),
'admin/deaths' => $this->make_hook('deaths', AUTH_MDP, 'admin'),
exit;
}
- function handler_get_rights(&$page, $level)
+ function handler_get_rights(&$page)
{
if (S::suid()) {
$page->kill('Déjà en SUID');
}
- $user =& S::user();
- Platal::session()->startSUID($user, $level);
+ S::assert_xsrf_token();
+ $level = Post::s('account_type');
+ if ($level != 'admin') {
+ $user = User::getSilentWithUID(S::user()->id());
+ $user->is_admin = false;
+ $types = DirEnum::getOptions(DirEnum::ACCOUNTTYPES);
+ if (!empty($types[$level])) {
+ $user->setPerms($types[$level]);
+ }
+ S::set('suid_startpage', $_SERVER['HTTP_REFERER']);
+ Platal::session()->startSUID($user);
+ }
+ if (!empty($_SERVER['HTTP_REFERER'])) {
+ http_redirect($_SERVER['HTTP_REFERER']);
+ } else {
+ pl_redirect('/');
+ }
+ }
- pl_redirect('/');
+ function handler_set_skin(&$page)
+ {
+ S::assert_xsrf_token();
+ S::set('skin', Post::s('change_skin'));
+ if (!empty($_SERVER['HTTP_REFERER'])) {
+ http_redirect($_SERVER['HTTP_REFERER']);
+ } else {
+ pl_redirect('/');
+ }
}
function handler_default(&$page)
if ($action == 'session') {
// we are viewing a session
- $res = XDB::query("SELECT ls.*, a.alias AS username, sa.alias AS suer
+ $res = XDB::query("SELECT ls.*, a.hruid AS username, sa.hruid AS suer
FROM log_sessions AS ls
- LEFT JOIN aliases AS a ON (a.uid = ls.uid AND a.type='a_vie')
- LEFT JOIN aliases AS sa ON (sa.uid = ls.suid AND sa.type='a_vie')
+ INNER JOIN accounts AS a ON (a.uid = ls.uid)
+ LEFT JOIN accounts AS sa ON (sa.uid = ls.suid)
WHERE ls.id = {?}", $arg);
$page->assign('session', $a = $res->fetchOneAssoc());
} else {
$loguser = $action == 'user' ? $arg : Env::v('loguser');
- $res = XDB::query('SELECT uid FROM aliases WHERE alias={?}',
- $loguser);
- $loguid = $res->fetchOneCell();
+ if ($loguser) {
+ $user = User::get($loguser);
+ $loguid = $user->id();
+ } else {
+ $loguid = null;
+ }
if ($loguid) {
$year = Env::i('year');
// get the requested sessions
$where = $this->_makeWhere($year, $month, $day, $loguid);
$select = "SELECT s.id, s.start, s.uid,
- a.alias as username
+ a.hruid as username
FROM log_sessions AS s
- LEFT JOIN aliases AS a ON (a.uid = s.uid AND a.type='a_vie')
+ INNER JOIN accounts AS a ON (a.uid = s.uid)
$where
ORDER BY start DESC";
$res = XDB::iterator($select);
}
$page->assign_by_ref('sessions', $sessions);
} else {
- $page->assign('msg_nofilters', "Sélectionner une annuée et/ou un utilisateur");
+ $page->assign('msg_nofilters', "Sélectionner une année et/ou un utilisateur");
}
}
FROM profiles
WHERE hrpid = {?}', $hrid);
if (is_null($hrid) || $res1->fetchOneCell() > 0 || $res2->fetchOneCell() > 0) {
- $page->trigError("La ligne $infosLine n'a pas été ajoutée.");
+ $page->trigError("La ligne $infosLine n'a pas été ajoutée: une entrée similaire existe déjà");
return false;
}
$infos['hrid'] = $hrid;
$entry_year = $promotion;
$grad_year = $promotion + 3;
$promo = 'X' . $promotion;
+ $hrpromo = $promotion;
break;
case 'M':
$degreeid = $eduDegrees[Profile::DEGREE_M];
$grad_year = $promotion;
$entry_year = $promotion - 2;
$promo = 'M' . $promotion;
+ $hrpromo = $promo;
+ $type = 'master';
break;
case 'D':
$degreeid = $eduDegrees[Profile::DEGREE_D];
$grad_year = $promotion;
$entry_year = $promotion - 3;
$promo = 'D' . $promotion;
+ $hrpromo = $promo;
+ $type = 'phd';
break;
default:
$page->killError("La formation n'est pas reconnue:" . Env::t('edu_type') . '.');
}
+ XDB::startTransaction();
foreach ($lines as $line) {
- if ($infos = self::formatNewUser($page, $line, $separator, $promotion, 6)) {
+ if ($infos = self::formatNewUser($page, $line, $separator, $hrpromo, 6)) {
$sex = self::formatSex($page, $infos[3], $line);
if (!is_null($sex)) {
$fullName = $infos[1] . ' ' . $infos[0];
$infos['hrid'], $xorgId, $infos[5], $birthDate, $sex);
$pid = XDB::insertId();
XDB::execute('INSERT INTO profile_name (pid, name, typeid)
- VALUES ({?}, {?}, {?})',
- $pid, $infos[0], $nameTypes['name_ini']);
- XDB::execute('INSERT INTO profile_name (pid, name, typeid)
- VALUES ({?}, {?}, {?})',
- $pid, $infos[1], $nameTypes['firstname_ini']);
+ VALUES ({?}, {?}, {?}),
+ ({?}, {?}, {?}),
+ ({?}, {?}, {?}),
+ ({?}, {?}, {?})',
+ $pid, $infos[0], $nameTypes['name_ini'],
+ $pid, $infos[0], $nameTypes['lastname'],
+ $pid, $infos[1], $nameTypes['firstname_ini'],
+ $pid, $infos[1], $nameTypes['firstname']);
XDB::execute('INSERT INTO profile_display (pid, yourself, public_name, private_name,
directory_name, short_name, sort_name, promo)
VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
VALUES ({?}, {?}, {?}, {?}, {?}, {?})',
$pid, $eduSchools[Profile::EDU_X], $degreeid, $entry_year, $grad_year, 'primary');
XDB::execute('INSERT INTO accounts (hruid, type, is_admin, state, full_name, directory_name, display_name, sex)
- VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?})',
- $infos['hrid'], $type, 0, 'active', $fullName, $directoryName, $infos[1], $sex);
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
+ $infos['hrid'], $type, 0, 'pending', $fullName, $directoryName, $infos[1], $sex);
$uid = XDB::insertId();
XDB::execute('INSERT INTO account_profiles (uid, pid, perms)
VALUES ({?}, {?}, {?})',
$uid, $pid, 'owner');
+ Profile::rebuildSearchTokens($pid, false);
}
}
}
+ XDB::commit();
} else if (Env::t('add_type') == 'account') {
$type = Env::t('type');
$newAccounts = array();
if (!is_null($sex)) {
$fullName = $infos[1] . ' ' . $infos[0];
$directoryName = $infos[0] . ' ' . $infos[1];
- XDB::execute('INSERT INTO accounts (hruid, type, is_admin, state, email, full_name, directory_name, display_name, sex)
- VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
- $infos['hrid'], $type, 0, 'active', $infos[2], $fullName, $directoryName, $infos[1], $sex);
+ XDB::execute('INSERT INTO accounts (hruid, type, is_admin, state,
+ email, full_name, directory_name,
+ display_name, sex)
+ VALUES ({?}, {?}, {?}, {?},
+ {?}, {?}, {?}, {?}, {?})',
+ $infos['hrid'], $type, 0, 'pending',
+ $infos[2], $fullName, $directoryName,
+ $infos[1], $sex);
$newAccounts[$infos['hrid']] = $infos[1] . ' ' . $infos[0];
}
}
S::assert_xsrf_token();
$firstname = Post::t('firstname');
$lastname = strtoupper(Post::t('lastname'));
- $sex = Post::b('sex') ? User::GENDER_FEMALE : User::GENDER_MALE;
+ $sex = Post::s('sex');
$email = Post::t('email');
$type = Post::s('type');
$login = PlUser::makeHrid($firstname, $lastname, $type);
$selectedJob = Env::has('selectedJob');
Phone::deletePhones(0, Phone::LINK_COMPANY, $id);
- Address::delete(null, Address::LINK_COMPANY, $id);
+ Address::deleteAddresses(null, Address::LINK_COMPANY, $id);
if (Env::has('change')) {
XDB::execute('UPDATE profile_job
SET jobid = {?}