aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/app.php169
-rw-r--r--lib/public/config.php117
-rw-r--r--lib/public/db.php9
-rw-r--r--lib/public/files.php23
-rw-r--r--lib/public/json.php2
-rw-r--r--lib/public/response.php10
-rw-r--r--lib/public/share.php179
-rw-r--r--lib/public/user.php38
-rw-r--r--lib/public/util.php33
9 files changed, 286 insertions, 294 deletions
diff --git a/lib/public/app.php b/lib/public/app.php
index eb824f043e9..809a656f17f 100644
--- a/lib/public/app.php
+++ b/lib/public/app.php
@@ -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 ) {
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/config.php b/lib/public/config.php
index fa9658e7288..1f163d52617 100644
--- a/lib/public/config.php
+++ b/lib/public/config.php
@@ -38,13 +38,11 @@ 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
- * @param $default = null default value
- * @returns the value or $default
+ * @param string $key key
+ * @param string $default = null default value
+ * @return string the value or $default
*
* This function gets the value from config.php. If it does not exist,
* $default will be returned.
@@ -53,12 +51,11 @@ class Config {
return(\OC_Config::getValue( $key, $default ));
}
-
/**
* @brief Sets a value
- * @param $key key
- * @param $value value
- * @returns true/false
+ * @param string $key key
+ * @param string $value value
+ * @return bool
*
* This function sets the value and writes the config.php. If the file can
* not be written, false will be returned.
@@ -67,70 +64,60 @@ class Config {
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 string $app app
+ * @param string $key key
+ * @param string $default = null, default value if the key does not exist
+ * @return string the value or $default
+ *
+ * This function gets a value from the appconfig table. If the key does
+ * not exist the default value will be returned
+ */
+ 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 string $app app
+ * @param string $key key
+ * @param string $value value
+ * @return string 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 string $user user
+ * @param string $app app
+ * @param string $key key
+ * @param string $default = null, default value if the key does not exist
+ * @return string the value or $default
+ *
+ * This function gets a value from the preferences table. If the key does
+ * not exist the default value will be returned
+ */
+ 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 ) {
- return(\OC_Preferences::setValue( $user, $app, $key, $value ));
+ /**
+ * @brief sets a value in the preferences
+ * @param string $user user
+ * @param string $app app
+ * @param string $key key
+ * @param string $value value
+ * @returns bool
+ *
+ * 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 5ac356bb475..6ce62b27ca2 100644
--- a/lib/public/db.php
+++ b/lib/public/db.php
@@ -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
@@ -47,7 +45,6 @@ class DB {
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
@@ -62,7 +59,6 @@ class DB {
return(\OC_DB::insertid($table));
}
-
/**
* @brief Start a transaction
*/
@@ -70,7 +66,6 @@ class DB {
return(\OC_DB::beginTransaction());
}
-
/**
* @brief Commit the database changes done during a transaction that is in progress
*/
@@ -78,7 +73,6 @@ class DB {
return(\OC_DB::commit());
}
-
/**
* @brief check if a result is an error, works with MDB2 and PDOException
* @param mixed $result
@@ -87,7 +81,4 @@ class DB {
public static function isError($result) {
return(\OC_DB::isError($result));
}
-
-
-
}
diff --git a/lib/public/files.php b/lib/public/files.php
index 2f4f459bd91..90889c59ad8 100644
--- a/lib/public/files.php
+++ b/lib/public/files.php
@@ -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,7 +43,6 @@ class Files {
\OC_Helper::rmdirr( $dir );
}
-
/**
* get the mimetype form a local file
* @param string path
@@ -56,7 +53,6 @@ class Files {
return(\OC_Helper::getMimeType( $path ));
}
-
/**
* copy the contents of one stream to another
* @param resource source
@@ -67,7 +63,6 @@ class Files {
return(\OC_Helper::streamCopy( $source, $target ));
}
-
/**
* create a temporary file with an unique filename
* @param string postfix
@@ -79,7 +74,6 @@ class Files {
return(\OC_Helper::tmpFile( $postfix ));
}
-
/**
* create a temporary folder with an unique filename
* @return string
@@ -90,7 +84,6 @@ class Files {
return(\OC_Helper::tmpFolder());
}
-
/**
* Adds a suffix to the name in case the file exists
*
@@ -102,16 +95,12 @@ class Files {
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 93be920c6d7..2186dd8ee49 100644
--- a/lib/public/json.php
+++ b/lib/public/json.php
@@ -34,7 +34,6 @@ 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
@@ -170,5 +169,4 @@ class JSON {
public static function checkAdminUser() {
return(\OC_JSON::checkAdminUser());
}
-
}
diff --git a/lib/public/response.php b/lib/public/response.php
index febb3f14361..95e67a85720 100644
--- a/lib/public/response.php
+++ b/lib/public/response.php
@@ -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 cf61681424f..1039d6f0dbf 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -252,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;
@@ -337,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']);
+ return true;
}
return false;
}
@@ -406,6 +417,25 @@ class Share {
throw new \Exception($message);
}
+ public static function setExpirationDate($itemType, $itemSource, $date) {
+ if ($items = self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), self::FORMAT_NONE, null, -1, false)) {
+ if (!empty($items)) {
+ if ($date == '') {
+ $date = null;
+ } else {
+ $date = new \DateTime($date);
+ $date = date('Y-m-d H:i', $date->format('U') - $date->getOffset());
+ }
+ $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `expiration` = ? WHERE `id` = ?');
+ foreach ($items as $item) {
+ $query->execute(array($date, $item['id']));
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* @brief Get the backend class for the specified item type
* @param string Item type
@@ -447,8 +477,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;
@@ -493,9 +526,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` = ?';
@@ -570,7 +607,7 @@ class Share {
}
}
$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);
@@ -594,23 +631,23 @@ class Share {
// TODO Optimize selects
if ($format == self::FORMAT_STATUSES) {
if ($itemType == 'file' || $itemType == 'folder') {
- $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `file_source`, `path`';
+ $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `file_source`, `path`, `expiration`';
} else {
- $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`';
+ $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`';
}
} else {
if (isset($uidOwner)) {
if ($itemType == 'file' || $itemType == 'folder') {
- $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`';
+ $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`, `expiration`';
} else {
- $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`, `stime`, `file_source`';
+ $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`, `stime`, `file_source`, `expiration`';
}
} else {
if ($fileDependent) {
if (($itemType == 'file' || $itemType == 'folder') && $format == \OC_Share_Backend_File::FORMAT_FILE_APP || $format == \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT) {
- $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `file_source`, `path`, `file_target`, `permissions`, `name`, `ctime`, `mtime`, `mimetype`, `size`, `encrypted`, `versioned`, `writable`';
+ $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `file_source`, `path`, `file_target`, `permissions`, `expiration`, `name`, `ctime`, `mtime`, `mimetype`, `size`, `encrypted`, `versioned`, `writable`';
} else {
- $select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`, `file_source`, `path`, `file_target`, `permissions`, `stime`';
+ $select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`, `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`';
}
} else {
$select = '*';
@@ -629,6 +666,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]])) {
@@ -662,6 +702,13 @@ class Share {
$row['path'] = substr($row['path'], $root);
}
}
+ if (isset($row['expiration'])) {
+ $time = new \DateTime();
+ if ($row['expiration'] < date('Y-m-d H:i', $time->format('U') - $time->getOffset())) {
+ self::delete($row['id']);
+ continue;
+ }
+ }
$items[$row['id']] = $row;
}
if (!empty($items)) {
@@ -676,29 +723,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;
}
}
}
@@ -848,6 +920,7 @@ class Share {
// 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)) {
$query->execute(array($itemType, $itemSource, $itemTarget, $parent, self::$shareTypeGroupUserUnique, $uid, $uidOwner, $permissions, time(), $fileSource, $fileTarget));
+ \OC_DB::insertid('*PREFIX*share');
}
}
if ($parentFolder === true) {
@@ -1153,7 +1226,7 @@ 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/user.php b/lib/public/user.php
index b530321f21d..b320ce8ea0c 100644
--- a/lib/public/user.php
+++ b/lib/public/user.php
@@ -34,8 +34,6 @@ 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
@@ -44,7 +42,6 @@ class User {
return \OC_USER::getUser();
}
-
/**
* @brief Get a list of all users
* @returns array with all uids
@@ -55,7 +52,6 @@ class User {
return \OC_USER::getUsers();
}
-
/**
* @brief Check if the user is logged in
* @returns true/false
@@ -66,7 +62,6 @@ class User {
return \OC_USER::isLoggedIn();
}
-
/**
* @brief check if a user exists
* @param string $uid the username
@@ -76,7 +71,6 @@ class User {
return \OC_USER::userExists( $uid );
}
-
/**
* @brief Loggs the user out including all the session data
* @returns true
@@ -87,7 +81,6 @@ class User {
return \OC_USER::logout();
}
-
/**
* @brief Check if the password is correct
* @param $uid The username
@@ -100,23 +93,18 @@ class User {
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 ed23521b040..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,7 +41,6 @@ class Util {
const ERROR=3;
const FATAL=4;
-
/**
* @brief get the current installed version of ownCloud
* @return array
@@ -52,7 +49,6 @@ class Util {
return(\OC_Util::getVersion());
}
-
/**
* @brief send an email
* @param string $toaddress
@@ -68,18 +64,16 @@ 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
@@ -87,8 +81,7 @@ class Util {
*/
public static function addStyle( $application, $file = null ) {
\OC_Util::addStyle( $application, $file );
- }
-
+ }
/**
* @brief add a javascript file
@@ -97,7 +90,7 @@ class Util {
*/
public static function addScript( $application, $file = null ) {
\OC_Util::addScript( $application, $file );
- }
+ }
/**
* @brief Add a custom element to the header
@@ -118,8 +111,6 @@ class Util {
return(\OC_Util::formatDate( $timestamp,$dateOnly ));
}
-
-
/**
* @brief Creates an absolute url
* @param $app app
@@ -133,7 +124,6 @@ class Util {
return(\OC_Helper::linkToAbsolute( $app, $file, $args ));
}
-
/**
* @brief Creates an absolute url for remote use
* @param $service id
@@ -156,7 +146,6 @@ class Util {
return \OC_Helper::linkToPublic($service);
}
-
/**
* @brief Creates an url
* @param $app app
@@ -199,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
@@ -244,7 +232,6 @@ class Util {
return(\OC_Hook::connect( $signalclass, $signalname, $slotclass, $slotname ));
}
-
/**
* @brief emitts a signal
* @param $signalclass class name of emitter
@@ -260,7 +247,6 @@ class Util {
return(\OC_Hook::emit( $signalclass, $signalname, $params ));
}
-
/**
* Register an get/post call. This is important to prevent CSRF attacks
* TODO: write example
@@ -269,7 +255,6 @@ class Util {
return(\OC_Util::callRegister());
}
-
/**
* Check an ajax get/post call if the request token is valid. exit if not.
* Todo: Write howto