Merge branch 'master' into migration

This commit is contained in:
Tom Needham 2012-04-07 17:31:30 +00:00
commit 9edf45a324
45 changed files with 699 additions and 308 deletions

5
README
View file

@ -3,10 +3,11 @@ A personal cloud which runs on your own server.
http://ownCloud.org
Installation instructions: http://owncloud.org/support/setup-and-installation/
Source code: http://gitorious.org/owncloud
Installation instructions: http://owncloud.org/support
Source code: http://gitorious.org/owncloud
Mailing list: http://mail.kde.org/mailman/listinfo/owncloud
IRC channel: http://webchat.freenode.net/?channels=owncloud
Diaspora: https://joindiaspora.com/u/owncloud
Identi.ca: http://identi.ca/owncloud

View file

@ -39,7 +39,10 @@ foreach ($_POST as $key=>$element) {
debug('_POST: '.$key.'=>'.$element);
}
$aid = $_POST['aid'];
$aid = isset($_POST['aid'])?$_POST['aid']:null;
if(!$aid) {
$aid = min(OC_Contacts_Addressbook::activeIds()); // first active addressbook.
}
OC_Contacts_App::getAddressbook( $aid ); // is owner access check
$fn = trim($_POST['fn']);

View file

@ -97,39 +97,39 @@ switch($element) {
}
break;
case 'CATEGORIES':
/* multi autocomplete triggers an save with empty value */
/* multi autocomplete triggers an save with empty value
if (!$value) {
$value = $vcard->getAsString('CATEGORIES');
}
break;
break;*/
case 'EMAIL':
$value = strtolower($value);
break;
}
if(!$value) {
bailOut(OC_Contacts_App::$l10n->t('Cannot save empty value.'));
}
/* setting value */
switch($element) {
case 'BDAY':
case 'FN':
case 'N':
case 'ORG':
case 'NOTE':
case 'NICKNAME':
case 'CATEGORIES':
debug('Setting string:'.$name.' '.$value);
$vcard->setString($name, $value);
break;
case 'EMAIL':
case 'TEL':
case 'ADR': // should I delete the property if empty or throw an error?
debug('Setting element: (EMAIL/TEL/ADR)'.$element);
if(!$value) {
unset($vcard->children[$line]); // Should never happen...
} else {
unset($vcard->children[$line]);
$checksum = '';
} else {
/* setting value */
switch($element) {
case 'BDAY':
case 'FN':
case 'N':
case 'ORG':
case 'NOTE':
case 'NICKNAME':
debug('Setting string:'.$name.' '.$value);
$vcard->setString($name, $value);
break;
case 'CATEGORIES':
debug('Setting string:'.$name.' '.$value);
$vcard->children[$line]->setValue($value);
break;
case 'EMAIL':
case 'TEL':
case 'ADR': // should I delete the property if empty or throw an error?
debug('Setting element: (EMAIL/TEL/ADR)'.$element);
$vcard->children[$line]->setValue($value);
$vcard->children[$line]->parameters = array();
if(!is_null($parameters)) {
@ -142,12 +142,12 @@ switch($element) {
}
}
}
}
break;
break;
}
// Do checksum and be happy
$checksum = md5($vcard->children[$line]->serialize());
}
// Do checksum and be happy
$checksum = md5($vcard->children[$line]->serialize());
debug('New checksum: '.$checksum);
//debug('New checksum: '.$checksum);
if(!OC_Contacts_VCard::edit($id,$vcard)) {
bailOut(OC_Contacts_App::$l10n->t('Error updating contact property.'));

View file

@ -13,22 +13,26 @@
#contacts_propertymenu li a { padding: 3px; display: block }
#contacts_propertymenu li:hover { background-color: #1d2d44; }
#contacts_propertymenu li a:hover { color: #fff }
#actionbar { height: 30px; width: 200px; position: fixed; right: 0px; top: 75px; margin: 0 0 0 0; padding: 0 0 0 0;}
#card { /*max-width: 70em; border: thin solid lightgray; display: block;*/ }
#actionbar { height: 30px; width: 200px; position: fixed; right: 0px; top: 75px; margin: 0 0 0 0; padding: 0 0 0 0; z-index: 1000; }
#card { width: auto;/*max-width: 70em; border: thin solid lightgray; display: block;*/ }
#firstrun { width: 100%; position: absolute; top: 5em; left: 0; text-align: center; font-weight:bold; font-size:1.5em; color:#777; }
#firstrun #selections { font-size:0.8em; margin: 2em auto auto auto; clear: both; }
#card input[type="text"].contacts_property,input[type="email"].contacts_property { width: 14em; }
#card input[type="text"].contacts_property,input[type="email"].contacts_property { width: 14em; float: left; }
.categories { float: left; width: 16em; }
#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; }
#card input[type="text"],input[type="email"],input[type="tel"],input[type="date"], select, textarea { background-color: #fefefe; 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, textarea:focus, textarea:hover { 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, textarea:invalid { color: #bbb !important; }
textarea { min-height: 4em; }
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 dt { display: table-cell; clear: left; float: left; width: 7em; margin: 0; padding: 0.8em 0.5em 0 0; text-align:right; text-overflow:ellipsis; o-text-overflow: ellipsis; vertical-align: text-bottom; color: #bbb;/* 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; }
#address.form dt { min-width: 5em; }
#address.form dl { min-width: 10em; }
.loading { background: url('../../../core/img/loading.gif') no-repeat center !important; /*cursor: progress; */ cursor: wait; }
.ui-autocomplete-loading { background: url('../../../core/img/loading.gif') right center no-repeat; }
.float { float: left; }
.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; }
@ -43,18 +47,18 @@ dl.form { width: 100%; float: left; clear: right; margin: 0; padding: 0; }
#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; }
#fn { float: left !important; width: 18em !important; }
#name { /*position: absolute; top: 0px; left: 0px;*/ min-width: 25em; height: 2em; clear: right; display: block; }
#identityprops { /*position: absolute; top: 2.5em; left: 0px;*/ }
/*#contact_photo { max-width: 250px; }*/
#contact_identity { min-width: 30em; }
.contactsection { position: relative; float: left; /*max-width: 40em;*/ padding: 0.5em; height: auto: border: thin solid lightgray;/* -webkit-border-radius: 0.5em; -moz-border-radius: 0.5em; border-radius: 0.5em; background-color: #f8f8f8;*/ }
.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; }
#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 { border-radius: 0.5em; border: thin solid #bbb; padding: 0.5em; margin: 0.3em; cursor: pointer; background: url(../../../core/img/loading.gif) no-repeat center center; display: block; /* clear: right;*/ }
#contacts_details_photo:hover { background: #fff; }
#contacts_details_photo_progress { margin: 0.3em 0.3em 0.3em 7em; clear: left; }
/*#contacts_details_photo_progress { margin: 0.3em 0.3em 0.3em 7em; clear: left; }*/
/* Address editor */
#addressdisplay { padding: 0.5em; }
dl.addresscard { background-color: #fff; float: left; width: 45%; margin: 0 0.3em 0.3em 0.3em; padding: 0; border: thin solid lightgray; }
@ -72,8 +76,10 @@ dl.addresscard dd > ul { margin: 0.3em; padding: 0.3em; }
#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;}
#file_upload_start { opacity:0; filter:alpha(opacity=0); z-index:1; /*position:absolute; left:0; top:0;*/ cursor:pointer; width:0; height: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; }
.propertycontainer dd { float: left; width: 25em; }
.propertylist { clear: none; max-width: 28em; }
.propertylist li { /*background-color: cyan; */ min-width: 25em; /*max-width: 30em;*/ display: block; clear: right; }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

View file

@ -34,7 +34,26 @@ if(!is_null($id)) {
}
$property_types = OC_Contacts_App::getAddPropertyOptions();
$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
$categories = OC_Contacts_App::$categories->categories();
$categories = OC_Contacts_App::getCategories();
if(count($categories) == 0) {
$vcaddressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
if(count($vcaddressbooks) > 0) {
$vcaddressbookids = array();
foreach($vcaddressbooks as $vcaddressbook) {
$vcaddressbookids[] = $vcaddressbook['id'];
}
$vccontacts = OC_Contacts_VCard::all($vcaddressbookids);
if(count($vccontacts) > 0) {
$cards = array();
foreach($vccontacts as $vccontact) {
$cards[] = $vccontact['carddata'];
}
OC_Contacts_App::$categories->rescan($cards);
$categories = OC_Contacts_App::$categories->categories();
}
}
}
$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
@ -61,7 +80,6 @@ $tmpl = new OC_Template( "contacts", "index", "user" );
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
$tmpl->assign('property_types',$property_types);
$tmpl->assign('categories',OC_Contacts_App::getCategories());
$tmpl->assign('phone_types',$phone_types);
$tmpl->assign('categories',$categories);
$tmpl->assign('addressbooks', $addressbooks);

View file

@ -65,7 +65,7 @@ Contacts={
propertyTypeFor:function(obj) {
return $(obj).parents('.propertycontainer').first().data('element');
},
showHideContactInfo:function() {
/*showHideContactInfo:function() {
var show = ($('#emaillist li.propertycontainer').length > 0 || $('#phonelist li.propertycontainer').length > 0 || $('#addressdisplay dl.propertycontainer').length > 0);
console.log('showHideContactInfo: ' + show);
if(show) {
@ -73,8 +73,8 @@ Contacts={
} else {
$('#contact_communication').hide();
}
},
checkListFor:function(obj) {
},*/
/*checkListFor:function(obj) {
var type = $(obj).parents('.propertycontainer').first().data('element');
console.log('checkListFor: ' + type);
switch (type) {
@ -101,7 +101,7 @@ Contacts={
case 'BDAY':
break;
}
},
},*/
loading:function(obj, state) {
if(state) {
$(obj).addClass('loading');
@ -116,7 +116,7 @@ Contacts={
},
loadListHandlers:function() {
//$('.add,.delete').hide();
$('.globe,.mail,.delete,.edit').tipsy();
$('.globe,.mail,.delete,.edit,.tip').tipsy();
$('.addresscard,.propertylist li,.propertycontainer').hover(
function () {
$(this).find('.globe,.mail,.delete,.edit').fadeIn(100);
@ -137,18 +137,14 @@ Contacts={
$(this).find('.add').fadeOut(500);
}
);*/
$('.button,.action').tipsy();
$('#contacts_deletecard').tipsy({gravity: 'ne'});
$('#contacts_downloadcard').tipsy({gravity: 'ne'});
//$('#fn').jec();
$('#fn_select').combobox({
'id': 'fn',
'name': 'value',
'classes': ['contacts_property'],
'classes': ['contacts_property', 'huge', 'tip', 'float'],
'attributes': {'placeholder': t('contacts', 'Enter name')},
'title': t('contacts', 'Format custom, Short name, Full name, Reverse or Reverse with comma')});
//$('.jecEditableOption').attr('title', t('contacts','Custom'));
$('#fn').tipsy();
$('#contacts_details_photo_wrapper').tipsy();
$('#bday').datepicker({
dateFormat : 'dd-mm-yy'
});
@ -175,10 +171,6 @@ Contacts={
// Contacts.UI.Card.editAddress();
// return false;
// });
$('#n').click(function(){
Contacts.UI.Card.editName();
//return false;
});
$('#edit_name').click(function(){
Contacts.UI.Card.editName();
return false;
@ -200,6 +192,9 @@ Contacts={
}
] );
$('#categories').multiple_autocomplete({source: categories});
$('.button,.action,.tip').tipsy();
$('#contacts_deletecard').tipsy({gravity: 'ne'});
$('#contacts_downloadcard').tipsy({gravity: 'ne'});
Contacts.UI.loadListHandlers();
},
Card:{
@ -259,15 +254,15 @@ Contacts={
});
}
},
export:function() {
do_export:function() {
document.location.href = OC.linkTo('contacts', 'export.php') + '?contactid=' + this.id;
//$.get(OC.linkTo('contacts', 'export.php'),{'contactid':this.id},function(jsondata){
//});
},
import:function(){
do_import:function(){
Contacts.UI.notImplemented();
},
add:function(n, fn, aid){ // add a new contact
add:function(n, fn, aid, isnew){ // add a new contact
console.log('Add contact: ' + n + ', ' + fn + ' ' + aid);
$.post(OC.filePath('contacts', 'ajax', 'addcontact.php'), { n: n, fn: fn, aid: aid },
function(jsondata) {
@ -291,7 +286,15 @@ Contacts={
if(!added) {
$('#leftcontent ul').append(item);
}
if(isnew) {
Contacts.UI.Card.addProperty('EMAIL');
Contacts.UI.Card.addProperty('TEL');
Contacts.UI.Card.addProperty('NICKNAME');
Contacts.UI.Card.addProperty('ORG');
Contacts.UI.Card.addProperty('CATEGORIES');
$('#fn').focus();
$('#fn').select();
}
}
else{
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
@ -308,7 +311,7 @@ Contacts={
}
});
},
delete:function() {
do_delete:function() {
$('#contacts_deletecard').tipsy('hide');
OC.dialogs.confirm(t('contacts', 'Are you sure you want to delete this contact?'), t('contacts', 'Warning'), function(answer) {
if(answer == true) {
@ -356,7 +359,7 @@ Contacts={
return false;
},
loadContact:function(jsondata){
$('#contact_communication').hide();
//$('#contact_communication').hide();
this.data = jsondata;
this.id = this.data.id;
$('#rightcontent').data('id',this.id);
@ -368,7 +371,6 @@ Contacts={
this.loadPhones();
this.loadAddresses();
this.loadSingleProperties();
// TODO: load NOTE ;-)
if(this.data.NOTE) {
$('#note').data('checksum', this.data.NOTE[0]['checksum']);
$('#note').find('textarea').val(this.data.NOTE[0]['value']);
@ -376,7 +378,7 @@ Contacts={
} else {
$('#note').data('checksum', '');
$('#note').find('textarea').val('');
$('#note').hide();
//$('#note').hide();
}
},
loadSingleProperties:function() {
@ -521,17 +523,18 @@ Contacts={
},*/
editNew:function(){ // add a new contact
this.id = ''; this.fn = ''; this.fullname = ''; this.givname = ''; this.famname = ''; this.addname = ''; this.honpre = ''; this.honsuf = '';
$.getJSON(OC.filePath('contacts', 'ajax', 'newcontact.php'),{},function(jsondata){
Contacts.UI.Card.add(';;;;', '', '', true);
/*$.getJSON(OC.filePath('contacts', 'ajax', 'newcontact.php'),{},function(jsondata){
if(jsondata.status == 'success'){
id = '';
$('#rightcontent').data('id','');
$('#rightcontent').html(jsondata.data.page);
Contacts.UI.Card.editName();
//Contacts.UI.Card.editName();
} else {
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
//alert(jsondata.data.message);
}
});
});*/
},
savePropertyInternal:function(name, fields, oldchecksum, checksum){
// TODO: Add functionality for new fields.
@ -627,8 +630,8 @@ Contacts={
},'json');
}
},
addProperty:function(obj){
var type = $(obj).data('type');
addProperty:function(type){
//var type = $(obj).data('type');
console.log('addProperty:' + type);
switch (type) {
case 'PHOTO':
@ -647,21 +650,21 @@ Contacts={
$('#emails').show();
}
Contacts.UI.Card.addMail();
Contacts.UI.showHideContactInfo();
//Contacts.UI.showHideContactInfo();
break;
case 'TEL':
if($('#phonelist>li').length == 1) {
$('#phones').show();
}
Contacts.UI.Card.addPhone();
Contacts.UI.showHideContactInfo();
//Contacts.UI.showHideContactInfo();
break;
case 'ADR':
if($('#addressdisplay>dl').length == 1) {
$('#addresses').show();
}
Contacts.UI.Card.editAddress('new', true);
Contacts.UI.showHideContactInfo();
//Contacts.UI.showHideContactInfo();
break;
case 'NICKNAME':
case 'ORG':
@ -682,8 +685,8 @@ Contacts={
if(jsondata.status == 'success'){
if(type == 'list') {
Contacts.UI.propertyContainerFor(obj).remove();
Contacts.UI.showHideContactInfo();
Contacts.UI.checkListFor(obj);
//Contacts.UI.showHideContactInfo();
//Contacts.UI.checkListFor(obj);
} else if(type == 'single') {
var proptype = Contacts.UI.propertyTypeFor(obj);
console.log('deleteProperty, hiding: ' + proptype);
@ -718,8 +721,8 @@ Contacts={
} else { // Property hasn't been saved so there's nothing to delete.
if(type == 'list') {
Contacts.UI.propertyContainerFor(obj).remove();
Contacts.UI.showHideContactInfo();
Contacts.UI.checkListFor(obj);
//Contacts.UI.showHideContactInfo();
//Contacts.UI.checkListFor(obj);
} else if(type == 'single') {
var proptype = Contacts.UI.propertyTypeFor(obj);
console.log('deleteProperty, hiding: ' + proptype);
@ -891,7 +894,7 @@ Contacts={
if(isnew) {
container.remove();
}
Contacts.UI.showHideContactInfo();
//Contacts.UI.showHideContactInfo();
}
},
close : function(event, ui) {
@ -900,11 +903,95 @@ Contacts={
if(isnew) {
container.remove();
}
Contacts.UI.showHideContactInfo();
}/*,
//Contacts.UI.showHideContactInfo();
},
open : function(event, ui) {
// load 'ADR' property - maybe :-P
}*/
$( "#adr_city" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "http://ws.geonames.org/searchJSON",
dataType: "jsonp",
data: {
featureClass: "P",
style: "full",
maxRows: 12,
lang: lang,
name_startsWith: request.term
},
success: function( data ) {
response( $.map( data.geonames, function( item ) {
/*for(var key in item) {
console.log(key + ': ' + item[key]);
}*/
return {
label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
value: item.name,
country: item.countryName
}
}));
}
});
},
minLength: 2,
select: function( event, ui ) {
if(ui.item && $('#adr_country').val().trim().length == 0) {
$('#adr_country').val(ui.item.country);
}
/*log( ui.item ?
"Selected: " + ui.item.label :
"Nothing selected, input was " + this.value);*/
},
open: function() {
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function() {
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
}
});
$( "#adr_country" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "http://ws.geonames.org/searchJSON",
dataType: "jsonp",
data: {
/*featureClass: "A",*/
featureCode: "PCLI",
/*countryBias: "true",*/
/*style: "full",*/
lang: lang,
maxRows: 12,
name_startsWith: request.term
},
success: function( data ) {
response( $.map( data.geonames, function( item ) {
for(var key in item) {
console.log(key + ': ' + item[key]);
}
return {
label: item.name,
value: item.name
}
}));
}
});
},
minLength: 2,
select: function( event, ui ) {
/*if(ui.item) {
$('#adr_country').val(ui.item.country);
}
log( ui.item ?
"Selected: " + ui.item.label :
"Nothing selected, input was " + this.value);*/
},
open: function() {
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function() {
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
}
});
}
});
} else {
alert(jsondata.data.message);
@ -973,7 +1060,7 @@ Contacts={
}
},
loadPhoto:function(force){
if(this.data.PHOTO||force==true) {
//if(this.data.PHOTO||force==true) {
$.getJSON('ajax/loadphoto.php',{'id':this.id},function(jsondata){
if(jsondata.status == 'success'){
//alert(jsondata.data.page);
@ -986,11 +1073,11 @@ Contacts={
});
$('#file_upload_form').show();
$('#contacts_propertymenu a[data-type="PHOTO"]').parent().hide();
} else {
/*} else {
$('#contacts_details_photo_wrapper').empty();
$('#file_upload_form').hide();
$('#contacts_propertymenu a[data-type="PHOTO"]').parent().show();
}
}*/
},
editPhoto:function(id, tmp_path){
//alert('editPhoto: ' + tmp_path);
@ -1165,7 +1252,7 @@ Contacts={
});
}
},
import:function(){
do_import:function(){
Contacts.UI.notImplemented();
},
submit:function(button, bookid){
@ -1198,9 +1285,7 @@ Contacts={
}
},
Contacts:{
/**
* Reload the contacts list.
*/
// Reload the contacts list.
update:function(){
console.log('Contacts.update, start');
$.getJSON('ajax/contacts.php',{},function(jsondata){
@ -1215,9 +1300,7 @@ Contacts={
});
setTimeout(Contacts.UI.Contacts.lazyupdate, 500);
},
/**
* Add thumbnails to the contact list as they become visible in the viewport.
*/
// Add thumbnails to the contact list as they become visible in the viewport.
lazyupdate:function(){
$('#contacts li').live('inview', function(){
if (!$(this).find('a').attr('style')) {
@ -1237,9 +1320,6 @@ $(document).ready(function(){
OCCategories.changed = Contacts.UI.Card.categoriesChanged;
OCCategories.app = 'contacts';
/**
* Show the Addressbook chooser
*/
$('#chooseaddressbook').click(function(){
Contacts.UI.Addressbooks.overview();
return false;
@ -1272,7 +1352,7 @@ $(document).ready(function(){
});
$('#contacts_deletecard').live('click',function(){
Contacts.UI.Card.delete();
Contacts.UI.Card.do_delete();
});
$('#contacts li').bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
@ -1430,7 +1510,8 @@ $(document).ready(function(){
}
});
$('#contacts_propertymenu a').live('click',function(){
Contacts.UI.Card.addProperty(this);
var type = $(this).data('type');
Contacts.UI.Card.addProperty(type);
$('#contacts_propertymenu').hide();
});
});

View file

@ -72,17 +72,10 @@
.appendTo( ul );
};
this.button = $( "<button type='button'>&nbsp;</button>" )
/*this.button = $( "<button type='button'>&nbsp;</button>" )
.attr( "tabIndex", -1 )
.attr( "title", "Show All Items" )
.insertAfter( input )
/*.button({
icons: {
primary: "ui-icon-triangle-1-s"
},
text: false
})
.removeClass( "ui-corner-all" )*/
.addClass('svg')
.addClass('action')
.addClass('combo-button')
@ -99,7 +92,7 @@
// pass empty string as value to search for, displaying all results
input.autocomplete( "search", "" );
input.focus();
});
});*/
$.each(this.options, function(key, value) {
self._setOption(key, value);
});
@ -123,17 +116,23 @@
case "id":
this.options['id'] = value;
this.input.attr('id', value);
break;
break;
case "name":
this.options['name'] = value;
this.input.attr('name', value);
break;
break;
case "attributes":
var input = this.input;
$.each(this.options['attributes'], function(key, value) {
input.attr(key, value);
});
break;
case "classes":
var input = this.input;
$.each(this.options['classes'], function(key, value) {
input.addClass(value);
});
break;
break;
}
// In jQuery UI 1.8, you have to manually invoke the _setOption method from the base widget
$.Widget.prototype._setOption.apply( this, arguments );

View file

@ -62,7 +62,7 @@
return false;
}
});
this.button = $( "<button type='button'>&nbsp;</button>" )
/*this.button = $( "<button type='button'>&nbsp;</button>" )
.attr( "tabIndex", -1 )
.attr( "title", "Show All Items" )
.insertAfter( this.element )
@ -86,7 +86,7 @@
// pass empty string as value to search for, displaying all results
self.element.autocomplete( "search", "" );
self.element.focus();
});
});*/
},
});
})( jQuery );

View file

@ -1,6 +1,7 @@
<script type='text/javascript'>
var totalurl = '<?php echo OC_Helper::linkToAbsolute('contacts', 'carddav.php'); ?>/addressbooks';
var categories = <?php sort($_['categories']); echo json_encode($_['categories']); ?>;
var lang = '<?php echo OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang', 'en'); ?>';
</script>
<div id="controls">
<form>

View file

@ -17,16 +17,16 @@ $id = isset($_['id']) ? $_['id'] : '';
<li><a data-type="CATEGORIES"><?php echo $l->t('Categories'); ?></a></li>
</ul>
</div>
<img onclick="Contacts.UI.Card.export();" class="svg action" id="contacts_downloadcard" src="<?php echo image_path('', 'actions/download.svg'); ?>" title="<?php echo $l->t('Download contact');?>" />
<img onclick="Contacts.UI.Card.do_export();" class="svg action" id="contacts_downloadcard" src="<?php echo image_path('', 'actions/download.svg'); ?>" title="<?php echo $l->t('Download contact');?>" />
<img class="svg action" id="contacts_deletecard" src="<?php echo image_path('', 'actions/delete.svg'); ?>" title="<?php echo $l->t('Delete contact');?>" />
</div>
<div class="contactsection">
<div id="contact_photo" class="contactsection">
<form style="display:none;" id="file_upload_form" action="ajax/uploadphoto.php" method="post" enctype="multipart/form-data" target="file_upload_target" class="propertycontainer" data-element="PHOTO">
<fieldset id="photo" class="formfloat">
<form class="float" id="file_upload_form" action="ajax/uploadphoto.php" method="post" enctype="multipart/form-data" target="file_upload_target" class="propertycontainer" data-element="PHOTO">
<fieldset id="photo">
<a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a>
<div id="contacts_details_photo_wrapper" title="<?php echo $l->t('Click or drop to upload picture'); ?> (max <?php echo $_['uploadMaxHumanFilesize']; ?>)">
<div class="tip" id="contacts_details_photo_wrapper" title="<?php echo $l->t('Click or drop to upload picture'); ?> (max <?php echo $_['uploadMaxHumanFilesize']; ?>)">
<!-- img style="padding: 1em;" id="contacts_details_photo" alt="Profile picture" src="photo.php?id=<?php echo $_['id']; ?>" / -->
<progress id="contacts_details_photo_progress" style="display:none;" value="0" max="100">0 %</progress>
</div>
@ -37,58 +37,55 @@ $id = isset($_['id']) ? $_['id'] : '';
<iframe name="file_upload_target" id='file_upload_target' src=""></iframe>
</fieldset>
</form>
<form id="contact_identity" method="post" <?php echo ($_['id']==''||!isset($_['id'])?'style="display:none;"':''); ?>>
</div> <!-- contact_photo -->
<div id="contact_identity" class="contactsection">
<form method="post">
<input type="hidden" name="id" value="<?php echo $_['id'] ?>">
<fieldset class="propertycontainer" data-element="N"><input type="hidden" id="n" class="contacts_property" name="value" value="" /></fieldset>
<fieldset id="ident" class="formfloat">
<fieldset id="ident" class="contactpart">
<!-- legend>Name</legend -->
<dl class="form">
<!-- dt><label for="n"><?php echo $l->t('Name'); ?></label></dt>
<dd style="padding-top: 0.8em;vertical-align: text-bottom;"><span id="n" type="text"></span></dd -->
<dt><label for="fn"><?php echo $l->t('Display name'); ?></label></dt>
<dd class="propertycontainer" data-element="FN">
<select id="fn_select" title="<?php echo $l->t('Format custom, Short name, Full name, Reverse or Reverse with comma'); ?>" style="width:16em;">
</select><a id="edit_name" class="action edit" title="<?php echo $l->t('Edit name details'); ?>"></a>
</dd>
<span class="propertycontainer" data-element="N"><input type="hidden" id="n" class="contacts_property" name="value" value="" /></span>
<span id="name" class="propertycontainer" data-element="FN">
<select class="float" id="fn_select" title="<?php echo $l->t('Format custom, Short name, Full name, Reverse or Reverse with comma'); ?>" style="width:16em;">
</select><a id="edit_name" class="action edit" title="<?php echo $l->t('Edit name details'); ?>"></a>
</span>
<dl id="identityprops" class="form">
<dt style="display:none;" id="org_label" data-element="ORG"><label for="org"><?php echo $l->t('Organization'); ?></label></dt>
<dd style="display:none;" class="propertycontainer" id="org_value" data-element="ORG"><input id="org" required="required" name="value[ORG]" type="text" class="contacts_property" style="width:16em;" name="value" value="" placeholder="<?php echo $l->t('Organization'); ?>" /><a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a></dd>
<dd style="display:none;" class="propertycontainer" id="org_value" data-element="ORG"><input id="org" required="required" name="value[ORG]" type="text" class="contacts_property big" name="value" value="" placeholder="<?php echo $l->t('Organization'); ?>" /><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="nickname_label" data-element="NICKNAME"><label for="nickname"><?php echo $l->t('Nickname'); ?></label></dt>
<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>
<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 big" 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 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>
<dd style="display:none;" class="propertycontainer" id="bday_value" data-element="BDAY"><input id="bday" required="required" name="value" type="text" class="contacts_property big" 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 style="display:none;" id="categories_label" data-element="CATEGORIES"><label for="categories"><?php echo $l->t('Groups'); ?></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 bold" name="value" value="" placeholder="
<?php echo $l->t('Separate groups with commas'); ?>" /><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>
</fieldset>
<fieldset id="note" class="formfloat propertycontainer contactpart" style="display:none;" data-element="NOTE">
<legend><?php echo $l->t('Note'); ?><a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a></legend>
<textarea class="contacts_property note" name="value" cols="60" rows="10"></textarea>
</fieldset>
</form>
</div>
</div> <!-- contact_identity -->
<!-- div class="delimiter"></div -->
<form id="contact_communication" method="post" style="display: none;">
<div class="contactsection">
<div id="contact_communication" class="contactsection">
<form method="post">
<!-- email addresses -->
<div id="emails" style="display:none;">
<div id="emails">
<fieldset class="contactpart">
<legend><?php echo $l->t('Email'); ?></legend>
<!-- legend><?php echo $l->t('Email'); ?></legend -->
<ul id="emaillist" class="propertylist">
<li class="template" style="white-space: nowrap; display: none;" data-element="EMAIL">
<input type="checkbox" class="contacts_property" name="parameters[TYPE][]" value="PREF" title="<?php echo $l->t('Preferred'); ?>" />
<input type="checkbox" class="contacts_property tip" name="parameters[TYPE][]" value="PREF" title="<?php echo $l->t('Preferred'); ?>" />
<input type="email" required="required" class="nonempty contacts_property" style="width:15em;" name="value" value="" x-moz-errormessage="<?php echo $l->t('Please specify a valid email address.'); ?>" placeholder="<?php echo $l->t('Enter email address'); ?>" /><span class="listactions"><a onclick="Contacts.UI.mailTo(this)" class="action mail" title="<?php echo $l->t('Mail to address'); ?>"></a>
<a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'list');" title="<?php echo $l->t('Delete email address'); ?>"></a></span></li>
</ul><!-- a id="add_email" class="add" title="<?php echo $l->t('Add email address'); ?>"></a -->
</div> <!-- email addresses-->
<!-- Phone numbers -->
<div id="phones" style="display:none;">
<div id="phones">
<fieldset class="contactpart">
<legend><?php echo $l->t('Phone'); ?></legend>
<!-- legend><?php echo $l->t('Phone'); ?></legend -->
<ul id="phonelist" class="propertylist">
<li class="template" style="white-space: nowrap; display: none;" data-element="TEL">
<input type="checkbox" class="contacts_property" name="parameters[TYPE][]" value="PREF" title="<?php echo $l->t('Preferred'); ?>" />
<input type="checkbox" class="contacts_property tip" name="parameters[TYPE][]" value="PREF" title="<?php echo $l->t('Preferred'); ?>" />
<input type="text" required="required" class="nonempty contacts_property" style="width:10em; border: 0px;" name="value" value="" placeholder="<?php echo $l->t('Enter phone number'); ?>" />
<select multiple="multiple" name="parameters[TYPE][]">
<?php echo html_select_options($_['phone_types'], array()) ?>
@ -100,7 +97,7 @@ $id = isset($_['id']) ? $_['id'] : '';
<!-- Addresses -->
<div id="addresses" style="display:none;">
<fieldset class="contactpart">
<legend><?php echo $l->t('Address'); ?></legend>
<!-- legend><?php echo $l->t('Address'); ?></legend -->
<div id="addressdisplay">
<dl class="addresscard template" style="display: none;" data-element="ADR"><dt>
<input class="adr contacts_property" name="value" type="hidden" value="" />
@ -109,13 +106,18 @@ $id = isset($_['id']) ? $_['id'] : '';
</dt><dd><ul class="addresslist"></ul></dd></dl>
</fieldset>
</div>
</div> <!-- addressdisplay -->
</div> <!-- Addresses -->
</div>
<!-- a id="add_address" onclick="Contacts.UI.Card.editAddress('new', true)" class="add" title="<?php echo $l->t('Add address'); ?>"></a -->
</div>
</form>
</div>
</div> <!-- contact_communication -->
<div id="contact_note" class="contactsection">
<form class="float" method="post">
<fieldset id="note" class="formfloat propertycontainer contactpart" data-element="NOTE">
<textarea class="contacts_property note" name="value" cols="40" rows="10" required="required" placeholder="<?php echo $l->t('Add notes here.'); ?>"></textarea>
</fieldset>
</form>
</div> <!-- contact_note -->
</div> <!-- card -->
<div id="edit_photo_dialog" title="Edit photo">
<div id="edit_photo_dialog_img"></div>
</div>
@ -128,7 +130,7 @@ $(document).ready(function(){
Contacts.UI.Card.loadContact(jsondata.data);
}
else{
Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
}

View file

@ -22,44 +22,44 @@ foreach(isset($adr['parameters']['TYPE'])?array($adr['parameters']['TYPE']):arra
<label class="label" for="adr_pobox"><?php echo $l->t('PO Box'); ?></label>
</dt>
<dd>
<input type="text" id="adr_pobox" name="value[ADR][0]" value="<?php echo isset($adr['value'][0])?$adr['value'][0]:''; ?>">
<input type="text" id="adr_pobox" name="value[ADR][0]" placeholder="<?php echo $l->t('PO Box'); ?>" value="<?php echo isset($adr['value'][0])?$adr['value'][0]:''; ?>">
</dd>
<dd>
<dt>
<label class="label" for="adr_extended"><?php echo $l->t('Extended'); ?></label>
</dt>
<dd>
<input type="text" id="adr_extended" name="value[ADR][1]" value="<?php echo isset($adr['value'][1])?$adr['value'][1]:''; ?>">
<input type="text" id="adr_extended" name="value[ADR][1]" placeholder="<?php echo $l->t('Extended'); ?>" value="<?php echo isset($adr['value'][1])?$adr['value'][1]:''; ?>">
</dd>
<dt>
<label class="label" for="adr_street"><?php echo $l->t('Street'); ?></label>
</dt>
<dd>
<input type="text" id="adr_street" name="value[ADR][2]" value="<?php echo isset($adr['value'][2])?$adr['value'][2]:''; ?>">
<input type="text" id="adr_street" name="value[ADR][2]" placeholder="<?php echo $l->t('Street'); ?>" value="<?php echo isset($adr['value'][2])?$adr['value'][2]:''; ?>">
</dd>
<dt>
<label class="label" for="adr_city"><?php echo $l->t('City'); ?></label>
</dt>
<dd>
<input type="text" id="adr_city" name="value[ADR][3]" value="<?php echo isset($adr['value'][3])?$adr['value'][3]:''; ?>">
<input type="text" id="adr_city" name="value[ADR][3]" placeholder="<?php echo $l->t('City'); ?>" value="<?php echo isset($adr['value'][3])?$adr['value'][3]:''; ?>">
</dd>
<dt>
<label class="label" for="adr_region"><?php echo $l->t('Region'); ?></label>
</dt>
<dd>
<input type="text" id="adr_region" name="value[ADR][4]" value="<?php echo isset($adr['value'][4])?$adr['value'][4]:''; ?>">
<input type="text" id="adr_region" name="value[ADR][4]" placeholder="<?php echo $l->t('Region'); ?>" value="<?php echo isset($adr['value'][4])?$adr['value'][4]:''; ?>">
</dd>
<dt>
<label class="label" for="adr_zipcode"><?php echo $l->t('Zipcode'); ?></label>
</dt>
<dd>
<input type="text" id="adr_zipcode" name="value[ADR][5]" value="<?php echo isset($adr['value'][5])?$adr['value'][5]:''; ?>">
<input type="text" id="adr_zipcode" name="value[ADR][5]" placeholder="<?php echo $l->t('Zipcode'); ?>" value="<?php echo isset($adr['value'][5])?$adr['value'][5]:''; ?>">
</dd>
<dt>
<label class="label" for="adr_country"><?php echo $l->t('Country'); ?></label>
</dt>
<dd>
<input type="text" id="adr_country" name="value[ADR][6]" value="<?php echo isset($adr['value'][6])?$adr['value'][6]:''; ?>">
<input type="text" id="adr_country" name="value[ADR][6]" placeholder="<?php echo $l->t('Country'); ?>" value="<?php echo isset($adr['value'][6])?$adr['value'][6]:''; ?>">
</dd>
</dl>
</fieldset>

View file

@ -8,5 +8,6 @@
<dt><?php echo $l->t('iOS/OS X'); ?></dt>
<dd><code><?php echo OC_Helper::linkToAbsolute('contacts', 'carddav.php'); ?>/principals/<?php echo OC_User::getUser(); ?></code>/</dd>
</dl>
Powered by <a href="http://geonames.org/" target="_blank">geonames.org webservice</a>
</fieldset>
</form>

View file

@ -22,9 +22,11 @@ function setSyntaxMode(ext){
filetype["css"] = "css";
filetype["groovy"] = "groovy";
filetype["haxe"] = "hx";
filetype["htm"] = "html";
filetype["html"] = "html";
filetype["java"] = "java";
filetype["js"] = "javascript";
filetype["jsm"] = "javascript";
filetype["json"] = "json";
filetype["latex"] = "latex";
filetype["ly"] = "latex";
@ -141,32 +143,40 @@ function doSearch(){
// Tries to save the file.
function doFileSave(){
if(editorIsShown()){
// Get file path
var path = $('#editor').attr('data-dir')+'/'+$('#editor').attr('data-filename');
// Get original mtime
var mtime = $('#editor').attr('data-mtime');
// Show saving spinner
$("#editor_save").die('click',doFileSave);
$('#save_result').remove();
$('#editor_save').text(t('files_texteditor','Saving...'));
// Get the data
var filecontents = window.aceEditor.getSession().getValue();
// Send the data
$.post(OC.filePath('files_texteditor','ajax','savefile.php'), { filecontents: filecontents, path: path, mtime: mtime },function(jsondata){
if(jsondata.status!='success'){
// Save failed
$('#editor_save').text(t('files_texteditor','Save'));
$('#editor_save').after('<p id="save_result" style="float: left">Failed to save file</p>');
$("#editor_save").live('click',doFileSave);
} else {
// Save OK
// Update mtime
$('#editor').attr('data-mtime',jsondata.data.mtime);
$('#editor_save').text(t('files_texteditor','Save'));
$("#editor_save").live('click',doFileSave);
}
},'json');
// Changed contents?
if($('#editor').attr('data-edited')=='true'){
// Get file path
var path = $('#editor').attr('data-dir')+'/'+$('#editor').attr('data-filename');
// Get original mtime
var mtime = $('#editor').attr('data-mtime');
// Show saving spinner
$("#editor_save").die('click',doFileSave);
$('#save_result').remove();
$('#editor_save').text(t('files_texteditor','Saving...'));
// Get the data
var filecontents = window.aceEditor.getSession().getValue();
// Send the data
$.post(OC.filePath('files_texteditor','ajax','savefile.php'), { filecontents: filecontents, path: path, mtime: mtime },function(jsondata){
if(jsondata.status!='success'){
// Save failed
$('#editor_save').text(t('files_texteditor','Save'));
$('#editor_save').after('<p id="save_result" style="float: left">Failed to save file</p>');
$("#editor_save").live('click',doFileSave);
} else {
// Save OK
// Update mtime
$('#editor').attr('data-mtime',jsondata.data.mtime);
$('#editor_save').text(t('files_texteditor','Save'));
$("#editor_save").live('click',doFileSave);
// Update titles
$('#editor').attr('data-edited', 'false');
$('#breadcrumb_file').text($('#editor').attr('data-filename'));
document.title = $('#editor').attr('data-filename')+' - ownCloud';
}
},'json');
}
}
giveEditorFocus();
};
// Gives the editor focus
@ -176,6 +186,8 @@ function giveEditorFocus(){
// Loads the file editor. Accepts two parameters, dir and filename.
function showFileEditor(dir,filename){
// Delete any old editors
$('#editor').remove();
if(!editorIsShown()){
// Loads the file editor and display it.
$('#content').append('<div id="editor"></div>');
@ -192,10 +204,11 @@ function showFileEditor(dir,filename){
// Show the control bar
showControls(filename,result.data.write);
// Update document title
document.title = filename;
document.title = filename+' - ownCloud';
$('#editor').text(result.data.filecontents);
$('#editor').attr('data-dir', dir);
$('#editor').attr('data-filename', filename);
$('#editor').attr('data-edited', 'false');
window.aceEditor = ace.edit("editor");
aceEditor.setShowPrintMargin(false);
aceEditor.getSession().setUseWrapMode(true);
@ -207,10 +220,17 @@ function showFileEditor(dir,filename){
OC.addScript('files_texteditor','aceeditor/theme-clouds', function(){
window.aceEditor.setTheme("ace/theme/clouds");
});
window.aceEditor.getSession().on('change', function(){
if($('#editor').attr('data-edited')!='true'){
$('#editor').attr('data-edited', 'true');
$('#breadcrumb_file').text($('#breadcrumb_file').text()+' *');
document.title = $('#editor').attr('data-filename')+' * - ownCloud';
}
});
});
} else {
// Failed to get the file.
alert(result.data.message);
OC.dialogs.alert(result.data.message, t('files_texteditor','An error occurred!'));
}
// End success
}
@ -222,37 +242,54 @@ function showFileEditor(dir,filename){
// Fades out the editor.
function hideFileEditor(){
// Fades out editor controls
$('#editorcontrols').fadeOut('slow',function(){
$(this).remove();
$(".crumb:last").addClass('last');
});
// Fade out editor
$('#editor').fadeOut('slow', function(){
$(this).remove();
// Reset document title
document.title = "ownCloud";
var editorhtml = '<div id="editor"></div>';
$('table').after(editorhtml);
$('.actions,#file_access_panel').fadeIn('slow');
$('table').fadeIn('slow');
});
is_editor_shown = false;
if($('#editor').attr('data-edited') == 'true'){
// Hide, not remove
$('#editorcontrols').fadeOut('slow',function(){
// Check if there is a folder in the breadcrumb
if($('.crumb.ui-droppable').length){
$('.crumb.ui-droppable:last').addClass('last');
}
});
// Fade out editor
$('#editor').fadeOut('slow', function(){
// Reset document title
document.title = "ownCloud";
$('.actions,#file_access_panel').fadeIn('slow');
$('table').fadeIn('slow');
});
$('#notification').text(t('files_texteditor','There were unsaved changes, click here to go back'));
$('#notification').data('reopeneditor',true);
$('#notification').fadeIn();
is_editor_shown = false;
} else {
// Remove editor
$('#editorcontrols').fadeOut('slow',function(){
$(this).remove();
$(".crumb:last").addClass('last');
});
// Fade out editor
$('#editor').fadeOut('slow', function(){
$(this).remove();
// Reset document title
document.title = "ownCloud";
$('.actions,#file_access_panel').fadeIn('slow');
$('table').fadeIn('slow');
});
is_editor_shown = false;
}
}
// Keyboard Shortcuts
var ctrlBtn = false;
// Reopens the last document
function reopenEditor(){
$('.actions,#file_action_panel').fadeOut('slow');
$('table').fadeOut('slow', function(){
$('#controls .last').not('#breadcrumb_file').removeClass('last');
$('#editor').fadeIn('fast');
$('#editorcontrols').fadeIn('fast', function(){
// TODO fix detection of ctrl keyup
// returns true if ctrl+s or cmd+s is being pressed
function checkForSaveKeyPress(e){
if(e.which == 17 || e.which == 91) ctrlBtn=true;
if(e.which == 83 && ctrlBtn == true) {
e.preventDefault();
$('#editor_save').trigger('click');
return false;
}
});
});
is_editor_shown = true;
}
// resizes the editor window
@ -285,6 +322,11 @@ $(document).ready(function(){
// Binds the file save and close editor events, and gotoline button
bindControlEvents();
$('#editor').remove();
// Binds the save keyboard shortcut events
//$(document).unbind('keydown').bind('keydown',checkForSaveKeyPress);
$('#notification').click(function(){
if($('#notification').data('reopeneditor'))
{
reopenEditor();
}
$('#notification').fadeOut();
});
});

View file

@ -2,8 +2,8 @@
<info>
<id>remoteStorage</id>
<name>remoteStorage compatibility</name>
<description>Enables you to use ownCloud as their remote storage for unhosted applications. This app requires the Webfinger app to be enabled as well. More info on <a href="http://unhosted.org">the website of the unhosted movement</a>.</description>
<version>0.5</version>
<description>Enables you to use ownCloud as their remote storage for unhosted applications. This app requires the Webfinger app to be installed and enabled correctly. More info on <a href="http://unhosted.org">the website of the unhosted movement</a>.</description>
<version>0.6</version>
<licence>AGPL or MIT</licence>
<author>Michiel de Jong</author>
<require>2</require>

View file

@ -0,0 +1,6 @@
<Link
rel="remoteStorage"
template="<?php echo WF_BASEURL; ?>/apps/remoteStorage/WebDAV.php/<?php echo WF_USER; ?>/remoteStorage/{category}/"
api="WebDAV"
auth="<?php echo WF_BASEURL; ?>/apps/remoteStorage/auth.php/<?php echo WF_USER; ?>">
</Link>

View file

@ -7,4 +7,7 @@
<licence>AGPL</licence>
<author>Dominik Schmidt</author>
<require>2</require>
<types>
<authentication/>
</types>
</info>

View file

@ -7,4 +7,7 @@
<licence>AGPL</licence>
<author>Robin Appelman</author>
<require>2</require>
<types>
<authentication/>
</types>
</info>

View file

@ -1,3 +0,0 @@
RewriteEngine On
RewriteBase /
RewriteRule host-meta$ \/\.well-known\/host-meta\.php [L]

View file

@ -2,9 +2,9 @@
<info>
<id>user_webfinger</id>
<name>Webfinger</name>
<description>Provide WebFinger for all users so they get a user address like user@owncloudinstance which can be used for unhosted applications. If you don't run ownCloud in the root of your domain, for instance if you run it on example.com/owncloud/, then make sure you link example.com/.well-known/ to example.com/owncloud/apps/user_webfinger/ - by running something like "ln -s /var/www/owncloud/apps/user_webfinger /var/www/.well-known". Only enable this app if you run this ownCloud installation on a public web address, not if you run it on an intranet or on localhost.</description>
<version>0.2</version>
<description>Provide WebFinger for all users so they get a user address like user@owncloudinstance which can be used for external applications. Other apps can provide information for webfinger requests, such as remoteStorage compatibility.</description>
<version>0.3</version>
<licence>AGPL or MIT</licence>
<author>Michiel de Jong</author>
<author>Michiel de Jong, Florian Hülsmann</author>
<require>2</require>
</info>

View file

@ -1,6 +1,51 @@
<?php
$hostMetaHeader = array(
'Access-Control-Allow-Origin' => '*',
'Content-Type' => 'application/xml+xrd'
);
$appInfoDir = __DIR__;
$thisAppDir = dirname($appInfoDir);
$appsDir = dirname($thisAppDir);
$ownCloudDir = dirname($appsDir);
@symlink($thisAppDir, $ownCloudDir.'/.well-known');
$docRoot = $_SERVER['DOCUMENT_ROOT'];
try {
$webRoot = substr(realpath($ownCloudDir), strlen(realpath($docRoot)));
} catch(Exception $e) {
// some servers fail on realpath(), let's try it the unsecure way:
$webRoot = substr($ownCloudDir, strlen($docRoot));
}
$serverName = $_SERVER['SERVER_NAME'];
$lrddTmpl = 'http';
if(isset($_SERVER['HTTPS'])) {
$lrddTmpl .= 's';
}
$lrddTmpl .= '://' . $serverName . $webRoot . '/apps/user_webfinger/webfinger.php?q={uri}';
$hostMetaPath = $docRoot . '/.well-known/host-meta';
$hostMetaDir = $docRoot . '/.well-known';
$hostMetaContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\" xmlns:hm=\"http://host-meta.net/xrd/1.0\">
<hm:Host xmlns=\"http://host-meta.net/xrd/1.0\">" . $serverName . "</hm:Host>
<Link rel=\"lrdd\" template=\"" . $lrddTmpl . "\">
<Title>Resource Descriptor</Title>
</Link>
</XRD>";
@mkdir($hostMetaDir);
$hostMeta = fopen($hostMetaPath, 'w');
if(!$hostMeta) {
die("Could not open " . $hostMetaPath . " for writing, please check permissions!");
}
if(!fwrite($hostMeta, $hostMetaContents, strlen($hostMetaContents))) {
die("Could not write to " . $hostMetaPath . ", please check permissions!");
}
fclose($hostMeta);
// write custom headers into .htaccess:
$htaccess = fopen($hostMetaDir . '/.htaccess', 'w');
//TODO: check compatibility!
fwrite($htaccess, "<filesMatch \"^host-meta$\">
<ifModule mod_headers.c>\n");
foreach($hostMetaHeader as $header => $value) {
fwrite($htaccess, "Header set " . $header . " \"" . $value . "\"\n");
}
fwrite($htaccess, "</ifModule>\n</filesMatch>");
fclose($htaccess);

View file

@ -1 +0,0 @@
please run 'a2enmod rewrite' on your server, set 'AllowOverride All' for /var/www in /etc/apache2/sites-enabled/000-default or equivalent, and then run '/etc/init.d/apache2 restart'

View file

@ -1,16 +0,0 @@
<?php
if($_SERVER['SCRIPT_NAME'] == '/.well-known/host-meta.php') {
header("Access-Control-Allow-Origin: *");
} else {
header('Please-first: activate');
}
header("Content-Type: application/xrd+xml");
echo "<";
?>
?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0" xmlns:hm="http://host-meta.net/xrd/1.0">
<hm:Host xmlns="http://host-meta.net/xrd/1.0"><?php echo $_SERVER['SERVER_NAME'] ?></hm:Host>
<Link rel="lrdd" template="http<?php echo (isset($_SERVER['HTTPS'])?'s':''); ?>://<?php echo $_SERVER['SERVER_NAME'] ?>/.well-known/webfinger.php?q={uri}">
</Link>
</XRD>

View file

@ -1,41 +1,71 @@
<?php
if($_SERVER['SCRIPT_NAME'] == '/.well-known/webfinger.php') {
header("Access-Control-Allow-Origin: *");
} else {
header('Please-first: activate');
}
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/xrd+xml");
/**
* To include your app in the webfinger XML, add a new script with file name
* 'webfinger.php' to /apps/yourapp/appinfo/, which prints out the XML parts
* to be included. That script can make use of the constants WF_USER (e. g.
* "user"), WF_ID (user@host) and WF_BASEURL (e. g. https://host/owncloud).
* An example could look like this:
*
* <Link
* rel="myProfile"
* type="text/html"
* href="<?php echo WF_BASEURL; ?>/apps/myApp/profile.php?user=<?php echo WF_USER; ?>">
* </Link>
*
'* but can also use complex database queries to generate the webfinger result
**/
// calculate the documentroot
// modified version of the one in lib/base.php that takes the .well-known symlink into account
$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']);
/*$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']);
$SERVERROOT=str_replace("\\",'/',dirname(dirname(dirname(dirname(__FILE__)))));
$SUBURI=substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen($SERVERROOT));
$WEBROOT=substr($SUBURI,0,-34);
*/
require_once('../../lib/base.php');
$request = urldecode($_GET['q']);
if($_GET['q']) {
$bits = explode('@', $_GET['q']);
$userName = $bits[0];
$reqParts = explode('@', $request);
$userName = $reqParts[0];
$hostName = $reqParts[1];
} else {
$userName = '';
$hostName = '';
}
if(substr($userName, 0, 5) == 'acct:') {
$userName = substr($userName, 5);
}
if(isset($_SERVER['HTTPS'])) {
$baseAddress = 'https://'.$_SERVER['SERVER_NAME'].'/apps/remoteStorage/';
if($userName == "") {
$id = "";
} else {
$baseAddress = 'http://'.$_SERVER['SERVER_NAME'].'/apps/remoteStorage/';
$id = $userName . '@' . $hostName;
}
if(isset($_SERVER['HTTPS'])) {
$baseAddress = 'https://';
} else {
$baseAddress = 'http://';
}
$baseAddress .= $_SERVER['SERVER_NAME'].OC::$WEBROOT;
define('WF_USER', $userName);
define('WF_ID', $id);
define('WF_BASEURL', $baseAddress);
echo "<";
?>
?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0" xmlns:hm="http://host-meta.net/xrd/1.0">
<hm:Host xmlns="http://host-meta.net/xrd/1.0"><?php echo $_SERVER['SERVER_NAME'] ?></hm:Host>
<Link
rel="remoteStorage"
template="<?php echo $baseAddress ?>WebDAV.php/<?php echo $userName ?>/remoteStorage/{category}/"
api="WebDAV"
auth="<?php echo $baseAddress; ?>auth.php/<?php echo $userName ?>"
></Link>
<hm:Host xmlns="http://host-meta.net/xrd/1.0"><?php echo $_SERVER['SERVER_NAME']; ?></hm:Host>
<Subject>acct:<?php echo $id ?></Subject>
<?php
$apps = OC_Appconfig::getApps();
foreach($apps as $app) {
if(OC_App::isEnabled($app)) {
if(is_file(OC::$APPSROOT . '/apps/' . $app . '/appinfo/webfinger.php')) {
require($app . '/appinfo/webfinger.php');
}
}
}
?>
</XRD>

View file

@ -131,3 +131,10 @@ li.error { width:640px; margin:4em auto; padding:1em 1em 1em 4em; background:#ff
.separator { display: inline; border-left: 1px solid #d3d3d3; border-right: 1px solid #fff; height: 10px; width:0px; margin: 4px; }
a.bookmarklet { background-color: #ddd; border:1px solid #ccc; padding: 5px;padding-top: 0px;padding-bottom: 2px; text-decoration: none; margin-top: 5px }
/* ---- DIALOGS ---- */
#dirtree {width: 100%;}
#filelist {height: 270px; overflow:scroll; background-color: white;}
.filepicker_element_selected { background-color: lightblue;}
.filepicker_loader {height: 120px; width: 100%; background-color: #333; opacity: 0.3; visibility: visible; position:absolute; top:0; left:0; text-align:center; padding-top: 150px;}

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

View file

@ -126,7 +126,13 @@ OC={
});
}
},
dialogs:OCdialogs
dialogs:OCdialogs,
mtime2date:function(mtime) {
mtime = parseInt(mtime);
var date = new Date(1000*mtime);
var ret = date.getDate()+'.'+(date.getMonth()+1)+'.'+date.getFullYear()+', '+date.getHours()+':'+date.getMinutes();
return ret;
}
};
OC.search.customResults={};
OC.search.currentResult=-1;

View file

@ -17,7 +17,6 @@
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* todo(bartek): add select option in form
*/
/**
@ -30,9 +29,9 @@ OCdialogs = {
* @param title dialog title
* @param callback which will be triggered when user press OK
*/
alert:function(text, title, callback) {
alert:function(text, title, callback, modal) {
var content = '<p><span class="ui-icon ui-icon-alert"></span>'+text+'</p>';
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback);
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback, modal);
},
/**
* displays info dialog
@ -40,9 +39,9 @@ OCdialogs = {
* @param title dialog title
* @param callback which will be triggered when user press OK
*/
info:function(text, title, callback) {
info:function(text, title, callback, modal) {
var content = '<p><span class="ui-icon ui-icon-info"></span>'+text+'</p>';
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback);
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback, modal);
},
/**
* displays confirmation dialog
@ -50,9 +49,9 @@ OCdialogs = {
* @param title dialog title
* @param callback which will be triggered when user press YES or NO (true or false would be passed to callback respectively)
*/
confirm:function(text, title, callback) {
confirm:function(text, title, callback, modal) {
var content = '<p><span class="ui-icon ui-icon-notice"></span>'+text+'</p>';
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.YES_NO_BUTTONS, callback);
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.YES_NO_BUTTONS, callback, modal);
},
/**
* prompt for user input
@ -60,9 +59,9 @@ OCdialogs = {
* @param title dialog title
* @param callback which will be triggered when user press OK (input text will be passed to callback)
*/
prompt:function(text, title, default_value, callback) {
prompt:function(text, title, default_value, callback, modal) {
var content = '<p><span class="ui-icon ui-icon-pencil"></span>'+text+':<br/><input type="text" id="oc-dialog-prompt-input" value="'+default_value+'" style="width:90%"></p>';
OCdialogs.message(content, title, OCdialogs.PROMPT_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback);
OCdialogs.message(content, title, OCdialogs.PROMPT_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback, modal);
},
/**
* prompt user for input with custom form
@ -71,7 +70,7 @@ OCdialogs = {
* @param title dialog title
* @param callback which will be triggered when user press OK (user answers will be passed to callback in following format: [{name:'return name', value: 'user value'},...])
*/
form:function(fields, title, callback) {
form:function(fields, title, callback, modal) {
var content = '<table>';
for (var a in fields) {
content += '<tr><td>'+fields[a].text+'</td><td>';
@ -96,12 +95,51 @@ OCdialogs = {
content += '</td></tr>';
}
content += '</table>';
OCdialogs.message(content, title, OCdialogs.FORM_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback);
OCdialogs.message(content, title, OCdialogs.FORM_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback, modal);
},
message:function(content, title, dialog_type, buttons, callback) {
filepicker:function(title, callback, multiselect, mimetype_filter, modal) {
var c_name = 'oc-dialog-'+OCdialogs.dialogs_counter+'-content';
var c_id = '#'+c_name;
var d = '<div id="'+c_name+'" title="'+title+'"><select id="dirtree"><option value="0">'+OC.currentUser+'</option></select><div id="filelist"></div><div class="filepicker_loader"><img src="'+OC.filePath('gallery','img','loading.gif')+'"></div></div>';
if (!modal) modal = false;
if (!multiselect) multiselect = false;
$('body').append(d);
$(c_id + ' #dirtree').focus(function() { var t = $(this); t.data('oldval', t.val())})
.change({dcid: c_id}, OC.dialogs.handleTreeListSelect);
$(c_id).ready(function(){
$.getJSON(OC.webroot+'/files/ajax/rawlist.php', {mimetype: mimetype_filter} ,function(r){OC.dialogs.fillFilePicker(r, c_id, callback)});
}).data('multiselect', multiselect).data('mimetype',mimetype_filter);
// build buttons
var b = [
{text: t('dialogs', 'Choose'), click: function(){
if (callback != undefined) {
var p;
if ($(c_id).data('multiselect') == true) {
p = [];
$(c_id+' .filepicker_element_selected #filename').each(function(i, elem) {
p.push(($(c_id).data('path')?$(c_id).data('path'):'')+'/'+$(elem).text());
});
} else {
var p = $(c_id).data('path');
if (p == undefined) p = '';
p = p+'/'+$(c_id+' .filepicker_element_selected #filename').text()
}
callback(p);
$(c_id).dialog('close');
}
}
},
{text: t('dialogs', 'Cancel'), click: function(){$(c_id).dialog('close'); }}
];
$(c_id).dialog({width: 4*$(document).width()/9, height: 400, modal: modal, buttons: b});
OCdialogs.dialogs_counter++;
},
// guts, dont use, dont touch
message:function(content, title, dialog_type, buttons, callback, modal) {
var c_name = 'oc-dialog-'+OCdialogs.dialogs_counter+'-content';
var c_id = '#'+c_name;
var d = '<div id="'+c_name+'" title="'+title+'">'+content+'</div>';
if (modal == undefined) modal = false;
$('body').append(d);
var b = [];
switch (buttons) {
@ -128,7 +166,7 @@ OCdialogs = {
break;
}
var possible_height = ($('tr', d).size()+1)*30;
$(c_id).dialog({width: 4*$(document).width()/9, height: possible_height + 120, modal: false, buttons: b});
$(c_id).dialog({width: 4*$(document).width()/9, height: possible_height + 120, modal: modal, buttons: b});
OCdialogs.dialogs_counter++;
},
// dialogs buttons types
@ -161,5 +199,47 @@ OCdialogs = {
} else {
$(c_id).dialog('close');
}
},
fillFilePicker:function(r, dialog_content_id) {
var entry_template = '<div onclick="javascript:OC.dialogs.handlePickerClick(this, \'*ENTRYNAME*\',\''+dialog_content_id+'\')" data="*ENTRYTYPE*"><img src="*MIMETYPEICON*" style="margin-right:1em;"><span id="filename">*NAME*</span><div style="float:right;margin-right:1em;">*LASTMODDATE*</div></div>';
var names = '';
for (var a in r.data) {
names += entry_template.replace('*LASTMODDATE*', OC.mtime2date(r.data[a].mtime)).replace('*NAME*', r.data[a].name).replace('*MIMETYPEICON*', r.data[a].mimetype_icon).replace('*ENTRYNAME*', r.data[a].name).replace('*ENTRYTYPE*', r.data[a].type);
}
$(dialog_content_id + ' #filelist').html(names);
$(dialog_content_id + ' .filepicker_loader').css('visibility', 'hidden');
},
handleTreeListSelect:function(event) {
var newval = parseInt($(this).val());
var oldval = parseInt($(this).data('oldval'));
while (newval != oldval && oldval > 0) {
$('option:last', this).remove();
$('option:last', this).attr('selected','selected');
oldval--;
}
var skip_first = true;
var path = '';
$(this).children().each(function(i, element) { if (skip_first) {skip_first = false; return; }path += '/'+$(element).text(); });
$(event.data.dcid).data('path', path);
$(event.data.dcid + ' .filepicker_loader').css('visibility', 'visible');
$.getJSON(OC.webroot+'/files/ajax/rawlist.php', {dir: path, mimetype: $(event.data.dcid).data('mimetype')}, function(r){OC.dialogs.fillFilePicker(r, event.data.dcid)});
},
// this function is in early development state, please dont use it unlsess you know what you are doing
handlePickerClick:function(element, name, dcid) {
var p = $(dcid).data('path');
if (p == undefined) p = '';
p = p+'/'+name;
if ($(element).attr('data') == 'file'){
if ($(dcid).data('multiselect') != true)
$(dcid+' .filepicker_element_selected').removeClass('filepicker_element_selected');
$(element).toggleClass('filepicker_element_selected');
return;
}
$(dcid).data('path', p);
$(dcid + ' #dirtree option:last').removeAttr('selected');
var newval = parseInt($(dcid + ' #dirtree option:last').val())+1;
$(dcid + ' #dirtree').append('<option selected="selected" value="'+newval+'">'+name+'</option>');
$(dcid + ' .filepicker_loader').css('visibility', 'visible');
$.getJSON(OC.webroot+'/files/ajax/rawlist.php', {dir: p, mimetype: $(dcid).data('mimetype')}, function(r){OC.dialogs.fillFilePicker(r, dcid)});
}
};

View file

@ -19,7 +19,7 @@ OCCategories={
height: 350, minHeight:200, width: 250, minWidth: 200,
buttons: {
'Delete':function() {
OCCategories.delete();
OCCategories.do_delete();
},
'Rescan':function() {
OCCategories.rescan();
@ -53,7 +53,7 @@ OCCategories={
}
});
},
delete:function(){
do_delete:function(){
var categories = $('#categorylist').find('input[type="checkbox"]').serialize();
categories += '&app=' + OCCategories.app;
console.log('OCCategories.delete: ' + categories);

View file

@ -12,7 +12,7 @@ require_once('../../lib/base.php');
// Someone lost their password:
if (isset($_POST['user'])) {
if (OC_User::userExists($_POST['user'])) {
$token = sha1($_POST['user']+uniqId());
$token = sha1($_POST['user'].md5(uniqid(rand(), true)));
OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', $token);
$email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
if (!empty($email)) {

26
files/ajax/rawlist.php Normal file
View file

@ -0,0 +1,26 @@
<?php
// only need filesystem apps
$RUNTIME_APPTYPES=array('filesystem');
// Init owncloud
require_once('../../lib/base.php');
require_once('../../lib/template.php');
OC_JSON::checkLoggedIn();
// Load the files
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
$mimetype = isset($_GET['mimetype']) ? $_GET['mimetype'] : '';
// make filelist
$files = array();
foreach( OC_Files::getdirectorycontent( $dir, $mimetype ) as $i ){
$i["date"] = OC_Util::formatDate($i["mtime"] );
$i['mimetype_icon'] = $i['type'] == 'dir' ? mimetype_icon('dir'): mimetype_icon($i['mimetype']);
$files[] = $i;
}
OC_JSON::success(array('data' => $files));
?>

View file

@ -27,7 +27,7 @@
$RUNTIME_NOSETUPFS = true;
// only need filesystem apps
$RUNTIME_APPTYPES=array('filesystem');
$RUNTIME_APPTYPES=array('filesystem','authentication');
require_once('../lib/base.php');

View file

@ -55,7 +55,7 @@ class OC_App{
// Our very own core apps are hardcoded
foreach( array('files', 'settings') as $app ){
if(is_null($types) or self::isType($app,$types)){
if(is_null($types)){
require( $app.'/appinfo/app.php' );
}
}
@ -103,9 +103,9 @@ class OC_App{
*/
public static function getEnabledApps(){
$apps=array();
$query = OC_DB::prepare( 'SELECT appid FROM *PREFIX*appconfig WHERE configkey = "enabled" AND configvalue="yes"' );
$query->execute();
while($row=$query->fetchRow()){
$query = OC_DB::prepare( 'SELECT appid FROM *PREFIX*appconfig WHERE configkey = \'enabled\' AND configvalue=\'yes\'' );
$result=$query->execute();
while($row=$result->fetchRow()){
$apps[]=$row['appid'];
}
return $apps;
@ -452,7 +452,7 @@ class OC_App{
*/
public static function getAppVersions(){
$versions=array();
$query = OC_DB::prepare( 'SELECT appid, configvalue FROM *PREFIX*appconfig WHERE configkey = "installed_version"' );
$query = OC_DB::prepare( 'SELECT appid, configvalue FROM *PREFIX*appconfig WHERE configkey = \'installed_version\'' );
$result = $query->execute();
while($row = $result->fetchRow()){
$versions[$row['appid']]=$row['configvalue'];

View file

@ -277,6 +277,24 @@ class OC{
date_default_timezone_set('Europe/Berlin');
ini_set('arg_separator.output','&amp;');
//try to configure php to enable big file uploads.
//this doesn´t work always depending on the webserver and php configuration.
//Let´s try to overwrite some defaults anyways
//try to set the maximum execution time to 60min
@set_time_limit(3600);
@ini_set('max_execution_time',3600);
@ini_set('max_input_time',3600);
//try to set the maximum filesize to 10G
@ini_set('upload_max_filesize','10G');
@ini_set('post_max_size','10G');
@ini_set('file_uploads','50');
//try to set the session lifetime to 60min
@ini_set('gc_maxlifetime','3600');
//set http auth headers for apache+php-cgi work around
if (isset($_SERVER['HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['HTTP_AUTHORIZATION'], $matches))
{
@ -347,6 +365,9 @@ class OC{
OC_App::loadApps();
}
}
// Check for blacklisted files
OC_Hook::connect('OC_Filesystem','write','OC_Filesystem','isBlacklisted');
//make sure temporary files are cleaned up
register_shutdown_function(array('OC_Helper','cleanTmp'));

View file

@ -240,7 +240,7 @@ class OC_FileCache{
* - encrypted
* - versioned
*/
public static function getFolderContent($path,$root=''){
public static function getFolderContent($path,$root='',$mimetype_filter=''){
if(self::isUpdated($path,$root)){
self::updateFolder($path,$root);
}
@ -252,8 +252,8 @@ class OC_FileCache{
}
$path=$root.$path;
$parent=self::getFileId($path);
$query=OC_DB::prepare('SELECT name,ctime,mtime,mimetype,size,encrypted,versioned,writable FROM *PREFIX*fscache WHERE parent=?');
$result=$query->execute(array($parent))->fetchAll();
$query=OC_DB::prepare('SELECT name,ctime,mtime,mimetype,size,encrypted,versioned,writable FROM *PREFIX*fscache WHERE parent=? AND (mimetype LIKE ? OR mimetype = ?)');
$result=$query->execute(array($parent, $mimetype_filter.'%', 'httpd/unix-directory'))->fetchAll();
if(is_array($result)){
return $result;
}else{

View file

@ -32,11 +32,11 @@ class OC_Files {
* get the content of a directory
* @param dir $directory
*/
public static function getDirectoryContent($directory){
public static function getDirectoryContent($directory, $mimetype_filter = ''){
if(strpos($directory,OC::$CONFIG_DATADIRECTORY)===0){
$directory=substr($directory,strlen(OC::$CONFIG_DATADIRECTORY));
}
$files=OC_FileCache::getFolderContent($directory);
$files=OC_FileCache::getFolderContent($directory, '', $mimetype_filter);
foreach($files as &$file){
$file['directory']=$directory;
$file['type']=($file['mimetype']=='httpd/unix-directory')?'dir':'file';

View file

@ -86,6 +86,10 @@ class OC_Filestorage_Local extends OC_Filestorage{
return $this->delTree($path);
}
public function rename($path1,$path2){
if (!$this->is_writable($path1)) {
OC_Log::write('core','unable to rename, file is not writable : '.$path1,OC_Log::ERROR);
return false;
}
if(! $this->file_exists($path1)){
OC_Log::write('core','unable to rename, file does not exists : '.$path1,OC_Log::ERROR);
return false;

View file

@ -298,6 +298,19 @@ class OC_Filesystem{
}
return true;
}
/**
* checks if a file is blacklsited for storage in the filesystem
* @param array $data from hook
*/
static public function isBlacklisted($data){
$blacklist = array('.htaccess');
$filename = strtolower(basename($data['path']));
if(in_array($filename,$blacklist)){
$data['run'] = false;
}
}
/**
* following functions are equivilent to their php buildin equivilents for arguments/return values.
*/

View file

@ -137,13 +137,16 @@ class OC_FilesystemView {
}
public function readfile($path){
$handle=$this->fopen($path,'r');
$chunkSize = 1024*1024;// 1 MB chunks
while (!feof($handle)) {
echo fread($handle, $chunkSize);
@ob_flush();
flush();
if ($handle) {
$chunkSize = 1024*1024;// 1 MB chunks
while (!feof($handle)) {
echo fread($handle, $chunkSize);
@ob_flush();
flush();
}
return $this->filesize($path);
}
return $this->filesize($path);
return false;
}
public function is_readable($path){
return $this->basicOperation('is_readable',$path);
@ -189,7 +192,7 @@ class OC_FilesystemView {
return $this->basicOperation('unlink',$path,array('delete'));
}
public function rename($path1,$path2){
if(OC_FileProxy::runPreProxies('rename',$path1,$path2) and $this->is_writable($path1) and OC_Filesystem::isValidPath($path2)){
if(OC_FileProxy::runPreProxies('rename',$path1,$path2) and OC_Filesystem::isValidPath($path2)){
$run=true;
OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_rename, array( OC_Filesystem::signal_param_oldpath => $path1 , OC_Filesystem::signal_param_newpath=>$path2, OC_Filesystem::signal_param_run => &$run));
if($run){

View file

@ -16,5 +16,6 @@ return array(
'xls'=>'application/msexcel',
'xlsx'=>'application/msexcel',
'ppt'=>'application/mspowerpoint',
'pptx'=>'application/mspowerpoint'
'pptx'=>'application/mspowerpoint',
'sgf' => 'application/sgf'
);

View file

@ -36,6 +36,7 @@ class OC_Updater{
$version['installed']=OC_Config::getValue('installedat');
$version['updated']=OC_Appconfig::getValue('core', 'lastupdatedat', OC_Config::getValue( 'lastupdatedat'));
$version['updatechannel']='stable';
$version['edition']=OC_Util::getEditionString();
$versionstring=implode('x',$version);
//fetch xml data from updater

View file

@ -77,6 +77,14 @@ class OC_Util {
return '3';
}
/**
* get the current installed edition of ownCloud. There is the community edition that just returns an empty string and the enterprise edition that returns "Enterprise".
* @return string
*/
public static function getEditionString(){
return '';
}
/**
* add a javascript file
*

View file

@ -5,7 +5,7 @@
*/?>
<div id="controls">
<a class="button" target="_blank" href="http://owncloud.org/contribute/writing-apps/"><?php echo $l->t('Add your application');?></a>
<a class="button" target="_blank" href="http://owncloud.org/dev/writing-apps/"><?php echo $l->t('Add your application');?></a>
</div>
<ul id="leftcontent">
<?php foreach($_['apps'] as $app):?>

View file

@ -50,7 +50,7 @@
};?>
<p class="personalblock">
<strong>ownCloud</strong> <?php echo(OC_Util::getVersionString()); ?><br />
<strong>ownCloud</strong> <?php echo(OC_Util::getVersionString()); ?> <?php echo(OC_Util::getEditionString()); ?><br />
developed by the <a href="http://ownCloud.org/credits" target="_blank">ownCloud community</a><br />
<?php echo(OC_Updater::ShowUpdatingHint()); ?><br />
<a href="http://gitorious.org/owncloud" target="_blank">source code</a> licensed freely under <a href="http://www.gnu.org/licenses/agpl-3.0.html" target="_blank">AGPL</a>

View file

@ -26,7 +26,7 @@ $RUNTIME_NOAPPS = TRUE; //no apps, yet
require_once('lib/base.php');
if(OC_Config::getValue('installed')==1) $installed='true'; else $installed='false';
$values=array('installed'=>$installed,'version'=>implode('.',OC_Util::getVersion()),'versionstring'=>OC_Util::getVersionString());
$values=array('installed'=>$installed,'version'=>implode('.',OC_Util::getVersion()),'versionstring'=>OC_Util::getVersionString(),'edition'=>OC_Util::getEditionString());
echo(json_encode($values));