From 2e18b36a287ad9b25619f9e2a073dcedf6d620ee Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 18 May 2016 18:04:56 +0200 Subject: MORE WMORK --- modules-available/main/page.inc.php | 44 +++++++++++-------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) (limited to 'modules-available/main/page.inc.php') diff --git a/modules-available/main/page.inc.php b/modules-available/main/page.inc.php index 0a9acd81..bd50a5d1 100644 --- a/modules-available/main/page.inc.php +++ b/modules-available/main/page.inc.php @@ -3,24 +3,9 @@ class Page_Main extends Page { - private $sysconfig; - private $minilinux; - private $vmstore; - private $ipxe; - private $delPending; - protected function doPreprocess() { User::load(); - if (User::isLoggedIn()) { - $this->sysconfig = !file_exists(CONFIG_HTTP_DIR . '/default/config.tgz'); - $this->minilinux = !file_exists(CONFIG_HTTP_DIR . '/default/kernel') || !file_exists(CONFIG_HTTP_DIR . '/default/initramfs-stage31') || !file_exists(CONFIG_HTTP_DIR . '/default/stage32.sqfs'); - $this->vmstore = !is_array(Property::getVmStoreConfig()); - $this->ipxe = !preg_match('/^\d+\.\d+\.\d+\.\d+$/', Property::getServerIp()); - Property::setNeedsSetup(($this->sysconfig || $this->minilinux || $this->vmstore || $this->ipxe) ? 1 : 0); - $res = Database::queryFirst("SELECT Count(*) AS cnt FROM sat.imageversion WHERE deletestate = 'SHOULD_DELETE'", array(), true); - $this->delPending = isset($res['cnt']) ? $res['cnt'] : 0; - } } protected function doRender() @@ -33,24 +18,21 @@ class Page_Main extends Page } // Logged in here - // Load news - $lines = array(); - $paginate = new Paginate("SELECT newsid, dateline, title, content FROM news ORDER BY dateline DESC", 10); - $res = $paginate->exec(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { - if(count($lines) >= 3) break; - $lines[] = $row; - } - Render::addTemplate('page-main', array( - 'user' => User::getName(), - 'sysconfig' => $this->sysconfig, - 'minilinux' => $this->minilinux, - 'vmstore' => $this->vmstore, - 'ipxe' => $this->ipxe, - 'delpending' => $this->delPending, - 'news' => $lines + 'user' => User::getName() )); + + // Warnings + $needSetup = false; + foreach (glob('modules/*/hooks/main-warning.inc.php') as $file) { + preg_match('#^modules/([^/]+)/#', $file, $out); + if (!Module::isAvailable($out[1])) + continue; + include $file; + } + + // Update warning state + Property::setNeedsSetup($needSetup ? 1 : 0); } protected function doAjax() -- cgit v1.2.3-55-g7522