diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php
index 9c6df31d29..3befbe4cc2 100644
--- a/apps/files_sharing/sharedstorage.php
+++ b/apps/files_sharing/sharedstorage.php
@@ -322,6 +322,11 @@ class OC_Filestorage_Shared extends OC_Filestorage {
public function file_get_contents($path) {
$source = $this->getSource($path);
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);
return $storage->file_get_contents($this->getInternalPath($source));
}
@@ -331,6 +336,11 @@ class OC_Filestorage_Shared extends OC_Filestorage {
if ($this->is_writable($path)) {
$source = $this->getSource($path);
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);
$result = $storage->file_put_contents($this->getInternalPath($source), $data);
if ($result) {
@@ -418,6 +428,12 @@ class OC_Filestorage_Shared extends OC_Filestorage {
public function fopen($path, $mode) {
$source = $this->getSource($path);
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);
return $storage->fopen($this->getInternalPath($source), $mode);
}
diff --git a/apps/files_sharing_log/appinfo/app.php b/apps/files_sharing_log/appinfo/app.php
new file mode 100644
index 0000000000..23cae61fbf
--- /dev/null
+++ b/apps/files_sharing_log/appinfo/app.php
@@ -0,0 +1,22 @@
+
+ * 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');
diff --git a/apps/files_sharing_log/appinfo/database.xml b/apps/files_sharing_log/appinfo/database.xml
new file mode 100644
index 0000000000..92e5f0125b
--- /dev/null
+++ b/apps/files_sharing_log/appinfo/database.xml
@@ -0,0 +1,44 @@
+
+
+ *dbname*
+ true
+ false
+ latin1
+
+ *dbprefix*sharing_log
+
+
+ user_id
+ text
+ true
+ 64
+
+
+ source
+ text
+ true
+ 128
+
+
+ uid_who
+ text
+ true
+ 64
+
+
+ when
+ integer
+
+ false
+ true
+ 4
+
+
+ mode
+ text
+ true
+ 4
+
+
+
+
diff --git a/apps/files_sharing_log/appinfo/info.xml b/apps/files_sharing_log/appinfo/info.xml
new file mode 100644
index 0000000000..d5e3283df3
--- /dev/null
+++ b/apps/files_sharing_log/appinfo/info.xml
@@ -0,0 +1,10 @@
+
+
+ files_sharing_log
+ File Shared access logging app
+ Log access to shared files
+ AGPL
+ Bart Visscher
+ 4
+ true
+
diff --git a/apps/files_sharing_log/appinfo/version b/apps/files_sharing_log/appinfo/version
new file mode 100644
index 0000000000..49d59571fb
--- /dev/null
+++ b/apps/files_sharing_log/appinfo/version
@@ -0,0 +1 @@
+0.1
diff --git a/apps/files_sharing_log/css/style.css b/apps/files_sharing_log/css/style.css
new file mode 100644
index 0000000000..069d3a45e0
--- /dev/null
+++ b/apps/files_sharing_log/css/style.css
@@ -0,0 +1,7 @@
+#files_sharing_log {
+padding: 2em;
+}
+#files_sharing_log th,
+#files_sharing_log td {
+padding: 0 1em;
+}
diff --git a/apps/files_sharing_log/index.php b/apps/files_sharing_log/index.php
new file mode 100644
index 0000000000..ffacbdd860
--- /dev/null
+++ b/apps/files_sharing_log/index.php
@@ -0,0 +1,21 @@
+
+ * 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();
diff --git a/apps/files_sharing_log/log.php b/apps/files_sharing_log/log.php
new file mode 100644
index 0000000000..e6a12b9fb1
--- /dev/null
+++ b/apps/files_sharing_log/log.php
@@ -0,0 +1,34 @@
+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;
+ }
+}
diff --git a/apps/files_sharing_log/templates/index.php b/apps/files_sharing_log/templates/index.php
new file mode 100644
index 0000000000..55bfc1d6a3
--- /dev/null
+++ b/apps/files_sharing_log/templates/index.php
@@ -0,0 +1,42 @@
+
+
+
+ t('File') ?> |
+ t('Who') ?> |
+ t('When') ?> |
+ t('What') ?> |
+
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+ 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;
+ ?>
+ |
+
+
+
+