aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/app.php22
-rw-r--r--lib/public/groupinterface.php31
-rw-r--r--lib/public/json.php105
-rw-r--r--lib/public/userinterface.php31
-rw-r--r--lib/public/util.php11
5 files changed, 159 insertions, 41 deletions
diff --git a/lib/public/app.php b/lib/public/app.php
index 38c51af9cdb..28411933beb 100644
--- a/lib/public/app.php
+++ b/lib/public/app.php
@@ -34,28 +34,6 @@ namespace OCP;
* This class provides functions to manage apps in ownCloud
*/
class App {
-
- /**
- * @brief Makes owncloud aware of this app
- * @brief This call is deprecated and not necessary to use.
- * @param $data array with all information
- * @returns true/false
- *
- * This function registers the application. $data is an associative array.
- * The following keys are required:
- * - id: id of the application, has to be unique ('addressbook')
- * - name: Human readable name ('Addressbook')
- * - version: array with Version (major, minor, bugfix) ( array(1, 0, 2))
- *
- * The following keys are optional:
- * - order: integer, that influences the position of your application in
- * a list of applications. Lower values come first.
- *
- */
- public static function register( $data ){
- }
-
-
/**
* @brief adds an entry to the navigation
* @param $data array containing the data
diff --git a/lib/public/groupinterface.php b/lib/public/groupinterface.php
new file mode 100644
index 00000000000..97833028118
--- /dev/null
+++ b/lib/public/groupinterface.php
@@ -0,0 +1,31 @@
+<?php
+/**
+* ownCloud
+*
+* @author Arthur Schiwon
+* @copyright 2012 Arthur Schiwon blizzz@owncloud.org
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+/**
+ * Public interface of ownCloud for apps to use.
+ * Group Class.
+ *
+ */
+
+namespace OCP;
+
+interface GroupInterface extends \OC_Group_Interface {} \ No newline at end of file
diff --git a/lib/public/json.php b/lib/public/json.php
index 1bc1e3ab4d5..99df79173eb 100644
--- a/lib/public/json.php
+++ b/lib/public/json.php
@@ -35,70 +35,137 @@ namespace OCP;
*/
class JSON {
-
/**
* @brief Encode and print $data in JSON format
* @param array $data The data to use
* @param string $setContentType the optional content type
+ * @return string json formatted string.
*/
public static function encodedPrint( $data, $setContentType=true ){
return(\OC_JSON::encodedPrint( $data, $setContentType ));
}
-
/**
- * @brief Check if the user is logged in, send json error msg if not
+ * Check if the user is logged in, send json error msg if not.
+ *
+ * This method checks if a user is logged in. If not, a json error
+ * response will be return and the method will exit from execution
+ * of the script.
+ * The returned json will be in the format:
+ *
+ * {"status":"error","data":{"message":"Authentication error."}}
+ *
+ * Add this call to the start of all ajax method files that requires
+ * an authenticated user.
+ *
+ * @return string json formatted error string if not authenticated.
*/
public static function checkLoggedIn(){
return(\OC_JSON::checkLoggedIn());
}
/**
- * @brief Check an ajax get/post call if the request token is valid.
- * @return json Error msg if not valid.
- */
+ * Check an ajax get/post call if the request token is valid.
+ *
+ * This method checks for a valid variable 'requesttoken' in $_GET,
+ * $_POST and $_SERVER. If a valid token is not found, a json error
+ * response will be return and the method will exit from execution
+ * of the script.
+ * The returned json will be in the format:
+ *
+ * {"status":"error","data":{"message":"Token expired. Please reload page."}}
+ *
+ * Add this call to the start of all ajax method files that creates,
+ * updates or deletes anything.
+ * In cases where you e.g. use an ajax call to load a dialog containing
+ * a submittable form, you will need to add the requesttoken first as a
+ * parameter to the ajax call, then assign it to the template and finally
+ * add a hidden input field also named 'requesttoken' containing the value.
+ *
+ * @return string json formatted error string if not valid.
+ */
public static function callCheck(){
return(\OC_JSON::callCheck());
}
/**
- * @brief Send json success msg
+ * Send json success msg
+ *
+ * Return a json success message with optional extra data.
+ * @see OCP\JSON::error() for the format to use.
+ *
* @param array $data The data to use
+ * @return string json formatted string.
*/
public static function success( $data = array() ){
return(\OC_JSON::success( $data ));
}
-
/**
- * @brief Send json error msg
+ * Send json error msg
+ *
+ * Return a json error message with optional extra data for
+ * error message or app specific data.
+ *
+ * Example use:
+ *
+ * $id = [some value]
+ * OCP\JSON::error(array('data':array('message':'An error happened', 'id': $id)));
+ *
+ * Will return the json formatted string:
+ *
+ * {"status":"error","data":{"message":"An error happened", "id":[some value]}}
+ *
* @param array $data The data to use
+ * @return string json formatted error string.
*/
public static function error( $data = array() ){
return(\OC_JSON::error( $data ));
}
-
/**
- * @brief set Content-Type header to jsonrequest
- * @param array $type The contwnt type header
- */
+ * @brief set Content-Type header to jsonrequest
+ * @param array $type The contwnt type header
+ * @return string json formatted string.
+ */
public static function setContentTypeHeader( $type='application/json' ){
return(\OC_JSON::setContentTypeHeader( $type ));
}
-
/**
- * @brief Check if the App is enabled and send JSON error message instead
- * @param string $app The app to check
- */
+ * Check if the App is enabled and send JSON error message instead
+ *
+ * This method checks if a specific app is enabled. If not, a json error
+ * response will be return and the method will exit from execution
+ * of the script.
+ * The returned json will be in the format:
+ *
+ * {"status":"error","data":{"message":"Application is not enabled."}}
+ *
+ * Add this call to the start of all ajax method files that requires
+ * a specific app to be enabled.
+ *
+ * @param string $app The app to check
+ * @return string json formatted string if not enabled.
+ */
public static function checkAppEnabled( $app ){
return(\OC_JSON::checkAppEnabled( $app ));
}
-
/**
- * @brief Check if the user is a admin, send json error msg if not
+ * Check if the user is a admin, send json error msg if not
+ *
+ * This method checks if the current user has admin rights. If not, a json error
+ * response will be return and the method will exit from execution
+ * of the script.
+ * The returned json will be in the format:
+ *
+ * {"status":"error","data":{"message":"Authentication error."}}
+ *
+ * Add this call to the start of all ajax method files that requires
+ * administrative rights.
+ *
+ * @return string json formatted string if not admin user.
*/
public static function checkAdminUser(){
return(\OC_JSON::checkAdminUser());
diff --git a/lib/public/userinterface.php b/lib/public/userinterface.php
new file mode 100644
index 00000000000..b73a8f8d8b0
--- /dev/null
+++ b/lib/public/userinterface.php
@@ -0,0 +1,31 @@
+<?php
+/**
+* ownCloud
+*
+* @author Arthur Schiwon
+* @copyright 2012 Arthur Schiwon blizzz@owncloud.org
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+/**
+ * Public interface of ownCloud for apps to use.
+ * User Class.
+ *
+ */
+
+namespace OCP;
+
+interface UserInterface extends \OC_User_Interface {} \ No newline at end of file
diff --git a/lib/public/util.php b/lib/public/util.php
index 43f9e3cee5d..75ca29f7129 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -320,4 +320,15 @@ class Util {
public static function mb_str_replace($search, $replace, $subject, $encoding = 'UTF-8', &$count = null) {
return(\OC_Helper::mb_str_replace($search, $replace, $subject, $encoding, $count));
}
+
+ /**
+ * @brief performs a search in a nested array
+ * @param haystack the array to be searched
+ * @param needle the search string
+ * @param $index optional, only search this key name
+ * @return the key of the matching field, otherwise false
+ */
+ public static function recursiveArraySearch($haystack, $needle, $index = null) {
+ return(\OC_Helper::recursiveArraySearch($haystack, $needle, $index));
+ }
}