diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_external/appinfo/app.php | 5 | ||||
-rwxr-xr-x | apps/files_external/lib/config.php | 12 | ||||
-rw-r--r-- | apps/files_external/lib/irods.php | 72 | ||||
-rw-r--r-- | apps/files_external/lib/streamwrapper.php | 2 | ||||
-rw-r--r-- | apps/files_external/tests/irods.php | 30 |
5 files changed, 120 insertions, 1 deletions
diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php index d786c6c7a2a..dd0b76ed9d7 100644 --- a/apps/files_external/appinfo/app.php +++ b/apps/files_external/appinfo/app.php @@ -15,9 +15,14 @@ OC::$CLASSPATH['OC\Files\Storage\SMB'] = 'files_external/lib/smb.php'; OC::$CLASSPATH['OC\Files\Storage\AmazonS3'] = 'files_external/lib/amazons3.php'; OC::$CLASSPATH['OC\Files\Storage\Dropbox'] = 'files_external/lib/dropbox.php'; OC::$CLASSPATH['OC\Files\Storage\SFTP'] = 'files_external/lib/sftp.php'; +OC::$CLASSPATH['OC\Files\Storage\iRODS'] = 'files_external/lib/irods.php'; OC::$CLASSPATH['OC_Mount_Config'] = 'files_external/lib/config.php'; OCP\App::registerAdmin('files_external', 'settings'); if (OCP\Config::getAppValue('files_external', 'allow_user_mounting', 'yes') == 'yes') { OCP\App::registerPersonal('files_external', 'personal'); } + +// connecting hooks +OCP\Util::connectHook( 'OC_User', 'post_login', 'OC\Files\Storage\iRODS', 'login' ); + diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 4cb9b7c8ecd..a35bf12167b 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -34,7 +34,7 @@ class OC_Mount_Config { * If the configuration parameter should be secret, add a '*' to the beginning of the value * If the configuration parameter is a boolean, add a '!' to the beginning of the value * If the configuration parameter is optional, add a '&' to the beginning of the value - * If the configuration parameter is hidden, add a '#' to the begining of the value + * If the configuration parameter is hidden, add a '#' to the beginning of the value * @return array */ public static function getBackends() { @@ -113,6 +113,16 @@ class OC_Mount_Config { 'password' => '*Password', 'root' => '&Root')); + $backends['\OC\Files\Storage\iRODS']=array( + 'backend' => 'iRODS', + 'configuration' => array( + 'host' => 'Host', + 'port' => 'Port', + 'use_logon_credentials' => '!Use ownCloud login', + 'user' => 'Username', + 'password' => '*Password', + 'zone' => 'Zone')); + return($backends); } diff --git a/apps/files_external/lib/irods.php b/apps/files_external/lib/irods.php new file mode 100644 index 00000000000..888cf569cb9 --- /dev/null +++ b/apps/files_external/lib/irods.php @@ -0,0 +1,72 @@ +<?php +/** + * Copyright (c) 2013 Thomas Müller <thomas.mueller@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Files\Storage; + +set_include_path(get_include_path() . PATH_SEPARATOR . + \OC_App::getAppPath('files_external') . '/3rdparty/irodsphp/prods/src'); + +require_once 'ProdsStreamer.class.php'; + +class iRODS extends \OC\Files\Storage\StreamWrapper{ + private $password; + private $user; + private $host; + private $port; + private $zone; + private $root; + private $use_logon_credentials; + + public function __construct($params) { + if (isset($params['host']) && isset($params['user']) && isset($params['password'])) { + $this->host=$params['host']; + $this->port=$params['port']; + $this->user=$params['user']; + $this->password=$params['password']; + $this->use_logon_credentials=$params['use_logon_credentials']; + $this->zone=$params['zone']; + + $this->root=isset($params['root'])?$params['root']:'/'; + if ( ! $this->root || $this->root[0]!='/') { + $this->root='/'.$this->root; + } + + if ($this->use_logon_credentials && isset($_SESSION['irods-credentials']) ) + { + $this->user = $_SESSION['irods-credentials']['uid']; + $this->password = $_SESSION['irods-credentials']['password']; + } + + //create the root folder if necessary + if ( ! $this->is_dir('')) { + $this->mkdir(''); + } + } else { + throw new \Exception(); + } + + } + + public static function login( $params ) { + $_SESSION['irods-credentials'] = $params; + } + + public function getId(){ + return 'irods::' . $this->user . '@' . $this->host . '/' . $this->root; + } + + /** + * construct the ftp url + * @param string $path + * @return string + */ + public function constructUrl($path) { + $userWithZone = $this->user.'.'.$this->zone; + return 'rods://'.$userWithZone.':'.$this->password.'@'.$this->host.':'.$this->port.$this->root.$path; + } +} diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php index 4685877f26b..df088e4ad71 100644 --- a/apps/files_external/lib/streamwrapper.php +++ b/apps/files_external/lib/streamwrapper.php @@ -82,6 +82,8 @@ abstract class StreamWrapper extends \OC\Files\Storage\Common{ $fh = $this->fopen($path, 'a'); fwrite($fh, ''); fclose($fh); + + return true; } else { return false;//not supported } diff --git a/apps/files_external/tests/irods.php b/apps/files_external/tests/irods.php new file mode 100644 index 00000000000..614e5bc7c3a --- /dev/null +++ b/apps/files_external/tests/irods.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace Test\Files\Storage; + +class iRODS extends Storage { + + private $config; + + public function setUp() { + $id = uniqid(); + $this->config = include('files_external/tests/config.php'); + if ( ! is_array($this->config) or ! isset($this->config['irods']) or ! $this->config['irods']['run']) { + $this->markTestSkipped('irods backend not configured'); + } + $this->config['irods']['root'] .= $id; //make sure we have an new empty folder to work in + $this->instance = new \OC\Files\Storage\iRODS($this->config['irods']); + } + + public function tearDown() { + if ($this->instance) { + \OCP\Files::rmdirr($this->instance->constructUrl('')); + } + } +} |