aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/app.php17
-rw-r--r--lib/connector/sabre/directory.php6
-rw-r--r--lib/group/group.php38
-rw-r--r--lib/helper.php34
-rw-r--r--lib/installer.php53
-rw-r--r--lib/l10n/eu.php8
-rw-r--r--lib/l10n/he.php8
-rw-r--r--lib/l10n/it.php8
-rw-r--r--lib/l10n/zh_CN.GB2312.php32
9 files changed, 93 insertions, 111 deletions
diff --git a/lib/app.php b/lib/app.php
index f76b92cde1b..8f5dd1d685e 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -210,7 +210,8 @@ class OC_App{
/**
* @brief enables an app
* @param mixed $app app
- * @return bool
+ * @throws \Exception
+ * @return void
*
* This function set an app as enabled in appconfig.
*/
@@ -228,25 +229,25 @@ class OC_App{
}
}
}
+ $l = OC_L10N::get('core');
if($app!==false) {
// check if the app is compatible with this version of ownCloud
$info=OC_App::getAppInfo($app);
$version=OC_Util::getVersion();
if(!isset($info['require']) or !self::isAppVersionCompatible($version, $info['require'])) {
- OC_Log::write('core',
- 'App "'.$info['name'].'" can\'t be installed because it is'
- .' not compatible with this version of ownCloud',
- OC_Log::ERROR);
- return false;
+ throw new \Exception(
+ $l->t("App \"%s\" can't be installed because it is not compatible with this version of ownCloud.",
+ array($info['name'])
+ )
+ );
}else{
OC_Appconfig::setValue( $app, 'enabled', 'yes' );
if(isset($appdata['id'])) {
OC_Appconfig::setValue( $app, 'ocsid', $appdata['id'] );
}
- return true;
}
}else{
- return false;
+ throw new \Exception($l->t("No app name specified"));
}
}
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index ed8d085462d..66cd2fcd4e3 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -233,10 +233,10 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
* @return array
*/
public function getQuotaInfo() {
- $rootInfo=\OC\Files\Filesystem::getFileInfo('');
+ $storageInfo = OC_Helper::getStorageInfo($this->path);
return array(
- $rootInfo['size'],
- \OC\Files\Filesystem::free_space()
+ $storageInfo['used'],
+ $storageInfo['total']
);
}
diff --git a/lib/group/group.php b/lib/group/group.php
index a752c4311c1..bcd2419b309 100644
--- a/lib/group/group.php
+++ b/lib/group/group.php
@@ -62,7 +62,6 @@ class Group {
return $this->users;
}
- $users = array();
$userIds = array();
foreach ($this->backends as $backend) {
$diff = array_diff(
@@ -74,11 +73,8 @@ class Group {
}
}
- foreach ($userIds as $userId) {
- $users[] = $this->userManager->get($userId);
- }
- $this->users = $users;
- return $users;
+ $this->users = $this->getVerifiedUsers($userIds);
+ return $this->users;
}
/**
@@ -113,7 +109,7 @@ class Group {
if ($backend->implementsActions(OC_GROUP_BACKEND_ADD_TO_GROUP)) {
$backend->addToGroup($user->getUID(), $this->gid);
if ($this->users) {
- $this->users[] = $user;
+ $this->users[$user->getUID()] = $user;
}
if ($this->emitter) {
$this->emitter->emit('\OC\Group', 'postAddUser', array($this, $user));
@@ -172,9 +168,7 @@ class Group {
if (!is_null($offset)) {
$offset -= count($userIds);
}
- foreach ($userIds as $userId) {
- $users[$userId] = $this->userManager->get($userId);
- }
+ $users += $this->getVerifiedUsers($userIds);
if (!is_null($limit) and $limit <= 0) {
return array_values($users);
}
@@ -191,7 +185,6 @@ class Group {
* @return \OC\User\User[]
*/
public function searchDisplayName($search, $limit = null, $offset = null) {
- $users = array();
foreach ($this->backends as $backend) {
if ($backend->implementsActions(OC_GROUP_BACKEND_GET_DISPLAYNAME)) {
$userIds = array_keys($backend->displayNamesInGroup($this->gid, $search, $limit, $offset));
@@ -204,9 +197,7 @@ class Group {
if (!is_null($offset)) {
$offset -= count($userIds);
}
- foreach ($userIds as $userId) {
- $users[$userId] = $this->userManager->get($userId);
- }
+ $users = $this->getVerifiedUsers($userIds);
if (!is_null($limit) and $limit <= 0) {
return array_values($users);
}
@@ -235,4 +226,23 @@ class Group {
}
return $result;
}
+
+ /**
+ * @brief returns all the Users from an array that really exists
+ * @param $userIds an array containing user IDs
+ * @return an Array with the userId as Key and \OC\User\User as value
+ */
+ private function getVerifiedUsers($userIds) {
+ if(!is_array($userIds)) {
+ return array();
+ }
+ $users = array();
+ foreach ($userIds as $userId) {
+ $user = $this->userManager->get($userId);
+ if(!is_null($user)) {
+ $users[$userId] = $user;
+ }
+ }
+ return $users;
+ }
}
diff --git a/lib/helper.php b/lib/helper.php
index 1024a570e36..dd2476eda5c 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -591,9 +591,26 @@ class OC_Helper {
* remove all files in PHP /oc-noclean temp dir
*/
public static function cleanTmpNoClean() {
- $tmpDirNoCleanFile = get_temp_dir() . '/oc-noclean/';
- if (file_exists($tmpDirNoCleanFile)) {
- self::rmdirr($tmpDirNoCleanFile);
+ $tmpDirNoCleanName=get_temp_dir() . '/oc-noclean/';
+ if(file_exists($tmpDirNoCleanName) && is_dir($tmpDirNoCleanName)) {
+ $files=scandir($tmpDirNoCleanName);
+ foreach($files as $file) {
+ $fileName = $tmpDirNoCleanName . $file;
+ if (!\OC\Files\Filesystem::isIgnoredDir($file) && filemtime($fileName) + 600 < time()) {
+ unlink($fileName);
+ }
+ }
+ // if oc-noclean is empty delete it
+ $isTmpDirNoCleanEmpty = true;
+ $tmpDirNoClean = opendir($tmpDirNoCleanName);
+ while (false !== ($file = readdir($tmpDirNoClean))) {
+ if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
+ $isTmpDirNoCleanEmpty = false;
+ }
+ }
+ if ($isTmpDirNoCleanEmpty) {
+ rmdir($tmpDirNoCleanName);
+ }
}
}
@@ -824,15 +841,18 @@ class OC_Helper {
}
/**
- * Calculate the disc space
+ * Calculate the disc space for the given path
+ *
+ * @param string $path
+ * @return array
*/
- public static function getStorageInfo() {
- $rootInfo = \OC\Files\Filesystem::getFileInfo('/');
+ public static function getStorageInfo($path) {
+ $rootInfo = \OC\Files\Filesystem::getFileInfo($path);
$used = $rootInfo['size'];
if ($used < 0) {
$used = 0;
}
- $free = \OC\Files\Filesystem::free_space();
+ $free = \OC\Files\Filesystem::free_space($path);
if ($free >= 0) {
$total = $free + $used;
} else {
diff --git a/lib/installer.php b/lib/installer.php
index c29f9ec8982..b9684eaeea0 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -27,6 +27,7 @@ class OC_Installer{
/**
* @brief Installs an app
* @param $data array with all information
+ * @throws \Exception
* @returns integer
*
* This function installs an app. All information needed are passed in the
@@ -56,23 +57,22 @@ class OC_Installer{
* needed to get the app working.
*/
public static function installApp( $data = array()) {
+ $l = \OC_L10N::get('lib');
+
if(!isset($data['source'])) {
- OC_Log::write('core', 'No source specified when installing app', OC_Log::ERROR);
- return false;
+ throw new \Exception($l->t("No source specified when installing app"));
}
//download the file if necesary
if($data['source']=='http') {
$path=OC_Helper::tmpFile();
if(!isset($data['href'])) {
- OC_Log::write('core', 'No href specified when installing app from http', OC_Log::ERROR);
- return false;
+ throw new \Exception($l->t("No href specified when installing app from http"));
}
copy($data['href'], $path);
}else{
if(!isset($data['path'])) {
- OC_Log::write('core', 'No path specified when installing app from local file', OC_Log::ERROR);
- return false;
+ throw new \Exception($l->t("No path specified when installing app from local file"));
}
$path=$data['path'];
}
@@ -86,8 +86,7 @@ class OC_Installer{
rename($path, $path.'.tgz');
$path.='.tgz';
}else{
- OC_Log::write('core', 'Archives of type '.$mime.' are not supported', OC_Log::ERROR);
- return false;
+ throw new \Exception($l->t("Archives of type %s are not supported", array($mime)));
}
//extract the archive in a temporary folder
@@ -97,12 +96,11 @@ class OC_Installer{
if($archive=OC_Archive::open($path)) {
$archive->extract($extractDir);
} else {
- OC_Log::write('core', 'Failed to open archive when installing app', OC_Log::ERROR);
OC_Helper::rmdirr($extractDir);
if($data['source']=='http') {
unlink($path);
}
- return false;
+ throw new \Exception($l->t("Failed to open archive when installing app"));
}
//load the info.xml file of the app
@@ -118,62 +116,48 @@ class OC_Installer{
}
}
if(!is_file($extractDir.'/appinfo/info.xml')) {
- OC_Log::write('core', 'App does not provide an info.xml file', OC_Log::ERROR);
OC_Helper::rmdirr($extractDir);
if($data['source']=='http') {
unlink($path);
}
- return false;
+ throw new \Exception($l->t("App does not provide an info.xml file"));
}
$info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml', true);
// check the code for not allowed calls
if(!OC_Installer::checkCode($info['id'], $extractDir)) {
- OC_Log::write('core', 'App can\'t be installed because of not allowed code in the App', OC_Log::ERROR);
OC_Helper::rmdirr($extractDir);
- return false;
+ throw new \Exception($l->t("App can't be installed because of not allowed code in the App"));
}
// check if the app is compatible with this version of ownCloud
if(
- !isset($info['require'])
- or !OC_App::isAppVersionCompatible(OC_Util::getVersion(), $info['require'])
- ) {
- OC_Log::write('core',
- 'App can\'t be installed because it is not compatible with this version of ownCloud',
- OC_Log::ERROR);
+ !isset($info['require'])
+ or !OC_App::isAppVersionCompatible(OC_Util::getVersion(), $info['require'])
+ ) {
OC_Helper::rmdirr($extractDir);
- return false;
+ throw new \Exception($l->t("App can't be installed because it is not compatible with this version of ownCloud"));
}
// check if shipped tag is set which is only allowed for apps that are shipped with ownCloud
if(isset($info['shipped']) and ($info['shipped']=='true')) {
- OC_Log::write('core',
- 'App can\'t be installed because it contains the <shipped>true</shippe>'
- .' tag which is not allowed for non shipped apps',
- OC_Log::ERROR);
OC_Helper::rmdirr($extractDir);
- return false;
+ throw new \Exception($l->t("App can't be installed because it contains the <shipped>true</shipped> tag which is not allowed for non shipped apps"));
}
// check if the ocs version is the same as the version in info.xml/version
if(!isset($info['version']) or ($info['version']<>$data['appdata']['version'])) {
- OC_Log::write('core',
- 'App can\'t be installed because the version in info.xml/version is not the same'
- .' as the version reported from the app store',
- OC_Log::ERROR);
OC_Helper::rmdirr($extractDir);
- return false;
+ throw new \Exception($l->t("App can't be installed because the version in info.xml/version is not the same as the version reported from the app store"));
}
$basedir=OC_App::getInstallPath().'/'.$info['id'];
//check if the destination directory already exists
if(is_dir($basedir)) {
- OC_Log::write('core', 'App directory already exists', OC_Log::WARN);
OC_Helper::rmdirr($extractDir);
if($data['source']=='http') {
unlink($path);
}
- return false;
+ throw new \Exception($l->t("App directory already exists"));
}
if(isset($data['pretent']) and $data['pretent']==true) {
@@ -182,12 +166,11 @@ class OC_Installer{
//copy the app to the correct place
if(@!mkdir($basedir)) {
- OC_Log::write('core', 'Can\'t create app folder. Please fix permissions. ('.$basedir.')', OC_Log::ERROR);
OC_Helper::rmdirr($extractDir);
if($data['source']=='http') {
unlink($path);
}
- return false;
+ throw new \Exception($l->t("Can't create app folder. Please fix permissions. %s", array($basedir)));
}
OC_Helper::copyr($extractDir, $basedir);
diff --git a/lib/l10n/eu.php b/lib/l10n/eu.php
index 8f967314f4b..413819f4f94 100644
--- a/lib/l10n/eu.php
+++ b/lib/l10n/eu.php
@@ -40,13 +40,13 @@ $TRANSLATIONS = array(
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Zure web zerbitzaria ez dago oraindik ongi konfiguratuta fitxategien sinkronizazioa egiteko, WebDAV interfazea ongi ez dagoela dirudi.",
"Please double check the <a href='%s'>installation guides</a>." => "Mesedez begiratu <a href='%s'>instalazio gidak</a>.",
"seconds ago" => "segundu",
-"_%n minute ago_::_%n minutes ago_" => array("",""),
-"_%n hour ago_::_%n hours ago_" => array("",""),
+"_%n minute ago_::_%n minutes ago_" => array("orain dela minutu %n","orain dela %n minutu"),
+"_%n hour ago_::_%n hours ago_" => array("orain dela ordu %n","orain dela %n ordu"),
"today" => "gaur",
"yesterday" => "atzo",
-"_%n day go_::_%n days ago_" => array("",""),
+"_%n day go_::_%n days ago_" => array("orain dela egun %n","orain dela %n egun"),
"last month" => "joan den hilabetean",
-"_%n month ago_::_%n months ago_" => array("",""),
+"_%n month ago_::_%n months ago_" => array("orain dela hilabete %n","orain dela %n hilabete"),
"last year" => "joan den urtean",
"years ago" => "urte",
"Caused by:" => "Honek eraginda:",
diff --git a/lib/l10n/he.php b/lib/l10n/he.php
index bab1a6ff424..ced6244ee91 100644
--- a/lib/l10n/he.php
+++ b/lib/l10n/he.php
@@ -19,13 +19,13 @@ $TRANSLATIONS = array(
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "שרת האינטרנט שלך אינו מוגדר לצורכי סנכרון קבצים עדיין כיוון שמנשק ה־WebDAV כנראה אינו תקין.",
"Please double check the <a href='%s'>installation guides</a>." => "נא לעיין שוב ב<a href='%s'>מדריכי ההתקנה</a>.",
"seconds ago" => "שניות",
-"_%n minute ago_::_%n minutes ago_" => array("",""),
-"_%n hour ago_::_%n hours ago_" => array("",""),
+"_%n minute ago_::_%n minutes ago_" => array("","לפני %n דקות"),
+"_%n hour ago_::_%n hours ago_" => array("","לפני %n שעות"),
"today" => "היום",
"yesterday" => "אתמול",
-"_%n day go_::_%n days ago_" => array("",""),
+"_%n day go_::_%n days ago_" => array("","לפני %n ימים"),
"last month" => "חודש שעבר",
-"_%n month ago_::_%n months ago_" => array("",""),
+"_%n month ago_::_%n months ago_" => array("","לפני %n חודשים"),
"last year" => "שנה שעברה",
"years ago" => "שנים",
"Could not find category \"%s\"" => "לא ניתן למצוא את הקטגוריה „%s“"
diff --git a/lib/l10n/it.php b/lib/l10n/it.php
index e734fbdbb9b..983152a14ca 100644
--- a/lib/l10n/it.php
+++ b/lib/l10n/it.php
@@ -40,13 +40,13 @@ $TRANSLATIONS = array(
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Il tuo server web non è configurato correttamente per consentire la sincronizzazione dei file poiché l'interfaccia WebDAV sembra essere danneggiata.",
"Please double check the <a href='%s'>installation guides</a>." => "Leggi attentamente le <a href='%s'>guide d'installazione</a>.",
"seconds ago" => "secondi fa",
-"_%n minute ago_::_%n minutes ago_" => array("",""),
-"_%n hour ago_::_%n hours ago_" => array("",""),
+"_%n minute ago_::_%n minutes ago_" => array("%n minuto fa","%n minuti fa"),
+"_%n hour ago_::_%n hours ago_" => array("%n ora fa","%n ore fa"),
"today" => "oggi",
"yesterday" => "ieri",
-"_%n day go_::_%n days ago_" => array("",""),
+"_%n day go_::_%n days ago_" => array("%n giorno fa","%n giorni fa"),
"last month" => "mese scorso",
-"_%n month ago_::_%n months ago_" => array("",""),
+"_%n month ago_::_%n months ago_" => array("%n mese fa","%n mesi fa"),
"last year" => "anno scorso",
"years ago" => "anni fa",
"Caused by:" => "Causato da:",
diff --git a/lib/l10n/zh_CN.GB2312.php b/lib/l10n/zh_CN.GB2312.php
deleted file mode 100644
index bc81ff8fe1b..00000000000
--- a/lib/l10n/zh_CN.GB2312.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-$TRANSLATIONS = array(
-"Help" => "帮助",
-"Personal" => "私人",
-"Settings" => "设置",
-"Users" => "用户",
-"Admin" => "管理员",
-"web services under your control" => "您控制的网络服务",
-"ZIP download is turned off." => "ZIP 下载已关闭",
-"Files need to be downloaded one by one." => "需要逐个下载文件。",
-"Back to Files" => "返回到文件",
-"Selected files too large to generate zip file." => "选择的文件太大而不能生成 zip 文件。",
-"Application is not enabled" => "应用未启用",
-"Authentication error" => "验证错误",
-"Token expired. Please reload page." => "会话过期。请刷新页面。",
-"Files" => "文件",
-"Text" => "文本",
-"Images" => "图片",
-"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "因WebDAV接口故障,您的网络服务器好像并未允许文件同步。",
-"Please double check the <a href='%s'>installation guides</a>." => "请双击<a href='%s'>安装向导</a>。",
-"seconds ago" => "秒前",
-"_%n minute ago_::_%n minutes ago_" => array("%n 分钟以前"),
-"_%n hour ago_::_%n hours ago_" => array("%n 小时以前"),
-"today" => "今天",
-"yesterday" => "昨天",
-"_%n day go_::_%n days ago_" => array("%n 天以前"),
-"last month" => "上个月",
-"_%n month ago_::_%n months ago_" => array("%n 个月以前"),
-"last year" => "去年",
-"years ago" => "年前"
-);
-$PLURAL_FORMS = "nplurals=1; plural=0;";