loadMe(); $this->layout()->set("me", $me); $this->me = $me; if (!$this->me->isAdmin()) { $this->redirect("dashboard"); } $this->kolmisoftMore = new KolmisoftMore($this->VOICE_PORTAL_HOST, $this->VOICE_PORTAL_API_KEY, $this->VOICE_PORTAL_USERNAME); } protected function indexAction(): void { $JSGlobals = ["BASE_URL" => self::getUrl("VoiceCallActive"), "DASHBOARD_URL" => self::getUrl("Dashboard"), "MFAPPNAME" => MFAPPNAME_SLUG, "PAGE_TITLE" => "Active Voice Calls", "PATH" => [ ["text" => MFAPPNAME_SLUG, "href" => self::getUrl("Dashboard")], ["text" => "Active Voice Calls", "href" => self::getUrl("VoiceCallActive")] ], "VOICE_CALL_ACTIVE_API_URL" => self::getUrl("VoiceCallActive/api"), ]; $this->layout()->set("additionalCSS", ["css/views/VoiceCallActive.css"]); $this->layout()->set("vueViewName", "VoiceCallActive"); $this->layout()->set("JSGlobals", $JSGlobals); $this->layout()->setTemplate("VueViews/Vue"); } protected function apiAction() { $do = $this->request->do; if (!$this->me->isAdmin()) { $this->redirect("dashboard"); } switch ($do) { case "getActiveCalls": $return = $this->getActiveCalls(); break; default: $return = false; break; } if (!$return) { $return = [ "status" => "error", "message" => "Invalid request." ]; } die(json_encode($return)); } private function getActiveCalls(): array { $activeCalls = $this->kolmisoftMore->getActiveCalls(); return [ "rows" => is_null($activeCalls) ? [] : (is_object($activeCalls) ? [$activeCalls] : $activeCalls), ]; } }