X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplatalglobals.php.in;h=6bd15186f546fb760dc637b9b4cee1f73901b56e;hb=05613e9aa75a084c495c82f6af043d5246e003ab;hp=94803e8389952919047d759ee5c976328d568798;hpb=1f58ccb1e75eca08fbd04971d617ea372bc77b5a;p=platal.git diff --git a/classes/platalglobals.php.in b/classes/platalglobals.php.in index 94803e8..6bd1518 100644 --- a/classes/platalglobals.php.in +++ b/classes/platalglobals.php.in @@ -1,6 +1,6 @@ bootstrap(array('NbValid'), array($this, 'updateNbValid')); } - public function asso($key=null) + public function asso($key = null) { + static $fetched = false; static $aid = null; - if (is_null($aid)) { + if (isset($GLOBALS['IS_XNET_SITE']) && !$fetched) { $gp = Get::v('n'); if ($p = strpos($gp, '/')) { $gp = substr($gp, 0, $p); } - if ($gp) { - $res = XDB::query("SELECT a.*, d.nom AS domnom, - FIND_IN_SET('wiki_desc', a.flags) AS wiki_desc, - FIND_IN_SET('notif_unsub', a.flags) AS notif_unsub, - FIND_IN_SET('has_ml', a.flags) AS has_ml - FROM groupex.asso AS a - LEFT JOIN groupex.dom AS d ON d.id = a.dom - WHERE diminutif = {?}", - $gp); - if (!($aid = $res->fetchOneAssoc())) { - $aid = array(); - } - } else { - $aid = array(); - } + $aid = Group::get($gp); + $fetched = true; } if (empty($key)) { return $aid; - } elseif ( isset($aid[$key]) ) { - return $aid[$key]; + } elseif (isset($aid->$key) ) { + return $aid->$key; } else { return null; } } - public function updateNbIns() { - $res = XDB::query("SELECT COUNT(*) - FROM auth_user_md5 - WHERE perms IN ('admin','user') AND deces=0"); - $cnt = $res->fetchOneCell(); - $this->changeDynamicConfig(array('NbIns' => $cnt)); + $count = XDB::rawFetchOneCell("SELECT COUNT(*) + FROM accounts AS a + INNER JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET('owner', ap.perms)) + INNER JOIN profiles AS p ON (ap.pid = p.pid) + WHERE a.state = 'active' AND p.deathdate IS NULL"); + $this->changeDynamicConfig(array('NbIns' => $count)); } public function updateNbValid() @@ -100,12 +91,16 @@ class PlatalGlobals extends PlGlobals FROM requests"); $this->changeDynamicConfig(array('NbValid' => $res->fetchOneCell())); } -} + public function cacheEnabled() + { + return ($this->debug & self::DEBUG_NOCACHE) == 0; + } +} /****************************************************************************** * Dynamic configuration update/edition stuff *****************************************************************************/ -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>