fix checkstyle for files_external app, add whitespace for readability
This commit is contained in:
parent
df21ebeaf7
commit
92df70b6e5
|
@ -10,4 +10,9 @@ if ($_POST['isPersonal'] == 'true') {
|
||||||
OCP\JSON::checkAdminUser();
|
OCP\JSON::checkAdminUser();
|
||||||
$isPersonal = false;
|
$isPersonal = false;
|
||||||
}
|
}
|
||||||
OC_Mount_Config::addMountPoint($_POST['mountPoint'], $_POST['class'], $_POST['classOptions'], $_POST['mountType'], $_POST['applicable'], $isPersonal);
|
OC_Mount_Config::addMountPoint($_POST['mountPoint'],
|
||||||
|
$_POST['class'],
|
||||||
|
$_POST['classOptions'],
|
||||||
|
$_POST['mountType'],
|
||||||
|
$_POST['applicable'],
|
||||||
|
$isPersonal);
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
OCP\JSON::checkAppEnabled('files_external');
|
OCP\JSON::checkAppEnabled('files_external');
|
||||||
|
|
||||||
if ( !($filename = $_FILES['rootcert_import']['name']) ) {
|
if ( ! ($filename = $_FILES['rootcert_import']['name']) ) {
|
||||||
header("Location: settings/personal.php");
|
header("Location: settings/personal.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ fclose($fh);
|
||||||
$filename = $_FILES['rootcert_import']['name'];
|
$filename = $_FILES['rootcert_import']['name'];
|
||||||
|
|
||||||
$view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_external/uploads');
|
$view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_external/uploads');
|
||||||
if (!$view->file_exists('')) $view->mkdir('');
|
if ( ! $view->file_exists('')) $view->mkdir('');
|
||||||
|
|
||||||
$isValid = openssl_pkey_get_public($data);
|
$isValid = openssl_pkey_get_public($data);
|
||||||
|
|
||||||
|
@ -29,8 +29,10 @@ if ( $isValid ) {
|
||||||
$view->file_put_contents($filename, $data);
|
$view->file_put_contents($filename, $data);
|
||||||
OC_Mount_Config::createCertificateBundle();
|
OC_Mount_Config::createCertificateBundle();
|
||||||
} else {
|
} else {
|
||||||
OCP\Util::writeLog("files_external", "Couldn't import SSL root certificate ($filename), allowed formats: PEM and DER", OCP\Util::WARN);
|
OCP\Util::writeLog('files_external',
|
||||||
|
'Couldn\'t import SSL root certificate ('.$filename.'), allowed formats: PEM and DER',
|
||||||
|
OCP\Util::WARN);
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Location: settings/personal.php");
|
header('Location: settings/personal.php');
|
||||||
exit;
|
exit;
|
||||||
|
|
|
@ -16,9 +16,13 @@ if (isset($_POST['app_key']) && isset($_POST['app_secret'])) {
|
||||||
$callback = null;
|
$callback = null;
|
||||||
}
|
}
|
||||||
$token = $oauth->getRequestToken();
|
$token = $oauth->getRequestToken();
|
||||||
OCP\JSON::success(array('data' => array('url' => $oauth->getAuthorizeUrl($callback), 'request_token' => $token['token'], 'request_token_secret' => $token['token_secret'])));
|
OCP\JSON::success(array('data' => array('url' => $oauth->getAuthorizeUrl($callback),
|
||||||
|
'request_token' => $token['token'],
|
||||||
|
'request_token_secret' => $token['token_secret'])));
|
||||||
} catch (Exception $exception) {
|
} catch (Exception $exception) {
|
||||||
OCP\JSON::error(array('data' => array('message' => 'Fetching request tokens failed. Verify that your Dropbox app key and secret are correct.')));
|
OCP\JSON::error(array('data' => array('message' =>
|
||||||
|
'Fetching request tokens failed. Verify that your Dropbox app key and secret are correct.')
|
||||||
|
));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -26,9 +30,12 @@ if (isset($_POST['app_key']) && isset($_POST['app_secret'])) {
|
||||||
try {
|
try {
|
||||||
$oauth->setToken($_POST['request_token'], $_POST['request_token_secret']);
|
$oauth->setToken($_POST['request_token'], $_POST['request_token_secret']);
|
||||||
$token = $oauth->getAccessToken();
|
$token = $oauth->getAccessToken();
|
||||||
OCP\JSON::success(array('access_token' => $token['token'], 'access_token_secret' => $token['token_secret']));
|
OCP\JSON::success(array('access_token' => $token['token'],
|
||||||
|
'access_token_secret' => $token['token_secret']));
|
||||||
} catch (Exception $exception) {
|
} catch (Exception $exception) {
|
||||||
OCP\JSON::error(array('data' => array('message' => 'Fetching access tokens failed. Verify that your Dropbox app key and secret are correct.')));
|
OCP\JSON::error(array('data' => array('message' =>
|
||||||
|
'Fetching access tokens failed. Verify that your Dropbox app key and secret are correct.')
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -14,7 +14,9 @@ if (isset($_POST['step'])) {
|
||||||
} else {
|
} else {
|
||||||
$callback = null;
|
$callback = null;
|
||||||
}
|
}
|
||||||
$scope = 'https://docs.google.com/feeds/ https://docs.googleusercontent.com/ https://spreadsheets.google.com/feeds/';
|
$scope = 'https://docs.google.com/feeds/'
|
||||||
|
.' https://docs.googleusercontent.com/'
|
||||||
|
.' https://spreadsheets.google.com/feeds/';
|
||||||
$url = 'https://www.google.com/accounts/OAuthGetRequestToken?scope='.urlencode($scope);
|
$url = 'https://www.google.com/accounts/OAuthGetRequestToken?scope='.urlencode($scope);
|
||||||
$params = array('scope' => $scope, 'oauth_callback' => $callback);
|
$params = array('scope' => $scope, 'oauth_callback' => $callback);
|
||||||
$request = OAuthRequest::from_consumer_and_token($consumer, null, 'GET', $url, $params);
|
$request = OAuthRequest::from_consumer_and_token($consumer, null, 'GET', $url, $params);
|
||||||
|
@ -24,24 +26,35 @@ if (isset($_POST['step'])) {
|
||||||
parse_str($response, $token);
|
parse_str($response, $token);
|
||||||
if (isset($token['oauth_token']) && isset($token['oauth_token_secret'])) {
|
if (isset($token['oauth_token']) && isset($token['oauth_token_secret'])) {
|
||||||
$authUrl = 'https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token='.$token['oauth_token'];
|
$authUrl = 'https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token='.$token['oauth_token'];
|
||||||
OCP\JSON::success(array('data' => array('url' => $authUrl, 'request_token' => $token['oauth_token'], 'request_token_secret' => $token['oauth_token_secret'])));
|
OCP\JSON::success(array('data' => array('url' => $authUrl,
|
||||||
|
'request_token' => $token['oauth_token'],
|
||||||
|
'request_token_secret' => $token['oauth_token_secret'])));
|
||||||
} else {
|
} else {
|
||||||
OCP\JSON::error(array('data' => array('message' => 'Fetching request tokens failed. Error: '.$response)));
|
OCP\JSON::error(array('data' => array(
|
||||||
|
'message' => 'Fetching request tokens failed. Error: '.$response
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (isset($_POST['oauth_verifier']) && isset($_POST['request_token']) && isset($_POST['request_token_secret'])) {
|
if (isset($_POST['oauth_verifier'])
|
||||||
|
&& isset($_POST['request_token'])
|
||||||
|
&& isset($_POST['request_token_secret'])
|
||||||
|
) {
|
||||||
$token = new OAuthToken($_POST['request_token'], $_POST['request_token_secret']);
|
$token = new OAuthToken($_POST['request_token'], $_POST['request_token_secret']);
|
||||||
$url = 'https://www.google.com/accounts/OAuthGetAccessToken';
|
$url = 'https://www.google.com/accounts/OAuthGetAccessToken';
|
||||||
$request = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $url, array('oauth_verifier' => $_POST['oauth_verifier']));
|
$request = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $url,
|
||||||
|
array('oauth_verifier' => $_POST['oauth_verifier']));
|
||||||
$request->sign_request($sigMethod, $consumer, $token);
|
$request->sign_request($sigMethod, $consumer, $token);
|
||||||
$response = send_signed_request('GET', $url, array($request->to_header()), null, false);
|
$response = send_signed_request('GET', $url, array($request->to_header()), null, false);
|
||||||
$token = array();
|
$token = array();
|
||||||
parse_str($response, $token);
|
parse_str($response, $token);
|
||||||
if (isset($token['oauth_token']) && isset($token['oauth_token_secret'])) {
|
if (isset($token['oauth_token']) && isset($token['oauth_token_secret'])) {
|
||||||
OCP\JSON::success(array('access_token' => $token['oauth_token'], 'access_token_secret' => $token['oauth_token_secret']));
|
OCP\JSON::success(array('access_token' => $token['oauth_token'],
|
||||||
|
'access_token_secret' => $token['oauth_token_secret']));
|
||||||
} else {
|
} else {
|
||||||
OCP\JSON::error(array('data' => array('message' => 'Fetching access tokens failed. Error: '.$response)));
|
OCP\JSON::error(array('data' => array(
|
||||||
|
'message' => 'Fetching access tokens failed. Error: '.$response
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -142,7 +142,7 @@ $(document).ready(function() {
|
||||||
$('td.remove>img').live('click', function() {
|
$('td.remove>img').live('click', function() {
|
||||||
var tr = $(this).parent().parent();
|
var tr = $(this).parent().parent();
|
||||||
var mountPoint = $(tr).find('.mountPoint input').val();
|
var mountPoint = $(tr).find('.mountPoint input').val();
|
||||||
if (!mountPoint) {
|
if ( ! mountPoint) {
|
||||||
var row=this.parentNode.parentNode;
|
var row=this.parentNode.parentNode;
|
||||||
$.post(OC.filePath('files_external', 'ajax', 'removeRootCertificate.php'), { cert: row.id });
|
$.post(OC.filePath('files_external', 'ajax', 'removeRootCertificate.php'), { cert: row.id });
|
||||||
$(tr).remove();
|
$(tr).remove();
|
||||||
|
|
|
@ -45,7 +45,7 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
|
||||||
if ($response) {
|
if ($response) {
|
||||||
$this->objects[$path] = $response;
|
$this->objects[$path] = $response;
|
||||||
return $response;
|
return $response;
|
||||||
// This object could be a folder, a '/' must be at the end of the path
|
// This object could be a folder, a '/' must be at the end of the path
|
||||||
} else if (substr($path, -1) != '/') {
|
} else if (substr($path, -1) != '/') {
|
||||||
$response = $this->s3->get_object_metadata($this->bucket, $path.'/');
|
$response = $this->s3->get_object_metadata($this->bucket, $path.'/');
|
||||||
if ($response) {
|
if ($response) {
|
||||||
|
@ -108,11 +108,14 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
|
||||||
$stat['atime'] = time();
|
$stat['atime'] = time();
|
||||||
$stat['mtime'] = $stat['atime'];
|
$stat['mtime'] = $stat['atime'];
|
||||||
$stat['ctime'] = $stat['atime'];
|
$stat['ctime'] = $stat['atime'];
|
||||||
} else if ($object = $this->getObject($path)) {
|
} else {
|
||||||
$stat['size'] = $object['Size'];
|
$object = $this->getObject($path);
|
||||||
$stat['atime'] = time();
|
if ($object) {
|
||||||
$stat['mtime'] = strtotime($object['LastModified']);
|
$stat['size'] = $object['Size'];
|
||||||
$stat['ctime'] = $stat['mtime'];
|
$stat['atime'] = time();
|
||||||
|
$stat['mtime'] = strtotime($object['LastModified']);
|
||||||
|
$stat['ctime'] = $stat['mtime'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isset($stat)) {
|
if (isset($stat)) {
|
||||||
return $stat;
|
return $stat;
|
||||||
|
@ -123,12 +126,15 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
|
||||||
public function filetype($path) {
|
public function filetype($path) {
|
||||||
if ($path == '' || $path == '/') {
|
if ($path == '' || $path == '/') {
|
||||||
return 'dir';
|
return 'dir';
|
||||||
} else if ($object = $this->getObject($path)) {
|
} else {
|
||||||
// Amazon S3 doesn't have typical folders, this is an alternative method to detect a folder
|
$object = $this->getObject($path);
|
||||||
if (substr($object['Key'], -1) == '/' && $object['Size'] == 0) {
|
if ($object) {
|
||||||
return 'dir';
|
// Amazon S3 doesn't have typical folders, this is an alternative method to detect a folder
|
||||||
} else {
|
if (substr($object['Key'], -1) == '/' && $object['Size'] == 0) {
|
||||||
return 'file';
|
return 'dir';
|
||||||
|
} else {
|
||||||
|
return 'file';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -199,7 +205,9 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
|
||||||
public function writeBack($tmpFile) {
|
public function writeBack($tmpFile) {
|
||||||
if (isset(self::$tempFiles[$tmpFile])) {
|
if (isset(self::$tempFiles[$tmpFile])) {
|
||||||
$handle = fopen($tmpFile, 'r');
|
$handle = fopen($tmpFile, 'r');
|
||||||
$response = $this->s3->create_object($this->bucket, self::$tempFiles[$tmpFile], array('fileUpload' => $handle));
|
$response = $this->s3->create_object($this->bucket,
|
||||||
|
self::$tempFiles[$tmpFile],
|
||||||
|
array('fileUpload' => $handle));
|
||||||
if ($response->isOK()) {
|
if ($response->isOK()) {
|
||||||
unlink($tmpFile);
|
unlink($tmpFile);
|
||||||
}
|
}
|
||||||
|
@ -209,8 +217,11 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
|
||||||
public function getMimeType($path) {
|
public function getMimeType($path) {
|
||||||
if ($this->filetype($path) == 'dir') {
|
if ($this->filetype($path) == 'dir') {
|
||||||
return 'httpd/unix-directory';
|
return 'httpd/unix-directory';
|
||||||
} else if ($object = $this->getObject($path)) {
|
} else {
|
||||||
return $object['ContentType'];
|
$object = $this->getObject($path);
|
||||||
|
if ($object) {
|
||||||
|
return $object['ContentType'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,14 +39,64 @@ class OC_Mount_Config {
|
||||||
*/
|
*/
|
||||||
public static function getBackends() {
|
public static function getBackends() {
|
||||||
return array(
|
return array(
|
||||||
'OC_Filestorage_Local' => array('backend' => 'Local', 'configuration' => array('datadir' => 'Location')),
|
'OC_Filestorage_Local' => array(
|
||||||
'OC_Filestorage_AmazonS3' => array('backend' => 'Amazon S3', 'configuration' => array('key' => 'Key', 'secret' => '*Secret', 'bucket' => 'Bucket')),
|
'backend' => 'Local',
|
||||||
'OC_Filestorage_Dropbox' => array('backend' => 'Dropbox', 'configuration' => array('configured' => '#configured','app_key' => 'App key', 'app_secret' => 'App secret', 'token' => '#token', 'token_secret' => '#token_secret'), 'custom' => 'dropbox'),
|
'configuration' => array(
|
||||||
'OC_Filestorage_FTP' => array('backend' => 'FTP', 'configuration' => array('host' => 'URL', 'user' => 'Username', 'password' => '*Password', 'root' => '&Root', 'secure' => '!Secure ftps://')),
|
'datadir' => 'Location')),
|
||||||
'OC_Filestorage_Google' => array('backend' => 'Google Drive', 'configuration' => array('configured' => '#configured', 'token' => '#token', 'token_secret' => '#token secret'), 'custom' => 'google'),
|
'OC_Filestorage_AmazonS3' => array(
|
||||||
'OC_Filestorage_SWIFT' => array('backend' => 'OpenStack Swift', 'configuration' => array('host' => 'URL', 'user' => 'Username', 'token' => '*Token', 'root' => '&Root', 'secure' => '!Secure ftps://')),
|
'backend' => 'Amazon S3',
|
||||||
'OC_Filestorage_SMB' => array('backend' => 'SMB', 'configuration' => array('host' => 'URL', 'user' => 'Username', 'password' => '*Password', 'share' => 'Share', 'root' => '&Root')),
|
'configuration' => array(
|
||||||
'OC_Filestorage_DAV' => array('backend' => 'WebDAV', 'configuration' => array('host' => 'URL', 'user' => 'Username', 'password' => '*Password', 'root' => '&Root', 'secure' => '!Secure https://'))
|
'key' => 'Key',
|
||||||
|
'secret' => '*Secret',
|
||||||
|
'bucket' => 'Bucket')),
|
||||||
|
'OC_Filestorage_Dropbox' => array(
|
||||||
|
'backend' => 'Dropbox',
|
||||||
|
'configuration' => array(
|
||||||
|
'configured' => '#configured',
|
||||||
|
'app_key' => 'App key',
|
||||||
|
'app_secret' => 'App secret',
|
||||||
|
'token' => '#token',
|
||||||
|
'token_secret' => '#token_secret'),
|
||||||
|
'custom' => 'dropbox'),
|
||||||
|
'OC_Filestorage_FTP' => array(
|
||||||
|
'backend' => 'FTP',
|
||||||
|
'configuration' => array(
|
||||||
|
'host' => 'URL',
|
||||||
|
'user' => 'Username',
|
||||||
|
'password' => '*Password',
|
||||||
|
'root' => '&Root',
|
||||||
|
'secure' => '!Secure ftps://')),
|
||||||
|
'OC_Filestorage_Google' => array(
|
||||||
|
'backend' => 'Google Drive',
|
||||||
|
'configuration' => array(
|
||||||
|
'configured' => '#configured',
|
||||||
|
'token' => '#token',
|
||||||
|
'token_secret' => '#token secret'),
|
||||||
|
'custom' => 'google'),
|
||||||
|
'OC_Filestorage_SWIFT' => array(
|
||||||
|
'backend' => 'OpenStack Swift',
|
||||||
|
'configuration' => array(
|
||||||
|
'host' => 'URL',
|
||||||
|
'user' => 'Username',
|
||||||
|
'token' => '*Token',
|
||||||
|
'root' => '&Root',
|
||||||
|
'secure' => '!Secure ftps://')),
|
||||||
|
'OC_Filestorage_SMB' => array(
|
||||||
|
'backend' => 'SMB',
|
||||||
|
'configuration' => array(
|
||||||
|
'host' => 'URL',
|
||||||
|
'user' => 'Username',
|
||||||
|
'password' => '*Password',
|
||||||
|
'share' => 'Share',
|
||||||
|
'root' => '&Root')),
|
||||||
|
'OC_Filestorage_DAV' => array(
|
||||||
|
'backend' => 'WebDAV',
|
||||||
|
'configuration' => array(
|
||||||
|
'host' => 'URL',
|
||||||
|
'user' => 'Username',
|
||||||
|
'password' => '*Password',
|
||||||
|
'root' => '&Root',
|
||||||
|
'secure' => '!Secure https://'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,9 +116,14 @@ class OC_Mount_Config {
|
||||||
$mountPoint = substr($mountPoint, 13);
|
$mountPoint = substr($mountPoint, 13);
|
||||||
// Merge the mount point into the current mount points
|
// Merge the mount point into the current mount points
|
||||||
if (isset($system[$mountPoint]) && $system[$mountPoint]['configuration'] == $mount['options']) {
|
if (isset($system[$mountPoint]) && $system[$mountPoint]['configuration'] == $mount['options']) {
|
||||||
$system[$mountPoint]['applicable']['groups'] = array_merge($system[$mountPoint]['applicable']['groups'], array($group));
|
$system[$mountPoint]['applicable']['groups']
|
||||||
|
= array_merge($system[$mountPoint]['applicable']['groups'], array($group));
|
||||||
} else {
|
} else {
|
||||||
$system[$mountPoint] = array('class' => $mount['class'], 'backend' => $backends[$mount['class']]['backend'], 'configuration' => $mount['options'], 'applicable' => array('groups' => array($group), 'users' => array()));
|
$system[$mountPoint] = array(
|
||||||
|
'class' => $mount['class'],
|
||||||
|
'backend' => $backends[$mount['class']]['backend'],
|
||||||
|
'configuration' => $mount['options'],
|
||||||
|
'applicable' => array('groups' => array($group), 'users' => array()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,9 +135,13 @@ class OC_Mount_Config {
|
||||||
$mountPoint = substr($mountPoint, 13);
|
$mountPoint = substr($mountPoint, 13);
|
||||||
// Merge the mount point into the current mount points
|
// Merge the mount point into the current mount points
|
||||||
if (isset($system[$mountPoint]) && $system[$mountPoint]['configuration'] == $mount['options']) {
|
if (isset($system[$mountPoint]) && $system[$mountPoint]['configuration'] == $mount['options']) {
|
||||||
$system[$mountPoint]['applicable']['users'] = array_merge($system[$mountPoint]['applicable']['users'], array($user));
|
$system[$mountPoint]['applicable']['users']
|
||||||
|
= array_merge($system[$mountPoint]['applicable']['users'], array($user));
|
||||||
} else {
|
} else {
|
||||||
$system[$mountPoint] = array('class' => $mount['class'], 'backend' => $backends[$mount['class']]['backend'], 'configuration' => $mount['options'], 'applicable' => array('groups' => array(), 'users' => array($user)));
|
$system[$mountPoint] = array('class' => $mount['class'],
|
||||||
|
'backend' => $backends[$mount['class']]['backend'],
|
||||||
|
'configuration' => $mount['options'],
|
||||||
|
'applicable' => array('groups' => array(), 'users' => array($user)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +162,9 @@ class OC_Mount_Config {
|
||||||
if (isset($mountPoints[self::MOUNT_TYPE_USER][$uid])) {
|
if (isset($mountPoints[self::MOUNT_TYPE_USER][$uid])) {
|
||||||
foreach ($mountPoints[self::MOUNT_TYPE_USER][$uid] as $mountPoint => $mount) {
|
foreach ($mountPoints[self::MOUNT_TYPE_USER][$uid] as $mountPoint => $mount) {
|
||||||
// Remove '/uid/files/' from mount point
|
// Remove '/uid/files/' from mount point
|
||||||
$personal[substr($mountPoint, strlen($uid) + 8)] = array('class' => $mount['class'], 'backend' => $backends[$mount['class']]['backend'], 'configuration' => $mount['options']);
|
$personal[substr($mountPoint, strlen($uid) + 8)] = array('class' => $mount['class'],
|
||||||
|
'backend' => $backends[$mount['class']]['backend'],
|
||||||
|
'configuration' => $mount['options']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $personal;
|
return $personal;
|
||||||
|
@ -135,7 +196,12 @@ class OC_Mount_Config {
|
||||||
* @param bool Personal or system mount point i.e. is this being called from the personal or admin page
|
* @param bool Personal or system mount point i.e. is this being called from the personal or admin page
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function addMountPoint($mountPoint, $class, $classOptions, $mountType, $applicable, $isPersonal = false) {
|
public static function addMountPoint($mountPoint,
|
||||||
|
$class,
|
||||||
|
$classOptions,
|
||||||
|
$mountType,
|
||||||
|
$applicable,
|
||||||
|
$isPersonal = false) {
|
||||||
if ($isPersonal) {
|
if ($isPersonal) {
|
||||||
// Verify that the mount point applies for the current user
|
// Verify that the mount point applies for the current user
|
||||||
// Prevent non-admin users from mounting local storage
|
// Prevent non-admin users from mounting local storage
|
||||||
|
@ -176,7 +242,8 @@ class OC_Mount_Config {
|
||||||
// Merge the new mount point into the current mount points
|
// Merge the new mount point into the current mount points
|
||||||
if (isset($mountPoints[$mountType])) {
|
if (isset($mountPoints[$mountType])) {
|
||||||
if (isset($mountPoints[$mountType][$applicable])) {
|
if (isset($mountPoints[$mountType][$applicable])) {
|
||||||
$mountPoints[$mountType][$applicable] = array_merge($mountPoints[$mountType][$applicable], $mount[$applicable]);
|
$mountPoints[$mountType][$applicable]
|
||||||
|
= array_merge($mountPoints[$mountType][$applicable], $mount[$applicable]);
|
||||||
} else {
|
} else {
|
||||||
$mountPoints[$mountType] = array_merge($mountPoints[$mountType], $mount);
|
$mountPoints[$mountType] = array_merge($mountPoints[$mountType], $mount);
|
||||||
}
|
}
|
||||||
|
@ -286,18 +353,18 @@ class OC_Mount_Config {
|
||||||
$view = \OCP\Files::getStorage('files_external');
|
$view = \OCP\Files::getStorage('files_external');
|
||||||
$path=\OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("").'uploads/';
|
$path=\OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("").'uploads/';
|
||||||
\OCP\Util::writeLog('files_external', 'checking path '.$path, \OCP\Util::INFO);
|
\OCP\Util::writeLog('files_external', 'checking path '.$path, \OCP\Util::INFO);
|
||||||
if(!is_dir($path)) {
|
if ( ! is_dir($path)) {
|
||||||
//path might not exist (e.g. non-standard OC_User::getHome() value)
|
//path might not exist (e.g. non-standard OC_User::getHome() value)
|
||||||
//in this case create full path using 3rd (recursive=true) parameter.
|
//in this case create full path using 3rd (recursive=true) parameter.
|
||||||
mkdir($path, 0777, true);
|
mkdir($path, 0777, true);
|
||||||
}
|
}
|
||||||
$result = array();
|
$result = array();
|
||||||
$handle = opendir($path);
|
$handle = opendir($path);
|
||||||
if (!$handle) {
|
if ( ! $handle) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
while (false !== ($file = readdir($handle))) {
|
while (false !== ($file = readdir($handle))) {
|
||||||
if($file != '.' && $file != '..') $result[] = $file;
|
if ($file != '.' && $file != '..') $result[] = $file;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,12 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
|
||||||
private static $tempFiles = array();
|
private static $tempFiles = array();
|
||||||
|
|
||||||
public function __construct($params) {
|
public function __construct($params) {
|
||||||
if (isset($params['configured']) && $params['configured'] == 'true' && isset($params['app_key']) && isset($params['app_secret']) && isset($params['token']) && isset($params['token_secret'])) {
|
if (isset($params['configured']) && $params['configured'] == 'true'
|
||||||
|
&& isset($params['app_key'])
|
||||||
|
&& isset($params['app_secret'])
|
||||||
|
&& isset($params['token'])
|
||||||
|
&& isset($params['token_secret'])
|
||||||
|
) {
|
||||||
$this->root=isset($params['root'])?$params['root']:'';
|
$this->root=isset($params['root'])?$params['root']:'';
|
||||||
$oauth = new Dropbox_OAuth_Curl($params['app_key'], $params['app_secret']);
|
$oauth = new Dropbox_OAuth_Curl($params['app_key'], $params['app_secret']);
|
||||||
$oauth->setToken($params['token'], $params['token_secret']);
|
$oauth->setToken($params['token'], $params['token_secret']);
|
||||||
|
@ -44,7 +49,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
|
||||||
|
|
||||||
private function getMetaData($path, $list = false) {
|
private function getMetaData($path, $list = false) {
|
||||||
$path = $this->root.$path;
|
$path = $this->root.$path;
|
||||||
if (!$list && isset($this->metaData[$path])) {
|
if ( ! $list && isset($this->metaData[$path])) {
|
||||||
return $this->metaData[$path];
|
return $this->metaData[$path];
|
||||||
} else {
|
} else {
|
||||||
if ($list) {
|
if ($list) {
|
||||||
|
@ -95,7 +100,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function opendir($path) {
|
public function opendir($path) {
|
||||||
if ($contents = $this->getMetaData($path, true)) {
|
$contents = $this->getMetaData($path, true);
|
||||||
|
if ($contents) {
|
||||||
$files = array();
|
$files = array();
|
||||||
foreach ($contents as $file) {
|
foreach ($contents as $file) {
|
||||||
$files[] = basename($file['path']);
|
$files[] = basename($file['path']);
|
||||||
|
@ -107,7 +113,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stat($path) {
|
public function stat($path) {
|
||||||
if ($metaData = $this->getMetaData($path)) {
|
$metaData = $this->getMetaData($path);
|
||||||
|
if ($metaData) {
|
||||||
$stat['size'] = $metaData['bytes'];
|
$stat['size'] = $metaData['bytes'];
|
||||||
$stat['atime'] = time();
|
$stat['atime'] = time();
|
||||||
$stat['mtime'] = (isset($metaData['modified'])) ? strtotime($metaData['modified']) : time();
|
$stat['mtime'] = (isset($metaData['modified'])) ? strtotime($metaData['modified']) : time();
|
||||||
|
@ -120,11 +127,14 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
|
||||||
public function filetype($path) {
|
public function filetype($path) {
|
||||||
if ($path == '' || $path == '/') {
|
if ($path == '' || $path == '/') {
|
||||||
return 'dir';
|
return 'dir';
|
||||||
} else if ($metaData = $this->getMetaData($path)) {
|
} else {
|
||||||
if ($metaData['is_dir'] == 'true') {
|
$metaData = $this->getMetaData($path);
|
||||||
return 'dir';
|
if ($metaData) {
|
||||||
} else {
|
if ($metaData['is_dir'] == 'true') {
|
||||||
return 'file';
|
return 'dir';
|
||||||
|
} else {
|
||||||
|
return 'file';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -241,8 +251,11 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
|
||||||
public function getMimeType($path) {
|
public function getMimeType($path) {
|
||||||
if ($this->filetype($path) == 'dir') {
|
if ($this->filetype($path) == 'dir') {
|
||||||
return 'httpd/unix-directory';
|
return 'httpd/unix-directory';
|
||||||
} else if ($metaData = $this->getMetaData($path)) {
|
} else {
|
||||||
return $metaData['mime_type'];
|
$metaData = $this->getMetaData($path);
|
||||||
|
if ($metaData) {
|
||||||
|
return $metaData['mime_type'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,21 +19,21 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
|
||||||
$this->host=$params['host'];
|
$this->host=$params['host'];
|
||||||
$this->user=$params['user'];
|
$this->user=$params['user'];
|
||||||
$this->password=$params['password'];
|
$this->password=$params['password'];
|
||||||
if(isset($params['secure'])) {
|
if (isset($params['secure'])) {
|
||||||
if(is_string($params['secure'])) {
|
if (is_string($params['secure'])) {
|
||||||
$this->secure = ($params['secure'] === 'true');
|
$this->secure = ($params['secure'] === 'true');
|
||||||
}else{
|
} else {
|
||||||
$this->secure = (bool)$params['secure'];
|
$this->secure = (bool)$params['secure'];
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
$this->secure = false;
|
$this->secure = false;
|
||||||
}
|
}
|
||||||
$this->root=isset($params['root'])?$params['root']:'/';
|
$this->root=isset($params['root'])?$params['root']:'/';
|
||||||
if(!$this->root || $this->root[0]!='/') {
|
if ( ! $this->root || $this->root[0]!='/') {
|
||||||
$this->root='/'.$this->root;
|
$this->root='/'.$this->root;
|
||||||
}
|
}
|
||||||
//create the root folder if necesary
|
//create the root folder if necesary
|
||||||
if (!$this->is_dir('')) {
|
if ( ! $this->is_dir('')) {
|
||||||
$this->mkdir('');
|
$this->mkdir('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
|
||||||
*/
|
*/
|
||||||
public function constructUrl($path) {
|
public function constructUrl($path) {
|
||||||
$url='ftp';
|
$url='ftp';
|
||||||
if($this->secure) {
|
if ($this->secure) {
|
||||||
$url.='s';
|
$url.='s';
|
||||||
}
|
}
|
||||||
$url.='://'.$this->user.':'.$this->password.'@'.$this->host.$this->root.$path;
|
$url.='://'.$this->user.':'.$this->password.'@'.$this->host.$this->root.$path;
|
||||||
|
@ -71,14 +71,14 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
|
||||||
case 'c':
|
case 'c':
|
||||||
case 'c+':
|
case 'c+':
|
||||||
//emulate these
|
//emulate these
|
||||||
if(strrpos($path, '.')!==false) {
|
if (strrpos($path, '.')!==false) {
|
||||||
$ext=substr($path, strrpos($path, '.'));
|
$ext=substr($path, strrpos($path, '.'));
|
||||||
}else{
|
} else {
|
||||||
$ext='';
|
$ext='';
|
||||||
}
|
}
|
||||||
$tmpFile=OCP\Files::tmpFile($ext);
|
$tmpFile=OCP\Files::tmpFile($ext);
|
||||||
OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack');
|
OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack');
|
||||||
if($this->file_exists($path)) {
|
if ($this->file_exists($path)) {
|
||||||
$this->getFile($path, $tmpFile);
|
$this->getFile($path, $tmpFile);
|
||||||
}
|
}
|
||||||
self::$tempFiles[$tmpFile]=$path;
|
self::$tempFiles[$tmpFile]=$path;
|
||||||
|
@ -87,7 +87,7 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function writeBack($tmpFile) {
|
public function writeBack($tmpFile) {
|
||||||
if(isset(self::$tempFiles[$tmpFile])) {
|
if (isset(self::$tempFiles[$tmpFile])) {
|
||||||
$this->uploadFile($tmpFile, self::$tempFiles[$tmpFile]);
|
$this->uploadFile($tmpFile, self::$tempFiles[$tmpFile]);
|
||||||
unlink($tmpFile);
|
unlink($tmpFile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,10 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
private static $tempFiles = array();
|
private static $tempFiles = array();
|
||||||
|
|
||||||
public function __construct($params) {
|
public function __construct($params) {
|
||||||
if (isset($params['configured']) && $params['configured'] == 'true' && isset($params['token']) && isset($params['token_secret'])) {
|
if (isset($params['configured']) && $params['configured'] == 'true'
|
||||||
|
&& isset($params['token'])
|
||||||
|
&& isset($params['token_secret'])
|
||||||
|
) {
|
||||||
$consumer_key = isset($params['consumer_key']) ? $params['consumer_key'] : 'anonymous';
|
$consumer_key = isset($params['consumer_key']) ? $params['consumer_key'] : 'anonymous';
|
||||||
$consumer_secret = isset($params['consumer_secret']) ? $params['consumer_secret'] : 'anonymous';
|
$consumer_secret = isset($params['consumer_secret']) ? $params['consumer_secret'] : 'anonymous';
|
||||||
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
|
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
|
||||||
|
@ -44,7 +47,14 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function sendRequest($uri, $httpMethod, $postData = null, $extraHeaders = null, $isDownload = false, $returnHeaders = false, $isContentXML = true, $returnHTTPCode = false) {
|
private function sendRequest($uri,
|
||||||
|
$httpMethod,
|
||||||
|
$postData = null,
|
||||||
|
$extraHeaders = null,
|
||||||
|
$isDownload = false,
|
||||||
|
$returnHeaders = false,
|
||||||
|
$isContentXML = true,
|
||||||
|
$returnHTTPCode = false) {
|
||||||
$uri = trim($uri);
|
$uri = trim($uri);
|
||||||
// create an associative array from each key/value url query param pair.
|
// create an associative array from each key/value url query param pair.
|
||||||
$params = array();
|
$params = array();
|
||||||
|
@ -58,7 +68,11 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
$tempStr .= '&' . urlencode($key) . '=' . urlencode($value);
|
$tempStr .= '&' . urlencode($key) . '=' . urlencode($value);
|
||||||
}
|
}
|
||||||
$uri = preg_replace('/&/', '?', $tempStr, 1);
|
$uri = preg_replace('/&/', '?', $tempStr, 1);
|
||||||
$request = OAuthRequest::from_consumer_and_token($this->consumer, $this->oauth_token, $httpMethod, $uri, $params);
|
$request = OAuthRequest::from_consumer_and_token($this->consumer,
|
||||||
|
$this->oauth_token,
|
||||||
|
$httpMethod,
|
||||||
|
$uri,
|
||||||
|
$params);
|
||||||
$request->sign_request($this->sig_method, $this->consumer, $this->oauth_token);
|
$request->sign_request($this->sig_method, $this->consumer, $this->oauth_token);
|
||||||
$auth_header = $request->to_header();
|
$auth_header = $request->to_header();
|
||||||
$headers = array($auth_header, 'GData-Version: 3.0');
|
$headers = array($auth_header, 'GData-Version: 3.0');
|
||||||
|
@ -132,6 +146,11 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base url for google docs feeds
|
||||||
|
*/
|
||||||
|
const BASE_URI='https://docs.google.com/feeds';
|
||||||
|
|
||||||
private function getResource($path) {
|
private function getResource($path) {
|
||||||
$file = basename($path);
|
$file = basename($path);
|
||||||
if (array_key_exists($file, $this->entries)) {
|
if (array_key_exists($file, $this->entries)) {
|
||||||
|
@ -140,14 +159,14 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
// Strip the file extension; file could be a native Google Docs resource
|
// Strip the file extension; file could be a native Google Docs resource
|
||||||
if ($pos = strpos($file, '.')) {
|
if ($pos = strpos($file, '.')) {
|
||||||
$title = substr($file, 0, $pos);
|
$title = substr($file, 0, $pos);
|
||||||
$dom = $this->getFeed('https://docs.google.com/feeds/default/private/full?showfolders=true&title='.$title, 'GET');
|
$dom = $this->getFeed(self::BASE_URI.'/default/private/full?showfolders=true&title='.$title, 'GET');
|
||||||
// Check if request was successful and entry exists
|
// Check if request was successful and entry exists
|
||||||
if ($dom && $entry = $dom->getElementsByTagName('entry')->item(0)) {
|
if ($dom && $entry = $dom->getElementsByTagName('entry')->item(0)) {
|
||||||
$this->entries[$file] = $entry;
|
$this->entries[$file] = $entry;
|
||||||
return $entry;
|
return $entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$dom = $this->getFeed('https://docs.google.com/feeds/default/private/full?showfolders=true&title='.$file, 'GET');
|
$dom = $this->getFeed(self::BASE_URI.'/default/private/full?showfolders=true&title='.$file, 'GET');
|
||||||
// Check if request was successful and entry exists
|
// Check if request was successful and entry exists
|
||||||
if ($dom && $entry = $dom->getElementsByTagName('entry')->item(0)) {
|
if ($dom && $entry = $dom->getElementsByTagName('entry')->item(0)) {
|
||||||
$this->entries[$file] = $entry;
|
$this->entries[$file] = $entry;
|
||||||
|
@ -180,20 +199,25 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
$collection = dirname($path);
|
$collection = dirname($path);
|
||||||
// Check if path parent is root directory
|
// Check if path parent is root directory
|
||||||
if ($collection == '/' || $collection == '\.' || $collection == '.') {
|
if ($collection == '/' || $collection == '\.' || $collection == '.') {
|
||||||
$uri = 'https://docs.google.com/feeds/default/private/full';
|
$uri = self::BASE_URI.'/default/private/full';
|
||||||
// Get parent content link
|
} else {
|
||||||
} else if ($dom = $this->getResource(basename($collection))) {
|
// Get parent content link
|
||||||
$uri = $dom->getElementsByTagName('content')->item(0)->getAttribute('src');
|
$dom = $this->getResource(basename($collection));
|
||||||
|
if ($dom) {
|
||||||
|
$uri = $dom->getElementsByTagName('content')->item(0)->getAttribute('src');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isset($uri)) {
|
if (isset($uri)) {
|
||||||
$title = basename($path);
|
$title = basename($path);
|
||||||
// Construct post data
|
// Construct post data
|
||||||
$postData = '<?xml version="1.0" encoding="UTF-8"?>';
|
$postData = '<?xml version="1.0" encoding="UTF-8"?>';
|
||||||
$postData .= '<entry xmlns="http://www.w3.org/2005/Atom">';
|
$postData .= '<entry xmlns="http://www.w3.org/2005/Atom">';
|
||||||
$postData .= '<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/docs/2007#folder"/>';
|
$postData .= '<category scheme="http://schemas.google.com/g/2005#kind"';
|
||||||
|
$postData .= ' term="http://schemas.google.com/docs/2007#folder"/>';
|
||||||
$postData .= '<title>'.$title.'</title>';
|
$postData .= '<title>'.$title.'</title>';
|
||||||
$postData .= '</entry>';
|
$postData .= '</entry>';
|
||||||
if ($dom = $this->sendRequest($uri, 'POST', $postData)) {
|
$dom = $this->sendRequest($uri, 'POST', $postData);
|
||||||
|
if ($dom) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,9 +230,10 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
|
|
||||||
public function opendir($path) {
|
public function opendir($path) {
|
||||||
if ($path == '' || $path == '/') {
|
if ($path == '' || $path == '/') {
|
||||||
$next = 'https://docs.google.com/feeds/default/private/full/folder%3Aroot/contents';
|
$next = self::BASE_URI.'/default/private/full/folder%3Aroot/contents';
|
||||||
} else {
|
} else {
|
||||||
if ($entry = $this->getResource($path)) {
|
$entry = $this->getResource($path);
|
||||||
|
if ($entry) {
|
||||||
$next = $entry->getElementsByTagName('content')->item(0)->getAttribute('src');
|
$next = $entry->getElementsByTagName('content')->item(0)->getAttribute('src');
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -230,7 +255,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
foreach ($entries as $entry) {
|
foreach ($entries as $entry) {
|
||||||
$name = $entry->getElementsByTagName('title')->item(0)->nodeValue;
|
$name = $entry->getElementsByTagName('title')->item(0)->nodeValue;
|
||||||
// Google Docs resources don't always include extensions in title
|
// Google Docs resources don't always include extensions in title
|
||||||
if (!strpos($name, '.')) {
|
if ( ! strpos($name, '.')) {
|
||||||
$extension = $this->getExtension($entry);
|
$extension = $this->getExtension($entry);
|
||||||
if ($extension != '') {
|
if ($extension != '') {
|
||||||
$name .= '.'.$extension;
|
$name .= '.'.$extension;
|
||||||
|
@ -251,13 +276,19 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
$stat['atime'] = time();
|
$stat['atime'] = time();
|
||||||
$stat['mtime'] = time();
|
$stat['mtime'] = time();
|
||||||
$stat['ctime'] = time();
|
$stat['ctime'] = time();
|
||||||
} else if ($entry = $this->getResource($path)) {
|
} else {
|
||||||
// NOTE: Native resources don't have a file size
|
$entry = $this->getResource($path);
|
||||||
$stat['size'] = $entry->getElementsByTagNameNS('http://schemas.google.com/g/2005', 'quotaBytesUsed')->item(0)->nodeValue;
|
if ($entry) {
|
||||||
// if (isset($atime = $entry->getElementsByTagNameNS('http://schemas.google.com/g/2005', 'lastViewed')->item(0)->nodeValue))
|
// NOTE: Native resources don't have a file size
|
||||||
// $stat['atime'] = strtotime($entry->getElementsByTagNameNS('http://schemas.google.com/g/2005', 'lastViewed')->item(0)->nodeValue);
|
$stat['size'] = $entry->getElementsByTagNameNS('http://schemas.google.com/g/2005',
|
||||||
$stat['mtime'] = strtotime($entry->getElementsByTagName('updated')->item(0)->nodeValue);
|
'quotaBytesUsed')->item(0)->nodeValue;
|
||||||
$stat['ctime'] = strtotime($entry->getElementsByTagName('published')->item(0)->nodeValue);
|
//if (isset($atime = $entry->getElementsByTagNameNS('http://schemas.google.com/g/2005',
|
||||||
|
// 'lastViewed')->item(0)->nodeValue))
|
||||||
|
//$stat['atime'] = strtotime($entry->getElementsByTagNameNS('http://schemas.google.com/g/2005',
|
||||||
|
// 'lastViewed')->item(0)->nodeValue);
|
||||||
|
$stat['mtime'] = strtotime($entry->getElementsByTagName('updated')->item(0)->nodeValue);
|
||||||
|
$stat['ctime'] = strtotime($entry->getElementsByTagName('published')->item(0)->nodeValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isset($stat)) {
|
if (isset($stat)) {
|
||||||
return $stat;
|
return $stat;
|
||||||
|
@ -268,15 +299,18 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
public function filetype($path) {
|
public function filetype($path) {
|
||||||
if ($path == '' || $path == '/') {
|
if ($path == '' || $path == '/') {
|
||||||
return 'dir';
|
return 'dir';
|
||||||
} else if ($entry = $this->getResource($path)) {
|
} else {
|
||||||
$categories = $entry->getElementsByTagName('category');
|
$entry = $this->getResource($path);
|
||||||
foreach ($categories as $category) {
|
if ($entry) {
|
||||||
if ($category->getAttribute('scheme') == 'http://schemas.google.com/g/2005#kind') {
|
$categories = $entry->getElementsByTagName('category');
|
||||||
$type = $category->getAttribute('label');
|
foreach ($categories as $category) {
|
||||||
if (strlen(strstr($type, 'folder')) > 0) {
|
if ($category->getAttribute('scheme') == 'http://schemas.google.com/g/2005#kind') {
|
||||||
return 'dir';
|
$type = $category->getAttribute('label');
|
||||||
} else {
|
if (strlen(strstr($type, 'folder')) > 0) {
|
||||||
return 'file';
|
return 'dir';
|
||||||
|
} else {
|
||||||
|
return 'file';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,14 +325,17 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
public function isUpdatable($path) {
|
public function isUpdatable($path) {
|
||||||
if ($path == '' || $path == '/') {
|
if ($path == '' || $path == '/') {
|
||||||
return true;
|
return true;
|
||||||
} else if ($entry = $this->getResource($path)) {
|
} else {
|
||||||
// Check if edit or edit-media links exist
|
$entry = $this->getResource($path);
|
||||||
$links = $entry->getElementsByTagName('link');
|
if ($entry) {
|
||||||
foreach ($links as $link) {
|
// Check if edit or edit-media links exist
|
||||||
if ($link->getAttribute('rel') == 'edit') {
|
$links = $entry->getElementsByTagName('link');
|
||||||
return true;
|
foreach ($links as $link) {
|
||||||
} else if ($link->getAttribute('rel') == 'edit-media') {
|
if ($link->getAttribute('rel') == 'edit') {
|
||||||
return true;
|
return true;
|
||||||
|
} else if ($link->getAttribute('rel') == 'edit-media') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -316,7 +353,8 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
|
|
||||||
public function unlink($path) {
|
public function unlink($path) {
|
||||||
// Get resource self link to trash resource
|
// Get resource self link to trash resource
|
||||||
if ($entry = $this->getResource($path)) {
|
$entry = $this->getResource($path);
|
||||||
|
if ($entry) {
|
||||||
$links = $entry->getElementsByTagName('link');
|
$links = $entry->getElementsByTagName('link');
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
if ($link->getAttribute('rel') == 'self') {
|
if ($link->getAttribute('rel') == 'self') {
|
||||||
|
@ -333,7 +371,8 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rename($path1, $path2) {
|
public function rename($path1, $path2) {
|
||||||
if ($entry = $this->getResource($path1)) {
|
$entry = $this->getResource($path1);
|
||||||
|
if ($entry) {
|
||||||
$collection = dirname($path2);
|
$collection = dirname($path2);
|
||||||
if (dirname($path1) == $collection) {
|
if (dirname($path1) == $collection) {
|
||||||
// Get resource edit link to rename resource
|
// Get resource edit link to rename resource
|
||||||
|
@ -348,14 +387,18 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
$title = basename($path2);
|
$title = basename($path2);
|
||||||
// Construct post data
|
// Construct post data
|
||||||
$postData = '<?xml version="1.0" encoding="UTF-8"?>';
|
$postData = '<?xml version="1.0" encoding="UTF-8"?>';
|
||||||
$postData .= '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:docs="http://schemas.google.com/docs/2007" xmlns:gd="http://schemas.google.com/g/2005" gd:etag='.$etag.'>';
|
$postData .= '<entry xmlns="http://www.w3.org/2005/Atom"';
|
||||||
|
$postData .= ' xmlns:docs="http://schemas.google.com/docs/2007"';
|
||||||
|
$postData .= ' xmlns:gd="http://schemas.google.com/g/2005"';
|
||||||
|
$postData .= ' gd:etag='.$etag.'>';
|
||||||
$postData .= '<title>'.$title.'</title>';
|
$postData .= '<title>'.$title.'</title>';
|
||||||
$postData .= '</entry>';
|
$postData .= '</entry>';
|
||||||
$this->sendRequest($uri, 'PUT', $postData);
|
$this->sendRequest($uri, 'PUT', $postData);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// Move to different collection
|
// Move to different collection
|
||||||
if ($collectionEntry = $this->getResource($collection)) {
|
$collectionEntry = $this->getResource($collection);
|
||||||
|
if ($collectionEntry) {
|
||||||
$feedUri = $collectionEntry->getElementsByTagName('content')->item(0)->getAttribute('src');
|
$feedUri = $collectionEntry->getElementsByTagName('content')->item(0)->getAttribute('src');
|
||||||
// Construct post data
|
// Construct post data
|
||||||
$postData = '<?xml version="1.0" encoding="UTF-8"?>';
|
$postData = '<?xml version="1.0" encoding="UTF-8"?>';
|
||||||
|
@ -374,7 +417,8 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
case 'r':
|
case 'r':
|
||||||
case 'rb':
|
case 'rb':
|
||||||
if ($entry = $this->getResource($path)) {
|
$entry = $this->getResource($path);
|
||||||
|
if ($entry) {
|
||||||
$extension = $this->getExtension($entry);
|
$extension = $this->getExtension($entry);
|
||||||
$downloadUri = $entry->getElementsByTagName('content')->item(0)->getAttribute('src');
|
$downloadUri = $entry->getElementsByTagName('content')->item(0)->getAttribute('src');
|
||||||
// TODO Non-native documents don't need these additional parameters
|
// TODO Non-native documents don't need these additional parameters
|
||||||
|
@ -420,14 +464,14 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
|
|
||||||
private function uploadFile($path, $target) {
|
private function uploadFile($path, $target) {
|
||||||
$entry = $this->getResource($target);
|
$entry = $this->getResource($target);
|
||||||
if (!$entry) {
|
if ( ! $entry) {
|
||||||
if (dirname($target) == '.' || dirname($target) == '/') {
|
if (dirname($target) == '.' || dirname($target) == '/') {
|
||||||
$uploadUri = 'https://docs.google.com/feeds/upload/create-session/default/private/full/folder%3Aroot/contents';
|
$uploadUri = self::BASE_URI.'/upload/create-session/default/private/full/folder%3Aroot/contents';
|
||||||
} else {
|
} else {
|
||||||
$entry = $this->getResource(dirname($target));
|
$entry = $this->getResource(dirname($target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isset($uploadUri) && $entry) {
|
if ( ! isset($uploadUri) && $entry) {
|
||||||
$links = $entry->getElementsByTagName('link');
|
$links = $entry->getElementsByTagName('link');
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
if ($link->getAttribute('rel') == 'http://schemas.google.com/g/2005#resumable-create-media') {
|
if ($link->getAttribute('rel') == 'http://schemas.google.com/g/2005#resumable-create-media') {
|
||||||
|
@ -466,7 +510,9 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$end = $i + $chunkSize - 1;
|
$end = $i + $chunkSize - 1;
|
||||||
$headers = array('Content-Length: '.$chunkSize, 'Content-Type: '.$mimetype, 'Content-Range: bytes '.$i.'-'.$end.'/'.$size);
|
$headers = array('Content-Length: '.$chunkSize,
|
||||||
|
'Content-Type: '.$mimetype,
|
||||||
|
'Content-Range: bytes '.$i.'-'.$end.'/'.$size);
|
||||||
$postData = fread($handle, $chunkSize);
|
$postData = fread($handle, $chunkSize);
|
||||||
$result = $this->sendRequest($uploadUri, 'PUT', $postData, $headers, false, true, false, true);
|
$result = $this->sendRequest($uploadUri, 'PUT', $postData, $headers, false, true, false, true);
|
||||||
if ($result['code'] == '308') {
|
if ($result['code'] == '308') {
|
||||||
|
@ -484,7 +530,8 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMimeType($path, $entry = null) {
|
public function getMimeType($path, $entry = null) {
|
||||||
// Entry can be passed, because extension is required for opendir and the entry can't be cached without the extension
|
// Entry can be passed, because extension is required for opendir
|
||||||
|
// and the entry can't be cached without the extension
|
||||||
if ($entry == null) {
|
if ($entry == null) {
|
||||||
if ($path == '' || $path == '/') {
|
if ($path == '' || $path == '/') {
|
||||||
return 'httpd/unix-directory';
|
return 'httpd/unix-directory';
|
||||||
|
@ -494,8 +541,10 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
}
|
}
|
||||||
if ($entry) {
|
if ($entry) {
|
||||||
$mimetype = $entry->getElementsByTagName('content')->item(0)->getAttribute('type');
|
$mimetype = $entry->getElementsByTagName('content')->item(0)->getAttribute('type');
|
||||||
// Native Google Docs resources often default to text/html, but it may be more useful to default to a corresponding ODF mimetype
|
// Native Google Docs resources often default to text/html,
|
||||||
// Collections get reported as application/atom+xml, make sure it actually is a folder and fix the mimetype
|
// but it may be more useful to default to a corresponding ODF mimetype
|
||||||
|
// Collections get reported as application/atom+xml,
|
||||||
|
// make sure it actually is a folder and fix the mimetype
|
||||||
if ($mimetype == 'text/html' || $mimetype == 'application/atom+xml;type=feed') {
|
if ($mimetype == 'text/html' || $mimetype == 'application/atom+xml;type=feed') {
|
||||||
$categories = $entry->getElementsByTagName('category');
|
$categories = $entry->getElementsByTagName('category');
|
||||||
foreach ($categories as $category) {
|
foreach ($categories as $category) {
|
||||||
|
@ -512,7 +561,8 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
} else if (strlen(strstr($type, 'drawing')) > 0) {
|
} else if (strlen(strstr($type, 'drawing')) > 0) {
|
||||||
return 'application/vnd.oasis.opendocument.graphics';
|
return 'application/vnd.oasis.opendocument.graphics';
|
||||||
} else {
|
} else {
|
||||||
// If nothing matches return text/html, all native Google Docs resources can be exported as text/html
|
// If nothing matches return text/html,
|
||||||
|
// all native Google Docs resources can be exported as text/html
|
||||||
return 'text/html';
|
return 'text/html';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -524,10 +574,13 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function free_space($path) {
|
public function free_space($path) {
|
||||||
if ($dom = $this->getFeed('https://docs.google.com/feeds/metadata/default', 'GET')) {
|
$dom = $this->getFeed(self::BASE_URI.'/metadata/default', 'GET');
|
||||||
|
if ($dom) {
|
||||||
// NOTE: Native Google Docs resources don't count towards quota
|
// NOTE: Native Google Docs resources don't count towards quota
|
||||||
$total = $dom->getElementsByTagNameNS('http://schemas.google.com/g/2005', 'quotaBytesTotal')->item(0)->nodeValue;
|
$total = $dom->getElementsByTagNameNS('http://schemas.google.com/g/2005',
|
||||||
$used = $dom->getElementsByTagNameNS('http://schemas.google.com/g/2005', 'quotaBytesUsed')->item(0)->nodeValue;
|
'quotaBytesTotal')->item(0)->nodeValue;
|
||||||
|
$used = $dom->getElementsByTagNameNS('http://schemas.google.com/g/2005',
|
||||||
|
'quotaBytesUsed')->item(0)->nodeValue;
|
||||||
return $total - $used;
|
return $total - $used;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -21,45 +21,46 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
|
||||||
$this->password=$params['password'];
|
$this->password=$params['password'];
|
||||||
$this->share=$params['share'];
|
$this->share=$params['share'];
|
||||||
$this->root=isset($params['root'])?$params['root']:'/';
|
$this->root=isset($params['root'])?$params['root']:'/';
|
||||||
if(!$this->root || $this->root[0]!='/') {
|
if ( ! $this->root || $this->root[0]!='/') {
|
||||||
$this->root='/'.$this->root;
|
$this->root='/'.$this->root;
|
||||||
}
|
}
|
||||||
if(substr($this->root, -1, 1)!='/') {
|
if (substr($this->root, -1, 1)!='/') {
|
||||||
$this->root.='/';
|
$this->root.='/';
|
||||||
}
|
}
|
||||||
if(!$this->share || $this->share[0]!='/') {
|
if ( ! $this->share || $this->share[0]!='/') {
|
||||||
$this->share='/'.$this->share;
|
$this->share='/'.$this->share;
|
||||||
}
|
}
|
||||||
if(substr($this->share, -1, 1)=='/') {
|
if (substr($this->share, -1, 1)=='/') {
|
||||||
$this->share=substr($this->share, 0, -1);
|
$this->share=substr($this->share, 0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//create the root folder if necesary
|
//create the root folder if necesary
|
||||||
if(!$this->is_dir('')) {
|
if ( ! $this->is_dir('')) {
|
||||||
$this->mkdir('');
|
$this->mkdir('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function constructUrl($path) {
|
public function constructUrl($path) {
|
||||||
if(substr($path, -1)=='/') {
|
if (substr($path, -1)=='/') {
|
||||||
$path=substr($path, 0, -1);
|
$path=substr($path, 0, -1);
|
||||||
}
|
}
|
||||||
return 'smb://'.$this->user.':'.$this->password.'@'.$this->host.$this->share.$this->root.$path;
|
return 'smb://'.$this->user.':'.$this->password.'@'.$this->host.$this->share.$this->root.$path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stat($path) {
|
public function stat($path) {
|
||||||
if(!$path and $this->root=='/') {//mtime doesn't work for shares
|
if ( ! $path and $this->root=='/') {//mtime doesn't work for shares
|
||||||
$mtime=$this->shareMTime();
|
$mtime=$this->shareMTime();
|
||||||
$stat=stat($this->constructUrl($path));
|
$stat=stat($this->constructUrl($path));
|
||||||
$stat['mtime']=$mtime;
|
$stat['mtime']=$mtime;
|
||||||
return $stat;
|
return $stat;
|
||||||
}else{
|
} else {
|
||||||
return stat($this->constructUrl($path));
|
return stat($this->constructUrl($path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function filetype($path) {
|
public function filetype($path) {
|
||||||
return (bool)@$this->opendir($path) ? 'dir' : 'file';//using opendir causes the same amount of requests and caches the content of the folder in one go
|
// using opendir causes the same amount of requests and caches the content of the folder in one go
|
||||||
|
return (bool)@$this->opendir($path) ? 'dir' : 'file';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,10 +69,11 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasUpdated($path, $time) {
|
public function hasUpdated($path, $time) {
|
||||||
if(!$path and $this->root=='/') {
|
if ( ! $path and $this->root=='/') {
|
||||||
//mtime doesn't work for shares, but giving the nature of the backend, doing a full update is still just fast enough
|
// mtime doesn't work for shares, but giving the nature of the backend,
|
||||||
|
// doing a full update is still just fast enough
|
||||||
return true;
|
return true;
|
||||||
}else{
|
} else {
|
||||||
$actualTime=$this->filemtime($path);
|
$actualTime=$this->filemtime($path);
|
||||||
return $actualTime>$time;
|
return $actualTime>$time;
|
||||||
}
|
}
|
||||||
|
@ -84,9 +86,9 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
|
||||||
$dh=$this->opendir('');
|
$dh=$this->opendir('');
|
||||||
$lastCtime=0;
|
$lastCtime=0;
|
||||||
while($file=readdir($dh)) {
|
while($file=readdir($dh)) {
|
||||||
if($file!='.' and $file!='..') {
|
if ($file!='.' and $file!='..') {
|
||||||
$ctime=$this->filemtime($file);
|
$ctime=$this->filemtime($file);
|
||||||
if($ctime>$lastCtime) {
|
if ($ctime>$lastCtime) {
|
||||||
$lastCtime=$ctime;
|
$lastCtime=$ctime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,11 @@ abstract class OC_FileStorage_StreamWrapper extends OC_Filestorage_Common{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rmdir($path) {
|
public function rmdir($path) {
|
||||||
if($this->file_exists($path)) {
|
if ($this->file_exists($path)) {
|
||||||
$succes=rmdir($this->constructUrl($path));
|
$succes = rmdir($this->constructUrl($path));
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
return $succes;
|
return $succes;
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ abstract class OC_FileStorage_StreamWrapper extends OC_Filestorage_Common{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function unlink($path) {
|
public function unlink($path) {
|
||||||
$succes=unlink($this->constructUrl($path));
|
$succes = unlink($this->constructUrl($path));
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
return $succes;
|
return $succes;
|
||||||
}
|
}
|
||||||
|
@ -58,12 +58,12 @@ abstract class OC_FileStorage_StreamWrapper extends OC_Filestorage_Common{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function touch($path, $mtime=null) {
|
public function touch($path, $mtime = null) {
|
||||||
if(is_null($mtime)) {
|
if (is_null($mtime)) {
|
||||||
$fh=$this->fopen($path, 'a');
|
$fh = $this->fopen($path, 'a');
|
||||||
fwrite($fh, '');
|
fwrite($fh, '');
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
}else{
|
} else {
|
||||||
return false;//not supported
|
return false;//not supported
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,4 @@ abstract class OC_FileStorage_StreamWrapper extends OC_Filestorage_Common{
|
||||||
return stat($this->constructUrl($path));
|
return stat($this->constructUrl($path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,17 +49,17 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
* @return CF_Container
|
* @return CF_Container
|
||||||
*/
|
*/
|
||||||
private function getContainer($path) {
|
private function getContainer($path) {
|
||||||
if($path=='' or $path=='/') {
|
if ($path=='' or $path=='/') {
|
||||||
return $this->rootContainer;
|
return $this->rootContainer;
|
||||||
}
|
}
|
||||||
if(isset($this->containers[$path])) {
|
if (isset($this->containers[$path])) {
|
||||||
return $this->containers[$path];
|
return $this->containers[$path];
|
||||||
}
|
}
|
||||||
try{
|
try {
|
||||||
$container=$this->conn->get_container($this->getContainerName($path));
|
$container=$this->conn->get_container($this->getContainerName($path));
|
||||||
$this->containers[$path]=$container;
|
$this->containers[$path]=$container;
|
||||||
return $container;
|
return $container;
|
||||||
}catch(NoSuchContainerException $e) {
|
} catch(NoSuchContainerException $e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,16 +70,16 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
* @return CF_Container
|
* @return CF_Container
|
||||||
*/
|
*/
|
||||||
private function createContainer($path) {
|
private function createContainer($path) {
|
||||||
if($path=='' or $path=='/' or $path=='.') {
|
if ($path=='' or $path=='/' or $path=='.') {
|
||||||
return $this->conn->create_container($this->getContainerName($path));
|
return $this->conn->create_container($this->getContainerName($path));
|
||||||
}
|
}
|
||||||
$parent=dirname($path);
|
$parent=dirname($path);
|
||||||
if($parent=='' or $parent=='/' or $parent=='.') {
|
if ($parent=='' or $parent=='/' or $parent=='.') {
|
||||||
$parentContainer=$this->rootContainer;
|
$parentContainer=$this->rootContainer;
|
||||||
}else{
|
} else {
|
||||||
if(!$this->containerExists($parent)) {
|
if ( ! $this->containerExists($parent)) {
|
||||||
$parentContainer=$this->createContainer($parent);
|
$parentContainer=$this->createContainer($parent);
|
||||||
}else{
|
} else {
|
||||||
$parentContainer=$this->getContainer($parent);
|
$parentContainer=$this->getContainer($parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,21 +93,21 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
* @return CF_Object
|
* @return CF_Object
|
||||||
*/
|
*/
|
||||||
private function getObject($path) {
|
private function getObject($path) {
|
||||||
if(isset($this->objects[$path])) {
|
if (isset($this->objects[$path])) {
|
||||||
return $this->objects[$path];
|
return $this->objects[$path];
|
||||||
}
|
}
|
||||||
$container=$this->getContainer(dirname($path));
|
$container=$this->getContainer(dirname($path));
|
||||||
if(is_null($container)) {
|
if (is_null($container)) {
|
||||||
return null;
|
return null;
|
||||||
}else{
|
} else {
|
||||||
if ($path=="/" or $path=='') {
|
if ($path=="/" or $path=='') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try{
|
try {
|
||||||
$obj=$container->get_object(basename($path));
|
$obj=$container->get_object(basename($path));
|
||||||
$this->objects[$path]=$obj;
|
$this->objects[$path]=$obj;
|
||||||
return $obj;
|
return $obj;
|
||||||
}catch(NoSuchObjectException $e) {
|
} catch(NoSuchObjectException $e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,11 +119,11 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getObjects($container) {
|
private function getObjects($container) {
|
||||||
if(is_null($container)) {
|
if (is_null($container)) {
|
||||||
return array();
|
return array();
|
||||||
}else{
|
} else {
|
||||||
$files=$container->get_objects();
|
$files=$container->get_objects();
|
||||||
foreach($files as &$file) {
|
foreach ($files as &$file) {
|
||||||
$file=$file->name;
|
$file=$file->name;
|
||||||
}
|
}
|
||||||
return $files;
|
return $files;
|
||||||
|
@ -137,7 +137,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
*/
|
*/
|
||||||
private function createObject($path) {
|
private function createObject($path) {
|
||||||
$container=$this->getContainer(dirname($path));
|
$container=$this->getContainer(dirname($path));
|
||||||
if(!is_null($container)) {
|
if ( ! is_null($container)) {
|
||||||
$container=$this->createContainer(dirname($path));
|
$container=$this->createContainer(dirname($path));
|
||||||
}
|
}
|
||||||
return $container->create_object(basename($path));
|
return $container->create_object(basename($path));
|
||||||
|
@ -169,15 +169,15 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
private function getSubContainers($container) {
|
private function getSubContainers($container) {
|
||||||
$tmpFile=OCP\Files::tmpFile();
|
$tmpFile=OCP\Files::tmpFile();
|
||||||
$obj=$this->getSubContainerFile($container);
|
$obj=$this->getSubContainerFile($container);
|
||||||
try{
|
try {
|
||||||
$obj->save_to_filename($tmpFile);
|
$obj->save_to_filename($tmpFile);
|
||||||
}catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
$obj->save_to_filename($tmpFile);
|
$obj->save_to_filename($tmpFile);
|
||||||
$containers=file($tmpFile);
|
$containers=file($tmpFile);
|
||||||
unlink($tmpFile);
|
unlink($tmpFile);
|
||||||
foreach($containers as &$sub) {
|
foreach ($containers as &$sub) {
|
||||||
$sub=trim($sub);
|
$sub=trim($sub);
|
||||||
}
|
}
|
||||||
return $containers;
|
return $containers;
|
||||||
|
@ -190,25 +190,25 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function addSubContainer($container, $name) {
|
private function addSubContainer($container, $name) {
|
||||||
if(!$name) {
|
if ( ! $name) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$tmpFile=OCP\Files::tmpFile();
|
$tmpFile=OCP\Files::tmpFile();
|
||||||
$obj=$this->getSubContainerFile($container);
|
$obj=$this->getSubContainerFile($container);
|
||||||
try{
|
try {
|
||||||
$obj->save_to_filename($tmpFile);
|
$obj->save_to_filename($tmpFile);
|
||||||
$containers=file($tmpFile);
|
$containers=file($tmpFile);
|
||||||
foreach($containers as &$sub) {
|
foreach ($containers as &$sub) {
|
||||||
$sub=trim($sub);
|
$sub=trim($sub);
|
||||||
}
|
}
|
||||||
if(array_search($name, $containers)!==false) {
|
if (array_search($name, $containers)!==false) {
|
||||||
unlink($tmpFile);
|
unlink($tmpFile);
|
||||||
return false;
|
return false;
|
||||||
}else{
|
} else {
|
||||||
$fh=fopen($tmpFile, 'a');
|
$fh=fopen($tmpFile, 'a');
|
||||||
fwrite($fh, $name."\n");
|
fwrite($fh, $name."\n");
|
||||||
}
|
}
|
||||||
}catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$containers=array();
|
$containers=array();
|
||||||
file_put_contents($tmpFile, $name."\n");
|
file_put_contents($tmpFile, $name."\n");
|
||||||
}
|
}
|
||||||
|
@ -225,25 +225,25 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function removeSubContainer($container, $name) {
|
private function removeSubContainer($container, $name) {
|
||||||
if(!$name) {
|
if ( ! $name) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$tmpFile=OCP\Files::tmpFile();
|
$tmpFile=OCP\Files::tmpFile();
|
||||||
$obj=$this->getSubContainerFile($container);
|
$obj=$this->getSubContainerFile($container);
|
||||||
try{
|
try {
|
||||||
$obj->save_to_filename($tmpFile);
|
$obj->save_to_filename($tmpFile);
|
||||||
$containers=file($tmpFile);
|
$containers=file($tmpFile);
|
||||||
}catch(Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
foreach($containers as &$sub) {
|
foreach ($containers as &$sub) {
|
||||||
$sub=trim($sub);
|
$sub=trim($sub);
|
||||||
}
|
}
|
||||||
$i=array_search($name, $containers);
|
$i=array_search($name, $containers);
|
||||||
if($i===false) {
|
if ($i===false) {
|
||||||
unlink($tmpFile);
|
unlink($tmpFile);
|
||||||
return false;
|
return false;
|
||||||
}else{
|
} else {
|
||||||
unset($containers[$i]);
|
unset($containers[$i]);
|
||||||
file_put_contents($tmpFile, implode("\n", $containers)."\n");
|
file_put_contents($tmpFile, implode("\n", $containers)."\n");
|
||||||
}
|
}
|
||||||
|
@ -259,9 +259,9 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
* @return CF_Object
|
* @return CF_Object
|
||||||
*/
|
*/
|
||||||
private function getSubContainerFile($container) {
|
private function getSubContainerFile($container) {
|
||||||
try{
|
try {
|
||||||
return $container->get_object(self::SUBCONTAINER_FILE);
|
return $container->get_object(self::SUBCONTAINER_FILE);
|
||||||
}catch(NoSuchObjectException $e) {
|
} catch(NoSuchObjectException $e) {
|
||||||
return $container->create_object(self::SUBCONTAINER_FILE);
|
return $container->create_object(self::SUBCONTAINER_FILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,16 +271,16 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
$this->host=$params['host'];
|
$this->host=$params['host'];
|
||||||
$this->user=$params['user'];
|
$this->user=$params['user'];
|
||||||
$this->root=isset($params['root'])?$params['root']:'/';
|
$this->root=isset($params['root'])?$params['root']:'/';
|
||||||
if(isset($params['secure'])) {
|
if (isset($params['secure'])) {
|
||||||
if(is_string($params['secure'])) {
|
if (is_string($params['secure'])) {
|
||||||
$this->secure = ($params['secure'] === 'true');
|
$this->secure = ($params['secure'] === 'true');
|
||||||
}else{
|
} else {
|
||||||
$this->secure = (bool)$params['secure'];
|
$this->secure = (bool)$params['secure'];
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
$this->secure = false;
|
$this->secure = false;
|
||||||
}
|
}
|
||||||
if(!$this->root || $this->root[0]!='/') {
|
if ( ! $this->root || $this->root[0]!='/') {
|
||||||
$this->root='/'.$this->root;
|
$this->root='/'.$this->root;
|
||||||
}
|
}
|
||||||
$this->auth = new CF_Authentication($this->user, $this->token, null, $this->host);
|
$this->auth = new CF_Authentication($this->user, $this->token, null, $this->host);
|
||||||
|
@ -288,29 +288,29 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
|
|
||||||
$this->conn = new CF_Connection($this->auth);
|
$this->conn = new CF_Connection($this->auth);
|
||||||
|
|
||||||
if(!$this->containerExists('/')) {
|
if ( ! $this->containerExists('/')) {
|
||||||
$this->rootContainer=$this->createContainer('/');
|
$this->rootContainer=$this->createContainer('/');
|
||||||
}else{
|
} else {
|
||||||
$this->rootContainer=$this->getContainer('/');
|
$this->rootContainer=$this->getContainer('/');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function mkdir($path) {
|
public function mkdir($path) {
|
||||||
if($this->containerExists($path)) {
|
if ($this->containerExists($path)) {
|
||||||
return false;
|
return false;
|
||||||
}else{
|
} else {
|
||||||
$this->createContainer($path);
|
$this->createContainer($path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rmdir($path) {
|
public function rmdir($path) {
|
||||||
if(!$this->containerExists($path)) {
|
if ( ! $this->containerExists($path)) {
|
||||||
return false;
|
return false;
|
||||||
}else{
|
} else {
|
||||||
$this->emptyContainer($path);
|
$this->emptyContainer($path);
|
||||||
if($path!='' and $path!='/') {
|
if ($path!='' and $path!='/') {
|
||||||
$parentContainer=$this->getContainer(dirname($path));
|
$parentContainer=$this->getContainer(dirname($path));
|
||||||
$this->removeSubContainer($parentContainer, basename($path));
|
$this->removeSubContainer($parentContainer, basename($path));
|
||||||
}
|
}
|
||||||
|
@ -323,12 +323,12 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
|
|
||||||
private function emptyContainer($path) {
|
private function emptyContainer($path) {
|
||||||
$container=$this->getContainer($path);
|
$container=$this->getContainer($path);
|
||||||
if(is_null($container)) {
|
if (is_null($container)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$subContainers=$this->getSubContainers($container);
|
$subContainers=$this->getSubContainers($container);
|
||||||
foreach($subContainers as $sub) {
|
foreach ($subContainers as $sub) {
|
||||||
if($sub) {
|
if ($sub) {
|
||||||
$this->emptyContainer($path.'/'.$sub);
|
$this->emptyContainer($path.'/'.$sub);
|
||||||
$this->conn->delete_container($this->getContainerName($path.'/'.$sub));
|
$this->conn->delete_container($this->getContainerName($path.'/'.$sub));
|
||||||
unset($this->containers[$path.'/'.$sub]);
|
unset($this->containers[$path.'/'.$sub]);
|
||||||
|
@ -336,7 +336,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
}
|
}
|
||||||
|
|
||||||
$objects=$this->getObjects($container);
|
$objects=$this->getObjects($container);
|
||||||
foreach($objects as $object) {
|
foreach ($objects as $object) {
|
||||||
$container->delete_object($object);
|
$container->delete_object($object);
|
||||||
unset($this->objects[$path.'/'.$object]);
|
unset($this->objects[$path.'/'.$object]);
|
||||||
}
|
}
|
||||||
|
@ -346,7 +346,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
$container=$this->getContainer($path);
|
$container=$this->getContainer($path);
|
||||||
$files=$this->getObjects($container);
|
$files=$this->getObjects($container);
|
||||||
$i=array_search(self::SUBCONTAINER_FILE, $files);
|
$i=array_search(self::SUBCONTAINER_FILE, $files);
|
||||||
if($i!==false) {
|
if ($i!==false) {
|
||||||
unset($files[$i]);
|
unset($files[$i]);
|
||||||
}
|
}
|
||||||
$subContainers=$this->getSubContainers($container);
|
$subContainers=$this->getSubContainers($container);
|
||||||
|
@ -357,9 +357,9 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function filetype($path) {
|
public function filetype($path) {
|
||||||
if($this->containerExists($path)) {
|
if ($this->containerExists($path)) {
|
||||||
return 'dir';
|
return 'dir';
|
||||||
}else{
|
} else {
|
||||||
return 'file';
|
return 'file';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -373,16 +373,16 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function file_exists($path) {
|
public function file_exists($path) {
|
||||||
if($this->is_dir($path)) {
|
if ($this->is_dir($path)) {
|
||||||
return true;
|
return true;
|
||||||
}else{
|
} else {
|
||||||
return $this->objectExists($path);
|
return $this->objectExists($path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function file_get_contents($path) {
|
public function file_get_contents($path) {
|
||||||
$obj=$this->getObject($path);
|
$obj=$this->getObject($path);
|
||||||
if(is_null($obj)) {
|
if (is_null($obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $obj->read();
|
return $obj->read();
|
||||||
|
@ -390,9 +390,9 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
|
|
||||||
public function file_put_contents($path, $content) {
|
public function file_put_contents($path, $content) {
|
||||||
$obj=$this->getObject($path);
|
$obj=$this->getObject($path);
|
||||||
if(is_null($obj)) {
|
if (is_null($obj)) {
|
||||||
$container=$this->getContainer(dirname($path));
|
$container=$this->getContainer(dirname($path));
|
||||||
if(is_null($container)) {
|
if (is_null($container)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$obj=$container->create_object(basename($path));
|
$obj=$container->create_object(basename($path));
|
||||||
|
@ -402,14 +402,14 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function unlink($path) {
|
public function unlink($path) {
|
||||||
if($this->containerExists($path)) {
|
if ($this->containerExists($path)) {
|
||||||
return $this->rmdir($path);
|
return $this->rmdir($path);
|
||||||
}
|
}
|
||||||
if($this->objectExists($path)) {
|
if ($this->objectExists($path)) {
|
||||||
$container=$this->getContainer(dirname($path));
|
$container=$this->getContainer(dirname($path));
|
||||||
$container->delete_object(basename($path));
|
$container->delete_object(basename($path));
|
||||||
unset($this->objects[$path]);
|
unset($this->objects[$path]);
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -447,7 +447,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function writeBack($tmpFile) {
|
public function writeBack($tmpFile) {
|
||||||
if(isset(self::$tempFiles[$tmpFile])) {
|
if (isset(self::$tempFiles[$tmpFile])) {
|
||||||
$this->fromTmpFile($tmpFile, self::$tempFiles[$tmpFile]);
|
$this->fromTmpFile($tmpFile, self::$tempFiles[$tmpFile]);
|
||||||
unlink($tmpFile);
|
unlink($tmpFile);
|
||||||
}
|
}
|
||||||
|
@ -459,10 +459,10 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
|
|
||||||
public function touch($path, $mtime=null) {
|
public function touch($path, $mtime=null) {
|
||||||
$obj=$this->getObject($path);
|
$obj=$this->getObject($path);
|
||||||
if(is_null($obj)) {
|
if (is_null($obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(is_null($mtime)) {
|
if (is_null($mtime)) {
|
||||||
$mtime=time();
|
$mtime=time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,7 +476,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
$targetContainer=$this->getContainer(dirname($path2));
|
$targetContainer=$this->getContainer(dirname($path2));
|
||||||
$result=$sourceContainer->move_object_to(basename($path1), $targetContainer, basename($path2));
|
$result=$sourceContainer->move_object_to(basename($path1), $targetContainer, basename($path2));
|
||||||
unset($this->objects[$path1]);
|
unset($this->objects[$path1]);
|
||||||
if($result) {
|
if ($result) {
|
||||||
$targetObj=$this->getObject($path2);
|
$targetObj=$this->getObject($path2);
|
||||||
$this->resetMTime($targetObj);
|
$this->resetMTime($targetObj);
|
||||||
}
|
}
|
||||||
|
@ -487,7 +487,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
$sourceContainer=$this->getContainer(dirname($path1));
|
$sourceContainer=$this->getContainer(dirname($path1));
|
||||||
$targetContainer=$this->getContainer(dirname($path2));
|
$targetContainer=$this->getContainer(dirname($path2));
|
||||||
$result=$sourceContainer->copy_object_to(basename($path1), $targetContainer, basename($path2));
|
$result=$sourceContainer->copy_object_to(basename($path1), $targetContainer, basename($path2));
|
||||||
if($result) {
|
if ($result) {
|
||||||
$targetObj=$this->getObject($path2);
|
$targetObj=$this->getObject($path2);
|
||||||
$this->resetMTime($targetObj);
|
$this->resetMTime($targetObj);
|
||||||
}
|
}
|
||||||
|
@ -496,7 +496,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
|
|
||||||
public function stat($path) {
|
public function stat($path) {
|
||||||
$container=$this->getContainer($path);
|
$container=$this->getContainer($path);
|
||||||
if (!is_null($container)) {
|
if ( ! is_null($container)) {
|
||||||
return array(
|
return array(
|
||||||
'mtime'=>-1,
|
'mtime'=>-1,
|
||||||
'size'=>$container->bytes_used,
|
'size'=>$container->bytes_used,
|
||||||
|
@ -506,13 +506,13 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
|
|
||||||
$obj=$this->getObject($path);
|
$obj=$this->getObject($path);
|
||||||
|
|
||||||
if(is_null($obj)) {
|
if (is_null($obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($obj->metadata['Mtime']) and $obj->metadata['Mtime']>-1) {
|
if (isset($obj->metadata['Mtime']) and $obj->metadata['Mtime']>-1) {
|
||||||
$mtime=$obj->metadata['Mtime'];
|
$mtime=$obj->metadata['Mtime'];
|
||||||
}else{
|
} else {
|
||||||
$mtime=strtotime($obj->last_modified);
|
$mtime=strtotime($obj->last_modified);
|
||||||
}
|
}
|
||||||
return array(
|
return array(
|
||||||
|
@ -524,18 +524,18 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
|
|
||||||
private function getTmpFile($path) {
|
private function getTmpFile($path) {
|
||||||
$obj=$this->getObject($path);
|
$obj=$this->getObject($path);
|
||||||
if(!is_null($obj)) {
|
if ( ! is_null($obj)) {
|
||||||
$tmpFile=OCP\Files::tmpFile();
|
$tmpFile=OCP\Files::tmpFile();
|
||||||
$obj->save_to_filename($tmpFile);
|
$obj->save_to_filename($tmpFile);
|
||||||
return $tmpFile;
|
return $tmpFile;
|
||||||
}else{
|
} else {
|
||||||
return OCP\Files::tmpFile();
|
return OCP\Files::tmpFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function fromTmpFile($tmpFile, $path) {
|
private function fromTmpFile($tmpFile, $path) {
|
||||||
$obj=$this->getObject($path);
|
$obj=$this->getObject($path);
|
||||||
if(is_null($obj)) {
|
if (is_null($obj)) {
|
||||||
$obj=$this->createObject($path);
|
$obj=$this->createObject($path);
|
||||||
}
|
}
|
||||||
$obj->load_from_filename($tmpFile);
|
$obj->load_from_filename($tmpFile);
|
||||||
|
@ -547,7 +547,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
||||||
* @param CF_Object obj
|
* @param CF_Object obj
|
||||||
*/
|
*/
|
||||||
private function resetMTime($obj) {
|
private function resetMTime($obj) {
|
||||||
if(isset($obj->metadata['Mtime'])) {
|
if (isset($obj->metadata['Mtime'])) {
|
||||||
$obj->metadata['Mtime']=-1;
|
$obj->metadata['Mtime']=-1;
|
||||||
$obj->sync_metadata();
|
$obj->sync_metadata();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,20 +27,20 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
|
||||||
$this->host=$host;
|
$this->host=$host;
|
||||||
$this->user=$params['user'];
|
$this->user=$params['user'];
|
||||||
$this->password=$params['password'];
|
$this->password=$params['password'];
|
||||||
if(isset($params['secure'])) {
|
if (isset($params['secure'])) {
|
||||||
if(is_string($params['secure'])) {
|
if (is_string($params['secure'])) {
|
||||||
$this->secure = ($params['secure'] === 'true');
|
$this->secure = ($params['secure'] === 'true');
|
||||||
}else{
|
} else {
|
||||||
$this->secure = (bool)$params['secure'];
|
$this->secure = (bool)$params['secure'];
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
$this->secure = false;
|
$this->secure = false;
|
||||||
}
|
}
|
||||||
$this->root=isset($params['root'])?$params['root']:'/';
|
$this->root=isset($params['root'])?$params['root']:'/';
|
||||||
if(!$this->root || $this->root[0]!='/') {
|
if ( ! $this->root || $this->root[0]!='/') {
|
||||||
$this->root='/'.$this->root;
|
$this->root='/'.$this->root;
|
||||||
}
|
}
|
||||||
if(substr($this->root, -1, 1)!='/') {
|
if (substr($this->root, -1, 1)!='/') {
|
||||||
$this->root.='/';
|
$this->root.='/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,8 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
|
||||||
|
|
||||||
$this->client = new OC_Connector_Sabre_Client($settings);
|
$this->client = new OC_Connector_Sabre_Client($settings);
|
||||||
|
|
||||||
if($caview = \OCP\Files::getStorage('files_external')) {
|
$caview = \OCP\Files::getStorage('files_external');
|
||||||
|
if ($caview) {
|
||||||
$certPath=\OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath("").'rootcerts.crt';
|
$certPath=\OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath("").'rootcerts.crt';
|
||||||
if (file_exists($certPath)) {
|
if (file_exists($certPath)) {
|
||||||
$this->client->addTrustedCertificates($certPath);
|
$this->client->addTrustedCertificates($certPath);
|
||||||
|
@ -64,7 +65,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
|
||||||
|
|
||||||
private function createBaseUri() {
|
private function createBaseUri() {
|
||||||
$baseUri='http';
|
$baseUri='http';
|
||||||
if($this->secure) {
|
if ($this->secure) {
|
||||||
$baseUri.='s';
|
$baseUri.='s';
|
||||||
}
|
}
|
||||||
$baseUri.='://'.$this->host.$this->root;
|
$baseUri.='://'.$this->host.$this->root;
|
||||||
|
@ -83,29 +84,29 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
|
||||||
|
|
||||||
public function opendir($path) {
|
public function opendir($path) {
|
||||||
$path=$this->cleanPath($path);
|
$path=$this->cleanPath($path);
|
||||||
try{
|
try {
|
||||||
$response=$this->client->propfind($path, array(), 1);
|
$response=$this->client->propfind($path, array(), 1);
|
||||||
$id=md5('webdav'.$this->root.$path);
|
$id=md5('webdav'.$this->root.$path);
|
||||||
OC_FakeDirStream::$dirs[$id]=array();
|
OC_FakeDirStream::$dirs[$id]=array();
|
||||||
$files=array_keys($response);
|
$files=array_keys($response);
|
||||||
array_shift($files);//the first entry is the current directory
|
array_shift($files);//the first entry is the current directory
|
||||||
foreach($files as $file) {
|
foreach ($files as $file) {
|
||||||
$file = urldecode(basename($file));
|
$file = urldecode(basename($file));
|
||||||
OC_FakeDirStream::$dirs[$id][]=$file;
|
OC_FakeDirStream::$dirs[$id][]=$file;
|
||||||
}
|
}
|
||||||
return opendir('fakedir://'.$id);
|
return opendir('fakedir://'.$id);
|
||||||
}catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function filetype($path) {
|
public function filetype($path) {
|
||||||
$path=$this->cleanPath($path);
|
$path=$this->cleanPath($path);
|
||||||
try{
|
try {
|
||||||
$response=$this->client->propfind($path, array('{DAV:}resourcetype'));
|
$response=$this->client->propfind($path, array('{DAV:}resourcetype'));
|
||||||
$responseType=$response["{DAV:}resourcetype"]->resourceType;
|
$responseType=$response["{DAV:}resourcetype"]->resourceType;
|
||||||
return (count($responseType)>0 and $responseType[0]=="{DAV:}collection")?'dir':'file';
|
return (count($responseType)>0 and $responseType[0]=="{DAV:}collection")?'dir':'file';
|
||||||
}catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
error_log($e->getMessage());
|
error_log($e->getMessage());
|
||||||
\OCP\Util::writeLog("webdav client", \OCP\Util::sanitizeHTML($e->getMessage()), \OCP\Util::ERROR);
|
\OCP\Util::writeLog("webdav client", \OCP\Util::sanitizeHTML($e->getMessage()), \OCP\Util::ERROR);
|
||||||
return false;
|
return false;
|
||||||
|
@ -122,10 +123,10 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
|
||||||
|
|
||||||
public function file_exists($path) {
|
public function file_exists($path) {
|
||||||
$path=$this->cleanPath($path);
|
$path=$this->cleanPath($path);
|
||||||
try{
|
try {
|
||||||
$this->client->propfind($path, array('{DAV:}resourcetype'));
|
$this->client->propfind($path, array('{DAV:}resourcetype'));
|
||||||
return true;//no 404 exception
|
return true;//no 404 exception
|
||||||
}catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +140,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
|
||||||
switch($mode) {
|
switch($mode) {
|
||||||
case 'r':
|
case 'r':
|
||||||
case 'rb':
|
case 'rb':
|
||||||
if(!$this->file_exists($path)) {
|
if ( ! $this->file_exists($path)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//straight up curl instead of sabredav here, sabredav put's the entire get result in memory
|
//straight up curl instead of sabredav here, sabredav put's the entire get result in memory
|
||||||
|
@ -166,14 +167,14 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
|
||||||
case 'c':
|
case 'c':
|
||||||
case 'c+':
|
case 'c+':
|
||||||
//emulate these
|
//emulate these
|
||||||
if(strrpos($path, '.')!==false) {
|
if (strrpos($path, '.')!==false) {
|
||||||
$ext=substr($path, strrpos($path, '.'));
|
$ext=substr($path, strrpos($path, '.'));
|
||||||
}else{
|
} else {
|
||||||
$ext='';
|
$ext='';
|
||||||
}
|
}
|
||||||
$tmpFile=OCP\Files::tmpFile($ext);
|
$tmpFile=OCP\Files::tmpFile($ext);
|
||||||
OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack');
|
OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack');
|
||||||
if($this->file_exists($path)) {
|
if ($this->file_exists($path)) {
|
||||||
$this->getFile($path, $tmpFile);
|
$this->getFile($path, $tmpFile);
|
||||||
}
|
}
|
||||||
self::$tempFiles[$tmpFile]=$path;
|
self::$tempFiles[$tmpFile]=$path;
|
||||||
|
@ -182,7 +183,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function writeBack($tmpFile) {
|
public function writeBack($tmpFile) {
|
||||||
if(isset(self::$tempFiles[$tmpFile])) {
|
if (isset(self::$tempFiles[$tmpFile])) {
|
||||||
$this->uploadFile($tmpFile, self::$tempFiles[$tmpFile]);
|
$this->uploadFile($tmpFile, self::$tempFiles[$tmpFile]);
|
||||||
unlink($tmpFile);
|
unlink($tmpFile);
|
||||||
}
|
}
|
||||||
|
@ -190,20 +191,20 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
|
||||||
|
|
||||||
public function free_space($path) {
|
public function free_space($path) {
|
||||||
$path=$this->cleanPath($path);
|
$path=$this->cleanPath($path);
|
||||||
try{
|
try {
|
||||||
$response=$this->client->propfind($path, array('{DAV:}quota-available-bytes'));
|
$response=$this->client->propfind($path, array('{DAV:}quota-available-bytes'));
|
||||||
if(isset($response['{DAV:}quota-available-bytes'])) {
|
if (isset($response['{DAV:}quota-available-bytes'])) {
|
||||||
return (int)$response['{DAV:}quota-available-bytes'];
|
return (int)$response['{DAV:}quota-available-bytes'];
|
||||||
}else{
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function touch($path, $mtime=null) {
|
public function touch($path, $mtime=null) {
|
||||||
if(is_null($mtime)) {
|
if (is_null($mtime)) {
|
||||||
$mtime=time();
|
$mtime=time();
|
||||||
}
|
}
|
||||||
$path=$this->cleanPath($path);
|
$path=$this->cleanPath($path);
|
||||||
|
@ -232,10 +233,10 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
|
||||||
public function rename($path1, $path2) {
|
public function rename($path1, $path2) {
|
||||||
$path1=$this->cleanPath($path1);
|
$path1=$this->cleanPath($path1);
|
||||||
$path2=$this->root.$this->cleanPath($path2);
|
$path2=$this->root.$this->cleanPath($path2);
|
||||||
try{
|
try {
|
||||||
$response=$this->client->request('MOVE', $path1, null, array('Destination'=>$path2));
|
$response=$this->client->request('MOVE', $path1, null, array('Destination'=>$path2));
|
||||||
return true;
|
return true;
|
||||||
}catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
echo $e;
|
echo $e;
|
||||||
echo 'fail';
|
echo 'fail';
|
||||||
var_dump($response);
|
var_dump($response);
|
||||||
|
@ -246,10 +247,10 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
|
||||||
public function copy($path1, $path2) {
|
public function copy($path1, $path2) {
|
||||||
$path1=$this->cleanPath($path1);
|
$path1=$this->cleanPath($path1);
|
||||||
$path2=$this->root.$this->cleanPath($path2);
|
$path2=$this->root.$this->cleanPath($path2);
|
||||||
try{
|
try {
|
||||||
$response=$this->client->request('COPY', $path1, null, array('Destination'=>$path2));
|
$response=$this->client->request('COPY', $path1, null, array('Destination'=>$path2));
|
||||||
return true;
|
return true;
|
||||||
}catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
echo $e;
|
echo $e;
|
||||||
echo 'fail';
|
echo 'fail';
|
||||||
var_dump($response);
|
var_dump($response);
|
||||||
|
@ -259,50 +260,50 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
|
||||||
|
|
||||||
public function stat($path) {
|
public function stat($path) {
|
||||||
$path=$this->cleanPath($path);
|
$path=$this->cleanPath($path);
|
||||||
try{
|
try {
|
||||||
$response=$this->client->propfind($path, array('{DAV:}getlastmodified', '{DAV:}getcontentlength'));
|
$response=$this->client->propfind($path, array('{DAV:}getlastmodified', '{DAV:}getcontentlength'));
|
||||||
return array(
|
return array(
|
||||||
'mtime'=>strtotime($response['{DAV:}getlastmodified']),
|
'mtime'=>strtotime($response['{DAV:}getlastmodified']),
|
||||||
'size'=>(int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0,
|
'size'=>(int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0,
|
||||||
'ctime'=>-1,
|
'ctime'=>-1,
|
||||||
);
|
);
|
||||||
}catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMimeType($path) {
|
public function getMimeType($path) {
|
||||||
$path=$this->cleanPath($path);
|
$path=$this->cleanPath($path);
|
||||||
try{
|
try {
|
||||||
$response=$this->client->propfind($path, array('{DAV:}getcontenttype', '{DAV:}resourcetype'));
|
$response=$this->client->propfind($path, array('{DAV:}getcontenttype', '{DAV:}resourcetype'));
|
||||||
$responseType=$response["{DAV:}resourcetype"]->resourceType;
|
$responseType=$response["{DAV:}resourcetype"]->resourceType;
|
||||||
$type=(count($responseType)>0 and $responseType[0]=="{DAV:}collection")?'dir':'file';
|
$type=(count($responseType)>0 and $responseType[0]=="{DAV:}collection")?'dir':'file';
|
||||||
if($type=='dir') {
|
if ($type=='dir') {
|
||||||
return 'httpd/unix-directory';
|
return 'httpd/unix-directory';
|
||||||
}elseif(isset($response['{DAV:}getcontenttype'])) {
|
} elseif (isset($response['{DAV:}getcontenttype'])) {
|
||||||
return $response['{DAV:}getcontenttype'];
|
return $response['{DAV:}getcontenttype'];
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function cleanPath($path) {
|
private function cleanPath($path) {
|
||||||
if(!$path || $path[0]=='/') {
|
if ( ! $path || $path[0]=='/') {
|
||||||
return substr($path, 1);
|
return substr($path, 1);
|
||||||
}else{
|
} else {
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function simpleResponse($method, $path, $body, $expected) {
|
private function simpleResponse($method, $path, $body, $expected) {
|
||||||
$path=$this->cleanPath($path);
|
$path=$this->cleanPath($path);
|
||||||
try{
|
try {
|
||||||
$response=$this->client->request($method, $path, $body);
|
$response=$this->client->request($method, $path, $body);
|
||||||
return $response['statusCode']==$expected;
|
return $response['statusCode']==$expected;
|
||||||
}catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,18 +16,22 @@
|
||||||
<?php $_['mounts'] = array_merge($_['mounts'], array('' => array())); ?>
|
<?php $_['mounts'] = array_merge($_['mounts'], array('' => array())); ?>
|
||||||
<?php foreach ($_['mounts'] as $mountPoint => $mount): ?>
|
<?php foreach ($_['mounts'] as $mountPoint => $mount): ?>
|
||||||
<tr <?php echo ($mountPoint != '') ? 'class="'.$mount['class'].'"' : 'id="addMountPoint"'; ?>>
|
<tr <?php echo ($mountPoint != '') ? 'class="'.$mount['class'].'"' : 'id="addMountPoint"'; ?>>
|
||||||
<td class="mountPoint"><input type="text" name="mountPoint" value="<?php echo $mountPoint; ?>" placeholder="<?php echo $l->t('Mount point'); ?>" /></td>
|
<td class="mountPoint"><input type="text" name="mountPoint"
|
||||||
|
value="<?php echo $mountPoint; ?>"
|
||||||
|
placeholder="<?php echo $l->t('Mount point'); ?>" /></td>
|
||||||
<?php if ($mountPoint == ''): ?>
|
<?php if ($mountPoint == ''): ?>
|
||||||
<td class="backend">
|
<td class="backend">
|
||||||
<select id="selectBackend" data-configurations='<?php echo json_encode($_['backends']); ?>'>
|
<select id="selectBackend" data-configurations='<?php echo json_encode($_['backends']); ?>'>
|
||||||
<option value="" disabled selected style="display:none;"><?php echo $l->t('Add mount point'); ?></option>
|
<option value="" disabled selected
|
||||||
|
style="display:none;"><?php echo $l->t('Add mount point'); ?></option>
|
||||||
<?php foreach ($_['backends'] as $class => $backend): ?>
|
<?php foreach ($_['backends'] as $class => $backend): ?>
|
||||||
<option value="<?php echo $class; ?>"><?php echo $backend['backend']; ?></option>
|
<option value="<?php echo $class; ?>"><?php echo $backend['backend']; ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<td class="backend" data-class="<?php echo $mount['class']; ?>"><?php echo $mount['backend']; ?></td>
|
<td class="backend"
|
||||||
|
data-class="<?php echo $mount['class']; ?>"><?php echo $mount['backend']; ?></td>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<td class ="configuration" width="100%">
|
<td class ="configuration" width="100%">
|
||||||
<?php if (isset($mount['configuration'])): ?>
|
<?php if (isset($mount['configuration'])): ?>
|
||||||
|
@ -35,46 +39,75 @@
|
||||||
<?php if (isset($_['backends'][$mount['class']]['configuration'][$parameter])): ?>
|
<?php if (isset($_['backends'][$mount['class']]['configuration'][$parameter])): ?>
|
||||||
<?php $placeholder = $_['backends'][$mount['class']]['configuration'][$parameter]; ?>
|
<?php $placeholder = $_['backends'][$mount['class']]['configuration'][$parameter]; ?>
|
||||||
<?php if (strpos($placeholder, '*') !== false): ?>
|
<?php if (strpos($placeholder, '*') !== false): ?>
|
||||||
<input type="password" data-parameter="<?php echo $parameter; ?>" value="<?php echo $value; ?>" placeholder="<?php echo substr($placeholder, 1); ?>" />
|
<input type="password"
|
||||||
<?php elseif(strpos($placeholder, '!') !== false): ?>
|
data-parameter="<?php echo $parameter; ?>"
|
||||||
<label><input type="checkbox" data-parameter="<?php echo $parameter; ?>" <?php if ($value == 'true') echo ' checked="checked"'; ?> /><?php echo substr($placeholder, 1); ?></label>
|
value="<?php echo $value; ?>"
|
||||||
|
placeholder="<?php echo substr($placeholder, 1); ?>" />
|
||||||
|
<?php elseif (strpos($placeholder, '!') !== false): ?>
|
||||||
|
<label><input type="checkbox"
|
||||||
|
data-parameter="<?php echo $parameter; ?>"
|
||||||
|
<?php if ($value == 'true'): ?> checked="checked"<?php endif; ?>
|
||||||
|
/><?php echo substr($placeholder, 1); ?></label>
|
||||||
<?php elseif (strpos($placeholder, '&') !== false): ?>
|
<?php elseif (strpos($placeholder, '&') !== false): ?>
|
||||||
<input type="text" class="optional" data-parameter="<?php echo $parameter; ?>" value="<?php echo $value; ?>" placeholder="<?php echo substr($placeholder, 5); ?>" />
|
<input type="text"
|
||||||
|
class="optional"
|
||||||
|
data-parameter="<?php echo $parameter; ?>"
|
||||||
|
value="<?php echo $value; ?>"
|
||||||
|
placeholder="<?php echo substr($placeholder, 5); ?>" />
|
||||||
<?php elseif (strpos($placeholder, '#') !== false): ?>
|
<?php elseif (strpos($placeholder, '#') !== false): ?>
|
||||||
<input type="hidden" data-parameter="<?php echo $parameter; ?>" value="<?php echo $value; ?>" />
|
<input type="hidden"
|
||||||
|
data-parameter="<?php echo $parameter; ?>"
|
||||||
|
value="<?php echo $value; ?>" />
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<input type="text" data-parameter="<?php echo $parameter; ?>" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" />
|
<input type="text"
|
||||||
|
data-parameter="<?php echo $parameter; ?>"
|
||||||
|
value="<?php echo $value; ?>"
|
||||||
|
placeholder="<?php echo $placeholder; ?>" />
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php if (isset($_['backends'][$mount['class']]['custom'])) OCP\Util::addScript('files_external', $_['backends'][$mount['class']]['custom']); ?>
|
<?php if (isset($_['backends'][$mount['class']]['custom'])): ?>
|
||||||
|
<?php OCP\Util::addScript('files_external',
|
||||||
|
$_['backends'][$mount['class']]['custom']); ?>
|
||||||
|
<?php endif; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</td>
|
</td>
|
||||||
<!--<td class="options">
|
|
||||||
<select class="selectOptions" title="<?php echo $l->t('None set')?>" multiple="multiple" disabled>
|
|
||||||
<?php if (OCP\App::isEnabled('files_encryption')) echo '<option value="Encrypt">Encrypt</option>'; ?>
|
|
||||||
<?php if (OCP\App::isEnabled('files_versions')) echo '<option value="Version control">Version control</option>'; ?>
|
|
||||||
<?php if (OCP\App::isEnabled('files_sharing')) echo '<option value="Allow sharing">Allow sharing</option>'; ?>
|
|
||||||
</select>
|
|
||||||
</td>-->
|
|
||||||
<?php if ($_['isAdminPage']): ?>
|
<?php if ($_['isAdminPage']): ?>
|
||||||
<td class="applicable" align="right" data-applicable-groups='<?php if (isset($mount['applicable']['groups'])) echo json_encode($mount['applicable']['groups']); ?>' data-applicable-users='<?php if (isset($mount['applicable']['users'])) echo json_encode($mount['applicable']['users']); ?>'>
|
<td class="applicable"
|
||||||
<select class="chzn-select" multiple style="width:20em;" data-placeholder="<?php echo $l->t('None set'); ?>">
|
align="right"
|
||||||
|
data-applicable-groups='<?php if (isset($mount['applicable']['groups']))
|
||||||
|
echo json_encode($mount['applicable']['groups']); ?>'
|
||||||
|
data-applicable-users='<?php if (isset($mount['applicable']['users']))
|
||||||
|
echo json_encode($mount['applicable']['users']); ?>'>
|
||||||
|
<select class="chzn-select"
|
||||||
|
multiple style="width:20em;"
|
||||||
|
data-placeholder="<?php echo $l->t('None set'); ?>">
|
||||||
<option value="all"><?php echo $l->t('All Users'); ?></option>
|
<option value="all"><?php echo $l->t('All Users'); ?></option>
|
||||||
<optgroup label="<?php echo $l->t('Groups'); ?>">
|
<optgroup label="<?php echo $l->t('Groups'); ?>">
|
||||||
<?php foreach ($_['groups'] as $group): ?>
|
<?php foreach ($_['groups'] as $group): ?>
|
||||||
<option value="<?php echo $group; ?>(group)" <?php if (isset($mount['applicable']['groups']) && in_array($group, $mount['applicable']['groups'])) echo 'selected="selected"'; ?>><?php echo $group; ?></option>
|
<option value="<?php echo $group; ?>(group)"
|
||||||
<?php endforeach; ?>
|
<?php if (isset($mount['applicable']['groups']) && in_array($group, $mount['applicable']['groups'])): ?>
|
||||||
|
selected="selected"
|
||||||
|
<?php endif; ?>><?php echo $group; ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
<optgroup label="<?php echo $l->t('Users'); ?>">
|
<optgroup label="<?php echo $l->t('Users'); ?>">
|
||||||
<?php foreach ($_['users'] as $user): ?>
|
<?php foreach ($_['users'] as $user): ?>
|
||||||
<option value="<?php echo $user; ?>" <?php if (isset($mount['applicable']['users']) && in_array($user, $mount['applicable']['users'])) echo 'selected="selected"'; ?>"><?php echo $user; ?></option>
|
<option value="<?php echo $user; ?>"
|
||||||
<?php endforeach; ?>
|
<?php if (isset($mount['applicable']['users']) && in_array($user, $mount['applicable']['users'])): ?>
|
||||||
|
selected="selected"
|
||||||
|
<?php endif; ?>><?php echo $user; ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<td <?php echo ($mountPoint != '') ? 'class="remove"' : 'style="visibility:hidden;"'; ?>><img alt="<?php echo $l->t('Delete'); ?>" title="<?php echo $l->t('Delete'); ?>" class="svg action" src="<?php echo image_path('core', 'actions/delete.svg'); ?>" /></td>
|
<td <?php if ($mountPoint != ''): ?>class="remove"
|
||||||
|
<?php else: ?>style="visibility:hidden;"
|
||||||
|
<?php endif ?>><img alt="<?php echo $l->t('Delete'); ?>"
|
||||||
|
title="<?php echo $l->t('Delete'); ?>"
|
||||||
|
class="svg action"
|
||||||
|
src="<?php echo image_path('core', 'actions/delete.svg'); ?>" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -83,16 +116,22 @@
|
||||||
|
|
||||||
<?php if ($_['isAdminPage']): ?>
|
<?php if ($_['isAdminPage']): ?>
|
||||||
<br />
|
<br />
|
||||||
<input type="checkbox" name="allowUserMounting" id="allowUserMounting" value="1" <?php if ($_['allowUserMounting'] == 'yes') echo ' checked="checked"'; ?> />
|
<input type="checkbox"
|
||||||
|
name="allowUserMounting"
|
||||||
|
id="allowUserMounting"
|
||||||
|
value="1" <?php if ($_['allowUserMounting'] == 'yes') echo ' checked="checked"'; ?> />
|
||||||
<label for="allowUserMounting"><?php echo $l->t('Enable User External Storage'); ?></label><br/>
|
<label for="allowUserMounting"><?php echo $l->t('Enable User External Storage'); ?></label><br/>
|
||||||
<em><?php echo $l->t('Allow users to mount their own external storage'); ?></em>
|
<em><?php echo $l->t('Allow users to mount their own external storage'); ?></em>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form id="files_external" method="post" enctype="multipart/form-data" action="<?php echo OCP\Util::linkTo('files_external', 'ajax/addRootCertificate.php'); ?>">
|
<form id="files_external"
|
||||||
|
method="post"
|
||||||
|
enctype="multipart/form-data"
|
||||||
|
action="<?php echo OCP\Util::linkTo('files_external', 'ajax/addRootCertificate.php'); ?>">
|
||||||
<fieldset class="personalblock">
|
<fieldset class="personalblock">
|
||||||
<?php if (!$_['isAdminPage']): ?>
|
<?php if ( ! $_['isAdminPage']): ?>
|
||||||
<table id="sslCertificate" data-admin='<?php echo json_encode($_['isAdminPage']); ?>'>
|
<table id="sslCertificate" data-admin='<?php echo json_encode($_['isAdminPage']); ?>'>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -104,13 +143,18 @@
|
||||||
<?php foreach ($_['certs'] as $rootCert): ?>
|
<?php foreach ($_['certs'] as $rootCert): ?>
|
||||||
<tr id="<?php echo $rootCert ?>">
|
<tr id="<?php echo $rootCert ?>">
|
||||||
<td class="rootCert"><?php echo $rootCert ?></td>
|
<td class="rootCert"><?php echo $rootCert ?></td>
|
||||||
<td <?php echo ($rootCert != '') ? 'class="remove"' : 'style="visibility:hidden;"'; ?>><img alt="<?php echo $l->t('Delete'); ?>" title="<?php echo $l->t('Delete'); ?>" class="svg action" src="<?php echo image_path('core', 'actions/delete.svg'); ?>" /></td>
|
<td <?php if ($rootCert != ''): ?>class="remove"
|
||||||
|
<?php else: ?>style="visibility:hidden;"
|
||||||
|
<?php endif; ?>><img alt="<?php echo $l->t('Delete'); ?>"
|
||||||
|
title="<?php echo $l->t('Delete'); ?>"
|
||||||
|
class="svg action"
|
||||||
|
src="<?php echo image_path('core', 'actions/delete.svg'); ?>" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<input type="file" id="rootcert_import" name="rootcert_import" style="width:230px;">
|
<input type="file" id="rootcert_import" name="rootcert_import" style="width:230px;">
|
||||||
<input type="submit" name="cert_import" value="<?php echo $l->t('Import Root Certificate'); ?>" />
|
<input type="submit" name="cert_import" value="<?php echo $l->t('Import Root Certificate'); ?>" />
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
|
@ -28,7 +28,7 @@ class Test_Filestorage_AmazonS3 extends Test_FileStorage {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
$id = uniqid();
|
$id = uniqid();
|
||||||
$this->config = include('files_external/tests/config.php');
|
$this->config = include('files_external/tests/config.php');
|
||||||
if (!is_array($this->config) or !isset($this->config['amazons3']) or !$this->config['amazons3']['run']) {
|
if ( ! is_array($this->config) or ! isset($this->config['amazons3']) or ! $this->config['amazons3']['run']) {
|
||||||
$this->markTestSkipped('AmazonS3 backend not configured');
|
$this->markTestSkipped('AmazonS3 backend not configured');
|
||||||
}
|
}
|
||||||
$this->config['amazons3']['bucket'] = $id; // Make sure we have a new empty bucket to work in
|
$this->config['amazons3']['bucket'] = $id; // Make sure we have a new empty bucket to work in
|
||||||
|
@ -37,7 +37,8 @@ class Test_Filestorage_AmazonS3 extends Test_FileStorage {
|
||||||
|
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
if ($this->instance) {
|
if ($this->instance) {
|
||||||
$s3 = new AmazonS3(array('key' => $this->config['amazons3']['key'], 'secret' => $this->config['amazons3']['secret']));
|
$s3 = new AmazonS3(array('key' => $this->config['amazons3']['key'],
|
||||||
|
'secret' => $this->config['amazons3']['secret']));
|
||||||
if ($s3->delete_all_objects($this->id)) {
|
if ($s3->delete_all_objects($this->id)) {
|
||||||
$s3->delete_bucket($this->id);
|
$s3->delete_bucket($this->id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Test_Filestorage_Dropbox extends Test_FileStorage {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
$id = uniqid();
|
$id = uniqid();
|
||||||
$this->config = include('files_external/tests/config.php');
|
$this->config = include('files_external/tests/config.php');
|
||||||
if (!is_array($this->config) or !isset($this->config['dropbox']) or !$this->config['dropbox']['run']) {
|
if ( ! is_array($this->config) or ! isset($this->config['dropbox']) or ! $this->config['dropbox']['run']) {
|
||||||
$this->markTestSkipped('Dropbox backend not configured');
|
$this->markTestSkipped('Dropbox backend not configured');
|
||||||
}
|
}
|
||||||
$this->config['dropbox']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
|
$this->config['dropbox']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Test_Filestorage_FTP extends Test_FileStorage {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
$id = uniqid();
|
$id = uniqid();
|
||||||
$this->config = include('files_external/tests/config.php');
|
$this->config = include('files_external/tests/config.php');
|
||||||
if (!is_array($this->config) or !isset($this->config['ftp']) or !$this->config['ftp']['run']) {
|
if ( ! is_array($this->config) or ! isset($this->config['ftp']) or ! $this->config['ftp']['run']) {
|
||||||
$this->markTestSkipped('FTP backend not configured');
|
$this->markTestSkipped('FTP backend not configured');
|
||||||
}
|
}
|
||||||
$this->config['ftp']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
|
$this->config['ftp']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
|
||||||
|
@ -26,7 +26,11 @@ class Test_Filestorage_FTP extends Test_FileStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConstructUrl(){
|
public function testConstructUrl(){
|
||||||
$config = array ( 'host' => 'localhost', 'user' => 'ftp', 'password' => 'ftp', 'root' => '/', 'secure' => false );
|
$config = array ( 'host' => 'localhost',
|
||||||
|
'user' => 'ftp',
|
||||||
|
'password' => 'ftp',
|
||||||
|
'root' => '/',
|
||||||
|
'secure' => false );
|
||||||
$instance = new OC_Filestorage_FTP($config);
|
$instance = new OC_Filestorage_FTP($config);
|
||||||
$this->assertEqual('ftp://ftp:ftp@localhost/', $instance->constructUrl(''));
|
$this->assertEqual('ftp://ftp:ftp@localhost/', $instance->constructUrl(''));
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Test_Filestorage_Google extends Test_FileStorage {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
$id = uniqid();
|
$id = uniqid();
|
||||||
$this->config = include('files_external/tests/config.php');
|
$this->config = include('files_external/tests/config.php');
|
||||||
if (!is_array($this->config) or !isset($this->config['google']) or !$this->config['google']['run']) {
|
if ( ! is_array($this->config) or ! isset($this->config['google']) or ! $this->config['google']['run']) {
|
||||||
$this->markTestSkipped('Google backend not configured');
|
$this->markTestSkipped('Google backend not configured');
|
||||||
}
|
}
|
||||||
$this->config['google']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
|
$this->config['google']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Test_Filestorage_SMB extends Test_FileStorage {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
$id = uniqid();
|
$id = uniqid();
|
||||||
$this->config = include('files_external/tests/config.php');
|
$this->config = include('files_external/tests/config.php');
|
||||||
if (!is_array($this->config) or !isset($this->config['smb']) or !$this->config['smb']['run']) {
|
if ( ! is_array($this->config) or ! isset($this->config['smb']) or ! $this->config['smb']['run']) {
|
||||||
$this->markTestSkipped('Samba backend not configured');
|
$this->markTestSkipped('Samba backend not configured');
|
||||||
}
|
}
|
||||||
$this->config['smb']['root'] .= $id; //make sure we have an new empty folder to work in
|
$this->config['smb']['root'] .= $id; //make sure we have an new empty folder to work in
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Test_Filestorage_SWIFT extends Test_FileStorage {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
$id = uniqid();
|
$id = uniqid();
|
||||||
$this->config = include('files_external/tests/config.php');
|
$this->config = include('files_external/tests/config.php');
|
||||||
if (!is_array($this->config) or !isset($this->config['swift']) or !$this->config['swift']['run']) {
|
if ( ! is_array($this->config) or ! isset($this->config['swift']) or ! $this->config['swift']['run']) {
|
||||||
$this->markTestSkipped('OpenStack SWIFT backend not configured');
|
$this->markTestSkipped('OpenStack SWIFT backend not configured');
|
||||||
}
|
}
|
||||||
$this->config['swift']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
|
$this->config['swift']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Test_Filestorage_DAV extends Test_FileStorage {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
$id = uniqid();
|
$id = uniqid();
|
||||||
$this->config = include('files_external/tests/config.php');
|
$this->config = include('files_external/tests/config.php');
|
||||||
if (!is_array($this->config) or !isset($this->config['webdav']) or !$this->config['webdav']['run']) {
|
if ( ! is_array($this->config) or ! isset($this->config['webdav']) or ! $this->config['webdav']['run']) {
|
||||||
$this->markTestSkipped('WebDAV backend not configured');
|
$this->markTestSkipped('WebDAV backend not configured');
|
||||||
}
|
}
|
||||||
$this->config['webdav']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
|
$this->config['webdav']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
|
||||||
|
|
Loading…
Reference in New Issue