Merge branch 'master' into sabredav_1.6

This commit is contained in:
Georg Ehrke 2012-02-25 16:29:32 +01:00
commit 097ce76fc4
12 changed files with 182 additions and 54 deletions

View File

@ -1,7 +1,8 @@
<?xml version="1.0"?>
<info>
<id>files_pdfviewer</id>
<name>PDF viewer (pdfjs-based)</name>
<name>PDF Viewer</name>
<description>Inline PDF viewer (pdfjs-based)</description>
<version>0.1</version>
<licence>GPL</licence>
<author>Joan Creus</author>

View File

@ -69,7 +69,6 @@ class OC_Gallery_Photo {
public static function getThumbnail($image_name) {
$save_dir = OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/gallery/';
$save_dir .= dirname($image_name). '/';
$image_name = basename($image_name);
$thumb_file = $save_dir . $image_name;
if (file_exists($thumb_file)) {
$image = new OC_Image($thumb_file);

View File

@ -40,8 +40,8 @@ input[type="text"]:hover, input[type="text"]:focus, input[type="text"]:active,
input[type="password"]:hover, input[type="password"]:focus, input[type="password"]:active,
.searchbox input[type="search"]:hover, .searchbox input[type="search"]:focus, .searchbox input[type="search"]:active { background-color:#fff; color:#333; opacity:1; }
input[type="submit"], input[type="button"], button, .button, #quota, div.jp-progress, .pager li a { width:auto; padding:.4em; border:1px solid #ddd; font-weight:bold; cursor:pointer; background:#f8f8f8; color:#555; text-shadow:#fff 0 1px 0; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; }
input[type="submit"]:hover, input[type="submit"]:focus, input[type="button"]:hover, input[type="button"]:focus, .button:hover { background:#fff; color:#333; }
input[type="submit"], input[type="button"], button, .button, #quota, div.jp-progress, select, .pager li a { width:auto; padding:.4em; border:1px solid #ddd; font-weight:bold; cursor:pointer; background:#f8f8f8; color:#555; text-shadow:#fff 0 1px 0; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; }
input[type="submit"]:hover, input[type="submit"]:focus, input[type="button"]:hover, select:hover, select:focus, select:active, input[type="button"]:focus, .button:hover { background:#fff; color:#333; }
input[type="checkbox"] { width:auto; }
#quota { cursor:default; }

View File

@ -166,6 +166,7 @@ $(document).ready(function() {
$('.file_upload_start').live('change',function(){
var form=$(this).closest('form');
var that=this;
var uploadId=form.attr('data-upload-id');
var files=this.files;
var target=form.children('iframe');
@ -173,6 +174,12 @@ $(document).ready(function() {
if(files){
for(var i=0;i<files.length;i++){
totalSize+=files[i].size;
if(FileList.deleteFiles && FileList.deleteFiles.indexOf(files[i].name)!=-1){//finish delete if we are uploading a deleted file
FileList.finishDelete(function(){
$(that).change();
});
return;
}
}
}
if(totalSize>$('#max_upload').val()){

View File

@ -26,11 +26,37 @@
*/
class OC_FileProxy_Quota extends OC_FileProxy{
private $userQuota=-1;
/**
* get the quota for the current user
* @return int
*/
private function getQuota(){
if($this->userQuota!=-1){
return $this->userQuota;
}
$userQuota=OC_Preferences::getValue(OC_User::getUser(),'files','quota','default');
if($userQuota=='default'){
$userQuota=OC_AppConfig::getValue('files','default_quota','none');
}
if($userQuota=='none'){
$this->userQuota=0;
}else{
$this->userQuota=OC_Helper::computerFileSize($userQuota);
}
return $this->userQuota;
}
/**
* get the free space in the users home folder
* @return int
*/
private function getFreeSpace(){
$rootInfo=OC_FileCache::get('');
$usedSpace=$rootInfo['size'];
$totalSpace=OC_Preferences::getValue(OC_User::getUser(),'files','quota',0);
$totalSpace=OC_Helper::computerFileSize($totalSpace);
$totalSpace=$this->getQuota();
if($totalSpace==0){
return 0;
}

View File

@ -130,7 +130,7 @@ class OC_Group_Database extends OC_Group_Backend {
* removes the user from a group.
*/
public static function removeFromGroup( $uid, $gid ){
$query = OC_DB::prepare( "DELETE FROM `*PREFIX*group_user` WHERE `uid` = ? AND `gid` = ?" );
$query = OC_DB::prepare( "DELETE FROM *PREFIX*group_user WHERE uid = ? AND gid = ?" );
$result = $query->execute( array( $uid, $gid ));
return true;

View File

@ -321,7 +321,10 @@ class OC_User {
$users=array();
foreach(self::$_usedBackends as $backend){
if($backend->implementsActions(OC_USER_BACKEND_GET_USERS)){
$users=array_merge($users,$backend->getUsers());
$backendUsers=$backend->getUsers();
if(is_array($backendUsers)){
$users=array_merge($users,$backendUsers);
}
}
}
return $users;

View File

@ -5,14 +5,28 @@ require_once('../../lib/base.php');
OC_JSON::checkAdminUser();
$username = $_POST["username"];
$username = isset($_POST["username"])?$_POST["username"]:'';
//make sure the quota is in the expected format
$quota= OC_Helper::computerFileSize($_POST["quota"]);
$quota=OC_Helper::humanFileSize($quota);
$quota=$_POST["quota"];
if($quota!='none' and $quota!='default'){
$quota= OC_Helper::computerFileSize($quota);
if($quota==0){
$quota='default';
}else{
$quota=OC_Helper::humanFileSize($quota);
}
}
// Return Success story
OC_Preferences::setValue($username,'files','quota',$quota);
if($username){
OC_Preferences::setValue($username,'files','quota',$quota);
}else{//set the default quota when no username is specified
if($quota=='default'){//'default' as default quota makes no sense
$quota='none';
}
OC_Appconfig::setValue('files','default_quota',$quota);
}
OC_JSON::success(array("data" => array( "username" => $username ,'quota'=>$quota)));
?>

View File

@ -29,6 +29,12 @@ li.selected { background-color:#ddd; }
#content>table:not(.nostyle) { margin-top:3em; }
table:not(.nostyle) { width:100%; }
#rightcontent { padding-left: 1em; }
td.quota { position:relative }
div.quota { float:right; display:block; position:absolute; right:25em; top:0; }
select.quota { position:absolute; left:0; top:0; width:10em; }
input.quota-other { display:none; position:absolute; left:0.1em; top:0.1em; width:7em; border:none; -webkit-box-shadow: none -mox-box-shadow:none ; box-shadow:none; }
div.quota>span { position:absolute; right:0em; white-space:nowrap; top: 0.7em }
select.quota.active { background: #fff; }
/* APPS */
li { color:#888; }

View File

@ -5,6 +5,18 @@
*/
$(document).ready(function(){
function setQuota(uid,quota,ready){
$.post(
OC.filePath('settings','ajax','setquota.php'),
{username:uid,quota:quota},
function(result){
if(ready){
ready(result.data.quota);
}
}
);
}
function applyMultiplySelect(element){
var checked=[];
var user=element.data('username');
@ -82,48 +94,66 @@ $(document).ready(function(){
$('td.password').live('click',function(event){
$(this).children('img').click();
});
$('td.quota>img').live('click',function(event){
event.stopPropagation();
var img=$(this);
var uid=img.parent().parent().data('uid');
var input=$('<input>');
var quota=img.parent().children('span').text();
if(quota=='None'){
quota='';
$('select.quota').live('change',function(){
var select=$(this);
var uid=$(this).parent().parent().data('uid');
var quota=$(this).val();
var other=$(this).next();
if(quota!='other'){
other.hide();
select.data('previous',quota);
setQuota(uid,quota);
}else{
other.show();
select.addClass('active');
other.focus();
}
input.val(quota);
img.css('display','none');
img.parent().children('span').replaceWith(input);
input.focus();
input.keypress(function(event) {
if(event.keyCode == 13) {
$(this).parent().attr('data-quota',$(this).val());
if($(this).val().length>0){
$.post(
OC.filePath('settings','ajax','setquota.php'),
{username:uid,quota:$(this).val()},
function(result){
img.parent().children('span').text(result.data.quota)
$(this).parent().attr('data-quota',result.data.quota);
}
);
input.blur();
});
$('select.quota').each(function(i,select){
$(select).data('previous',$(select).val());
})
$('input.quota-other').live('change',function(){
var uid=$(this).parent().parent().data('uid');
var quota=$(this).val();
var select=$(this).prev();
var other=$(this);
if(quota){
setQuota(uid,quota,function(quota){
select.children().attr('selected',null);
var existingOption=select.children().filter(function(i,option){
return ($(option).val()==quota);
});
if(existingOption.length){
existingOption.attr('selected','selected');
}else{
input.blur();
var option=$('<option/>');
option.attr('selected','selected').attr('value',quota).text(quota);
select.children().last().before(option);
}
}
});
input.blur(function(){
var quota=$(this).parent().attr('data-quota');
$(this).replaceWith($('<span>'+quota+'</span>'));
img.css('display','');
});
});
$('td.quota').live('click',function(event){
$(this).children('img').click();
select.val(quota);
select.removeClass('active');
other.val(null);
other.hide();
});
}else{
var previous=select.data('previous');
select.children().attr('selected',null);
select.children().each(function(i,option){
if($(option).val()==previous){
$(option).attr('selected','selected');
}
});
select.removeClass('active');
other.hide();
}
});
$('input.quota-other').live('blur',function(){
$(this).change();
})
$('#newuser').submit(function(event){
event.preventDefault();
var username=$('#newusername').val();
@ -157,7 +187,13 @@ $(document).ready(function(){
select.data('username',username);
select.data('userGroups',groups.join(', '));
tr.find('td.groups').empty();
$.each($('#content table').data('groups').split(', '),function(i,group){
var allGroups=$('#content table').data('groups').split(', ');
for(var i=0;i<groups.length;i++){
if(allGroups.indexOf(groups[i])==-1){
allGroups.push(groups[i]);
}
}
$.each(allGroups,function(i,group){
select.append($('<option value="'+group+'">'+group+'</option>'));
});
tr.find('td.groups').append(select);
@ -166,5 +202,9 @@ $(document).ready(function(){
}
applyMultiplySelect(select);
$('#content table tbody').last().after(tr);
tr.find('select.quota option').attr('selected',null);
tr.find('select.quota option').first().attr('selected','selected');
tr.find('select.quota').data('previous','default');
});
});

View File

@ -21,6 +21,21 @@ foreach($_["groups"] as $group) {
</select>
<input type="submit" value="<?php echo $l->t('Create')?>" />
</form>
<div class="quota">
<span><?php echo $l->t('Default Quota');?>:</span>
<select class='quota'>
<?php foreach($_['quota_preset'] as $preset):?>
<?php if($preset!='default'):?>
<option <?php if($_['default_quota']==$preset) echo 'selected="selected"';?> value='<?php echo $preset;?>'><?php echo $preset;?></option>
<?php endif;?>
<?php endforeach;?>
<?php if(array_search($_['default_quota'],$_['quota_preset'])===false):?>
<option selected="selected" value='<?php echo $_['default_quota'];?>'><?php echo $_['default_quota'];?></option>
<?php endif;?>
<option value='other'><?php echo $l->t('Other');?>...</option>
</select>
<input class='quota-other'></input>
</div>
</div>
<table data-groups="<?php echo implode(', ',$allGroups);?>">
@ -48,9 +63,17 @@ foreach($_["groups"] as $group) {
<?php endforeach;?>
</select>
</td>
<td class="quota" data-quota="<?php echo $user['quota']?>">
<span><?php echo ($user['quota']>0)?$user['quota']:'None';?></span>
<img class="svg action" src="<?php echo image_path('core','actions/rename.svg')?>" alt="set new password" title="set quota" />
<td class="quota">
<select class='quota'>
<?php foreach($_['quota_preset'] as $preset):?>
<option <?php if($user['quota']==$preset) echo 'selected="selected"';?> value='<?php echo $preset;?>'><?php echo $preset;?></option>
<?php endforeach;?>
<?php if(array_search($user['quota'],$_['quota_preset'])===false):?>
<option selected="selected" value='<?php echo $user['quota'];?>'><?php echo $user['quota'];?></option>
<?php endif;?>
<option value='other'><?php echo $l->t('Other');?>...</option>
</select>
<input class='quota-other'></input>
</td>
<td class="remove">
<?php if($user['name']!=OC_User::getUser()):?>

View File

@ -18,17 +18,26 @@ $users = array();
$groups = array();
foreach( OC_User::getUsers() as $i ){
$users[] = array( "name" => $i, "groups" => join( ", ", OC_Group::getUserGroups( $i ) ),'quota'=>OC_Preferences::getValue($i,'files','quota',0));
$users[] = array( "name" => $i, "groups" => join( ", ", OC_Group::getUserGroups( $i ) ),'quota'=>OC_Preferences::getValue($i,'files','quota','default'));
}
foreach( OC_Group::getGroups() as $i ){
// Do some more work here soon
$groups[] = array( "name" => $i );
}
$quotaPreset=OC_Appconfig::getValue('files','quota_preset','default,none,1 GB, 5 GB, 10 GB');
$quotaPreset=explode(',',$quotaPreset);
foreach($quotaPreset as &$preset){
$preset=trim($preset);
}
$defaultQuota=OC_Appconfig::getValue('files','default_quota','none');
$tmpl = new OC_Template( "settings", "users", "user" );
$tmpl->assign( "users", $users );
$tmpl->assign( "groups", $groups );
$tmpl->assign( 'quota_preset', $quotaPreset);
$tmpl->assign( 'default_quota', $defaultQuota);
$tmpl->printPage();
?>