First implementation of sharing user interface
This commit is contained in:
parent
61837428ba
commit
029b21bf54
|
@ -32,7 +32,7 @@ if (!OC_USER::isLoggedIn()){
|
||||||
OC_APP::setActiveNavigationEntry( "files_sharing_administration" );
|
OC_APP::setActiveNavigationEntry( "files_sharing_administration" );
|
||||||
|
|
||||||
$tmpl = new OC_TEMPLATE( "files_sharing", "admin", "admin" );
|
$tmpl = new OC_TEMPLATE( "files_sharing", "admin", "admin" );
|
||||||
$tmpl->assign( 'shared_items', OC_SHARE::getSharedItems());
|
$tmpl->assign( 'shared_items', OC_SHARE::getMySharedItems());
|
||||||
$tmpl->printPage();
|
$tmpl->printPage();
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
$RUNTIME_NOAPPS = true;
|
||||||
|
|
||||||
|
require_once('../../../lib/base.php');
|
||||||
|
require_once('../lib_share.php');
|
||||||
|
|
||||||
|
$source = $_GET['source'];
|
||||||
|
$uid_shared_with = array($_GET['uid_shared_with']);
|
||||||
|
$permissions = $_GET['permissions'];
|
||||||
|
new OC_SHARE($source, $uid_shared_with, $permissions);
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
$RUNTIME_NOAPPS = true;
|
||||||
|
|
||||||
|
require_once('../../../lib/base.php');
|
||||||
|
require_once('../lib_share.php');
|
||||||
|
|
||||||
|
$source = $_GET['source'];
|
||||||
|
$uid_shared_with = array($_GET['uid_shared_with']);
|
||||||
|
error_log("deleteitem called".$source.$uid_shared_with);
|
||||||
|
OC_SHARE::unshare($source, $uid_shared_with);
|
||||||
|
|
||||||
|
?>
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
require_once('apps/files_sharing/lib_share.php');
|
require_once('apps/files_sharing/lib_share.php');
|
||||||
|
|
||||||
OC_APP::addSettingsPage( array( "id" => "files_sharing_administration",
|
OC_APP::addNavigationEntry( array( "id" => "files_sharing_list",
|
||||||
"order" => 10,
|
"order" => 10,
|
||||||
"href" => OC_HELPER::linkTo( "files_sharing", "admin.php" ),
|
"href" => OC_HELPER::linkTo( "files_sharing", "list.php" ),
|
||||||
"name" => "Share",
|
"name" => "Share",
|
||||||
"icon" => OC_HELPER::imagePath( "files_sharing", "share.png" )));
|
"icon" => OC_HELPER::imagePath( "files_sharing", "share.png" )));
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
$(document).ready(function() {
|
||||||
|
$( "#source" ).autocomplete({
|
||||||
|
source: "../../files/ajax/autocomplete.php",
|
||||||
|
minLength: 1
|
||||||
|
});
|
||||||
|
$("button.delete").live('click', function( event ) {
|
||||||
|
event.preventDefault();
|
||||||
|
// var row=$(this);
|
||||||
|
var source=$(this).attr('data-source');
|
||||||
|
var uid_shared_with=$(this).attr('data-uid_shared_with');
|
||||||
|
var data='source='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with);
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: 'ajax/unshare.php',
|
||||||
|
cache: false,
|
||||||
|
data: data
|
||||||
|
// success: function(){
|
||||||
|
// row.remove();
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('#share_item').submit(function( event ){
|
||||||
|
event.preventDefault();
|
||||||
|
var source=$('#source').val();
|
||||||
|
var uid_shared_with=$('#uid_shared_with').val();
|
||||||
|
var permissions=$('#permissions').val()||0;
|
||||||
|
var data='source='+source+'&uid_shared_with='+uid_shared_with+'&permissions='+permissions;
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: 'ajax/share.php',
|
||||||
|
cache: false,
|
||||||
|
data: data,
|
||||||
|
// success: function(token){
|
||||||
|
// if(token){
|
||||||
|
// var html="<tr class='link' id='"+token+"'>";
|
||||||
|
// html+="<td class='path'>"+path+"</td>";
|
||||||
|
// var expire=($('#expire').val())?$('#expire').val():'Never'
|
||||||
|
// html+="<td class='expire'>"+expire+"</td>"
|
||||||
|
// html+="<td class='link'><a href='get.php?token="+token+"'>"+$('#baseUrl').val()+"?token="+token+"</a></td>"
|
||||||
|
// html+="<td><button class='delete fancybutton' data-token='"+token+"'>Delete</button></td>"
|
||||||
|
// html+="</tr>"
|
||||||
|
// $(html).insertBefore($('#newlink_row'));
|
||||||
|
// $('#expire').val('');
|
||||||
|
// $('#expire_time').val('');
|
||||||
|
// $('#path').val('');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -36,6 +36,7 @@ class OC_SHARE {
|
||||||
*/
|
*/
|
||||||
public function __construct($source, $uid_shared_with, $permissions, $public = false) {
|
public function __construct($source, $uid_shared_with, $permissions, $public = false) {
|
||||||
if ($source && OC_FILESYSTEM::file_exists($source) && OC_FILESYSTEM::is_readable($source)) {
|
if ($source && OC_FILESYSTEM::file_exists($source) && OC_FILESYSTEM::is_readable($source)) {
|
||||||
|
$source = "/".$_SESSION['user_id']."/files".$source;
|
||||||
$uid_owner = $_SESSION['user_id'];
|
$uid_owner = $_SESSION['user_id'];
|
||||||
if ($public) {
|
if ($public) {
|
||||||
// TODO create token for public file
|
// TODO create token for public file
|
||||||
|
@ -43,18 +44,19 @@ class OC_SHARE {
|
||||||
} else {
|
} else {
|
||||||
$query = OC_DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)");
|
$query = OC_DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)");
|
||||||
foreach ($uid_shared_with as $uid) {
|
foreach ($uid_shared_with as $uid) {
|
||||||
$target = "/".$uid."/files/Share".$source;
|
$target = "/".$uid."/files/Share/".basename($source);
|
||||||
$check = OC_DB::prepare("SELECT COUNT(target) FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with = ?");
|
// TODO Fix check if target already exists
|
||||||
$result = $check->execute(array($target, $uid))->fetchAll();
|
// $check = OC_DB::prepare("SELECT target FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with = ?");
|
||||||
$counter = 1;
|
// $result = $check->execute(array($target, $uid))->fetchAll();
|
||||||
while (count($result > 0)) {
|
// $counter = 1;
|
||||||
if ($pos = strrpos($target, ".")) {
|
// while (count($result > 0)) {
|
||||||
$target = substr($target, 0, $pos)."_".$counter.substr($target, $pos);
|
// if ($pos = strrpos($target, ".")) {
|
||||||
} else {
|
// $target = substr($target, 0, $pos)."_".$counter.substr($target, $pos);
|
||||||
$target .= $counter;
|
// } else {
|
||||||
}
|
// $target .= $counter;
|
||||||
$result = $check->execute(array($target, $uid))->fetchAll();
|
// }
|
||||||
}
|
// $result = $check->execute(array($target, $uid))->fetchAll();
|
||||||
|
// }
|
||||||
$query->execute(array($uid_owner, $uid, $source, $target, $permissions));
|
$query->execute(array($uid_owner, $uid, $source, $target, $permissions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ownCloud
|
||||||
|
*
|
||||||
|
* @author Michael Gapczynski
|
||||||
|
* @copyright 2011 Michael Gapczynski GapczynskiM@gmail.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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once('../../lib/base.php');
|
||||||
|
require_once('lib_share.php');
|
||||||
|
require('template.php');
|
||||||
|
|
||||||
|
if (!OC_USER::isLoggedIn()){
|
||||||
|
header( "Location: ".OC_HELPER::linkTo( "index.php" ));
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
OC_APP::setActiveNavigationEntry("files_sharing_list");
|
||||||
|
|
||||||
|
OC_UTIL::addScript("files_sharing", "list");
|
||||||
|
|
||||||
|
$tmpl = new OC_TEMPLATE("files_sharing", "list", "user");
|
||||||
|
$tmpl->assign("shared_items", OC_SHARE::getMySharedItems());
|
||||||
|
$tmpl->printPage();
|
||||||
|
|
||||||
|
?>
|
|
@ -1,30 +0,0 @@
|
||||||
<?php if ($_['shared_items'] == null) {echo "You are not sharing any of your files";} else {?>
|
|
||||||
<table id='itemlist'>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Item</th>
|
|
||||||
<th>Shared With</th>
|
|
||||||
<th>Permissions</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach($_['shared_items'] as $item):?>
|
|
||||||
<tr class='link' id='<?php echo $item['id'];?>'>
|
|
||||||
<td class='item'><?php echo $item['item'];?></td>
|
|
||||||
<td class='uid_shared_with'><?php echo $item['uid_shared_with'];?></td>
|
|
||||||
<td class='permissions'><?php echo $item['permissions'];?></td>
|
|
||||||
<td><button class='delete fancybutton' data-token='<?php echo $link['token'];?>'>Delete</button></td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach;?>
|
|
||||||
<tr id='newlink_row'>
|
|
||||||
<form action='#' id='newlink'>
|
|
||||||
<input type='hidden' id='expire_time'/>
|
|
||||||
<td class='path'><input placeholder='Item' id='path'/></td>
|
|
||||||
<td class='expire'><input placeholder='Share With' id='expire'/></td>
|
|
||||||
<td class='permissions'><input placeholder='Permissions' id='expire'/></td>
|
|
||||||
<td><input type='submit' value='Share'/></td>
|
|
||||||
</form>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<?php } ?>
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<fieldset>
|
||||||
|
<legend>Your Shared Files</legend>
|
||||||
|
<?php if ($_['shared_items'] == null) {echo "You are not sharing any of your files";} else {?>
|
||||||
|
<table id='itemlist'>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Item</th>
|
||||||
|
<th>Shared With</th>
|
||||||
|
<th>Permissions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach($_['shared_items'] as $item):?>
|
||||||
|
<tr class='item'>
|
||||||
|
<td class='source'><?php echo substr($item['source'], strlen("/".$_SESSION['user_id']."/files/"));?></td>
|
||||||
|
<td class='uid_shared_with'><?php echo $item['uid_shared_with'];?></td>
|
||||||
|
<td class='permissions'><?php echo $item['is_writeable'];?></td>
|
||||||
|
<td><button class='delete fancybutton' data-source='<?php echo $item['source'];?>' data-uid_shared_with='<?php echo $item['uid_shared_with'];?>'>Delete</button></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach;?>
|
||||||
|
<tr id='share_item_row'>
|
||||||
|
<form action='#' id='share_item'>
|
||||||
|
<td class='source'><input placeholder='Item' id='source'/></td>
|
||||||
|
<td class='uid_shared_with'><input placeholder='Share With' id='uid_shared_with'/></td>
|
||||||
|
<td class='permissions'><input placeholder='Permissions' id='permissions'/></td>
|
||||||
|
<td><input type='submit' value='Share'/></td>
|
||||||
|
</form>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php } ?>
|
||||||
|
</fieldset>
|
Loading…
Reference in New Issue