aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/calendar/ajax/import/import.php2
-rw-r--r--apps/calendar/export.php2
-rw-r--r--apps/contacts/ajax/deletecard.php10
-rw-r--r--apps/contacts/css/contacts.css127
-rw-r--r--apps/contacts/js/contacts.js87
-rw-r--r--apps/contacts/templates/part.contact.php8
-rw-r--r--apps/files_archive/appinfo/app.php3
-rw-r--r--apps/files_archive/js/archive.js4
-rw-r--r--apps/files_archive/lib/archive.php16
-rw-r--r--apps/files_archive/lib/storage.php6
-rw-r--r--apps/files_archive/lib/tar.php277
-rw-r--r--apps/files_archive/lib/zip.php34
-rw-r--r--apps/files_archive/tests/archive.php40
-rw-r--r--apps/files_archive/tests/tar.php20
-rw-r--r--apps/files_sharing/ajax/userautocomplete.php22
-rw-r--r--apps/files_sharing/lib_share.php14
-rw-r--r--apps/gallery/ajax/galleryOp.php3
-rw-r--r--apps/media/css/music.css1
18 files changed, 494 insertions, 182 deletions
diff --git a/apps/calendar/ajax/import/import.php b/apps/calendar/ajax/import/import.php
index c0797f6e425..d0bdab4f0d5 100644
--- a/apps/calendar/ajax/import/import.php
+++ b/apps/calendar/ajax/import/import.php
@@ -10,7 +10,7 @@ ob_start();
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_Util::checkAppEnabled('calendar');
-$nl = "\n";
+$nl = "\n\r";
$progressfile = OC::$APPSROOT . '/apps/calendar/import_tmp/' . md5(session_id()) . '.txt';
if(is_writable('import_tmp/')){
$progressfopen = fopen($progressfile, 'w');
diff --git a/apps/calendar/export.php b/apps/calendar/export.php
index 9886ad8e8cc..2736eec96c2 100644
--- a/apps/calendar/export.php
+++ b/apps/calendar/export.php
@@ -11,7 +11,7 @@ OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('calendar');
$cal = isset($_GET['calid']) ? $_GET['calid'] : NULL;
$event = isset($_GET['eventid']) ? $_GET['eventid'] : NULL;
-$nl = "\n";
+$nl = "\n\r";
if(isset($cal)){
$calendar = OC_Calendar_App::getCalendar($cal);
$calobjects = OC_Calendar_Object::all($cal);
diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php
index e26dfd6ebfe..5675aef5f15 100644
--- a/apps/contacts/ajax/deletecard.php
+++ b/apps/contacts/ajax/deletecard.php
@@ -19,6 +19,11 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
+function bailOut($msg) {
+ OC_JSON::error(array('data' => array('message' => $msg)));
+ OC_Log::write('contacts','ajax/saveproperty.php: '.$msg, OC_Log::DEBUG);
+ exit();
+}
// Init owncloud
require_once('../../../lib/base.php');
@@ -27,7 +32,10 @@ require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-$id = $_GET['id'];
+$id = isset($_GET['id'])?$_GET['id']:null;
+if(!$id) {
+ bailOut(OC_Contacts_App::$l10n->t('id is not set.'));
+}
$card = OC_Contacts_App::getContactObject( $id );
OC_Contacts_VCard::delete($id);
diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css
index 7c36a511d6e..76b5972ba3c 100644
--- a/apps/contacts/css/contacts.css
+++ b/apps/contacts/css/contacts.css
@@ -10,8 +10,6 @@
#contacts_propertymenu_button { position:absolute;top:15px;right:150px; background:url('../../../core/img/actions/add.svg') no-repeat center; }
#contacts_propertymenu { background-color: #fff; position:absolute;top:40px;right:150px; overflow:hidden; text-overflow:ellipsis; /*border: thin solid #1d2d44;*/ -moz-box-shadow:0 0 10px #000; -webkit-box-shadow:0 0 10px #000; box-shadow:0 0 10px #000; -moz-border-radius:0.5em; -webkit-border-radius:0.5em; border-radius:0.5em; -moz-border-radius:0.5em; -webkit-border-radius:0.5em; border-radius:0.5em; }
#contacts_propertymenu li { display: block; font-weight: bold; height: 20px; width: 100px; }
-/*#contacts_propertymenu li:first-child { border-top: thin solid #1d2d44; -moz-border-radius-topleft:0.5em; -webkit-border-top-left-radius:0.5em; border-top-left-radius:0.5em; -moz-border-radius-topright:0.5em; -webkit-border-top-right-radius:0.5em; border-top-right-radius:0.5em; }
-#contacts_propertymenu li:last-child { border-bottom: thin solid #1d2d44; -moz-border-radius-bottomleft:0.5em; -webkit-border-bottom-left-radius:0.5em; border-bottom-left-radius:0.5em; -moz-border-radius-bottomright:0.5em; -webkit-border-bottom-right-radius:0.5em; border-bottom-right-radius:0.5em; }*/
#contacts_propertymenu li a { padding: 3px; display: block }
#contacts_propertymenu li:hover { background-color: #1d2d44; }
#contacts_propertymenu li a:hover { color: #fff }
@@ -25,54 +23,12 @@
#card input[type="text"],input[type="email"],input[type="tel"],input[type="date"], select { background-color: #f8f8f8; border: 0 !important; -webkit-appearance:none !important; -moz-appearance:none !important; -webkit-box-sizing:none !important; -moz-box-sizing:none !important; box-sizing:none !important; -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: none; -moz-border-radius: 0px; -webkit-border-radius: 0px; border-radius: 0px; float: left; }
#card input[type="text"]:hover, input[type="text"]:focus, input[type="text"]:active,input[type="email"]:hover,input[type="tel"]:hover,input[type="date"]:hover,input[type="date"],input[type="date"]:hover,input[type="date"]:active,input[type="date"]:active,input[type="date"]:active,input[type="email"]:active,input[type="tel"]:active, select:hover, select:focus, select:active { border: 0 !important; -webkit-appearance:textfield; -moz-appearance:textfield; -webkit-box-sizing:content-box; -moz-box-sizing:content-box; box-sizing:content-box; background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #fff, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; outline:none; float: left; }
input[type="text"]:invalid,input[type="email"]:invalid,input[type="tel"]:invalid,input[type="date"]:invalid { background-color: #ffc0c0 !important; }
-/*input[type="text"]:valid,input[type="email"]:valid,input[type="tel"]:valid,input[type="date"]:valid { background-color: #b1d28f !important; }*/
-dl.form
-{
- width: 100%;
- float: left;
- clear: right;
- margin: 0;
- padding: 0;
-}
-
-.form dt
-{
- display: table-cell;
- clear: left;
- float: left;
- width: 7em;
- /*overflow: hidden;*/
- margin: 0;
- padding: 0.8em 0.5em 0 0;
- font-weight: bold;
- text-align:right;
- text-overflow:ellipsis;
- o-text-overflow: ellipsis;
- vertical-align: text-bottom;
- /*
- white-space: pre-wrap;
- white-space: -moz-pre-wrap !important;
- white-space: -pre-wrap;
- white-space: -o-pre-wrap;*/
-}
-
-.form dd
-{
- display: table-cell;
- clear: right;
- float: left;
- margin: 0;
- padding: 0px;
- white-space: nowrap;
- vertical-align: text-bottom;
- /*min-width: 20em;*/
- /*background-color: yellow;*/
-}
+dl.form { width: 100%; float: left; clear: right; margin: 0; padding: 0; }
+.form dt { display: table-cell; clear: left; float: left; width: 7em; margin: 0; padding: 0.8em 0.5em 0 0; font-weight: bold; text-align:right; text-overflow:ellipsis; o-text-overflow: ellipsis; vertical-align: text-bottom;/* white-space: pre-wrap; white-space: -moz-pre-wrap !important; white-space: -pre-wrap; white-space: -o-pre-wrap;*/ }
+.form dd { display: table-cell; clear: right; float: left; margin: 0; padding: 0px; white-space: nowrap; vertical-align: text-bottom; }
.loading { background: url('../../../core/img/loading.gif') no-repeat center !important; /*cursor: progress; */ cursor: wait; }
-/*.add { cursor: pointer; width: 25px; height: 25px; margin: 0px; float: right; position:relative; content: "\+"; font-weight: bold; color: #666; font-size: large; bottom: 0px; right: 0px; clear: both; text-align: center; vertical-align: bottom; display: none; }*/
-
.listactions { height: 1em; width:60px; float: left; clear: right; }
.add,.edit,.delete,.mail, .globe { cursor: pointer; width: 20px; height: 20px; margin: 0; float: left; position:relative; display: none; }
.add { background:url('../../../core/img/actions/add.svg') no-repeat center; clear: both; }
@@ -82,75 +38,21 @@ dl.form
/*.globe { background:url('../img/globe.svg') no-repeat center; }*/
.globe { background:url('../../../core/img/actions/public.svg') no-repeat center; }
-#messagebox_msg { font-weight: bold; font-size: 1.2em; }
-
-/* Name editor */
-#edit_name_dialog {
- /*width: 25em;*/
- padding:0;
-}
-#edit_name_dialog > input {
- width: 15em;
-}
-/* Address editor */
-#edit_address_dialog {
- /*width: 30em;*/
-}
-#edit_address_dialog > input {
- width: 15em;
-}
+#edit_name_dialog { padding:0; }
+#edit_name_dialog > input { width: 15em; }
+#edit_address_dialog { /*width: 30em;*/ }
+#edit_address_dialog > input { width: 15em; }
#edit_photo_dialog_img { display: block; width: 150; height: 200; border: thin solid black; }
#fn { float: left; }
/**
* Create classes form, floateven and floatodd which flows left and right respectively.
*/
-.contactsection {
- float: left;
- min-width: 30em;
- max-width: 40em;
- margin: 0.5em;
- border: thin solid lightgray;
- -webkit-border-radius: 0.5em;
- -moz-border-radius: 0.5em;
- border-radius: 0.5em;
- background-color: #f8f8f8;
-}
+.contactsection { float: left; min-width: 30em; max-width: 40em; margin: 0.5em; border: thin solid lightgray; -webkit-border-radius: 0.5em; -moz-border-radius: 0.5em; border-radius: 0.5em; background-color: #f8f8f8; }
-.contactpart legend {
- /*background: #fff;
- font-weight: bold;
- left: 1em;
- border: thin solid gray;
- -webkit-border-radius: 0.5em;
- -moz-border-radius: 0.5em;
- border-radius: 0.5em;
- padding: 3px;*/
-width:auto; padding:.3em; 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;
-}
-/*#contacts_details_photo {
- cursor: pointer;
- z-index:1;
- margin: auto;
-}
-*/
-#cropbox {
- margin: auto;
-}
+.contactpart legend { width:auto; padding:.3em; 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; }
+#cropbox { margin: auto; }
-/* Photo editor */
-/*#contacts_details_photo_wrapper {
- z-index: 1000;
-}*/
-#contacts_details_photo {
- border-radius: 0.5em;
- border: thin solid #bbb;
- padding: 0.5em;
- margin: 1em 1em 1em 7em;
- cursor: pointer;
- /*background: #f8f8f8;*/
- background: url(../../../core/img/loading.gif) no-repeat center center;
- clear: right;
-}
+#contacts_details_photo { border-radius: 0.5em; border: thin solid #bbb; padding: 0.5em; margin: 1em 1em 1em 7em; cursor: pointer; background: url(../../../core/img/loading.gif) no-repeat center center; clear: right; }
#contacts_details_photo:hover { background: #fff; }
#contacts_details_photo_progress { margin: 0.3em 0.3em 0.3em 7em; clear: left; }
/* Address editor */
@@ -168,13 +70,6 @@ dl.addresscard dd > ul { margin: 0.3em; padding: 0.3em; }
#adr_zipcode {}
#adr_country {}
-.delimiter {
- height: 10px;
- clear: both;
-}
-
-/*input[type="text"] { float: left; max-width: 15em; }
-input[type="radio"] { float: left; -khtml-appearance: none; width: 20px; height: 20px; vertical-align: middle; }*/
#file_upload_target, #crop_target { display:none; }
#file_upload_start { opacity:0; filter:alpha(opacity=0); z-index:1; position:absolute; left:0; top:0; cursor:pointer; width:0; height:0;}
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index e1827027453..d314878cc0a 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -213,19 +213,27 @@ Contacts={
honpre:'',
honsuf:'',
data:undefined,
- update:function() {
+ update:function(id) {
// Make sure proper DOM is loaded.
- console.log('Card.update(), #n: ' + $('#n').length);
+ var newid;
+ console.log('Card.update(), id: ' + id);
console.log('Card.update(), #contacts: ' + $('#contacts li').length);
- if($('#n').length == 0 && $('#contacts li').length > 0) {
+ if(id == undefined) {
+ newid = $('#contacts li:first-child').data('id');
+ } else {
+ newid = id;
+ }
+ if($('#contacts li').length > 0) {
$.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{},function(jsondata){
if(jsondata.status == 'success'){
$('#rightcontent').html(jsondata.data.page);
Contacts.UI.loadHandlers();
if($('#contacts li').length > 0) {
- var firstid = $('#contacts li:first-child').data('id');
- console.log('trying to load: ' + firstid);
- $.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':firstid},function(jsondata){
+ //var newid = $('#contacts li:first-child').data('id');
+ //$('#contacts li:first-child').addClass('active');
+ $('#leftcontent li[data-id="'+newid+'"]').addClass('active');
+ console.log('trying to load: ' + newid);
+ $.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':newid},function(jsondata){
if(jsondata.status == 'success'){
Contacts.UI.Card.loadContact(jsondata.data);
} else{
@@ -300,35 +308,49 @@ Contacts={
}
});
},
- delete: function() {
+ delete:function() {
$('#contacts_deletecard').tipsy('hide');
- $.getJSON('ajax/deletecard.php',{'id':this.id},function(jsondata){
- if(jsondata.status == 'success'){
- $('#leftcontent [data-id="'+jsondata.data.id+'"]').remove();
- $('#rightcontent').data('id','');
- //$('#rightcontent').empty();
- this.id = this.fn = this.fullname = this.shortname = this.famname = this.givname = this.addname = this.honpre = this.honsuf = '';
- this.data = undefined;
- // Load first in list.
- if($('#contacts li').length > 0) {
- Contacts.UI.Card.update();
- } else {
- // load intro page
- $.getJSON('ajax/loadintro.php',{},function(jsondata){
- if(jsondata.status == 'success'){
- id = '';
- $('#rightcontent').data('id','');
- $('#rightcontent').html(jsondata.data.page);
+ OC.dialogs.confirm(t('contacts', 'Are you sure you want to delete this contact?'), t('contacts', 'Warning'), function(answer) {
+ if(answer == true) {
+ $.getJSON('ajax/deletecard.php',{'id':Contacts.UI.Card.id},function(jsondata){
+ if(jsondata.status == 'success'){
+ var newid = '';
+ var curlistitem = $('#leftcontent [data-id="'+jsondata.data.id+'"]');
+ var newlistitem = curlistitem.prev();
+ console.log('Previous: ' + newlistitem);
+ if(newlistitem == undefined) {
+ newlistitem = curlistitem.next();
}
- else{
- OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
+ curlistitem.remove();
+ if(newlistitem != undefined) {
+ newid = newlistitem.data('id');
}
- });
- }
- }
- else{
- OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
- //alert(jsondata.data.message);
+ $('#rightcontent').data('id',newid);
+ //$('#rightcontent').empty();
+ this.id = this.fn = this.fullname = this.shortname = this.famname = this.givname = this.addname = this.honpre = this.honsuf = '';
+ this.data = undefined;
+ // Load first in list.
+ if($('#contacts li').length > 0) {
+ Contacts.UI.Card.update(newid);
+ } else {
+ // load intro page
+ $.getJSON('ajax/loadintro.php',{},function(jsondata){
+ if(jsondata.status == 'success'){
+ id = '';
+ $('#rightcontent').data('id','');
+ $('#rightcontent').html(jsondata.data.page);
+ }
+ else{
+ OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
+ }
+ });
+ }
+ }
+ else{
+ OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
+ //alert(jsondata.data.message);
+ }
+ });
}
});
return false;
@@ -1232,6 +1254,7 @@ $(document).ready(function(){
*/
$('#leftcontent li').live('click',function(){
var id = $(this).data('id');
+ $(this).addClass('active');
var oldid = $('#rightcontent').data('id');
if(oldid != 0){
$('#leftcontent li[data-id="'+oldid+'"]').removeClass('active');
diff --git a/apps/contacts/templates/part.contact.php b/apps/contacts/templates/part.contact.php
index a93069fa722..d243c2b5e14 100644
--- a/apps/contacts/templates/part.contact.php
+++ b/apps/contacts/templates/part.contact.php
@@ -56,13 +56,6 @@ $id = isset($_['id']) ? $_['id'] : '';
<dd style="display:none;" class="propertycontainer" id="nickname_value" data-element="NICKNAME"><input id="nickname" required="required" name="value[NICKNAME]" type="text" class="contacts_property" style="width:16em;" name="value" value="" placeholder="<?php echo $l->t('Enter nickname'); ?>" /><a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a></dd>
<dt style="display:none;" id="bday_label" data-element="BDAY"><label for="bday"><?php echo $l->t('Birthday'); ?></label></dt>
<dd style="display:none;" class="propertycontainer" id="bday_value" data-element="BDAY"><input id="bday" required="required" name="value" type="text" class="contacts_property" value="" placeholder="<?php echo $l->t('dd-mm-yyyy'); ?>" /><a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a></dd>
- <!-- dt id="categories_label" data-element="CATEGORIES"><label for="categories"><?php echo $l->t('Categories'); ?></label></dt>
- <dd class="propertycontainer" id="categories_value" data-element="CATEGORIES">
- <select class="contacts_property" multiple="multiple" id="categories" name="value[]">
- <?php echo html_select_options($_['categories'], array(), array('combine'=>true)) ?>
- </select>
- <a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"></a>
- </dd -->
<dt style="display:none;" id="categories_label" data-element="CATEGORIES"><label for="categories"><?php echo $l->t('Categories'); ?></label></dt>
<dd style="display:none;" class="propertycontainer" id="categories_value" data-element="CATEGORIES"><input id="categories" required="required" name="value[CATEGORIES]" type="text" class="contacts_property" style="width:16em;" name="value" value="" placeholder="<?php echo $l->t('Categories'); ?>" /><a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a><a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"></a></dd>
</dl>
@@ -131,6 +124,7 @@ $(document).ready(function(){
if('<?php echo $id; ?>'!='') {
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':'<?php echo $id; ?>'},function(jsondata){
if(jsondata.status == 'success'){
+ $('#leftcontent li[data-id="<?php echo $id; ?>"]').addClass('active');
Contacts.UI.Card.loadContact(jsondata.data);
}
else{
diff --git a/apps/files_archive/appinfo/app.php b/apps/files_archive/appinfo/app.php
index 693c28d98a0..67809ec980a 100644
--- a/apps/files_archive/appinfo/app.php
+++ b/apps/files_archive/appinfo/app.php
@@ -7,7 +7,8 @@
*/
OC::$CLASSPATH['OC_Archive'] = 'apps/files_archive/lib/archive.php';
-foreach(array('ZIP') as $type){
+OC::$CLASSPATH['Archive_Tar'] = '3rdparty/Archive/Tar.php';
+foreach(array('ZIP','TAR') as $type){
OC::$CLASSPATH['OC_Archive_'.$type] = 'apps/files_archive/lib/'.strtolower($type).'.php';
}
diff --git a/apps/files_archive/js/archive.js b/apps/files_archive/js/archive.js
index ec316c7bf2c..531eb61c01a 100644
--- a/apps/files_archive/js/archive.js
+++ b/apps/files_archive/js/archive.js
@@ -11,5 +11,9 @@ $(document).ready(function() {
window.location='index.php?dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename);
});
FileActions.setDefault('application/zip','Open');
+ FileActions.register('application/x-gzip','Open','',function(filename){
+ window.location='index.php?dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename);
+ });
+ FileActions.setDefault('application/x-gzip','Open');
}
});
diff --git a/apps/files_archive/lib/archive.php b/apps/files_archive/lib/archive.php
index be89f894fb7..113f92e9604 100644
--- a/apps/files_archive/lib/archive.php
+++ b/apps/files_archive/lib/archive.php
@@ -17,6 +17,15 @@ abstract class OC_Archive{
switch($ext){
case '.zip':
return new OC_Archive_ZIP($path);
+ case '.gz':
+ case '.bz':
+ case '.bz2':
+ if(strpos($path,'.tar.')){
+ return new OC_Archive_TAR($path);
+ }
+ break;
+ case '.tgz':
+ return new OC_Archive_TAR($path);
}
}
@@ -78,6 +87,13 @@ abstract class OC_Archive{
*/
abstract function extractFile($path,$dest);
/**
+ * extract the archive
+ * @param string path
+ * @param string dest
+ * @return bool
+ */
+ abstract function extract($dest);
+ /**
* check if a file or folder exists in the archive
* @param string path
* @return bool
diff --git a/apps/files_archive/lib/storage.php b/apps/files_archive/lib/storage.php
index 72a96ca5a5d..700d9633042 100644
--- a/apps/files_archive/lib/storage.php
+++ b/apps/files_archive/lib/storage.php
@@ -125,7 +125,7 @@ class OC_Filestorage_Archive extends OC_Filestorage_Common{
self::$rootView=new OC_FilesystemView('');
}
self::$enableAutomount=false;//prevent recursion
- $supported=array('zip');
+ $supported=array('zip','tar.gz','tar.bz2','tgz');
foreach($supported as $type){
$ext='.'.$type.'/';
if(($pos=strpos(strtolower($path),$ext))!==false){
@@ -139,4 +139,8 @@ class OC_Filestorage_Archive extends OC_Filestorage_Common{
}
self::$enableAutomount=true;
}
+
+ public function rename($path1,$path2){
+ return $this->archive->rename($path1,$path2);
+ }
}
diff --git a/apps/files_archive/lib/tar.php b/apps/files_archive/lib/tar.php
new file mode 100644
index 00000000000..a5d54004788
--- /dev/null
+++ b/apps/files_archive/lib/tar.php
@@ -0,0 +1,277 @@
+<?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.
+ */
+
+class OC_Archive_TAR extends OC_Archive{
+ const PLAIN=0;
+ const GZIP=1;
+ const BZIP=2;
+
+ /**
+ * @var Archive_Tar tar
+ */
+ private $tar=null;
+ private $path;
+
+ function __construct($source){
+ $types=array(null,'gz','bz');
+ $this->path=$source;
+ $this->tar=new Archive_Tar($source,$types[self::getTarType($source)]);
+ }
+
+ /**
+ * try to detect the type of tar compression
+ * @param string file
+ * @return str
+ */
+ static public function getTarType($file){
+ if(strpos($file,'.')){
+ $extention=substr($file,strrpos($file,'.'));
+ switch($extention){
+ case 'gz':
+ case 'tgz':
+ return self::GZIP;
+ case 'bz':
+ case 'bz2':
+ return self::BZIP;
+ default:
+ return self::PLAIN;
+ }
+ }else{
+ return self::PLAIN;
+ }
+ }
+
+ /**
+ * add an empty folder to the archive
+ * @param string path
+ * @return bool
+ */
+ function addFolder($path){
+ $tmpBase=get_temp_dir().'/';
+ if(substr($path,-1,1)!='/'){
+ $path.='/';
+ }
+ if($this->fileExists($path)){
+ return false;
+ }
+ mkdir($tmpBase.$path);
+ $result=$this->tar->addModify(array($tmpBase.$path),'',$tmpBase);
+ rmdir($tmpBase.$path);
+ return $result;
+ }
+ /**
+ * add a file to the archive
+ * @param string path
+ * @param string source either a local file or string data
+ * @return bool
+ */
+ function addFile($path,$source=''){
+ if($this->fileExists($path)){
+ $this->remove($path);
+ }
+ if(file_exists($source)){
+ $header=array();
+ $dummy='';
+ $this->tar->_openAppend();
+ $result=$this->tar->_addfile($source,$header,$dummy,$dummy,$path);
+ }else{
+ $result=$this->tar->addString($path,$source);
+ }
+ return $result;
+ }
+
+ /**
+ * rename a file or folder in the archive
+ * @param string source
+ * @param string dest
+ * @return bool
+ */
+ function rename($source,$dest){
+ //no proper way to delete, rename entire archive, rename file and remake archive
+ $tmp=OC_Helper::tmpFolder();
+ $this->tar->extract($tmp);
+ rename($tmp.$source,$tmp.$dest);
+ $this->tar=null;
+ unlink($this->path);
+ $types=array(null,'gz','bz');
+ $this->tar=new Archive_Tar($this->path,$types[self::getTarType($this->path)]);
+ $this->tar->createModify(array($tmp),'',$tmp.'/');
+ }
+
+ private function getHeader($file){
+ $headers=$this->tar->listContent();
+ foreach($headers as $header){
+ if($file==$header['filename'] or $file.'/'==$header['filename']){
+ return $header;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * get the uncompressed size of a file in the archive
+ * @param string path
+ * @return int
+ */
+ function filesize($path){
+ $stat=$this->getHeader($path);
+ return $stat['size'];
+ }
+ /**
+ * get the last modified time of a file in the archive
+ * @param string path
+ * @return int
+ */
+ function mtime($path){
+ $stat=$this->getHeader($path);
+ return $stat['mtime'];
+ }
+
+ /**
+ * get the files in a folder
+ * @param path
+ * @return array
+ */
+ function getFolder($path){
+ $files=$this->getFiles();
+ $folderContent=array();
+ $pathLength=strlen($path);
+ foreach($files as $file){
+ if(substr($file,0,$pathLength)==$path and $file!=$path){
+ if(strrpos(substr($file,0,-1),'/')<=$pathLength){
+ $folderContent[]=substr($file,$pathLength);
+ }
+ }
+ }
+ return $folderContent;
+ }
+ /**
+ *get all files in the archive
+ * @return array
+ */
+ function getFiles(){
+ $headers=$this->tar->listContent();
+ $files=array();
+ foreach($headers as $header){
+ $files[]=$header['filename'];
+ }
+ return $files;
+ }
+ /**
+ * get the content of a file
+ * @param string path
+ * @return string
+ */
+ function getFile($path){
+ return $this->tar->extractInString($path);
+ }
+ /**
+ * extract a single file from the archive
+ * @param string path
+ * @param string dest
+ * @return bool
+ */
+ function extractFile($path,$dest){
+ $tmp=OC_Helper::tmpFolder();
+ if(!$this->fileExists($path)){
+ return false;
+ }
+ $success=$this->tar->extractList(array($path),$tmp);
+ if($success){
+ rename($tmp.$path,$dest);
+ }
+ OC_Helper::rmdirr($tmp);
+ return $success;
+ }
+ /**
+ * extract the archive
+ * @param string path
+ * @param string dest
+ * @return bool
+ */
+ function extract($dest){
+ return $this->tar->extract($dest);
+ }
+ /**
+ * check if a file or folder exists in the archive
+ * @param string path
+ * @return bool
+ */
+ function fileExists($path){
+ return $this->getHeader($path)!==null;
+ }
+
+ /**
+ * remove a file or folder from the archive
+ * @param string path
+ * @return bool
+ */
+ function remove($path){
+ if(!$this->fileExists($path)){
+ return false;
+ }
+ //no proper way to delete, extract entire archive, delete file and remake archive
+ $tmp=OC_Helper::tmpFolder();
+ $this->tar->extract($tmp);
+ OC_Helper::rmdirr($tmp.$path);
+ $this->tar=null;
+ unlink($this->path);
+ $this->reopen();
+ $this->tar->createModify(array($tmp),'',$tmp);
+ return true;
+ }
+ /**
+ * get a file handler
+ * @param string path
+ * @param string mode
+ * @return resource
+ */
+ function getStream($path,$mode){
+ if(strrpos($path,'.')!==false){
+ $ext=substr($path,strrpos($path,'.'));
+ }else{
+ $ext='';
+ }
+ $tmpFile=OC_Helper::tmpFile($ext);
+ if($this->fileExists($path)){
+ $this->extractFile($path,$tmpFile);
+ }elseif($mode=='r' or $mode=='rb'){
+ return false;
+ }
+ if($mode=='r' or $mode=='rb'){
+ return fopen($tmpFile,$mode);
+ }else{
+ OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack');
+ self::$tempFiles[$tmpFile]=$path;
+ return fopen('close://'.$tmpFile,$mode);
+ }
+ }
+
+ private static $tempFiles=array();
+ /**
+ * write back temporary files
+ */
+ function writeBack($tmpFile){
+ if(isset(self::$tempFiles[$tmpFile])){
+ $this->addFile(self::$tempFiles[$tmpFile],$tmpFile);
+ unlink($tmpFile);
+ }
+ }
+
+ /**
+ * reopen the archive to ensure everything is written
+ */
+ private function reopen(){
+ if($this->tar){
+ $this->tar->_close();
+ $this->tar=null;
+ }
+ $types=array(null,'gz','bz');
+ $this->tar=new Archive_Tar($this->path,$types[self::getTarType($this->path)]);
+ }
+}
diff --git a/apps/files_archive/lib/zip.php b/apps/files_archive/lib/zip.php
index eab101b3a5c..5a5bc766875 100644
--- a/apps/files_archive/lib/zip.php
+++ b/apps/files_archive/lib/zip.php
@@ -11,7 +11,6 @@ class OC_Archive_ZIP extends OC_Archive{
* @var ZipArchive zip
*/
private $zip=null;
- private $contents=array();
private $success=false;
private $path;
@@ -56,7 +55,9 @@ class OC_Archive_ZIP extends OC_Archive{
* @return bool
*/
function rename($source,$dest){
- return $this->zip->renameName($source,$dest);
+ $source=$this->stripPath($source);
+ $dest=$this->stripPath($dest);
+ $this->zip->renameName($source,$dest);
}
/**
* get the uncompressed size of a file in the archive
@@ -99,15 +100,11 @@ class OC_Archive_ZIP extends OC_Archive{
* @return array
*/
function getFiles(){
- if(count($this->contents)){
- return $this->contents;
- }
$fileCount=$this->zip->numFiles;
$files=array();
for($i=0;$i<$fileCount;$i++){
$files[]=$this->zip->getNameIndex($i);
}
- $this->contents=$files;
return $files;
}
/**
@@ -129,12 +126,21 @@ class OC_Archive_ZIP extends OC_Archive{
file_put_contents($dest,$fp);
}
/**
+ * extract the archive
+ * @param string path
+ * @param string dest
+ * @return bool
+ */
+ function extract($dest){
+ return $this->zip->extractTo($dest);
+ }
+ /**
* check if a file or folder exists in the archive
* @param string path
* @return bool
*/
function fileExists($path){
- return $this->zip->locateName($path)!==false;
+ return ($this->zip->locateName($path)!==false) or ($this->zip->locateName($path.'/')!==false);
}
/**
* remove a file or folder from the archive
@@ -142,7 +148,11 @@ class OC_Archive_ZIP extends OC_Archive{
* @return bool
*/
function remove($path){
- return $this->zip->deleteName($path);
+ if($this->fileExists($path.'/')){
+ return $this->zip->deleteName($path.'/');
+ }else{
+ return $this->zip->deleteName($path);
+ }
}
/**
* get a file handler
@@ -179,4 +189,12 @@ class OC_Archive_ZIP extends OC_Archive{
unlink($tmpFile);
}
}
+
+ private function stripPath($path){
+ if(substr($path,0,1)=='/'){
+ return substr($path,1);
+ }else{
+ return $path;
+ }
+ }
}
diff --git a/apps/files_archive/tests/archive.php b/apps/files_archive/tests/archive.php
index 2e26b5e03b5..9e99466a521 100644
--- a/apps/files_archive/tests/archive.php
+++ b/apps/files_archive/tests/archive.php
@@ -27,10 +27,10 @@ abstract class Test_Archive extends UnitTestCase {
$this->instance=$this->getExisting();
$allFiles=$this->instance->getFiles();
$expected=array('lorem.txt','logo-wide.png','dir/','dir/lorem.txt');
- $this->assertEqual(4,count($allFiles));
+ $this->assertEqual(4,count($allFiles),'only found '.count($allFiles).' out of 4 expected files');
foreach($expected as $file){
$this->assertNotIdentical(false,array_search($file,$allFiles),'cant find '.$file.' in archive');
- $this->assertTrue($this->instance->fileExists($file));
+ $this->assertTrue($this->instance->fileExists($file),'file '.$file.' does not exist in archive');
}
$this->assertFalse($this->instance->fileExists('non/existing/file'));
@@ -68,6 +68,7 @@ abstract class Test_Archive extends UnitTestCase {
$this->instance->addFile('lorem.txt',$textFile);
$this->assertEqual(1,count($this->instance->getFiles()));
$this->assertTrue($this->instance->fileExists('lorem.txt'));
+ $this->assertFalse($this->instance->fileExists('lorem.txt/'));
$this->assertEqual(file_get_contents($textFile),$this->instance->getFile('lorem.txt'));
$this->instance->addFile('lorem.txt','foobar');
@@ -94,4 +95,39 @@ abstract class Test_Archive extends UnitTestCase {
$this->assertTrue($this->instance->fileExists('lorem.txt'));
$this->assertEqual(file_get_contents($dir.'/lorem.txt'),$this->instance->getFile('lorem.txt'));
}
+ public function testFolder(){
+ $this->instance=$this->getNew();
+ $this->assertFalse($this->instance->fileExists('/test'));
+ $this->assertFalse($this->instance->fileExists('/test/'));
+ $this->instance->addFolder('/test');
+ $this->assertTrue($this->instance->fileExists('/test'));
+ $this->assertTrue($this->instance->fileExists('/test/'));
+ $this->instance->remove('/test');
+ $this->assertFalse($this->instance->fileExists('/test'));
+ $this->assertFalse($this->instance->fileExists('/test/'));
+ }
+ public function testExtract(){
+ $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
+ $this->instance=$this->getExisting();
+ $tmpDir=OC_Helper::tmpFolder();
+ $this->instance->extract($tmpDir);
+ $this->assertEqual(true,file_exists($tmpDir.'lorem.txt'));
+ $this->assertEqual(true,file_exists($tmpDir.'dir/lorem.txt'));
+ $this->assertEqual(true,file_exists($tmpDir.'logo-wide.png'));
+ $this->assertEqual(file_get_contents($dir.'/lorem.txt'),file_get_contents($tmpDir.'lorem.txt'));
+ OC_Helper::rmdirr($tmpDir);
+ }
+ public function testMoveRemove(){
+ $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
+ $textFile=$dir.'/lorem.txt';
+ $this->instance=$this->getNew();
+ $this->instance->addFile('lorem.txt',$textFile);
+ $this->assertFalse($this->instance->fileExists('target.txt'));
+ $this->instance->rename('lorem.txt','target.txt');
+ $this->assertTrue($this->instance->fileExists('target.txt'));
+ $this->assertFalse($this->instance->fileExists('lorem.txt'));
+ $this->assertEqual(file_get_contents($textFile),$this->instance->getFile('target.txt'));
+ $this->instance->remove('target.txt');
+ $this->assertFalse($this->instance->fileExists('target.txt'));
+ }
}
diff --git a/apps/files_archive/tests/tar.php b/apps/files_archive/tests/tar.php
new file mode 100644
index 00000000000..193a65b550a
--- /dev/null
+++ b/apps/files_archive/tests/tar.php
@@ -0,0 +1,20 @@
+<?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.
+ */
+
+require_once('archive.php');
+
+class Test_Archive_TAR extends Test_Archive{
+ protected function getExisting(){
+ $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
+ return new OC_Archive_TAR($dir.'/data.tar.gz');
+ }
+
+ protected function getNew(){
+ return new OC_Archive_TAR(OC_Helper::tmpFile('.tar.gz'));
+ }
+}
diff --git a/apps/files_sharing/ajax/userautocomplete.php b/apps/files_sharing/ajax/userautocomplete.php
index 9d971fb62af..38b673ee51b 100644
--- a/apps/files_sharing/ajax/userautocomplete.php
+++ b/apps/files_sharing/ajax/userautocomplete.php
@@ -7,21 +7,23 @@ OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('files_sharing');
$users = array();
-$ocusers = OC_User::getUsers();
+$groups = array();
$self = OC_User::getUser();
-$groups = OC_Group::getUserGroups($self);
+$userGroups = OC_Group::getUserGroups($self);
$users[] = "<optgroup label='Users'>";
-foreach ($ocusers as $user) {
- if ($user != $self) {
- $users[] = "<option value='".$user."'>".$user."</option>";
+$groups[] = "<optgroup label='Groups'>";
+foreach ($userGroups as $group) {
+ $groupUsers = OC_Group::usersInGroup($group);
+ foreach ($groupUsers as $user) {
+ if ($user != $self) {
+ $users[] = "<option value='".$user."'>".$user."</option>";
+ }
}
+ $groups[] = "<option value='".$group."'>".$group."</option>";
}
$users[] = "</optgroup>";
-$users[] = "<optgroup label='Groups'>";
-foreach ($groups as $group) {
- $users[] = "<option value='".$group."'>".$group."</option>";
-}
-$users[] = "</optgroup>";
+$groups[] = "</optgroup>";
+$users = array_merge($users, $groups);
OC_JSON::encodedPrint($users);
?>
diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php
index 42739bdfba9..673984f393b 100644
--- a/apps/files_sharing/lib_share.php
+++ b/apps/files_sharing/lib_share.php
@@ -52,8 +52,18 @@ class OC_Share {
// Remove the owner from the list of users in the group
$uid_shared_with = array_diff($uid_shared_with, array($uid_owner));
} else if (OC_User::userExists($uid_shared_with)) {
- $gid = null;
- $uid_shared_with = array($uid_shared_with);
+ $userGroups = OC_Group::getUserGroups($uid_owner);
+ // Check if the user is in one of the owner's groups
+ foreach ($userGroups as $group) {
+ if ($inGroup = OC_Group::inGroup($uid_shared_with, $group)) {
+ $gid = null;
+ $uid_shared_with = array($uid_shared_with);
+ break;
+ }
+ }
+ if (!$inGroup) {
+ throw new Exception("You can't share with ".$uid_shared_with);
+ }
} else {
throw new Exception($uid_shared_with." is not a user");
}
diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php
index b0433898cda..1b3ad48f561 100644
--- a/apps/gallery/ajax/galleryOp.php
+++ b/apps/gallery/ajax/galleryOp.php
@@ -127,6 +127,9 @@ function handleGetGallery($path) {
function handleShare($path, $share, $recursive) {
$recursive = $recursive == 'true' ? 1 : 0;
$owner = OC_User::getUser();
+ $root = OC_Preferences::getValue(OC_User::getUser(),'gallery', 'root', '/');
+ $path = utf8_decode(rtrim($root.$path,'/'));
+ if($path == '') $path = '/';
$r = OC_Gallery_Album::find($owner, null, $path);
if ($row = $r->fetchRow()) {
$albumId = $row['album_id'];
diff --git a/apps/media/css/music.css b/apps/media/css/music.css
index 07173624018..164a6c62ae6 100644
--- a/apps/media/css/music.css
+++ b/apps/media/css/music.css
@@ -22,6 +22,7 @@ div.jp-volume-bar-value { background:#ccc; width:0; height:0.4em; }
#leftcontent img.remove { display:none; float:right; cursor:pointer; opacity: 0; }
#leftcontent li:hover img.remove { display:inline; opacity: .3; }
#leftcontent li div.label { float: left; width: 200px; overflow: hidden; text-overflow: ellipsis; }
+#rightcontent { overflow: auto; }
#playlist li { list-style-type:none; }
.template { display:none; }
.collection_playing { background:#eee; font-weight: bold; }