public function defaultAction()
 {
     $loader = new \Twig_Loader_Filesystem(EQUIPMENT_VIEWS_DIR);
     $twig = new \Twig_Environment($loader);
     $args = array();
     $args['title'] = 'Plugin Maintenance';
     global $ost;
     $staff = \StaffAuthenticationBackend::getUser();
     $tocken = $ost->getCSRF();
     $args['staff'] = $staff;
     $args['linktoken'] = $ost->getLinkToken();
     $args['tocken'] = $tocken->getToken();
     $args['tocken_name'] = $tocken->getTokenName();
     echo $twig->render('maintenanceTemplate.html.twig', $args);
 }
 public function render($template, $args = array())
 {
     $loader = new \Twig_Loader_Filesystem(EQUIPMENT_VIEWS_DIR);
     $twig = new \Twig_Environment($loader);
     global $ost;
     $staff = \StaffAuthenticationBackend::getUser();
     $tocken = $ost->getCSRF();
     $args['staff'] = $staff;
     $args['linktoken'] = $ost->getLinkToken();
     $args['tocken'] = $tocken->getToken();
     $args['tocken_name'] = $tocken->getTokenName();
     if (!empty($_SESSION['flash'])) {
         $args['flash'] = $_SESSION['flash'];
         unset($_SESSION['flash']);
     }
     echo $twig->render($template, $args);
 }
示例#3
0
/* First order of the day is see if the user is logged in and with a valid session.
    * User must be valid staff beyond this point
    * ONLY super admins can access the helpdesk on offline state.
*/
if (!function_exists('staffLoginPage')) {
    //Ajax interface can pre-declare the function to  trap expired sessions.
    function staffLoginPage($msg)
    {
        global $ost, $cfg;
        $_SESSION['_staff']['auth']['dest'] = '/' . ltrim($_SERVER['REQUEST_URI'], '/');
        $_SESSION['_staff']['auth']['msg'] = $msg;
        require SCP_DIR . 'login.php';
        exit;
    }
}
$thisstaff = StaffAuthenticationBackend::getUser();
//1) is the user Logged in for real && is staff.
if (!$thisstaff || !$thisstaff->getId() || !$thisstaff->isValid()) {
    if (isset($_SESSION['_staff']['auth']['msg'])) {
        $msg = $_SESSION['_staff']['auth']['msg'];
        unset($_SESSION['_staff']['auth']['msg']);
    } elseif ($thisstaff && !$thisstaff->isValid()) {
        $msg = 'Session timed out due to inactivity';
    } else {
        $msg = 'Authentication Required';
    }
    staffLoginPage($msg);
    exit;
}
//2) if not super admin..check system status and group status
if (!$thisstaff->isAdmin()) {
 public function listNotBelongingJsonAction()
 {
     $properties = array();
     $staff = \StaffAuthenticationBackend::getUser();
     if (isset($staff)) {
         $items = \model\Equipment::findByNotStaffId($staff->getId());
     }
     foreach ($items as $item) {
         $properties[] = $item->getJsonProperties();
     }
     echo json_encode($properties);
 }