diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-10-26 22:32:44 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-10-26 22:32:44 +0200 |
commit | 4b616764e825022e9394a4cb26af2012276285b4 (patch) | |
tree | cf43a37a9fb7c3a1b96561f0556a2fbe2f9000ca /lib | |
parent | c22a723785f80671548b89c543e9163c2fff9264 (diff) | |
parent | 1313cad1b98949195c6aca83a2006d4cc058fc45 (diff) | |
download | nextcloud-server-4b616764e825022e9394a4cb26af2012276285b4.tar.gz nextcloud-server-4b616764e825022e9394a4cb26af2012276285b4.zip |
Merge branch 'master' into filesystem
Diffstat (limited to 'lib')
-rw-r--r-- | lib/helper.php | 13 | ||||
-rw-r--r-- | lib/public/share.php | 31 |
2 files changed, 34 insertions, 10 deletions
diff --git a/lib/helper.php b/lib/helper.php index 00b974543ad..aa453ad7504 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -373,20 +373,15 @@ class OC_Helper { } if (!$isWrapped and $mimeType=='application/octet-stream' && OC_Helper::canExecute("file")) { // it looks like we have a 'file' command, - // lets see it it does have mime support + // lets see if it does have mime support $path=escapeshellarg($path); $fp = popen("file -i -b $path 2>/dev/null", "r"); $reply = fgets($fp); pclose($fp); - //trim the character set from the end of the response - $mimeType=substr($reply,0, strrpos($reply,' ')); - $mimeType=substr($mimeType,0, strrpos($mimeType,"\n")); - - //trim ; - if (strpos($mimeType, ';') !== false) { - $mimeType = strstr($mimeType, ';', true); - } + // we have smth like 'text/x-c++; charset=us-ascii\n' + // and need to eliminate everything starting with semicolon including trailing LF + $mimeType = preg_replace('/;.*/ms', '', trim($reply)); } return $mimeType; diff --git a/lib/public/share.php b/lib/public/share.php index d27802b52f7..7a9a087d1bd 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -28,6 +28,9 @@ namespace OCP; /** * This class provides the ability for apps to share their content between users. * Apps must create a backend class that implements OCP\Share_Backend and register it with this class. +* +* It provides the following hooks: +* - post_shared */ class Share { @@ -937,7 +940,20 @@ 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'); + $id = \OC_DB::insertid('*PREFIX*share'); + \OC_Hook::emit('OCP\Share', 'post_shared', array( + 'itemType' => $itemType, + 'itemSource' => $itemSource, + 'itemTarget' => $itemTarget, + 'parent' => $parent, + 'shareType' => self::$shareTypeGroupUserUnique, + 'shareWith' => $uid, + 'uidOwner' => $uidOwner, + 'permissions' => $permissions, + 'fileSource' => $fileSource, + 'fileTarget' => $fileTarget, + 'id' => $id + )); } } if ($parentFolder === true) { @@ -963,6 +979,19 @@ class Share { } $query->execute(array($itemType, $itemSource, $itemTarget, $parent, $shareType, $shareWith, $uidOwner, $permissions, time(), $fileSource, $fileTarget)); $id = \OC_DB::insertid('*PREFIX*share'); + \OC_Hook::emit('OCP\Share', 'post_shared', array( + 'itemType' => $itemType, + 'itemSource' => $itemSource, + 'itemTarget' => $itemTarget, + 'parent' => $parent, + 'shareType' => $shareType, + 'shareWith' => $shareWith, + 'uidOwner' => $uidOwner, + 'permissions' => $permissions, + 'fileSource' => $fileSource, + 'fileTarget' => $fileTarget, + 'id' => $id + )); if ($parentFolder === true) { $parentFolders['id'] = $id; // Return parent folder to preserve file target paths for potential children |