From 77adaee6457c3e17d0f0b32c74da4cdbfce60164 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Fri, 30 Aug 2013 13:53:49 +0200 Subject: enable user to inform recipients about a shared file by mail --- lib/public/share.php | 81 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 7 deletions(-) (limited to 'lib/public/share.php') diff --git a/lib/public/share.php b/lib/public/share.php index b38208bc67f..eac6fab2b6a 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -106,22 +106,22 @@ class Share { } return false; } - + /** * @brief Prepare a path to be passed to DB as file_target * @return string Prepared path */ public static function prepFileTarget( $path ) { - + // Paths in DB are stored with leading slashes, so add one if necessary if ( substr( $path, 0, 1 ) !== '/' ) { - + $path = '/' . $path; - + } - + return $path; - + } /** @@ -251,7 +251,57 @@ class Share { return self::getItems($itemType, $itemTarget, self::$shareTypeUserAndGroups, \OC_User::getUser(), null, $format, $parameters, 1, $includeCollections); } - + + /** + * @brief Get the item of item type shared with a given user by source + * @param string Item type + * @param string Item source + * @param string User user to whom the item was shared + * @return Return list of items with file_target, permissions and expiration + */ + public static function getItemSharedWithUser($itemType, $itemSource, $user) { + + $shares = array(); + + // first check if there is a db entry for the specific user + $query = \OC_DB::prepare( + 'SELECT `file_target`, `permissions`, `expiration` + FROM + `*PREFIX*share` + WHERE + `item_source` = ? AND `item_type` = ? AND `share_with` = ?' + ); + + $result = $query->execute(array($itemSource, $itemType, $user)); + + while ($row = $result->fetchRow()) { + $shares[] = $row; + } + + //if didn't found a result than let's look for a group share. + if(empty($shares)) { + $groups = \OC_Group::getUserGroups($user); + + $query = \OC_DB::prepare( + 'SELECT `file_target`, `permissions`, `expiration` + FROM + `*PREFIX*share` + WHERE + `item_source` = ? AND `item_type` = ? AND `share_with` in (?)' + ); + + $result = $query->execute(array($itemSource, $itemType, implode(',', $groups))); + + while ($row = $result->fetchRow()) { + $shares[] = $row; + } + } + + return $shares; + + } + + /** * @brief Get the item of item type shared with the current user by source * @param string Item type @@ -633,6 +683,23 @@ class Share { } return false; } + /** + * @brief sent status if users got informed by mail about share + * @param string $itemType + * @param string $itemSource + * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK + * @param bool $status + */ + public static function setSendMailStatus($itemType, $itemSource, $shareType, $status) { + $status = $status ? 1 : 0; + + $query = \OC_DB::prepare( + 'UPDATE `*PREFIX*share` + SET `mail_send` = ? + WHERE `item_type` = ? AND `item_source` = ? AND `share_type` = ?'); + + $query->execute(array($status, $itemType, $itemSource, $shareType)); + } /** * @brief Set the permissions of an item for a specific user or group -- cgit v1.2.3 From 10cf1b3a4e03dfa908d9dfc7cae85e9bd418e5bf Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Fri, 30 Aug 2013 15:39:43 +0200 Subject: return mailSend status in getItems() --- core/js/share.js | 5 +++-- lib/public/share.php | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'lib/public/share.php') diff --git a/core/js/share.js b/core/js/share.js index c806d83f10c..7d7f580c9bb 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -114,6 +114,7 @@ OC.Share={ data = false; } }}); + return data; }, share:function(itemType, itemSource, shareType, shareWith, permissions, callback) { @@ -219,7 +220,7 @@ OC.Share={ if (share.collection) { OC.Share.addShareWith(share.share_type, share.share_with, share.share_with_displayname, share.permissions, possiblePermissions, share.mail_send, share.collection); } else { - OC.Share.addShareWith(share.share_type, share.share_with, share.share_with_displayname, share.mail_send, share.permissions, possiblePermissions, share.mail_send, false); + OC.Share.addShareWith(share.share_type, share.share_with, share.share_with_displayname, share.permissions, possiblePermissions, share.mail_send, false); } } if (share.expiration != null) { @@ -344,7 +345,7 @@ OC.Share={ mailNotificationEnabled = $('input:hidden[name=mailNotificationEnabled]').val(); if (mailNotificationEnabled === 'yes') { checked = ''; - if (mailSend === true) { + if (mailSend === '1') { checked = 'checked'; } html += ''+t('core', 'notify user by email')+''; diff --git a/lib/public/share.php b/lib/public/share.php index eac6fab2b6a..c2dd0096ab9 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -1030,19 +1030,19 @@ class Share { if ($format == self::FORMAT_STATUSES) { if ($itemType == 'file' || $itemType == 'folder') { $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,' - .' `share_type`, `file_source`, `path`, `expiration`, `storage`'; + .' `share_type`, `file_source`, `path`, `expiration`, `storage`, `mail_send`'; } else { - $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`'; + $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`, `mail_send`'; } } 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`,' - .' `expiration`, `token`, `storage`'; + .' `expiration`, `token`, `storage`, `storage`, `mail_send`'; } else { $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`,' - .' `stime`, `file_source`, `expiration`, `token`'; + .' `stime`, `file_source`, `expiration`, `token`, `storage`, `mail_send`'; } } else { if ($fileDependent) { @@ -1053,11 +1053,11 @@ class Share { $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `uid_owner`, ' .'`share_type`, `share_with`, `file_source`, `path`, `file_target`, ' .'`permissions`, `expiration`, `storage`, `*PREFIX*filecache`.`parent` as `file_parent`, ' - .'`name`, `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`'; + .'`name`, `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`, `storage`, `mail_send`'; } 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`, `expiration`, `token`, `storage`'; + `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`, `storage`, `storage`, `mail_send`'; } } else { $select = '*'; -- cgit v1.2.3 From 983da0d78fe13814fb771eb90dd2f10a89e0bcc6 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Mon, 2 Sep 2013 17:01:10 +0200 Subject: fix db queries --- lib/public/share.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/public/share.php') diff --git a/lib/public/share.php b/lib/public/share.php index c2dd0096ab9..cb55c5c9756 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -1053,11 +1053,11 @@ class Share { $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `uid_owner`, ' .'`share_type`, `share_with`, `file_source`, `path`, `file_target`, ' .'`permissions`, `expiration`, `storage`, `*PREFIX*filecache`.`parent` as `file_parent`, ' - .'`name`, `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`, `storage`, `mail_send`'; + .'`name`, `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`, `mail_send`'; } 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`, `expiration`, `token`, `storage`, `storage`, `mail_send`'; + `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`, `storage`, `mail_send`'; } } else { $select = '*'; -- cgit v1.2.3 From 931e90634e905816e5ec8db3d10f9446c1b1eacc Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Mon, 2 Sep 2013 17:03:35 +0200 Subject: fix db queries --- lib/public/share.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/public/share.php') diff --git a/lib/public/share.php b/lib/public/share.php index cb55c5c9756..4461a1d421f 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -1039,10 +1039,10 @@ class Share { if ($itemType == 'file' || $itemType == 'folder') { $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,' .' `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`,' - .' `expiration`, `token`, `storage`, `storage`, `mail_send`'; + .' `expiration`, `token`, `storage`, `mail_send`'; } else { $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`,' - .' `stime`, `file_source`, `expiration`, `token`, `storage`, `mail_send`'; + .' `stime`, `file_source`, `expiration`, `token`, `mail_send`'; } } else { if ($fileDependent) { -- cgit v1.2.3 From 0637dad0b39f1f90dc1c22afc2985642432e8096 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Tue, 24 Sep 2013 18:52:20 +0200 Subject: some small fixes --- lib/public/share.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'lib/public/share.php') diff --git a/lib/public/share.php b/lib/public/share.php index 0dfbbef0a73..03ad5853e28 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -246,9 +246,9 @@ class Share { /** * @brief Get the item of item type shared with the current user - * @param string Item type - * @param string Item target - * @param int Format (optional) Format type must be defined by the backend + * @param string $itemType + * @param string $ItemTarget + * @param int $format (optional) Format type must be defined by the backend * @return Return depends on format */ public static function getItemSharedWith($itemType, $itemTarget, $format = self::FORMAT_NONE, @@ -279,8 +279,10 @@ class Share { $result = $query->execute(array($itemSource, $itemType, $user)); - while ($row = $result->fetchRow()) { - $shares[] = $row; + if($result) { + while ($row = $result->fetchRow()) { + $shares[] = $row; + } } //if didn't found a result than let's look for a group share. @@ -297,8 +299,10 @@ class Share { $result = $query->execute(array($itemSource, $itemType, implode(',', $groups))); - while ($row = $result->fetchRow()) { - $shares[] = $row; + if($result) { + while ($row = $result->fetchRow()) { + $shares[] = $row; + } } } @@ -706,7 +710,13 @@ class Share { SET `mail_send` = ? WHERE `item_type` = ? AND `item_source` = ? AND `share_type` = ?'); - $query->execute(array($status, $itemType, $itemSource, $shareType)); + $result = $query->execute(array($status, $itemType, $itemSource, $shareType)); + + if($result === false) { + \OC_Log::write('OCP\Share', 'Couldn\'t set send mail status', \OC_Log::ERROR); + } + + } /** -- cgit v1.2.3 From ca47fc5f18178c88f8a4eff3de35f02b580bc6b1 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Tue, 24 Sep 2013 19:37:24 +0200 Subject: fix PHPDoc --- lib/public/share.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/public/share.php') diff --git a/lib/public/share.php b/lib/public/share.php index 03ad5853e28..bdfaed2d5cd 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -259,10 +259,10 @@ class Share { /** * @brief Get the item of item type shared with a given user by source - * @param string Item type - * @param string Item source - * @param string User user to whom the item was shared - * @return Return list of items with file_target, permissions and expiration + * @param string $ItemType + * @param string $ItemSource + * @param string $user User user to whom the item was shared + * @return array Return list of items with file_target, permissions and expiration */ public static function getItemSharedWithUser($itemType, $itemSource, $user) { -- cgit v1.2.3 From 5a9e473a7964a068599de59cbbd7fe1dae6493ef Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Wed, 25 Sep 2013 12:15:46 +0200 Subject: use OC_DB::executeAudited --- lib/public/share.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lib/public/share.php') diff --git a/lib/public/share.php b/lib/public/share.php index bdfaed2d5cd..c0f339744cc 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -277,12 +277,10 @@ class Share { `item_source` = ? AND `item_type` = ? AND `share_with` = ?' ); - $result = $query->execute(array($itemSource, $itemType, $user)); + $result = \OC_DB::executeAudited($query, array($itemSource, $itemType, $user)); - if($result) { - while ($row = $result->fetchRow()) { - $shares[] = $row; - } + while ($row = $result->fetchRow()) { + $shares[] = $row; } //if didn't found a result than let's look for a group share. -- cgit v1.2.3 From acd3c11e47212e3b9d59a914cea408637582bb06 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Wed, 25 Sep 2013 12:18:29 +0200 Subject: use OC_DB::executeAudited --- lib/public/share.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lib/public/share.php') diff --git a/lib/public/share.php b/lib/public/share.php index c0f339744cc..be61d046f0b 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -295,12 +295,10 @@ class Share { `item_source` = ? AND `item_type` = ? AND `share_with` in (?)' ); - $result = $query->execute(array($itemSource, $itemType, implode(',', $groups))); + $result = \OC_DB::executeAudited($query, array($itemSource, $itemType, implode(',', $groups))); - if($result) { - while ($row = $result->fetchRow()) { - $shares[] = $row; - } + while ($row = $result->fetchRow()) { + $shares[] = $row; } } -- cgit v1.2.3 From 48b5c1d5f934fb4f6c58bf196b81ee8089217e52 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Sun, 29 Sep 2013 20:31:12 +0200 Subject: initial implementation of activity manager --- lib/activitymanager.php | 48 ++++++++++++++++++++++++++++++++++++++++ lib/public/activity/imanager.php | 8 +++++++ lib/public/share.php | 5 +++++ lib/server.php | 12 ++++++++++ 4 files changed, 73 insertions(+) create mode 100755 lib/activitymanager.php (limited to 'lib/public/share.php') diff --git a/lib/activitymanager.php b/lib/activitymanager.php new file mode 100755 index 00000000000..c1338d873fa --- /dev/null +++ b/lib/activitymanager.php @@ -0,0 +1,48 @@ +consumers as $consumer) { + $c = $consumer(); + if ($c instanceof IConsumer) { + $c->receive($app, $subject, $message, $file, $link); + } + + } + } + + /** + * In order to improve lazy loading a closure can be registered which will be called in case + * activity consumers are actually requested + * + * $callable has to return an instance of OCA\Activity\IConsumer + * + * @param string $key + * @param \Closure $callable + */ + function registerConsumer(\Closure $callable) { + array_push($this->consumers, $callable); + } +} diff --git a/lib/public/activity/imanager.php b/lib/public/activity/imanager.php index da7e9d4b662..9cba2db7e7f 100644 --- a/lib/public/activity/imanager.php +++ b/lib/public/activity/imanager.php @@ -25,6 +25,14 @@ namespace OCP\Activity; interface IManager { + /** + * @param $app + * @param $subject + * @param $message + * @param $file + * @param $link + * @return mixed + */ function publishActivity($app, $subject, $message, $file, $link); /** diff --git a/lib/public/share.php b/lib/public/share.php index 6c5783f1179..ff11aad1a12 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -1400,6 +1400,11 @@ class Share { 'id' => $parent, 'token' => $token )); + + // hook up activity manager + $subject = 'Something has been shared'; + \OC::$server->getActivityManager()->publishActivity('files_sharing', $subject, '', '', ''); + if ($parentFolder === true) { // Return parent folders to preserve file target paths for potential children return $parentFolders; diff --git a/lib/server.php b/lib/server.php index cabb15324ec..b14b2e17d03 100644 --- a/lib/server.php +++ b/lib/server.php @@ -114,6 +114,9 @@ class Server extends SimpleContainer implements IServerContainer { $this->registerService('UserCache', function($c) { return new UserCache(); }); + $this->registerService('ActivityManager', function($c) { + return new ActivityManager(); + }); } /** @@ -252,4 +255,13 @@ class Server extends SimpleContainer implements IServerContainer { function getDatabaseConnection() { return \OC_DB::getConnection(); } + + /** + * Returns the activity manager + * + * @return \OCP\Activity\IManager + */ + function getActivityManager() { + return $this->query('ActivityManager'); + } } -- cgit v1.2.3 From 7fe493fdb8d662b20b435c86aa23eb3b38a271b1 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Wed, 9 Oct 2013 17:25:58 +0200 Subject: make sure that we only find file/folder shares --- lib/public/share.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/public/share.php') diff --git a/lib/public/share.php b/lib/public/share.php index e6a74117aa2..66605dafee5 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -155,13 +155,13 @@ class Share { while ($source !== -1) { - // Fetch all shares of this file path from DB + // Fetch all shares with another user $query = \OC_DB::prepare( 'SELECT `share_with` FROM `*PREFIX*share` WHERE - `item_source` = ? AND `share_type` = ?' + `item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')' ); $result = $query->execute(array($source, self::SHARE_TYPE_USER)); @@ -180,7 +180,7 @@ class Share { FROM `*PREFIX*share` WHERE - `item_source` = ? AND `share_type` = ?' + `item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')' ); $result = $query->execute(array($source, self::SHARE_TYPE_GROUP)); @@ -201,7 +201,7 @@ class Share { FROM `*PREFIX*share` WHERE - `item_source` = ? AND `share_type` = ?' + `item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')' ); $result = $query->execute(array($source, self::SHARE_TYPE_LINK)); -- cgit v1.2.3 From 852a50aa8968560738f61e32d8b1cb7f5cd329c1 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Wed, 16 Oct 2013 15:38:56 +0200 Subject: remove test code --- lib/public/share.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/public/share.php') diff --git a/lib/public/share.php b/lib/public/share.php index b2873d22f43..c5bce41846b 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -1473,10 +1473,6 @@ class Share { 'token' => $token )); - // hook up activity manager - $subject = 'Something has been shared'; - \OC::$server->getActivityManager()->publishActivity('files_sharing', $subject, '', '', ''); - if ($parentFolder === true) { // Return parent folders to preserve file target paths for potential children return $parentFolders; -- cgit v1.2.3 From 30f4d91d01cc9f0f32767a466a5024ad4f76ebf5 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 17 Oct 2013 00:07:29 +0200 Subject: Public API documentation fixes refs #4883 * http/response.php * config.php * response.php * files.php * idbconnection.php * app.php * user.php * template.php * share.php * db.php * icache.php & il10n.php --- lib/public/app.php | 48 +++++++++++----------- lib/public/appframework/http/response.php | 14 ++++++- lib/public/config.php | 14 +++---- lib/public/db.php | 12 +++--- lib/public/files.php | 28 ++++++------- lib/public/icache.php | 6 +-- lib/public/idbconnection.php | 16 ++++---- lib/public/il10n.php | 8 ++-- lib/public/response.php | 10 ++--- lib/public/share.php | 66 +++++++++++++++---------------- lib/public/template.php | 60 ++++++++++++++-------------- lib/public/user.php | 51 ++++++++++++------------ 12 files changed, 166 insertions(+), 167 deletions(-) (limited to 'lib/public/share.php') diff --git a/lib/public/app.php b/lib/public/app.php index 0a5721b334e..18681670ddd 100644 --- a/lib/public/app.php +++ b/lib/public/app.php @@ -35,14 +35,12 @@ namespace OCP; */ 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 boolean + * Makes ownCloud aware of this app + * @param array with all information + * @return boolean * - * @deprecated this method is deprecated - * Do not call it anymore - * It'll remain in our public API for compatibility reasons + * @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 ) { @@ -50,9 +48,9 @@ class App { } /** - * @brief adds an entry to the navigation - * @param $data array containing the data - * @returns boolean + * Adds an entry to the navigation + * @param array containing the data + * @return boolean * * This function adds a new entry to the navigation visible to users. $data * is an associative array. @@ -71,9 +69,9 @@ class App { } /** - * @brief marks a navigation entry as active - * @param $id string id of the entry - * @returns boolean + * Marks a navigation entry as active + * @param string id of the entry + * @return boolean * * This function sets a navigation entry as active and removes the 'active' * property from all other entries. The templates can use this for @@ -84,7 +82,7 @@ class App { } /** - * @brief Register a Configuration Screen that should appear in the personal settings section. + * Register a Configuration Screen that should appear in the personal settings section. * @param $app string appid * @param $page string page to be included */ @@ -93,7 +91,7 @@ class App { } /** - * @brief Register a Configuration Screen that should appear in the Admin section. + * Register a Configuration Screen that should appear in the Admin section. * @param $app string appid * @param $page string page to be included */ @@ -102,19 +100,19 @@ class App { } /** - * @brief Read app metadata from the info.xml file + * 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 + * @return 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 boolean + * checks whether or not an app is enabled + * @param string + * @return boolean * * This function checks whether or not an app is enabled. */ @@ -123,17 +121,17 @@ class App { } /** - * @brief Check if the app is enabled, redirects to home if not - * @param $app app + * Check if the app is enabled, redirects to home if not + * @param string */ public static function checkAppEnabled( $app ) { \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 boolean + * Get the last version of the app, either from appinfo/version or from appinfo/info.xml + * @param string + * @return boolean */ public static function getAppVersion( $app ) { return \OC_App::getAppVersion( $app ); diff --git a/lib/public/appframework/http/response.php b/lib/public/appframework/http/response.php index 64477258948..5ca389b9946 100644 --- a/lib/public/appframework/http/response.php +++ b/lib/public/appframework/http/response.php @@ -26,12 +26,15 @@ namespace OCP\AppFramework\Http; /** - * Base class for responses. Also used to just send headers + * Base class for responses. Also used to just send headers. + * + * It handles headers, HTTP status code, last modified and ETag. */ class Response { /** - * @var array default headers + * Headers - defaults to ['Cache-Control' => 'no-cache, must-revalidate'] + * @var array */ private $headers = array( 'Cache-Control' => 'no-cache, must-revalidate' @@ -39,18 +42,21 @@ class Response { /** + * HTTP status code - defaults to STATUS OK * @var string */ private $status = Http::STATUS_OK; /** + * Last modified date * @var \DateTime */ private $lastModified; /** + * ETag * @var string */ private $ETag; @@ -135,6 +141,7 @@ class Response { /** + * Get the ETag * @return string the etag */ public function getETag() { @@ -143,6 +150,7 @@ class Response { /** + * Get "last modified" date * @return string RFC2822 formatted last modified date */ public function getLastModified() { @@ -151,6 +159,7 @@ class Response { /** + * Set the ETag * @param string $ETag */ public function setETag($ETag) { @@ -159,6 +168,7 @@ class Response { /** + * Set "last modified" date * @param \DateTime $lastModified */ public function setLastModified($lastModified) { diff --git a/lib/public/config.php b/lib/public/config.php index 73476d7551d..74aaa4e1891 100644 --- a/lib/public/config.php +++ b/lib/public/config.php @@ -40,7 +40,7 @@ namespace OCP; */ class Config { /** - * @brief Gets a value from config.php + * Gets a value from config.php * @param string $key key * @param string $default = null default value * @return string the value or $default @@ -53,7 +53,7 @@ class Config { } /** - * @brief Sets a value + * Sets a value * @param string $key key * @param string $value value * @return bool @@ -71,7 +71,7 @@ class Config { } /** - * @brief Gets the config value + * Gets the config value * @param string $app app * @param string $key key * @param string $default = null, default value if the key does not exist @@ -85,7 +85,7 @@ class Config { } /** - * @brief sets a value in the appconfig + * Sets a value in the appconfig * @param string $app app * @param string $key key * @param string $value value @@ -103,7 +103,7 @@ class Config { } /** - * @brief Gets the preference + * Gets the preference * @param string $user user * @param string $app app * @param string $key key @@ -118,12 +118,12 @@ class Config { } /** - * @brief sets a value in the preferences + * Sets a value in the preferences * @param string $user user * @param string $app app * @param string $key key * @param string $value value - * @returns bool + * @return bool * * Adds a value to the preferences. If the key did not exist before, it * will be added automagically. diff --git a/lib/public/db.php b/lib/public/db.php index 9512cca2d19..fc6621f5b51 100644 --- a/lib/public/db.php +++ b/lib/public/db.php @@ -35,7 +35,7 @@ namespace OCP; */ class DB { /** - * @brief Prepare a SQL query + * Prepare a SQL query * @param string $query Query string * @return \MDB2_Statement_Common prepared SQL query * @@ -46,7 +46,7 @@ class DB { } /** - * @brief Insert a row if a matching row doesn't exists. + * Insert a row if a matching row doesn't exists. * @param $table string The table name (will replace *PREFIX*) to perform the replace on. * @param $input array * @@ -67,7 +67,7 @@ class DB { } /** - * @brief gets last value of autoincrement + * Gets last value of autoincrement * @param $table string The optional table name (will replace *PREFIX*) and add sequence suffix * @return int * @@ -81,21 +81,21 @@ class DB { } /** - * @brief Start a transaction + * Start a transaction */ public static function beginTransaction() { return(\OC_DB::beginTransaction()); } /** - * @brief Commit the database changes done during a transaction that is in progress + * Commit the database changes done during a transaction that is in progress */ public static function commit() { return(\OC_DB::commit()); } /** - * @brief check if a result is an error, works with MDB2 and PDOException + * Check if a result is an error, works with MDB2 and PDOException * @param mixed $result * @return bool */ diff --git a/lib/public/files.php b/lib/public/files.php index 852b041eefb..1e4c25c5ef1 100644 --- a/lib/public/files.php +++ b/lib/public/files.php @@ -36,9 +36,8 @@ namespace OCP; */ class Files { /** - * @brief Recusive deletion of folders - * @param string $dir path to the folder - * + * Recusive deletion of folders + * @param string path to the folder * @return bool */ static function rmdirr( $dir ) { @@ -46,7 +45,7 @@ class Files { } /** - * get the mimetype form a local file + * Get the mimetype form a local file * @param string path * @return string * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead @@ -56,17 +55,16 @@ class Files { } /** - * search for files by mimetype - * - * @param string $query + * Search for files by mimetype + * @param string mimetype * @return array */ - static public function searchByMime($mimetype) { + static public function searchByMime( $mimetype ) { return(\OC\Files\Filesystem::searchByMime( $mimetype )); } /** - * copy the contents of one stream to another + * Copy the contents of one stream to another * @param resource source * @param resource target * @return int the number of bytes copied @@ -77,7 +75,7 @@ class Files { } /** - * create a temporary file with an unique filename + * Create a temporary file with an unique filename * @param string postfix * @return string * @@ -88,7 +86,7 @@ class Files { } /** - * create a temporary folder with an unique filename + * Create a temporary folder with an unique filename * @return string * * temporary files are automatically cleaned up after the script is finished @@ -99,9 +97,8 @@ class Files { /** * Adds a suffix to the name in case the file exists - * - * @param $path - * @param $filename + * @param string path + * @param string filename * @return string */ public static function buildNotExistingFileName( $path, $filename ) { @@ -109,8 +106,9 @@ class Files { } /** + * Gets the Storage for an app - creates the needed folder if they are not + * existant * @param string appid - * @param $app app * @return \OC\Files\View */ public static function getStorage( $app ) { diff --git a/lib/public/icache.php b/lib/public/icache.php index 436ee71b2b9..a73004ec9a7 100644 --- a/lib/public/icache.php +++ b/lib/public/icache.php @@ -14,7 +14,6 @@ interface ICache { /** * Get a value from the user cache - * * @param string $key * @return mixed */ @@ -22,7 +21,6 @@ interface ICache { /** * Set a value in the user cache - * * @param string $key * @param mixed $value * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 @@ -32,7 +30,6 @@ interface ICache { /** * Check if a value is set in the user cache - * * @param string $key * @return bool */ @@ -40,14 +37,13 @@ interface ICache { /** * Remove an item from the user cache - * * @param string $key * @return bool */ public function remove($key); /** - * clear the user cache of all entries starting with a prefix + * Clear the user cache of all entries starting with a prefix * @param string $prefix (optional) * @return bool */ diff --git a/lib/public/idbconnection.php b/lib/public/idbconnection.php index c741a0f061a..252902eda6c 100644 --- a/lib/public/idbconnection.php +++ b/lib/public/idbconnection.php @@ -4,7 +4,7 @@ * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. - * + * */ namespace OCP; @@ -30,9 +30,9 @@ interface IDBConnection { public function lastInsertId($table = null); /** - * @brief Insert a row if a matching row doesn't exists. - * @param $table string The table name (will replace *PREFIX*) to perform the replace on. - * @param $input array + * Insert a row if a matching row doesn't exists. + * @param string The table name (will replace *PREFIX*) to perform the replace on. + * @param array * * The input array if in the form: * @@ -49,25 +49,25 @@ interface IDBConnection { public function insertIfNotExist($table, $input); /** - * @brief Start a transaction + * Start a transaction * @return bool TRUE on success or FALSE on failure */ public function beginTransaction(); /** - * @brief Commit the database changes done during a transaction that is in progress + * Commit the database changes done during a transaction that is in progress * @return bool TRUE on success or FALSE on failure */ public function commit(); /** - * @brief Rollback the database changes done during a transaction that is in progress + * Rollback the database changes done during a transaction that is in progress * @return bool TRUE on success or FALSE on failure */ public function rollBack(); /** - * returns the error code and message as a string for logging + * Gets the error code and message as a string for logging * @return string */ public function getError(); diff --git a/lib/public/il10n.php b/lib/public/il10n.php index 9cf9093d391..805c8988aa2 100644 --- a/lib/public/il10n.php +++ b/lib/public/il10n.php @@ -14,7 +14,7 @@ namespace OCP; */ interface IL10N { /** - * @brief Translating + * Translating * @param $text String The text we need a translation for * @param array $parameters default:array() Parameters for sprintf * @return \OC_L10N_String|string Translation or the same text @@ -25,7 +25,7 @@ interface IL10N { public function t($text, $parameters = array()); /** - * @brief Translating + * Translating * @param $text_singular String the string to translate for exactly one object * @param $text_plural String the string to translate for n objects * @param $count Integer Number of objects @@ -42,10 +42,10 @@ interface IL10N { public function n($text_singular, $text_plural, $count, $parameters = array()); /** - * @brief Localization + * Localization * @param $type Type of localization * @param $params parameters for this localization - * @returns String or false + * @return String or false * * Returns the localized data. * diff --git a/lib/public/response.php b/lib/public/response.php index de0c3f25347..f7f6afcec95 100644 --- a/lib/public/response.php +++ b/lib/public/response.php @@ -35,7 +35,7 @@ namespace OCP; */ class Response { /** - * @brief Enable response caching by sending correct HTTP headers + * Enable response caching by sending correct HTTP headers * @param int $cache_time time to cache the response * >0 cache time in seconds * 0 and <0 enable default browser caching @@ -55,7 +55,7 @@ class Response { } /** - * @brief disable browser caching + * Disable browser caching * @see enableCaching with cache_time = 0 */ static public function disableCaching() { @@ -72,7 +72,7 @@ class Response { } /** - * @brief Send file as response, checking and setting caching headers + * Send file as response, checking and setting caching headers * @param string $filepath of file to send */ static public function sendFile( $filepath ) { @@ -80,7 +80,7 @@ class Response { } /** - * @brief Set response expire time + * Set response expire time * @param string|\DateTime $expires date-time when the response expires * string for DateInterval from now * DateTime object when to expire response @@ -90,7 +90,7 @@ class Response { } /** - * @brief Send redirect response + * Send redirect response * @param string $location to redirect to */ static public function redirect( $location ) { diff --git a/lib/public/share.php b/lib/public/share.php index 66605dafee5..1b6f5d05f10 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -64,7 +64,7 @@ class Share { private static $isResharingAllowed; /** - * @brief Register a sharing backend class that implements OCP\Share_Backend for an item type + * Register a sharing backend class that implements OCP\Share_Backend for an item type * @param string Item type * @param string Backend class * @param string (optional) Depends on item type @@ -94,11 +94,10 @@ class Share { } /** - * @brief Check if the Share API is enabled + * Check if the Share API is enabled * @return Returns true if enabled or false * * The Share API is enabled by default if not configured - * */ public static function isEnabled() { if (\OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes') == 'yes') { @@ -108,7 +107,7 @@ class Share { } /** - * @brief Prepare a path to be passed to DB as file_target + * Prepare a path to be passed to DB as file_target * @return string Prepared path */ public static function prepFileTarget( $path ) { @@ -125,7 +124,7 @@ class Share { } /** - * @brief Find which users can access a shared item + * Find which users can access a shared item * @param $path to the file * @param $user owner of the file * @param include owner to the list of users with access to the file @@ -232,7 +231,7 @@ class Share { } /** - * @brief Get the items of item type shared with the current user + * Get the items of item type shared with the current user * @param string Item type * @param int Format (optional) Format type must be defined by the backend * @param int Number of items to return (optional) Returns all by default @@ -245,7 +244,7 @@ class Share { } /** - * @brief Get the item of item type shared with the current user + * Get the item of item type shared with the current user * @param string $itemType * @param string $ItemTarget * @param int $format (optional) Format type must be defined by the backend @@ -258,7 +257,7 @@ class Share { } /** - * @brief Get the item of item type shared with a given user by source + * Get the item of item type shared with a given user by source * @param string $ItemType * @param string $ItemSource * @param string $user User user to whom the item was shared @@ -307,7 +306,7 @@ class Share { } /** - * @brief Get the item of item type shared with the current user by source + * Get the item of item type shared with the current user by source * @param string Item type * @param string Item source * @param int Format (optional) Format type must be defined by the backend @@ -320,7 +319,7 @@ class Share { } /** - * @brief Get the item of item type shared by a link + * Get the item of item type shared by a link * @param string Item type * @param string Item source * @param string Owner of link @@ -332,7 +331,7 @@ class Share { } /** - * @brief Get the item shared by a token + * Get the item shared by a token * @param string token * @return Item */ @@ -357,7 +356,7 @@ class Share { } /** - * @brief resolves reshares down to the last real share + * resolves reshares down to the last real share * @param $linkItem * @return $fileOwner */ @@ -380,7 +379,7 @@ class Share { /** - * @brief Get the shared items of item type owned by the current user + * Get the shared items of item type owned by the current user * @param string Item type * @param int Format (optional) Format type must be defined by the backend * @param int Number of items to return (optional) Returns all by default @@ -393,7 +392,7 @@ class Share { } /** - * @brief Get the shared item of item type owned by the current user + * Get the shared item of item type owned by the current user * @param string Item type * @param string Item source * @param int Format (optional) Format type must be defined by the backend @@ -429,7 +428,7 @@ class Share { } /** - * @brief Share an item with a user, group, or via private link + * Share an item with a user, group, or via private link * @param string Item type * @param string Item source * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK @@ -606,7 +605,7 @@ class Share { } /** - * @brief Unshare an item from a user, group, or delete a private link + * Unshare an item from a user, group, or delete a private link * @param string Item type * @param string Item source * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK @@ -639,7 +638,7 @@ class Share { } /** - * @brief Unshare an item from all users, groups, and remove all links + * Unshare an item from all users, groups, and remove all links * @param string Item type * @param string Item source * @return Returns true on success or false on failure @@ -666,7 +665,7 @@ class Share { } /** - * @brief Unshare an item shared with the current user + * Unshare an item shared with the current user * @param string Item type * @param string Item target * @return Returns true on success or false on failure @@ -703,7 +702,7 @@ class Share { return false; } /** - * @brief sent status if users got informed by mail about share + * sent status if users got informed by mail about share * @param string $itemType * @param string $itemSource * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK @@ -727,7 +726,7 @@ class Share { } /** - * @brief Set the permissions of an item for a specific user or group + * Set the permissions of an item for a specific user or group * @param string Item type * @param string Item source * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK @@ -831,7 +830,7 @@ class Share { } /** - * @brief Get the backend class for the specified item type + * Get the backend class for the specified item type * @param string $itemType * @return Share_Backend */ @@ -860,7 +859,7 @@ class Share { } /** - * @brief Check if resharing is allowed + * Check if resharing is allowed * @return Returns true if allowed or false * * Resharing is allowed by default if not configured @@ -878,7 +877,7 @@ class Share { } /** - * @brief Get a list of collection item types for the specified item type + * Get a list of collection item types for the specified item type * @param string Item type * @return array */ @@ -902,7 +901,7 @@ class Share { } /** - * @brief Get shared items from the database + * Get shared items from the database * @param string Item type * @param string Item source or target (optional) * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, SHARE_TYPE_LINK, $shareTypeUserAndGroups, or $shareTypeGroupUserUnique @@ -1307,7 +1306,7 @@ class Share { } /** - * @brief Put shared item into the database + * Put shared item into the database * @param string Item type * @param string Item source * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK @@ -1543,7 +1542,7 @@ class Share { } /** - * @brief Generate a unique target for the item + * Generate a unique target for the item * @param string Item type * @param string Item source * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK @@ -1659,7 +1658,7 @@ class Share { } /** - * @brief Delete all reshares of an item + * Delete all reshares of an item * @param int Id of item to delete * @param bool If true, exclude the parent from the delete (optional) * @param string The user that the parent was shared with (optinal) @@ -1797,7 +1796,7 @@ class Share { interface Share_Backend { /** - * @brief Get the source of the item to be stored in the database + * Get the source of the item to be stored in the database * @param string Item source * @param string Owner of the item * @return mixed|array|false Source @@ -1810,7 +1809,7 @@ interface Share_Backend { public function isValidSource($itemSource, $uidOwner); /** - * @brief Get a unique name of the item for the specified user + * Get a unique name of the item for the specified user * @param string Item source * @param string|false User the item is being shared with * @param array|null List of similar item names already existing as shared items @@ -1822,7 +1821,7 @@ interface Share_Backend { public function generateTarget($itemSource, $shareWith, $exclude = null); /** - * @brief Converts the shared item sources back into the item in the specified format + * Converts the shared item sources back into the item in the specified format * @param array Shared items * @param int Format * @return ? @@ -1853,10 +1852,7 @@ interface Share_Backend { interface Share_Backend_File_Dependent extends Share_Backend { /** - * @brief Get the file path of the item - * @param - * @param - * @return + * Get the file path of the item */ public function getFilePath($itemSource, $uidOwner); @@ -1869,7 +1865,7 @@ interface Share_Backend_File_Dependent extends Share_Backend { interface Share_Backend_Collection extends Share_Backend { /** - * @brief Get the sources of the children of the item + * Get the sources of the children of the item * @param string Item source * @return array Returns an array of children each inside an array with the keys: source, target, and file_path if applicable */ diff --git a/lib/public/template.php b/lib/public/template.php index a5c500b0e25..cf2dc7766f5 100644 --- a/lib/public/template.php +++ b/lib/public/template.php @@ -32,12 +32,12 @@ namespace OCP; /** - * @brief make OC_Helper::imagePath available as a simple function - * @param $app app - * @param $image image - * @returns link to the image + * Make OC_Helper::imagePath available as a simple function + * @param string app + * @param string image + * @return link to the image * - * For further information have a look at OC_Helper::imagePath + * @see OC_Helper::imagePath */ function image_path( $app, $image ) { return(\image_path( $app, $image )); @@ -45,40 +45,39 @@ function image_path( $app, $image ) { /** - * @brief make OC_Helper::mimetypeIcon available as a simple function - * Returns the path to the image of this file type. - * @param $mimetype mimetype - * @returns link to the image + * Make OC_Helper::mimetypeIcon available as a simple function + * @param string mimetype + * @return path to the image of this file type. */ function mimetype_icon( $mimetype ) { return(\mimetype_icon( $mimetype )); } /** - * @brief make preview_icon available as a simple function - * Returns the path to the preview of the image. - * @param $path path of file - * @returns link to the preview + * Make preview_icon available as a simple function + * @param string path of file + * @return path to the preview of the image */ function preview_icon( $path ) { return(\preview_icon( $path )); } /** - * @brief make publicpreview_icon available as a simple function + * Make publicpreview_icon available as a simple function * Returns the path to the preview of the image. - * @param $path path of file - * @returns link to the preview + * @param string path of file + * @param string token + * @return link to the preview */ function publicPreview_icon ( $path, $token ) { return(\publicPreview_icon( $path, $token )); } /** - * @brief make OC_Helper::humanFileSize available as a simple function - * Makes 2048 to 2 kB. - * @param $bytes size in bytes - * @returns size as string + * Make OC_Helper::humanFileSize available as a simple function + * Example: 2048 to 2 kB. + * @param int size in bytes + * @return size as string */ function human_file_size( $bytes ) { return(\human_file_size( $bytes )); @@ -86,20 +85,21 @@ function human_file_size( $bytes ) { /** - * @brief Return the relative date in relation to today. Returns something like "last hour" or "two month ago" - * @param $timestamp unix timestamp - * @returns human readable interpretation of the timestamp + * Return the relative date in relation to today. Returns something like "last hour" or "two month ago" + * @param int unix timestamp + * @param boolean date only + * @return human readable interpretation of the timestamp */ -function relative_modified_date($timestamp, $dateOnly = false) { +function relative_modified_date( $timestamp, $dateOnly = false ) { return(\relative_modified_date($timestamp, null, $dateOnly)); } /** - * @brief DEPRECATED Return a human readable outout for a file size. + * Return a human readable outout for a file size. * @deprecated human_file_size() instead - * @param $byte size of a file in byte - * @returns human readable interpretation of a file size + * @param integer size of a file in byte + * @return human readable interpretation of a file size */ function simple_file_size($bytes) { return(\human_file_size($bytes)); @@ -107,11 +107,11 @@ function simple_file_size($bytes) { /** - * @brief Generate html code for an options block. + * Generate html code for an options block. * @param $options the options * @param $selected which one is selected? - * @param $params the parameters - * @returns html options + * @param array the parameters + * @return html options */ function html_select_options($options, $selected, $params=array()) { return(\html_select_options($options, $selected, $params)); diff --git a/lib/public/user.php b/lib/public/user.php index 576a64d7048..b4931ecc0fa 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -36,7 +36,7 @@ namespace OCP; */ class User { /** - * @brief get the user id of the user currently logged in. + * Get the user id of the user currently logged in. * @return string uid or false */ public static function getUser() { @@ -44,45 +44,46 @@ class User { } /** - * @brief Get a list of all users - * @returns array with all uids - * - * Get a list of all users. + * Get a list of all users + * @param string search pattern + * @param int limit + * @param int offset + * @return array with all uids */ - public static function getUsers($search = '', $limit = null, $offset = null) { - return \OC_User::getUsers($search, $limit, $offset); + public static function getUsers( $search = '', $limit = null, $offset = null ) { + return \OC_User::getUsers( $search, $limit, $offset ); } /** - * @brief get the user display name of the user currently logged in. + * Get the user display name of the user currently logged in. + * @param string user id or null for current user * @return string display name */ - public static function getDisplayName($user=null) { - return \OC_User::getDisplayName($user); + public static function getDisplayName( $user = null ) { + return \OC_User::getDisplayName( $user ); } /** - * @brief Get a list of all display names - * @returns array with all display names (value) and the correspondig uids (key) - * * Get a list of all display names and user ids. + * @param string search pattern + * @param int limit + * @param int offset + * @return array with all display names (value) and the correspondig uids (key) */ - public static function getDisplayNames($search = '', $limit = null, $offset = null) { - return \OC_User::getDisplayNames($search, $limit, $offset); + public static function getDisplayNames( $search = '', $limit = null, $offset = null ) { + return \OC_User::getDisplayNames( $search, $limit, $offset ); } /** - * @brief Check if the user is logged in - * @returns true/false - * - * Checks if the user is logged in + * Check if the user is logged in + * @return boolean */ public static function isLoggedIn() { return \OC_User::isLoggedIn(); } /** - * @brief check if a user exists + * Check if a user exists * @param string $uid the username * @param string $excludingBackend (default none) * @return boolean @@ -91,7 +92,7 @@ class User { return \OC_User::userExists( $uid, $excludingBackend ); } /** - * @brief Loggs the user out including all the session data + * Logs the user out including all the session data * Logout, destroys session */ public static function logout() { @@ -99,10 +100,10 @@ class User { } /** - * @brief Check if the password is correct - * @param $uid The username - * @param $password The password - * @returns mixed username on success, false otherwise + * Check if the password is correct + * @param string The username + * @param string The password + * @return mixed username on success, false otherwise * * Check if the password is correct without logging in the user */ -- cgit v1.2.3 From f9bbfad3e561c52cd3a7a9002ed9708a87237dc5 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 17 Oct 2013 16:45:11 +0200 Subject: Fix sharing error message - id -> file name fixe #2827 --- lib/public/share.php | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'lib/public/share.php') diff --git a/lib/public/share.php b/lib/public/share.php index 1b6f5d05f10..814c02499f3 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -439,22 +439,31 @@ class Share { public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions) { $uidOwner = \OC_User::getUser(); $sharingPolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global'); + + //retrieve name of file + $fileData = \OC\Files\Filesystem::getFileInfo(\OC\Files\Filesystem::getPath($itemSource)); + if(!is_null($fileData)) { + $itemSourceName = $fileData['name']; + } else { + $itemSourceName = $itemSource; + } + // Verify share type and sharing conditions are met if ($shareType === self::SHARE_TYPE_USER) { if ($shareWith == $uidOwner) { - $message = 'Sharing '.$itemSource.' failed, because the user '.$shareWith.' is the item owner'; + $message = 'Sharing '.$itemSourceName.' failed, because the user '.$shareWith.' is the item owner'; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); } if (!\OC_User::userExists($shareWith)) { - $message = 'Sharing '.$itemSource.' failed, because the user '.$shareWith.' does not exist'; + $message = 'Sharing '.$itemSourceName.' failed, because the user '.$shareWith.' does not exist'; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); } if ($sharingPolicy == 'groups_only') { $inGroup = array_intersect(\OC_Group::getUserGroups($uidOwner), \OC_Group::getUserGroups($shareWith)); if (empty($inGroup)) { - $message = 'Sharing '.$itemSource.' failed, because the user ' + $message = 'Sharing '.$itemSourceName.' failed, because the user ' .$shareWith.' is not a member of any groups that '.$uidOwner.' is a member of'; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); @@ -467,19 +476,19 @@ class Share { // owner and is not a user share, this use case is for increasing // permissions for a specific user if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) { - $message = 'Sharing '.$itemSource.' failed, because this item is already shared with '.$shareWith; + $message = 'Sharing '.$itemSourceName.' failed, because this item is already shared with '.$shareWith; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); } } } else if ($shareType === self::SHARE_TYPE_GROUP) { if (!\OC_Group::groupExists($shareWith)) { - $message = 'Sharing '.$itemSource.' failed, because the group '.$shareWith.' does not exist'; + $message = 'Sharing '.$itemSourceName.' failed, because the group '.$shareWith.' does not exist'; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); } if ($sharingPolicy == 'groups_only' && !\OC_Group::inGroup($uidOwner, $shareWith)) { - $message = 'Sharing '.$itemSource.' failed, because ' + $message = 'Sharing '.$itemSourceName.' failed, because ' .$uidOwner.' is not a member of the group '.$shareWith; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); @@ -492,7 +501,7 @@ class Share { // owner and is not a group share, this use case is for increasing // permissions for a specific user if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) { - $message = 'Sharing '.$itemSource.' failed, because this item is already shared with '.$shareWith; + $message = 'Sharing '.$itemSourceName.' failed, because this item is already shared with '.$shareWith; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); } @@ -541,7 +550,7 @@ class Share { return false; } } - $message = 'Sharing '.$itemSource.' failed, because sharing with links is not allowed'; + $message = 'Sharing '.$itemSourceName.' failed, because sharing with links is not allowed'; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); return false; @@ -1318,18 +1327,27 @@ class Share { private static function put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, $parentFolder = null, $token = null) { $backend = self::getBackend($itemType); + // Check if this is a reshare if ($checkReshare = self::getItemSharedWithBySource($itemType, $itemSource, self::FORMAT_NONE, null, true)) { + //retrieve name of file + $fileData = \OC\Files\Filesystem::getFileInfo(\OC\Files\Filesystem::getPath($itemSource)); + if(!is_null($fileData)) { + $itemSourceName = $fileData['name']; + } else { + $itemSourceName = $itemSource; + } + // Check if attempting to share back to owner if ($checkReshare['uid_owner'] == $shareWith && $shareType == self::SHARE_TYPE_USER) { - $message = 'Sharing '.$itemSource.' failed, because the user '.$shareWith.' is the original sharer'; + $message = 'Sharing '.$itemSourceName.' failed, because the user '.$shareWith.' is the original sharer'; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); } // Check if share permissions is granted if (self::isResharingAllowed() && (int)$checkReshare['permissions'] & PERMISSION_SHARE) { if (~(int)$checkReshare['permissions'] & $permissions) { - $message = 'Sharing '.$itemSource + $message = 'Sharing '.$itemSourceName .' failed, because the permissions exceed permissions granted to '.$uidOwner; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); @@ -1343,7 +1361,7 @@ class Share { $filePath = $checkReshare['file_target']; } } else { - $message = 'Sharing '.$itemSource.' failed, because resharing is not allowed'; + $message = 'Sharing '.$itemSourceName.' failed, because resharing is not allowed'; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); } -- cgit v1.2.3 From 4cf328e3b941139f3a41a8a3631f3c74544eb094 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Wed, 1 May 2013 21:15:32 -0400 Subject: Don't return links for shared files if disabled --- lib/public/share.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/public/share.php') diff --git a/lib/public/share.php b/lib/public/share.php index 1b6f5d05f10..2847f9e5ec9 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -960,6 +960,10 @@ class Share { $queryArgs = array($itemType); } } + if (\OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { + $where .= ' AND `share_type` != ?'; + $queryArgs[] = self::SHARE_TYPE_LINK; + } if (isset($shareType)) { // Include all user and group items if ($shareType == self::$shareTypeUserAndGroups && isset($shareWith)) { -- cgit v1.2.3 From 1f1fcc61298e1ce8b32a16824da0e44671bb30f5 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 18 Oct 2013 11:37:13 +0200 Subject: Remove "link" shares right after disabling the "allow_link_share" setting --- apps/files_sharing/appinfo/app.php | 2 ++ apps/files_sharing/lib/maintainer.php | 44 +++++++++++++++++++++++++++++++++++ lib/private/appconfig.php | 6 +++++ lib/public/share.php | 12 ++++++++++ 4 files changed, 64 insertions(+) create mode 100644 apps/files_sharing/lib/maintainer.php (limited to 'lib/public/share.php') diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php index ffdcbf05109..bdaea64bb90 100644 --- a/apps/files_sharing/appinfo/app.php +++ b/apps/files_sharing/appinfo/app.php @@ -8,6 +8,7 @@ OC::$CLASSPATH['OC\Files\Cache\Shared_Permissions'] = 'files_sharing/lib/permiss OC::$CLASSPATH['OC\Files\Cache\Shared_Updater'] = 'files_sharing/lib/updater.php'; OC::$CLASSPATH['OC\Files\Cache\Shared_Watcher'] = 'files_sharing/lib/watcher.php'; OC::$CLASSPATH['OCA\Files\Share\Api'] = 'files_sharing/lib/api.php'; +OC::$CLASSPATH['OCA\Files\Share\Maintainer'] = 'files_sharing/lib/maintainer.php'; OCP\Util::connectHook('OC_Filesystem', 'setup', '\OC\Files\Storage\Shared', 'setup'); OCP\Share::registerBackend('file', 'OC_Share_Backend_File'); OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file'); @@ -17,3 +18,4 @@ OCP\Util::addScript('files_sharing', 'share'); \OC_Hook::connect('OC_Filesystem', 'post_rename', '\OC\Files\Cache\Shared_Updater', 'renameHook'); \OC_Hook::connect('OCP\Share', 'post_shared', '\OC\Files\Cache\Shared_Updater', 'shareHook'); \OC_Hook::connect('OCP\Share', 'pre_unshare', '\OC\Files\Cache\Shared_Updater', 'shareHook'); +\OC_Hook::connect('OC_Appconfig', 'post_set_value', '\OCA\Files\Share\Maintainer', 'configChangeHook'); diff --git a/apps/files_sharing/lib/maintainer.php b/apps/files_sharing/lib/maintainer.php new file mode 100644 index 00000000000..bbb3268410e --- /dev/null +++ b/apps/files_sharing/lib/maintainer.php @@ -0,0 +1,44 @@ +. + */ + +namespace OCA\Files\Share; + +/** + * Maintains stuff around the sharing functionality + * + * for example: on disable of "allow links" it removes all link shares + */ + +class Maintainer { + + /** + * Keeps track of the "allow links" config setting + * and removes all link shares if the config option is set to "no" + * + * @param array with app, key, value as named values + */ + static public function configChangeHook($params) { + if($params['app'] === 'core' && $params['key'] === 'shareapi_allow_links' && $params['value'] === 'no') { + \OCP\Share::removeAllLinkShares(); + } + } + +} diff --git a/lib/private/appconfig.php b/lib/private/appconfig.php index e615d838173..4f170e054e9 100644 --- a/lib/private/appconfig.php +++ b/lib/private/appconfig.php @@ -134,6 +134,12 @@ class OC_Appconfig{ .' WHERE `appid` = ? AND `configkey` = ?' ); $query->execute( array( $value, $app, $key )); } + // TODO where should this be documented? + \OC_Hook::emit('OC_Appconfig', 'post_set_value', array( + 'app' => $app, + 'key' => $key, + 'value' => $value + )); } /** diff --git a/lib/public/share.php b/lib/public/share.php index 2847f9e5ec9..59150e1964f 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -1721,6 +1721,18 @@ class Share { } } + /** + * Delete all shares with type SHARE_TYPE_LINK + */ + public static function removeAllLinkShares() { + // Delete any link shares + $query = \OC_DB::prepare('SELECT `id` FROM `*PREFIX*share` WHERE `share_type` = ?'); + $result = $query->execute(array(self::SHARE_TYPE_LINK)); + while ($item = $result->fetchRow()) { + self::delete($item['id']); + } + } + /** * Hook Listeners */ -- cgit v1.2.3 From 1317b7c03dbbd98165ef29b50aa26bb1dd283cba Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Wed, 23 Oct 2013 18:39:37 +0200 Subject: pass the name of the item source from the browser to the server - no need to get the data via complicated db queries --- apps/files_sharing/js/share.js | 4 ++-- core/ajax/share.php | 3 ++- core/js/share.js | 24 ++++++++++++++++++----- lib/public/share.php | 44 +++++++++++++++++++----------------------- 4 files changed, 43 insertions(+), 32 deletions(-) (limited to 'lib/public/share.php') diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 68f6f3ba76f..340e0939445 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -35,14 +35,14 @@ $(document).ready(function() { if ($(tr).data('id') != $('#dropdown').attr('data-item-source')) { OC.Share.hideDropDown(function () { $(tr).addClass('mouseOver'); - OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions); + OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions, filename); }); } else { OC.Share.hideDropDown(); } } else { $(tr).addClass('mouseOver'); - OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions); + OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions, filename); } }); } diff --git a/core/ajax/share.php b/core/ajax/share.php index 0dacc17d3a5..be02c056357 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -41,7 +41,8 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo $_POST['itemSource'], $shareType, $shareWith, - $_POST['permissions'] + $_POST['permissions'], + $_POST['itemSourceName'] ); if (is_string($token)) { diff --git a/core/js/share.js b/core/js/share.js index 281cccaaef8..352ad4d4ca8 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -136,8 +136,17 @@ OC.Share={ return data; }, - share:function(itemType, itemSource, shareType, shareWith, permissions, callback) { - $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'share', itemType: itemType, itemSource: itemSource, shareType: shareType, shareWith: shareWith, permissions: permissions }, function(result) { + share:function(itemType, itemSource, shareType, shareWith, permissions, itemSourceName, callback) { + $.post(OC.filePath('core', 'ajax', 'share.php'), + { + action: 'share', + itemType: itemType, + itemSource: itemSource, + shareType: shareType, + shareWith: shareWith, + permissions: permissions, + itemSourceName: itemSourceName + }, function (result) { if (result && result.status === 'success') { if (callback) { callback(result.data); @@ -170,9 +179,9 @@ OC.Share={ } }); }, - showDropDown:function(itemType, itemSource, appendTo, link, possiblePermissions) { + showDropDown:function(itemType, itemSource, appendTo, link, possiblePermissions, filename) { var data = OC.Share.loadItem(itemType, itemSource); - var html = '