diff options
Diffstat (limited to 'lib')
30 files changed, 246 insertions, 159 deletions
diff --git a/lib/private/api.php b/lib/private/api.php index f5576af2ad8..66b763fdc3e 100644 --- a/lib/private/api.php +++ b/lib/private/api.php @@ -132,7 +132,7 @@ class OC_API { * @return array|\OC_OCS_Result */ public static function mergeResponses($responses) { - // Sort into shipped and thirdparty + // Sort into shipped and third-party $shipped = array( 'succeeded' => array(), 'failed' => array(), @@ -162,7 +162,7 @@ class OC_API { if(!empty($shipped['failed'])) { // Which shipped response do we use if they all failed? // They may have failed for different reasons (different status codes) - // Which reponse code should we return? + // Which response code should we return? // Maybe any that are not OC_API::RESPOND_SERVER_ERROR // Merge failed responses if more than one $data = array(); @@ -273,26 +273,32 @@ class OC_API { // reuse existing login $loggedIn = OC_User::isLoggedIn(); - $ocsApiRequest = isset($_SERVER['HTTP_OCS_APIREQUEST']) ? $_SERVER['HTTP_OCS_APIREQUEST'] === 'true' : false; - if ($loggedIn === true && $ocsApiRequest) { + if ($loggedIn === true) { + $ocsApiRequest = isset($_SERVER['HTTP_OCS_APIREQUEST']) ? $_SERVER['HTTP_OCS_APIREQUEST'] === 'true' : false; + if ($ocsApiRequest) { - // initialize the user's filesystem - \OC_Util::setUpFS(\OC_User::getUser()); + // initialize the user's filesystem + \OC_Util::setUpFS(\OC_User::getUser()); - return OC_User::getUser(); + return OC_User::getUser(); + } + return false; } - // basic auth - $authUser = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : ''; - $authPw = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : ''; - $return = OC_User::login($authUser, $authPw); - if ($return === true) { - self::$logoutRequired = true; + // basic auth - because OC_User::login will create a new session we shall only try to login + // if user and pass are set + if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) ) { + $authUser = $_SERVER['PHP_AUTH_USER']; + $authPw = $_SERVER['PHP_AUTH_PW']; + $return = OC_User::login($authUser, $authPw); + if ($return === true) { + self::$logoutRequired = true; - // initialize the user's filesystem - \OC_Util::setUpFS(\OC_User::getUser()); + // initialize the user's filesystem + \OC_Util::setUpFS(\OC_User::getUser()); - return $authUser; + return $authUser; + } } return false; diff --git a/lib/private/app.php b/lib/private/app.php index bc9ca0351ea..8e36d43bfb1 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -635,63 +635,10 @@ class OC_App { } $file = self::getAppPath($appId) . '/appinfo/info.xml'; } - $data = array(); - if (!file_exists($file)) { - return null; - } - $content = @file_get_contents($file); - if (!$content) { - return null; - } - $xml = new SimpleXMLElement($content); - $data['info'] = array(); - $data['remote'] = array(); - $data['public'] = array(); - foreach ($xml->children() as $child) { - /** - * @var $child SimpleXMLElement - */ - if ($child->getName() == 'remote') { - foreach ($child->children() as $remote) { - /** - * @var $remote SimpleXMLElement - */ - $data['remote'][$remote->getName()] = (string)$remote; - } - } elseif ($child->getName() == 'public') { - foreach ($child->children() as $public) { - /** - * @var $public SimpleXMLElement - */ - $data['public'][$public->getName()] = (string)$public; - } - } elseif ($child->getName() == 'types') { - $data['types'] = array(); - foreach ($child->children() as $type) { - /** - * @var $type SimpleXMLElement - */ - $data['types'][] = $type->getName(); - } - } elseif ($child->getName() == 'description') { - $xml = (string)$child->asXML(); - $data[$child->getName()] = substr($xml, 13, -14); //script <description> tags - } elseif ($child->getName() == 'documentation') { - foreach ($child as $subChild) { - $url = (string) $subChild; - - // If it is not an absolute URL we assume it is a key - // i.e. admin-ldap will get converted to go.php?to=admin-ldap - if(!\OC::$server->getHTTPHelper()->isHTTPURL($url)) { - $url = OC_Helper::linkToDocs($url); - } - $data["documentation"][$subChild->getName()] = $url; - } - } else { - $data[$child->getName()] = (string)$child; - } - } + $parser = new \OC\App\InfoParser(\OC::$server->getHTTPHelper(), \OC::$server->getURLGenerator()); + $data = $parser->parse($file); + self::$appInfo[$appId] = $data; return $data; diff --git a/lib/private/app/infoparser.php b/lib/private/app/infoparser.php new file mode 100644 index 00000000000..b4bdbea5c04 --- /dev/null +++ b/lib/private/app/infoparser.php @@ -0,0 +1,84 @@ +<?php + /** + * @author Thomas Müller + * @copyright 2014 Thomas Müller deepdiver@owncloud.com + * + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\App; + +use OCP\IURLGenerator; + +class InfoParser { + /** + * @var \OC\HTTPHelper + */ + private $httpHelper; + + /** + * @var IURLGenerator + */ + private $urlGenerator; + + /** + * @param \OC\HTTPHelper $httpHelper + * @param IURLGenerator $urlGenerator + */ + public function __construct(\OC\HTTPHelper $httpHelper, IURLGenerator $urlGenerator) { + $this->httpHelper = $httpHelper; + $this->urlGenerator = $urlGenerator; + } + + /** + * @param string $file the xml file to be loaded + * @return null|array where null is an indicator for an error + */ + public function parse($file) { + if (!file_exists($file)) { + return null; + } + + $loadEntities = libxml_disable_entity_loader(false); + $xml = @simplexml_load_file($file); + libxml_disable_entity_loader($loadEntities); + if ($xml == false) { + return null; + } + $array = json_decode(json_encode((array)$xml), TRUE); + if (is_null($array)) { + return null; + } + if (!array_key_exists('info', $array)) { + $array['info'] = array(); + } + if (!array_key_exists('remote', $array)) { + $array['remote'] = array(); + } + if (!array_key_exists('public', $array)) { + $array['public'] = array(); + } + + if (array_key_exists('documentation', $array)) { + foreach ($array['documentation'] as $key => $url) { + // If it is not an absolute URL we assume it is a key + // i.e. admin-ldap will get converted to go.php?to=admin-ldap + if (!$this->httpHelper->isHTTPURL($url)) { + $url = $this->urlGenerator->linkToDocs($url); + } + + $array['documentation'][$key] = $url; + } + } + if (array_key_exists('types', $array)) { + foreach ($array['types'] as $type => $v) { + unset($array['types'][$type]); + $array['types'][] = $type; + } + } + + return $array; + } +} diff --git a/lib/private/contacts/localaddressbook.php b/lib/private/contacts/localaddressbook.php index 483bbee83f8..91ddb5798f2 100644 --- a/lib/private/contacts/localaddressbook.php +++ b/lib/private/contacts/localaddressbook.php @@ -91,7 +91,7 @@ class LocalAddressBook implements \OCP\IAddressBook { * @return int */ public function getPermissions() { - return \OCP\PERMISSION_READ; + return \OCP\Constants::PERMISSION_READ; } /** diff --git a/lib/private/contactsmanager.php b/lib/private/contactsmanager.php index 338cc048651..737fc4f0e3a 100644 --- a/lib/private/contactsmanager.php +++ b/lib/private/contactsmanager.php @@ -62,7 +62,7 @@ namespace OC { return null; } - if ($addressBook->getPermissions() & \OCP\PERMISSION_DELETE) { + if ($addressBook->getPermissions() & \OCP\Constants::PERMISSION_DELETE) { return null; } @@ -83,7 +83,7 @@ namespace OC { return null; } - if ($addressBook->getPermissions() & \OCP\PERMISSION_CREATE) { + if ($addressBook->getPermissions() & \OCP\Constants::PERMISSION_CREATE) { return null; } diff --git a/lib/private/db/connectionfactory.php b/lib/private/db/connectionfactory.php index f6253e09b95..58043b30440 100644 --- a/lib/private/db/connectionfactory.php +++ b/lib/private/db/connectionfactory.php @@ -90,7 +90,8 @@ class ConnectionFactory { $eventManager->addEventSubscriber(new \Doctrine\DBAL\Event\Listeners\OracleSessionInit); break; case 'sqlite3': - $eventManager->addEventSubscriber(new SQLiteSessionInit); + $journalMode = $additionalConnectionParams['sqlite.journal_mode']; + $eventManager->addEventSubscriber(new SQLiteSessionInit(true, $journalMode)); break; } $connection = \Doctrine\DBAL\DriverManager::getConnection( @@ -153,6 +154,7 @@ class ConnectionFactory { } $connectionParams['tablePrefix'] = $config->getSystemValue('dbtableprefix', 'oc_'); + $connectionParams['sqlite.journal_mode'] = $config->getSystemValue('sqlite.journal_mode', 'WAL'); //additional driver options, eg. for mysql ssl $driverOptions = $config->getSystemValue('dbdriveroptions', null); diff --git a/lib/private/db/sqlitesessioninit.php b/lib/private/db/sqlitesessioninit.php index 7e1166be95b..1fff22b883a 100644 --- a/lib/private/db/sqlitesessioninit.php +++ b/lib/private/db/sqlitesessioninit.php @@ -19,12 +19,19 @@ class SQLiteSessionInit implements EventSubscriber { private $caseSensitiveLike; /** + * @var string + */ + private $journalMode; + + /** * Configure case sensitive like for each connection * * @param bool $caseSensitiveLike + * @param string $journalMode */ - public function __construct($caseSensitiveLike = true) { + public function __construct($caseSensitiveLike, $journalMode) { $this->caseSensitiveLike = $caseSensitiveLike; + $this->journalMode = $journalMode; } /** @@ -34,6 +41,7 @@ class SQLiteSessionInit implements EventSubscriber { public function postConnect(ConnectionEventArgs $args) { $sensitive = ($this->caseSensitiveLike) ? 'true' : 'false'; $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive); + $args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode); } public function getSubscribedEvents() { diff --git a/lib/private/files/fileinfo.php b/lib/private/files/fileinfo.php index d6d6a245e44..8bab51f0737 100644 --- a/lib/private/files/fileinfo.php +++ b/lib/private/files/fileinfo.php @@ -173,14 +173,14 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { * @return bool */ public function isReadable() { - return $this->checkPermissions(\OCP\PERMISSION_READ); + return $this->checkPermissions(\OCP\Constants::PERMISSION_READ); } /** * @return bool */ public function isUpdateable() { - return $this->checkPermissions(\OCP\PERMISSION_UPDATE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE); } /** @@ -189,21 +189,21 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { * @return bool */ public function isCreatable() { - return $this->checkPermissions(\OCP\PERMISSION_CREATE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_CREATE); } /** * @return bool */ public function isDeletable() { - return $this->checkPermissions(\OCP\PERMISSION_DELETE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_DELETE); } /** * @return bool */ public function isShareable() { - return $this->checkPermissions(\OCP\PERMISSION_SHARE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_SHARE); } /** diff --git a/lib/private/files/node/file.php b/lib/private/files/node/file.php index 75d5e0166b6..81e251c20b8 100644 --- a/lib/private/files/node/file.php +++ b/lib/private/files/node/file.php @@ -16,7 +16,7 @@ class File extends Node implements \OCP\Files\File { * @throws \OCP\Files\NotPermittedException */ public function getContent() { - if ($this->checkPermissions(\OCP\PERMISSION_READ)) { + if ($this->checkPermissions(\OCP\Constants::PERMISSION_READ)) { /** * @var \OC\Files\Storage\Storage $storage; */ @@ -31,7 +31,7 @@ class File extends Node implements \OCP\Files\File { * @throws \OCP\Files\NotPermittedException */ public function putContent($data) { - if ($this->checkPermissions(\OCP\PERMISSION_UPDATE)) { + if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) { $this->sendHooks(array('preWrite')); $this->view->file_put_contents($this->path, $data); $this->sendHooks(array('postWrite')); @@ -55,7 +55,7 @@ class File extends Node implements \OCP\Files\File { public function fopen($mode) { $preHooks = array(); $postHooks = array(); - $requiredPermissions = \OCP\PERMISSION_READ; + $requiredPermissions = \OCP\Constants::PERMISSION_READ; switch ($mode) { case 'r+': case 'rb+': @@ -73,7 +73,7 @@ class File extends Node implements \OCP\Files\File { case 'ab': $preHooks[] = 'preWrite'; $postHooks[] = 'postWrite'; - $requiredPermissions |= \OCP\PERMISSION_UPDATE; + $requiredPermissions |= \OCP\Constants::PERMISSION_UPDATE; break; } @@ -88,7 +88,7 @@ class File extends Node implements \OCP\Files\File { } public function delete() { - if ($this->checkPermissions(\OCP\PERMISSION_DELETE)) { + if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) { $this->sendHooks(array('preDelete')); $this->view->unlink($this->path); $nonExisting = new NonExistingFile($this->root, $this->view, $this->path); diff --git a/lib/private/files/node/folder.php b/lib/private/files/node/folder.php index 8c7acc339ae..83e20871528 100644 --- a/lib/private/files/node/folder.php +++ b/lib/private/files/node/folder.php @@ -180,7 +180,7 @@ class Folder extends Node implements \OCP\Files\Folder { * @throws \OCP\Files\NotPermittedException */ public function newFolder($path) { - if ($this->checkPermissions(\OCP\PERMISSION_CREATE)) { + if ($this->checkPermissions(\OCP\Constants::PERMISSION_CREATE)) { $fullPath = $this->getFullPath($path); $nonExisting = new NonExistingFolder($this->root, $this->view, $fullPath); $this->root->emit('\OC\Files', 'preWrite', array($nonExisting)); @@ -201,7 +201,7 @@ class Folder extends Node implements \OCP\Files\Folder { * @throws \OCP\Files\NotPermittedException */ public function newFile($path) { - if ($this->checkPermissions(\OCP\PERMISSION_CREATE)) { + if ($this->checkPermissions(\OCP\Constants::PERMISSION_CREATE)) { $fullPath = $this->getFullPath($path); $nonExisting = new NonExistingFile($this->root, $this->view, $fullPath); $this->root->emit('\OC\Files', 'preWrite', array($nonExisting)); @@ -325,11 +325,11 @@ class Folder extends Node implements \OCP\Files\Folder { * @return bool */ public function isCreatable() { - return $this->checkPermissions(\OCP\PERMISSION_CREATE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_CREATE); } public function delete() { - if ($this->checkPermissions(\OCP\PERMISSION_DELETE)) { + if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) { $this->sendHooks(array('preDelete')); $this->view->rmdir($this->path); $nonExisting = new NonExistingFolder($this->root, $this->view, $this->path); diff --git a/lib/private/files/node/node.php b/lib/private/files/node/node.php index bc075911749..c52f5bbd54f 100644 --- a/lib/private/files/node/node.php +++ b/lib/private/files/node/node.php @@ -81,7 +81,7 @@ class Node implements \OCP\Files\Node { * @throws \OCP\Files\NotPermittedException */ public function touch($mtime = null) { - if ($this->checkPermissions(\OCP\PERMISSION_UPDATE)) { + if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) { $this->sendHooks(array('preTouch')); $this->view->touch($this->path, $mtime); $this->sendHooks(array('postTouch')); @@ -163,28 +163,28 @@ class Node implements \OCP\Files\Node { * @return bool */ public function isReadable() { - return $this->checkPermissions(\OCP\PERMISSION_READ); + return $this->checkPermissions(\OCP\Constants::PERMISSION_READ); } /** * @return bool */ public function isUpdateable() { - return $this->checkPermissions(\OCP\PERMISSION_UPDATE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE); } /** * @return bool */ public function isDeletable() { - return $this->checkPermissions(\OCP\PERMISSION_DELETE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_DELETE); } /** * @return bool */ public function isShareable() { - return $this->checkPermissions(\OCP\PERMISSION_SHARE); + return $this->checkPermissions(\OCP\Constants::PERMISSION_SHARE); } /** diff --git a/lib/private/files/node/root.php b/lib/private/files/node/root.php index 18e7a6b681a..1e8387dc5cb 100644 --- a/lib/private/files/node/root.php +++ b/lib/private/files/node/root.php @@ -262,7 +262,7 @@ class Root extends Folder implements Emitter { * @return int */ public function getPermissions() { - return \OCP\PERMISSION_CREATE; + return \OCP\Constants::PERMISSION_CREATE; } /** diff --git a/lib/private/files/objectstore/objectstorestorage.php b/lib/private/files/objectstore/objectstorestorage.php index ae8bff52896..b0095ad94bb 100644 --- a/lib/private/files/objectstore/objectstorestorage.php +++ b/lib/private/files/objectstore/objectstorestorage.php @@ -72,7 +72,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { 'size' => 0, 'mtime' => $mTime, 'storage_mtime' => $mTime, - 'permissions' => \OCP\PERMISSION_ALL, + 'permissions' => \OCP\Constants::PERMISSION_ALL, ); if ($dirName === '' && !$parentExists) { @@ -332,7 +332,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { 'size' => 0, 'mtime' => $mtime, 'storage_mtime' => $mtime, - 'permissions' => \OCP\PERMISSION_ALL, + 'permissions' => \OCP\Constants::PERMISSION_ALL, ); $fileId = $this->getCache()->put($path, $stat); try { @@ -357,7 +357,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { if (empty($stat)) { // create new file $stat = array( - 'permissions' => \OCP\PERMISSION_ALL, + 'permissions' => \OCP\Constants::PERMISSION_ALL, ); } // update stat with new data diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index 518d3ec400c..d76c6aa031b 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -113,19 +113,19 @@ abstract class Common implements \OC\Files\Storage\Storage { public function getPermissions($path) { $permissions = 0; if ($this->isCreatable($path)) { - $permissions |= \OCP\PERMISSION_CREATE; + $permissions |= \OCP\Constants::PERMISSION_CREATE; } if ($this->isReadable($path)) { - $permissions |= \OCP\PERMISSION_READ; + $permissions |= \OCP\Constants::PERMISSION_READ; } if ($this->isUpdatable($path)) { - $permissions |= \OCP\PERMISSION_UPDATE; + $permissions |= \OCP\Constants::PERMISSION_UPDATE; } if ($this->isDeletable($path)) { - $permissions |= \OCP\PERMISSION_DELETE; + $permissions |= \OCP\Constants::PERMISSION_DELETE; } if ($this->isSharable($path)) { - $permissions |= \OCP\PERMISSION_SHARE; + $permissions |= \OCP\Constants::PERMISSION_SHARE; } return $permissions; } diff --git a/lib/private/files/storage/dav.php b/lib/private/files/storage/dav.php index 26fa69408a8..a2832bce009 100644 --- a/lib/private/files/storage/dav.php +++ b/lib/private/files/storage/dav.php @@ -416,19 +416,19 @@ class DAV extends \OC\Files\Storage\Common { } public function isUpdatable($path) { - return (bool)($this->getPermissions($path) & \OCP\PERMISSION_UPDATE); + return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_UPDATE); } public function isCreatable($path) { - return (bool)($this->getPermissions($path) & \OCP\PERMISSION_CREATE); + return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_CREATE); } public function isSharable($path) { - return (bool)($this->getPermissions($path) & \OCP\PERMISSION_SHARE); + return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_SHARE); } public function isDeletable($path) { - return (bool)($this->getPermissions($path) & \OCP\PERMISSION_DELETE); + return (bool)($this->getPermissions($path) & \OCP\Constants::PERMISSION_DELETE); } public function getPermissions($path) { @@ -438,9 +438,9 @@ class DAV extends \OC\Files\Storage\Common { if (isset($response['{http://owncloud.org/ns}permissions'])) { return $this->parsePermissions($response['{http://owncloud.org/ns}permissions']); } else if ($this->is_dir($path)) { - return \OCP\PERMISSION_ALL; + return \OCP\Constants::PERMISSION_ALL; } else if ($this->file_exists($path)) { - return \OCP\PERMISSION_ALL - \OCP\PERMISSION_CREATE; + return \OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE; } else { return 0; } @@ -451,19 +451,19 @@ class DAV extends \OC\Files\Storage\Common { * @return int */ protected function parsePermissions($permissionsString) { - $permissions = \OCP\PERMISSION_READ; + $permissions = \OCP\Constants::PERMISSION_READ; if (strpos($permissionsString, 'R') !== false) { - $permissions |= \OCP\PERMISSION_SHARE; + $permissions |= \OCP\Constants::PERMISSION_SHARE; } if (strpos($permissionsString, 'D') !== false) { - $permissions |= \OCP\PERMISSION_DELETE; + $permissions |= \OCP\Constants::PERMISSION_DELETE; } if (strpos($permissionsString, 'W') !== false) { - $permissions |= \OCP\PERMISSION_UPDATE; + $permissions |= \OCP\Constants::PERMISSION_UPDATE; } if (strpos($permissionsString, 'CK') !== false) { - $permissions |= \OCP\PERMISSION_CREATE; - $permissions |= \OCP\PERMISSION_UPDATE; + $permissions |= \OCP\Constants::PERMISSION_CREATE; + $permissions |= \OCP\Constants::PERMISSION_UPDATE; } return $permissions; } diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 19676524a0e..331ab9ba6cd 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -933,7 +933,7 @@ class View { } if ($mount instanceof MoveableMount && $internalPath === '') { - $data['permissions'] |= \OCP\PERMISSION_DELETE | \OCP\PERMISSION_UPDATE; + $data['permissions'] |= \OCP\Constants::PERMISSION_DELETE | \OCP\Constants::PERMISSION_UPDATE; } $data = \OC_FileProxy::runPostProxies('getFileInfo', $path, $data); @@ -988,7 +988,7 @@ class View { } // if sharing was disabled for the user we remove the share permissions if (\OCP\Util::isSharingDisabledForUser()) { - $content['permissions'] = $content['permissions'] & ~\OCP\PERMISSION_SHARE; + $content['permissions'] = $content['permissions'] & ~\OCP\Constants::PERMISSION_SHARE; } $files[] = new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content); } @@ -1025,9 +1025,9 @@ class View { // do not allow renaming/deleting the mount point if they are not shared files/folders // for shared files/folders we use the permissions given by the owner if ($mount instanceof MoveableMount) { - $rootEntry['permissions'] = $permissions | \OCP\PERMISSION_UPDATE | \OCP\PERMISSION_DELETE; + $rootEntry['permissions'] = $permissions | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE; } else { - $rootEntry['permissions'] = $permissions & (\OCP\PERMISSION_ALL - (\OCP\PERMISSION_UPDATE | \OCP\PERMISSION_DELETE)); + $rootEntry['permissions'] = $permissions & (\OCP\Constants::PERMISSION_ALL - (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE)); } //remove any existing entry with the same name @@ -1041,7 +1041,7 @@ class View { // if sharing was disabled for the user we remove the share permissions if (\OCP\Util::isSharingDisabledForUser()) { - $content['permissions'] = $content['permissions'] & ~\OCP\PERMISSION_SHARE; + $content['permissions'] = $content['permissions'] & ~\OCP\Constants::PERMISSION_SHARE; } $files[] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry); diff --git a/lib/private/helper.php b/lib/private/helper.php index be448b8ff9b..d43eefcdc52 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -58,12 +58,11 @@ class OC_Helper { } /** - * @param $key + * @param string $key * @return string url to the online documentation */ public static function linkToDocs($key) { - $theme = new OC_Defaults(); - return $theme->buildDocLinkToKey($key); + return OC::$server->getURLGenerator()->linkToDocs($key); } /** diff --git a/lib/private/preview.php b/lib/private/preview.php index 778007b21fd..c9d8810be6f 100644 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -17,7 +17,7 @@ use OC\Preview\Provider; use OCP\Files\NotFoundException; require_once 'preview/image.php'; -require_once 'preview/movies.php'; +require_once 'preview/movie.php'; require_once 'preview/mp3.php'; require_once 'preview/svg.php'; require_once 'preview/txt.php'; @@ -713,7 +713,7 @@ class Preview { * - OC\Preview\OpenDocument * - OC\Preview\StarOffice * - OC\Preview\SVG - * - OC\Preview\Movies + * - OC\Preview\Movie * - OC\Preview\PDF * - OC\Preview\TIFF * - OC\Preview\Illustrator diff --git a/lib/private/preview/movies.php b/lib/private/preview/movie.php index d69266ceb33..d69266ceb33 100644 --- a/lib/private/preview/movies.php +++ b/lib/private/preview/movie.php diff --git a/lib/private/share/helper.php b/lib/private/share/helper.php index 2418535c9d5..6bbb101db3a 100644 --- a/lib/private/share/helper.php +++ b/lib/private/share/helper.php @@ -189,20 +189,23 @@ class Helper extends \OC\Share\Constants { public static function calculateExpireDate($defaultExpireSettings, $creationTime, $userExpireDate = null) { $expires = false; + $defaultExpires = null; if (!empty($defaultExpireSettings['defaultExpireDateSet'])) { - $expires = $creationTime + $defaultExpireSettings['expireAfterDays'] * 86400; + $defaultExpires = $creationTime + $defaultExpireSettings['expireAfterDays'] * 86400; } if (isset($userExpireDate)) { // if the admin decided to enforce the default expire date then we only take // the user defined expire date of it is before the default expire date - if ($expires && !empty($defaultExpireSettings['enforceExpireDate'])) { - $expires = min($userExpireDate, $expires); + if ($defaultExpires && !empty($defaultExpireSettings['enforceExpireDate'])) { + $expires = min($userExpireDate, $defaultExpires); } else { $expires = $userExpireDate; } + } else if ($defaultExpires && !empty($defaultExpireSettings['enforceExpireDate'])) { + $expires = $defaultExpires; } return $expires; diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 10fff9aeacf..c6fd1604ac7 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -547,7 +547,7 @@ class Share extends \OC\Share\Constants { // single file shares should never have delete permissions if ($itemType === 'file') { - $permissions = (int)$permissions & ~\OCP\PERMISSION_DELETE; + $permissions = (int)$permissions & ~\OCP\Constants::PERMISSION_DELETE; } // Verify share type and sharing conditions are met @@ -929,7 +929,7 @@ class Share extends \OC\Share\Constants { // Check if permissions were removed if ($item['permissions'] & ~$permissions) { // If share permission is removed all reshares must be deleted - if (($item['permissions'] & \OCP\PERMISSION_SHARE) && (~$permissions & \OCP\PERMISSION_SHARE)) { + if (($item['permissions'] & \OCP\Constants::PERMISSION_SHARE) && (~$permissions & \OCP\Constants::PERMISSION_SHARE)) { Helper::delete($item['id'], true); } else { $ids = array(); @@ -1458,8 +1458,8 @@ class Share extends \OC\Share\Constants { } // Switch ids if sharing permission is granted on only // one share to ensure correct parent is used if resharing - if (~(int)$items[$id]['permissions'] & \OCP\PERMISSION_SHARE - && (int)$row['permissions'] & \OCP\PERMISSION_SHARE) { + if (~(int)$items[$id]['permissions'] & \OCP\Constants::PERMISSION_SHARE + && (int)$row['permissions'] & \OCP\Constants::PERMISSION_SHARE) { $items[$row['id']] = $items[$id]; $switchedItems[$id] = $row['id']; unset($items[$id]); @@ -1516,7 +1516,7 @@ class Share extends \OC\Share\Constants { } // Check if resharing is allowed, if not remove share permission if (isset($row['permissions']) && (!self::isResharingAllowed() | \OC_Util::isSharingDisabledForUser())) { - $row['permissions'] &= ~\OCP\PERMISSION_SHARE; + $row['permissions'] &= ~\OCP\Constants::PERMISSION_SHARE; } // Add display names to result if ( isset($row['share_with']) && $row['share_with'] != '' && @@ -1911,7 +1911,7 @@ class Share extends \OC\Share\Constants { } // Check if share permissions is granted - if (self::isResharingAllowed() && (int)$checkReshare['permissions'] & \OCP\PERMISSION_SHARE) { + if (self::isResharingAllowed() && (int)$checkReshare['permissions'] & \OCP\Constants::PERMISSION_SHARE) { if (~(int)$checkReshare['permissions'] & $permissions) { $message = 'Sharing %s failed, because the permissions exceed permissions granted to %s'; $message_t = $l->t('Sharing %s failed, because the permissions exceed permissions granted to %s', array($itemSourceName, $uidOwner)); diff --git a/lib/private/urlgenerator.php b/lib/private/urlgenerator.php index e50e9eed6af..d263d25aeef 100644 --- a/lib/private/urlgenerator.php +++ b/lib/private/urlgenerator.php @@ -8,6 +8,7 @@ */ namespace OC; +use OC_Defaults; use OCP\IURLGenerator; use RuntimeException; @@ -156,7 +157,7 @@ class URLGenerator implements IURLGenerator { /** * Makes an URL absolute - * @param string $url the url in the owncloud host + * @param string $url the url in the ownCloud host * @return string the absolute version of the url */ public function getAbsoluteURL($url) { @@ -173,4 +174,13 @@ class URLGenerator implements IURLGenerator { return \OC_Request::serverProtocol() . '://' . \OC_Request::serverHost(). $webRoot . $separator . $url; } + + /** + * @param string $key + * @return string url to the online documentation + */ + public function linkToDocs($key) { + $theme = new OC_Defaults(); + return $theme->buildDocLinkToKey($key); + } } diff --git a/lib/private/util.php b/lib/private/util.php index 4190f0aa3d8..a18a4e44232 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -1336,7 +1336,7 @@ class OC_Util { return false; } foreach (str_split($trimmed) as $char) { - if (strpos(\OCP\FILENAME_INVALID_CHARS, $char) !== false) { + if (strpos(\OCP\Constants::FILENAME_INVALID_CHARS, $char) !== false) { return false; } } diff --git a/lib/public/constants.php b/lib/public/constants.php index 350646a0ac0..78cafd11847 100644 --- a/lib/public/constants.php +++ b/lib/public/constants.php @@ -26,15 +26,37 @@ namespace OCP; -/** - * CRUDS permissions. - */ +/** @deprecated Use \OCP\Constants::PERMISSION_CREATE instead */ const PERMISSION_CREATE = 4; + +/** @deprecated Use \OCP\Constants::PERMISSION_READ instead */ const PERMISSION_READ = 1; + +/** @deprecated Use \OCP\Constants::PERMISSION_UPDATE instead */ const PERMISSION_UPDATE = 2; + +/** @deprecated Use \OCP\Constants::PERMISSION_DELETE instead */ const PERMISSION_DELETE = 8; + +/** @deprecated Use \OCP\Constants::PERMISSION_SHARE instead */ const PERMISSION_SHARE = 16; + +/** @deprecated Use \OCP\Constants::PERMISSION_ALL instead */ const PERMISSION_ALL = 31; +/** @deprecated Use \OCP\Constants::FILENAME_INVALID_CHARS instead */ const FILENAME_INVALID_CHARS = "\\/<>:\"|?*\n"; +class Constants { + /** + * CRUDS permissions. + */ + const PERMISSION_CREATE = 4; + const PERMISSION_READ = 1; + const PERMISSION_UPDATE = 2; + const PERMISSION_DELETE = 8; + const PERMISSION_SHARE = 16; + const PERMISSION_ALL = 31; + + const FILENAME_INVALID_CHARS = "\\/<>:\"|?*\n"; +} diff --git a/lib/public/files/fileinfo.php b/lib/public/files/fileinfo.php index ec81a541564..3a407ed67ca 100644 --- a/lib/public/files/fileinfo.php +++ b/lib/public/files/fileinfo.php @@ -103,12 +103,12 @@ interface FileInfo { /** * Get the permissions of the file or folder as bitmasked combination of the following constants - * \OCP\PERMISSION_CREATE - * \OCP\PERMISSION_READ - * \OCP\PERMISSION_UPDATE - * \OCP\PERMISSION_DELETE - * \OCP\PERMISSION_SHARE - * \OCP\PERMISSION_ALL + * \OCP\Constants::PERMISSION_CREATE + * \OCP\Constants::PERMISSION_READ + * \OCP\Constants::PERMISSION_UPDATE + * \OCP\Constants::PERMISSION_DELETE + * \OCP\Constants::PERMISSION_SHARE + * \OCP\Constants::PERMISSION_ALL * * @return int */ diff --git a/lib/public/files/node.php b/lib/public/files/node.php index a380394095b..35c20b487c9 100644 --- a/lib/public/files/node.php +++ b/lib/public/files/node.php @@ -128,11 +128,11 @@ interface Node { /** * Get the permissions of the file or folder as a combination of one or more of the following constants: - * - \OCP\PERMISSION_READ - * - \OCP\PERMISSION_UPDATE - * - \OCP\PERMISSION_CREATE - * - \OCP\PERMISSION_DELETE - * - \OCP\PERMISSION_SHARE + * - \OCP\Constants::PERMISSION_READ + * - \OCP\Constants::PERMISSION_UPDATE + * - \OCP\Constants::PERMISSION_CREATE + * - \OCP\Constants::PERMISSION_DELETE + * - \OCP\Constants::PERMISSION_SHARE * * @return int */ diff --git a/lib/public/iavatar.php b/lib/public/iavatar.php index 1e80682c4f7..213d2e6cef5 100644 --- a/lib/public/iavatar.php +++ b/lib/public/iavatar.php @@ -23,9 +23,9 @@ interface IAvatar { /** * sets the users avatar * @param Image $data mixed imagedata or path to set a new avatar - * @throws Exception if the provided file is not a jpg or png image - * @throws Exception if the provided image is not valid - * @throws \OCP\NotSquareException if the image is not square + * @throws \Exception if the provided file is not a jpg or png image + * @throws \Exception if the provided image is not valid + * @throws \OC\NotSquareException if the image is not square * @return void */ function set($data); diff --git a/lib/public/iurlgenerator.php b/lib/public/iurlgenerator.php index dbbd8a3bb63..fa817c10ea5 100644 --- a/lib/public/iurlgenerator.php +++ b/lib/public/iurlgenerator.php @@ -69,8 +69,14 @@ interface IURLGenerator { /** * Makes an URL absolute - * @param string $url the url in the owncloud host + * @param string $url the url in the ownCloud host * @return string the absolute version of the url */ public function getAbsoluteURL($url); + + /** + * @param string $key + * @return string url to the online documentation + */ + public function linkToDocs($key); } diff --git a/lib/public/template.php b/lib/public/template.php index 2e265bb5e8e..a1b650649ff 100644 --- a/lib/public/template.php +++ b/lib/public/template.php @@ -88,7 +88,7 @@ function human_file_size( $bytes ) { * Return the relative date in relation to today. Returns something like "last hour" or "two month ago" * @param int $timestamp unix timestamp * @param boolean $dateOnly - * @return OC_L10N_String human readable interpretation of the timestamp + * @return \OC_L10N_String human readable interpretation of the timestamp */ function relative_modified_date( $timestamp, $dateOnly = false ) { return(\relative_modified_date($timestamp, null, $dateOnly)); diff --git a/lib/public/util.php b/lib/public/util.php index a87d26a4004..793a16c4d84 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -508,8 +508,8 @@ class Util { /** * Compare two strings to provide a natural sort - * @param $a first string to compare - * @param $b second string to compare + * @param string $a first string to compare + * @param string $b second string to compare * @return -1 if $b comes before $a, 1 if $a comes before $b * or 0 if the strings are identical */ |