X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=classes%2Fplatalglobals.php.in;h=3f0085d5785827f5c2b817a92eb27700d050da7c;hb=f31c2a2484c122c1ed4928cb9d461917069e4418;hp=43140c6e9c154134592c9403cc78c7d977176f26;hpb=ea74d2785d9c1ff5571ebf2f73c89cbf19c8dd07;p=platal.git diff --git a/classes/platalglobals.php.in b/classes/platalglobals.php.in index 43140c6..3f0085d 100644 --- a/classes/platalglobals.php.in +++ b/classes/platalglobals.php.in @@ -1,6 +1,6 @@ core->sitename = 'Polytechnique.net'; + } } public function init() @@ -46,45 +52,34 @@ class PlatalGlobals extends PlGlobals $this->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 - 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"); + FROM accounts + WHERE state = 'active'"); $cnt = $res->fetchOneCell(); $this->changeDynamicConfig(array('NbIns' => $cnt)); } @@ -95,8 +90,12 @@ 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