Merge branch 'master' into subadmin
This commit is contained in:
commit
4700222ea9
41 changed files with 739 additions and 519 deletions
|
@ -1 +1 @@
|
|||
0.5
|
||||
0.5.2
|
||||
|
|
35
apps/contacts/ajax/addaddressbook.php
Normal file
35
apps/contacts/ajax/addaddressbook.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011-2012 Thomas Tanghus <thomas@tanghus.net>
|
||||
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
|
||||
// Check if we are a user
|
||||
OCP\JSON::checkLoggedIn();
|
||||
OCP\JSON::checkAppEnabled('contacts');
|
||||
OCP\JSON::callCheck();
|
||||
require_once('loghandler.php');
|
||||
|
||||
debug('name: '.$_POST['name']);
|
||||
|
||||
$userid = OCP\USER::getUser();
|
||||
$name = isset($_POST['name'])?trim(strip_tags($_POST['name'])):null;
|
||||
$description = isset($_POST['description'])?trim(strip_tags($_POST['description'])):null;
|
||||
|
||||
if(is_null($name)) {
|
||||
bailOut('Cannot add addressbook with an empty name.');
|
||||
}
|
||||
$bookid = OC_Contacts_Addressbook::add($userid, $name, $description);
|
||||
if(!$bookid) {
|
||||
bailOut('Error adding addressbook: '.$name);
|
||||
}
|
||||
|
||||
if(!OC_Contacts_Addressbook::setActive($bookid, 1)) {
|
||||
bailOut('Error activating addressbook.');
|
||||
}
|
||||
$addressbook = OC_Contacts_App::getAddressbook($bookid);
|
||||
OCP\JSON::success(array('data' => $addressbook));
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
OCP\JSON::checkLoggedIn();
|
||||
OCP\App::checkAppEnabled('contacts');
|
||||
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
|
||||
$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
|
||||
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
|
||||
|
||||
$freeSpace=OC_Filesystem::free_space('/');
|
||||
$freeSpace=max($freeSpace,0);
|
||||
$maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
|
||||
|
||||
$tmpl = new OCP\Template('contacts', 'part.importaddressbook');
|
||||
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
|
||||
$tmpl->assign('requesttoken', $_SERVER['HTTP_REQUESTTOKEN']);
|
||||
$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
|
||||
$tmpl->printpage();
|
16
apps/contacts/ajax/selectaddressbook.php
Normal file
16
apps/contacts/ajax/selectaddressbook.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011 Thomas Tanghus <thomas@tanghus.net>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
OCP\JSON::checkLoggedIn();
|
||||
OCP\JSON::checkAppEnabled('contacts');
|
||||
|
||||
$addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser());
|
||||
$tmpl = new OCP\Template("contacts", "part.selectaddressbook");
|
||||
$tmpl->assign('addressbooks', $addressbooks);
|
||||
$page = $tmpl->fetchPage();
|
||||
OCP\JSON::success(array('data' => array('page' => $page )));
|
|
@ -27,13 +27,16 @@ OCP\JSON::callCheck();
|
|||
require_once('loghandler.php');
|
||||
|
||||
$view = OCP\Files::getStorage('contacts');
|
||||
if(!$view->file_exists('imports')) {
|
||||
$view->mkdir('imports');
|
||||
}
|
||||
$tmpfile = md5(rand());
|
||||
|
||||
// If it is a Drag'n'Drop transfer it's handled here.
|
||||
$fn = (isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : false);
|
||||
if($fn) {
|
||||
if($view->file_put_contents('/'.$tmpfile, file_get_contents('php://input'))) {
|
||||
OCP\JSON::success(array('data' => array('path'=>'', 'file'=>$tmpfile)));
|
||||
if($view->file_put_contents('/imports/'.$fn, file_get_contents('php://input'))) {
|
||||
OCP\JSON::success(array('data' => array('file'=>$tmpfile, 'name'=>$fn)));
|
||||
exit();
|
||||
} else {
|
||||
bailOut(OC_Contacts_App::$l10n->t('Error uploading contacts to storage.'));
|
||||
|
@ -60,10 +63,9 @@ if($error !== UPLOAD_ERR_OK) {
|
|||
}
|
||||
$file=$_FILES['importfile'];
|
||||
|
||||
$tmpfname = tempnam(get_temp_dir(), "occOrig");
|
||||
if(file_exists($file['tmp_name'])) {
|
||||
if($view->file_put_contents('/'.$tmpfile, file_get_contents($file['tmp_name']))) {
|
||||
OCP\JSON::success(array('data' => array('path'=>'', 'file'=>$tmpfile)));
|
||||
if($view->file_put_contents('/imports/'.$file['name'], file_get_contents($file['tmp_name']))) {
|
||||
OCP\JSON::success(array('data' => array('file'=>$file['name'], 'name'=>$file['name'])));
|
||||
} else {
|
||||
bailOut(OC_Contacts_App::$l10n->t('Error uploading contacts to storage.'));
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.2.1
|
||||
0.2.3
|
|
@ -13,7 +13,8 @@
|
|||
.ui-state-hover { border: 1px solid dashed; }
|
||||
#bottomcontrols { padding: 0; bottom:0px; height:2.8em; width: 20em; margin:0; background:#eee; border-top:1px solid #ccc; position:fixed; -moz-box-shadow: 0 -3px 3px -3px #000; -webkit-box-shadow: 0 -3px 3px -3px #000; box-shadow: 0 -3px 3px -3px #000;}
|
||||
#bottomcontrols img { margin-top: 0.35em; }
|
||||
#contacts_newcontact { float: left; margin: 0.2em 0 0 1em; }
|
||||
#uploadprogressbar { display: none; padding: 0; bottom: 3em; height:2em; width: 20em; margin:0; background:#eee; border:1px solid #ccc; position:fixed; }
|
||||
#contacts_newcontact, #contacts_import, #chooseaddressbook { float: left; margin: 0.2em 0 0 1em; border: 0 none; border-radius: 0; -moz-box-shadow: none; box-shadow: none; outline: 0 none; }
|
||||
#chooseaddressbook { float: right; margin: 0.2em 1em 0 0; }
|
||||
#actionbar { position: relative; clear: both; height: 30px;}
|
||||
#contacts_deletecard {position:relative; float:left; background:url('%webroot%/core/img/actions/delete.svg') no-repeat center; }
|
||||
|
@ -110,7 +111,7 @@ dl.addresscard .action { float: right; }
|
|||
#file_upload_form { width: 0; height: 0; }
|
||||
#file_upload_target, #import_upload_target, #crop_target { display:none; }
|
||||
#file_upload_start, #import_upload_start { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter:alpha(opacity=0); opacity:0; z-index:1001; width:0; height:0;}
|
||||
#import_upload_start { width: 16px; height: 16px; margin: 0 0 0 0; }
|
||||
#import_upload_start { width: 20px; height: 20px; margin: 0 0 -24px 0; padding: 0;}
|
||||
input[type="checkbox"] { width: 20px; height: 20px; vertical-align: bottom; }
|
||||
.big { font-weight:bold; font-size:1.2em; }
|
||||
.huge { font-weight:bold; font-size:1.5em; }
|
||||
|
|
|
@ -12,7 +12,6 @@ OCP\JSON::checkLoggedIn();
|
|||
OCP\App::checkAppEnabled('contacts');
|
||||
session_write_close();
|
||||
|
||||
$cr = "\r";
|
||||
$nl = "\n";
|
||||
|
||||
global $progresskey;
|
||||
|
@ -31,7 +30,7 @@ writeProgress('10');
|
|||
$view = $file = null;
|
||||
if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') {
|
||||
$view = OCP\Files::getStorage('contacts');
|
||||
$file = $view->file_get_contents('/' . $_POST['file']);
|
||||
$file = $view->file_get_contents('/imports/' . $_POST['file']);
|
||||
} else {
|
||||
$file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']);
|
||||
}
|
||||
|
@ -49,17 +48,15 @@ if(isset($_POST['method']) && $_POST['method'] == 'new'){
|
|||
}else{
|
||||
$id = $_POST['id'];
|
||||
if(!$id) {
|
||||
OCP\JSON::error(array('data' => array('message' => 'Error getting the ID of the address book.')));
|
||||
OCP\JSON::error(array('data' => array('message' => 'Error getting the ID of the address book.', 'file'=>$_POST['file'])));
|
||||
exit();
|
||||
}
|
||||
OC_Contacts_App::getAddressbook($id); // is owner access check
|
||||
}
|
||||
//analyse the contacts file
|
||||
writeProgress('40');
|
||||
$file = str_replace(array("\r","\n\n"), array("\n","\n"), $file);
|
||||
$lines = explode($nl, $file);
|
||||
if(count($lines) == 1) { // Mac eol
|
||||
$lines = explode($cr, $file);
|
||||
}
|
||||
|
||||
$inelement = false;
|
||||
$parts = array();
|
||||
|
@ -82,7 +79,7 @@ writeProgress('70');
|
|||
$imported = 0;
|
||||
$failed = 0;
|
||||
if(!count($parts) > 0) {
|
||||
OCP\JSON::error(array('data' => array('message' => 'No contacts to import in .'.$_POST['file'].' Please check if the file is corrupted.')));
|
||||
OCP\JSON::error(array('data' => array('message' => 'No contacts to import in '.$_POST['file'].'. Please check if the file is corrupted.', 'file'=>$_POST['file'])));
|
||||
exit();
|
||||
}
|
||||
foreach($parts as $part){
|
||||
|
@ -105,8 +102,8 @@ writeProgress('100');
|
|||
sleep(3);
|
||||
OC_Cache::remove($progresskey);
|
||||
if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') {
|
||||
if(!$view->unlink('/' . $_POST['file'])) {
|
||||
if(!$view->unlink('/imports/' . $_POST['file'])) {
|
||||
OCP\Util::writeLog('contacts','Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'], OCP\Util::ERROR);
|
||||
}
|
||||
}
|
||||
OCP\JSON::success(array('data' => array('imported'=>$imported, 'failed'=>$failed)));
|
||||
OCP\JSON::success(array('data' => array('imported'=>$imported, 'failed'=>$failed, 'file'=>$_POST['file'])));
|
||||
|
|
|
@ -15,7 +15,7 @@ OCP\App::checkAppEnabled('contacts');
|
|||
// Get active address books. This creates a default one if none exists.
|
||||
$ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser());
|
||||
$has_contacts = (count(OC_Contacts_VCard::all($ids, 0, 1)) > 0 ? true : false); // just to check if there are any contacts.
|
||||
if($contacts === false) {
|
||||
if($has_contacts === false) {
|
||||
OCP\Util::writeLog('contacts','index.html: No contacts found.',OCP\Util::DEBUG);
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@ OCP\Util::addscript('','oc-vcategories');
|
|||
OCP\Util::addscript('contacts','contacts');
|
||||
OCP\Util::addscript('contacts','expanding');
|
||||
OCP\Util::addscript('contacts','jquery.combobox');
|
||||
OCP\Util::addscript('files', 'jquery.fileupload');
|
||||
OCP\Util::addscript('contacts','jquery.inview');
|
||||
OCP\Util::addscript('contacts','jquery.Jcrop');
|
||||
OCP\Util::addscript('contacts','jquery.multi-autocomplete');
|
||||
|
|
|
@ -12,13 +12,10 @@ String.prototype.strip_tags = function(){
|
|||
|
||||
Contacts={
|
||||
UI:{
|
||||
notification:function(msg, ndata) {
|
||||
$('#notification').text(msg);
|
||||
if(data) {
|
||||
$('#notification').data(ndata[0],ndata[1]);
|
||||
}
|
||||
notify:function(params) {
|
||||
$('#notification').text(params.message);
|
||||
$('#notification').fadeIn();
|
||||
setTimeout($('#notification').fadeOut(), 10000);
|
||||
setTimeout(function() {$('#notification').fadeOut();}, 10000);
|
||||
},
|
||||
notImplemented:function() {
|
||||
OC.dialogs.alert(t('contacts', 'Sorry, this functionality has not been implemented yet'), t('contacts', 'Not implemented'));
|
||||
|
@ -187,16 +184,7 @@ Contacts={
|
|||
}
|
||||
] );
|
||||
|
||||
/*$('#fn').blur(function(){
|
||||
if($('#fn').val() == '') {
|
||||
OC.dialogs.alert(t('contacts','The name field cannot be empty. Please enter a name for this contact.'), t('contacts','Name is empty'), function() { $('#fn').focus(); });
|
||||
$('#fn').focus();
|
||||
return false;
|
||||
}
|
||||
});*/
|
||||
|
||||
// Name has changed. Update it and reorder.
|
||||
// TODO: Take addressbook into account
|
||||
$('#fn').change(function(){
|
||||
var name = $('#fn').val().strip_tags();
|
||||
var item = $('.contacts li[data-id="'+Contacts.UI.Card.id+'"]');
|
||||
|
@ -218,7 +206,7 @@ Contacts={
|
|||
|
||||
$('#contacts_deletecard').click( function() { Contacts.UI.Card.doDelete();return false;} );
|
||||
$('#contacts_deletecard').keydown( function(event) {
|
||||
if(event.which == 13) {
|
||||
if(event.which == 13 || event.which == 32) {
|
||||
Contacts.UI.Card.doDelete();
|
||||
}
|
||||
return false;
|
||||
|
@ -226,7 +214,7 @@ Contacts={
|
|||
|
||||
$('#contacts_downloadcard').click( function() { Contacts.UI.Card.doExport();return false;} );
|
||||
$('#contacts_downloadcard').keydown( function(event) {
|
||||
if(event.which == 13) {
|
||||
if(event.which == 13 || event.which == 32) {
|
||||
Contacts.UI.Card.doExport();
|
||||
}
|
||||
return false;
|
||||
|
@ -258,7 +246,7 @@ Contacts={
|
|||
$('#contacts_deletecard').tipsy({gravity: 'ne'});
|
||||
$('#contacts_downloadcard').tipsy({gravity: 'ne'});
|
||||
$('#contacts_propertymenu_button').tipsy();
|
||||
$('#contacts_newcontact, #chooseaddressbook').tipsy({gravity: 'sw'});
|
||||
$('#contacts_newcontact, #contacts_import, #chooseaddressbook').tipsy({gravity: 'sw'});
|
||||
|
||||
$('body').click(function(e){
|
||||
if(!$(e.target).is('#contacts_propertymenu_button')) {
|
||||
|
@ -295,22 +283,32 @@ Contacts={
|
|||
honpre:'',
|
||||
honsuf:'',
|
||||
data:undefined,
|
||||
update:function(id, bookid) {
|
||||
var newid, firstitem;
|
||||
if(!id) {
|
||||
update:function(params) { // params {cid:int, aid:int}
|
||||
if(!params) { params = {}; }
|
||||
$('#contacts li').removeClass('active');
|
||||
console.log('Card, cid: ' + params.cid + ' aid: ' + params.aid);
|
||||
var newid, bookid, firstitem;
|
||||
if(!parseInt(params.cid) && !parseInt(params.aid)) {
|
||||
firstitem = $('#contacts ul').first().find('li:first-child');
|
||||
if(firstitem.length > 0) {
|
||||
newid = firstitem.data('id');
|
||||
bookid = firstitem.data('bookid');
|
||||
newid = parseInt(firstitem.data('id'));
|
||||
bookid = parseInt(firstitem.data('bookid'));
|
||||
}
|
||||
} else if(!parseInt(params.cid) && parseInt(params.aid)) {
|
||||
bookid = parseInt(params.aid);
|
||||
newid = parseInt($('#contacts').find('li[data-bookid="'+bookid+'"]').first().data('id'));
|
||||
} else if(parseInt(params.cid) && !parseInt(params.aid)) {
|
||||
newid = parseInt(params.cid);
|
||||
bookid = parseInt($('#contacts li[data-id="'+newid+'"]').data('bookid'));
|
||||
} else {
|
||||
newid = id;
|
||||
bookid = bookid?bookid:$('#contacts li[data-id="'+newid+'"]').data('bookid');
|
||||
newid = parseInt(params.cid);
|
||||
bookid = parseInt(params.aid);
|
||||
}
|
||||
if(!bookid) {
|
||||
bookid = $('#contacts h3').first().data('id');
|
||||
if(!bookid || !newid) {
|
||||
bookid = parseInt($('#contacts h3').first().data('id'));
|
||||
newid = parseInt($('#contacts').find('li[data-bookid="'+bookid+'"]').first().data('id'));
|
||||
}
|
||||
console.log('bookid: ' +bookid);
|
||||
console.log('newid: ' + newid + ' bookid: ' +bookid);
|
||||
var localLoadContact = function(newid, bookid) {
|
||||
if($('.contacts li').length > 0) {
|
||||
$('#contacts li[data-id="'+newid+'"]').addClass('active');
|
||||
|
@ -359,9 +357,6 @@ Contacts={
|
|||
doExport:function() {
|
||||
document.location.href = OC.linkTo('contacts', 'export.php') + '?contactid=' + this.id;
|
||||
},
|
||||
doImport:function(){
|
||||
Contacts.UI.notImplemented();
|
||||
},
|
||||
editNew:function(){ // add a new contact
|
||||
this.id = ''; this.fn = ''; this.fullname = ''; this.givname = ''; this.famname = ''; this.addname = ''; this.honpre = ''; this.honsuf = '';
|
||||
//Contacts.UI.Card.add(t('contacts', 'Contact')+';'+t('contacts', 'New')+';;;', t('contacts', 'New Contact'), '', true);
|
||||
|
@ -441,20 +436,20 @@ Contacts={
|
|||
var newid = '', bookid;
|
||||
var curlistitem = $('#contacts li[data-id="'+jsondata.data.id+'"]');
|
||||
var newlistitem = curlistitem.prev('li');
|
||||
if(newlistitem == undefined) {
|
||||
if(!newlistitem) {
|
||||
newlistitem = curlistitem.next('li');
|
||||
}
|
||||
curlistitem.remove();
|
||||
if(!$(newlistitem).is('li')) {
|
||||
if($(newlistitem).is('li')) {
|
||||
newid = newlistitem.data('id');
|
||||
bookid = newlistitem.data('id');
|
||||
bookid = newlistitem.data('bookid');
|
||||
}
|
||||
$('#rightcontent').data('id',newid);
|
||||
this.id = this.fn = this.fullname = this.shortname = this.famname = this.givname = this.addname = this.honpre = this.honsuf = '';
|
||||
this.data = undefined;
|
||||
|
||||
if($('.contacts li').length > 0) { // Load first in list.
|
||||
Contacts.UI.Card.update(newid, bookid);
|
||||
Contacts.UI.Card.update({cid:newid, aid:bookid});
|
||||
} else {
|
||||
// load intro page
|
||||
$.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){
|
||||
|
@ -774,6 +769,7 @@ Contacts={
|
|||
}
|
||||
},
|
||||
deleteProperty:function(obj, type){
|
||||
console.log('deleteProperty');
|
||||
Contacts.UI.loading(obj, true);
|
||||
var checksum = Contacts.UI.checksumFor(obj);
|
||||
if(checksum) {
|
||||
|
@ -1377,6 +1373,20 @@ Contacts={
|
|||
}
|
||||
});
|
||||
},
|
||||
addAddressbook:function(name, description, cb) {
|
||||
$.post(OC.filePath('contacts', 'ajax', 'addaddressbook.php'), { name: name, description: description, active: true },
|
||||
function(jsondata){
|
||||
if(jsondata.status == 'success'){
|
||||
if(cb) {
|
||||
cb(jsondata.data);
|
||||
}
|
||||
} else {
|
||||
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
newAddressbook:function(object){
|
||||
var tr = $(document.createElement('tr'))
|
||||
.load(OC.filePath('contacts', 'ajax', 'addbook.php'));
|
||||
|
@ -1404,129 +1414,14 @@ Contacts={
|
|||
});
|
||||
}
|
||||
},
|
||||
loadImportHandlers:function() {
|
||||
$('#import_upload_start').change(function(){
|
||||
Contacts.UI.Addressbooks.uploadImport(this.files);
|
||||
});
|
||||
$('#importaddressbook_dialog').find('.upload').click(function() {
|
||||
Contacts.UI.Addressbooks.droptarget.html(t('contacts', 'Uploading...'));
|
||||
Contacts.UI.loading(Contacts.UI.Addressbooks.droptarget, true);
|
||||
//$('#import_upload_start').trigger('click');
|
||||
//return false;
|
||||
});
|
||||
$('#importaddressbook_dialog').find('.upload').tipsy();
|
||||
this.droptarget = $('#import_drop_target');
|
||||
$(this.droptarget).bind('dragover',function(event){
|
||||
$(event.target).addClass('droppable');
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
});
|
||||
$(this.droptarget).bind('dragleave',function(event){
|
||||
$(event.target).removeClass('droppable');
|
||||
});
|
||||
$(this.droptarget).bind('drop',function(event){
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
$(event.target).removeClass('droppable');
|
||||
$(event.target).html(t('contacts', 'Uploading...'));
|
||||
Contacts.UI.loading(event.target, true);
|
||||
$.importUpload(event.originalEvent.dataTransfer.files);
|
||||
});
|
||||
|
||||
$.importUpload = function(files){
|
||||
var file = files[0];
|
||||
if(file.size > $('#max_upload').val()){
|
||||
OC.dialogs.alert(t('contacts','The file you are trying to upload exceed the maximum size for file uploads on this server.'), t('contacts','Upload too large'));
|
||||
$(Contacts.UI.Addressbooks.droptarget).html(Contacts.UI.Addressbooks.droptext);
|
||||
Contacts.UI.loading(Contacts.UI.Addressbooks.droptarget, false);
|
||||
return;
|
||||
}
|
||||
if(file.type.indexOf('text') != 0) {
|
||||
OC.dialogs.alert(t('contacts','You have dropped a file type that cannot be imported: ') + file.type, t('contacts','Wrong file type'));
|
||||
$(Contacts.UI.Addressbooks.droptarget).html(Contacts.UI.Addressbooks.droptext);
|
||||
Contacts.UI.loading(Contacts.UI.Addressbooks.droptarget, false);
|
||||
return;
|
||||
}
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
if (!xhr.upload) {
|
||||
OC.dialogs.alert(t('contacts', 'Your browser doesn\'t support AJAX upload. Please upload the contacts file to ownCloud and import that way.'), t('contacts', 'Error'))
|
||||
}
|
||||
importUpload = xhr.upload,
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == 4){
|
||||
response = $.parseJSON(xhr.responseText);
|
||||
if(response.status == 'success') {
|
||||
if(xhr.status == 200) {
|
||||
Contacts.UI.Addressbooks.doImport(response.data.path, response.data.file);
|
||||
} else {
|
||||
$(Contacts.UI.Addressbooks.droptarget).html(Contacts.UI.Addressbooks.droptext);
|
||||
Contacts.UI.loading(Contacts.UI.Addressbooks.droptarget, false);
|
||||
OC.dialogs.alert(xhr.status + ': ' + xhr.responseText, t('contacts', 'Error'));
|
||||
}
|
||||
} else {
|
||||
OC.dialogs.alert(response.data.message, t('contacts', 'Error'));
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.open('POST', OC.filePath('contacts', 'ajax', 'uploadimport.php') + '?file='+encodeURIComponent(file.name)+'&requesttoken='+requesttoken, true);
|
||||
xhr.setRequestHeader('Cache-Control', 'no-cache');
|
||||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
xhr.setRequestHeader('X_FILE_NAME', encodeURIComponent(file.name));
|
||||
xhr.setRequestHeader('X-File-Size', file.size);
|
||||
xhr.setRequestHeader('Content-Type', file.type);
|
||||
xhr.send(file);
|
||||
}
|
||||
},
|
||||
uploadImport:function(filelist) {
|
||||
if(!filelist) {
|
||||
OC.dialogs.alert(t('contacts','No files selected for upload.'), t('contacts', 'Error'));
|
||||
return;
|
||||
}
|
||||
//var file = filelist.item(0);
|
||||
var file = filelist[0];
|
||||
var target = $('#import_upload_target');
|
||||
var form = $('#import_upload_form');
|
||||
var totalSize=0;
|
||||
if(file.size > $('#max_upload').val()){
|
||||
OC.dialogs.alert(t('contacts','The file you are trying to upload exceed the maximum size for file uploads on this server.'), t('contacts', 'Error'));
|
||||
return;
|
||||
} else {
|
||||
target.load(function(){
|
||||
var response=jQuery.parseJSON(target.contents().text());
|
||||
if(response != undefined && response.status == 'success'){
|
||||
Contacts.UI.Addressbooks.doImport(response.data.path, response.data.file);
|
||||
}else{
|
||||
OC.dialogs.alert(response.data.message, t('contacts', 'Error'));
|
||||
}
|
||||
});
|
||||
form.submit();
|
||||
}
|
||||
},
|
||||
importAddressbook:function(object){
|
||||
var tr = $(document.createElement('tr'))
|
||||
.load(OC.filePath('contacts', 'ajax', 'importaddressbook.php'));
|
||||
$(object).closest('tr').after(tr).hide();
|
||||
},
|
||||
doImport:function(path, file){
|
||||
$(Contacts.UI.Addressbooks.droptarget).html(t('contacts', 'Importing...'));
|
||||
Contacts.UI.loading(Contacts.UI.Addressbooks.droptarget, true);
|
||||
var id = $('#importaddressbook_dialog').find('#book').val();
|
||||
$.post(OC.filePath('contacts', '', 'import.php'), { id: id, path: path, file: file, fstype: 'OC_FilesystemView' },
|
||||
doImport:function(file, aid){
|
||||
$.post(OC.filePath('contacts', '', 'import.php'), { id: aid, file: file, fstype: 'OC_FilesystemView' },
|
||||
function(jsondata){
|
||||
if(jsondata.status == 'success'){
|
||||
Contacts.UI.Addressbooks.droptarget.html(t('contacts', 'Import done. Success/Failure: ')+jsondata.data.imported+'/'+jsondata.data.failed);
|
||||
$('#chooseaddressbook_dialog').find('#close_button').val(t('contacts', 'OK'));
|
||||
Contacts.UI.Contacts.update();
|
||||
setTimeout(
|
||||
function() {
|
||||
$(Contacts.UI.Addressbooks.droptarget).html(Contacts.UI.Addressbooks.droptext);
|
||||
}, 5000);
|
||||
} else {
|
||||
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
|
||||
if(jsondata.status != 'success'){
|
||||
Contacts.UI.notify({message:jsondata.data.message});
|
||||
}
|
||||
});
|
||||
Contacts.UI.loading(Contacts.UI.Addressbooks.droptarget, false);
|
||||
return false;
|
||||
},
|
||||
submit:function(button, bookid){
|
||||
var displayname = $("#displayname_"+bookid).val().trim();
|
||||
|
@ -1582,6 +1477,7 @@ Contacts={
|
|||
if(!added) {
|
||||
$(droplist).append(dragitem.detach());
|
||||
}
|
||||
dragitem.attr('data-bookid', droptarget.data('id'))
|
||||
dragitem.data('bookid', droptarget.data('id'));
|
||||
Contacts.UI.Contacts.scrollTo(dragitem.data('id'));
|
||||
} else {
|
||||
|
@ -1590,28 +1486,46 @@ Contacts={
|
|||
});
|
||||
},
|
||||
// Reload the contacts list.
|
||||
update:function(id, aid, start){
|
||||
update:function(params){
|
||||
if(!params) { params = {}; }
|
||||
if(!params.start) {
|
||||
if(params.aid) {
|
||||
$('#contacts h3[data-id="'+params.aid+'"],#contacts ul[data-id="'+params.aid+'"]').remove();
|
||||
} else {
|
||||
$('#contacts').empty();
|
||||
}
|
||||
}
|
||||
self = this;
|
||||
console.log('update: ' + aid + ' ' + start);
|
||||
console.log('update: ' + params.cid + ' ' + params.aid + ' ' + params.start);
|
||||
var firstrun = false;
|
||||
var opts = {};
|
||||
opts['startat'] = (start?start:0);
|
||||
if(aid) {
|
||||
opts['aid'] = aid;
|
||||
opts['startat'] = (params.start?params.start:0);
|
||||
if(params.aid) {
|
||||
opts['aid'] = params.aid;
|
||||
}
|
||||
$.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),opts,function(jsondata){
|
||||
if(jsondata.status == 'success'){
|
||||
var books = jsondata.data.entries;
|
||||
$.each(jsondata.data.entries, function(b, book) {
|
||||
$.each(books, function(b, book) {
|
||||
if($('#contacts h3[data-id="'+b+'"]').length == 0) {
|
||||
firstrun = true;
|
||||
|
||||
if($('#contacts h3').length == 0) {
|
||||
$('#contacts').html('<h3 class="addressbook" data-id="'+b+'">'+book.displayname+'</h3><ul class="contacts hidden" data-id="'+b+'"></ul>');
|
||||
$('#contacts').html('<h3 class="addressbook" contextmenu="addressbookmenu" data-id="'+b+'">'+book.displayname+'</h3><ul class="contacts hidden" data-id="'+b+'"></ul>');
|
||||
} else {
|
||||
if(!$('#contacts h3[data-id="'+b+'"]').length) {
|
||||
$('<h3 class="addressbook" data-id="'+b+'">'+book.displayname+'</h3><ul class="contacts hidden" data-id="'+b+'"></ul>')
|
||||
.appendTo('#contacts');
|
||||
var item = $('<h3 class="addressbook" contextmenu="addressbookmenu" data-id="'+b+'">'+book.displayname+'</h3><ul class="contacts hidden" data-id="'+b+'"></ul>')
|
||||
var added = false;
|
||||
$('#contacts h3').each(function(){
|
||||
if ($(this).text().toLowerCase() > book.displayname.toLowerCase()) {
|
||||
$(this).before(item).fadeIn('fast');
|
||||
added = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if(!added) {
|
||||
$('#contacts').append(item);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$('#contacts h3[data-id="'+b+'"]').on('click', function(event) {
|
||||
|
@ -1621,7 +1535,7 @@ Contacts={
|
|||
return false;
|
||||
});
|
||||
var accept = 'li:not([data-bookid="'+b+'"])';
|
||||
$('#contacts h3[data-id="'+b+'"]').droppable({
|
||||
$('#contacts h3[data-id="'+b+'"],#contacts ul[data-id="'+b+'"]').droppable({
|
||||
drop: Contacts.UI.Contacts.drop,
|
||||
activeClass: 'ui-state-hover',
|
||||
accept: accept
|
||||
|
@ -1639,7 +1553,7 @@ Contacts={
|
|||
var numsiblings = $('.contacts li[data-bookid="'+bookid+'"]').length;
|
||||
if (isInView && numsiblings >= self.batchnum) {
|
||||
console.log('This would be a good time to load more contacts.');
|
||||
Contacts.UI.Contacts.update(id, bookid, $('#contacts li[data-bookid="'+bookid+'"]').length);
|
||||
Contacts.UI.Contacts.update({cid:params.cid, aid:bookid, start:$('#contacts li[data-bookid="'+bookid+'"]').length});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1658,7 +1572,7 @@ Contacts={
|
|||
$('#contacts h3').first().addClass('active');
|
||||
}
|
||||
if(opts['startat'] == 0) { // only update card on first load.
|
||||
Contacts.UI.Card.update();
|
||||
Contacts.UI.Card.update(params);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
@ -1698,7 +1612,7 @@ $(document).ready(function(){
|
|||
|
||||
// Load a contact.
|
||||
$('.contacts').keydown(function(event) {
|
||||
if(event.which == 13) {
|
||||
if(event.which == 13 || event.which == 32) {
|
||||
$('.contacts').click();
|
||||
}
|
||||
});
|
||||
|
@ -1725,34 +1639,11 @@ $(document).ready(function(){
|
|||
return false;
|
||||
});
|
||||
|
||||
/*$('.contacts li').bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
|
||||
if (isInView) { //NOTE: I've kept all conditions for future reference ;-)
|
||||
// element is now visible in the viewport
|
||||
if (visiblePartY == 'top') {
|
||||
// top part of element is visible
|
||||
} else if (visiblePartY == 'bottom') {
|
||||
// bottom part of element is visible
|
||||
} else {
|
||||
// whole part of element is visible
|
||||
if (!$(this).find('a').attr('style')) {
|
||||
//alert($(this).data('id') + ' has background: ' + $(this).attr('style'));
|
||||
$(this).find('a').css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+$(this).data('id')+') no-repeat');
|
||||
}// else {
|
||||
// alert($(this).data('id') + ' has style ' + $(this).attr('style').match('url'));
|
||||
//}
|
||||
}
|
||||
} else {
|
||||
// element has gone out of viewport
|
||||
}
|
||||
});*/
|
||||
|
||||
$('.contacts_property').live('change', function(){
|
||||
Contacts.UI.Card.saveProperty(this);
|
||||
});
|
||||
|
||||
/**
|
||||
* Upload function for dropped files. Should go in the Contacts class/object.
|
||||
*/
|
||||
// Upload function for dropped contact photos files. Should go in the Contacts class/object.
|
||||
$.fileUpload = function(files){
|
||||
var file = files[0];
|
||||
if(file.size > $('#max_upload').val()){
|
||||
|
@ -1800,6 +1691,210 @@ $(document).ready(function(){
|
|||
xhr.send(file);
|
||||
}
|
||||
|
||||
$(document).bind('drop dragover', function (e) {
|
||||
e.preventDefault(); // prevent browser from doing anything, if file isn't dropped in dropZone
|
||||
});
|
||||
|
||||
//add multiply file upload attribute to all browsers except konqueror (which crashes when it's used)
|
||||
if(navigator.userAgent.search(/konqueror/i)==-1){
|
||||
$('#import_upload_start').attr('multiple','multiple')
|
||||
}
|
||||
// Import using jquery.fileupload
|
||||
$(function() {
|
||||
var uploadingFiles = {}, numfiles = 0, uploadedfiles = 0, retries = 0;
|
||||
var aid;
|
||||
|
||||
$('#import_upload_start').fileupload({
|
||||
dropZone: $('#contacts'), // restrict dropZone to contacts list.
|
||||
acceptFileTypes: /^text\/(directory|vcard|x-vcard)$/i,
|
||||
add: function(e, data) {
|
||||
var files = data.files;
|
||||
var totalSize=0;
|
||||
if(files) {
|
||||
numfiles += files.length; uploadedfiles = 0;
|
||||
for(var i=0;i<files.length;i++) {
|
||||
if(files[i].size ==0 && files[i].type== '') {
|
||||
OC.dialogs.alert(t('files', 'Unable to upload your file as it is a directory or has 0 bytes'), t('files', 'Upload Error'));
|
||||
return;
|
||||
}
|
||||
totalSize+=files[i].size;
|
||||
}
|
||||
}
|
||||
if(totalSize>$('#max_upload').val()){
|
||||
OC.dialogs.alert(t('contacts','The file you are trying to upload exceed the maximum size for file uploads on this server.'), t('contacts','Upload too large'));
|
||||
numfiles = uploadedfiles = retries = aid = 0;
|
||||
uploadingFiles = {};
|
||||
return;
|
||||
}else{
|
||||
if($.support.xhrFileUpload) {
|
||||
for(var i=0;i<files.length;i++){
|
||||
var fileName = files[i].name;
|
||||
var dropTarget;
|
||||
if($(e.originalEvent.target).is('h3')) {
|
||||
dropTarget = $(e.originalEvent.target).next('ul');
|
||||
} else {
|
||||
dropTarget = $(e.originalEvent.target).closest('ul');
|
||||
}
|
||||
if(dropTarget && dropTarget.hasClass('contacts')) { // TODO: More thorough check for where we are.
|
||||
aid = dropTarget.attr('data-id');
|
||||
} else {
|
||||
aid = undefined;
|
||||
}
|
||||
var jqXHR = $('#import_upload_start').fileupload('send', {files: files[i],
|
||||
formData: function(form) {
|
||||
var formArray = form.serializeArray();
|
||||
formArray['aid'] = aid;
|
||||
return formArray;
|
||||
}})
|
||||
.success(function(result, textStatus, jqXHR) {
|
||||
if(result.status == 'success') {
|
||||
// import the file
|
||||
uploadedfiles += 1;
|
||||
} else {
|
||||
Contacts.UI.notify({message:jsondata.data.message});
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.error(function(jqXHR, textStatus, errorThrown) {
|
||||
console.log(textStatus);
|
||||
Contacts.UI.notify({message:errorThrown + ': ' + textStatus,});
|
||||
});
|
||||
uploadingFiles[fileName] = jqXHR;
|
||||
}
|
||||
} else {
|
||||
data.submit().success(function(data, status) {
|
||||
response = jQuery.parseJSON(data[0].body.innerText);
|
||||
if(response[0] != undefined && response[0].status == 'success') {
|
||||
var file=response[0];
|
||||
delete uploadingFiles[file.name];
|
||||
$('tr').filterAttr('data-file',file.name).data('mime',file.mime);
|
||||
var size = $('tr').filterAttr('data-file',file.name).find('td.filesize').text();
|
||||
if(size==t('files','Pending')){
|
||||
$('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size);
|
||||
}
|
||||
FileList.loadingDone(file.name);
|
||||
} else {
|
||||
Contacts.UI.notify({message:response.data.message});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: function(e, data) {
|
||||
console.log('fail');
|
||||
Contacts.UI.notify({message:data.errorThrown + ': ' + data.textStatus});
|
||||
// TODO: Remove file from upload queue.
|
||||
},
|
||||
progressall: function(e, data) {
|
||||
var progress = (data.loaded/data.total)*50;
|
||||
$('#uploadprogressbar').progressbar('value',progress);
|
||||
},
|
||||
start: function(e, data) {
|
||||
$('#uploadprogressbar').progressbar({value:0});
|
||||
$('#uploadprogressbar').fadeIn();
|
||||
if(data.dataType != 'iframe ') {
|
||||
$('#upload input.stop').show();
|
||||
}
|
||||
},
|
||||
stop: function(e, data) {
|
||||
// stop only gets fired once so we collect uploaded items here.
|
||||
var importFiles = function(aid, fileList) {
|
||||
// Create a closure that can be called from different places.
|
||||
if(numfiles != uploadedfiles) {
|
||||
Contacts.UI.notify({message:t('contacts', 'Not all files uploaded. Retrying...')});
|
||||
retries += 1;
|
||||
if(retries > 0) {
|
||||
numfiles = uploadedfiles = retries = aid = 0;
|
||||
uploadingFiles = {};
|
||||
OC.dialogs.alert(t('contacts', 'Something went wrong with the upload, please retry.'), t('contacts', 'Error'));
|
||||
return;
|
||||
}
|
||||
setTimeout(function() { // Just to let any uploads finish
|
||||
importFiles(aid, uploadingFiles);
|
||||
}, 1000);
|
||||
}
|
||||
$('#uploadprogressbar').progressbar('value',50);
|
||||
var todo = uploadedfiles;
|
||||
$.each(fileList, function(fileName, data) {
|
||||
Contacts.UI.Addressbooks.doImport(fileName, aid);
|
||||
delete fileList[fileName];
|
||||
numfiles -= 1; uploadedfiles -= 1;
|
||||
$('#uploadprogressbar').progressbar('value',50+(50/(todo-uploadedfiles)));
|
||||
})
|
||||
$('#uploadprogressbar').progressbar('value',100);
|
||||
$('#uploadprogressbar').fadeOut();
|
||||
setTimeout(function() {
|
||||
Contacts.UI.Contacts.update({aid:aid});
|
||||
numfiles = uploadedfiles = retries = aid = 0;
|
||||
}, 1000);
|
||||
}
|
||||
if(!aid) {
|
||||
// Either selected with filepicker or dropped outside of an address book.
|
||||
$.getJSON(OC.filePath('contacts', 'ajax', 'selectaddressbook.php'),{},function(jsondata) {
|
||||
if(jsondata.status == 'success') {
|
||||
if($('#selectaddressbook_dialog').dialog('isOpen') == true) {
|
||||
$('#selectaddressbook_dialog').dialog('moveToTop');
|
||||
} else {
|
||||
$('#dialog_holder').html(jsondata.data.page).ready(function($) {
|
||||
$('#selectaddressbook_dialog').dialog({
|
||||
modal: true, height: 'auto', width: 'auto',
|
||||
buttons: {
|
||||
'Ok':function() {
|
||||
aid = $('#selectaddressbook_dialog').find('input:checked').val();
|
||||
if(aid == 'new') {
|
||||
var displayname = $('#selectaddressbook_dialog').find('input.name').val();
|
||||
var description = $('#selectaddressbook_dialog').find('input.desc').val();
|
||||
if(!displayname.trim()) {
|
||||
OC.dialogs.alert(t('contacts', 'The address book name cannot be empty.'), t('contacts', 'Error'));
|
||||
return false;
|
||||
}
|
||||
$(this).dialog('close');
|
||||
Contacts.UI.Addressbooks.addAddressbook(displayname, description, function(addressbook){
|
||||
aid = addressbook.id;
|
||||
setTimeout(function() {
|
||||
importFiles(aid, uploadingFiles);
|
||||
}, 500);
|
||||
console.log('aid ' + aid);
|
||||
});
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
importFiles(aid, uploadingFiles);
|
||||
}, 500);
|
||||
console.log('aid ' + aid);
|
||||
$(this).dialog('close');
|
||||
}
|
||||
},
|
||||
'Cancel':function() {
|
||||
$(this).dialog('close');
|
||||
numfiles = uploadedfiles = retries = aid = 0;
|
||||
uploadingFiles = {};
|
||||
$('#uploadprogressbar').fadeOut();
|
||||
}
|
||||
},
|
||||
close: function(event, ui) {
|
||||
// TODO: If numfiles != 0 delete tmp files after a timeout.
|
||||
$(this).dialog('destroy').remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Dropped on an address book or it's list.
|
||||
setTimeout(function() { // Just to let any uploads finish
|
||||
importFiles(aid, uploadingFiles);
|
||||
}, 1000);
|
||||
}
|
||||
if(data.dataType != 'iframe ') {
|
||||
$('#upload input.stop').hide();
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
Contacts.UI.loadHandlers();
|
||||
Contacts.UI.Contacts.update(id);
|
||||
Contacts.UI.Contacts.update({cid:id});
|
||||
});
|
||||
|
|
|
@ -62,8 +62,8 @@
|
|||
|
||||
function getViewportOffset() {
|
||||
return {
|
||||
top: w.pageYOffset || documentElement.scrollTop || d.body.scrollTop,
|
||||
left: w.pageXOffset || documentElement.scrollLeft || d.body.scrollLeft
|
||||
top: w.pageYOffset || documentElement.scrollTop || (d.body?d.body.scrollTop:0),
|
||||
left: w.pageXOffset || documentElement.scrollLeft || (d.body?d.body.scrollLeft:0)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ class OC_Contacts_Addressbook{
|
|||
if(is_null($uid)) {
|
||||
$uid = OCP\USER::getUser();
|
||||
}
|
||||
$id = self::add($uid,'default','Default Address Book');
|
||||
$id = self::add($uid,'Contacts','Default Address Book');
|
||||
if($id !== false) {
|
||||
self::setActive($id, true);
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ class OC_Contacts_Addressbook{
|
|||
* @return string new name
|
||||
*/
|
||||
public static function createURI($name,$existing){
|
||||
$name = strtolower($name);
|
||||
$name = str_replace(' ', '_', strtolower($name));
|
||||
$newname = $name;
|
||||
$i = 1;
|
||||
while(in_array($newname,$existing)){
|
||||
|
|
|
@ -41,7 +41,7 @@ class OC_Contacts_App {
|
|||
$card = OC_Contacts_VCard::find( $id );
|
||||
if( $card === false ) {
|
||||
OCP\Util::writeLog('contacts', 'Contact could not be found: '.$id, OCP\Util::ERROR);
|
||||
OCP\JSON::error(array('data' => array( 'message' => self::$l10n->t('Contact could not be found.').' '.$id)));
|
||||
OCP\JSON::error(array('data' => array( 'message' => self::$l10n->t('Contact could not be found.').' '.print_r($id, true))));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<div id='notification'></div>
|
||||
<script type='text/javascript'>
|
||||
var totalurl = '<?php echo OCP\Util::linkToRemote('carddav'); ?>addressbooks';
|
||||
var categories = <?php echo json_encode($_['categories']); ?>;
|
||||
|
@ -5,13 +6,21 @@
|
|||
var lang = '<?php echo OCP\Config::getUserValue(OCP\USER::getUser(), 'core', 'lang', 'en'); ?>';
|
||||
</script>
|
||||
<div id="leftcontent">
|
||||
<div class="hidden" id="statusbar"></div>
|
||||
<div id="contacts">
|
||||
</div>
|
||||
<div id="uploadprogressbar"></div>
|
||||
<div id="bottomcontrols">
|
||||
<form>
|
||||
<button class="svg" id="contacts_newcontact" title="<?php echo $l->t('Add Contact'); ?>"><img class="svg" src="<?php echo OCP\Util::imagePath('contacts', 'contact-new.svg'); ?>" alt="<?php echo $l->t('Add Contact'); ?>" /></button>
|
||||
<form id="import_upload_form" action="<?php echo OCP\Util::linkTo('contacts', 'ajax/uploadimport.php'); ?>" method="post" enctype="multipart/form-data" target="import_upload_target">
|
||||
<button class="svg" id="contacts_newcontact" title="<?php echo $l->t('Add Contact'); ?>"><img class="svg" src="<?php echo OCP\Util::imagePath('contacts', 'contact-new.svg'); ?>" alt="<?php echo $l->t('Add Contact'); ?>" /></button>
|
||||
<span class="svg" id="contacts_import" title="<?php echo $l->t('Import'); ?>">
|
||||
<input class="float" id="import_upload_start" type="file" accept="text/directory,text/vcard,text/x-vcard" name="importfile" />
|
||||
<img class="svg" src="core/img/actions/upload.svg" alt="<?php echo $l->t('Import'); ?>" />
|
||||
</span>
|
||||
<button class="svg" id="chooseaddressbook" title="<?php echo $l->t('Addressbooks'); ?>"><img class="svg" src="core/img/actions/settings.svg" alt="<?php echo $l->t('Addressbooks'); ?>" /></button>
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $_['uploadMaxFilesize'] ?>" id="max_upload">
|
||||
</form>
|
||||
<iframe name="import_upload_target" id='import_upload_target' src=""></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<div id="rightcontent" class="rightcontent" data-id="<?php echo $_['id']; ?>">
|
||||
|
@ -27,3 +36,7 @@
|
|||
<!-- Dialogs -->
|
||||
<div id="dialog_holder"></div>
|
||||
<!-- End of Dialogs -->
|
||||
<menu type="context" id="addressbookmenu">
|
||||
<menuitem label="Delete" icon="core/img/actions/delete.svg" onclick="alert('Really? ' + $(this).attr('data-id'))"></menuitem>
|
||||
<menuitem label="Rename" icon="core/img/actions/rename.svg" onclick="alert('Can\'t do that')"></menuitem>
|
||||
</menu>
|
||||
|
|
|
@ -14,7 +14,6 @@ for($i = 0; $i < count($option_addressbooks); $i++){
|
|||
<tr>
|
||||
<td colspan="5" style="padding: 0.5em;">
|
||||
<a class="button" href="#" onclick="Contacts.UI.Addressbooks.newAddressbook(this);"><?php echo $l->t('New Address Book') ?></a>
|
||||
<a class="button" href="#" onclick="Contacts.UI.Addressbooks.importAddressbook(this);"><?php echo $l->t('Import from VCF') ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
?>
|
||||
<td id="importaddressbook_dialog" colspan="6">
|
||||
<table>
|
||||
<tr>
|
||||
<th><?php echo $l->t('Select address book to import to:') ?></th>
|
||||
<td>
|
||||
<form id="import_upload_form" action="<?php echo OCP\Util::linkTo('contacts', 'ajax/uploadimport.php'); ?>" method="post" enctype="multipart/form-data" target="import_upload_target">
|
||||
<input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>">
|
||||
<select id="book" name="book" class="float">
|
||||
<?php
|
||||
$contacts_options = OC_Contacts_Addressbook::all(OCP\USER::getUser());
|
||||
echo OCP\html_select_options($contacts_options, $contacts_options[0]['id'], array('value'=>'id', 'label'=>'displayname'));
|
||||
?>
|
||||
</select>
|
||||
<span id="import_drop_target" class="droptarget float"><?php echo $l->t("Drop a VCF file<br />to import contacts."); ?> (Max. <?php echo $_['uploadMaxHumanFilesize']; ?>)</span>
|
||||
<a class="svg upload float" title="<?php echo $l->t('Select from HD'); ?>">
|
||||
<input class="float" id="import_upload_start" type="file" accept="text/*" name="importfile" /></a>
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $_['uploadMaxFilesize'] ?>" id="max_upload">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<input id="close_button" style="float: left;" type="button" onclick="Contacts.UI.Addressbooks.cancel(this);" value="<?php echo $l->t("Cancel"); ?>">
|
||||
<iframe name="import_upload_target" id='import_upload_target' src=""></iframe>
|
||||
</td>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
Contacts.UI.Addressbooks.loadImportHandlers();
|
||||
});
|
||||
</script>
|
27
apps/contacts/templates/part.selectaddressbook.php
Normal file
27
apps/contacts/templates/part.selectaddressbook.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<div id="selectaddressbook_dialog" title="<?php echo $l->t("Select Address Books"); ?>">
|
||||
<form>
|
||||
<table style="width: 100%">
|
||||
<?php foreach($_['addressbooks'] as $idx => $addressbook) { ?>
|
||||
<tr>
|
||||
<td>
|
||||
<input id="book_<?php echo $addressbook['id']; ?>" name="book" type="radio" value="<?php echo $addressbook['id']; ?>" <?php echo ($idx==0?'checked="checked"':'')?>>
|
||||
</td>
|
||||
<td>
|
||||
<label for="book_<?php echo $addressbook['id']; ?>"><?php echo $addressbook['displayname']; ?></label>
|
||||
</td>
|
||||
<td><?php echo $addressbook['description']; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<td>
|
||||
<input id="book_new" name="book" type="radio" value="new">
|
||||
</td>
|
||||
<th>
|
||||
<input type="text" class="name" name="displayname" placeholder="<?php echo $l->t("Enter name"); ?>" />
|
||||
</th>
|
||||
<td><input type="text" class="desc" name="description" placeholder="<?php echo $l->t("Enter description"); ?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -1 +1 @@
|
|||
1.1.1
|
||||
1.1.3
|
|
@ -14,7 +14,7 @@ FileList={
|
|||
var extension=false;
|
||||
}
|
||||
html+='<td class="filename" style="background-image:url('+img+')"><input type="checkbox" />';
|
||||
html+='<a class="name" href="download.php?file='+$('#dir').val()+'/'+name+'"><span class="nametext">'+basename
|
||||
html+='<a class="name" href="download.php?file='+$('#dir').val().replace(/</, '<').replace(/>/, '>')+'/'+name+'"><span class="nametext">'+basename
|
||||
if(extension){
|
||||
html+='<span class="extension">'+extension+'</span>';
|
||||
}
|
||||
|
|
|
@ -10,4 +10,4 @@ $subject = $user.' shared a '.$type.' with you';
|
|||
$link = $_POST['link'];
|
||||
$text = $user.' shared the '.$type.' '.$_POST['file'].' with you. It is available for download here: '.$link;
|
||||
$fromaddress = OCP\Config::getUserValue($user, 'settings', 'email', 'sharing-noreply@'.OCP\Util::getServerHost());
|
||||
OC_Mail::send($_POST['toaddress'], $_POST['toaddress'], $subject, $text, $fromaddress, $user);
|
||||
OCP\Util::sendMail($_POST['toaddress'], $_POST['toaddress'], $subject, $text, $fromaddress, $user);
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.2.1
|
||||
0.2.2
|
|
@ -28,7 +28,7 @@
|
|||
OCP\JSON::checkLoggedIn();
|
||||
OCP\App::checkAppEnabled('files_versions');
|
||||
|
||||
$versions = new OCA_Versions\Storage( new OC_FilesystemView('') );
|
||||
$versions = new OCA_Versions\Storage();
|
||||
|
||||
if( $versions->expireAll() ){
|
||||
|
||||
|
|
16
apps/files_versions/appinfo/update.php
Normal file
16
apps/files_versions/appinfo/update.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
$installedVersion=OCP\Config::getAppValue('files_versions', 'installed_version');
|
||||
// move versions to new directory
|
||||
if (version_compare($installedVersion, '1.0.2', '<')) {
|
||||
$users = \OCP\User::getUsers();
|
||||
$datadir = \OCP\Config::getSystemValue('datadirectory').'/';
|
||||
foreach ($users as $user) {
|
||||
$oldPath = $datadir.$user.'/versions';
|
||||
$newPath = $datadir.$user.'/files_versions';
|
||||
if(is_dir($oldPath)) {
|
||||
rename($oldPath, $newPath);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1 +1 @@
|
|||
1.0.1
|
||||
1.0.2
|
|
@ -30,7 +30,7 @@ if ( isset( $_GET['path'] ) ) {
|
|||
$path = $_GET['path'];
|
||||
$path = strip_tags( $path );
|
||||
$tmpl->assign( 'path', $path );
|
||||
$versions = new OCA_Versions\Storage( new OC_FilesystemView('') );
|
||||
$versions = new OCA_Versions\Storage();
|
||||
|
||||
// roll back to old version if button clicked
|
||||
if( isset( $_GET['revert'] ) ) {
|
||||
|
|
|
@ -30,41 +30,46 @@ class Hooks {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erase versions of deleted file
|
||||
* @param array
|
||||
*
|
||||
* This function is connected to the delete signal of OC_Filesystem
|
||||
* cleanup the versions directory if the actual file gets deleted
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Erase versions of deleted file
|
||||
* @param array
|
||||
*
|
||||
* This function is connected to the delete signal of OC_Filesystem
|
||||
* cleanup the versions directory if the actual file gets deleted
|
||||
*/
|
||||
public static function remove_hook($params) {
|
||||
$rel_path = $params['path'];
|
||||
$abs_path = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_path.'.v';
|
||||
if(Storage::isversioned($rel_path)) {
|
||||
$versions = Storage::getVersions($rel_path);
|
||||
foreach ($versions as $v){
|
||||
unlink($abs_path . $v['version']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief rename/move versions of renamed/moved files
|
||||
* @param array with oldpath and newpath
|
||||
*
|
||||
* This function is connected to the rename signal of OC_Filesystem and adjust the name and location
|
||||
* of the stored versions along the actual file
|
||||
*/
|
||||
$versions_fileview = \OCP\Files::getStorage('files_versions');
|
||||
$rel_path = $params['path'];
|
||||
$abs_path = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('').$rel_path.'.v';
|
||||
if(Storage::isversioned($rel_path)) {
|
||||
$versions = Storage::getVersions($rel_path);
|
||||
foreach ($versions as $v){
|
||||
unlink($abs_path . $v['version']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief rename/move versions of renamed/moved files
|
||||
* @param array with oldpath and newpath
|
||||
*
|
||||
* This function is connected to the rename signal of OC_Filesystem and adjust the name and location
|
||||
* of the stored versions along the actual file
|
||||
*/
|
||||
public static function rename_hook($params) {
|
||||
$rel_oldpath = $params['oldpath'];
|
||||
$abs_oldpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_oldpath.'.v';
|
||||
$abs_newpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$params['newpath'].'.v';
|
||||
$versions_fileview = \OCP\Files::getStorage('files_versions');
|
||||
$rel_oldpath = $params['oldpath'];
|
||||
$abs_oldpath = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('').$rel_oldpath.'.v';
|
||||
$abs_newpath = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('').$params['newpath'].'.v';
|
||||
if(Storage::isversioned($rel_oldpath)) {
|
||||
$versions = Storage::getVersions($rel_oldpath);
|
||||
foreach ($versions as $v){
|
||||
rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']);
|
||||
}
|
||||
}
|
||||
$info=pathinfo($abs_newpath);
|
||||
if(!file_exists($info['dirname'])) mkdir($info['dirname'],0700,true);
|
||||
$versions = Storage::getVersions($rel_oldpath);
|
||||
foreach ($versions as $v){
|
||||
rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,41 +22,26 @@ class Storage {
|
|||
// - files_versionsfolder
|
||||
// - files_versionsblacklist
|
||||
// - files_versionsmaxfilesize
|
||||
// - files_versionsinterval
|
||||
// - files_versionmaxversions
|
||||
// - files_versionsinterval
|
||||
// - files_versionmaxversions
|
||||
//
|
||||
// todo:
|
||||
// - finish porting to OC_FilesystemView to enable network transparency
|
||||
// - add transparent compression. first test if it´s worth it.
|
||||
|
||||
const DEFAULTENABLED=true;
|
||||
const DEFAULTFOLDER='versions';
|
||||
const DEFAULTBLACKLIST='avi mp3 mpg mp4 ctmp';
|
||||
const DEFAULTMAXFILESIZE=1048576; // 10MB
|
||||
const DEFAULTENABLED=true;
|
||||
const DEFAULTBLACKLIST='avi mp3 mpg mp4 ctmp';
|
||||
const DEFAULTMAXFILESIZE=1048576; // 10MB
|
||||
const DEFAULTMININTERVAL=60; // 1 min
|
||||
const DEFAULTMAXVERSIONS=50;
|
||||
|
||||
|
||||
private $view;
|
||||
|
||||
function __construct( $view ) {
|
||||
|
||||
$this->view = $view;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* init the versioning and create the versions folder.
|
||||
*/
|
||||
public static function init() {
|
||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||
// create versions folder
|
||||
$foldername=\OCP\Config::getSystemValue('datadirectory').'/'. \OCP\USER::getUser() .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER);
|
||||
if(!is_dir($foldername)){
|
||||
mkdir($foldername);
|
||||
}
|
||||
}
|
||||
}
|
||||
function __construct() {
|
||||
|
||||
$this->view = \OCP\Files::getStorage('files_versions');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* listen to write event.
|
||||
|
@ -75,11 +60,11 @@ class Storage {
|
|||
*/
|
||||
public function store($filename) {
|
||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||
|
||||
|
||||
$files_view = \OCP\Files::getStorage("files");
|
||||
$users_view = \OCP\Files::getStorage("files_versions");
|
||||
$users_view->chroot(\OCP\User::getUser().'/');
|
||||
|
||||
|
||||
if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) {
|
||||
$pos = strpos($source, '/files', 1);
|
||||
$uid = substr($source, 1, $pos - 1);
|
||||
|
@ -87,15 +72,14 @@ class Storage {
|
|||
} else {
|
||||
$uid = \OCP\User::getUser();
|
||||
}
|
||||
$versionsFolderName=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER);
|
||||
$filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/files';
|
||||
Storage::init();
|
||||
|
||||
|
||||
$versionsFolderName=\OCP\Config::getSystemValue('datadirectory') . $this->view->getAbsolutePath('');
|
||||
|
||||
//check if source file already exist as version to avoid recursions.
|
||||
if ($users_view->file_exists($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// check if filename is a directory
|
||||
if($files_view->is_dir($filename)){
|
||||
return false;
|
||||
|
@ -110,7 +94,7 @@ class Storage {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check filesize
|
||||
if($files_view->filesize($filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)){
|
||||
return false;
|
||||
|
@ -129,12 +113,12 @@ class Storage {
|
|||
|
||||
|
||||
// create all parent folders
|
||||
$info=pathinfo($filename);
|
||||
if(!file_exists($versionsFolderName.'/'.$info['dirname'])) mkdir($versionsFolderName.'/'.$info['dirname'],0700,true);
|
||||
$info=pathinfo($filename);
|
||||
if(!file_exists($versionsFolderName.'/'.$info['dirname'])) mkdir($versionsFolderName.'/'.$info['dirname'],0700,true);
|
||||
|
||||
// store a new version of a file
|
||||
@$users_view->copy('files'.$filename, 'versions'.$filename.'.v'.time());
|
||||
|
||||
@$users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.time());
|
||||
|
||||
// expire old revisions if necessary
|
||||
Storage::expire($filename);
|
||||
}
|
||||
|
@ -145,11 +129,11 @@ class Storage {
|
|||
* rollback to an old version of a file.
|
||||
*/
|
||||
public static function rollback($filename,$revision) {
|
||||
|
||||
|
||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||
$users_view = \OCP\Files::getStorage("files_versions");
|
||||
$users_view->chroot(\OCP\User::getUser().'/');
|
||||
|
||||
|
||||
if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) {
|
||||
$pos = strpos($source, '/files', 1);
|
||||
$uid = substr($source, 1, $pos - 1);
|
||||
|
@ -157,23 +141,20 @@ class Storage {
|
|||
} else {
|
||||
$uid = \OCP\User::getUser();
|
||||
}
|
||||
$versionsFolderName=\OCP\Config::getSystemValue('datadirectory').'/'.$uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER);
|
||||
|
||||
$filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/files';
|
||||
|
||||
|
||||
// rollback
|
||||
if( @$users_view->copy('versions'.$filename.'.v'.$revision, 'files'.$filename) ) {
|
||||
|
||||
if( @$users_view->copy('files_versions'.$filename.'.v'.$revision, 'files'.$filename) ) {
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -181,18 +162,17 @@ class Storage {
|
|||
*/
|
||||
public static function isversioned($filename) {
|
||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||
$versions_fileview = \OCP\Files::getStorage("files_versions");
|
||||
if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) {
|
||||
$pos = strpos($source, '/files', 1);
|
||||
$uid = substr($source, 1, $pos - 1);
|
||||
$filename = substr($source, $pos + 6);
|
||||
} else {
|
||||
$uid = \OCP\User::getUser();
|
||||
}
|
||||
$versionsFolderName=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER);
|
||||
|
||||
$versionsFolderName=\OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath('');
|
||||
|
||||
// check for old versions
|
||||
$matches=glob($versionsFolderName.'/'.$filename.'.v*');
|
||||
if(count($matches)>1){
|
||||
$matches=glob($versionsFolderName.$filename.'.v*');
|
||||
if(count($matches)>0){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
|
@ -203,17 +183,17 @@ class Storage {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief get a list of all available versions of a file in descending chronological order
|
||||
* @param $filename file to find versions of, relative to the user files dir
|
||||
* @param $count number of versions to return
|
||||
* @returns array
|
||||
*/
|
||||
public static function getVersions( $filename, $count = 0 ) {
|
||||
|
||||
if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
|
||||
|
||||
|
||||
/**
|
||||
* @brief get a list of all available versions of a file in descending chronological order
|
||||
* @param $filename file to find versions of, relative to the user files dir
|
||||
* @param $count number of versions to return
|
||||
* @returns array
|
||||
*/
|
||||
public static function getVersions( $filename, $count = 0 ) {
|
||||
|
||||
if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
|
||||
|
||||
if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) {
|
||||
$pos = strpos($source, '/files', 1);
|
||||
$uid = substr($source, 1, $pos - 1);
|
||||
|
@ -221,70 +201,71 @@ class Storage {
|
|||
} else {
|
||||
$uid = \OCP\User::getUser();
|
||||
}
|
||||
$versionsFolderName = \OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER);
|
||||
$versions = array();
|
||||
|
||||
$versions_fileview = \OCP\Files::getStorage('files_versions');
|
||||
$versionsFolderName = \OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath('');
|
||||
$versions = array();
|
||||
|
||||
// fetch for old versions
|
||||
$matches = glob( $versionsFolderName.'/'.$filename.'.v*' );
|
||||
|
||||
sort( $matches );
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $matches as $ma ) {
|
||||
|
||||
sort( $matches );
|
||||
|
||||
$i = 0;
|
||||
|
||||
$files_view = \OCP\Files::getStorage('files');
|
||||
$local_file = $files_view->getLocalFile($filename);
|
||||
foreach( $matches as $ma ) {
|
||||
|
||||
$i++;
|
||||
$versions[$i]['cur'] = 0;
|
||||
$parts = explode( '.v', $ma );
|
||||
$versions[$i]['version'] = ( end( $parts ) );
|
||||
|
||||
|
||||
// if file with modified date exists, flag it in array as currently enabled version
|
||||
$files_view = \OCP\Files::getStorage('files');
|
||||
$local_file = $files_view->getLocalFile($filename);
|
||||
( \md5_file( $ma ) == \md5_file( $local_file ) ? $versions[$i]['fileMatch'] = 1 : $versions[$i]['fileMatch'] = 0 );
|
||||
|
||||
|
||||
}
|
||||
|
||||
$versions = array_reverse( $versions );
|
||||
|
||||
foreach( $versions as $key => $value ) {
|
||||
|
||||
$versions = array_reverse( $versions );
|
||||
|
||||
foreach( $versions as $key => $value ) {
|
||||
|
||||
// flag the first matched file in array (which will have latest modification date) as current version
|
||||
if ( $versions[$key]['fileMatch'] ) {
|
||||
|
||||
|
||||
$versions[$key]['cur'] = 1;
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$versions = array_reverse( $versions );
|
||||
|
||||
|
||||
// only show the newest commits
|
||||
if( $count != 0 and ( count( $versions )>$count ) ) {
|
||||
|
||||
|
||||
$versions = array_slice( $versions, count( $versions ) - $count );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return( $versions );
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
// if versioning isn't enabled then return an empty array
|
||||
return( array() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
/**
|
||||
* @brief Erase a file's versions which exceed the set quota
|
||||
*/
|
||||
public static function expire($filename) {
|
||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||
// if versioning isn't enabled then return an empty array
|
||||
return( array() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erase a file's versions which exceed the set quota
|
||||
*/
|
||||
public static function expire($filename) {
|
||||
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
||||
|
||||
if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) {
|
||||
$pos = strpos($source, '/files', 1);
|
||||
|
@ -293,36 +274,33 @@ class Storage {
|
|||
} else {
|
||||
$uid = \OCP\User::getUser();
|
||||
}
|
||||
$versionsFolderName=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER);
|
||||
$versions_fileview = \OCP\Files::getStorage("files_versions");
|
||||
$versionsFolderName=\OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath('');
|
||||
|
||||
// check for old versions
|
||||
$matches = glob( $versionsFolderName.'/'.$filename.'.v*' );
|
||||
|
||||
|
||||
if( count( $matches ) > \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ) ) {
|
||||
|
||||
|
||||
$numberToDelete = count( $matches-\OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ) );
|
||||
|
||||
// delete old versions of a file
|
||||
$deleteItems = array_slice( $matches, 0, $numberToDelete );
|
||||
|
||||
|
||||
foreach( $deleteItems as $de ) {
|
||||
|
||||
|
||||
unlink( $versionsFolderName.'/'.$filename.'.v'.$de );
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erase all old versions of all user files
|
||||
* @return true/false
|
||||
*/
|
||||
public function expireAll() {
|
||||
|
||||
$dir = \OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER);
|
||||
|
||||
return $this->view->deleteAll( $dir, true );
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief Erase all old versions of all user files
|
||||
* @return true/false
|
||||
*/
|
||||
public function expireAll() {
|
||||
return $this->view->deleteAll('', true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.5.0
|
||||
0.5.1
|
||||
|
|
|
@ -15,7 +15,7 @@ $(document).ready(function(){
|
|||
|
||||
var images=[];
|
||||
$('#gallerycontent div a').each(function(i,a){
|
||||
images.push({image : a.href, title : a.title, thumb : a.children[0].src, url : 'javascript:$.endSlideshow()'});
|
||||
images.push({image : a.href, title : a.title.replace(/</, '<').replace(/>/, '>'), thumb : a.children[0].src, url : 'javascript:$.endSlideshow()'});
|
||||
});
|
||||
|
||||
if (images.length <= 0) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.4
|
||||
0.4.1
|
|
@ -1,3 +1 @@
|
|||
<?php
|
||||
OCP\CONFIG::setAppValue('core', 'public_host-meta', '/apps/user_webfinger/host-meta.php');
|
||||
OCP\CONFIG::setAppValue('core', 'public_webfinger', '/apps/user_webfinger/webfinger.php');
|
||||
|
|
|
@ -7,4 +7,8 @@
|
|||
<author>Michiel de Jong, Florian Hülsmann</author>
|
||||
<require>4</require>
|
||||
<shipped>true</shipped>
|
||||
<public>
|
||||
<host-meta>host-meta.php</host-meta>
|
||||
<webfinger>webfinger.php</webfinger>
|
||||
</public>
|
||||
</info>
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.3
|
||||
0.3.1
|
72
autotest.sh
Executable file
72
autotest.sh
Executable file
|
@ -0,0 +1,72 @@
|
|||
#
|
||||
# sqlite testing now
|
||||
#
|
||||
echo "Setup environment for sqlite testing ..."
|
||||
DATADIR=data-autotest
|
||||
rm -rf $DATADIR
|
||||
mkdir $DATADIR
|
||||
rm -rf config/config.php
|
||||
#cp autotest/config.sqlite.php config/autoconfig.php
|
||||
cat > ./config/autoconfig.php <<DELIM
|
||||
<?php
|
||||
\$AUTOCONFIG = array (
|
||||
'installed' => false,
|
||||
'dbtype' => 'sqlite',
|
||||
'dbtableprefix' => 'oc_',
|
||||
'datadirectory' => 'data',
|
||||
'adminlogin' => 'admin',
|
||||
'adminpass' => 'admin',
|
||||
'directory' => '$PWD/$DATADIR',
|
||||
);
|
||||
DELIM
|
||||
|
||||
php -f index.php
|
||||
|
||||
#test execution
|
||||
echo 'Testing with sqlite ...'
|
||||
cd tests
|
||||
php -f index.php -- xml > autotest-results-sqlite.xml
|
||||
|
||||
#
|
||||
# mysql testing now
|
||||
#
|
||||
# NOTES:
|
||||
# - grant access permissions: grant all on oc_autotest.* to 'oc_autotest'@'localhost';
|
||||
#
|
||||
echo "Setup environment for MySql testing ..."
|
||||
DATADIR=data-autotest
|
||||
rm -rf $DATADIR
|
||||
mkdir $DATADIR
|
||||
rm -rf config/config.php
|
||||
cat > ./config/autoconfig.php <<DELIM
|
||||
<?php
|
||||
\$AUTOCONFIG = array (
|
||||
'installed' => false,
|
||||
'dbtype' => 'mysql',
|
||||
'dbtableprefix' => 'oc_',
|
||||
'datadirectory' => 'data',
|
||||
'adminlogin' => 'admin',
|
||||
'adminpass' => 'admin',
|
||||
'directory' => '$PWD/$DATADIR',
|
||||
'dbuser' => 'oc_autotest',
|
||||
'dbname' => 'oc_autotest',
|
||||
'dbhost' => 'localhost',
|
||||
'dbpass' => 'owncloud',
|
||||
);
|
||||
DELIM
|
||||
|
||||
#drop the database
|
||||
mysql -u oc_autotest -powncloud -e "DROP DATABASE oc_autotest"
|
||||
|
||||
#setup
|
||||
php -f index.php
|
||||
|
||||
#test execution
|
||||
echo 'Testing with MySql ...'
|
||||
cd tests
|
||||
php -f index.php -- xml > autotest-results-MySql.xml
|
||||
|
||||
#
|
||||
# TODO: create config for postgres
|
||||
#
|
||||
|
|
@ -613,7 +613,7 @@ class OC_App{
|
|||
//set remote/public handelers
|
||||
$appData=self::getAppInfo($appid);
|
||||
foreach($appData['remote'] as $name=>$path){
|
||||
OCP\CONFIG::setAppValue('core', 'remote_'.$name, $path);
|
||||
OCP\CONFIG::setAppValue('core', 'remote_'.$name, $appid.'/'.$path);
|
||||
}
|
||||
foreach($appData['public'] as $name=>$path){
|
||||
OCP\CONFIG::setAppValue('core', 'public_'.$name, $appid.'/'.$path);
|
||||
|
|
56
lib/mail.php
56
lib/mail.php
|
@ -36,7 +36,7 @@ class OC_Mail {
|
|||
$SMTPPASSWORD = OC_Config::getValue( 'mail_smtppassword', '' );
|
||||
|
||||
|
||||
$mailo = new PHPMailer();
|
||||
$mailo = new PHPMailer(true);
|
||||
if($SMTPMODE=='sendmail') {
|
||||
$mailo->IsSendmail();
|
||||
}elseif($SMTPMODE=='smtp'){
|
||||
|
@ -56,33 +56,35 @@ class OC_Mail {
|
|||
$mailo->From =$fromaddress;
|
||||
$mailo->FromName = $fromname;;
|
||||
$a=explode(' ',$toaddress);
|
||||
foreach($a as $ad) {
|
||||
$mailo->AddAddress($ad,$toname);
|
||||
try {
|
||||
foreach($a as $ad) {
|
||||
$mailo->AddAddress($ad,$toname);
|
||||
}
|
||||
|
||||
if($ccaddress<>'') $mailo->AddCC($ccaddress,$ccname);
|
||||
if($bcc<>'') $mailo->AddBCC($bcc);
|
||||
|
||||
$mailo->AddReplyTo($fromaddress, $fromname);
|
||||
|
||||
$mailo->WordWrap = 50;
|
||||
if($html==1) $mailo->IsHTML(true); else $mailo->IsHTML(false);
|
||||
|
||||
$mailo->Subject = $subject;
|
||||
if($altbody=='') {
|
||||
$mailo->Body = $mailtext.OC_MAIL::getfooter();
|
||||
$mailo->AltBody = '';
|
||||
}else{
|
||||
$mailo->Body = $mailtext;
|
||||
$mailo->AltBody = $altbody;
|
||||
}
|
||||
$mailo->CharSet = 'UTF-8';
|
||||
|
||||
$mailo->Send();
|
||||
unset($mailo);
|
||||
OC_Log::write('mail', 'Mail from '.$fromname.' ('.$fromaddress.')'.' to: '.$toname.'('.$toaddress.')'.' subject: '.$subject, OC_Log::DEBUG);
|
||||
} catch (Exception $exception) {
|
||||
OC_Log::write('mail', $exception->getMessage(), OC_Log::DEBUG);
|
||||
}
|
||||
|
||||
if($ccaddress<>'') $mailo->AddCC($ccaddress,$ccname);
|
||||
if($bcc<>'') $mailo->AddBCC($bcc);
|
||||
|
||||
$mailo->AddReplyTo($fromaddress, $fromname);
|
||||
|
||||
$mailo->WordWrap = 50;
|
||||
if($html==1) $mailo->IsHTML(true); else $mailo->IsHTML(false);
|
||||
|
||||
$mailo->Subject = $subject;
|
||||
if($altbody=='') {
|
||||
$mailo->Body = $mailtext.OC_MAIL::getfooter();
|
||||
$mailo->AltBody = '';
|
||||
}else{
|
||||
$mailo->Body = $mailtext;
|
||||
$mailo->AltBody = $altbody;
|
||||
}
|
||||
$mailo->CharSet = 'UTF-8';
|
||||
|
||||
$mailo->Send();
|
||||
unset($mailo);
|
||||
|
||||
OC_Log::write('Mail from '.$fromname.' ('.$fromaddress.')'.' to: '.$toname.'('.$toaddress.')'.' subject: '.$subject,'mail',OC_Log::DEBUG);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ class OC_Setup {
|
|||
OC_Installer::installShippedApps();
|
||||
|
||||
//create htaccess files for apache hosts
|
||||
if (strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
|
||||
if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
|
||||
self::createHtaccess();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ if(is_null($file)){
|
|||
|
||||
$parts=explode('/',$file,2);
|
||||
$app=$parts[0];
|
||||
|
||||
OC_Util::checkAppEnabled($app);
|
||||
OC_App::loadApp($app);
|
||||
|
||||
|
|
10
remote.php
10
remote.php
|
@ -15,27 +15,27 @@ if (!$pos = strpos($path_info, '/', 1)) {
|
|||
$pos = strlen($path_info);
|
||||
}
|
||||
$service=substr($path_info, 1, $pos-1);
|
||||
|
||||
$file = OC_AppConfig::getValue('core', 'remote_' . $service);
|
||||
$file = preg_replace('/apps\//','', $file); //Todo Remove after Multiappdir migration
|
||||
|
||||
if(is_null($file)){
|
||||
OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);
|
||||
exit;
|
||||
}
|
||||
|
||||
$file = ltrim ($file, '/');
|
||||
$file=ltrim($file,'/');
|
||||
|
||||
$parts=explode('/', $file, 2);
|
||||
$app=$parts[0];
|
||||
switch ($app) {
|
||||
case 'core':
|
||||
$file = OC::$SERVERROOT .'/'. $file;
|
||||
break;
|
||||
default:
|
||||
OC_Util::checkAppEnabled($app);
|
||||
OC_App::loadApp($app);
|
||||
$file = OC_App::getAppPath($app) .'/'. $parts[1];
|
||||
break;
|
||||
case 'core':
|
||||
$file = OC::$SERVERROOT .'/'. $file;
|
||||
break;
|
||||
}
|
||||
$baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/';
|
||||
require_once($file);
|
||||
|
|
|
@ -47,25 +47,24 @@ UserList={
|
|||
if( !UserList.deleteCanceled && UserList.deleteUid ){
|
||||
|
||||
// Delete user via ajax
|
||||
$.post(
|
||||
OC.filePath('settings','ajax','removeuser.php'),
|
||||
{username:UserList.deleteUid},
|
||||
function(result){
|
||||
|
||||
// Remove undo option, & remove user from table
|
||||
boolOperationFinished(
|
||||
data, function(){
|
||||
$('#notification').fadeOut();
|
||||
$('tr').filterAttr( 'data-uid', username ).remove();
|
||||
UserList.deleteCanceled=true;
|
||||
UserList.deleteFiles=null;
|
||||
if( ready ){
|
||||
ready();
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: OC.filePath('settings', 'ajax', 'removeuser.php'),
|
||||
async: false,
|
||||
data: { username: UserList.deleteUid },
|
||||
success: function(result) {
|
||||
if (result.status == 'success') {
|
||||
// Remove undo option, & remove user from table
|
||||
$('#notification').fadeOut();
|
||||
$('tr').filterAttr('data-uid', UserList.deleteUid).remove();
|
||||
UserList.deleteCanceled = true;
|
||||
UserList.deleteFiles = null;
|
||||
if (ready) {
|
||||
ready();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,7 +224,7 @@ $(document).ready(function(){
|
|||
})
|
||||
|
||||
$('input.quota-other').live('change',function(){
|
||||
var uid=$(this).parent().parent().data('uid');
|
||||
var uid=$(this).parent().parent().parent().data('uid');
|
||||
var quota=$(this).val();
|
||||
var select=$(this).prev();
|
||||
var other=$(this);
|
||||
|
|
|
@ -26,39 +26,59 @@ require_once 'simpletest/mock_objects.php';
|
|||
require_once 'simpletest/collector.php';
|
||||
require_once 'simpletest/default_reporter.php';
|
||||
|
||||
// test suite instance
|
||||
$testSuite=new TestSuite("ownCloud Unit Test Suite");
|
||||
|
||||
// prepare the reporter
|
||||
if(OC::$CLI){
|
||||
$reporter=new TextReporter;
|
||||
$test=isset($_SERVER['argv'][1])?$_SERVER['argv'][1]:false;
|
||||
if($test=='xml')
|
||||
{
|
||||
$reporter= new XmlReporter;
|
||||
$test=false;
|
||||
}
|
||||
}else{
|
||||
$reporter='HtmlReporter';
|
||||
$test=isset($_GET['test'])?$_GET['test']:false;
|
||||
}
|
||||
|
||||
//load core test cases
|
||||
loadTests(dirname(__FILE__));
|
||||
loadTests(dirname(__FILE__), $testSuite, $test);
|
||||
|
||||
//load app test cases
|
||||
|
||||
//
|
||||
// TODO: define a list of apps to be enabled + enable them
|
||||
//
|
||||
|
||||
$apps=OC_App::getEnabledApps();
|
||||
foreach($apps as $app){
|
||||
if(is_dir(OC::$SERVERROOT.'/apps/'.$app.'/tests')){
|
||||
loadTests(OC::$SERVERROOT.'/apps/'.$app.'/tests');
|
||||
loadTests(OC::$SERVERROOT.'/apps/'.$app.'/tests', $testSuite, $test);
|
||||
}
|
||||
}
|
||||
|
||||
function loadTests($dir=''){
|
||||
if(OC::$CLI){
|
||||
$reporter='TextReporter';
|
||||
$test=isset($_SERVER['argv'][1])?$_SERVER['argv'][1]:false;
|
||||
}else{
|
||||
$reporter='HtmlReporter';
|
||||
$test=isset($_GET['test'])?$_GET['test']:false;
|
||||
}
|
||||
// run the suite
|
||||
if($testSuite->getSize()>0){
|
||||
$testSuite->run($reporter);
|
||||
}
|
||||
|
||||
// helper below
|
||||
function loadTests($dir,$testSuite, $test){
|
||||
if($dh=opendir($dir)){
|
||||
while($name=readdir($dh)){
|
||||
if($name[0]!='.'){//no hidden files, '.' or '..'
|
||||
$file=$dir.'/'.$name;
|
||||
if(is_dir($file)){
|
||||
loadTests($file);
|
||||
loadTests($file, $testSuite, $test);
|
||||
}elseif(substr($file,-4)=='.php' and $file!=__FILE__){
|
||||
$name=getTestName($file);
|
||||
if($test===false or $test==$name or substr($name,0,strlen($test))==$test){
|
||||
$testCase=new TestSuite($name);
|
||||
$testCase->addFile($file);
|
||||
if($testCase->getSize()>0){
|
||||
$testCase->run(new $reporter());
|
||||
}
|
||||
$extractor = new SimpleFileLoader();
|
||||
$loadedSuite=$extractor->load($file);
|
||||
if ($loadedSuite->getSize() > 0)
|
||||
$testSuite->add($loadedSuite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue