static function process(Mobile_API_Request $request) { $operation = $request->getOperation(); $sessionid = $request->getSession(); $response = false; if (isset(self::$opControllers[$operation])) { $operationFile = self::$opControllers[$operation]['file']; $operationClass = self::$opControllers[$operation]['class']; include_once dirname(__FILE__) . $operationFile; $operationController = new $operationClass(); $operationSession = false; if ($operationController->requireLogin()) { $operationSession = Mobile_API_Session::init($sessionid); if ($operationController->hasActiveUser() === false) { $operationSession = false; } //Mobile_WS_Utils::initAppGlobals(); } else { // By-pass login $operationSession = true; } if ($operationSession === false) { $response = new Mobile_API_Response(); $response->setError(1501, 'Login required'); } else { try { $response = $operationController->process($request); } catch (Exception $e) { $response = new Mobile_API_Response(); $response->setError($e->getCode(), $e->getMessage()); } } } else { $response = new Mobile_API_Response(); $response->setError(1404, 'Operation not found: ' . $operation); } if ($response !== false) { echo $response->emitJSON(); } }