X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fadmin.php;h=ee66de1e9e8ae3fc771188c01430d3188c2fd311;hb=1490093c909c086ce8eba3c0f5c24b62ef20cfb3;hp=a635f009fe2de7a60934ee87b1170728ed233ccf;hpb=ccdbc270a4d0e98d88c1d7a29e8cb3c5f260bcef;p=platal.git diff --git a/modules/admin.php b/modules/admin.php index a635f00..ee66de1 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -45,6 +45,7 @@ class AdminModule extends PLModule 'admin/validate/answers' => $this->make_hook('validate_answers', AUTH_MDP, 'admin'), 'admin/wiki' => $this->make_hook('wiki', AUTH_MDP, 'admin'), 'admin/ipwatch' => $this->make_hook('ipwatch', AUTH_MDP, 'admin'), + 'admin/icons' => $this->make_hook('icons', AUTH_MDP, 'admin'), ); } @@ -63,12 +64,12 @@ class AdminModule extends PLModule function handler_postfix_delayed(&$page) { $page->changeTpl('admin/postfix_delayed.tpl'); - $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Retardés'); + $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Retardés'); if (Env::has('del')) { $crc = Env::v('crc'); XDB::execute("UPDATE postfix_mailseen SET release = 'del' WHERE crc = {?}", $crc); - $page->trig($crc." verra tous ses mails supprimés !"); + $page->trig($crc." verra tous ses mails supprimés !"); } elseif (Env::has('ok')) { $crc = Env::v('crc'); XDB::execute("UPDATE postfix_mailseen SET release = 'ok' WHERE crc = {?}", $crc); @@ -339,7 +340,7 @@ class AdminModule extends PLModule } $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 annuée et/ou un utilisateur"); } } @@ -356,7 +357,7 @@ class AdminModule extends PLModule require_once("user.func.inc.php"); if (S::has('suid')) { - $page->kill("déjà en SUID !!!"); + $page->kill("déjà en SUID !!!"); } if (Env::has('user_id')) { @@ -388,13 +389,15 @@ class AdminModule extends PLModule if ($login) { if (is_numeric($login)) { - $r = XDB::query("SELECT *, a.alias AS forlife, u.flags AS sexe, + $r = XDB::query("SELECT *, a.alias AS forlife, + FIND_IN_SET('watch', u.flags) AS watch, FIND_IN_SET('femme', u.flags) AS sexe, (year(naissance) > promo - 15 or year(naissance) < promo - 25) AS naiss_err FROM auth_user_md5 AS u LEFT JOIN aliases AS a ON (a.id = u.user_id AND type= 'a_vie') WHERE u.user_id = {?}", $login); } else { - $r = XDB::query("SELECT *, a.alias AS forlife, u.flags AS sexe, + $r = XDB::query("SELECT *, a.alias AS forlife, + FIND_IN_SET('watch', u.flags) AS watch, FIND_IN_SET('femme', u.flags) AS sexe, (year(naissance) > promo - 15 or year(naissance) < promo - 25) AS naiss_err FROM auth_user_md5 AS u INNER JOIN aliases AS a ON ( a.id = u.user_id AND a.alias={?} AND type!='homonyme' )", $login); @@ -414,7 +417,7 @@ class AdminModule extends PLModule $page->trig("invalid email $email"); } else { $redirect->add_email($email); - $page->trig("Ajout de $email effectué"); + $page->trig("Ajout de $email effectué"); } break; @@ -434,7 +437,7 @@ class AdminModule extends PLModule WHERE uid = {?} AND rewrite LIKE CONCAT({?}, '@%')", $mr['user_id'], $val); fix_bestalias($mr['user_id']); - $page->trig($val." a été supprimé"); + $page->trig($val." a été supprimé"); } break; case "activate_fwd": @@ -473,7 +476,23 @@ class AdminModule extends PLModule $nom = Env::v('nomN'); $promo = Env::i('promoN'); $sexe = Env::v('sexeN'); - $comm = Env::v('commentN'); + $comm = trim(Env::v('commentN')); + $watch = Env::v('watchN'); + $flags = ''; + if ($sexe) { + $flags = 'femme'; + } + if ($watch) { + if ($flags) { + $flags .= ','; + } + $flags .= 'watch'; + } + + if ($watch && !$comm) { + $page->trig("Il est nécessaire de mettre un commentaire pour surveiller un compte"); + break; + } $query = "UPDATE auth_user_md5 SET naissance = '$naiss', @@ -482,29 +501,29 @@ class AdminModule extends PLModule perms = '$perms', prenom = '".addslashes($prenm)."', nom = '".addslashes($nom)."', - flags = '$sexe', + flags = '$flags', promo = $promo, comment = '".addslashes($comm)."' WHERE user_id = '{$mr['user_id']}'"; if (XDB::execute($query)) { user_reindex($mr['user_id']); - $mailer = new PlMailer(); - $mailer->setFrom("webmaster@polytechnique.org"); - $mailer->addTo("web@polytechnique.org"); - $mailer->setSubject("INTERVENTION de ".S::v('forlife')); - $mailer->setTxtBody(preg_replace("/[ \t]+/", ' ', $query)); + $mailer = new PlMailer("admin/mail_intervention.tpl"); + $mailer->assign("user", S::v('forlife')); + $mailer->assign("query", $query); $mailer->send(); - $page->trig("updaté correctement."); + $page->trig("updaté correctement."); } if (Env::v('nomusageN') != $mr['nom_usage']) { + require_once "xorg.misc.inc.php"; set_new_usage($mr['user_id'], Env::v('nomusageN'), make_username(Env::v('prenomN'), Env::v('nomusageN'))); } if (Env::v('decesN') != $mr['deces']) { user_clear_all_subs($mr['user_id'], false); } - $r = XDB::query("SELECT *, a.alias AS forlife, u.flags AS sexe + $r = XDB::query("SELECT *, a.alias AS forlife, + FIND_IN_SET('watch', u.flags) AS watch, FIND_IN_SET('femme', u.flags) AS sexe FROM auth_user_md5 AS u LEFT JOIN aliases AS a ON (a.id = u.user_id AND type= 'a_vie') WHERE u.user_id = {?}", $mr['user_id']); @@ -514,12 +533,10 @@ class AdminModule extends PLModule // DELETE FROM auth_user_md5 case "u_kill": user_clear_all_subs($mr['user_id']); - $page->trig("'{$mr['user_id']}' a été désinscrit !"); - $mailer = new PlMailer(); - $mailer->setFrom("webmaster@polytechnique.org"); - $mailer->addTo("web@polytechnique.org"); - $mailer->setSubject("INTERVENTION de ".S::v('forlife')); - $mailer->setTxtBody("\nUtilisateur $login désinscrit"); + $page->trig("'{$mr['user_id']}' a été désinscrit !"); + $mailer = new PlMailer("admin/mail_intervention.tpl"); + $mailer->assign("user", S::v('forlife')); + $mailer->assign("query", "\nUtilisateur $login désinscrit"); $mailer->send(); break; } @@ -666,7 +683,7 @@ class AdminModule extends PLModule $page->changeTpl('admin/ax-xorg.tpl'); $page->assign('xorg_title','Polytechnique.org - Administration - AX/X.org'); - // liste des différences + // liste des différences $res = XDB::query( 'SELECT u.promo,u.nom AS nom,u.prenom AS prenom,ia.nom AS nomax,ia.prenom AS prenomax,u.matricule AS mat,ia.matricule_ax AS matax FROM auth_user_md5 AS u @@ -677,7 +694,7 @@ class AdminModule extends PLModule ORDER BY u.promo,u.nom,u.prenom'); $page->assign('diffs', $res->fetchAllAssoc()); - // gens à l'ax mais pas chez nous + // gens à l'ax mais pas chez nous $res = XDB::query( 'SELECT ia.promo,ia.nom,ia.nom_patro,ia.prenom FROM identification_ax as ia @@ -685,7 +702,7 @@ class AdminModule extends PLModule WHERE u.nom IS NULL'); $page->assign('mank', $res->fetchAllAssoc()); - // gens chez nous et pas à l'ax + // gens chez nous et pas à l'ax $res = XDB::query('SELECT promo,nom,prenom FROM auth_user_md5 WHERE matricule_ax IS NULL'); $page->assign('plus', $res->fetchAllAssoc()); } @@ -772,11 +789,15 @@ class AdminModule extends PLModule } } - function handler_validate(&$page, $action = 'list', $id = null) { + function handler_validate(&$page, $action = 'list', $id = null) + { $page->changeTpl('admin/valider.tpl'); $page->assign('xorg_title','Polytechnique.org - Administration - Valider une demande'); + $page->addCssLink('nl.css'); + $page->addJsLink('ajax.js'); require_once("validations.inc.php"); + if ($action == 'edit' and !is_null($id)) { $page->assign('preview_id', $id); } @@ -807,11 +828,12 @@ class AdminModule extends PLModule $page->assign('vit', new ValidateIterator()); } + function handler_validate_answers(&$page, $action = 'list', $id = null) { - $page->assign('xorg_title','Polytechnique.org - Administration - Réponses automatiques de validation'); - $page->assign('title', 'Gestion des réponses automatiques'); + $page->assign('xorg_title','Polytechnique.org - Administration - Réponses automatiques de validation'); + $page->assign('title', 'Gestion des réponses automatiques'); $table_editor = new PLTableEditor('admin/validate/answers','requests_answers','id'); - $table_editor->describe('category','catégorie',true); + $table_editor->describe('category','catégorie',true); $table_editor->describe('title','titre',true); $table_editor->describe('answer','texte',false); $table_editor->apply($page, $action, $id); @@ -844,19 +866,19 @@ class AdminModule extends PLModule $table_editor->apply($page, $action, $id); } function handler_mx_broken(&$page, $action = 'list', $id = null) { - $page->assign('xorg_title', 'Polytechnique.org - Administration - MX Défaillants'); - $page->assign('title', 'MX Défaillant'); + $page->assign('xorg_title', 'Polytechnique.org - Administration - MX Défaillants'); + $page->assign('title', 'MX Défaillant'); $table_editor = new PLTableEditor('admin/mx/broken', 'mx_watch', 'host', true); $table_editor->describe('host', 'Masque', true); $table_editor->describe('state', 'Niveau', true); - $table_editor->describe('text', 'Description du problème', false); + $table_editor->describe('text', 'Description du problème', false); $table_editor->apply($page, $action, $id); } function handler_logger_actions(&$page, $action = 'list', $id = null) { $page->assign('xorg_title','Polytechnique.org - Administration - Actions'); $page->assign('title', 'Gestion des actions de logger'); $table_editor = new PLTableEditor('admin/logger/actions','logger.actions','id'); - $table_editor->describe('text','intitulé',true); + $table_editor->describe('text','intitulé',true); $table_editor->describe('description','description',true); $table_editor->apply($page, $action, $id); } @@ -865,14 +887,14 @@ class AdminModule extends PLModule $page->assign('title', 'Gestion des coupures'); $table_editor = new PLTableEditor('admin/downtime','coupures','id'); $table_editor->describe('debut','date',true); - $table_editor->describe('duree','durée',false); - $table_editor->describe('resume','résumé',true); - $table_editor->describe('services','services affectés',true); + $table_editor->describe('duree','durée',false); + $table_editor->describe('resume','résumé',true); + $table_editor->describe('services','services affectés',true); $table_editor->describe('description','description',false); $table_editor->apply($page, $action, $id); } - function handler_wiki(&$page, $action='list') + function handler_wiki(&$page, $action='list', $wikipage='', $wikipage2='') { require_once 'wiki.inc.php'; @@ -893,6 +915,26 @@ class AdminModule extends PLModule } } } + + if ($action == 'delete' && $wikipage != '') { + if (wiki_delete_page($wikipage)) { + $page->trig("La page ".$wikipage." a été supprimée."); + } else { + $page->trig("Impossible de supprimer la page ".$wikipage."."); + } + } + + if ($action == 'rename' && $wikipage != '' && $wikipage2 != '' && $wikipage != $wikipage2) { + if ($changedLinks = wiki_rename_page($wikipage, $wikipage2)) { + $s = 'La page '.$wikipage.' a été déplacée en '.$wikipage2.'.'; + if (is_numeric($changedLinks)) { + $s .= $changedLinks.' lien'.(($changedLinks>1)?'s ont été modifiés.':' a été modifié.'); + } + $page->trig($s); + } else { + $page->trig("Impossible de déplacer la page ".$wikipage); + } + } $perms = wiki_perms_options(); @@ -904,6 +946,9 @@ class AdminModule extends PLModule while (($file = readdir($dh)) !== false) if (substr($file,0,1) >= 'A' && substr($file,0,1) <= 'Z') { list($read,$edit) = wiki_get_perms($file); $wiki_pages[$file] = array('read' => $perms[$read], 'edit' => $perms[$edit]); + if (is_file($dir . '/cache_' . wiki_filename($file) . '.tpl')) { + $wiki_pages[$file]['cached'] = true; + } } closedir($dh); } @@ -921,6 +966,7 @@ class AdminModule extends PLModule $page->changeTpl('admin/wiki.tpl'); + $page->addJsLink('jquery.js'); $page->assign('wiki_pages', $wiki_tree); $page->assign('perms_opts', $perms); } @@ -930,8 +976,8 @@ class AdminModule extends PLModule $page->changeTpl('admin/ipwatcher.tpl'); $states = array('safe' => 'Ne pas surveiller', - 'unsafe' => 'Surveiller les inscription', - 'dangerous' => 'Surveiller tous les accès', + 'unsafe' => 'Surveiller les inscriptions', + 'dangerous' => 'Surveiller tous les accès', 'ban' => 'Bannir cette adresse'); $page->assign('states', $states); @@ -961,9 +1007,9 @@ class AdminModule extends PLModule $page->assign('action', $action); if ($action == 'list') { - $sql = "SELECT w.ip, s.host, w.detection, w.state, a.alias AS forlife + $sql = "SELECT w.ip, IF(w.ip = s.ip, s.host, s.forward_host), w.detection, w.state, a.alias AS forlife FROM ip_watch AS w - LEFT JOIN logger.sessions AS s USING(ip) + LEFT JOIN logger.sessions AS s ON (s.ip = w.ip OR s.forward_ip = w.ip) LEFT JOIN aliases AS a ON (a.id = s.uid AND a.type = 'a_vie') GROUP BY w.ip, a.alias ORDER BY w.state, w.ip, a.alias"; @@ -1019,6 +1065,24 @@ class AdminModule extends PLModule $page->assign('ip', $props); } } + + function handler_icons(&$page) + { + $page->changeTpl('admin/icons.tpl'); + $dh = opendir('../htdocs/images/icons'); + if (!$dh) { + $page->trig('Dossier des icones introuvables.'); + } + $icons = array(); + while (($file = readdir($dh)) !== false) { + if (strlen($file) > 4 && substr($file,-4) == '.gif') { + array_push($icons, substr($file, 0, -4)); + } + } + sort($icons); + $page->assign('icons', $icons); + } } +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>