aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php2
-rw-r--r--lib/l10n/af.php8
-rw-r--r--lib/l10n/el.php2
-rw-r--r--lib/l10n/es_AR.php2
-rw-r--r--lib/l10n/ja_JP.php8
-rw-r--r--lib/l10n/mk.php1
-rw-r--r--lib/l10n/nds.php8
-rw-r--r--lib/l10n/ru_RU.php1
-rw-r--r--lib/l10n/zh_CN.php2
-rw-r--r--lib/private/files/cache/cache.php4
-rw-r--r--lib/private/files/cache/updater.php71
-rw-r--r--lib/private/files/storage/wrapper/quota.php2
-rw-r--r--lib/private/files/stream/quota.php16
-rw-r--r--lib/private/files/type/detection.php8
-rw-r--r--lib/private/installer.php6
-rw-r--r--lib/private/l10n.php46
-rw-r--r--lib/private/urlgenerator.php10
-rw-r--r--lib/private/user.php25
-rw-r--r--lib/private/user/database.php17
-rw-r--r--lib/private/user/manager.php14
-rw-r--r--lib/public/share.php60
21 files changed, 216 insertions, 97 deletions
diff --git a/lib/base.php b/lib/base.php
index 240dd1c12b6..d29a95ecec9 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -507,7 +507,7 @@ class OC {
// This includes plugins for users and filesystems as well
global $RUNTIME_NOAPPS;
global $RUNTIME_APPTYPES;
- if (!$RUNTIME_NOAPPS) {
+ if (!$RUNTIME_NOAPPS && !self::checkUpgrade(false)) {
if ($RUNTIME_APPTYPES) {
OC_App::loadApps($RUNTIME_APPTYPES);
} else {
diff --git a/lib/l10n/af.php b/lib/l10n/af.php
new file mode 100644
index 00000000000..15f78e0bce6
--- /dev/null
+++ b/lib/l10n/af.php
@@ -0,0 +1,8 @@
+<?php
+$TRANSLATIONS = array(
+"_%n minute ago_::_%n minutes ago_" => array("",""),
+"_%n hour ago_::_%n hours ago_" => array("",""),
+"_%n day go_::_%n days ago_" => array("",""),
+"_%n month ago_::_%n months ago_" => array("","")
+);
+$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/el.php b/lib/l10n/el.php
index 7f74dafca74..aed5e052a8e 100644
--- a/lib/l10n/el.php
+++ b/lib/l10n/el.php
@@ -6,6 +6,8 @@ $TRANSLATIONS = array(
"Users" => "Χρήστες",
"Admin" => "Διαχειριστής",
"Failed to upgrade \"%s\"." => "Αποτυχία αναβάθμισης του \"%s\".",
+"Unknown filetype" => "Άγνωστος τύπος αρχείου",
+"Invalid image" => "Μη έγκυρη εικόνα",
"web services under your control" => "υπηρεσίες δικτύου υπό τον έλεγχό σας",
"cannot open \"%s\"" => "αδυναμία ανοίγματος \"%s\"",
"ZIP download is turned off." => "Η λήψη ZIP απενεργοποιήθηκε.",
diff --git a/lib/l10n/es_AR.php b/lib/l10n/es_AR.php
index 668c46b7b10..4e65755ba87 100644
--- a/lib/l10n/es_AR.php
+++ b/lib/l10n/es_AR.php
@@ -8,6 +8,8 @@ $TRANSLATIONS = array(
"Users" => "Usuarios",
"Admin" => "Administración",
"Failed to upgrade \"%s\"." => "No se pudo actualizar \"%s\".",
+"Unknown filetype" => "Tipo de archivo desconocido",
+"Invalid image" => "Imagen inválida",
"web services under your control" => "servicios web sobre los que tenés control",
"cannot open \"%s\"" => "no se puede abrir \"%s\"",
"ZIP download is turned off." => "La descarga en ZIP está desactivada.",
diff --git a/lib/l10n/ja_JP.php b/lib/l10n/ja_JP.php
index e4e45462779..f156c68715c 100644
--- a/lib/l10n/ja_JP.php
+++ b/lib/l10n/ja_JP.php
@@ -58,14 +58,14 @@ $TRANSLATIONS = array(
"Could not find category \"%s\"" => "カテゴリ \"%s\" が見つかりませんでした",
"seconds ago" => "数秒前",
"_%n minute ago_::_%n minutes ago_" => array("%n 分前"),
-"_%n hour ago_::_%n hours ago_" => array("%n 時間後"),
+"_%n hour ago_::_%n hours ago_" => array("%n 時間前"),
"today" => "今日",
"yesterday" => "昨日",
-"_%n day go_::_%n days ago_" => array("%n 日後"),
+"_%n day go_::_%n days ago_" => array("%n 日前"),
"last month" => "一月前",
-"_%n month ago_::_%n months ago_" => array("%n カ月後"),
+"_%n month ago_::_%n months ago_" => array("%n ヶ月前"),
"last year" => "一年前",
"years ago" => "年前",
-"Caused by:" => "原因は以下:"
+"Caused by:" => "原因:"
);
$PLURAL_FORMS = "nplurals=1; plural=0;";
diff --git a/lib/l10n/mk.php b/lib/l10n/mk.php
index 19e36c868d0..deaf1bc8d05 100644
--- a/lib/l10n/mk.php
+++ b/lib/l10n/mk.php
@@ -5,6 +5,7 @@ $TRANSLATIONS = array(
"Settings" => "Подесувања",
"Users" => "Корисници",
"Admin" => "Админ",
+"Unknown filetype" => "Непознат тип на датотека",
"Invalid image" => "Невалидна фотографија",
"web services under your control" => "веб сервиси под Ваша контрола",
"ZIP download is turned off." => "Преземање во ZIP е исклучено",
diff --git a/lib/l10n/nds.php b/lib/l10n/nds.php
new file mode 100644
index 00000000000..15f78e0bce6
--- /dev/null
+++ b/lib/l10n/nds.php
@@ -0,0 +1,8 @@
+<?php
+$TRANSLATIONS = array(
+"_%n minute ago_::_%n minutes ago_" => array("",""),
+"_%n hour ago_::_%n hours ago_" => array("",""),
+"_%n day go_::_%n days ago_" => array("",""),
+"_%n month ago_::_%n months ago_" => array("","")
+);
+$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/ru_RU.php b/lib/l10n/ru_RU.php
index c1ebdd14951..622333c3855 100644
--- a/lib/l10n/ru_RU.php
+++ b/lib/l10n/ru_RU.php
@@ -1,5 +1,6 @@
<?php
$TRANSLATIONS = array(
+"Help" => "Помощь",
"Settings" => "Настройки",
"Files" => "Файлы",
"_%n minute ago_::_%n minutes ago_" => array("","",""),
diff --git a/lib/l10n/zh_CN.php b/lib/l10n/zh_CN.php
index e3f2c949175..ae9243cf412 100644
--- a/lib/l10n/zh_CN.php
+++ b/lib/l10n/zh_CN.php
@@ -5,6 +5,8 @@ $TRANSLATIONS = array(
"Settings" => "设置",
"Users" => "用户",
"Admin" => "管理",
+"Unknown filetype" => "未知的文件类型",
+"Invalid image" => "无效的图像",
"web services under your control" => "您控制的web服务",
"ZIP download is turned off." => "ZIP 下载已经关闭",
"Files need to be downloaded one by one." => "需要逐一下载文件",
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index fc2d965d7f9..c1e5b34c8aa 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -64,6 +64,10 @@ class Cache {
* @return int
*/
public function getMimetypeId($mime) {
+ if (empty($mime)) {
+ // Can not insert empty string into Oracle NOT NULL column.
+ $mime = 'application/octet-stream';
+ }
if (empty(self::$mimetypeIds)) {
$this->loadMimetypes();
}
diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php
index 1f30173a8f8..da223567001 100644
--- a/lib/private/files/cache/updater.php
+++ b/lib/private/files/cache/updater.php
@@ -7,6 +7,7 @@
*/
namespace OC\Files\Cache;
+
use OCP\Util;
/**
@@ -42,6 +43,7 @@ class Updater {
$scanner->scan($internalPath, Scanner::SCAN_SHALLOW);
$cache->correctFolderSize($internalPath);
self::correctFolder($path, $storage->filemtime($internalPath));
+ self::correctParentStorageMtime($storage, $internalPath);
}
}
@@ -61,6 +63,7 @@ class Updater {
$cache->remove($internalPath);
$cache->correctFolderSize($internalPath);
self::correctFolder($path, time());
+ self::correctParentStorageMtime($storage, $internalPath);
}
}
@@ -87,6 +90,8 @@ class Updater {
$cache->correctFolderSize($internalTo);
self::correctFolder($from, time());
self::correctFolder($to, time());
+ self::correctParentStorageMtime($storageFrom, $internalFrom);
+ self::correctParentStorageMtime($storageTo, $internalTo);
} else {
self::deleteUpdate($from);
self::writeUpdate($to);
@@ -95,6 +100,24 @@ class Updater {
}
/**
+ * @brief get file owner and path
+ * @param string $filename
+ * @return array with the oweners uid and the owners path
+ */
+ private static function getUidAndFilename($filename) {
+
+ $uid = \OC\Files\Filesystem::getOwner($filename);
+ \OC\Files\Filesystem::initMountPoints($uid);
+
+ if ($uid != \OCP\User::getUser()) {
+ $info = \OC\Files\Filesystem::getFileInfo($filename);
+ $ownerView = new \OC\Files\View('/' . $uid . '/files');
+ $filename = $ownerView->getPath($info['fileid']);
+ }
+ return array($uid, '/files/' . $filename);
+ }
+
+ /**
* Update the mtime and ETag of all parent folders
*
* @param string $path
@@ -102,29 +125,53 @@ class Updater {
*/
static public function correctFolder($path, $time) {
if ($path !== '' && $path !== '/') {
- $parent = dirname($path);
- if ($parent === '.' || $parent === '\\') {
- $parent = '';
- }
+
+ list($owner, $realPath) = self::getUidAndFilename(dirname($path));
+
/**
* @var \OC\Files\Storage\Storage $storage
* @var string $internalPath
*/
- list($storage, $internalPath) = self::resolvePath($parent);
- if ($storage) {
- $cache = $storage->getCache();
- $id = $cache->getId($internalPath);
- if ($id !== -1) {
- $cache->update($id, array('mtime' => $time, 'etag' => $storage->getETag($internalPath)));
- self::correctFolder($parent, $time);
+ $view = new \OC\Files\View('/' . $owner);
+
+ list($storage, $internalPath) = $view->resolvePath($realPath);
+ $cache = $storage->getCache();
+ $id = $cache->getId($internalPath);
+
+ while ($id !== -1) {
+ $cache->update($id, array('mtime' => $time, 'etag' => $storage->getETag($internalPath)));
+ if ($realPath !== '') {
+ $realPath = dirname($realPath);
+ if($realPath === '/') {
+ $realPath = "";
+ }
+ // check storage for parent in case we change the storage in this step
+ list($storage, $internalPath) = $view->resolvePath($realPath);
+ $cache = $storage->getCache();
+ $id = $cache->getId($internalPath);
} else {
- Util::writeLog('core', 'Path not in cache: '.$internalPath, Util::ERROR);
+ $id = -1;
}
}
}
}
/**
+ * update the storage_mtime of the parent
+ *
+ * @param \OC\Files\Storage\Storage $storage
+ * @param string $internalPath
+ */
+ static private function correctParentStorageMtime($storage, $internalPath) {
+ $cache = $storage->getCache();
+ $parentId = $cache->getParentId($internalPath);
+ $parent = dirname($internalPath);
+ if ($parentId != -1) {
+ $cache->update($parentId, array('storage_mtime' => $storage->filemtime($parent)));
+ }
+ }
+
+ /**
* @param array $params
*/
static public function writeHook($params) {
diff --git a/lib/private/files/storage/wrapper/quota.php b/lib/private/files/storage/wrapper/quota.php
index e2da8cf2e05..43016e0892f 100644
--- a/lib/private/files/storage/wrapper/quota.php
+++ b/lib/private/files/storage/wrapper/quota.php
@@ -95,7 +95,7 @@ class Quota extends Wrapper {
public function fopen($path, $mode) {
$source = $this->storage->fopen($path, $mode);
$free = $this->free_space('');
- if ($free >= 0) {
+ if ($free >= 0 && $mode !== 'r') {
return \OC\Files\Stream\Quota::wrap($source, $free);
} else {
return $source;
diff --git a/lib/private/files/stream/quota.php b/lib/private/files/stream/quota.php
index 53d8a03d30f..60e60da8e67 100644
--- a/lib/private/files/stream/quota.php
+++ b/lib/private/files/stream/quota.php
@@ -66,12 +66,24 @@ class Quota {
}
public function stream_seek($offset, $whence = SEEK_SET) {
- if ($whence === SEEK_SET) {
+ if ($whence === SEEK_END){
+ // go to the end to find out last position's offset
+ $oldOffset = $this->stream_tell();
+ if (fseek($this->source, 0, $whence) !== 0){
+ return false;
+ }
+ $whence = SEEK_SET;
+ $offset = $this->stream_tell() + $offset;
+ $this->limit += $oldOffset - $offset;
+ }
+ else if ($whence === SEEK_SET) {
$this->limit += $this->stream_tell() - $offset;
} else {
$this->limit -= $offset;
}
- fseek($this->source, $offset, $whence);
+ // this wrapper needs to return "true" for success.
+ // the fseek call itself returns 0 on succeess
+ return !fseek($this->source, $offset, $whence);
}
public function stream_tell() {
diff --git a/lib/private/files/type/detection.php b/lib/private/files/type/detection.php
index 242a81cb5a4..d7cc9ebbf4e 100644
--- a/lib/private/files/type/detection.php
+++ b/lib/private/files/type/detection.php
@@ -61,8 +61,6 @@ class Detection {
* @return string
*/
public function detect($path) {
- $isWrapped = (strpos($path, '://') !== false) and (substr($path, 0, 7) === 'file://');
-
if (@is_dir($path)) {
// directories are easy
return "httpd/unix-directory";
@@ -76,9 +74,11 @@ class Detection {
$info = @strtolower(finfo_file($finfo, $path));
if ($info) {
$mimeType = substr($info, 0, strpos($info, ';'));
+ return empty($mimeType) ? 'application/octet-stream' : $mimeType;
}
finfo_close($finfo);
}
+ $isWrapped = (strpos($path, '://') !== false) and (substr($path, 0, 7) === 'file://');
if (!$isWrapped and $mimeType === 'application/octet-stream' && function_exists("mime_content_type")) {
// use mime magic extension if available
$mimeType = mime_content_type($path);
@@ -94,6 +94,10 @@ class Detection {
//trim the newline
$mimeType = trim($reply);
+ if (empty($mimeType)) {
+ $mimeType = 'application/octet-stream';
+ }
+
}
return $mimeType;
}
diff --git a/lib/private/installer.php b/lib/private/installer.php
index e082c7eeee9..a7ca7269716 100644
--- a/lib/private/installer.php
+++ b/lib/private/installer.php
@@ -259,7 +259,7 @@ class OC_Installer{
/**
* @brief Check if an update for the app is available
* @param $name name of the application
- * @returns empty string is no update available or the version number of the update
+ * @return boolean false or the version number of the update
*
* The function will check if an update for a version is available
*/
@@ -275,11 +275,11 @@ class OC_Installer{
return($ocsversion);
}else{
- return('');
+ return false;
}
}else{
- return('');
+ return false;
}
}
diff --git a/lib/private/l10n.php b/lib/private/l10n.php
index 3e84c306dc2..2d440850459 100644
--- a/lib/private/l10n.php
+++ b/lib/private/l10n.php
@@ -419,7 +419,7 @@ class OC_L10N implements \OCP\IL10N {
/**
* @brief find the best language
* @param $app Array or string, details below
- * @returns language
+ * @returns string language
*
* If $app is an array, ownCloud assumes that these are the available
* languages. Otherwise ownCloud tries to find the files in the l10n
@@ -438,8 +438,7 @@ class OC_L10N implements \OCP\IL10N {
if(is_array($app)) {
$available = $app;
$lang_exists = array_search($lang, $available) !== false;
- }
- else {
+ } else {
$lang_exists = self::languageExists($app, $lang);
}
if($lang_exists) {
@@ -447,35 +446,40 @@ class OC_L10N implements \OCP\IL10N {
}
}
- $default_language = OC_Config::getValue('default_language', false);
+ $default_language = OC_Config::getValue('default_language', false);
- if($default_language !== false) {
- return $default_language;
- }
+ if($default_language !== false) {
+ return $default_language;
+ }
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
- $accepted_languages = preg_split('/,\s*/', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
if(is_array($app)) {
$available = $app;
- }
- else{
+ } else {
$available = self::findAvailableLanguages($app);
}
- foreach($accepted_languages as $i) {
- $temp = explode(';', $i);
- $temp[0] = str_replace('-', '_', $temp[0]);
- if( ($key = array_search($temp[0], $available)) !== false) {
- if (is_null($app)) {
- self::$language = $available[$key];
+
+ // E.g. make sure that 'de' is before 'de_DE'.
+ sort($available);
+
+ $preferences = preg_split('/,\s*/', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
+ foreach($preferences as $preference) {
+ list($preferred_language) = explode(';', $preference);
+ $preferred_language = str_replace('-', '_', $preferred_language);
+ foreach($available as $available_language) {
+ if ($preferred_language === strtolower($available_language)) {
+ if (is_null($app)) {
+ self::$language = $available_language;
+ }
+ return $available_language;
}
- return $available[$key];
}
- foreach($available as $l) {
- if ( $temp[0] == substr($l, 0, 2) ) {
+ foreach($available as $available_language) {
+ if (substr($preferred_language, 0, 2) === $available_language) {
if (is_null($app)) {
- self::$language = $l;
+ self::$language = $available_language;
}
- return $l;
+ return $available_language;
}
}
}
diff --git a/lib/private/urlgenerator.php b/lib/private/urlgenerator.php
index 1ec10fe5688..7795011fd06 100644
--- a/lib/private/urlgenerator.php
+++ b/lib/private/urlgenerator.php
@@ -88,27 +88,27 @@ class URLGenerator implements IURLGenerator {
if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) {
return \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image";
} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg")
- && file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) {
+ && file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) {
return \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png";
} elseif (file_exists(\OC_App::getAppPath($app) . "/img/$image")) {
return \OC_App::getAppWebPath($app) . "/img/$image";
} elseif (!file_exists(\OC_App::getAppPath($app) . "/img/$basename.svg")
- && file_exists(\OC_App::getAppPath($app) . "/img/$basename.png")) {
+ && file_exists(\OC_App::getAppPath($app) . "/img/$basename.png")) {
return \OC_App::getAppPath($app) . "/img/$basename.png";
} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) {
return \OC::$WEBROOT . "/themes/$theme/$app/img/$image";
} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg")
- && file_exists(\OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png"))) {
+ && file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.png"))) {
return \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png";
} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) {
return \OC::$WEBROOT . "/$app/img/$image";
} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg")
- && file_exists(\OC::$WEBROOT . "/$app/img/$basename.png"))) {
+ && file_exists(\OC::$SERVERROOT . "/$app/img/$basename.png"))) {
return \OC::$WEBROOT . "/$app/img/$basename.png";
} elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) {
return \OC::$WEBROOT . "/themes/$theme/core/img/$image";
} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg")
- && file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) {
+ && file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) {
return \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
} elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) {
return \OC::$WEBROOT . "/core/img/$image";
diff --git a/lib/private/user.php b/lib/private/user.php
index 6b350d4cf1b..f15fdf1dbbc 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -187,18 +187,25 @@ class OC_User {
public static function deleteUser($uid) {
$user = self::getManager()->get($uid);
if ($user) {
- $user->delete();
+ $result = $user->delete();
- // We have to delete the user from all groups
- foreach (OC_Group::getUserGroups($uid) as $i) {
- OC_Group::removeFromGroup($uid, $i);
+ // if delete was successful we clean-up the rest
+ if ($result) {
+
+ // We have to delete the user from all groups
+ foreach (OC_Group::getUserGroups($uid) as $i) {
+ OC_Group::removeFromGroup($uid, $i);
+ }
+ // Delete the user's keys in preferences
+ OC_Preferences::deleteUser($uid);
+
+ // Delete user files in /data/
+ OC_Helper::rmdirr(\OC_User::getHome($uid));
+
+ // Remove it from the Cache
+ self::getManager()->delete($uid);
}
- // Delete the user's keys in preferences
- OC_Preferences::deleteUser($uid);
- // Delete user files in /data/
- OC_Helper::rmdirr(OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid . '/');
-
return true;
} else {
return false;
diff --git a/lib/private/user/database.php b/lib/private/user/database.php
index 9f00a022d9f..3db770f9898 100644
--- a/lib/private/user/database.php
+++ b/lib/private/user/database.php
@@ -156,25 +156,14 @@ class OC_User_Database extends OC_User_Backend {
public function getDisplayNames($search = '', $limit = null, $offset = null) {
$displayNames = array();
$query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`'
- .' WHERE LOWER(`displayname`) LIKE LOWER(?)', $limit, $offset);
- $result = $query->execute(array($search.'%'));
+ .' WHERE LOWER(`displayname`) LIKE LOWER(?) OR '
+ .'LOWER(`uid`) LIKE LOWER(?)', $limit, $offset);
+ $result = $query->execute(array($search.'%', $search.'%'));
$users = array();
while ($row = $result->fetchRow()) {
$displayNames[$row['uid']] = $row['displayname'];
}
- // let's see if we can also find some users who don't have a display name yet
- $query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`'
- .' WHERE LOWER(`uid`) LIKE LOWER(?)', $limit, $offset);
- $result = $query->execute(array($search.'%'));
- while ($row = $result->fetchRow()) {
- $displayName = trim($row['displayname'], ' ');
- if ( empty($displayName) ) {
- $displayNames[$row['uid']] = $row['uid'];
- }
- }
-
-
return $displayNames;
}
diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php
index 13286bc28a4..703c8cd7413 100644
--- a/lib/private/user/manager.php
+++ b/lib/private/user/manager.php
@@ -119,6 +119,20 @@ class Manager extends PublicEmitter {
}
/**
+ * remove deleted user from cache
+ *
+ * @param string $uid
+ * @return bool
+ */
+ public function delete($uid) {
+ if (isset($this->cachedUsers[$uid])) {
+ unset($this->cachedUsers[$uid]);
+ return true;
+ }
+ return false;
+ }
+
+ /**
* Check if the password is valid for the user
*
* @param $loginname
diff --git a/lib/public/share.php b/lib/public/share.php
index dce3c2211b1..c62f964fe1b 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -428,33 +428,45 @@ class Share {
}
/**
- * 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
- * @param string User or group the item is being shared with
- * @param int CRUDS permissions
- * @return bool|string Returns true on success or false on failure, Returns token on success for links
- */
- public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions) {
+ * Share an item with a user, group, or via private link
+ * @param string $itemType
+ * @param string $itemSource
+ * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
+ * @param string $shareWith User or group the item is being shared with
+ * @param int $permissions CRUDS
+ * @param null $itemSourceName
+ * @throws \Exception
+ * @internal param \OCP\Item $string type
+ * @internal param \OCP\Item $string source
+ * @internal param \OCP\SHARE_TYPE_USER $int , SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
+ * @internal param \OCP\User $string or group the item is being shared with
+ * @internal param \OCP\CRUDS $int permissions
+ * @return bool|string Returns true on success or false on failure, Returns token on success for links
+ */
+ public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions, $itemSourceName = null) {
$uidOwner = \OC_User::getUser();
$sharingPolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');
+
+ if (is_null($itemSourceName)) {
+ $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 +479,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 +504,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);
}
@@ -534,14 +546,14 @@ class Share {
$token = \OC_Util::generateRandomBytes(self::TOKEN_LENGTH);
}
$result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions,
- null, $token);
+ null, $token, $itemSourceName);
if ($result) {
return $token;
} else {
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;
@@ -600,7 +612,7 @@ class Share {
// return false;
// } else {
// Put the item into the database
- return self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions);
+ return self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, null, null, $itemSourceName);
// }
}
@@ -1320,20 +1332,22 @@ class Share {
* @return bool Returns true on success or false on failure
*/
private static function put($itemType, $itemSource, $shareType, $shareWith, $uidOwner,
- $permissions, $parentFolder = null, $token = null) {
+ $permissions, $parentFolder = null, $token = null, $itemSourceName = null) {
$backend = self::getBackend($itemType);
+
// Check if this is a reshare
if ($checkReshare = self::getItemSharedWithBySource($itemType, $itemSource, self::FORMAT_NONE, null, true)) {
+
// 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);
@@ -1347,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);
}