diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/app.php | 9 | ||||
-rw-r--r-- | lib/base.php | 8 | ||||
-rw-r--r-- | lib/files/cache/cache.php | 8 | ||||
-rw-r--r-- | lib/files/filesystem.php | 13 | ||||
-rw-r--r-- | lib/files/storage/local.php | 4 | ||||
-rw-r--r-- | lib/files/storage/temporary.php | 4 | ||||
-rw-r--r-- | lib/hook.php | 22 | ||||
-rw-r--r-- | lib/l10n/af_ZA.php | 8 | ||||
-rw-r--r-- | lib/l10n/lv.php | 31 | ||||
-rw-r--r-- | lib/public/contacts.php | 4 | ||||
-rw-r--r-- | lib/public/share.php | 28 | ||||
-rw-r--r-- | lib/template.php | 2 | ||||
-rw-r--r-- | lib/user.php | 38 | ||||
-rwxr-xr-x | lib/util.php | 25 |
14 files changed, 172 insertions, 32 deletions
diff --git a/lib/app.php b/lib/app.php index fa3e14ce4d2..3a4e21e8cd1 100644 --- a/lib/app.php +++ b/lib/app.php @@ -36,6 +36,7 @@ class OC_App{ static private $appTypes = array(); static private $loadedApps = array(); static private $checkedApps = array(); + static private $altLogin = array(); /** * @brief loads all apps @@ -568,6 +569,14 @@ class OC_App{ self::$personalForms[]= $app.'/'.$page.'.php'; } + public static function registerLogIn($entry) { + self::$altLogin[] = $entry; + } + + public static function getAlternativeLogIns() { + return self::$altLogin; + } + /** * @brief: get a list of all apps in the apps folder * @return array or app names (string IDs) diff --git a/lib/base.php b/lib/base.php index 90e64f13af6..b432f282aaf 100644 --- a/lib/base.php +++ b/lib/base.php @@ -402,9 +402,11 @@ class OC { self::initPaths(); - register_shutdown_function(array('OC_Log', 'onShutdown')); - set_error_handler(array('OC_Log', 'onError')); - set_exception_handler(array('OC_Log', 'onException')); + if (!defined('PHPUNIT_RUN')) { + register_shutdown_function(array('OC_Log', 'onShutdown')); + set_error_handler(array('OC_Log', 'onError')); + set_exception_handler(array('OC_Log', 'onException')); + } // set debug mode if an xdebug session is active if (!defined('DEBUG') || !DEBUG) { diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php index 69cbaea8516..dcb6e8fd39a 100644 --- a/lib/files/cache/cache.php +++ b/lib/files/cache/cache.php @@ -410,7 +410,13 @@ class Cache { ); $mimetype = $this->getMimetypeId($mimetype); $result = $query->execute(array($mimetype, $this->numericId)); - return $result->fetchAll(); + $files = array(); + while ($row = $result->fetchRow()) { + $row['mimetype'] = $this->getMimetype($row['mimetype']); + $row['mimepart'] = $this->getMimetype($row['mimepart']); + $files[] = $row; + } + return $files; } /** diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index 65d9ffab485..71bf3d8708d 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -527,8 +527,7 @@ class Filesystem { } /** - * normalize a path - * + * @brief Fix common problems with a file path * @param string $path * @param bool $stripTrailingSlash * @return string @@ -537,21 +536,21 @@ class Filesystem { if ($path == '') { return '/'; } -//no windows style slashes + //no windows style slashes $path = str_replace('\\', '/', $path); -//add leading slash + //add leading slash if ($path[0] !== '/') { $path = '/' . $path; } -//remove duplicate slashes + //remove duplicate slashes while (strpos($path, '//') !== false) { $path = str_replace('//', '/', $path); } -//remove trailing slash + //remove trailing slash if ($stripTrailingSlash and strlen($path) > 1 and substr($path, -1, 1) === '/') { $path = substr($path, 0, -1); } -//normalize unicode if possible + //normalize unicode if possible if (class_exists('Normalizer')) { $path = \Normalizer::normalize($path); } diff --git a/lib/files/storage/local.php b/lib/files/storage/local.php index 9fc9d375bb3..a5db4ba9194 100644 --- a/lib/files/storage/local.php +++ b/lib/files/storage/local.php @@ -184,7 +184,7 @@ class Local extends \OC\Files\Storage\Common{ // Windows OS: we use COM to access the filesystem if (strpos($name, 'win') !== false) { if (class_exists('COM')) { - $fsobj = new COM("Scripting.FileSystemObject"); + $fsobj = new \COM("Scripting.FileSystemObject"); $f = $fsobj->GetFile($fullPath); return $f->Size; } @@ -197,7 +197,7 @@ class Local extends \OC\Files\Storage\Common{ return (float)exec('stat -c %s ' . escapeshellarg($fullPath)); } } else { - OC_Log::write('core', 'Unable to determine file size of "'.$fullPath.'". Unknown OS: '.$name, OC_Log::ERROR); + \OC_Log::write('core', 'Unable to determine file size of "'.$fullPath.'". Unknown OS: '.$name, \OC_Log::ERROR); } return 0; diff --git a/lib/files/storage/temporary.php b/lib/files/storage/temporary.php index ffc55e27507..542d2cd9f48 100644 --- a/lib/files/storage/temporary.php +++ b/lib/files/storage/temporary.php @@ -9,11 +9,11 @@ namespace OC\Files\Storage; /** - * local storage backnd in temporary folder for testing purpores + * local storage backend in temporary folder for testing purpose */ class Temporary extends Local{ public function __construct($arguments) { - $this->datadir=\OC_Helper::tmpFolder(); + parent::__construct(array('datadir' => \OC_Helper::tmpFolder())); } public function cleanUp() { diff --git a/lib/hook.php b/lib/hook.php index 4da331bb5d8..e30aefb5e18 100644 --- a/lib/hook.php +++ b/lib/hook.php @@ -20,19 +20,22 @@ class OC_Hook{ * TODO: write example */ static public function connect( $signalclass, $signalname, $slotclass, $slotname ) { - // Create the data structure + // If we're trying to connect to an emitting class that isn't + // yet registered, register it if( !array_key_exists( $signalclass, self::$registered )) { self::$registered[$signalclass] = array(); } - if( !array_key_exists( $signalname, self::$registered[$signalclass] )) { + // If we're trying to connect to an emitting method that isn't + // yet registered, register it with the emitting class + if( !array_key_exists( $signalname, self::$registered[$signalclass] )) { self::$registered[$signalclass][$signalname] = array(); } - - // register hook + + // Connect the hook handler to the requested emitter self::$registered[$signalclass][$signalname][] = array( "class" => $slotclass, "name" => $slotname ); - + // No chance for failure ;-) return true; } @@ -49,14 +52,19 @@ class OC_Hook{ * TODO: write example */ static public function emit( $signalclass, $signalname, $params = array()) { - // Return false if there are no slots + + // Return false if no hook handlers are listening to this + // emitting class if( !array_key_exists( $signalclass, self::$registered )) { return false; } + + // Return false if no hook handlers are listening to this + // emitting method if( !array_key_exists( $signalname, self::$registered[$signalclass] )) { return false; } - + // Call all slots foreach( self::$registered[$signalclass][$signalname] as $i ) { try { diff --git a/lib/l10n/af_ZA.php b/lib/l10n/af_ZA.php new file mode 100644 index 00000000000..38e91288fbe --- /dev/null +++ b/lib/l10n/af_ZA.php @@ -0,0 +1,8 @@ +<?php $TRANSLATIONS = array( +"Help" => "Hulp", +"Personal" => "Persoonlik", +"Settings" => "Instellings", +"Users" => "Gebruikers", +"Apps" => "Toepassings", +"Admin" => "Admin" +); diff --git a/lib/l10n/lv.php b/lib/l10n/lv.php index 3330d0e6b70..9f2a0dea749 100644 --- a/lib/l10n/lv.php +++ b/lib/l10n/lv.php @@ -3,6 +3,33 @@ "Personal" => "Personīgi", "Settings" => "Iestatījumi", "Users" => "Lietotāji", -"Authentication error" => "Ielogošanās kļūme", -"Files" => "Faili" +"Apps" => "Lietotnes", +"Admin" => "Administratori", +"ZIP download is turned off." => "ZIP lejupielādēšana ir izslēgta.", +"Files need to be downloaded one by one." => "Datnes var lejupielādēt tikai katru atsevišķi.", +"Back to Files" => "Atpakaļ pie datnēm", +"Selected files too large to generate zip file." => "Izvēlētās datnes ir pārāk lielas, lai izveidotu zip datni.", +"couldn't be determined" => "nevarēja noteikt", +"Application is not enabled" => "Lietotne nav aktivēta", +"Authentication error" => "Autentifikācijas kļūda", +"Token expired. Please reload page." => "Pilnvarai ir beidzies termiņš. Lūdzu, pārlādējiet lapu.", +"Files" => "Datnes", +"Text" => "Teksts", +"Images" => "Attēli", +"seconds ago" => "sekundes atpakaļ", +"1 minute ago" => "pirms 1 minūtes", +"%d minutes ago" => "pirms %d minūtēm", +"1 hour ago" => "pirms 1 stundas", +"%d hours ago" => "pirms %d stundām", +"today" => "šodien", +"yesterday" => "vakar", +"%d days ago" => "pirms %d dienām", +"last month" => "pagājušajā mēnesī", +"%d months ago" => "pirms %d mēnešiem", +"last year" => "gājušajā gadā", +"years ago" => "gadus atpakaļ", +"%s is available. Get <a href=\"%s\">more information</a>" => "%s ir pieejams. Iegūt <a href=\"%s\">vairāk informācijas</a>", +"up to date" => "ir aktuāls", +"updates check is disabled" => "atjauninājumu pārbaude ir deaktivēta", +"Could not find category \"%s\"" => "Nevarēja atrast kategoriju “%s”" ); diff --git a/lib/public/contacts.php b/lib/public/contacts.php index 88d812e735a..44d82c37908 100644 --- a/lib/public/contacts.php +++ b/lib/public/contacts.php @@ -149,14 +149,14 @@ namespace OCP { /** * @param \OCP\IAddressBook $address_book */ - public static function registerAddressBook(\OCP\IAddressBook $address_book) { + public static function registerAddressBook($address_book) { self::$address_books[$address_book->getKey()] = $address_book; } /** * @param \OCP\IAddressBook $address_book */ - public static function unregisterAddressBook(\OCP\IAddressBook $address_book) { + public static function unregisterAddressBook($address_book) { unset(self::$address_books[$address_book->getKey()]); } diff --git a/lib/public/share.php b/lib/public/share.php index 3c5c2d53782..d46bee26dd4 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -342,6 +342,13 @@ class Share { */ public static function unshare($itemType, $itemSource, $shareType, $shareWith) { if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith, \OC_User::getUser(), self::FORMAT_NONE, null, 1)) { + // Pass all the vars we have for now, they may be useful + \OC_Hook::emit('OCP\Share', 'pre_unshare', array( + 'itemType' => $itemType, + 'itemSource' => $itemSource, + 'shareType' => $shareType, + 'shareWith' => $shareWith, + )); self::delete($item['id']); return true; } @@ -356,6 +363,12 @@ class Share { */ public static function unshareAll($itemType, $itemSource) { if ($shares = self::getItemShared($itemType, $itemSource)) { + // Pass all the vars we have for now, they may be useful + \OC_Hook::emit('OCP\Share', 'pre_unshareAll', array( + 'itemType' => $itemType, + 'itemSource' => $itemSource, + 'shares' => $shares + )); foreach ($shares as $share) { self::delete($share['id']); } @@ -516,7 +529,8 @@ class Share { $collectionTypes[] = $type; } } - if (!self::getBackend($itemType) instanceof Share_Backend_Collection) { + // TODO Add option for collections to be collection of themselves, only 'folder' does it now... + if (!self::getBackend($itemType) instanceof Share_Backend_Collection || $itemType != 'folder') { unset($collectionTypes[0]); } // Return array if collections were found or the item type is a collection itself - collections can be inside collections @@ -707,6 +721,7 @@ class Share { } $items = array(); $targets = array(); + $switchedItems = array(); while ($row = $result->fetchRow()) { // Filter out duplicate group shares for users with unique targets if ($row['share_type'] == self::$shareTypeGroupUserUnique && isset($items[$row['parent']])) { @@ -731,6 +746,7 @@ class Share { // Switch ids if sharing permission is granted on only one share to ensure correct parent is used if resharing if (~(int)$items[$id]['permissions'] & PERMISSION_SHARE && (int)$row['permissions'] & PERMISSION_SHARE) { $items[$row['id']] = $items[$id]; + $switchedItems[$id] = $row['id']; unset($items[$id]); $id = $row['id']; } @@ -763,8 +779,8 @@ class Share { if ( isset($row['share_with']) && $row['share_with'] != '') { $row['share_with_displayname'] = \OCP\User::getDisplayName($row['share_with']); } - if ( isset($row['uid_owner']) && $row['uid_owner'] != '') {
- $row['displayname_owner'] = \OCP\User::getDisplayName($row['uid_owner']);
+ if ( isset($row['uid_owner']) && $row['uid_owner'] != '') { + $row['displayname_owner'] = \OCP\User::getDisplayName($row['uid_owner']); } $items[$row['id']] = $row; @@ -834,7 +850,11 @@ class Share { } } // Remove collection item - unset($items[$row['id']]); + $toRemove = $row['id']; + if (array_key_exists($toRemove, $switchedItems)) { + $toRemove = $switchedItems[$toRemove]; + } + unset($items[$toRemove]); } } if (!empty($collectionItems)) { diff --git a/lib/template.php b/lib/template.php index 238d8a8ad0f..fb9f7ad62d9 100644 --- a/lib/template.php +++ b/lib/template.php @@ -192,7 +192,7 @@ class OC_Template{ // Content Security Policy // If you change the standard policy, please also change it in config.sample.php - $policy = OC_Config::getValue('custom_csp_policy', 'default-src \'self\'; script-src \'self\' \'unsafe-eval\'; style-src \'self\' \'unsafe-inline\'; frame-src *; img-src *'); + $policy = OC_Config::getValue('custom_csp_policy', 'default-src \'self\'; script-src \'self\' \'unsafe-eval\'; style-src \'self\' \'unsafe-inline\'; frame-src *; img-src *; font-src \'self\' data:'); header('Content-Security-Policy:'.$policy); // Standard header('X-WebKit-CSP:'.$policy); // Older webkit browsers diff --git a/lib/user.php b/lib/user.php index 38259bceea5..9dc8cca97a6 100644 --- a/lib/user.php +++ b/lib/user.php @@ -275,7 +275,7 @@ class OC_User { foreach(self::$_usedBackends as $backend) { if($backend->implementsActions(OC_USER_BACKEND_SET_DISPLAYNAME)) { if($backend->userExists($uid)) { - $success |= $backend->setDisplayName($uid, $displayName); + $result |= $backend->setDisplayName($uid, $displayName); } } } @@ -420,6 +420,42 @@ class OC_User { } /** + * @brief Check whether user can change his password + * @param $uid The username + * @returns true/false + * + * Check whether a specified user can change his password + */ + public static function canUserChangePassword($uid) { + foreach(self::$_usedBackends as $backend) { + if($backend->implementsActions(OC_USER_BACKEND_SET_PASSWORD)) { + if($backend->userExists($uid)) { + return true; + } + } + } + return false; + } + + /** + * @brief Check whether user can change his display name + * @param $uid The username + * @returns true/false + * + * Check whether a specified user can change his display name + */ + public static function canUserChangeDisplayName($uid) { + foreach(self::$_usedBackends as $backend) { + if($backend->implementsActions(OC_USER_BACKEND_SET_DISPLAYNAME)) { + if($backend->userExists($uid)) { + return true; + } + } + } + return false; + } + + /** * @brief Check if the password is correct * @param $uid The username * @param $password The password diff --git a/lib/util.php b/lib/util.php index 4de34b9dfda..faa1a549e64 100755 --- a/lib/util.php +++ b/lib/util.php @@ -243,6 +243,17 @@ class OC_Util { $web_server_restart= false; } + $handler = ini_get("session.save_handler"); + if($handler == "files") { + $tmpDir = session_save_path(); + if($tmpDir != ""){ + if(!@is_writable($tmpDir)){ + $errors[]=array('error' => 'The temporary folder used by PHP to save the session data is either incorrect or not writable! Please check : '.session_save_path().'<br/>', + 'hint'=>'Please ask your server administrator to grant write access or define another temporary folder.'); + } + } + } + if($web_server_restart) { $errors[]=array('error'=>'PHP modules have been installed, but they are still listed as missing?<br/>', 'hint'=>'Please ask your server administrator to restart the web server.'); } @@ -289,6 +300,8 @@ class OC_Util { $redirect_url = OC_Util::sanitizeHTML($_REQUEST['redirect_url']); $parameters['redirect_url'] = urlencode($redirect_url); } + + $parameters['alt_login'] = OC_App::getAlternativeLogIns(); OC_Template::printGuestPage("", "login", $parameters); } @@ -508,6 +521,11 @@ class OC_Util { * Check if the setlocal call doesn't work. This can happen if the right local packages are not available on the server. */ public static function issetlocaleworking() { + // setlocale test is pointless on Windows + if (OC_Util::runningOnWindows() ) { + return true; + } + $result=setlocale(LC_ALL, 'en_US.UTF-8'); if($result==false) { return(false); @@ -674,4 +692,11 @@ class OC_Util { return $data; } + /** + * @return bool - well are we running on windows or not + */ + public static function runningOnWindows() { + return (substr(PHP_OS, 0, 3) === "WIN"); + } + } |