/** * Used to start/finish adding a link between a system and an owner * Optionally add a new system using the Systems model class * * @param array $options */ public function sysaddAction($options) { // get system object $system = new \Videogames\Model\Systems(); if (isset($_POST) && sizeof($_POST) > 0 && isset($_POST['own_id'])) { if (!isset($_POST['sys_id']) || $_POST['sys_id'] == '0') { if (!isset($_POST['sys_long']) || !isset($_POST['sys_short'])) { $this->errorMsg['error_msg'] = "No system passed!"; $this->render($this->errorPage, $this->errorMsg, $this->stdHeader); exit; } // Check if a system is known with given code $temp = $system->getSystemByCode($_POST['sys_short']); // No system exists, then add it if ($temp === false) { $system->add($_POST); $sys_id = \Videogames\Db::getInstance()->lastInsertId(); } else { // otherwise use this system (for now give an error) // $sys_id = $temp['sys_id']; $this->errorMsg['error_msg'] = "Abbreviation " . $_POST['sys_short'] . " already exsists!"; $this->render($this->errorPage, $this->errorMsg, $this->stdHeader); exit; } } else { $sys_id = $_POST['sys_id']; } $own_id = $_POST['own_id']; if ($this->data->addSystem(['own_id' => $own_id, 'sys_id' => $sys_id])) { header("Location: /owner/syslist/" . $own_id); exit; } else { $this->errorMsg['error_msg'] = "Add failed."; $this->render($this->errorPage, $this->errorMsg, $this->stdHeader); exit; } } if (!isset($options['own_id']) || empty($options['own_id'])) { $this->errorMsg['error_msg'] = "No owner ID passed!"; $this->render($this->errorPage, $this->errorMsg, $this->stdHeader); exit; } $owner = $this->data->getOwner($options['own_id']); if ($owner === false) { $this->errorMsg['error_msg'] = "Owner not found!"; $this->render($this->errorPage, $this->errorMsg, $this->stdHeader); exit; } $systems = $system->getAllSystems(); $sysown = $this->data->getSystems($options['own_id']); $this->render("owner/addsystem.phtml", ['owner' => $owner, 'systems' => $systems, 'sysown' => $sysown], $this->stdHeader); }
/** * Used to list games for a specified system * * @param array $options */ public function list2Action($options) { $sys_id = 0; $system = false; if (isset($options['sys_id'])) { $sys_id = $options['sys_id']; $_system = new \Videogames\Model\Systems(); $system = $_system->getSystem($sys_id); $this->actHeader = $this->altHeader; } if ($system === false) { $this->errorMsg['error_msg'] = "System not found!"; $this->render($this->errorPage, $this->errorMsg, $this->actHeader); exit; } $games = $this->data->getSystemGames($sys_id); $this->render("game/list2.phtml", ['system' => $system, 'games' => $games], $this->actHeader); }