summaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-09-12 01:06:57 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-09-12 01:06:57 -0400
commit60feaf9abfbc60d950de9c2b820ad46b3b973eb3 (patch)
treef9931192ec8f3cf20840f87462592bf5a03b4af1 /lib/public
parentb194ac3ddeeab6ce923a313725b3ce85fe849baa (diff)
parent54d4e556fe3302d1e580cb6d4abbfcd5699263a5 (diff)
downloadnextcloud-server-60feaf9abfbc60d950de9c2b820ad46b3b973eb3.tar.gz
nextcloud-server-60feaf9abfbc60d950de9c2b820ad46b3b973eb3.zip
Merge branch 'master' into share_expiration
Conflicts: core/js/share.js lib/util.php
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/app.php173
-rw-r--r--lib/public/backgroundjob.php18
-rw-r--r--lib/public/config.php109
-rw-r--r--lib/public/db.php21
-rw-r--r--lib/public/files.php35
-rw-r--r--lib/public/json.php74
-rw-r--r--lib/public/response.php12
-rw-r--r--lib/public/share.php278
-rw-r--r--lib/public/template.php16
-rw-r--r--lib/public/user.php52
-rw-r--r--lib/public/util.php71
11 files changed, 437 insertions, 422 deletions
diff --git a/lib/public/app.php b/lib/public/app.php
index e74f1550740..809a656f17f 100644
--- a/lib/public/app.php
+++ b/lib/public/app.php
@@ -26,7 +26,7 @@
*
*/
-// use OCP namespace for all classes that are considered public.
+// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP;
@@ -34,120 +34,109 @@ 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
- *
- * @deprecated this method is deprecated
- * Do not call it anymore
- * It'll remain in our public API for compatibility reasons
- *
- */
- public static function register( $data ){
+ /**
+ * @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
+ *
+ * @deprecated this method is deprecated
+ * Do not call it anymore
+ * It'll remain in our public API for compatibility reasons
+ *
+ */
+ public static function register( $data ) {
return true; // don't do anything
- }
+ }
- /**
- * @brief adds an entry to the navigation
- * @param $data array containing the data
- * @returns true/false
- *
- * This function adds a new entry to the navigation visible to users. $data
- * is an associative array.
- * The following keys are required:
- * - id: unique id for this entry ('addressbook_index')
- * - href: link to the page
- * - name: Human readable name ('Addressbook')
- *
- * The following keys are optional:
- * - icon: path to the icon of the app
- * - order: integer, that influences the position of your application in
- * the navigation. Lower values come first.
- */
- public static function addNavigationEntry( $data ){
+ /**
+ * @brief adds an entry to the navigation
+ * @param $data array containing the data
+ * @returns true/false
+ *
+ * This function adds a new entry to the navigation visible to users. $data
+ * is an associative array.
+ * The following keys are required:
+ * - id: unique id for this entry ('addressbook_index')
+ * - href: link to the page
+ * - name: Human readable name ('Addressbook')
+ *
+ * The following keys are optional:
+ * - icon: path to the icon of the app
+ * - order: integer, that influences the position of your application in
+ * the navigation. Lower values come first.
+ */
+ public static function addNavigationEntry( $data ) {
return \OC_App::addNavigationEntry( $data );
}
-
- /**
- * @brief marks a navigation entry as active
- * @param $id id of the entry
- * @returns true/false
- *
- * This function sets a navigation entry as active and removes the 'active'
- * property from all other entries. The templates can use this for
- * highlighting the current position of the user.
- */
- public static function setActiveNavigationEntry( $id ){
+ /**
+ * @brief marks a navigation entry as active
+ * @param $id id of the entry
+ * @returns true/false
+ *
+ * This function sets a navigation entry as active and removes the 'active'
+ * property from all other entries. The templates can use this for
+ * highlighting the current position of the user.
+ */
+ public static function setActiveNavigationEntry( $id ) {
return \OC_App::setActiveNavigationEntry( $id );
}
-
- /**
- * @brief Register a Configuration Screen that should appear in the personal settings section.
- * @param $app string appid
- * @param $page string page to be included
- */
- public static function registerPersonal( $app, $page ){
+ /**
+ * @brief Register a Configuration Screen that should appear in the personal settings section.
+ * @param $app string appid
+ * @param $page string page to be included
+ */
+ public static function registerPersonal( $app, $page ) {
return \OC_App::registerPersonal( $app, $page );
}
-
/**
- * @brief Register a Configuration Screen that should appear in the Admin section.
- * @param $app string appid
- * @param $page string page to be included
+ * @brief Register a Configuration Screen that should appear in the Admin section.
+ * @param $app string appid
+ * @param $page string page to be included
*/
- public static function registerAdmin( $app, $page ){
+ public static function registerAdmin( $app, $page ) {
return \OC_App::registerAdmin( $app, $page );
}
-
- /**
- * @brief Read app metadata from the info.xml file
- * @param string $app id of the app or the path of the info.xml file
- * @param boolean path (optional)
- * @returns array
- */
- public static function getAppInfo( $app, $path=false ){
+ /**
+ * @brief Read app metadata from the info.xml file
+ * @param string $app id of the app or the path of the info.xml file
+ * @param boolean path (optional)
+ * @returns array
+ */
+ public static function getAppInfo( $app, $path=false ) {
return \OC_App::getAppInfo( $app, $path);
}
-
-
- /**
- * @brief checks whether or not an app is enabled
- * @param $app app
- * @returns true/false
- *
- * This function checks whether or not an app is enabled.
- */
- public static function isEnabled( $app ){
+ /**
+ * @brief checks whether or not an app is enabled
+ * @param $app app
+ * @returns true/false
+ *
+ * This function checks whether or not an app is enabled.
+ */
+ public static function isEnabled( $app ) {
return \OC_App::isEnabled( $app );
}
+ /**
+ * @brief Check if the app is enabled, redirects to home if not
+ * @param $app app
+ * @returns true/false
+ */
+ public static function checkAppEnabled( $app ) {
+ return \OC_Util::checkAppEnabled( $app );
+ }
- /**
- * @brief Check if the app is enabled, redirects to home if not
- * @param $app app
- * @returns true/false
- */
- public static function checkAppEnabled( $app ){
- return \OC_Util::checkAppEnabled( $app );
- }
-
-
- /**
- * @brief Get the last version of the app, either from appinfo/version or from appinfo/info.xml
- * @param $app app
- * @returns true/false
- */
- public static function getAppVersion( $app ){
+ /**
+ * @brief Get the last version of the app, either from appinfo/version or from appinfo/info.xml
+ * @param $app app
+ * @returns true/false
+ */
+ public static function getAppVersion( $app ) {
return \OC_App::getAppVersion( $app );
}
-
-
-
}
diff --git a/lib/public/backgroundjob.php b/lib/public/backgroundjob.php
index 834bebb5c3c..aba7d2b7620 100644
--- a/lib/public/backgroundjob.php
+++ b/lib/public/backgroundjob.php
@@ -24,7 +24,7 @@
* Public interface of ownCloud forbackground jobs.
*/
-// use OCP namespace for all classes that are considered public.
+// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP;
@@ -42,7 +42,7 @@ namespace OCP;
* An example of the queued task would be the creation of the thumbnail. As
* soon as the user uploads a picture the gallery app registers the queued
* task "create thumbnail" and saves the path in the parameter instead of doing
- * the work right away. This makes the app more responsive. As soon as the task
+ * the work right away. This makes the app more responsive. As soon as the task
* is done it will be deleted from the list.
*/
class BackgroundJob {
@@ -52,7 +52,7 @@ class BackgroundJob {
* @param $method method name
* @return true
*/
- public static function addRegularTask( $klass, $method ){
+ public static function addRegularTask( $klass, $method ) {
return \OC_BackgroundJob_RegularTask::register( $klass, $method );
}
@@ -62,7 +62,7 @@ class BackgroundJob {
*
* key is string "$klass-$method", value is array( $klass, $method )
*/
- static public function allRegularTasks(){
+ static public function allRegularTasks() {
return \OC_BackgroundJob_RegularTask::all();
}
@@ -71,7 +71,7 @@ class BackgroundJob {
* @param $id ID of the task
* @return associative array
*/
- public static function findQueuedTask( $id ){
+ public static function findQueuedTask( $id ) {
return \OC_BackgroundJob_QueuedTask::find( $id );
}
@@ -79,7 +79,7 @@ class BackgroundJob {
* @brief Gets all queued tasks
* @return array with associative arrays
*/
- public static function allQueuedTasks(){
+ public static function allQueuedTasks() {
return \OC_BackgroundJob_QueuedTask::all();
}
@@ -88,7 +88,7 @@ class BackgroundJob {
* @param $app app name
* @return array with associative arrays
*/
- public static function queuedTaskWhereAppIs( $app ){
+ public static function queuedTaskWhereAppIs( $app ) {
return \OC_BackgroundJob_QueuedTask::whereAppIs( $app );
}
@@ -100,7 +100,7 @@ class BackgroundJob {
* @param $parameters all useful data as text
* @return id of task
*/
- public static function addQueuedTask( $app, $klass, $method, $parameters ){
+ public static function addQueuedTask( $app, $klass, $method, $parameters ) {
return \OC_BackgroundJob_QueuedTask::add( $app, $klass, $method, $parameters );
}
@@ -111,7 +111,7 @@ class BackgroundJob {
*
* Deletes a report
*/
- public static function deleteQueuedTask( $id ){
+ public static function deleteQueuedTask( $id ) {
return \OC_BackgroundJob_QueuedTask::delete( $id );
}
}
diff --git a/lib/public/config.php b/lib/public/config.php
index ab01902ffe6..377150115ff 100644
--- a/lib/public/config.php
+++ b/lib/public/config.php
@@ -27,7 +27,7 @@
*/
/**
- * @brief use OCP namespace for all classes that are considered public.
+ * @brief use OCP namespace for all classes that are considered public.
*
* Classes that use this namespace are for use by apps, and not for use by internal
* OC classes
@@ -38,8 +38,6 @@ namespace OCP;
* This class provides functions to read and write configuration data. configuration can be on a system, application or user level
*/
class Config {
-
-
/**
* @brief Gets a value from config.php
* @param $key key
@@ -49,11 +47,10 @@ class Config {
* This function gets the value from config.php. If it does not exist,
* $default will be returned.
*/
- public static function getSystemValue( $key, $default = null ){
+ public static function getSystemValue( $key, $default = null ) {
return(\OC_Config::getValue( $key, $default ));
}
-
/**
* @brief Sets a value
* @param $key key
@@ -63,74 +60,64 @@ class Config {
* This function sets the value and writes the config.php. If the file can
* not be written, false will be returned.
*/
- public static function setSystemValue( $key, $value ){
+ public static function setSystemValue( $key, $value ) {
return(\OC_Config::setValue( $key, $value ));
}
-
- /**
- * @brief Gets the config value
- * @param $app app
- * @param $key key
- * @param $default = null, default value if the key does not exist
- * @returns the value or $default
- *
- * This function gets a value from the appconfig table. If the key does
- * not exist the default value will be returnes
- */
- public static function getAppValue( $app, $key, $default = null ){
+ /**
+ * @brief Gets the config value
+ * @param $app app
+ * @param $key key
+ * @param $default = null, default value if the key does not exist
+ * @returns the value or $default
+ *
+ * This function gets a value from the appconfig table. If the key does
+ * not exist the default value will be returnes
+ */
+ public static function getAppValue( $app, $key, $default = null ) {
return(\OC_Appconfig::getValue( $app, $key, $default ));
}
-
- /**
- * @brief sets a value in the appconfig
- * @param $app app
- * @param $key key
- * @param $value value
- * @returns true/false
- *
- * Sets a value. If the key did not exist before it will be created.
- */
- public static function setAppValue( $app, $key, $value ){
+ /**
+ * @brief sets a value in the appconfig
+ * @param $app app
+ * @param $key key
+ * @param $value value
+ * @returns true/false
+ *
+ * Sets a value. If the key did not exist before it will be created.
+ */
+ public static function setAppValue( $app, $key, $value ) {
return(\OC_Appconfig::setValue( $app, $key, $value ));
}
-
- /**
- * @brief Gets the preference
- * @param $user user
- * @param $app app
- * @param $key key
- * @param $default = null, default value if the key does not exist
- * @returns the value or $default
- *
- * This function gets a value from the prefernces table. If the key does
- * not exist the default value will be returnes
- */
- public static function getUserValue( $user, $app, $key, $default = null ){
+ /**
+ * @brief Gets the preference
+ * @param $user user
+ * @param $app app
+ * @param $key key
+ * @param $default = null, default value if the key does not exist
+ * @returns the value or $default
+ *
+ * This function gets a value from the prefernces table. If the key does
+ * not exist the default value will be returnes
+ */
+ public static function getUserValue( $user, $app, $key, $default = null ) {
return(\OC_Preferences::getValue( $user, $app, $key, $default ));
}
-
- /**
- * @brief sets a value in the preferences
- * @param $user user
- * @param $app app
- * @param $key key
- * @param $value value
- * @returns true/false
- *
- * Adds a value to the preferences. If the key did not exist before, it
- * will be added automagically.
- */
- public static function setUserValue( $user, $app, $key, $value ){
+ /**
+ * @brief sets a value in the preferences
+ * @param $user user
+ * @param $app app
+ * @param $key key
+ * @param $value value
+ * @returns true/false
+ *
+ * Adds a value to the preferences. If the key did not exist before, it
+ * will be added automagically.
+ */
+ public static function setUserValue( $user, $app, $key, $value ) {
return(\OC_Preferences::setValue( $user, $app, $key, $value ));
}
-
-
-
-
-
-
}
diff --git a/lib/public/db.php b/lib/public/db.php
index 23c670cf442..6ce62b27ca2 100644
--- a/lib/public/db.php
+++ b/lib/public/db.php
@@ -26,7 +26,7 @@
*
*/
-// use OCP namespace for all classes that are considered public.
+// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP;
@@ -34,8 +34,6 @@ namespace OCP;
* This class provides access to the internal database system. Use this class exlusively if you want to access databases
*/
class DB {
-
-
/**
* @brief Prepare a SQL query
* @param $query Query string
@@ -43,11 +41,10 @@ class DB {
*
* SQL query via MDB2 prepare(), needs to be execute()'d!
*/
- static public function prepare( $query, $limit=null, $offset=null ){
+ static public function prepare( $query, $limit=null, $offset=null ) {
return(\OC_DB::prepare($query,$limit,$offset));
}
-
/**
* @brief gets last value of autoincrement
* @param $table string The optional table name (will replace *PREFIX*) and add sequence suffix
@@ -58,36 +55,30 @@ class DB {
* Call this method right after the insert command or other functions may
* cause trouble!
*/
- public static function insertid($table=null){
+ public static function insertid($table=null) {
return(\OC_DB::insertid($table));
}
-
/**
* @brief Start a transaction
*/
- public static function beginTransaction(){
+ public static function beginTransaction() {
return(\OC_DB::beginTransaction());
}
-
/**
* @brief Commit the database changes done during a transaction that is in progress
*/
- public static function commit(){
+ public static function commit() {
return(\OC_DB::commit());
}
-
/**
* @brief check if a result is an error, works with MDB2 and PDOException
* @param mixed $result
* @return bool
*/
- public static function isError($result){
+ public static function isError($result) {
return(\OC_DB::isError($result));
}
-
-
-
}
diff --git a/lib/public/files.php b/lib/public/files.php
index 32b3f036744..90889c59ad8 100644
--- a/lib/public/files.php
+++ b/lib/public/files.php
@@ -26,7 +26,7 @@
*
*/
-// use OCP namespace for all classes that are considered public.
+// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP;
@@ -34,8 +34,6 @@ namespace OCP;
* This class provides access to the internal filesystem abstraction layer. Use this class exlusively if you want to access files
*/
class Files {
-
-
/**
* @brief Recusive deletion of folders
* @param string $dir path to the folder
@@ -45,29 +43,26 @@ class Files {
\OC_Helper::rmdirr( $dir );
}
-
/**
* get the mimetype form a local file
* @param string path
* @return string
* does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead
*/
- static function getMimeType( $path ){
+ static function getMimeType( $path ) {
return(\OC_Helper::getMimeType( $path ));
}
-
/**
* copy the contents of one stream to another
* @param resource source
* @param resource target
* @return int the number of bytes copied
*/
- public static function streamCopy( $source, $target ){
+ public static function streamCopy( $source, $target ) {
return(\OC_Helper::streamCopy( $source, $target ));
}
-
/**
* create a temporary file with an unique filename
* @param string postfix
@@ -75,22 +70,20 @@ class Files {
*
* temporary files are automatically cleaned up after the script is finished
*/
- public static function tmpFile( $postfix='' ){
+ public static function tmpFile( $postfix='' ) {
return(\OC_Helper::tmpFile( $postfix ));
}
-
/**
* create a temporary folder with an unique filename
* @return string
*
* temporary files are automatically cleaned up after the script is finished
*/
- public static function tmpFolder(){
+ public static function tmpFolder() {
return(\OC_Helper::tmpFolder());
}
-
/**
* Adds a suffix to the name in case the file exists
*
@@ -98,20 +91,16 @@ class Files {
* @param $filename
* @return string
*/
- public static function buildNotExistingFileName( $path, $filename ){
+ public static function buildNotExistingFileName( $path, $filename ) {
return(\OC_Helper::buildNotExistingFileName( $path, $filename ));
}
- /**
- * @param string appid
- * @param $app app
- * @return OC_FilesystemView
- */
- public static function getStorage( $app ){
+ /**
+ * @param string appid
+ * @param $app app
+ * @return OC_FilesystemView
+ */
+ public static function getStorage( $app ) {
return \OC_App::getStorage( $app );
}
-
-
-
-
}
diff --git a/lib/public/json.php b/lib/public/json.php
index 99df79173eb..2186dd8ee49 100644
--- a/lib/public/json.php
+++ b/lib/public/json.php
@@ -26,7 +26,7 @@
*
*/
-// use OCP namespace for all classes that are considered public.
+// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP;
@@ -34,92 +34,91 @@ namespace OCP;
* This class provides convinient functions to generate and send JSON data. Usefull for Ajax calls
*/
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 ){
+ public static function encodedPrint( $data, $setContentType=true ) {
return(\OC_JSON::encodedPrint( $data, $setContentType ));
}
/**
* 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(){
+ public static function checkLoggedIn() {
return(\OC_JSON::checkLoggedIn());
}
/**
* 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,
+ *
+ * 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(){
+ public static function callCheck() {
return(\OC_JSON::callCheck());
}
/**
* Send json success msg
- *
+ *
* Return a json success message with optional extra data.
- * @see OCP\JSON::error() for the format to use.
- *
+ * @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() ){
+ public static function success( $data = array() ) {
return(\OC_JSON::success( $data ));
}
/**
* Send json error msg
- *
- * Return a json error message with optional extra data for
+ *
+ * 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() ){
+ public static function error( $data = array() ) {
return(\OC_JSON::error( $data ));
}
@@ -128,47 +127,46 @@ class JSON {
* @param array $type The contwnt type header
* @return string json formatted string.
*/
- public static function setContentTypeHeader( $type='application/json' ){
+ public static function setContentTypeHeader( $type='application/json' ) {
return(\OC_JSON::setContentTypeHeader( $type ));
}
/**
* 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 ){
+ public static function checkAppEnabled( $app ) {
return(\OC_JSON::checkAppEnabled( $app ));
}
/**
* 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(){
+ public static function checkAdminUser() {
return(\OC_JSON::checkAdminUser());
}
-
}
diff --git a/lib/public/response.php b/lib/public/response.php
index 8dff3bcd354..95e67a85720 100644
--- a/lib/public/response.php
+++ b/lib/public/response.php
@@ -26,7 +26,7 @@
*
*/
-// use OCP namespace for all classes that are considered public.
+// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP;
@@ -34,8 +34,6 @@ namespace OCP;
* This class provides convinient functions to send the correct http response headers
*/
class Response {
-
-
/**
* @brief Enable response caching by sending correct HTTP headers
* @param $cache_time time to cache the response
@@ -47,7 +45,6 @@ class Response {
return(\OC_Response::enableCaching( $cache_time ));
}
-
/**
* Checks and set Last-Modified header, when the request matches sends a
* 'not modified' response
@@ -57,7 +54,6 @@ class Response {
return(\OC_Response::setLastModifiedHeader( $lastModified ));
}
-
/**
* @brief disable browser caching
* @see enableCaching with cache_time = 0
@@ -66,7 +62,6 @@ class Response {
return(\OC_Response::disableCaching());
}
-
/**
* Checks and set ETag header, when the request matches sends a
* 'not modified' response
@@ -76,7 +71,6 @@ class Response {
return(\OC_Response::setETagHeader( $etag ));
}
-
/**
* @brief Send file as response, checking and setting caching headers
* @param $filepath of file to send
@@ -102,6 +96,4 @@ class Response {
static public function redirect( $location ) {
return(\OC_Response::redirect( $location ));
}
-
-
-}
+} \ No newline at end of file
diff --git a/lib/public/share.php b/lib/public/share.php
index a9fd23bfac8..b215d7f9389 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -23,6 +23,7 @@ namespace OCP;
\OC_Hook::connect('OC_User', 'post_deleteUser', 'OCP\Share', 'post_deleteUser');
\OC_Hook::connect('OC_User', 'post_addToGroup', 'OCP\Share', 'post_addToGroup');
\OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OCP\Share', 'post_removeFromGroup');
+\OC_Hook::connect('OC_User', 'post_deleteGroup', 'OCP\Share', 'post_deleteGroup');
/**
* This class provides the ability for apps to share their content between users.
@@ -229,6 +230,16 @@ class Share {
$shareWith['users'] = array_diff(\OC_Group::usersInGroup($group), array($uidOwner));
} else if ($shareType === self::SHARE_TYPE_LINK) {
if (\OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes') == 'yes') {
+ if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_LINK, null, $uidOwner, self::FORMAT_NONE, null, 1)) {
+ // If password is set delete the old link
+ if (isset($shareWith)) {
+ self::delete($checkExists['id']);
+ } else {
+ $message = 'Sharing '.$itemSource.' failed, because this item is already shared with a link';
+ \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
+ throw new \Exception($message);
+ }
+ }
// Generate hash of password - same method as user passwords
if (isset($shareWith)) {
$forcePortable = (CRYPT_BLOWFISH != 1);
@@ -241,26 +252,26 @@ class Share {
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
throw new \Exception($message);
return false;
- } else if ($shareType === self::SHARE_TYPE_CONTACT) {
- if (!\OC_App::isEnabled('contacts')) {
- $message = 'Sharing '.$itemSource.' failed, because the contacts app is not enabled';
- \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
- return false;
- }
- $vcard = \OC_Contacts_App::getContactVCard($shareWith);
- if (!isset($vcard)) {
- $message = 'Sharing '.$itemSource.' failed, because the contact does not exist';
- \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
- throw new \Exception($message);
- }
- $details = \OC_Contacts_VCard::structureContact($vcard);
- // TODO Add ownCloud user to contacts vcard
- if (!isset($details['EMAIL'])) {
- $message = 'Sharing '.$itemSource.' failed, because no email address is associated with the contact';
- \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
- throw new \Exception($message);
- }
- return self::shareItem($itemType, $itemSource, self::SHARE_TYPE_EMAIL, $details['EMAIL'], $permissions);
+// } else if ($shareType === self::SHARE_TYPE_CONTACT) {
+// if (!\OC_App::isEnabled('contacts')) {
+// $message = 'Sharing '.$itemSource.' failed, because the contacts app is not enabled';
+// \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
+// return false;
+// }
+// $vcard = \OC_Contacts_App::getContactVCard($shareWith);
+// if (!isset($vcard)) {
+// $message = 'Sharing '.$itemSource.' failed, because the contact does not exist';
+// \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
+// throw new \Exception($message);
+// }
+// $details = \OC_Contacts_VCard::structureContact($vcard);
+// // TODO Add ownCloud user to contacts vcard
+// if (!isset($details['EMAIL'])) {
+// $message = 'Sharing '.$itemSource.' failed, because no email address is associated with the contact';
+// \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
+// throw new \Exception($message);
+// }
+// return self::shareItem($itemType, $itemSource, self::SHARE_TYPE_EMAIL, $details['EMAIL'], $permissions);
} else {
// Future share types need to include their own conditions
$message = 'Share type '.$shareType.' is not valid for '.$itemSource;
@@ -326,10 +337,21 @@ class Share {
public static function unshareFromSelf($itemType, $itemTarget) {
if ($item = self::getItemSharedWith($itemType, $itemTarget)) {
if ((int)$item['share_type'] === self::SHARE_TYPE_GROUP) {
- // TODO
+ // Insert an extra row for the group share and set permission to 0 to prevent it from showing up for the user
+ $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`, `item_target`, `parent`, `share_type`, `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`, `file_target`) VALUES (?,?,?,?,?,?,?,?,?,?,?)');
+ $query->execute(array($item['item_type'], $item['item_source'], $item['item_target'], $item['id'], self::$shareTypeGroupUserUnique, \OC_User::getUser(), $item['uid_owner'], 0, $item['stime'], $item['file_source'], $item['file_target']));
+ \OC_DB::insertid('*PREFIX*share');
+ // Delete all reshares by this user of the group share
+ self::delete($item['id'], true, \OC_User::getUser());
+ } else if ((int)$item['share_type'] === self::$shareTypeGroupUserUnique) {
+ // Set permission to 0 to prevent it from showing up for the user
+ $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `permissions` = ? WHERE `id` = ?');
+ $query->execute(array(0, $item['id']));
+ self::delete($item['id'], true);
+ } else {
+ self::delete($item['id']);
}
- // Delete
- return self::delete($item['id'], true);
+ return true;
}
return false;
}
@@ -347,7 +369,7 @@ class Share {
if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith, \OC_User::getUser(), self::FORMAT_NONE, null, 1, false)) {
// Check if this item is a reshare and verify that the permissions granted don't exceed the parent shared item
if (isset($item['parent'])) {
- $query = \OC_DB::prepare('SELECT `permissions` FROM `*PREFIX*share` WHERE `id` = ?',1);
+ $query = \OC_DB::prepare('SELECT `permissions` FROM `*PREFIX*share` WHERE `id` = ?', 1);
$result = $query->execute(array($item['parent']))->fetchRow();
if (~(int)$result['permissions'] & $permissions) {
$message = 'Setting permissions for '.$itemSource.' failed, because the permissions exceed permissions granted to '.\OC_User::getUser();
@@ -446,8 +468,11 @@ class Share {
$collectionTypes[] = $type;
}
}
- if (count($collectionTypes) > 1) {
+ if (!self::getBackend($itemType) instanceof Share_Backend_Collection) {
unset($collectionTypes[0]);
+ }
+ // Return array if collections were found or the item type is a collection itself - collections can be inside collections
+ if (count($collectionTypes) > 0) {
return $collectionTypes;
}
return false;
@@ -492,9 +517,13 @@ class Share {
$root = '';
if ($includeCollections && !isset($item) && ($collectionTypes = self::getCollectionItemTypes($itemType))) {
// If includeCollections is true, find collections of this item type, e.g. a music album contains songs
- $itemTypes = array_merge(array($itemType), $collectionTypes);
+ if (!in_array($itemType, $collectionTypes)) {
+ $itemTypes = array_merge(array($itemType), $collectionTypes);
+ } else {
+ $itemTypes = $collectionTypes;
+ }
$placeholders = join(',', array_fill(0, count($itemTypes), '?'));
- $where = ' WHERE `item_type` IN ('.$placeholders.')';
+ $where .= ' WHERE item_type IN ('.$placeholders.'))';
$queryArgs = $itemTypes;
} else {
$where = ' WHERE `item_type` = ?';
@@ -563,12 +592,13 @@ class Share {
} else {
if ($itemType == 'file' || $itemType == 'folder') {
$where .= ' `file_target` = ?';
+ $item = \OC_Filesystem::normalizePath($item);
} else {
$where .= ' `item_target` = ?';
}
}
$queryArgs[] = $item;
- if ($includeCollections && $collectionTypes = self::getCollectionItemTypes($itemType)) {
+ if ($includeCollections && $collectionTypes) {
$placeholders = join(',', array_fill(0, count($collectionTypes), '?'));
$where .= ' OR item_type IN ('.$placeholders.'))';
$queryArgs = array_merge($queryArgs, $collectionTypes);
@@ -627,6 +657,9 @@ class Share {
$row['share_with'] = $items[$row['parent']]['share_with'];
// Remove the parent group share
unset($items[$row['parent']]);
+ if ($row['permissions'] == 0) {
+ continue;
+ }
} else if (!isset($uidOwner)) {
// Check if the same target already exists
if (isset($targets[$row[$column]])) {
@@ -681,29 +714,54 @@ class Share {
}
}
// Check if this is a collection of the requested item type
- if ($includeCollections && $row['item_type'] != $itemType) {
+ if ($includeCollections && $collectionTypes && in_array($row['item_type'], $collectionTypes)) {
if (($collectionBackend = self::getBackend($row['item_type'])) && $collectionBackend instanceof Share_Backend_Collection) {
- $row['collection'] = array('item_type' => $itemType, $column => $row[$column]);
- // Fetch all of the children sources
- $children = $collectionBackend->getChildren($row[$column]);
- foreach ($children as $child) {
- $childItem = $row;
- $childItem['item_source'] = $child;
- // $childItem['item_target'] = $child['target']; TODO
- if (isset($item)) {
- if ($childItem[$column] == $item) {
- // Return only the item instead of a 2-dimensional array
- if ($limit == 1 && $format == self::FORMAT_NONE) {
- return $childItem;
+ // Collections can be inside collections, check if the item is a collection
+ if (isset($item) && $row['item_type'] == $itemType && $row[$column] == $item) {
+ $collectionItems[] = $row;
+ } else {
+ $collection = array();
+ $collection['item_type'] = $row['item_type'];
+ if ($row['item_type'] == 'file' || $row['item_type'] == 'folder') {
+ $collection['path'] = basename($row['path']);
+ }
+ $row['collection'] = $collection;
+ // Fetch all of the children sources
+ $children = $collectionBackend->getChildren($row[$column]);
+ foreach ($children as $child) {
+ $childItem = $row;
+ $childItem['item_type'] = $itemType;
+ if ($row['item_type'] != 'file' && $row['item_type'] != 'folder') {
+ $childItem['item_source'] = $child['source'];
+ $childItem['item_target'] = $child['target'];
+ }
+ if ($backend instanceof Share_Backend_File_Dependent) {
+ if ($row['item_type'] == 'file' || $row['item_type'] == 'folder') {
+ $childItem['file_source'] = $child['source'];
} else {
- // Unset the items array and break out of both loops
- $items = array();
- $items[] = $childItem;
- break 2;
+ $childItem['file_source'] = \OC_FileCache::getId($child['file_path']);
}
+ $childItem['file_target'] = \OC_Filesystem::normalizePath($child['file_path']);
+ }
+ if (isset($item)) {
+ if ($childItem[$column] == $item) {
+ // Return only the item instead of a 2-dimensional array
+ if ($limit == 1) {
+ if ($format == self::FORMAT_NONE) {
+ return $childItem;
+ } else {
+ // Unset the items array and break out of both loops
+ $items = array();
+ $items[] = $childItem;
+ break 2;
+ }
+ } else {
+ $collectionItems[] = $childItem;
+ }
+ }
+ } else {
+ $collectionItems[] = $childItem;
}
- } else {
- $collectionItems[] = $childItem;
}
}
}
@@ -769,9 +827,9 @@ class Share {
// TODO Don't check if inside folder
$parent = $checkReshare['id'];
$itemSource = $checkReshare['item_source'];
- // TODO Suggest item/file target
- $suggestedItemTarget = $checkReshare['item_target'];
$fileSource = $checkReshare['file_source'];
+ $suggestedItemTarget = $checkReshare['item_target'];
+ $suggestedFileTarget = $checkReshare['file_target'];
$filePath = $checkReshare['file_target'];
}
} else {
@@ -781,6 +839,8 @@ class Share {
}
} else {
$parent = null;
+ $suggestedItemTarget = null;
+ $suggestedFileTarget = null;
if (!$backend->isValidSource($itemSource, $uidOwner)) {
$message = 'Sharing '.$itemSource.' failed, because the sharing backend for '.$itemType.' could not find its source';
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
@@ -789,7 +849,7 @@ class Share {
$parent = null;
if ($backend instanceof Share_Backend_File_Dependent) {
$filePath = $backend->getFilePath($itemSource, $uidOwner);
- if ($itemType == 'file' && $itemType == 'folder') {
+ if ($itemType == 'file' || $itemType == 'folder') {
$fileSource = $itemSource;
} else {
$fileSource = \OC_FileCache::getId($filePath);
@@ -807,35 +867,34 @@ class Share {
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`, `item_target`, `parent`, `share_type`, `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`, `file_target`) VALUES (?,?,?,?,?,?,?,?,?,?,?)');
// Share with a group
if ($shareType == self::SHARE_TYPE_GROUP) {
+ $groupItemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith['group'], $uidOwner, $suggestedItemTarget);
if (isset($fileSource)) {
if ($parentFolder) {
if ($parentFolder === true) {
- $groupFileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith['group'], $uidOwner);
+ $groupFileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith['group'], $uidOwner, $suggestedFileTarget);
// Set group default file target for future use
$parentFolders[0]['folder'] = $groupFileTarget;
} else {
// Get group default file target
$groupFileTarget = $parentFolder[0]['folder'].$itemSource;
$parent = $parentFolder[0]['id'];
- unset($parentFolder[0]);
- // Only loop through users we know have different file target paths
- $uidSharedWith = array_keys($parentFolder);
}
} else {
- $groupFileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith['group'], $uidOwner);
+ $groupFileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith['group'], $uidOwner, $suggestedFileTarget);
}
} else {
$groupFileTarget = null;
}
- $groupItemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith['group'], $uidOwner);
- $uniqueTargets = array();
+ $query->execute(array($itemType, $itemSource, $groupItemTarget, $parent, $shareType, $shareWith['group'], $uidOwner, $permissions, time(), $fileSource, $groupFileTarget));
+ // Save this id, any extra rows for this group share will need to reference it
+ $parent = \OC_DB::insertid('*PREFIX*share');
// Loop through all users of this group in case we need to add an extra row
foreach ($shareWith['users'] as $uid) {
- $itemTarget = self::generateTarget($itemType, $itemSource, self::SHARE_TYPE_USER, $uid, $uidOwner);
+ $itemTarget = self::generateTarget($itemType, $itemSource, self::SHARE_TYPE_USER, $uid, $uidOwner, $suggestedItemTarget, $parent);
if (isset($fileSource)) {
if ($parentFolder) {
if ($parentFolder === true) {
- $fileTarget = self::generateTarget('file', $filePath, self::SHARE_TYPE_USER, $uid, $uidOwner);
+ $fileTarget = self::generateTarget('file', $filePath, self::SHARE_TYPE_USER, $uid, $uidOwner, $suggestedFileTarget, $parent);
if ($fileTarget != $groupFileTarget) {
$parentFolders[$uid]['folder'] = $fileTarget;
}
@@ -844,24 +903,15 @@ class Share {
$parent = $parentFolder[$uid]['id'];
}
} else {
- $fileTarget = self::generateTarget('file', $filePath, self::SHARE_TYPE_USER, $uid, $uidOwner);
+ $fileTarget = self::generateTarget('file', $filePath, self::SHARE_TYPE_USER, $uid, $uidOwner, $suggestedFileTarget, $parent);
}
} else {
$fileTarget = null;
}
// Insert an extra row for the group share if the item or file target is unique for this user
if ($itemTarget != $groupItemTarget || (isset($fileSource) && $fileTarget != $groupFileTarget)) {
- $uniqueTargets[] = array('uid' => $uid, 'item_target' => $itemTarget, 'file_target' => $fileTarget);
- }
- }
- $query->execute(array($itemType, $itemSource, $groupItemTarget, $parent, $shareType, $shareWith['group'], $uidOwner, $permissions, time(), $fileSource, $groupFileTarget));
- // Save this id, any extra rows for this group share will need to reference it
- $parent = \OC_DB::insertid('*PREFIX*share');
- foreach ($uniqueTargets as $unique) {
- $query->execute(array($itemType, $itemSource, $unique['item_target'], $parent, self::$shareTypeGroupUserUnique, $unique['uid'], $uidOwner, $permissions, time(), $fileSource, $unique['file_target']));
- $id = \OC_DB::insertid('*PREFIX*share');
- if ($parentFolder === true) {
- $parentFolders['id'] = $id;
+ $query->execute(array($itemType, $itemSource, $itemTarget, $parent, self::$shareTypeGroupUserUnique, $uid, $uidOwner, $permissions, time(), $fileSource, $fileTarget));
+ \OC_DB::insertid('*PREFIX*share');
}
}
if ($parentFolder === true) {
@@ -869,18 +919,18 @@ class Share {
return $parentFolders;
}
} else {
- $itemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner);
+ $itemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $suggestedItemTarget);
if (isset($fileSource)) {
if ($parentFolder) {
if ($parentFolder === true) {
- $fileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith, $uidOwner);
+ $fileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith, $uidOwner, $suggestedFileTarget);
$parentFolders['folder'] = $fileTarget;
} else {
$fileTarget = $parentFolder['folder'].$itemSource;
$parent = $parentFolder['id'];
}
} else {
- $fileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith, $uidOwner);
+ $fileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith, $uidOwner, $suggestedFileTarget);
}
} else {
$fileTarget = null;
@@ -902,14 +952,16 @@ class Share {
* @param string Item source
* @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
* @param string User or group the item is being shared with
+ * @param string The suggested target originating from a reshare (optional)
+ * @param int The id of the parent group share (optional)
* @return string Item target
- *
- * TODO Use a suggested item target by default
- *
*/
- private static function generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner) {
+ private static function generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $suggestedTarget = null, $groupParent = null) {
$backend = self::getBackend($itemType);
if ($shareType == self::SHARE_TYPE_LINK) {
+ if (isset($suggestedTarget)) {
+ return $suggestedTarget;
+ }
return $backend->generateTarget($itemSource, false);
} else {
if ($itemType == 'file' || $itemType == 'folder') {
@@ -927,19 +979,35 @@ class Share {
$exclude = null;
// Backend has 3 opportunities to generate a unique target
for ($i = 0; $i < 2; $i++) {
- if ($shareType == self::SHARE_TYPE_GROUP) {
- $target = $backend->generateTarget($itemSource, false, $exclude);
+ // Check if suggested target exists first
+ if ($i == 0 && isset($suggestedTarget)) {
+ $target = $suggestedTarget;
} else {
- $target = $backend->generateTarget($itemSource, $shareWith, $exclude);
- }
- if (is_array($exclude) && in_array($target, $exclude)) {
- break;
+ if ($shareType == self::SHARE_TYPE_GROUP) {
+ $target = $backend->generateTarget($itemSource, false, $exclude);
+ } else {
+ $target = $backend->generateTarget($itemSource, $shareWith, $exclude);
+ }
+ if (is_array($exclude) && in_array($target, $exclude)) {
+ break;
+ }
}
// Check if target already exists
- if ($checkTarget = self::getItems($itemType, $target, $shareType, $shareWith, null, self::FORMAT_NONE, null, 1)) {
- // If matching target is from the same owner, use the same target. The share type will be different so this isn't the same share.
- if ($checkTarget['uid_owner'] == $uidOwner) {
- return $target;
+ $checkTarget = self::getItems($itemType, $target, $shareType, $shareWith);
+ if (!empty($checkTarget)) {
+ foreach ($checkTarget as $item) {
+ // Skip item if it is the group parent row
+ if (isset($groupParent) && $item['id'] == $groupParent) {
+ if (count($checkTarget) == 1) {
+ return $target;
+ } else {
+ continue;
+ }
+ }
+ // If matching target is from the same owner, use the same target. The share type will be different so this isn't the same share.
+ if ($item['uid_owner'] == $uidOwner) {
+ return $target;
+ }
}
if (!isset($exclude)) {
$exclude = array();
@@ -1030,7 +1098,27 @@ class Share {
}
public static function post_addToGroup($arguments) {
- // TODO
+ // Find the group shares and check if the user needs a unique target
+ $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `share_type` = ? AND `share_with` = ?');
+ $result = $query->execute(array(self::SHARE_TYPE_GROUP, $arguments['gid']));
+ $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`, `item_target`, `parent`, `share_type`, `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`, `file_target`) VALUES (?,?,?,?,?,?,?,?,?,?,?)');
+ while ($item = $result->fetchRow()) {
+ if ($item['item_type'] == 'file' || $item['item_type'] == 'file') {
+ $itemTarget = null;
+ } else {
+ $itemTarget = self::generateTarget($item['item_type'], $item['item_source'], self::SHARE_TYPE_USER, $arguments['uid'], $item['uid_owner'], $item['item_target'], $item['id']);
+ }
+ if (isset($item['file_source'])) {
+ $fileTarget = self::generateTarget($item['item_type'], $item['item_source'], self::SHARE_TYPE_USER, $arguments['uid'], $item['uid_owner'], $item['file_target'], $item['id']);
+ } else {
+ $fileTarget = null;
+ }
+ // Insert an extra row for the group share if the item or file target is unique for this user
+ if ($itemTarget != $item['item_target'] || $fileTarget != $item['file_target']) {
+ $query->execute(array($item['item_type'], $item['item_source'], $itemTarget, $item['id'], self::$shareTypeGroupUserUnique, $arguments['uid'], $item['uid_owner'], $item['permissions'], $item['stime'], $item['file_source'], $fileTarget));
+ \OC_DB::insertid('*PREFIX*share');
+ }
+ }
}
public static function post_removeFromGroup($arguments) {
@@ -1047,6 +1135,14 @@ class Share {
}
}
+ public static function post_deleteGroup($arguments) {
+ $query = \OC_DB::prepare('SELECT id FROM `*PREFIX*share` WHERE `share_type` = ? AND `share_with` = ?');
+ $result = $query->execute(array(self::SHARE_TYPE_GROUP, $arguments['gid']));
+ while ($item = $result->fetchRow()) {
+ self::delete($item['id']);
+ }
+ }
+
}
/**
@@ -1121,10 +1217,8 @@ interface Share_Backend_Collection extends Share_Backend {
/**
* @brief Get the sources of the children of the item
* @param string Item source
- * @return array Returns an array of sources
+ * @return array Returns an array of children each inside an array with the keys: source, target, and file_path if applicable
*/
public function getChildren($itemSource);
}
-
-?>
diff --git a/lib/public/template.php b/lib/public/template.php
index a0ed618cb2c..4cda3650866 100644
--- a/lib/public/template.php
+++ b/lib/public/template.php
@@ -26,7 +26,7 @@
*
*/
-// use OCP namespace for all classes that are considered public.
+// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP;
@@ -39,7 +39,7 @@ namespace OCP;
*
* For further information have a look at OC_Helper::imagePath
*/
-function image_path( $app, $image ){
+function image_path( $app, $image ) {
return(\image_path( $app, $image ));
}
@@ -50,7 +50,7 @@ function image_path( $app, $image ){
* @param $mimetype mimetype
* @returns link to the image
*/
-function mimetype_icon( $mimetype ){
+function mimetype_icon( $mimetype ) {
return(\mimetype_icon( $mimetype ));
}
@@ -61,7 +61,7 @@ function mimetype_icon( $mimetype ){
* @param $bytes size in bytes
* @returns size as string
*/
-function human_file_size( $bytes ){
+function human_file_size( $bytes ) {
return(\human_file_size( $bytes ));
}
@@ -88,13 +88,13 @@ function simple_file_size($bytes) {
/**
* @brief Generate html code for an options block.
- * @param $options the options
- * @param $selected which one is selected?
- * @param $params the parameters
+ * @param $options the options
+ * @param $selected which one is selected?
+ * @param $params the parameters
* @returns html options
*/
function html_select_options($options, $selected, $params=array()) {
- return(\html_select_options($options, $selected, $params));
+ return(\html_select_options($options, $selected, $params));
}
diff --git a/lib/public/user.php b/lib/public/user.php
index 2fa599488a7..b320ce8ea0c 100644
--- a/lib/public/user.php
+++ b/lib/public/user.php
@@ -26,7 +26,7 @@
*
*/
-// use OCP namespace for all classes that are considered public.
+// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP;
@@ -34,60 +34,53 @@ namespace OCP;
* This class provides access to the user management. You can get information about the currently logged in user and the permissions for example
*/
class User {
-
-
/**
* @brief get the user id of the user currently logged in.
* @return string uid or false
*/
- public static function getUser(){
+ public static function getUser() {
return \OC_USER::getUser();
}
-
/**
* @brief Get a list of all users
* @returns array with all uids
*
* Get a list of all users.
*/
- public static function getUsers($search = '', $limit = -1, $offset = 0) {
+ public static function getUsers($search = '', $limit = null, $offset = null) {
return \OC_USER::getUsers();
}
-
/**
* @brief Check if the user is logged in
* @returns true/false
*
* Checks if the user is logged in
*/
- public static function isLoggedIn(){
+ public static function isLoggedIn() {
return \OC_USER::isLoggedIn();
}
-
/**
* @brief check if a user exists
* @param string $uid the username
* @return boolean
*/
- public static function userExists( $uid ){
+ public static function userExists( $uid ) {
return \OC_USER::userExists( $uid );
}
-
/**
* @brief Loggs the user out including all the session data
* @returns true
*
* Logout, destroys session
*/
- public static function logout(){
+ public static function logout() {
return \OC_USER::logout();
}
-
/**
* @brief Check if the password is correct
* @param $uid The username
@@ -96,27 +89,22 @@ class User {
*
* Check if the password is correct without logging in the user
*/
- public static function checkPassword( $uid, $password ){
+ public static function checkPassword( $uid, $password ) {
return \OC_USER::checkPassword( $uid, $password );
}
+ /**
+ * Check if the user is a admin, redirects to home if not
+ */
+ public static function checkAdminUser() {
+ \OC_Util::checkAdminUser();
+ }
- /**
- * Check if the user is a admin, redirects to home if not
- */
- public static function checkAdminUser(){
- \OC_Util::checkAdminUser();
- }
-
-
- /**
- * Check if the user is logged in, redirects to home if not. With
- * redirect URL parameter to the request URI.
- */
- public static function checkLoggedIn(){
- \OC_Util::checkLoggedIn();
- }
-
-
-
+ /**
+ * Check if the user is logged in, redirects to home if not. With
+ * redirect URL parameter to the request URI.
+ */
+ public static function checkLoggedIn() {
+ \OC_Util::checkLoggedIn();
+ }
}
diff --git a/lib/public/util.php b/lib/public/util.php
index 8d7303bf7a4..747448e62eb 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -34,8 +34,6 @@ namespace OCP;
* This class provides different helper functions to make the life of a developer easier
*/
class Util {
-
-
// consts for Logging
const DEBUG=0;
const INFO=1;
@@ -43,16 +41,14 @@ class Util {
const ERROR=3;
const FATAL=4;
-
/**
* @brief get the current installed version of ownCloud
* @return array
*/
- public static function getVersion(){
+ public static function getVersion() {
return(\OC_Util::getVersion());
}
-
/**
* @brief send an email
* @param string $toaddress
@@ -68,36 +64,33 @@ class Util {
\OC_MAIL::send( $toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html=0, $altbody='', $ccaddress='', $ccname='', $bcc='');
}
-
- /**
+ /**
* @brief write a message in the log
* @param string $app
* @param string $message
* @param int level
- */
- public static function writeLog( $app, $message, $level ) {
- // call the internal log class
- \OC_LOG::write( $app, $message, $level );
- }
-
+ */
+ public static function writeLog( $app, $message, $level ) {
+ // call the internal log class
+ \OC_LOG::write( $app, $message, $level );
+ }
/**
* @brief add a css file
* @param url $url
*/
- public static function addStyle( $application, $file = null ){
+ public static function addStyle( $application, $file = null ) {
\OC_Util::addStyle( $application, $file );
- }
-
+ }
/**
* @brief add a javascript file
* @param appid $application
* @param filename $file
*/
- public static function addScript( $application, $file = null ){
+ public static function addScript( $application, $file = null ) {
\OC_Util::addScript( $application, $file );
- }
+ }
/**
* @brief Add a custom element to the header
@@ -105,7 +98,7 @@ class Util {
* @param array $attributes array of attributes for the element
* @param string $text the text content for the element
*/
- public static function addHeader( $tag, $attributes, $text=''){
+ public static function addHeader( $tag, $attributes, $text='') {
\OC_Util::addHeader( $tag, $attributes, $text );
}
@@ -114,25 +107,23 @@ class Util {
* @param int timestamp $timestamp
* @param bool dateOnly option to ommit time from the result
*/
- public static function formatDate( $timestamp,$dateOnly=false){
+ public static function formatDate( $timestamp,$dateOnly=false) {
return(\OC_Util::formatDate( $timestamp,$dateOnly ));
}
-
-
/**
* @brief Creates an absolute url
* @param $app app
* @param $file file
+ * @param $args array with param=>value, will be appended to the returned url
* @returns the url
*
* Returns a absolute url to the given app and file.
*/
- public static function linkToAbsolute( $app, $file ) {
- return(\OC_Helper::linkToAbsolute( $app, $file ));
+ public static function linkToAbsolute( $app, $file, $args = array() ) {
+ return(\OC_Helper::linkToAbsolute( $app, $file, $args ));
}
-
/**
* @brief Creates an absolute url for remote use
* @param $service id
@@ -155,17 +146,17 @@ class Util {
return \OC_Helper::linkToPublic($service);
}
-
/**
* @brief Creates an url
* @param $app app
* @param $file file
+ * @param $args array with param=>value, will be appended to the returned url
* @returns the url
*
* Returns a url to the given app and file.
*/
- public static function linkTo( $app, $file ){
- return(\OC_Helper::linkTo( $app, $file ));
+ public static function linkTo( $app, $file, $args = array() ) {
+ return(\OC_Helper::linkTo( $app, $file, $args ));
}
/**
@@ -197,11 +188,10 @@ class Util {
*
* Returns the path to the image.
*/
- public static function imagePath( $app, $image ){
+ public static function imagePath( $app, $image ) {
return(\OC_Helper::imagePath( $app, $image ));
}
-
/**
* @brief Make a human file size
* @param $bytes file size in bytes
@@ -209,7 +199,7 @@ class Util {
*
* Makes 2048 to 2 kB.
*/
- public static function humanFileSize( $bytes ){
+ public static function humanFileSize( $bytes ) {
return(\OC_Helper::humanFileSize( $bytes ));
}
@@ -222,7 +212,7 @@ class Util {
*
* Inspired by: http://www.php.net/manual/en/function.filesize.php#92418
*/
- public static function computerFileSize( $str ){
+ public static function computerFileSize( $str ) {
return(\OC_Helper::computerFileSize( $str ));
}
@@ -238,11 +228,10 @@ class Util {
*
* TODO: write example
*/
- static public function connectHook( $signalclass, $signalname, $slotclass, $slotname ){
+ static public function connectHook( $signalclass, $signalname, $slotclass, $slotname ) {
return(\OC_Hook::connect( $signalclass, $signalname, $slotclass, $slotname ));
}
-
/**
* @brief emitts a signal
* @param $signalclass class name of emitter
@@ -254,25 +243,23 @@ class Util {
*
* TODO: write example
*/
- static public function emitHook( $signalclass, $signalname, $params = array()){
+ static public function emitHook( $signalclass, $signalname, $params = array()) {
return(\OC_Hook::emit( $signalclass, $signalname, $params ));
}
-
/**
- * Register an get/post call. This is important to prevent CSRF attacks
+ * Register an get/post call. This is important to prevent CSRF attacks
* TODO: write example
*/
- public static function callRegister(){
+ public static function callRegister() {
return(\OC_Util::callRegister());
}
-
/**
* Check an ajax get/post call if the request token is valid. exit if not.
* Todo: Write howto
*/
- public static function callCheck(){
+ public static function callCheck() {
return(\OC_Util::callCheck());
}
@@ -284,7 +271,7 @@ class Util {
* @param string or array of strings
* @return array with sanitized strings or a single sinitized string, depends on the input parameter.
*/
- public static function sanitizeHTML( $value ){
+ public static function sanitizeHTML( $value ) {
return(\OC_Util::sanitizeHTML($value));
}
@@ -298,7 +285,7 @@ class Util {
*
*
*/
- public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8'){
+ public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') {
return(\OC_Helper::mb_array_change_key_case($input, $case, $encoding));
}