jakCheckrestlogged($userid, $loginhash); if ($usr) { // Select the fields $jakuser = new JAK_user($usr); // Only the SuperAdmin in the config file see everything if ($jakuser->jakSuperadminaccess($userid)) { define('JAK_SUPERADMINACCESS', true); } else { define('JAK_SUPERADMINACCESS', false); } // Check if a sibling has logged in if ($jakuser->getVar("opid") != 0) { $opcacheid = $jakuser->getVar("opid"); } else { $opcacheid = $jakuser->getVar("id"); } // Cache stuff if (file_exists(APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php')) include_once APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php'; // timezone from server date_default_timezone_set(JAK_TIMEZONESERVER); $jakdb->query('SET time_zone = "'.date("P").'"'); // Check if a sibling has logged in if ($jakuser->getVar("opid") != 0) $opcacheid = $jakuser->getVar("opid"); // Ok, we have check for some data, pull it if (jak_get_access("support", $jakuser->getVar("permissions"), JAK_SUPERADMINACCESS)) { // Filter the right result or show all if (is_numeric($jakuser->getVar("support_dep")) && $jakuser->getVar("support_dep") != 0) { $newdata = $jakdb->select("support_tickets", ["[>]support_departments" => ["depid" => "id"]], ["support_tickets.id", "support_tickets.subject", "support_departments.title(department)", "support_tickets.name", "support_tickets.email", "support_tickets.private", "support_tickets.status", "support_tickets.updated"], ["AND" => ["OR" => ["support_tickets.operatorid" => $jakuser->getVar("id"), "support_tickets.depid" => $jakuser->getVar("support_dep")], "support_tickets.opid" => $opcacheid], "ORDER" => ["support_tickets.updated" => "DESC"]]); } elseif (!((boolean)$jakuser->getVar("support_dep")) && $jakuser->getVar("support_dep") != 0) { $newdata = $jakdb->select("support_tickets", ["[>]support_departments" => ["depid" => "id"]], ["support_tickets.id", "support_tickets.subject", "support_departments.title(department)", "support_tickets.name", "support_tickets.email", "support_tickets.private", "support_tickets.status", "support_tickets.updated"], ["AND" => ["OR" => ["support_tickets.operatorid" => $jakuser->getVar("id"), "support_tickets.depid" => [$jakuser->getVar("support_dep")]], "support_tickets.opid" => $opcacheid], "ORDER" => ["support_tickets.updated" => "DESC"]]); } else { $newdata = $jakdb->select("support_tickets", ["[>]support_departments" => ["depid" => "id"]], ["support_tickets.id", "support_tickets.subject", "support_departments.title(department)", "support_tickets.name", "support_tickets.email", "support_tickets.private", "support_tickets.status", "support_tickets.updated"], ["support_tickets.opid" => $opcacheid, "ORDER" => ["support_tickets.updated" => "DESC"]]); } } if (isset($newdata) && !empty($newdata)) { die(json_encode(array('status' => true, 'tickets' => $newdata))); } else { die(json_encode(array('status' => false, 'errorcode' => 9))); } } else { die(json_encode(array('status' => false, 'errorcode' => 1))); } } die(json_encode(array('status' => false, 'errorcode' => 7))); ?>