From: Vincent Zanotti Date: Fri, 10 Apr 2009 16:48:39 +0000 (+0200) Subject: Merge commit 'origin/fusionax' into account X-Git-Tag: xorg/1.0.0~332^2~340 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=483da16573717c21c7e6da3eacc094048ab7d72f;p=platal.git Merge commit 'origin/fusionax' into account Conflicts: modules/admin.php Signed-off-by: Vincent Zanotti --- 483da16573717c21c7e6da3eacc094048ab7d72f diff --cc modules/admin.php index c4f79f5,032d02a..4b6e085 --- a/modules/admin.php +++ b/modules/admin.php @@@ -49,7 -48,7 +49,8 @@@ class AdminModule extends PLModul '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'), ); } @@@ -1153,16 -1246,77 +1154,78 @@@ 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: diff --cc modules/profile/jobs.inc.php index 1564c6d,1b67ff1..424de8e --- a/modules/profile/jobs.inc.php +++ b/modules/profile/jobs.inc.php @@@ -227,9 -227,9 +227,9 @@@ class ProfileJobs extends ProfilePag 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, diff --cc modules/profile/mentor.inc.php index b2d2699,e85318c..2ecb60b --- a/modules/profile/mentor.inc.php +++ b/modules/profile/mentor.inc.php @@@ -61,11 -61,11 +61,11 @@@ class ProfileSectors implements Profile 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); } } } @@@ -125,9 -125,9 +125,9 @@@ class ProfileMentor extends ProfilePag 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(); } @@@ -136,14 -136,14 +136,14 @@@ 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; } }