'skin' field in 'accounts' corresponds to 'id' in 'skins' and thus should have the...
[platal.git] / modules / admin.php
index 988a3ea..3aa7a7c 100644 (file)
@@ -27,7 +27,6 @@ class AdminModule extends PLModule
             'phpinfo'                      => $this->make_hook('phpinfo',                AUTH_MDP, 'admin'),
             'get_rights'                   => $this->make_hook('get_rights',             AUTH_MDP, 'admin'),
             'admin'                        => $this->make_hook('default',                AUTH_MDP, 'admin'),
-            'admin/ax-xorg'                => $this->make_hook('ax_xorg',                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'),
             'admin/downtime'               => $this->make_hook('downtime',               AUTH_MDP, 'admin'),
@@ -396,7 +395,7 @@ class AdminModule extends PLModule
             pl_redirect("admin/logger?loguser=$login&year=".date('Y')."&month=".date('m'));
         }
 
-        if(Post::has('su_button') && $registered) {
+        if(Post::has('su_account') && $registered) {
             if (!Platal::session()->startSUID($user)) {
                 $page->trigError('Impossible d\'effectuer un SUID sur ' . $user->login());
             } else {
@@ -434,10 +433,10 @@ class AdminModule extends PLModule
             if (Post::i('token_access', 0) != ($user->token_access ? 1 : 0)) {
                 $to_update['token'] = Post::i('token_access') ? rand_url_id(16) : null;
             }
-            if (Post::i('skin', 0) != $user->skin) {
-                $to_update['skin'] = Post::i('skin', 0);
+            if (Post::i('skin') != $user->skin) {
+                $to_update['skin'] = Post::i('skin');
                 if ($to_update['skin'] == 0) {
-                    $to_update['skin'] = null;
+                    $to_update['skin'] = 1;
                 }
             }
             if (Post::s('state') != $user->state) {
@@ -579,7 +578,7 @@ class AdminModule extends PLModule
 
         // OpenId form {{{
         if (Post::has('del_openid')) {
-            XDB::execute('DELETE FROM  openid_trusted
+            XDB::execute('DELETE FROM  account_auth_openid
                                 WHERE  id = {?}', Post::i('del_openid'));
         }
         // }}}
@@ -599,8 +598,8 @@ class AdminModule extends PLModule
         // }}}
 
 
-        $page->addJsLink('ui.core.js');
-        $page->addJsLink('ui.tabs.js');
+        $page->addJsLink('jquery.ui.core.js');
+        $page->addJsLink('jquery.ui.tabs.js');
 
         // Displays last login and last host information.
         $res = XDB::query("SELECT  start, host
@@ -626,8 +625,8 @@ class AdminModule extends PLModule
                                              INNER JOIN  profiles AS p ON (ap.pid = p.pid)
                                                   WHERE  ap.uid = {?}', $user->id()));
         $page->assign('openid', XDB::iterator('SELECT  id, url
-                                                 FROM  openid_trusted
-                                                WHERE  user_id = {?}', $user->id()));
+                                                 FROM  account_auth_openid
+                                                WHERE  uid = {?}', $user->id()));
 
         // Displays email redirection and the general profile.
         if ($registered && $redirect) {
@@ -698,18 +697,17 @@ class AdminModule extends PLModule
         $page->changeTpl('admin/add_accounts.tpl');
 
         if (Env::has('add_type') && Env::has('people')) {
-            require_once 'directory.enums.inc.php';
             $lines = explode("\n", Env::t('people'));
             $separator = Env::t('separator');
             $promotion = Env::i('promotion');
-            $nameTypes = DirEnum::getOptionsArray(DirEnum::NAMETYPES);
+            $nameTypes = DirEnum::getOptions(DirEnum::NAMETYPES);
             $nameTypes = array_flip($nameTypes);
 
             if (Env::t('add_type') == 'promo') {
                 $type = 'x';
-                $eduSchools = DirEnum::getOptionsArray(DirEnum::EDUSCHOOLS);
+                $eduSchools = DirEnum::getOptions(DirEnum::EDUSCHOOLS);
                 $eduSchools = array_flip($eduSchools);
-                $eduDegrees = DirEnum::getOptionsArray(DirEnum::EDUDEGREES);
+                $eduDegrees = DirEnum::getOptions(DirEnum::EDUDEGREES);
                 $eduDegrees = array_flip($eduDegrees);
                 var_dump($eduDegrees);
                 switch (Env::t('edu_type')) {
@@ -843,7 +841,7 @@ class AdminModule extends PLModule
                     XDB::execute("UPDATE  aliases
                                      SET  type = 'homonyme', expire=NOW()
                                    WHERE  alias = {?}", $loginbis);
-                    XDB::execute("REPLACE INTO  homonyms (homonyme_id,user_id)
+                    XDB::execute("REPLACE INTO  homonyms (homonyme_id, uid)
                                         VALUES  ({?}, {?})", $target, $target);
                     send_robot_homonyme($user, $loginbis);
                     $op = 'list';
@@ -856,11 +854,10 @@ class AdminModule extends PLModule
             $res = XDB::iterator(
                     "SELECT  a.alias AS homonyme, s.alias AS forlife,
                              IF(h.homonyme_id = s.id, a.expire, NULL) AS expire,
-                             IF(h.homonyme_id = s.id, a.type, NULL) AS type,
-                             ac.uid AS user_id
+                             IF(h.homonyme_id = s.id, a.type, NULL) AS type, ac.uid
                        FROM  aliases       AS a
-                  LEFT JOIN  homonyms      AS h ON (h.homonyme_id = a.uid)
-                 INNER JOIN  aliases       AS s ON (s.uid = h.user_id AND s.type='a_vie')
+                  LEFT JOIN  homonyms      AS h  ON (h.homonyme_id = a.uid)
+                 INNER JOIN  aliases       AS s  ON (s.uid = h.uid AND s.type = 'a_vie')
                  INNER JOIN  accounts      AS ac ON (ac.uid = a.uid)
                       WHERE  a.type = 'homonyme' OR a.expire != ''
                    ORDER BY  a.alias, forlife");
@@ -868,7 +865,7 @@ class AdminModule extends PLModule
             while ($tab = $res->next()) {
                 $hnymes[$tab['homonyme']][] = $tab;
             }
-            $page->assign_by_ref('hnymes',$hnymes);
+            $page->assign_by_ref('hnymes', $hnymes);
         }
     }
 
@@ -903,9 +900,9 @@ class AdminModule extends PLModule
                                WHERE  hrpid = {?}', $val, $pid);
                 $page->trigSuccess('Ajout du décès de ' . $name . ' le ' . $val . '.');
                 if($death == '0000-00-00' || empty($death)) {
-                    // TODO: FIX THIS DEPRECATED CALL
-                    require_once('user.func.inc.php');
-                    user_clear_all_subs($uid, false);   // by default, dead ppl do not loose their email
+                    $profile = Profile::get($pid);
+                    $profile->clear();
+                    $profile->owner()->clear(false);
                 }
             }
         }
@@ -938,7 +935,7 @@ class AdminModule extends PLModule
 
     function handler_validate(&$page, $action = 'list', $id = null)
     {
-        $page->changeTpl('admin/valider.tpl');
+        $page->changeTpl('admin/validation.tpl');
         $page->setTitle('Administration - Valider une demande');
                 $page->addCssLink('nl.css');
         $page->addJsLink('ajax.js');
@@ -965,7 +962,9 @@ class AdminModule extends PLModule
         $page->assign('categories', $categories = explode(',', str_replace("'", '', substr($a['Type'], 5, -1))));
 
         $hidden = array();
-        $res = XDB::query('SELECT hidden_requests FROM requests_hidden WHERE user_id = {?}', S::v('uid'));
+        $res = XDB::query('SELECT  hidden_requests
+                             FROM  requests_hidden
+                            WHERE  uid = {?}', S::v('uid'));
         $hide_requests = $res->fetchOneCell();
         if (Post::has('hide')) {
             $hide = array();
@@ -975,7 +974,8 @@ class AdminModule extends PLModule
                     $hide[] = $cat;
                 }
             $hide_requests = join(',', $hide);
-            XDB::query('REPLACE INTO requests_hidden (user_id, hidden_requests) VALUES({?}, {?})',
+            XDB::query('REPLACE INTO  requests_hidden (uid, hidden_requests)
+                              VALUES  ({?}, {?})',
                        S::v('uid'), $hide_requests);
         } elseif ($hide_requests)  {
             foreach (explode(',', $hide_requests) as $hide_type)