summaryrefslogtreecommitdiffstats
path: root/lib/private/api.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-04-18 09:17:58 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-04-18 09:29:52 +0200
commit6ce1abfa5c273c657cde1a52fb0fdd3ca450e2c6 (patch)
tree61d1328d664d080713c4bd8e9d40d6d9d8e29fcc /lib/private/api.php
parent4e58f4892a3598a8377c3479efc79858279c4713 (diff)
downloadnextcloud-server-6ce1abfa5c273c657cde1a52fb0fdd3ca450e2c6.tar.gz
nextcloud-server-6ce1abfa5c273c657cde1a52fb0fdd3ca450e2c6.zip
Deprecate the OC_API constants in favor of the OCP ones
Diffstat (limited to 'lib/private/api.php')
-rw-r--r--lib/private/api.php32
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/private/api.php b/lib/private/api.php
index 119cdb7d1a3..f8fd4fbb5aa 100644
--- a/lib/private/api.php
+++ b/lib/private/api.php
@@ -34,17 +34,33 @@ class OC_API {
/**
* API authentication levels
*/
+
+ /** @deprecated Use \OCP\API::GUEST_AUTH instead */
const GUEST_AUTH = 0;
+
+ /** @deprecated Use \OCP\API::USER_AUTH instead */
const USER_AUTH = 1;
+
+ /** @deprecated Use \OCP\API::SUBADMIN_AUTH instead */
const SUBADMIN_AUTH = 2;
+
+ /** @deprecated Use \OCP\API::ADMIN_AUTH instead */
const ADMIN_AUTH = 3;
/**
* API Response Codes
*/
+
+ /** @deprecated Use \OCP\API::RESPOND_UNAUTHORISED instead */
const RESPOND_UNAUTHORISED = 997;
+
+ /** @deprecated Use \OCP\API::RESPOND_SERVER_ERROR instead */
const RESPOND_SERVER_ERROR = 996;
+
+ /** @deprecated Use \OCP\API::RESPOND_NOT_FOUND instead */
const RESPOND_NOT_FOUND = 998;
+
+ /** @deprecated Use \OCP\API::RESPOND_UNKNOWN_ERROR instead */
const RESPOND_UNKNOWN_ERROR = 999;
/**
@@ -65,7 +81,7 @@ class OC_API {
* @param array $requirements
*/
public static function register($method, $url, $action, $app,
- $authLevel = OC_API::USER_AUTH,
+ $authLevel = \OCP\API::USER_AUTH,
$defaults = array(),
$requirements = array()) {
$name = strtolower($method).$url;
@@ -106,7 +122,7 @@ class OC_API {
if(!self::isAuthorised($action)) {
$responses[] = array(
'app' => $action['app'],
- 'response' => new OC_OCS_Result(null, OC_API::RESPOND_UNAUTHORISED, 'Unauthorised'),
+ 'response' => new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED, 'Unauthorised'),
'shipped' => OC_App::isShipped($action['app']),
);
continue;
@@ -114,7 +130,7 @@ class OC_API {
if(!is_callable($action['action'])) {
$responses[] = array(
'app' => $action['app'],
- 'response' => new OC_OCS_Result(null, OC_API::RESPOND_NOT_FOUND, 'Api method not found'),
+ 'response' => new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, 'Api method not found'),
'shipped' => OC_App::isShipped($action['app']),
);
continue;
@@ -235,15 +251,15 @@ class OC_API {
private static function isAuthorised($action) {
$level = $action['authlevel'];
switch($level) {
- case OC_API::GUEST_AUTH:
+ case \OCP\API::GUEST_AUTH:
// Anyone can access
return true;
break;
- case OC_API::USER_AUTH:
+ case \OCP\API::USER_AUTH:
// User required
return self::loginUser();
break;
- case OC_API::SUBADMIN_AUTH:
+ case \OCP\API::SUBADMIN_AUTH:
// Check for subadmin
$user = self::loginUser();
if(!$user) {
@@ -258,7 +274,7 @@ class OC_API {
}
}
break;
- case OC_API::ADMIN_AUTH:
+ case \OCP\API::ADMIN_AUTH:
// Check for admin
$user = self::loginUser();
if(!$user) {
@@ -325,7 +341,7 @@ class OC_API {
*/
public static function respond($result, $format='xml') {
// Send 401 headers if unauthorised
- if($result->getStatusCode() === self::RESPOND_UNAUTHORISED) {
+ if($result->getStatusCode() === \OCP\API::RESPOND_UNAUTHORISED) {
header('WWW-Authenticate: Basic realm="Authorisation Required"');
header('HTTP/1.0 401 Unauthorized');
}