From 50404f3b23b7fd6aeae4c9d2f6df0ea25e984e66 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 3 May 2016 19:03:09 +0200 Subject: WIP --- modules-available/main/page.inc.php | 64 +++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 modules-available/main/page.inc.php (limited to 'modules-available/main/page.inc.php') diff --git a/modules-available/main/page.inc.php b/modules-available/main/page.inc.php new file mode 100644 index 00000000..369d4b54 --- /dev/null +++ b/modules-available/main/page.inc.php @@ -0,0 +1,64 @@ +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() + { + // Render::setTitle('abc'); + + if (!User::isLoggedIn()) { + Render::addTemplate('page-main-guest', array( + 'register' => (Database::queryFirst('SELECT userid FROM user LIMIT 1') === false) + )); + return; + } + // 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 + )); + } + + protected function doAjax() + { + User::isLoggedIn(); + die('Status: DB running'); + } + +} -- cgit v1.2.3-55-g7522