* @since 1.0 * @package MammutCMS * @subpackage Module */ class MMModBlog extends MMModCommentableList { public function runIndex(MMRequest $request, MMResponse $response, $activeInstance) { $system = \MCMS\System::getInstance(); $tplfile = __DIR__ . '/_layout_/_default_/' . 'tpl.' . $system->getTarget('action') . '.php'; // define the template file try { $template = new MFCTemplate(); $template->loadTemplate($tplfile); $template->setParam('title', 'User'); $template->setParam('self', $_SERVER['PHP_SELF']); $template->setParam('logoutLink', $_SERVER['PHP_SELF'] . '?mod=' . $activeInstance . '&view=logout'); $template->setParam('instance', $activeInstance); $template->setParam('isUser', !is_null($system->getUserSvc()->getUser())); $errors = array(-1 => 'Invalid login',-2 => 'Invalid password'); $template->setParam('error', !empty($_REQUEST['errno']) ? $errors[$_REQUEST['errno']] : false); $response->setFragment('CONTENT', $template->getDocument()); } catch(MFFileNotFoundException $ex) { $response->setFragment('CONTENT', "file is missing: " . $tplfile); } } public function runLogin(MMRequest $request, MMResponse $response, $activeInstance) { $login = $_POST['login']; $passwd = $_POST['passwd']; $system = \MCMS\System::getInstance(); $svc = $system->getUserSvc(); $usr = $svc->loginUser($login, $passwd); $redirectParam = array(); if(!is_object($usr)) $redirectParam['errno'] = (int) $usr; $response->setRedirect($activeInstance, 'index', $redirectParam); } public function runLogout(MMRequest $request, MMResponse $response, $activeInstance) { $system = \MCMS\System::getInstance(); $svc = $system->getUserSvc(); $usr = $svc->logoutUser(); $response->setRedirect($activeInstance, 'index'); } } ?>