2 /***************************************************************************
3 * Copyright (C) 2003-2014 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 class PlatalGlobals
extends PlGlobals
24 const DEBUG_NOCACHE
= DEBUG_USERBASE
;
26 /** The x.org version */
27 public $version = '@VERSION@';
31 public $dbprefix = '';
32 public $dbhost = 'localhost';
33 public $dbuser = null
;
35 public $dbcharset = 'utf8';
39 public $register_skin;
41 public function __construct()
43 parent
::__construct(array('platal.ini', 'platal.conf'));
44 if (isset($GLOBALS['IS_XNET_SITE'])) {
45 $this->core
->sitename
= 'Polytechnique.net';
49 public function init()
51 $this->bootstrap(array('NbIns'), array($this, 'updateNbIns'));
52 $this->bootstrap(array('NbValid'), array($this, 'updateNbValid'));
55 public function asso($key = null
)
57 static $fetched = false
;
60 if (isset($GLOBALS['IS_XNET_SITE']) && !$fetched) {
62 if ($p = strpos($gp, '/')) {
63 $gp = substr($gp, 0, $p);
66 $aid = Group
::get($gp);
71 } elseif (isset($aid->$key) ) {
78 public function updateNbIns()
80 $count = XDB
::rawFetchOneCell("SELECT COUNT(*)
82 INNER JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET('owner', ap.perms))
83 INNER JOIN profiles AS p ON (ap.pid = p.pid)
84 WHERE a.state = 'active' AND p.deathdate IS NULL");
85 $this->changeDynamicConfig(array('NbIns' => $count));
88 public function updateNbValid()
90 $res = XDB
::query("SELECT COUNT(*)
92 $this->changeDynamicConfig(array('NbValid' => $res->fetchOneCell()));
95 public function cacheEnabled()
97 return ($this->debug
& self
::DEBUG_NOCACHE
) == 0;
101 /******************************************************************************
102 * Dynamic configuration update/edition stuff
103 *****************************************************************************/
105 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: