<?php //----------------------------------------------------------------------------- namespace mycms; require_once 'DB.php'; require_once 'admin.class.php'; //----------------------------------------------------------------------------- global $g; if (!$g['user']['is_authenticated']) { $g['auth']->authenticate(); } // This page is only loaded for authorized users if (!$g['user']['is_admin']) { $g['error']->push('This account has no administration privilage', 'error', true); system::redirect(system::genlink('')); } if (!isset($_GET['content'])) { $_GET['content'] = 'people'; } $ct = strtolower($_GET['content']); $g['template'] = $ct . '_admin_create'; $err = false; // Set main menu options $menu = array(array('name' => 'people', 'url' => 'admin/people'), array('name' => 'research', 'url' => 'admin/research'), array('name' => 'publication', 'url' => 'admin/publication')); $g['smarty']->assign('menu', $menu); // Set secondary menu options $menu = array(array('name' => 'trac', 'url' => 'https://papyrus.usask.ca/trac/hci/'), array('name' => 'logout', 'url' => 'logout', 'user_id' => $g['user']['id'])); $g['smarty']->assign('menu_2', $menu); //----------------------------------------------------------------------------- function checkparams($params)
//you wanna to stay logged in? $_POST['remember'] = false; $res = $g['user']->login($_POST['username'], $_POST['password'], $_POST['remember']); // if login is not successful if ($res['count'] == 0) { $g['error']->push(L_LOGIN_ERROR, 'error', true); system::redirect(system::genlink('users/login'), true); } if ($g['user']->role != 'guest') { //if($_SESSION['request']){ //system::redirect(system::genlink($_SESSION['request']), true); //} else { system::redirect(system::genlink('pages/home'), true); //} } else { system::redirect(system::genlink('users/login'), true); } } $g['template'] = 'login'; break; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- case 'logout': $g['user']->logout(); system::redirect($g['weburl']); break; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- case 'edit_profile': if (isset($_POST['submit'])) { if ($_POST['password'] != $_POST['confirm_password']) {
// Set main menu options $menu = array(array('name' => 'Home', 'url' => ''), array('name' => 'People', 'url' => 'people'), array('name' => 'Research', 'url' => 'research'), array('name' => 'Publications', 'url' => 'publications'), array('name' => 'Courses', 'url' => 'courses'), array('name' => 'Download', 'url' => 'download'), array('name' => 'Contact', 'url' => 'contact')); $g['smarty']->assign('menu', $menu); $auth_menu_state = $g['user']['is_authenticated'] ? 'logout' : 'login'; // Set secondary menu options $menu = array(array('name' => 'trac', 'url' => $g['trac_url']), array('name' => $auth_menu_state, 'url' => $auth_menu_state, 'user_id' => $g['user']['id'])); $g['smarty']->assign('menu_2', $menu); //----------------------------------------------------------------------------- switch ($_GET['action']) { //----------------------------------------------------------------------------- //TODO: after login it should continue on the current page not the homepage case 'login': $g['auth']->authenticate(); goto HOME; case 'logout': $g['auth']->logout(system::genlink('')); goto HOME; //----------------------------------------------------------------------------- HOME: case 'home': $imglist = pages::get_imagelist(true); if (!$imglist['error'] && $imglist['count'] > 0) { $g['smarty']->assign('imglist', $imglist); } $faculty = $g['content']['people']->view('teaser', 'people.people_group = "faculty"'); if (!$faculty['error'] && $faculty['count'] > 0) { $g['smarty']->assign('faculty', $faculty); } $research = $g['content']['research']->view('teaser', 'research.research_status = "active"', 'research.research_priority DESC', '0,3'); if (!$research['error'] && $research['count'] > 0) { $g['smarty']->assign('research', $research);