aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib
diff options
context:
space:
mode:
authorRobin McCorkell <rmccorkell@karoshi.org.uk>2015-04-01 14:50:51 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-07-01 09:08:28 +0200
commit728a22cda18845f831d65eac0c6f49b9f9b3b42f (patch)
tree8c3a6b1f7c9dbf38b948bf7d919dceeed13ff413 /apps/files_external/lib
parentb5c9196ffcf8f5300d96e7d2bdd78f2695f6fd7a (diff)
downloadnextcloud-server-728a22cda18845f831d65eac0c6f49b9f9b3b42f.tar.gz
nextcloud-server-728a22cda18845f831d65eac0c6f49b9f9b3b42f.zip
Use OCP classes as much as possible in files_external
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r--apps/files_external/lib/amazons3.php4
-rw-r--r--apps/files_external/lib/api.php2
-rw-r--r--apps/files_external/lib/config.php32
-rw-r--r--apps/files_external/lib/dropbox.php4
-rw-r--r--apps/files_external/lib/google.php4
-rw-r--r--apps/files_external/lib/swift.php4
6 files changed, 27 insertions, 23 deletions
diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php
index 02a02710a14..77918c5507c 100644
--- a/apps/files_external/lib/amazons3.php
+++ b/apps/files_external/lib/amazons3.php
@@ -373,7 +373,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
switch ($mode) {
case 'r':
case 'rb':
- $tmpFile = \OC_Helper::tmpFile();
+ $tmpFile = \OCP\Files::tmpFile();
self::$tmpFiles[$tmpFile] = $path;
try {
@@ -405,7 +405,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
} else {
$ext = '';
}
- $tmpFile = \OC_Helper::tmpFile($ext);
+ $tmpFile = \OCP\Files::tmpFile($ext);
\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
diff --git a/apps/files_external/lib/api.php b/apps/files_external/lib/api.php
index b9435e33105..015c15c41ff 100644
--- a/apps/files_external/lib/api.php
+++ b/apps/files_external/lib/api.php
@@ -71,7 +71,7 @@ class Api {
*/
public static function getUserMounts($params) {
$entries = array();
- $user = \OC_User::getUser();
+ $user = \OC::$server->getUserSession()->getUser()->getUID();
$mounts = \OC_Mount_Config::getAbsoluteMountPoints($user);
foreach($mounts as $mountPoint => $mount) {
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 5dc6d06ae06..9d8b312e77e 100644
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -124,10 +124,9 @@ class OC_Mount_Config {
self::addStorageIdToConfig($data['user']);
$user = \OC::$server->getUserManager()->get($data['user']);
if (!$user) {
- \OCP\Util::writeLog(
- 'files_external',
+ \OC::$server->getLogger()->warning(
'Cannot init external mount points for non-existant user "' . $data['user'] . '".',
- \OCP\Util::WARN
+ ['app' => 'files_external']
);
return;
}
@@ -161,6 +160,9 @@ class OC_Mount_Config {
// Load system mount points
$mountConfig = self::readData();
+ $userObject = \OC::$server->getUserManager()->get($user);
+ $groupManager = \OC::$server->getGroupManager();
+
// Global mount points (is this redundant?)
if (isset($mountConfig[self::MOUNT_TYPE_GLOBAL])) {
foreach ($mountConfig[self::MOUNT_TYPE_GLOBAL] as $mountPoint => $options) {
@@ -207,7 +209,7 @@ class OC_Mount_Config {
// Group mount points
if (isset($mountConfig[self::MOUNT_TYPE_GROUP])) {
foreach ($mountConfig[self::MOUNT_TYPE_GROUP] as $group => $mounts) {
- if (\OC_Group::inGroup($user, $group)) {
+ if ($groupManager->get($group)->inGroup($userObject)) {
foreach ($mounts as $mountPoint => $options) {
$mountPoint = self::setUserVars($user, $mountPoint);
foreach ($options as &$option) {
@@ -581,7 +583,7 @@ class OC_Mount_Config {
$result = self::getBackendStatus($class, $classOptions, $isPersonal);
if ($result === self::STATUS_SUCCESS && $isNew) {
- \OC_Hook::emit(
+ \OCP\Util::emitHook(
\OC\Files\Filesystem::CLASSNAME,
\OC\Files\Filesystem::signal_create_mount,
array(
@@ -627,7 +629,7 @@ class OC_Mount_Config {
}
}
self::writeData($isPersonal ? OCP\User::getUser() : null, $mountPoints);
- \OC_Hook::emit(
+ \OCP\Util::emitHook(
\OC\Files\Filesystem::CLASSNAME,
\OC\Files\Filesystem::signal_delete_mount,
array(
@@ -669,10 +671,11 @@ class OC_Mount_Config {
*/
public static function readData($user = null) {
if (isset($user)) {
- $jsonFile = OC_User::getHome($user) . '/mount.json';
+ $jsonFile = \OC::$server->getUserManager()->get($user)->getHome() . '/mount.json';
} else {
- $datadir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data/');
- $jsonFile = \OC_Config::getValue('mount_file', $datadir . '/mount.json');
+ $config = \OC::$server->getConfig();
+ $datadir = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/');
+ $jsonFile = $config->getSystemValue('mount_file', $datadir . '/mount.json');
}
if (is_file($jsonFile)) {
$mountPoints = json_decode(file_get_contents($jsonFile), true);
@@ -691,10 +694,11 @@ class OC_Mount_Config {
*/
public static function writeData($user, $data) {
if (isset($user)) {
- $file = OC_User::getHome($user) . '/mount.json';
+ $file = \OC::$server->getUserManager()->get($user)->getHome() . '/mount.json';
} else {
- $datadir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data/');
- $file = \OC_Config::getValue('mount_file', $datadir . '/mount.json');
+ $config = \OC::$server->getConfig();
+ $datadir = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/');
+ $file = $config->getSystemValue('mount_file', $datadir . '/mount.json');
}
foreach ($data as &$applicables) {
@@ -752,7 +756,7 @@ class OC_Mount_Config {
}
private static function generateDependencyMessage($dependencies) {
- $l = new \OC_L10N('files_external');
+ $l = \OC::$server->getL10N('files_external');
$dependencyMessage = '';
foreach ($dependencies as $module => $backends) {
$dependencyGroup = array();
@@ -789,7 +793,7 @@ class OC_Mount_Config {
* @param string $backend
* @return string
*/
- private static function getSingleDependencyMessage(OC_L10N $l, $module, $backend) {
+ private static function getSingleDependencyMessage(\OCP\IL10N $l, $module, $backend) {
switch (strtolower($module)) {
case 'curl':
return $l->t('<b>Note:</b> The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it.', $backend);
diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php
index 78219f8f06e..afdf09a676b 100644
--- a/apps/files_external/lib/dropbox.php
+++ b/apps/files_external/lib/dropbox.php
@@ -243,7 +243,7 @@ class Dropbox extends \OC\Files\Storage\Common {
switch ($mode) {
case 'r':
case 'rb':
- $tmpFile = \OC_Helper::tmpFile();
+ $tmpFile = \OCP\Files::tmpFile();
try {
$data = $this->dropbox->getFile($path);
file_put_contents($tmpFile, $data);
@@ -269,7 +269,7 @@ class Dropbox extends \OC\Files\Storage\Common {
} else {
$ext = '';
}
- $tmpFile = \OC_Helper::tmpFile($ext);
+ $tmpFile = \OCP\Files::tmpFile($ext);
\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php
index 8199d97eacb..b4cc9bb0eab 100644
--- a/apps/files_external/lib/google.php
+++ b/apps/files_external/lib/google.php
@@ -428,7 +428,7 @@ class Google extends \OC\Files\Storage\Common {
$request = new \Google_Http_Request($downloadUrl, 'GET', null, null);
$httpRequest = $this->client->getAuth()->authenticatedRequest($request);
if ($httpRequest->getResponseHttpCode() == 200) {
- $tmpFile = \OC_Helper::tmpFile($ext);
+ $tmpFile = \OCP\Files::tmpFile($ext);
$data = $httpRequest->getResponseBody();
file_put_contents($tmpFile, $data);
return fopen($tmpFile, $mode);
@@ -448,7 +448,7 @@ class Google extends \OC\Files\Storage\Common {
case 'x+':
case 'c':
case 'c+':
- $tmpFile = \OC_Helper::tmpFile($ext);
+ $tmpFile = \OCP\Files::tmpFile($ext);
\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'rb');
diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php
index 50f0d40805a..4104e97fbe6 100644
--- a/apps/files_external/lib/swift.php
+++ b/apps/files_external/lib/swift.php
@@ -310,7 +310,7 @@ class Swift extends \OC\Files\Storage\Common {
switch ($mode) {
case 'r':
case 'rb':
- $tmpFile = \OC_Helper::tmpFile();
+ $tmpFile = \OCP\Files::tmpFile();
self::$tmpFiles[$tmpFile] = $path;
try {
$object = $this->getContainer()->getObject($path);
@@ -348,7 +348,7 @@ class Swift extends \OC\Files\Storage\Common {
} else {
$ext = '';
}
- $tmpFile = \OC_Helper::tmpFile($ext);
+ $tmpFile = \OCP\Files::tmpFile($ext);
\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');