[Pkg-owncloud-commits] [owncloud] 53/165: Deprecate the OC_API constants in favor of the OCP ones

David Prévot taffit at moszumanska.debian.org
Thu Apr 23 04:06:25 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 6ce1abfa5c273c657cde1a52fb0fdd3ca450e2c6
Author: Joas Schilling <nickvergessen at owncloud.com>
Date:   Sat Apr 18 09:17:58 2015 +0200

    Deprecate the OC_API constants in favor of the OCP ones
---
 lib/private/api.php | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/lib/private/api.php b/lib/private/api.php
index 119cdb7..f8fd4fb 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');
 		}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list