db = $service->db; $this->cuid = $cuid = $service->token->uid; $this->isAdmin = $service->token->isAdmin; // We use the global $admin from AlternC legacy classes $this->admin = $admin; // Set the legacy rights: $this->admin->enabled = $this->isAdmin; } /** return a proper Alternc_Api_Response from an error class and error string * from AlternC legacy class */ protected function alterncLegacyErrorManager() { global $err; return new Alternc_Api_Response(array("code" => self::ERR_ALTERNC_FUNCTION, "message" => "[" . $err->clsid . "] " . $err->error)); } /** ensure that offset & count are set properly from $options. */ protected function offsetAndCount($options, $max) { $offset = -1; $count = -1; if (isset($options["count"])) $count = intval($options["count"]); if (isset($options["offset"])) $offset = intval($options["offset"]); if ($offset != -1 || $count != -1) { if ($offset < 0 || $offset > $max) $offset = 0; if ($count < 0 || $count > 1000) $count = 1000; } return array($offset, $count); } } // Aternc_Api_Legacyobject