diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/l10n/sl.php | 1 | ||||
-rw-r--r-- | lib/private/app.php | 118 | ||||
-rw-r--r-- | lib/private/connector/sabre/directory.php | 2 | ||||
-rw-r--r-- | lib/private/files/storage/dav.php | 4 | ||||
-rw-r--r-- | lib/private/files/view.php | 10 | ||||
-rw-r--r-- | lib/private/installer.php | 3 | ||||
-rw-r--r-- | lib/private/largefilehelper.php | 4 | ||||
-rw-r--r-- | lib/private/ocsclient.php | 2 | ||||
-rw-r--r-- | lib/private/setup.php | 2 | ||||
-rw-r--r-- | lib/private/urlgenerator.php | 4 | ||||
-rw-r--r-- | lib/private/user/session.php | 23 | ||||
-rw-r--r-- | lib/private/user/user.php | 14 | ||||
-rwxr-xr-x | lib/private/util.php | 2 |
13 files changed, 104 insertions, 85 deletions
diff --git a/lib/l10n/sl.php b/lib/l10n/sl.php index af92aac057d..1ae1628fdbd 100644 --- a/lib/l10n/sl.php +++ b/lib/l10n/sl.php @@ -83,6 +83,7 @@ $TRANSLATIONS = array( "No database drivers (sqlite, mysql, or postgresql) installed." => "Ni nameščenih programnikov podatkovnih zbirk (sqlite, mysql, ali postgresql).", "Cannot write into \"config\" directory" => "Mapa 'config' nima nastavljenih ustreznih dovoljenj za pisanje!", "Cannot write into \"apps\" directory" => "Mapa \"apps\" nima nastavljenih ustreznih dovoljenj za pisanje!", +"Setting locale to %s failed" => "Nastavljanje jezikovnih določil na %s je spodletelo.", "Please ask your server administrator to install the module." => "Obvestite skrbnika strežnika, da je treba namestiti manjkajoč modul.", "PHP module %s not installed." => "Modul PHP %s ni nameščen.", "PHP %s or higher is required." => "Zahtevana je različica PHP %s ali višja.", diff --git a/lib/private/app.php b/lib/private/app.php index a356139044c..95a8a7302d9 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -815,7 +815,7 @@ class OC_App { * Lists all apps, this is used in apps.php * @return array */ - public static function listAllApps() { + public static function listAllApps($onlyLocal = false) { $installedApps = OC_App::getAllApps(); //TODO which apps do we want to blacklist and how do we integrate @@ -823,6 +823,7 @@ class OC_App { $blacklist = array('files'); //we don't want to show configuration for these $appList = array(); + $l = \OC::$server->getL10N('core'); foreach ($installedApps as $app) { if (array_search($app, $blacklist) === false) { @@ -849,24 +850,36 @@ class OC_App { if(isset($info['shipped']) and ($info['shipped'] == 'true')) { $info['internal'] = true; - $info['internallabel'] = 'Internal App'; - $info['internalclass'] = ''; + $info['internallabel'] = $l->t('Recommended'); + $info['internalclass'] = 'recommendedapp'; $info['removable'] = false; } else { $info['internal'] = false; - $info['internallabel'] = '3rd Party'; - $info['internalclass'] = 'externalapp'; $info['removable'] = true; } $info['update'] = OC_Installer::isUpdateAvailable($app); - $info['preview'] = OC_Helper::imagePath('settings', 'trans.png'); + $appIcon = self::getAppPath($app) . '/img/' . $app.'.svg'; + if (file_exists($appIcon)) { + $info['preview'] = OC_Helper::imagePath($app, $app.'.svg'); + $info['previewAsIcon'] = true; + } else { + $appIcon = self::getAppPath($app) . '/img/app.svg'; + if (file_exists($appIcon)) { + $info['preview'] = OC_Helper::imagePath($app, 'app.svg'); + $info['previewAsIcon'] = true; + } + } $info['version'] = OC_App::getAppVersion($app); $appList[] = $info; } } - $remoteApps = OC_App::getAppstoreApps(); + if ($onlyLocal) { + $remoteApps = array(); + } else { + $remoteApps = OC_App::getAppstoreApps(); + } if ($remoteApps) { // Remove duplicates foreach ($appList as $app) { @@ -898,9 +911,11 @@ class OC_App { } // priority 3: recommended - if ($a['internalclass'] != $b['internalclass']) { - $aTemp = ($a['internalclass'] == 'recommendedapp' ? 1 : 0); - $bTemp = ($b['internalclass'] == 'recommendedapp' ? 1 : 0); + $internalClassA = isset($a['internalclass']) ? $a['internalclass'] : ''; + $internalClassB = isset($b['internalclass']) ? $b['internalclass'] : ''; + if ($internalClassA != $internalClassB) { + $aTemp = ($internalClassA == 'recommendedapp' ? 1 : 0); + $bTemp = ($internalClassB == 'recommendedapp' ? 1 : 0); return ($bTemp - $aTemp); } @@ -917,63 +932,40 @@ class OC_App { * @return array, multi-dimensional array of apps. * Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description */ - public static function getAppstoreApps($filter = 'approved') { - $categoryNames = OC_OCSClient::getCategories(); - if (is_array($categoryNames)) { - // Check that categories of apps were retrieved correctly - if (!$categories = array_keys($categoryNames)) { + public static function getAppstoreApps($filter = 'approved', $category = null) { + $categories = array($category); + if (is_null($category)) { + $categoryNames = OC_OCSClient::getCategories(); + if (is_array($categoryNames)) { + // Check that categories of apps were retrieved correctly + if (!$categories = array_keys($categoryNames)) { + return false; + } + } else { return false; } + } - $page = 0; - $remoteApps = OC_OCSClient::getApplications($categories, $page, $filter); - $app1 = array(); - $i = 0; - foreach ($remoteApps as $app) { - $app1[$i] = $app; - $app1[$i]['author'] = $app['personid']; - $app1[$i]['ocs_id'] = $app['id']; - $app1[$i]['internal'] = $app1[$i]['active'] = 0; - $app1[$i]['update'] = false; - $app1[$i]['groups'] = false; - $app1[$i]['removable'] = false; - if ($app['label'] == 'recommended') { - $app1[$i]['internallabel'] = 'Recommended'; - $app1[$i]['internalclass'] = 'recommendedapp'; - } else { - $app1[$i]['internallabel'] = '3rd Party'; - $app1[$i]['internalclass'] = 'externalapp'; - } - - - // rating img - if ($app['score'] < 5) { - $img = OC_Helper::imagePath( "core", "rating/s1.png" ); - } elseif ($app['score'] < 15) { - $img = OC_Helper::imagePath( "core", "rating/s2.png" ); - } elseif($app['score'] < 25) { - $img = OC_Helper::imagePath( "core", "rating/s3.png" ); - } elseif($app['score'] < 35) { - $img = OC_Helper::imagePath( "core", "rating/s4.png" ); - } elseif($app['score'] < 45) { - $img = OC_Helper::imagePath( "core", "rating/s5.png" ); - } elseif($app['score'] < 55) { - $img = OC_Helper::imagePath( "core", "rating/s6.png" ); - } elseif($app['score'] < 65) { - $img = OC_Helper::imagePath( "core", "rating/s7.png" ); - } elseif($app['score'] < 75) { - $img = OC_Helper::imagePath( "core", "rating/s8.png" ); - } elseif($app['score'] < 85) { - $img = OC_Helper::imagePath( "core", "rating/s9.png" ); - } elseif($app['score'] < 95) { - $img = OC_Helper::imagePath( "core", "rating/s10.png" ); - } elseif($app['score'] < 100) { - $img = OC_Helper::imagePath( "core", "rating/s11.png" ); - } - - $app1[$i]['score'] = '<img src="' . $img . '"> Score: ' . $app['score'] . '%'; - $i++; + $page = 0; + $remoteApps = OC_OCSClient::getApplications($categories, $page, $filter); + $app1 = array(); + $i = 0; + $l = \OC::$server->getL10N('core'); + foreach ($remoteApps as $app) { + $app1[$i] = $app; + $app1[$i]['author'] = $app['personid']; + $app1[$i]['ocs_id'] = $app['id']; + $app1[$i]['internal'] = $app1[$i]['active'] = 0; + $app1[$i]['update'] = false; + $app1[$i]['groups'] = false; + $app1[$i]['score'] = $app['score']; + $app1[$i]['removable'] = false; + if ($app['label'] == 'recommended') { + $app1[$i]['internallabel'] = $l->t('Recommended'); + $app1[$i]['internalclass'] = 'recommendedapp'; } + + $i++; } if (empty($app1)) { diff --git a/lib/private/connector/sabre/directory.php b/lib/private/connector/sabre/directory.php index 597fbdae0cc..1b6d1f363b8 100644 --- a/lib/private/connector/sabre/directory.php +++ b/lib/private/connector/sabre/directory.php @@ -84,7 +84,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node * @return void */ public function createDirectory($name) { - if (!$this->fileView->isCreatable($this->path)) { + if (!$this->info->isCreatable()) { throw new \Sabre\DAV\Exception\Forbidden(); } diff --git a/lib/private/files/storage/dav.php b/lib/private/files/storage/dav.php index a0ef79a7b32..7f53704e94f 100644 --- a/lib/private/files/storage/dav.php +++ b/lib/private/files/storage/dav.php @@ -58,7 +58,7 @@ class DAV extends \OC\Files\Storage\Common { $this->root .= '/'; } } else { - throw new \Exception(); + throw new \Exception('Invalid webdav storage configuration'); } } @@ -85,7 +85,7 @@ class DAV extends \OC\Files\Storage\Common { return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root; } - protected function createBaseUri() { + public function createBaseUri() { $baseUri = 'http'; if ($this->secure) { $baseUri .= 's'; diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 95f3e9a2c7f..3d3406af94e 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -1110,6 +1110,16 @@ class View { } /** + * search for files with the name matching $query + * + * @param string $query + * @return FileInfo[] + */ + public function searchRaw($query) { + return $this->searchCommon($query, 'search'); + } + + /** * search for files by mimetype * * @param string $mimetype diff --git a/lib/private/installer.php b/lib/private/installer.php index 02e2190aaf2..cd1d8ce392f 100644 --- a/lib/private/installer.php +++ b/lib/private/installer.php @@ -201,11 +201,10 @@ class OC_Installer{ /** * update an app by it's id * @param integer $ocsid - * @param bool $isShipped * @return bool * @throws Exception */ - public static function updateAppByOCSId($ocsid, $isShipped=false) { + public static function updateAppByOCSId($ocsid) { $appdata = OC_OCSClient::getApplication($ocsid); $download = OC_OCSClient::getApplicationDownload($ocsid, 1); diff --git a/lib/private/largefilehelper.php b/lib/private/largefilehelper.php index d5b7946feff..750ba1d23de 100644 --- a/lib/private/largefilehelper.php +++ b/lib/private/largefilehelper.php @@ -101,7 +101,7 @@ class LargeFileHelper { */ public function getFileSizeViaCurl($filename) { if (function_exists('curl_init')) { - $fencoded = urlencode($filename); + $fencoded = rawurlencode($filename); $ch = curl_init("file://$fencoded"); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @@ -151,7 +151,7 @@ class LargeFileHelper { $result = null; if (strpos($os, 'linux') !== false) { $result = $this->exec("stat -c %s $arg"); - } else if (strpos($os, 'bsd') !== false) { + } else if (strpos($os, 'bsd') !== false || strpos($os, 'darwin') !== false) { $result = $this->exec("stat -f %z $arg"); } else if (strpos($os, 'win') !== false) { $result = $this->exec("for %F in ($arg) do @echo %~zF"); diff --git a/lib/private/ocsclient.php b/lib/private/ocsclient.php index dc147dea0c9..8ceb43f4c1f 100644 --- a/lib/private/ocsclient.php +++ b/lib/private/ocsclient.php @@ -142,9 +142,11 @@ class OC_OCSClient{ $app['license']=(string)$tmp[$i]->license; $app['detailpage']=(string)$tmp[$i]->detailpage; $app['preview']=(string)$tmp[$i]->smallpreviewpic1; + $app['preview-full']=(string)$tmp[$i]->previewpic1; $app['changed']=strtotime($tmp[$i]->changed); $app['description']=(string)$tmp[$i]->description; $app['score']=(string)$tmp[$i]->score; + $app['downloads'] = $tmp[$i]->downloads; $apps[]=$app; } diff --git a/lib/private/setup.php b/lib/private/setup.php index b1b3388f81b..75dc1987ee6 100644 --- a/lib/private/setup.php +++ b/lib/private/setup.php @@ -86,7 +86,7 @@ class OC_Setup { //write the config file \OC::$server->getConfig()->setSystemValue('trusted_domains', $trustedDomains); \OC::$server->getConfig()->setSystemValue('datadirectory', $datadir); - \OC::$server->getConfig()->setSystemValue('overwritewebroot', OC::$WEBROOT); + \OC::$server->getConfig()->setSystemValue('overwrite.cli.url', \OC_Request::serverProtocol() . '://' . \OC_Request::serverHost() . OC::$WEBROOT); \OC::$server->getConfig()->setSystemValue('dbtype', $dbtype); \OC::$server->getConfig()->setSystemValue('version', implode('.', OC_Util::getVersion())); diff --git a/lib/private/urlgenerator.php b/lib/private/urlgenerator.php index f5ec9803edb..e50e9eed6af 100644 --- a/lib/private/urlgenerator.php +++ b/lib/private/urlgenerator.php @@ -162,6 +162,10 @@ class URLGenerator implements IURLGenerator { public function getAbsoluteURL($url) { $separator = $url[0] === '/' ? '' : '/'; + if (\OC::$CLI && !defined('PHPUNIT_RUN')) { + return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/'); + } + // The ownCloud web root can already be prepended. $webRoot = substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT ? '' diff --git a/lib/private/user/session.php b/lib/private/user/session.php index 5517e08a25d..b9c341b4ae9 100644 --- a/lib/private/user/session.php +++ b/lib/private/user/session.php @@ -91,8 +91,8 @@ class Session implements IUserSession, Emitter { // fetch the deprecated \OC::$session if it changed for backwards compatibility if (isset(\OC::$session) && \OC::$session !== $this->session) { \OC::$server->getLogger()->warning( - 'One of your installed apps still seems to use the deprecated '. - '\OC::$session and has replaced it with a new instance. Please file a bug against it.'. + 'One of your installed apps still seems to use the deprecated ' . + '\OC::$session and has replaced it with a new instance. Please file a bug against it.' . 'Closing and replacing session in UserSession instance.' ); $this->setSession(\OC::$session); @@ -110,6 +110,7 @@ class Session implements IUserSession, Emitter { $this->session->close(); } $this->session = $session; + $this->activeUser = null; // maintain deprecated \OC::$session if (\OC::$session !== $this->session) { @@ -195,7 +196,7 @@ class Session implements IUserSession, Emitter { public function login($uid, $password) { $this->manager->emit('\OC\User', 'preLogin', array($uid, $password)); $user = $this->manager->checkPassword($uid, $password); - if($user !== false) { + if ($user !== false) { if (!is_null($user)) { if ($user->isEnabled()) { $this->setUser($user); @@ -221,7 +222,7 @@ class Session implements IUserSession, Emitter { public function loginWithCookie($uid, $currentToken) { $this->manager->emit('\OC\User', 'preRememberedLogin', array($uid)); $user = $this->manager->get($uid); - if(is_null($user)) { + if (is_null($user)) { // user does not exist return false; } @@ -229,7 +230,7 @@ class Session implements IUserSession, Emitter { // get stored tokens $tokens = \OC_Preferences::getKeys($uid, 'login_token'); // test cookies token against stored tokens - if(!in_array($currentToken, $tokens, true)) { + if (!in_array($currentToken, $tokens, true)) { return false; } // replace successfully used token with a new one @@ -275,13 +276,13 @@ class Session implements IUserSession, Emitter { unset($_COOKIE["oc_username"]); //TODO: DI unset($_COOKIE["oc_token"]); unset($_COOKIE["oc_remember_login"]); - setcookie('oc_username', '', time()-3600, \OC::$WEBROOT); - setcookie('oc_token', '', time()-3600, \OC::$WEBROOT); - setcookie('oc_remember_login', '', time()-3600, \OC::$WEBROOT); + setcookie('oc_username', '', time() - 3600, \OC::$WEBROOT); + setcookie('oc_token', '', time() - 3600, \OC::$WEBROOT); + setcookie('oc_remember_login', '', time() - 3600, \OC::$WEBROOT); // old cookies might be stored under /webroot/ instead of /webroot // and Firefox doesn't like it! - setcookie('oc_username', '', time()-3600, \OC::$WEBROOT . '/'); - setcookie('oc_token', '', time()-3600, \OC::$WEBROOT . '/'); - setcookie('oc_remember_login', '', time()-3600, \OC::$WEBROOT . '/'); + setcookie('oc_username', '', time() - 3600, \OC::$WEBROOT . '/'); + setcookie('oc_token', '', time() - 3600, \OC::$WEBROOT . '/'); + setcookie('oc_remember_login', '', time() - 3600, \OC::$WEBROOT . '/'); } } diff --git a/lib/private/user/user.php b/lib/private/user/user.php index 993fb4c0c64..452261a75ff 100644 --- a/lib/private/user/user.php +++ b/lib/private/user/user.php @@ -89,8 +89,17 @@ class User implements IUser { */ public function getDisplayName() { if (!isset($this->displayName)) { + $displayName = ''; if ($this->backend and $this->backend->implementsActions(OC_USER_BACKEND_GET_DISPLAYNAME)) { - $this->displayName = $this->backend->getDisplayName($this->uid); + // get display name and strip whitespace from the beginning and end of it + $backendDisplayName = $this->backend->getDisplayName($this->uid); + if (is_string($backendDisplayName)) { + $displayName = trim($backendDisplayName); + } + } + + if (!empty($displayName)) { + $this->displayName = $displayName; } else { $this->displayName = $this->uid; } @@ -105,7 +114,8 @@ class User implements IUser { * @return bool */ public function setDisplayName($displayName) { - if ($this->canChangeDisplayName()) { + $displayName = trim($displayName); + if ($this->canChangeDisplayName() && !empty($displayName)) { $this->displayName = $displayName; $result = $this->backend->setDisplayName($this->uid, $displayName); return $result !== false; diff --git a/lib/private/util.php b/lib/private/util.php index 304db827a1a..c0a68c56223 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -986,7 +986,7 @@ class OC_Util { * file in the data directory and trying to access via http */ public static function isHtaccessWorking() { - if (!OC::$server->getConfig()->getSystemValue('check_for_working_htaccess', true)) { + if (\OC::$CLI || !OC::$server->getConfig()->getSystemValue('check_for_working_htaccess', true)) { return true; } |