diff options
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/app.php | 18 | ||||
-rw-r--r-- | lib/public/backgroundjob.php | 14 | ||||
-rw-r--r-- | lib/public/config.php | 12 | ||||
-rw-r--r-- | lib/public/db.php | 10 | ||||
-rw-r--r-- | lib/public/files.php | 12 | ||||
-rw-r--r-- | lib/public/json.php | 16 | ||||
-rw-r--r-- | lib/public/share.php | 127 | ||||
-rw-r--r-- | lib/public/template.php | 6 | ||||
-rw-r--r-- | lib/public/user.php | 16 | ||||
-rw-r--r-- | lib/public/util.php | 38 |
10 files changed, 155 insertions, 114 deletions
diff --git a/lib/public/app.php b/lib/public/app.php index be38bbff98a..eb824f043e9 100644 --- a/lib/public/app.php +++ b/lib/public/app.php @@ -45,7 +45,7 @@ class App { * It'll remain in our public API for compatibility reasons * */ - public static function register( $data ){ + public static function register( $data ) { return true; // don't do anything } @@ -66,7 +66,7 @@ class App { * - order: integer, that influences the position of your application in * the navigation. Lower values come first. */ - public static function addNavigationEntry( $data ){ + public static function addNavigationEntry( $data ) { return \OC_App::addNavigationEntry( $data ); } @@ -80,7 +80,7 @@ class App { * property from all other entries. The templates can use this for * highlighting the current position of the user. */ - public static function setActiveNavigationEntry( $id ){ + public static function setActiveNavigationEntry( $id ) { return \OC_App::setActiveNavigationEntry( $id ); } @@ -90,7 +90,7 @@ class App { * @param $app string appid * @param $page string page to be included */ - public static function registerPersonal( $app, $page ){ + public static function registerPersonal( $app, $page ) { return \OC_App::registerPersonal( $app, $page ); } @@ -100,7 +100,7 @@ class App { * @param $app string appid * @param $page string page to be included */ - public static function registerAdmin( $app, $page ){ + public static function registerAdmin( $app, $page ) { return \OC_App::registerAdmin( $app, $page ); } @@ -111,7 +111,7 @@ class App { * @param boolean path (optional) * @returns array */ - public static function getAppInfo( $app, $path=false ){ + public static function getAppInfo( $app, $path=false ) { return \OC_App::getAppInfo( $app, $path); } @@ -124,7 +124,7 @@ class App { * * This function checks whether or not an app is enabled. */ - public static function isEnabled( $app ){ + public static function isEnabled( $app ) { return \OC_App::isEnabled( $app ); } @@ -134,7 +134,7 @@ class App { * @param $app app * @returns true/false */ - public static function checkAppEnabled( $app ){ + public static function checkAppEnabled( $app ) { return \OC_Util::checkAppEnabled( $app ); } @@ -144,7 +144,7 @@ class App { * @param $app app * @returns true/false */ - public static function getAppVersion( $app ){ + public static function getAppVersion( $app ) { return \OC_App::getAppVersion( $app ); } diff --git a/lib/public/backgroundjob.php b/lib/public/backgroundjob.php index 2962346dbc9..aba7d2b7620 100644 --- a/lib/public/backgroundjob.php +++ b/lib/public/backgroundjob.php @@ -52,7 +52,7 @@ class BackgroundJob { * @param $method method name * @return true */ - public static function addRegularTask( $klass, $method ){ + public static function addRegularTask( $klass, $method ) { return \OC_BackgroundJob_RegularTask::register( $klass, $method ); } @@ -62,7 +62,7 @@ class BackgroundJob { * * key is string "$klass-$method", value is array( $klass, $method ) */ - static public function allRegularTasks(){ + static public function allRegularTasks() { return \OC_BackgroundJob_RegularTask::all(); } @@ -71,7 +71,7 @@ class BackgroundJob { * @param $id ID of the task * @return associative array */ - public static function findQueuedTask( $id ){ + public static function findQueuedTask( $id ) { return \OC_BackgroundJob_QueuedTask::find( $id ); } @@ -79,7 +79,7 @@ class BackgroundJob { * @brief Gets all queued tasks * @return array with associative arrays */ - public static function allQueuedTasks(){ + public static function allQueuedTasks() { return \OC_BackgroundJob_QueuedTask::all(); } @@ -88,7 +88,7 @@ class BackgroundJob { * @param $app app name * @return array with associative arrays */ - public static function queuedTaskWhereAppIs( $app ){ + public static function queuedTaskWhereAppIs( $app ) { return \OC_BackgroundJob_QueuedTask::whereAppIs( $app ); } @@ -100,7 +100,7 @@ class BackgroundJob { * @param $parameters all useful data as text * @return id of task */ - public static function addQueuedTask( $app, $klass, $method, $parameters ){ + public static function addQueuedTask( $app, $klass, $method, $parameters ) { return \OC_BackgroundJob_QueuedTask::add( $app, $klass, $method, $parameters ); } @@ -111,7 +111,7 @@ class BackgroundJob { * * Deletes a report */ - public static function deleteQueuedTask( $id ){ + public static function deleteQueuedTask( $id ) { return \OC_BackgroundJob_QueuedTask::delete( $id ); } } diff --git a/lib/public/config.php b/lib/public/config.php index f3120b9aaa2..fa9658e7288 100644 --- a/lib/public/config.php +++ b/lib/public/config.php @@ -49,7 +49,7 @@ class Config { * This function gets the value from config.php. If it does not exist, * $default will be returned. */ - public static function getSystemValue( $key, $default = null ){ + public static function getSystemValue( $key, $default = null ) { return(\OC_Config::getValue( $key, $default )); } @@ -63,7 +63,7 @@ class Config { * This function sets the value and writes the config.php. If the file can * not be written, false will be returned. */ - public static function setSystemValue( $key, $value ){ + public static function setSystemValue( $key, $value ) { return(\OC_Config::setValue( $key, $value )); } @@ -78,7 +78,7 @@ class Config { * 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 ){ + public static function getAppValue( $app, $key, $default = null ) { return(\OC_Appconfig::getValue( $app, $key, $default )); } @@ -92,7 +92,7 @@ class Config { * * Sets a value. If the key did not exist before it will be created. */ - public static function setAppValue( $app, $key, $value ){ + public static function setAppValue( $app, $key, $value ) { return(\OC_Appconfig::setValue( $app, $key, $value )); } @@ -108,7 +108,7 @@ class Config { * 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 ){ + public static function getUserValue( $user, $app, $key, $default = null ) { return(\OC_Preferences::getValue( $user, $app, $key, $default )); } @@ -124,7 +124,7 @@ class Config { * 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 ){ + 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 e1da62e2d27..5ac356bb475 100644 --- a/lib/public/db.php +++ b/lib/public/db.php @@ -43,7 +43,7 @@ class DB { * * SQL query via MDB2 prepare(), needs to be execute()'d! */ - static public function prepare( $query, $limit=null, $offset=null ){ + static public function prepare( $query, $limit=null, $offset=null ) { return(\OC_DB::prepare($query,$limit,$offset)); } @@ -58,7 +58,7 @@ class DB { * Call this method right after the insert command or other functions may * cause trouble! */ - public static function insertid($table=null){ + public static function insertid($table=null) { return(\OC_DB::insertid($table)); } @@ -66,7 +66,7 @@ class DB { /** * @brief Start a transaction */ - public static function beginTransaction(){ + public static function beginTransaction() { return(\OC_DB::beginTransaction()); } @@ -74,7 +74,7 @@ class DB { /** * @brief Commit the database changes done during a transaction that is in progress */ - public static function commit(){ + public static function commit() { return(\OC_DB::commit()); } @@ -84,7 +84,7 @@ class DB { * @param mixed $result * @return bool */ - public static function isError($result){ + public static function isError($result) { return(\OC_DB::isError($result)); } diff --git a/lib/public/files.php b/lib/public/files.php index be5952d362a..2f4f459bd91 100644 --- a/lib/public/files.php +++ b/lib/public/files.php @@ -52,7 +52,7 @@ class Files { * @return string * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead */ - static function getMimeType( $path ){ + static function getMimeType( $path ) { return(\OC_Helper::getMimeType( $path )); } @@ -63,7 +63,7 @@ class Files { * @param resource target * @return int the number of bytes copied */ - public static function streamCopy( $source, $target ){ + public static function streamCopy( $source, $target ) { return(\OC_Helper::streamCopy( $source, $target )); } @@ -75,7 +75,7 @@ class Files { * * temporary files are automatically cleaned up after the script is finished */ - public static function tmpFile( $postfix='' ){ + public static function tmpFile( $postfix='' ) { return(\OC_Helper::tmpFile( $postfix )); } @@ -86,7 +86,7 @@ class Files { * * temporary files are automatically cleaned up after the script is finished */ - public static function tmpFolder(){ + public static function tmpFolder() { return(\OC_Helper::tmpFolder()); } @@ -98,7 +98,7 @@ class Files { * @param $filename * @return string */ - public static function buildNotExistingFileName( $path, $filename ){ + public static function buildNotExistingFileName( $path, $filename ) { return(\OC_Helper::buildNotExistingFileName( $path, $filename )); } @@ -107,7 +107,7 @@ class Files { * @param $app app * @return OC_FilesystemView */ - public static function getStorage( $app ){ + public static function getStorage( $app ) { return \OC_App::getStorage( $app ); } diff --git a/lib/public/json.php b/lib/public/json.php index c37b42c3f74..93be920c6d7 100644 --- a/lib/public/json.php +++ b/lib/public/json.php @@ -41,7 +41,7 @@ class JSON { * @param string $setContentType the optional content type * @return string json formatted string. */ - public static function encodedPrint( $data, $setContentType=true ){ + public static function encodedPrint( $data, $setContentType=true ) { return(\OC_JSON::encodedPrint( $data, $setContentType )); } @@ -60,7 +60,7 @@ class JSON { * * @return string json formatted error string if not authenticated. */ - public static function checkLoggedIn(){ + public static function checkLoggedIn() { return(\OC_JSON::checkLoggedIn()); } @@ -84,7 +84,7 @@ class JSON { * * @return string json formatted error string if not valid. */ - public static function callCheck(){ + public static function callCheck() { return(\OC_JSON::callCheck()); } @@ -97,7 +97,7 @@ class JSON { * @param array $data The data to use * @return string json formatted string. */ - public static function success( $data = array() ){ + public static function success( $data = array() ) { return(\OC_JSON::success( $data )); } @@ -119,7 +119,7 @@ class JSON { * @param array $data The data to use * @return string json formatted error string. */ - public static function error( $data = array() ){ + public static function error( $data = array() ) { return(\OC_JSON::error( $data )); } @@ -128,7 +128,7 @@ class JSON { * @param array $type The contwnt type header * @return string json formatted string. */ - public static function setContentTypeHeader( $type='application/json' ){ + public static function setContentTypeHeader( $type='application/json' ) { return(\OC_JSON::setContentTypeHeader( $type )); } @@ -148,7 +148,7 @@ class JSON { * @param string $app The app to check * @return string json formatted string if not enabled. */ - public static function checkAppEnabled( $app ){ + public static function checkAppEnabled( $app ) { return(\OC_JSON::checkAppEnabled( $app )); } @@ -167,7 +167,7 @@ class JSON { * * @return string json formatted string if not admin user. */ - public static function checkAdminUser(){ + public static function checkAdminUser() { return(\OC_JSON::checkAdminUser()); } diff --git a/lib/public/share.php b/lib/public/share.php index 9ad0f0f68f6..cf61681424f 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -23,6 +23,7 @@ namespace OCP; \OC_Hook::connect('OC_User', 'post_deleteUser', 'OCP\Share', 'post_deleteUser'); \OC_Hook::connect('OC_User', 'post_addToGroup', 'OCP\Share', 'post_addToGroup'); \OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OCP\Share', 'post_removeFromGroup'); +\OC_Hook::connect('OC_User', 'post_deleteGroup', 'OCP\Share', 'post_deleteGroup'); /** * This class provides the ability for apps to share their content between users. @@ -339,7 +340,7 @@ class Share { // TODO } // Delete - return self::delete($item['id'], true); + return self::delete($item['id']); } return false; } @@ -357,7 +358,7 @@ class Share { if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith, \OC_User::getUser(), self::FORMAT_NONE, null, 1, false)) { // Check if this item is a reshare and verify that the permissions granted don't exceed the parent shared item if (isset($item['parent'])) { - $query = \OC_DB::prepare('SELECT `permissions` FROM `*PREFIX*share` WHERE `id` = ?',1); + $query = \OC_DB::prepare('SELECT `permissions` FROM `*PREFIX*share` WHERE `id` = ?', 1); $result = $query->execute(array($item['parent']))->fetchRow(); if (~(int)$result['permissions'] & $permissions) { $message = 'Setting permissions for '.$itemSource.' failed, because the permissions exceed permissions granted to '.\OC_User::getUser(); @@ -563,6 +564,7 @@ class Share { } else { if ($itemType == 'file' || $itemType == 'folder') { $where .= ' `file_target` = ?'; + $item = \OC_Filesystem::normalizePath($item); } else { $where .= ' `item_target` = ?'; } @@ -762,9 +764,9 @@ class Share { // TODO Don't check if inside folder $parent = $checkReshare['id']; $itemSource = $checkReshare['item_source']; - // TODO Suggest item/file target - $suggestedItemTarget = $checkReshare['item_target']; $fileSource = $checkReshare['file_source']; + $suggestedItemTarget = $checkReshare['item_target']; + $suggestedFileTarget = $checkReshare['file_target']; $filePath = $checkReshare['file_target']; } } else { @@ -774,6 +776,8 @@ class Share { } } else { $parent = null; + $suggestedItemTarget = null; + $suggestedFileTarget = null; if (!$backend->isValidSource($itemSource, $uidOwner)) { $message = 'Sharing '.$itemSource.' failed, because the sharing backend for '.$itemType.' could not find its source'; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); @@ -782,7 +786,7 @@ class Share { $parent = null; if ($backend instanceof Share_Backend_File_Dependent) { $filePath = $backend->getFilePath($itemSource, $uidOwner); - if ($itemType == 'file' && $itemType == 'folder') { + if ($itemType == 'file' || $itemType == 'folder') { $fileSource = $itemSource; } else { $fileSource = \OC_FileCache::getId($filePath); @@ -800,35 +804,34 @@ class Share { $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`, `item_target`, `parent`, `share_type`, `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`, `file_target`) VALUES (?,?,?,?,?,?,?,?,?,?,?)'); // Share with a group if ($shareType == self::SHARE_TYPE_GROUP) { + $groupItemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith['group'], $uidOwner, $suggestedItemTarget); if (isset($fileSource)) { if ($parentFolder) { if ($parentFolder === true) { - $groupFileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith['group'], $uidOwner); + $groupFileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith['group'], $uidOwner, $suggestedFileTarget); // Set group default file target for future use $parentFolders[0]['folder'] = $groupFileTarget; } else { // Get group default file target $groupFileTarget = $parentFolder[0]['folder'].$itemSource; $parent = $parentFolder[0]['id']; - unset($parentFolder[0]); - // Only loop through users we know have different file target paths - $uidSharedWith = array_keys($parentFolder); } } else { - $groupFileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith['group'], $uidOwner); + $groupFileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith['group'], $uidOwner, $suggestedFileTarget); } } else { $groupFileTarget = null; } - $groupItemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith['group'], $uidOwner); - $uniqueTargets = array(); + $query->execute(array($itemType, $itemSource, $groupItemTarget, $parent, $shareType, $shareWith['group'], $uidOwner, $permissions, time(), $fileSource, $groupFileTarget)); + // Save this id, any extra rows for this group share will need to reference it + $parent = \OC_DB::insertid('*PREFIX*share'); // Loop through all users of this group in case we need to add an extra row foreach ($shareWith['users'] as $uid) { - $itemTarget = self::generateTarget($itemType, $itemSource, self::SHARE_TYPE_USER, $uid, $uidOwner); + $itemTarget = self::generateTarget($itemType, $itemSource, self::SHARE_TYPE_USER, $uid, $uidOwner, $suggestedItemTarget, $parent); if (isset($fileSource)) { if ($parentFolder) { if ($parentFolder === true) { - $fileTarget = self::generateTarget('file', $filePath, self::SHARE_TYPE_USER, $uid, $uidOwner); + $fileTarget = self::generateTarget('file', $filePath, self::SHARE_TYPE_USER, $uid, $uidOwner, $suggestedFileTarget, $parent); if ($fileTarget != $groupFileTarget) { $parentFolders[$uid]['folder'] = $fileTarget; } @@ -837,24 +840,14 @@ class Share { $parent = $parentFolder[$uid]['id']; } } else { - $fileTarget = self::generateTarget('file', $filePath, self::SHARE_TYPE_USER, $uid, $uidOwner); + $fileTarget = self::generateTarget('file', $filePath, self::SHARE_TYPE_USER, $uid, $uidOwner, $suggestedFileTarget, $parent); } } else { $fileTarget = null; } // Insert an extra row for the group share if the item or file target is unique for this user if ($itemTarget != $groupItemTarget || (isset($fileSource) && $fileTarget != $groupFileTarget)) { - $uniqueTargets[] = array('uid' => $uid, 'item_target' => $itemTarget, 'file_target' => $fileTarget); - } - } - $query->execute(array($itemType, $itemSource, $groupItemTarget, $parent, $shareType, $shareWith['group'], $uidOwner, $permissions, time(), $fileSource, $groupFileTarget)); - // Save this id, any extra rows for this group share will need to reference it - $parent = \OC_DB::insertid('*PREFIX*share'); - foreach ($uniqueTargets as $unique) { - $query->execute(array($itemType, $itemSource, $unique['item_target'], $parent, self::$shareTypeGroupUserUnique, $unique['uid'], $uidOwner, $permissions, time(), $fileSource, $unique['file_target'])); - $id = \OC_DB::insertid('*PREFIX*share'); - if ($parentFolder === true) { - $parentFolders['id'] = $id; + $query->execute(array($itemType, $itemSource, $itemTarget, $parent, self::$shareTypeGroupUserUnique, $uid, $uidOwner, $permissions, time(), $fileSource, $fileTarget)); } } if ($parentFolder === true) { @@ -862,18 +855,18 @@ class Share { return $parentFolders; } } else { - $itemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner); + $itemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $suggestedItemTarget); if (isset($fileSource)) { if ($parentFolder) { if ($parentFolder === true) { - $fileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith, $uidOwner); + $fileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith, $uidOwner, $suggestedFileTarget); $parentFolders['folder'] = $fileTarget; } else { $fileTarget = $parentFolder['folder'].$itemSource; $parent = $parentFolder['id']; } } else { - $fileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith, $uidOwner); + $fileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith, $uidOwner, $suggestedFileTarget); } } else { $fileTarget = null; @@ -895,14 +888,16 @@ class Share { * @param string Item source * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK * @param string User or group the item is being shared with + * @param string The suggested target originating from a reshare (optional) + * @param int The id of the parent group share (optional) * @return string Item target - * - * TODO Use a suggested item target by default - * */ - private static function generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner) { + private static function generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $suggestedTarget = null, $groupParent = null) { $backend = self::getBackend($itemType); if ($shareType == self::SHARE_TYPE_LINK) { + if (isset($suggestedTarget)) { + return $suggestedTarget; + } return $backend->generateTarget($itemSource, false); } else { if ($itemType == 'file' || $itemType == 'folder') { @@ -920,19 +915,35 @@ class Share { $exclude = null; // Backend has 3 opportunities to generate a unique target for ($i = 0; $i < 2; $i++) { - if ($shareType == self::SHARE_TYPE_GROUP) { - $target = $backend->generateTarget($itemSource, false, $exclude); + // Check if suggested target exists first + if ($i == 0 && isset($suggestedTarget)) { + $target = $suggestedTarget; } else { - $target = $backend->generateTarget($itemSource, $shareWith, $exclude); - } - if (is_array($exclude) && in_array($target, $exclude)) { - break; + if ($shareType == self::SHARE_TYPE_GROUP) { + $target = $backend->generateTarget($itemSource, false, $exclude); + } else { + $target = $backend->generateTarget($itemSource, $shareWith, $exclude); + } + if (is_array($exclude) && in_array($target, $exclude)) { + break; + } } // Check if target already exists - if ($checkTarget = self::getItems($itemType, $target, $shareType, $shareWith, null, self::FORMAT_NONE, null, 1)) { - // If matching target is from the same owner, use the same target. The share type will be different so this isn't the same share. - if ($checkTarget['uid_owner'] == $uidOwner) { - return $target; + $checkTarget = self::getItems($itemType, $target, $shareType, $shareWith); + if (!empty($checkTarget)) { + foreach ($checkTarget as $item) { + // Skip item if it is the group parent row + if (isset($groupParent) && $item['id'] == $groupParent) { + if (count($checkTarget) == 1) { + return $target; + } else { + continue; + } + } + // If matching target is from the same owner, use the same target. The share type will be different so this isn't the same share. + if ($item['uid_owner'] == $uidOwner) { + return $target; + } } if (!isset($exclude)) { $exclude = array(); @@ -1023,7 +1034,27 @@ class Share { } public static function post_addToGroup($arguments) { - // TODO + // Find the group shares and check if the user needs a unique target + $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `share_type` = ? AND `share_with` = ?'); + $result = $query->execute(array(self::SHARE_TYPE_GROUP, $arguments['gid'])); + $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`, `item_target`, `parent`, `share_type`, `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`, `file_target`) VALUES (?,?,?,?,?,?,?,?,?,?,?)'); + while ($item = $result->fetchRow()) { + if ($item['item_type'] == 'file' || $item['item_type'] == 'file') { + $itemTarget = null; + } else { + $itemTarget = self::generateTarget($item['item_type'], $item['item_source'], self::SHARE_TYPE_USER, $arguments['uid'], $item['uid_owner'], $item['item_target'], $item['id']); + } + if (isset($item['file_source'])) { + $fileTarget = self::generateTarget($item['item_type'], $item['item_source'], self::SHARE_TYPE_USER, $arguments['uid'], $item['uid_owner'], $item['file_target'], $item['id']); + } else { + $fileTarget = null; + } + // Insert an extra row for the group share if the item or file target is unique for this user + if ($itemTarget != $item['item_target'] || $fileTarget != $item['file_target']) { + $query->execute(array($item['item_type'], $item['item_source'], $itemTarget, $item['id'], self::$shareTypeGroupUserUnique, $arguments['uid'], $item['uid_owner'], $item['permissions'], $item['stime'], $item['file_source'], $fileTarget)); + \OC_DB::insertid('*PREFIX*share'); + } + } } public static function post_removeFromGroup($arguments) { @@ -1040,6 +1071,14 @@ class Share { } } + public static function post_deleteGroup($arguments) { + $query = \OC_DB::prepare('SELECT id FROM `*PREFIX*share` WHERE `share_type` = ? AND `share_with` = ?'); + $result = $query->execute(array(self::SHARE_TYPE_GROUP, $arguments['gid'])); + while ($item = $result->fetchRow()) { + self::delete($item['id']); + } + } + } /** diff --git a/lib/public/template.php b/lib/public/template.php index 11c740d13ac..4cda3650866 100644 --- a/lib/public/template.php +++ b/lib/public/template.php @@ -39,7 +39,7 @@ namespace OCP; * * For further information have a look at OC_Helper::imagePath */ -function image_path( $app, $image ){ +function image_path( $app, $image ) { return(\image_path( $app, $image )); } @@ -50,7 +50,7 @@ function image_path( $app, $image ){ * @param $mimetype mimetype * @returns link to the image */ -function mimetype_icon( $mimetype ){ +function mimetype_icon( $mimetype ) { return(\mimetype_icon( $mimetype )); } @@ -61,7 +61,7 @@ function mimetype_icon( $mimetype ){ * @param $bytes size in bytes * @returns size as string */ -function human_file_size( $bytes ){ +function human_file_size( $bytes ) { return(\human_file_size( $bytes )); } diff --git a/lib/public/user.php b/lib/public/user.php index 6228268d75b..b530321f21d 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -40,7 +40,7 @@ class User { * @brief get the user id of the user currently logged in. * @return string uid or false */ - public static function getUser(){ + public static function getUser() { return \OC_USER::getUser(); } @@ -51,7 +51,7 @@ class User { * * Get a list of all users. */ - public static function getUsers($search = '', $limit = -1, $offset = 0) { + public static function getUsers($search = '', $limit = null, $offset = null) { return \OC_USER::getUsers(); } @@ -62,7 +62,7 @@ class User { * * Checks if the user is logged in */ - public static function isLoggedIn(){ + public static function isLoggedIn() { return \OC_USER::isLoggedIn(); } @@ -72,7 +72,7 @@ class User { * @param string $uid the username * @return boolean */ - public static function userExists( $uid ){ + public static function userExists( $uid ) { return \OC_USER::userExists( $uid ); } @@ -83,7 +83,7 @@ class User { * * Logout, destroys session */ - public static function logout(){ + public static function logout() { return \OC_USER::logout(); } @@ -96,7 +96,7 @@ class User { * * Check if the password is correct without logging in the user */ - public static function checkPassword( $uid, $password ){ + public static function checkPassword( $uid, $password ) { return \OC_USER::checkPassword( $uid, $password ); } @@ -104,7 +104,7 @@ class User { /** * Check if the user is a admin, redirects to home if not */ - public static function checkAdminUser(){ + public static function checkAdminUser() { \OC_Util::checkAdminUser(); } @@ -113,7 +113,7 @@ class User { * Check if the user is logged in, redirects to home if not. With * redirect URL parameter to the request URI. */ - public static function checkLoggedIn(){ + public static function checkLoggedIn() { \OC_Util::checkLoggedIn(); } diff --git a/lib/public/util.php b/lib/public/util.php index 6ad578441e2..ed23521b040 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -48,7 +48,7 @@ class Util { * @brief get the current installed version of ownCloud * @return array */ - public static function getVersion(){ + public static function getVersion() { return(\OC_Util::getVersion()); } @@ -85,7 +85,7 @@ class Util { * @brief add a css file * @param url $url */ - public static function addStyle( $application, $file = null ){ + public static function addStyle( $application, $file = null ) { \OC_Util::addStyle( $application, $file ); } @@ -95,7 +95,7 @@ class Util { * @param appid $application * @param filename $file */ - public static function addScript( $application, $file = null ){ + public static function addScript( $application, $file = null ) { \OC_Util::addScript( $application, $file ); } @@ -105,7 +105,7 @@ class Util { * @param array $attributes array of attributes for the element * @param string $text the text content for the element */ - public static function addHeader( $tag, $attributes, $text=''){ + public static function addHeader( $tag, $attributes, $text='') { \OC_Util::addHeader( $tag, $attributes, $text ); } @@ -114,7 +114,7 @@ class Util { * @param int timestamp $timestamp * @param bool dateOnly option to ommit time from the result */ - public static function formatDate( $timestamp,$dateOnly=false){ + public static function formatDate( $timestamp,$dateOnly=false) { return(\OC_Util::formatDate( $timestamp,$dateOnly )); } @@ -124,12 +124,13 @@ class Util { * @brief Creates an absolute url * @param $app app * @param $file file + * @param $args array with param=>value, will be appended to the returned url * @returns the url * * Returns a absolute url to the given app and file. */ - public static function linkToAbsolute( $app, $file ) { - return(\OC_Helper::linkToAbsolute( $app, $file )); + public static function linkToAbsolute( $app, $file, $args = array() ) { + return(\OC_Helper::linkToAbsolute( $app, $file, $args )); } @@ -160,12 +161,13 @@ class Util { * @brief Creates an url * @param $app app * @param $file file + * @param $args array with param=>value, will be appended to the returned url * @returns the url * * Returns a url to the given app and file. */ - public static function linkTo( $app, $file ){ - return(\OC_Helper::linkTo( $app, $file )); + public static function linkTo( $app, $file, $args = array() ) { + return(\OC_Helper::linkTo( $app, $file, $args )); } /** @@ -197,7 +199,7 @@ 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 )); } @@ -209,7 +211,7 @@ class Util { * * Makes 2048 to 2 kB. */ - public static function humanFileSize( $bytes ){ + public static function humanFileSize( $bytes ) { return(\OC_Helper::humanFileSize( $bytes )); } @@ -222,7 +224,7 @@ class Util { * * Inspired by: http://www.php.net/manual/en/function.filesize.php#92418 */ - public static function computerFileSize( $str ){ + public static function computerFileSize( $str ) { return(\OC_Helper::computerFileSize( $str )); } @@ -238,7 +240,7 @@ class Util { * * TODO: write example */ - static public function connectHook( $signalclass, $signalname, $slotclass, $slotname ){ + static public function connectHook( $signalclass, $signalname, $slotclass, $slotname ) { return(\OC_Hook::connect( $signalclass, $signalname, $slotclass, $slotname )); } @@ -254,7 +256,7 @@ class Util { * * TODO: write example */ - static public function emitHook( $signalclass, $signalname, $params = array()){ + static public function emitHook( $signalclass, $signalname, $params = array()) { return(\OC_Hook::emit( $signalclass, $signalname, $params )); } @@ -263,7 +265,7 @@ class Util { * Register an get/post call. This is important to prevent CSRF attacks * TODO: write example */ - public static function callRegister(){ + public static function callRegister() { return(\OC_Util::callRegister()); } @@ -272,7 +274,7 @@ class Util { * Check an ajax get/post call if the request token is valid. exit if not. * Todo: Write howto */ - public static function callCheck(){ + public static function callCheck() { return(\OC_Util::callCheck()); } @@ -284,7 +286,7 @@ class Util { * @param string or array of strings * @return array with sanitized strings or a single sinitized string, depends on the input parameter. */ - public static function sanitizeHTML( $value ){ + public static function sanitizeHTML( $value ) { return(\OC_Util::sanitizeHTML($value)); } @@ -298,7 +300,7 @@ class Util { * * */ - public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8'){ + public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') { return(\OC_Helper::mb_array_change_key_case($input, $case, $encoding)); } |