Merge branch 'master' into calendar_repeat

This commit is contained in:
Georg Ehrke 2012-06-20 20:14:08 +02:00
commit 0f13cbb47d
35 changed files with 468 additions and 66 deletions

View File

@ -4662,7 +4662,7 @@ function DayEventRenderer() {
"</span>"; "</span>";
} }
html += html +=
"<span class='fc-event-title'>" + htmlEscape(event.title) + "</span>" + "<span class='fc-event-title'>" + event.title + "</span>" +
"</div>"; "</div>";
if (seg.isEnd && isEventResizable(event)) { if (seg.isEnd && isEventResizable(event)) {
html += html +=

View File

@ -0,0 +1,18 @@
<?php
OC::$CLASSPATH['OC_Admin_Audit_Hooks_Handlers'] = 'apps/admin_audit/lib/hooks_handlers.php';
OCP\Util::connectHook('OCP\User', 'pre_login', 'OC_Admin_Audit_Hooks_Handlers', 'pre_login');
OCP\Util::connectHook('OCP\User', 'post_login', 'OC_Admin_Audit_Hooks_Handlers', 'post_login');
OCP\Util::connectHook('OCP\User', 'logout', 'OC_Admin_Audit_Hooks_Handlers', 'logout');
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_rename, 'OC_Admin_Audit_Hooks_Handlers', 'rename');
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_create, 'OC_Admin_Audit_Hooks_Handlers', 'create');
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_copy, 'OC_Admin_Audit_Hooks_Handlers', 'copy');
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_write, 'OC_Admin_Audit_Hooks_Handlers', 'write');
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_read, 'OC_Admin_Audit_Hooks_Handlers', 'read');
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_delete, 'OC_Admin_Audit_Hooks_Handlers', 'delete');
OCP\Util::connectHook('OC_Share', 'public', 'OC_Admin_Audit_Hooks_Handlers', 'share_public');
OCP\Util::connectHook('OC_Share', 'public-download', 'OC_Admin_Audit_Hooks_Handlers', 'share_public_download');
OCP\Util::connectHook('OC_Share', 'user', 'OC_Admin_Audit_Hooks_Handlers', 'share_user');

View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<info>
<id>admin_audit</id>
<name>Log audit info</name>
<version>0.1</version>
<licence>AGPL</licence>
<author>Bart Visscher</author>
<require>2</require>
<description>Audit user actions in Owncloud</description>
</info>

View File

@ -0,0 +1,72 @@
<?php
class OC_Admin_Audit_Hooks_Handlers {
static public function pre_login($params) {
$path = $params['uid'];
self::log('Trying login '.$user);
}
static public function post_login($params) {
$path = $params['uid'];
self::log('Login '.$user);
}
static public function logout($params) {
$user = OCP\User::getUser();
self::log('Logout '.$user);
}
static public function rename($params) {
$oldpath = $params[OC_Filesystem::signal_param_oldpath];
$newpath = $params[OC_Filesystem::signal_param_newpath];
$user = OCP\User::getUser();
self::log('Rename "'.$oldpath.'" to "'.$newpath.'" by '.$user);
}
static public function create($params) {
$path = $params[OC_Filesystem::signal_param_path];
$user = OCP\User::getUser();
self::log('Create "'.$path.'" by '.$user);
}
static public function copy($params) {
$oldpath = $params[OC_Filesystem::signal_param_oldpath];
$newpath = $params[OC_Filesystem::signal_param_newpath];
$user = OCP\User::getUser();
self::log('Copy "'.$oldpath.'" to "'.$newpath.'" by '.$user);
}
static public function write($params) {
$path = $params[OC_Filesystem::signal_param_path];
$user = OCP\User::getUser();
self::log('Write "'.$path.'" by '.$user);
}
static public function read($params) {
$path = $params[OC_Filesystem::signal_param_path];
$user = OCP\User::getUser();
self::log('Read "'.$path.'" by '.$user);
}
static public function delete($params) {
$path = $params[OC_Filesystem::signal_param_path];
$user = OCP\User::getUser();
self::log('Delete "'.$path.'" by '.$user);
}
static public function share_public($params) {
$path = $params['source'];
$token = $params['token'];
$user = OCP\User::getUser();
self::log('Shared "'.$path.'" with public, token="'.$token.'" by '.$user);
}
static public function share_public_download($params) {
$path = $params['source'];
$token = $params['token'];
$user = $_SERVER['REMOTE_ADDR'];
self::log('Download of shared "'.$path.'" token="'.$token.'" by '.$user);
}
static public function share_user($params) {
$path = $params['source'];
$permissions = $params['permissions'];
$with = $params['with'];
$user = OCP\User::getUser();
$rw = $permissions & OC_Share::WRITE ? 'w' : 'o';
self::log('Shared "'.$path.'" (r'.$rw.') with user "'.$with.'" by '.$user);
}
static protected function log($msg) {
OCP\Util::writeLog('admin_audit', $msg, OCP\Util::INFO);
}
}

View File

@ -5,20 +5,20 @@
* *
* @author Arthur Schiwon * @author Arthur Schiwon
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de * @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 3 of the License, or any later version. * version 3 of the License, or any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
@ -28,6 +28,6 @@ OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('bookmarks'); OCP\App::checkAppEnabled('bookmarks');
require_once('bookmarksHelper.php'); require_once('bookmarksHelper.php');
addBookmark($_POST['url'], '', 'Read-Later'); addBookmark($_GET['url'], '', 'Read-Later');
include 'templates/addBm.php'; include 'templates/addBm.php';

View File

@ -1,5 +1,5 @@
#content { overflow: auto; height: 100%; } #content { overflow: auto; height: 100%; }
#firstrun { width: 80%; margin: 5em auto auto auto; text-align: center; font-weight:bold; font-size:1.5em; color:#777;} #firstrun { width: 80%; margin: 5em auto auto auto; text-align: center; font-weight:bold; font-size:1.5em; color:#777; position: relative;}
#firstrun small { display: block; font-weight: normal; font-size: 0.5em; margin-bottom: 1.5em; } #firstrun small { display: block; font-weight: normal; font-size: 0.5em; margin-bottom: 1.5em; }
#firstrun .button { font-size: 0.7em; } #firstrun .button { font-size: 0.7em; }
#firstrun #selections { font-size:0.8em; font-weight: normal; width: 100%; margin: 2em auto auto auto; clear: both; } #firstrun #selections { font-size:0.8em; font-weight: normal; width: 100%; margin: 2em auto auto auto; clear: both; }

View File

@ -27,4 +27,4 @@ $output = array();
foreach($events as $event){ foreach($events as $event){
$output = array_merge($output, OC_Calendar_App::generateEventOutput($event, $start, $end)); $output = array_merge($output, OC_Calendar_App::generateEventOutput($event, $start, $end));
} }
OCP\JSON::encodedPrint($output); OCP\JSON::encodedPrint(OCP\Util::sanitizeHTML($output));

View File

@ -869,7 +869,7 @@ $(document).ready(function(){
eventDrop: Calendar.UI.moveEvent, eventDrop: Calendar.UI.moveEvent,
eventResize: Calendar.UI.resizeEvent, eventResize: Calendar.UI.resizeEvent,
eventRender: function(event, element) { eventRender: function(event, element) {
element.find('.fc-event-title').html(element.find('.fc-event-title').text()); element.find('.fc-event-title').html(element.find('.fc-event-title').html());
element.tipsy({ element.tipsy({
className: 'tipsy-event', className: 'tipsy-event',
opacity: 0.9, opacity: 0.9,

View File

@ -605,8 +605,8 @@ class OC_Calendar_Object{
public static function updateVCalendarFromRequest($request, $vcalendar) public static function updateVCalendarFromRequest($request, $vcalendar)
{ {
$title = strip_tags($request["title"]); $title = $request["title"];
$location = strip_tags($request["location"]); $location = $request["location"];
$categories = $request["categories"]; $categories = $request["categories"];
$allday = isset($request["allday"]); $allday = isset($request["allday"]);
$from = $request["from"]; $from = $request["from"];
@ -616,7 +616,7 @@ class OC_Calendar_Object{
$totime = $request['totime']; $totime = $request['totime'];
} }
$vevent = $vcalendar->VEVENT; $vevent = $vcalendar->VEVENT;
$description = strip_tags($request["description"]); $description = $request["description"];
$repeat = $request["repeat"]; $repeat = $request["repeat"];
if($repeat != 'doesnotrepeat'){ if($repeat != 'doesnotrepeat'){
$rrule = ''; $rrule = '';

View File

@ -49,7 +49,6 @@ class OC_Filestorage_Archive extends OC_Filestorage_Common{
OC_FakeDirStream::$dirs[$id]=$content; OC_FakeDirStream::$dirs[$id]=$content;
return opendir('fakedir://'.$id); return opendir('fakedir://'.$id);
} }
public function readdir($path){}
public function stat($path){ public function stat($path){
$ctime=filectime($this->path); $ctime=filectime($this->path);
$path=$this->stripPath($path); $path=$this->stripPath($path);

View File

@ -1,15 +1,20 @@
<?php <?php
require_once('apps/files_sharing/sharedstorage.php');
OC::$CLASSPATH['OC_Share'] = "apps/files_sharing/lib_share.php"; OC::$CLASSPATH['OC_Share'] = "apps/files_sharing/lib_share.php";
OC::$CLASSPATH['OC_Filestorage_Shared'] = "apps/files_sharing/sharedstorage.php";
OCP\App::registerAdmin('files_sharing', 'settings'); OCP\App::registerAdmin('files_sharing', 'settings');
OCP\Util::connectHook('OC_Filesystem', 'setup', 'OC_Filestorage_Shared', 'setup');
OCP\Util::connectHook("OC_Filesystem", "post_delete", "OC_Share", "deleteItem"); OCP\Util::connectHook("OC_Filesystem", "post_delete", "OC_Share", "deleteItem");
OCP\Util::connectHook("OC_Filesystem", "post_rename", "OC_Share", "renameItem"); OCP\Util::connectHook("OC_Filesystem", "post_rename", "OC_Share", "renameItem");
OCP\Util::connectHook("OC_Filesystem", "post_write", "OC_Share", "updateItem"); OCP\Util::connectHook("OC_Filesystem", "post_write", "OC_Share", "updateItem");
OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Share', 'removeUser'); OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Share', 'removeUser');
OCP\Util::connectHook('OC_User', 'post_addToGroup', 'OC_Share', 'addToGroupShare'); OCP\Util::connectHook('OC_User', 'post_addToGroup', 'OC_Share', 'addToGroupShare');
OCP\Util::connectHook('OC_User', 'post_removeFromGroup', 'OC_Share', 'removeFromGroupShare'); OCP\Util::connectHook('OC_User', 'post_removeFromGroup', 'OC_Share', 'removeFromGroupShare');
$dir = isset($_GET['dir']) ? $_GET['dir'] : '/'; $dir = isset($_GET['dir']) ? $_GET['dir'] : '/';
if ($dir != '/Shared' || OCP\Config::getAppValue('files_sharing', 'resharing', 'yes') == 'yes') { if ($dir != '/Shared' || OCP\Config::getAppValue('files_sharing', 'resharing', 'yes') == 'yes') {
OCP\Util::addscript("files_sharing", "share"); OCP\Util::addscript("files_sharing", "share");

View File

@ -77,6 +77,7 @@ if (isset($_GET['token']) && $source = OC_Share::getSource($_GET['token'])) {
header("Content-Length: " . OC_Filesystem::filesize($source)); header("Content-Length: " . OC_Filesystem::filesize($source));
//download the file //download the file
@ob_clean(); @ob_clean();
OCP\Util::emitHook('OC_Share', 'public-download', array('source'=>$source, 'token'=>$token);
OC_Filesystem::readfile($source); OC_Filesystem::readfile($source);
} }
} else { } else {

View File

@ -47,6 +47,7 @@ class OC_Share {
} }
if ($uid_shared_with == self::PUBLICLINK) { if ($uid_shared_with == self::PUBLICLINK) {
$token = sha1("$uid_shared_with-$source"); $token = sha1("$uid_shared_with-$source");
OCP\Util::emitHook('OC_Share', 'public', array('source'=>$source, 'token'=>$token, 'permissions'=>$permissions));
$query->execute(array($uid_owner, self::PUBLICLINK, $source, $token, $permissions)); $query->execute(array($uid_owner, self::PUBLICLINK, $source, $token, $permissions));
$this->token = $token; $this->token = $token;
} else { } else {
@ -118,6 +119,7 @@ class OC_Share {
if (isset($gid)) { if (isset($gid)) {
$uid = $uid."@".$gid; $uid = $uid."@".$gid;
} }
OCP\Util::emitHook('OC_Share', 'user', array('source'=>$source, 'target'=>$target, 'with'=>$uid, 'permissions'=>$permissions));
$query->execute(array($uid_owner, $uid, $source, $target, $permissions)); $query->execute(array($uid_owner, $uid, $source, $target, $permissions));
} }
} }

View File

@ -139,8 +139,6 @@ class OC_Filestorage_Shared extends OC_Filestorage {
} }
} }
public function readdir( $path ) {}
public function is_dir($path) { public function is_dir($path) {
if ($path == "" || $path == "/") { if ($path == "" || $path == "/") {
return true; return true;
@ -322,6 +320,11 @@ class OC_Filestorage_Shared extends OC_Filestorage {
public function file_get_contents($path) { public function file_get_contents($path) {
$source = $this->getSource($path); $source = $this->getSource($path);
if ($source) { if ($source) {
$info = array(
'target' => $this->datadir.$path,
'source' => $source,
);
OCP\Util::emitHook('OC_Filestorage_Shared', 'file_get_contents', $info);
$storage = OC_Filesystem::getStorage($source); $storage = OC_Filesystem::getStorage($source);
return $storage->file_get_contents($this->getInternalPath($source)); return $storage->file_get_contents($this->getInternalPath($source));
} }
@ -331,6 +334,11 @@ class OC_Filestorage_Shared extends OC_Filestorage {
if ($this->is_writable($path)) { if ($this->is_writable($path)) {
$source = $this->getSource($path); $source = $this->getSource($path);
if ($source) { if ($source) {
$info = array(
'target' => $this->datadir.$path,
'source' => $source,
);
OCP\Util::emitHook('OC_Filestorage_Shared', 'file_put_contents', $info);
$storage = OC_Filesystem::getStorage($source); $storage = OC_Filesystem::getStorage($source);
$result = $storage->file_put_contents($this->getInternalPath($source), $data); $result = $storage->file_put_contents($this->getInternalPath($source), $data);
if ($result) { if ($result) {
@ -418,6 +426,12 @@ class OC_Filestorage_Shared extends OC_Filestorage {
public function fopen($path, $mode) { public function fopen($path, $mode) {
$source = $this->getSource($path); $source = $this->getSource($path);
if ($source) { if ($source) {
$info = array(
'target' => $this->datadir.$path,
'source' => $source,
'mode' => $mode,
);
OCP\Util::emitHook('OC_Filestorage_Shared', 'fopen', $info);
$storage = OC_Filesystem::getStorage($source); $storage = OC_Filesystem::getStorage($source);
return $storage->fopen($this->getInternalPath($source), $mode); return $storage->fopen($this->getInternalPath($source), $mode);
} }
@ -510,8 +524,9 @@ class OC_Filestorage_Shared extends OC_Filestorage {
} }
} }
public static function setup() { public static function setup($options) {
OC_Filesystem::mount('OC_Filestorage_Shared', array('datadir' => '/'.OCP\USER::getUser().'/files/Shared'), '/'.OCP\USER::getUser().'/files/Shared/'); $user_dir = $options['user_dir'];
OC_Filesystem::mount('OC_Filestorage_Shared', array('datadir' => $user_dir.'/Shared'), $user_dir.'/Shared/');
} }
/** /**
@ -524,11 +539,3 @@ class OC_Filestorage_Shared extends OC_Filestorage {
return $this->filemtime($path)>$time; return $this->filemtime($path)>$time;
} }
} }
if (OCP\USER::isLoggedIn()) {
OC_Filestorage_Shared::setup();
} else {
OCP\Util::connectHook('OC_User', 'post_login', 'OC_Filestorage_Shared', 'setup');
}
?>

View File

@ -0,0 +1,22 @@
<?php
/**
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
OC::$CLASSPATH['OC_Files_Sharing_Log'] = 'apps/files_sharing_log/log.php';
$l=new OC_L10N('files_sharing_log');
OCP\App::addNavigationEntry( array(
'id' => 'files_sharing_log_index',
'order' => 5,
'href' => OCP\Util::linkTo( 'files_sharing_log', 'index.php' ),
'icon' => OCP\Util::imagePath( 'files_sharing_log', 'icon.png' ),
'name' => $l->t('Shared files log'))
);
OCP\Util::connectHook('OC_Filestorage_Shared', 'fopen', 'OC_Files_Sharing_Log', 'fopen');
OCP\Util::connectHook('OC_Filestorage_Shared', 'file_get_contents', 'OC_Files_Sharing_Log', 'file_get_contents');
OCP\Util::connectHook('OC_Filestorage_Shared', 'file_put_contents', 'OC_Files_Sharing_Log', 'file_put_contents');

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<database>
<name>*dbname*</name>
<create>true</create>
<overwrite>false</overwrite>
<charset>latin1</charset>
<table>
<name>*dbprefix*sharing_log</name>
<declaration>
<field>
<name>user_id</name>
<type>text</type>
<notnull>true</notnull>
<length>64</length>
</field>
<field>
<name>source</name>
<type>text</type>
<notnull>true</notnull>
<length>128</length>
</field>
<field>
<name>uid_who</name>
<type>text</type>
<notnull>true</notnull>
<length>64</length>
</field>
<field>
<name>when</name>
<type>integer</type>
<default></default>
<notnull>false</notnull>
<unsigned>true</unsigned>
<length>4</length>
</field>
<field>
<name>mode</name>
<type>text</type>
<notnull>true</notnull>
<length>4</length>
</field>
</declaration>
</table>
</database>

View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<info>
<id>files_sharing_log</id>
<name>File Shared access logging app</name>
<description>Log access to shared files</description>
<licence>AGPL</licence>
<author>Bart Visscher</author>
<require>4</require>
<shipped>true</shipped>
</info>

View File

@ -0,0 +1 @@
0.1

View File

@ -0,0 +1,7 @@
#files_sharing_log {
padding: 2em;
}
#files_sharing_log th,
#files_sharing_log td {
padding: 0 1em;
}

View File

@ -0,0 +1,21 @@
<?php
/**
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('files_sharing_log');
OCP\App::setActiveNavigationEntry('files_sharing_log_index');
OCP\Util::addStyle('files_sharing_log', 'style');
$query = OCP\DB::prepare('SELECT * FROM *PREFIX*sharing_log WHERE user_id = ?');
$log = $query->execute(array(OCP\User::getUser()))->fetchAll();
$output = new OCP\Template('files_sharing_log', 'index', 'user');
$output->assign('log', $log);
$output->printPage();

View File

@ -0,0 +1,34 @@
<?php
class OC_Files_Sharing_Log {
static public function fopen($arguments) {
$target = $arguments['target'];
$source = $arguments['source'];
$mode = $arguments['mode'];
self::log($target, $source, $mode);
}
static public function file_get_contents($arguments) {
$target = $arguments['target'];
$source = $arguments['source'];
$mode = 'get';
self::log($target, $source, $mode);
}
static public function file_put_contents($arguments) {
$target = $arguments['target'];
$source = $arguments['source'];
$mode = 'put';
self::log($target, $source, $mode);
}
static public function log($target, $source, $mode) {
$query = OCP\DB::prepare("SELECT * FROM *PREFIX*sharing WHERE source = ? AND target = ?");
$info = $query->execute(array($source, $target))->fetchAll();
$info = $info[0];
//var_dump($info);
$query = OCP\DB::prepare("INSERT INTO *PREFIX*sharing_log VALUES (?,?,?,?,?)");
$query->execute(array($info['uid_owner'], $source, OCP\User::getUser(), time(), $mode));
//die;
}
}

View File

@ -0,0 +1,42 @@
<table id="files_sharing_log">
<thead>
<tr>
<th><?php echo $l->t('File') ?></th>
<th><?php echo $l->t('Who') ?></th>
<th><?php echo $l->t('When') ?></th>
<th><?php echo $l->t('What') ?></th>
</tr>
</thead>
<tbody>
<?php foreach($_['log'] as $log): ?>
<tr>
<td>
<?php echo $log['source'] ?>
</td>
<td>
<?php echo $log['uid_who'] ?>
</td>
<td>
<?php echo date('Y-m-d H:i:s', $log['when']) ?>
</td>
<td>
<?php switch ($log['mode']):
case 'get':
echo $l->t('Read');
break;
case 'put':
echo $l->t('Write');
break;
default:
if (strpos('r', $log['mode']) !== false):
echo $l->t('Read');
else:
echo $l->t('Write');
endif;
endswitch;
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

View File

@ -0,0 +1,41 @@
<?php
/**
* ownCloud - user_migrate
*
* @author Sam Tuke
* @copyright 2012 Sam Tuke samtuke@owncloud.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
// TODO: Allow admins to expire versions of any user
// TODO: Provide feedback as to how many versions were deleted
// Check user and app status
OCP\JSON::checkLoggedIn();
OCP\App::checkAppEnabled('files_versions');
if( OCA_Versions\Storage::expireAll() ){
OCP\JSON::success();
die();
} else {
OCP\JSON::error();
die();
}

View File

@ -3,7 +3,9 @@
require_once('apps/files_versions/versions.php'); require_once('apps/files_versions/versions.php');
OCP\App::registerAdmin('files_versions', 'settings'); OCP\App::registerAdmin('files_versions', 'settings');
OCP\App::registerPersonal('files_versions','settings-personal');
OCP\Util::addscript('files_versions', 'versions'); OCP\Util::addscript('files_versions', 'versions');
// Listen to write signals // Listen to write signals
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, "OCA_Versions\Storage", "write_hook"); OCP\Util::connectHook('OC_Filesystem', 'post_write', "OCA_Versions\Storage", "write_hook");

View File

@ -0,0 +1,51 @@
// $(document).ready(function(){
// $('#versions').change( function(){
// OC.msg.startSaving('#calendar .msg')
// // Serialize the data
// var post = $( '#timezone' ).serialize();
// $.post( OC.filePath('calendar', 'ajax/settings', 'settimezone.php'), post, function(data){
// //OC.msg.finishedSaving('#calendar .msg', data);
// });
// return false;
// });
// });
$(document).ready(function(){
//
$('#expireAllBtn').click(function(){
// Prevent page from reloading
event.preventDefault();
// Show loading gif
$('.expireAllLoading').show();
$.getJSON(
OC.filePath('files_versions','ajax','expireAll.php'),
function(result){
if (result.status == 'success') {
$('.expireAllLoading').hide();
$('#expireAllBtn').html('Expiration successful');
} else {
// Cancel loading
$('#expireAllBtn').html('Expiration failed');
// Show Dialog
OC.dialogs.alert(
'Something went wrong, your files may not have been expired',
'An error has occurred',
function(){
$('#expireAllBtn').html(t('files_versions', 'Expire all versions')+'<img style="display: none;" class="loading" src="'+OC.filePath('core','img','loading.gif')+'" />');
}
);
}
}
);
});
});

View File

@ -0,0 +1,8 @@
<?php
$tmpl = new OCP\Template( 'files_versions', 'settings-personal');
OCP\Util::addscript('files_versions','settings-personal');
return $tmpl->fetchPage();
?>

View File

@ -0,0 +1,9 @@
<form id="versions">
<fieldset class="personalblock">
<legend>
<strong>Versions</strong><!-- translate using echo $l->t('foo'); -->
</legend>
<p>This will delete all existing backup versions of your files</p><!-- translate using echo $l->t('foo'); -->
<button id="expireAllBtn">Expire all versions<img style="display: none;" class="expireAllLoading" src="<?php echo OCP\Util::linkTo('core', 'img/loading.gif'); ?>" /></button>
</fieldset>
</form>

View File

@ -333,9 +333,9 @@ class Storage {
$foldername = \OCP\Config::getSystemValue('datadirectory') .'/' . \OCP\USER::getUser() .'/' . $directory; // have to set an absolute path for use with PHP's opendir as OC version doesn't work $foldername = \OCP\Config::getSystemValue('datadirectory') .'/' . \OCP\USER::getUser() .'/' . $directory; // have to set an absolute path for use with PHP's opendir as OC version doesn't work
$directoryHandle = opendir( $foldername ); $directoryHandle = $view->opendir( \OCP\USER::getUser() . '/' . $directory );
while ( $contents = $view->readdir( $directoryHandle ) ) { while ( $contents = readdir( $directoryHandle ) ) {
if ( $contents != '.' && $contents != '..') { if ( $contents != '.' && $contents != '..') {
@ -373,17 +373,15 @@ class Storage {
$dir = \OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); $dir = \OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER);
deleteAll( $dir, true ); if ( deleteAll( $dir, true ) ) {
// if ( deleteAll( $dir, 1 ) ) { return true;
//
// echo "<h1>deleted ok</h1>"; } else {
//
// } else { return false;
//
// echo "<h1>not deleted</h1>"; }
//
// }
} }

View File

@ -21,7 +21,7 @@
* *
*/ */
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_delete, "OC_Gallery_Hooks_Handlers", "removePhoto"); OCP\Util::connectHook('OC_Filesystem', 'delete', "OC_Gallery_Hooks_Handlers", "removePhoto");
//OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_rename, "OC_Gallery_Hooks_Handlers", "renamePhoto"); //OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_rename, "OC_Gallery_Hooks_Handlers", "renamePhoto");
require_once(OC::$CLASSPATH['Pictures_Managers']); require_once(OC::$CLASSPATH['Pictures_Managers']);

View File

@ -353,12 +353,6 @@ class OC{
OC_User::useBackend( OC_Config::getValue( "userbackend", "database" )); OC_User::useBackend( OC_Config::getValue( "userbackend", "database" ));
OC_Group::useBackend(new OC_Group_Database()); OC_Group::useBackend(new OC_Group_Database());
// Set up file system unless forbidden
global $RUNTIME_NOSETUPFS;
if(!$RUNTIME_NOSETUPFS ){
OC_Util::setupFS();
}
// Load Apps // Load Apps
// This includes plugins for users and filesystems as well // This includes plugins for users and filesystems as well
global $RUNTIME_NOAPPS; global $RUNTIME_NOAPPS;

View File

@ -28,7 +28,6 @@ abstract class OC_Filestorage{
abstract public function mkdir($path); abstract public function mkdir($path);
abstract public function rmdir($path); abstract public function rmdir($path);
abstract public function opendir($path); abstract public function opendir($path);
abstract public function readdir($path);
abstract public function is_dir($path); abstract public function is_dir($path);
abstract public function is_file($path); abstract public function is_file($path);
abstract public function stat($path); abstract public function stat($path);

View File

@ -20,9 +20,6 @@ class OC_Filestorage_Local extends OC_Filestorage{
public function opendir($path){ public function opendir($path){
return opendir($this->datadir.$path); return opendir($this->datadir.$path);
} }
public function readdir($handle){
return readdir($handle);
}
public function is_dir($path){ public function is_dir($path){
if(substr($path,-1)=='/'){ if(substr($path,-1)=='/'){
$path=substr($path,0,-1); $path=substr($path,0,-1);

View File

@ -25,7 +25,7 @@
/** /**
* Class for abstraction of filesystem functions * Class for abstraction of filesystem functions
* This class won't call any filesystem functions for itself but but will pass them to the correct OC_Filestorage object * This class won't call any filesystem functions for itself but but will pass them to the correct OC_Filestorage object
* this class should also handle all the file premission related stuff * this class should also handle all the file permission related stuff
* *
* Hooks provided: * Hooks provided:
* read(path) * read(path)
@ -488,4 +488,5 @@ class OC_Filesystem{
} }
} }
OC_Util::setupFS();
require_once('filecache.php'); require_once('filecache.php');

View File

@ -274,7 +274,7 @@ class Util {
* @return array with sanitized strings or a single sinitized string, depends on the input parameter. * @return array with sanitized strings or a single sinitized string, depends on the input parameter.
*/ */
public static function sanitizeHTML( $value ){ public static function sanitizeHTML( $value ){
return(\OC_Util::sanitizeHTML($value)); //Specify encoding for PHP<5.4 return(\OC_Util::sanitizeHTML($value));
} }
} }

View File

@ -14,30 +14,32 @@ class OC_Util {
public static $core_scripts=array(); public static $core_scripts=array();
// Can be set up // Can be set up
public static function setupFS( $user = "", $root = "files" ){// configure the initial filesystem based on the configuration public static function setupFS( $user = '' ){// configure the initial filesystem based on the configuration
if(self::$fsSetup){//setting up the filesystem twice can only lead to trouble if(self::$fsSetup){//setting up the filesystem twice can only lead to trouble
return false; return false;
} }
// If we are not forced to load a specific user we load the one that is logged in
if( $user == "" && OC_User::isLoggedIn()){
$user = OC_User::getUser();
}
$CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ); $CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
//first set up the local "root" storage //first set up the local "root" storage
if(!self::$rootMounted){ if(!self::$rootMounted){
OC_Filesystem::mount('OC_Filestorage_Local',array('datadir'=>$CONFIG_DATADIRECTORY),'/'); OC_Filesystem::mount('OC_Filestorage_Local',array('datadir'=>$CONFIG_DATADIRECTORY),'/');
self::$rootMounted=true; self::$rootMounted=true;
} }
// If we are not forced to load a specific user we load the one that is logged in
if( $user == "" && OC_User::isLoggedIn()){
$user = OC_User::getUser();
}
if( $user != "" ){ //if we aren't logged in, there is no use to set up the filesystem if( $user != "" ){ //if we aren't logged in, there is no use to set up the filesystem
$userdirectory = $CONFIG_DATADIRECTORY."/$user/$root"; $user_dir = '/'.$user.'/files';
$userdirectory = $CONFIG_DATADIRECTORY.$user_dir;
if( !is_dir( $userdirectory )){ if( !is_dir( $userdirectory )){
mkdir( $userdirectory, 0755, true ); mkdir( $userdirectory, 0755, true );
} }
//jail the user into his "home" directory //jail the user into his "home" directory
OC_Filesystem::init('/'.$user.'/'.$root); OC_Filesystem::init($user_dir);
$quotaProxy=new OC_FileProxy_Quota(); $quotaProxy=new OC_FileProxy_Quota();
OC_FileProxy::register($quotaProxy); OC_FileProxy::register($quotaProxy);
self::$fsSetup=true; self::$fsSetup=true;
@ -50,6 +52,7 @@ class OC_Util {
} }
} }
} }
OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $user_dir));
} }
} }
@ -321,7 +324,11 @@ class OC_Util {
OC_Log::write('core','redirectToDefaultPage',OC_Log::DEBUG); OC_Log::write('core','redirectToDefaultPage',OC_Log::DEBUG);
if(isset($_REQUEST['redirect_url']) && (substr($_REQUEST['redirect_url'], 0, strlen(OC::$WEBROOT)) == OC::$WEBROOT || $_REQUEST['redirect_url'][0] == '/')) { if(isset($_REQUEST['redirect_url']) && (substr($_REQUEST['redirect_url'], 0, strlen(OC::$WEBROOT)) == OC::$WEBROOT || $_REQUEST['redirect_url'][0] == '/')) {
header( 'Location: '.$_REQUEST['redirect_url']); header( 'Location: '.$_REQUEST['redirect_url']);
} else { }
else if (isset(OC::$REQUESTEDAPP) && !empty(OC::$REQUESTEDAPP)) {
header( 'Location: '.OC::$WEBROOT.'/?app='.OC::$REQUESTEDAPP );
}
else {
header( 'Location: '.OC::$WEBROOT.'/'.OC_Appconfig::getValue('core', 'defaultpage', '?app=files')); header( 'Location: '.OC::$WEBROOT.'/'.OC_Appconfig::getValue('core', 'defaultpage', '?app=files'));
} }
exit(); exit();