commit cda60551b88b1912f07964b548661f7c68ad3e4c
parent 8b2905a13e58cbc43b8949ae605cee4f90044f58
Author: Felicitus <felicitus@felicitus.org>
Date: Sun, 18 Sep 2011 18:22:15 +0200
Added a few helper methods, added "ping" service+call
Diffstat:
4 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/frontend/service.php b/frontend/service.php
@@ -44,6 +44,6 @@ if (array_key_exists("type", $_REQUEST) && strtolower($_REQUEST["type"]) == "jso
echo $_REQUEST["callback"]."(".json_encode($response).")";
}
} else {
- header('Content-Type: application/x-json');
+ header('Content-Type: application/json');
echo json_encode($response);
}
\ No newline at end of file
diff --git a/src/de/RaumZeitLabor/PartKeepr/Service/Service.php b/src/de/RaumZeitLabor/PartKeepr/Service/Service.php
@@ -58,6 +58,35 @@ class Service {
return SessionManager::getCurrentSession()->getUser();
}
+ /**
+ * Checks if the environment has an active, logged in user.
+ *
+ * @param none
+ * @return boolean True if a logged in user exists, false otherwise
+ */
+ public function hasUser () {
+ if (!$this->hasSession()) {
+ return false;
+ }
+
+ var_dump($this->getUser());
+ if ($this->getUser() !== null) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Checks if there is an active session.
+ *
+ * @param none
+ * @return boolean true if an active session exists, false otherwise
+ */
+ public function hasSession () {
+ return SessionManager::hasSession();
+ }
+
public function hasParameter ($name) {
if (array_key_exists($name, $this->params)) {
return true;
diff --git a/src/de/RaumZeitLabor/PartKeepr/Session/SessionManager.php b/src/de/RaumZeitLabor/PartKeepr/Session/SessionManager.php
@@ -14,6 +14,14 @@ class SessionManager extends Singleton {
return self::$currentSession;
}
+ public static function hasSession () {
+ if (self::$currentSession !== null) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
public function startSession (User $user = null) {
if (is_object($user)) {
try {
diff --git a/src/de/RaumZeitLabor/PartKeepr/System/SystemService.php b/src/de/RaumZeitLabor/PartKeepr/System/SystemService.php
@@ -1,5 +1,9 @@
<?php
namespace de\RaumZeitLabor\PartKeepr\System;
+use de\RaumZeitLabor\PartKeepr\Session\SessionManager;
+
+use de\RaumZeitLabor\PartKeepr\Service\AnonService;
+
use de\RaumZeitLabor\PartKeepr\Service\RestfulService;
declare(encoding = 'UTF-8');
@@ -47,5 +51,4 @@ class SystemService extends Service {
// TODO: add information about post max, file upload size, timeout, memory limit
return array("data" => $aData);
}
-
}
\ No newline at end of file