X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile.php;h=b75fbe0a9f09fa64dadd0497fb3604e6c4b60b7b;hb=a5878ac19cc6ea75a753470cf68b7d2180d6cd51;hp=fc6bd7d27998cc94dfe8069cae3a5012801f9d1e;hpb=756ff73fbb0cdd01cce2eda27ba18e1cc99bd735;p=platal.git diff --git a/modules/profile.php b/modules/profile.php index fc6bd7d..b75fbe0 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -59,6 +59,8 @@ class ProfileModule extends PLModule 'admin/sections' => $this->make_hook('admin_sections', AUTH_MDP, 'admin'), 'admin/secteurs' => $this->make_hook('admin_secteurs', AUTH_MDP, 'admin'), 'admin/trombino' => $this->make_hook('admin_trombino', AUTH_MDP, 'admin'), + 'admin/ss_secteurs' => $this->make_hook('admin_ss_secteurs', AUTH_MDP, 'admin'), + 'admin/fonctions' => $this->make_hook('admin_fonctions', AUTH_MDP, 'admin'), ); } @@ -105,11 +107,16 @@ class ProfileModule extends PLModule function handler_medal(&$page, $mid) { + $thumb = ($mid == 'thumb'); + $mid = $thumb ? @func_get_arg(2) : $mid; + $res = XDB::query("SELECT img FROM profile_medals WHERE id = {?}", $mid); - $img = dirname(__FILE__).'/../htdocs/images/medals/' . $res->fetchOneCell(); + $img = $thumb ? + dirname(__FILE__).'/../htdocs/images/medals/thumb/' . $res->fetchOneCell() : + dirname(__FILE__).'/../htdocs/images/medals/' . $res->fetchOneCell(); $type = mime_content_type($img); header("Content-Type: $type"); echo file_get_contents($img); @@ -190,27 +197,29 @@ class ProfileModule extends PLModule WHERE matricule={?}", $x); $login = $res->fetchOneCell(); } else { - $login = get_user_forlife($x); + $login = get_user_forlife($x, S::logged() ? '_default_user_callback' + : '_silent_user_callback'); } if (empty($login)) { - if (preg_match('/([-a-z]+)\.([-a-z]+)\.([0-9]{4})/i', $x, $matches)) { - $matches = str_replace('-', '_', $matches); - $res = XDB::query("SELECT user_id - FROM auth_user_md5 - WHERE prenom LIKE {?} AND nom LIKE {?} AND promo = {?} - AND perms = 'pending'", - $matches[1], $matches[2], $matches[3]); - if ($res->numRows() == 1) { - $uid = $res->fetchOneCell(); - pl_redirect('marketing/public/' . $uid); - } + $user = get_not_registered_user($x, true); + if ($user->total() != 1) { + return PL_NOT_FOUND; } - return PL_NOT_FOUND; + $user = $user->next(); + if (S::logged()) { + pl_redirect('marketing/public/' . $user['user_id']); + } + $user['forlife'] = $x; + } else { + $new = Env::v('modif') == 'new'; + $user = get_user_details($login, S::v('uid'), $view); + } + + if (S::logged()) { + $_SESSION['log']->log('view_profile', $login); } - $new = Env::v('modif') == 'new'; - $user = get_user_details($login, S::v('uid'), $view); $title = $user['prenom'] . ' ' . ( empty($user['nom_usage']) ? $user['nom'] : $user['nom_usage'] ); $page->assign('xorg_title', $title); @@ -255,6 +264,7 @@ class ProfileModule extends PLModule $user['forlife'].'@'.$globals->mail->domain, $user['forlife'].'@'.$globals->mail->domain2); $page->assign('virtualalias', $res->fetchOneCell()); + $page->assign('view', $view); $page->addJsLink('close_on_esc.js'); header('Last-Modified: ' . date('r', strtotime($user['date']))); @@ -294,9 +304,9 @@ class ProfileModule extends PLModule // Build the page $page->addJsLink('ajax.js'); - $page->addJsLink('profile.js'); $page->addJsLink('applis.js'); $page->addJsLink('grades.js'); + $page->addJsLink('profile.js'); $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true, true); require_once dirname(__FILE__) . '/profile/page.inc.php'; $wiz->addPage('ProfileGeneral', 'Général', 'general'); @@ -755,16 +765,32 @@ class ProfileModule extends PLModule } function handler_admin_sections(&$page, $action = 'list', $id = null) { $page->assign('xorg_title','Polytechnique.org - Administration - Sections'); - $page->assign('title', 'Gestion des Sections'); + $page->assign('title', 'Gestion des sections'); $table_editor = new PLTableEditor('admin/sections','sections','id'); $table_editor->describe('text','intitulé',true); $table_editor->apply($page, $action, $id); } + function handler_admin_ss_secteurs(&$page, $action = 'list', $id = null) { + $page->assign('xorg_title', 'Polytechnique.org - Administration - Sous-secteurs'); + $page->assign('title', 'Gestion des sous-secteurs'); + $table_editor = new PLTableEditor('admin/ss_secteurs', 'emploi_ss_secteur', 'id', true); + $table_editor->describe('label', 'intitulé', true); + $table_editor->apply($page, $action, $id); + } + function handler_admin_fonctions(&$page, $action = 'list', $id = null) { + $page->assign('xorg_title', 'Polytechnique.org - Administration - Fonctions'); + $page->assign('title', 'Gestion des fonctions'); + $table_editor = new PLTableEditor('admin/fonctions', 'fonctions_def', 'id', true); + $table_editor->describe('fonction_fr', 'intitulé', true); + $table_editor->describe('fonction_en', 'intitulé (ang)', true); + $table_editor->describe('flags', 'titre', true); + $table_editor->apply($page, $action, $id); + } function handler_admin_secteurs(&$page, $action = 'list', $id = null) { - $page->assign('xorg_title','Polytechnique.org - Administration - Secteurs'); - $page->assign('title', 'Gestion des Secteurs'); - $table_editor = new PLTableEditor('admin/secteurs','emploi_secteur','id'); - $table_editor->describe('label','intitulé',true); + $page->assign('xorg_title', 'Polytechnique.org - Administration - Secteurs'); + $page->assign('title', 'Gestion des secteurs'); + $table_editor = new PLTableEditor('admin/secteurs', 'emploi_secteur', 'id', true); + $table_editor->describe('label', 'intitulé', true); $table_editor->apply($page, $action, $id); } function handler_admin_medals(&$page, $action = 'list', $id = null) { @@ -783,15 +809,24 @@ class ProfileModule extends PLModule if (Post::v('act') == 'del') { XDB::execute('DELETE FROM profile_medals_grades WHERE mid={?} AND gid={?}', $mid, Post::i('gid')); - } elseif (Post::v('act') == 'new') { - XDB::execute('INSERT INTO profile_medals_grades (mid,gid) - VALUES ({?},{?})', - $mid, max(array_keys(Post::v('grades', array(0))))+1); } else { foreach (Post::v('grades', array()) as $gid=>$text) { - XDB::execute('UPDATE profile_medals_grades - SET pos={?}, text={?} - WHERE gid={?} AND mid={?}', $_POST['pos'][$gid], $text, $gid, $mid); + if ($gid === 0) { + if (!empty($text)) { + $res = XDB::query('SELECT MAX(gid) + FROM profile_medals_grades + WHERE mid = {?}', $mid); + $gid = $res->fetchOneCell() + 1; + + XDB::execute('INSERT INTO profile_medals_grades (mid, gid, text, pos) + VALUES ({?}, {?}, {?}, {?})', + $mid, $gid, $text, $_POST['pos']['0']); + } + } else { + XDB::execute('UPDATE profile_medals_grades + SET pos={?}, text={?} + WHERE gid={?} AND mid={?}', $_POST['pos'][$gid], $text, $gid, $mid); + } } } $res = XDB::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid);