'admin/ipwatch' => $this->make_hook('ipwatch', AUTH_MDP, 'admin'),
'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'),
);
}
function handler_accounts(&$page)
{
$page->changeTpl('admin/accounts.tpl');
- $page->assign('disabled', XDB::iterator('SELECT u.nom, u.prenom, u.promo, u.comment, u.hruid
- FROM auth_user_md5 AS u
- WHERE perms = \'disabled\'
- ORDER BY nom, prenom'));
- $page->assign('admins', XDB::iterator('SELECT u.nom, u.prenom, u.promo, u.hruid
- FROM auth_user_md5 AS u
- WHERE perms = \'admin\'
- ORDER BY nom, prenom'));
+ $page->assign('disabled', XDB::iterator('SELECT a.hruid, FIND_IN_SET(\'watch\', a.flags) AS watch,
+ a.state = \'disabled\' AS disabled, a.comment
+ FROM accounts AS a
+ WHERE a.state = \'disabled\' OR FIND_IN_SET(\'watch\', a.flags)
+ ORDER BY a.hruid'));
+ $page->assign('admins', XDB::iterator('SELECT a.hruid
+ FROM accounts AS a
+ 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:
LEFT JOIN profile_addresses AS ah ON (ah.jobid = j.jobid AND ah.type = 'hq')
WHERE j.uid = {?}
ORDER BY j.id",
- S::i('uid'));
+ $this->pid());
$this->values['jobs'] = array();
- while (list($id, $jobid, $name, $function, $sector, $subSector, $subSubSector,
+ while (list($id, $jobid, $name, $sector, $subSector, $subSubSector,
$subSubSectorName, $description, $w_email, $w_emailPub, $w_url, $pub,
$hq_acronym, $hq_url, $hq_email,
$w_accuracy, $w_text, $w_postalText, $w_postalCode, $w_localityId,
if (!count($value)) {
return;
}
- foreach ($value as $id=>&$sect) {
- foreach ($sect as $sid=>&$name) {
+ foreach ($value as $id => $sect) {
+ foreach ($sect as $sid => $name) {
XDB::execute("INSERT INTO profile_mentor_sector (uid, sectorid, subsectorid)
VALUES ({?}, {?}, {?})",
- S::i('uid'), $id, $sid);
+ $page->pid(), $id, $sid);
}
}
}
protected function _fetchData()
{
$res = XDB::query("SELECT expertise
- FROM mentor
+ FROM profile_mentor
WHERE uid = {?}",
- S::i('uid'));
+ $this->pid());
$this->values['expertise'] = $res->fetchOneCell();
}
if ($this->changed['expertise']) {
$expertise = trim($this->values['expertise']);
if (empty($expertise)) {
- XDB::execute("DELETE FROM mentor
+ XDB::execute("DELETE FROM profile_mentor
WHERE uid = {?}",
- S::i('uid'));
+ $this->pid());
$this->values['expertise'] = null;
} else {
- XDB::execute("REPLACE INTO mentor (uid, expertise)
+ XDB::execute("REPLACE INTO profile_mentor (uid, expertise)
VALUES ({?}, {?})",
- S::i('uid'), $expertise);
+ $this->pid(), $expertise);
$this->values['expertise'] = $expertise;
}
}