diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/app.php | 9 | ||||
-rw-r--r-- | lib/archive/tar.php | 2 | ||||
-rw-r--r-- | lib/base.php | 26 | ||||
-rw-r--r-- | lib/helper.php | 7 | ||||
-rw-r--r-- | lib/hook.php | 22 | ||||
-rw-r--r-- | lib/l10n/ru.php | 1 | ||||
-rw-r--r-- | lib/public/share.php | 10 | ||||
-rw-r--r-- | lib/public/util.php | 18 | ||||
-rw-r--r-- | lib/router.php | 6 | ||||
-rw-r--r-- | lib/templatelayout.php | 6 | ||||
-rw-r--r-- | lib/user.php | 38 | ||||
-rwxr-xr-x | lib/util.php | 13 |
12 files changed, 129 insertions, 29 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/archive/tar.php b/lib/archive/tar.php index 117d88e5f42..e7c81389619 100644 --- a/lib/archive/tar.php +++ b/lib/archive/tar.php @@ -6,7 +6,7 @@ * See the COPYING-README file. */ -require_once 'Archive/Tar.php'; +require_once OC::$THIRDPARTYROOT . '/3rdparty/Archive/Tar.php'; class OC_Archive_TAR extends OC_Archive{ const PLAIN=0; diff --git a/lib/base.php b/lib/base.php index 90e64f13af6..5bfdb0b7c0a 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) { @@ -552,14 +554,16 @@ class OC { self::checkUpgrade(); } - try { - OC::getRouter()->match(OC_Request::getPathInfo()); - return; - } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) { - //header('HTTP/1.0 404 Not Found'); - } catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) { - OC_Response::setStatus(405); - return; + if (!self::$CLI) { + try { + OC::getRouter()->match(OC_Request::getPathInfo()); + return; + } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) { + //header('HTTP/1.0 404 Not Found'); + } catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) { + OC_Response::setStatus(405); + return; + } } $app = OC::$REQUESTEDAPP; diff --git a/lib/helper.php b/lib/helper.php index 0e549d006a1..a0fbdd10394 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -394,13 +394,12 @@ class OC_Helper { // it looks like we have a 'file' command, // lets see if it does have mime support $path=escapeshellarg($path); - $fp = popen("file -i -b $path 2>/dev/null", "r"); + $fp = popen("file -b --mime-type $path 2>/dev/null", "r"); $reply = fgets($fp); pclose($fp); - // we have smth like 'text/x-c++; charset=us-ascii\n' - // and need to eliminate everything starting with semicolon including trailing LF - $mimeType = preg_replace('/;.*/ms', '', trim($reply)); + //trim the newline + $mimeType = trim($reply); } return $mimeType; 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/ru.php b/lib/l10n/ru.php index 3ed55f8e9dc..5ef2cca3be3 100644 --- a/lib/l10n/ru.php +++ b/lib/l10n/ru.php @@ -9,6 +9,7 @@ "Files need to be downloaded one by one." => "Файлы должны быть загружены по одному.", "Back to Files" => "Назад к файлам", "Selected files too large to generate zip file." => "Выбранные файлы слишком велики, чтобы создать zip файл.", +"couldn't be determined" => "Невозможно установить", "Application is not enabled" => "Приложение не разрешено", "Authentication error" => "Ошибка аутентификации", "Token expired. Please reload page." => "Токен просрочен. Перезагрузите страницу.", diff --git a/lib/public/share.php b/lib/public/share.php index 9aacf5e3449..af2a538e252 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -704,7 +704,7 @@ class Share { $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `uid_owner`, ' .'`share_type`, `share_with`, `file_source`, `path`, `file_target`, ' .'`permissions`, `expiration`, `storage`, `*PREFIX*filecache`.`parent` as `file_parent`, ' - .'`name` `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`'; + .'`name`, `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`'; } else { $select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`, `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`'; } @@ -721,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']])) { @@ -745,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']; } @@ -848,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/public/util.php b/lib/public/util.php index a78a52f326e..5f6ede4460e 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -59,9 +59,9 @@ class Util { * @param string $fromname * @param bool $html */ - public static function sendMail( $toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html=0, $altbody='', $ccaddress='', $ccname='', $bcc='') { + public static function sendMail( $toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '') { // call the internal mail class - \OC_MAIL::send($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = ''); + \OC_MAIL::send($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html, $altbody, $ccaddress, $ccname, $bcc); } /** @@ -148,6 +148,20 @@ class Util { } /** + * @brief Creates an url using a defined route + * @param $route + * @param array $parameters + * @return + * @internal param array $args 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 linkToRoute( $route, $parameters = array() ) { + return \OC_Helper::linkToRoute($route, $parameters); + } + + /** * @brief Creates an url * @param string $app app * @param string $file file diff --git a/lib/router.php b/lib/router.php index 746b68c2c0c..dbaca9e0d5d 100644 --- a/lib/router.php +++ b/lib/router.php @@ -23,7 +23,11 @@ class OC_Router { public function __construct() { $baseUrl = OC_Helper::linkTo('', 'index.php'); - $method = $_SERVER['REQUEST_METHOD']; + if ( !OC::$CLI) { + $method = $_SERVER['REQUEST_METHOD']; + }else{ + $method = 'GET'; + } $host = OC_Request::serverHost(); $schema = OC_Request::serverProtocol(); $this->context = new RequestContext($baseUrl, $method, $host, $schema); diff --git a/lib/templatelayout.php b/lib/templatelayout.php index 37ece91047f..345f540af04 100644 --- a/lib/templatelayout.php +++ b/lib/templatelayout.php @@ -19,6 +19,7 @@ class OC_TemplateLayout extends OC_Template { } // Add navigation entry + $this->assign( 'application', '', false ); $navigation = OC_App::getNavigation(); $this->assign( 'navigation', $navigation, false); $this->assign( 'settingsnavigation', OC_App::getSettingsNavigation(), false); @@ -28,6 +29,8 @@ class OC_TemplateLayout extends OC_Template { break; } } + $user_displayname = OC_User::getDisplayName(); + $this->assign( 'user_displayname', $user_displayname ); } else if ($renderas == 'guest') { parent::__construct('core', 'layout.guest'); } else { @@ -36,6 +39,9 @@ class OC_TemplateLayout extends OC_Template { // Add the js files $jsfiles = self::findJavascriptFiles(OC_Util::$scripts); $this->assign('jsfiles', array(), false); + if (OC_Config::getValue('installed', false)) { + $this->append( 'jsfiles', OC_Helper::linkToRoute('js_config')); + } if (!empty(OC_Util::$core_scripts)) { $this->append( 'jsfiles', OC_Helper::linkToRemoteBase('core.js', false)); } 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 4932be2d6cc..9ce974619bc 100755 --- a/lib/util.php +++ b/lib/util.php @@ -300,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); } @@ -533,6 +535,14 @@ class OC_Util { } /** + * Check if the PHP module fileinfo is loaded. + * @return bool + */ + public static function fileInfoLoaded() { + return function_exists('finfo_open'); + } + + /** * Check if the ownCloud server can connect to the internet */ public static function isinternetconnectionworking() { @@ -644,6 +654,9 @@ class OC_Util { curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($curl, CURLOPT_MAXREDIRS, 10); + curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler"); if(OC_Config::getValue('proxy','')<>'') { curl_setopt($curl, CURLOPT_PROXY, OC_Config::getValue('proxy')); |