diff options
author | VicDeo <dubiniuk@owncloud.com> | 2015-08-27 18:21:11 +0300 |
---|---|---|
committer | VicDeo <dubiniuk@owncloud.com> | 2015-08-27 18:21:11 +0300 |
commit | 1e6160adceba6b7cf99bd47d1a447af1e99d656b (patch) | |
tree | bcbed3d9e259c9ab00fcea9da687729c0ee1a0f8 /lib | |
parent | a7da2844f9e7ebea47a9fec276eb6c522c426f1c (diff) | |
parent | 52f251a8af54f0ed25b7558be8d7a237bcb0f90f (diff) |
Merge pull request #536 from owncloud/code-checker
Remove deprecated API usage
Diffstat (limited to 'lib')
-rw-r--r-- | lib/config.php | 8 | ||||
-rw-r--r-- | lib/converter.php | 4 | ||||
-rw-r--r-- | lib/db.php | 2 | ||||
-rw-r--r-- | lib/db/session.php | 22 | ||||
-rw-r--r-- | lib/file.php | 7 | ||||
-rw-r--r-- | lib/helper.php | 5 |
6 files changed, 29 insertions, 19 deletions
diff --git a/lib/config.php b/lib/config.php index 4d6f182f..b4e59067 100644 --- a/lib/config.php +++ b/lib/config.php @@ -20,8 +20,8 @@ class Config { $targetFilter = 'odt:writer8'; $targetExtension = 'odt'; $input = file_get_contents(dirname(__DIR__) . self::TEST_DOC_PATH); - $infile = \OCP\Files::tmpFile(); - $outdir = \OCP\Files::tmpFolder(); + $infile = \OC::$server->getTempManager()->getTemporaryFile(); + $outdir = \OC::$server->getTempManager()->getTemporaryFolder(); $outfile = $outdir . '/' . basename($infile) . '.' . $targetExtension; $cmd = Helper::findOpenOffice(); @@ -66,11 +66,11 @@ class Config { } protected static function getAppValue($key, $default){ - return \OCP\Config::getAppValue(self::APP_NAME, $key, $default); + return \OC::$server->getConfig()->getAppValue(self::APP_NAME, $key, $default); } protected static function setAppValue($key, $value){ - return \OCP\Config::setAppValue(self::APP_NAME, $key, $value); + return \OC::$server->getConfig()->setAppValue(self::APP_NAME, $key, $value); } } diff --git a/lib/converter.php b/lib/converter.php index 1667d528..5dbe2007 100644 --- a/lib/converter.php +++ b/lib/converter.php @@ -43,8 +43,8 @@ class Converter { * @return string */ protected static function convertLocal($input, $targetFilter, $targetExtension){ - $infile = \OCP\Files::tmpFile(); - $outdir = \OCP\Files::tmpFolder(); + $infile = \OC::$server->getTempManager()->getTemporaryFile(); + $outdir = \OC::$server->getTempManager()->getTemporaryFolder(); $cmd = Helper::findOpenOffice(); $params = ' --headless --convert-to ' . $targetFilter . ' --outdir ' . escapeshellarg($outdir) @@ -43,7 +43,7 @@ abstract class Db { * @return mixed */ public function getLastInsertId(){ - return \OCP\DB::insertid($this->tableName); + return \OC::$server->getDatabaseConnection()->lastInsertId($this->tableName); } /** diff --git a/lib/db/session.php b/lib/db/session.php index 04bdbe84..b8de3c1c 100644 --- a/lib/db/session.php +++ b/lib/db/session.php @@ -12,6 +12,8 @@ namespace OCA\Documents\Db; +use OCP\Security\ISecureRandom; + use OCA\Documents\Filter; /** @@ -88,6 +90,7 @@ class Session extends \OCA\Documents\Db { if (!$member->insert()){ throw new \Exception('Failed to add member into database'); } + $sessionData['member_id'] = (string) $member->getLastInsertId(); // Do we have OC_Avatar in out disposal? if (\OC_Config::getValue('enable_avatars', true) !== true){ @@ -96,10 +99,11 @@ class Session extends \OCA\Documents\Db { $imageUrl = $uid; } - $displayName = $file->isPublicShare() ? $uid . ' ' . \OCA\Documents\Db\Member::getGuestPostfix() : \OCP\User::getDisplayName($uid); - $userId = $file->isPublicShare() ? $displayName : \OCP\User::getUser(); - - $sessionData['member_id'] = (string) $member->getLastInsertId(); + $displayName = $file->isPublicShare() + ? $uid . ' ' . \OCA\Documents\Db\Member::getGuestPostfix() + : \OC::$server->getUserSession()->getUser()->getDisplayName($uid) + ; + $userId = $file->isPublicShare() ? $displayName : \OC::$server->getUserSession()->getUser()->getUID(); $op = new \OCA\Documents\Db\Op(); $op->addMember( $sessionData['es_id'], @@ -188,10 +192,10 @@ class Session extends \OCA\Documents\Db { WHERE `s`.`es_id` = ? GROUP BY `m`.`es_id` ', - array( - \OCP\User::getUser(), + [ + \OC::$server->getUserSession()->getUser()->getUID(), $esId - ) + ] ); $info = $result->fetchRow(); @@ -204,7 +208,9 @@ class Session extends \OCA\Documents\Db { protected function getUniqueSessionId(){ $testSession = new Session(); do{ - $id = \OC_Util::generateRandomBytes(30); + $id = \OC::$server->getSecureRandom() + ->getMediumStrengthGenerator() + ->generate(30, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS); } while ($testSession->load($id)->hasData()); return $id; diff --git a/lib/file.php b/lib/file.php index 74c8964e..ed4acf99 100644 --- a/lib/file.php +++ b/lib/file.php @@ -147,7 +147,10 @@ class File { if ($this->isPublicShare()){ if (isset($this->sharing['uid_owner'])){ $owner = $this->sharing['uid_owner']; - \OCP\JSON::checkUserExists($this->sharing['uid_owner']); + if (!\OC::$server->getUserManager()->userExists($this->sharing['uid_owner'])) { + throw new \Exception('Share owner' . $this->sharing['uid_owner'] . ' does not exist '); + } + \OC_Util::tearDownFS(); \OC_Util::setupFS($this->sharing['uid_owner']); } else { @@ -155,7 +158,7 @@ class File { } $view = new View('/' . $owner . '/files'); } else { - $owner = \OCP\User::getUser(); + $owner = \OC::$server->getUserSession()->getUser()->getUID(); $root = '/' . $owner; if ($useDefaultRoot){ $root .= '/' . 'files'; diff --git a/lib/helper.php b/lib/helper.php index a351672f..e6ffaee5 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -161,9 +161,10 @@ class Helper { } public static function findOpenOffice(){ + $config = \OC::$server->getConfig(); $cmd = ''; - if (is_string(\OC_Config::getValue('preview_libreoffice_path', null))){ - $cmd = \OC_Config::getValue('preview_libreoffice_path', null); + if (is_string($config->getSystemValue('preview_libreoffice_path', null))){ + $cmd = $config->getSystemValue('preview_libreoffice_path', null); } $whichLibreOffice = shell_exec('which libreoffice'); |