summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Karlitschek <frank@owncloud.org>2012-06-29 11:08:43 +0200
committerFrank Karlitschek <frank@owncloud.org>2012-06-29 11:08:43 +0200
commitbd908affa3972653c99e4a9f7f0bc846d81e0b16 (patch)
tree498cb42dd3b387c94e879b03a68d04e5fb1ec1c4
parent6917d741931acb8d8a5dddbc6c668a5b75960a91 (diff)
parent75af5778a4e034600edd2e891f8c70e6e807808a (diff)
downloadnextcloud-server-bd908affa3972653c99e4a9f7f0bc846d81e0b16.tar.gz
nextcloud-server-bd908affa3972653c99e4a9f7f0bc846d81e0b16.zip
Merge branch 'master' of gitorious.org:owncloud/owncloud
-rw-r--r--apps/bookmarks/appinfo/migrate.php8
-rw-r--r--apps/calendar/js/loader.js2
-rw-r--r--apps/contacts/ajax/contacts.php36
-rw-r--r--apps/contacts/ajax/loadphoto.php10
-rw-r--r--apps/contacts/appinfo/migrate.php9
-rw-r--r--apps/contacts/css/contacts.css6
-rw-r--r--apps/contacts/js/contacts.js198
-rw-r--r--apps/contacts/lib/vcard.php14
-rw-r--r--apps/contacts/templates/part.contact.php8
-rw-r--r--apps/contacts/templates/part.contactphoto.php16
-rw-r--r--apps/contacts/templates/part.contacts.php10
-rw-r--r--apps/files_external/js/settings.js4
-rw-r--r--apps/files_external/lib/amazons3.php4
-rwxr-xr-xapps/files_external/personal.php2
-rw-r--r--apps/files_external/settings.php2
-rw-r--r--apps/files_external/templates/settings.php2
-rw-r--r--apps/files_versions/ajax/getVersions.php2
-rw-r--r--apps/files_versions/appinfo/app.php3
-rw-r--r--apps/files_versions/versions.php37
-rw-r--r--apps/gallery/lib/managers.php24
-rwxr-xr-xlib/app.php8
-rw-r--r--lib/helper.php9
-rw-r--r--lib/migrate.php6
-rw-r--r--lib/setup.php37
24 files changed, 284 insertions, 173 deletions
diff --git a/apps/bookmarks/appinfo/migrate.php b/apps/bookmarks/appinfo/migrate.php
index e7e572f52dc..f1353f1887e 100644
--- a/apps/bookmarks/appinfo/migrate.php
+++ b/apps/bookmarks/appinfo/migrate.php
@@ -40,8 +40,8 @@ class OC_Migration_Provider_Bookmarks extends OC_Migration_Provider{
$idmap = array();
while( $row = $results->fetchRow() ){
// Import each bookmark, saving its id into the map
- $query = OCP\DB::prepare( "INSERT INTO *PREFIX*bookmarks(url, title, user_id, public, added, lastmodified) VALUES (?, ?, ?, ?, ?, ?)" );
- $query->execute( array( $row['url'], $row['title'], $this->uid, $row['public'], $row['added'], $row['lastmodified'] ) );
+ $bookmarkquery = OCP\DB::prepare( "INSERT INTO *PREFIX*bookmarks(url, title, user_id, public, added, lastmodified) VALUES (?, ?, ?, ?, ?, ?)" );
+ $bookmarkquery->execute( array( $row['url'], $row['title'], $this->uid, $row['public'], $row['added'], $row['lastmodified'] ) );
// Map the id
$idmap[$row['id']] = OCP\DB::insertid();
}
@@ -51,8 +51,8 @@ class OC_Migration_Provider_Bookmarks extends OC_Migration_Provider{
$results = $query->execute( array( $oldid ) );
while( $row = $results->fetchRow() ){
// Import the tags for this bookmark, using the new bookmark id
- $query = OCP\DB::prepare( "INSERT INTO *PREFIX*bookmarks_tags(bookmark_id, tag) VALUES (?, ?)" );
- $query->execute( array( $newid, $row['tag'] ) );
+ $tagquery = OCP\DB::prepare( "INSERT INTO *PREFIX*bookmarks_tags(bookmark_id, tag) VALUES (?, ?)" );
+ $tagquery->execute( array( $newid, $row['tag'] ) );
}
}
// All done!
diff --git a/apps/calendar/js/loader.js b/apps/calendar/js/loader.js
index 0fc5018e89c..cef95afc3aa 100644
--- a/apps/calendar/js/loader.js
+++ b/apps/calendar/js/loader.js
@@ -44,7 +44,7 @@ Calendar_Import={
$('#newcalendar').attr('readonly', 'readonly');
$('#calendar').attr('disabled', 'disabled');
var progresskey = $('#progresskey').val();
- $.post(OC.filePath('calendar', 'ajax/import', 'import.php') + '?progresskey='+progresskey, {method: String (method), calname: String (calname), path: String (path), file: String (filename), id: String (calid)}, function(data){
+ $.post(OC.filePath('calendar', 'ajax/import', 'import.php'), {progresskey: progresskey, method: String (method), calname: String (calname), path: String (path), file: String (filename), id: String (calid)}, function(data){
if(data.status == 'success'){
$('#progressbar').progressbar('option', 'value', 100);
$('#import_done').css('display', 'block');
diff --git a/apps/contacts/ajax/contacts.php b/apps/contacts/ajax/contacts.php
index 07b442159c9..67ebcaf7362 100644
--- a/apps/contacts/ajax/contacts.php
+++ b/apps/contacts/ajax/contacts.php
@@ -17,24 +17,44 @@ function cmp($a, $b)
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-$active_addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
+$start = isset($_GET['startat'])?$_GET['startat']:0;
+$aid = isset($_GET['aid'])?$_GET['aid']:null;
+if(is_null($aid)) {
+ // Called initially to get the active addressbooks.
+ $active_addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
+} else {
+ // called each time more contacts has to be shown.
+ $active_addressbooks = array(OC_Contacts_Addressbook::find($aid));
+}
+
+
+session_write_close();
+
+// create the addressbook associate array
$contacts_addressbook = array();
$ids = array();
foreach($active_addressbooks as $addressbook) {
$ids[] = $addressbook['id'];
if(!isset($contacts_addressbook[$addressbook['id']])) {
- $contacts_addressbook[$addressbook['id']] = array('contacts' => array());
+ $contacts_addressbook[$addressbook['id']] = array('contacts' => array('type' => 'book',));
$contacts_addressbook[$addressbook['id']]['displayname'] = $addressbook['displayname'];
}
}
-$contacts_alphabet = OC_Contacts_VCard::all($ids);
+$contacts_alphabet = array();
+
+// get next 50 for each addressbook.
+foreach($ids as $id) {
+ if($id) {
+ $contacts_alphabet = array_merge($contacts_alphabet, OC_Contacts_VCard::all($id, $start, 50));
+ }
+}
// Our new array for the contacts sorted by addressbook
if($contacts_alphabet) {
foreach($contacts_alphabet as $contact) {
if(!isset($contacts_addressbook[$contact['addressbookid']])) { // It should never execute.
- $contacts_addressbook[$contact['addressbookid']] = array('contacts' => array());
+ $contacts_addressbook[$contact['addressbookid']] = array('contacts' => array('type' => 'book',));
}
$display = trim($contact['fullname']);
if(!$display) {
@@ -44,15 +64,11 @@ if($contacts_alphabet) {
$display = isset($struct['EMAIL'][0])?$struct['EMAIL'][0]['value']:'[UNKNOWN]';
}
}
- $contacts_addressbook[$contact['addressbookid']]['contacts'][] = array('id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'displayname' => htmlspecialchars($display));
+ $contacts_addressbook[$contact['addressbookid']]['contacts'][] = array('type' => 'contact', 'id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'displayname' => htmlspecialchars($display));
}
}
unset($contacts_alphabet);
uasort($contacts_addressbook, 'cmp');
-$tmpl = new OCP\Template("contacts", "part.contacts");
-$tmpl->assign('books', $contacts_addressbook, false);
-$page = $tmpl->fetchPage();
-
-OCP\JSON::success(array('data' => array( 'page' => $page )));
+OCP\JSON::success(array('data' => array('entries' => $contacts_addressbook)));
diff --git a/apps/contacts/ajax/loadphoto.php b/apps/contacts/ajax/loadphoto.php
index 61b5356edce..a35631055eb 100644
--- a/apps/contacts/ajax/loadphoto.php
+++ b/apps/contacts/ajax/loadphoto.php
@@ -42,11 +42,5 @@ foreach($vcard->children as $property){
}
}
-$tmpl = new OCP\Template("contacts", "part.contactphoto");
-$tmpl->assign('id', $id);
-if($refresh) {
- $tmpl->assign('refresh', 1);
-}
-$page = $tmpl->fetchPage();
-OCP\JSON::success(array('data' => array('page'=>$page, 'checksum'=>$checksum)));
-?>
+OCP\JSON::success(array('data' => array('checksum'=>$checksum)));
+
diff --git a/apps/contacts/appinfo/migrate.php b/apps/contacts/appinfo/migrate.php
index 1400cdf79d4..cceb4406172 100644
--- a/apps/contacts/appinfo/migrate.php
+++ b/apps/contacts/appinfo/migrate.php
@@ -40,19 +40,20 @@ class OC_Migration_Provider_Contacts extends OC_Migration_Provider{
$idmap = array();
while( $row = $results->fetchRow() ){
// Import each bookmark, saving its id into the map
- $query = OCP\DB::prepare( "INSERT INTO *PREFIX*contacts_addressbooks (`userid`, `displayname`, `uri`, `description`, `ctag`) VALUES (?, ?, ?, ?, ?)" );
- $query->execute( array( $this->uid, $row['displayname'], $row['uri'], $row['description'], $row['ctag'] ) );
+ $addressbookquery = OCP\DB::prepare( "INSERT INTO *PREFIX*contacts_addressbooks (`userid`, `displayname`, `uri`, `description`, `ctag`) VALUES (?, ?, ?, ?, ?)" );
+ $addressbookquery->execute( array( $this->uid, $row['displayname'], $row['uri'], $row['description'], $row['ctag'] ) );
// Map the id
$idmap[$row['id']] = OCP\DB::insertid();
}
// Now tags
foreach($idmap as $oldid => $newid){
+
$query = $this->content->prepare( "SELECT * FROM contacts_cards WHERE addressbookid LIKE ?" );
$results = $query->execute( array( $oldid ) );
while( $row = $results->fetchRow() ){
// Import the tags for this bookmark, using the new bookmark id
- $query = OCP\DB::prepare( "INSERT INTO *PREFIX*contacts_cards (`addressbookid`, `fullname`, `carddata`, `uri`, `lastmodified`) VALUES (?, ?, ?, ?, ?)" );
- $query->execute( array( $newid, $row['fullname'], $row['carddata'], $row['uri'], $row['lastmodified'] ) );
+ $contactquery = OCP\DB::prepare( "INSERT INTO *PREFIX*contacts_cards (`addressbookid`, `fullname`, `carddata`, `uri`, `lastmodified`) VALUES (?, ?, ?, ?, ?)" );
+ $contactquery->execute( array( $newid, $row['fullname'], $row['carddata'], $row['uri'], $row['lastmodified'] ) );
}
}
// All done!
diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css
index 1766c28761e..ce4daa1d3a1 100644
--- a/apps/contacts/css/contacts.css
+++ b/apps/contacts/css/contacts.css
@@ -73,10 +73,10 @@ label:hover, dt:hover { color: #333; }
.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;*/ }
#cropbox { margin: auto; }
-#contacts_details_photo_wrapper { min-width: 120px; }
+#contacts_details_photo_wrapper { width: 200px; }
#contacts_details_photo_wrapper.wait { opacity: 0.6; filter:alpha(opacity=0.6); z-index:1000; background: url('%webroot%/core/img/loading.gif') no-repeat center center; cursor: wait; }
-#contacts_details_photo { border-radius: 0.5em; border: thin solid #bbb; margin: 0.3em; background: url('%webroot%/core/img/loading.gif') no-repeat center center; -moz-box-shadow: 0 1px 3px #777; -webkit-box-shadow: 0 1px 3px #777; box-shadow: 0 1px 3px #777; }
-#contacts_details_photo:hover { background: #fff; cursor: default; }
+.contacts_details_photo { border-radius: 0.5em; border: thin solid #bbb; margin: 0.3em; background: url('%webroot%/core/img/loading.gif') no-repeat center center; -moz-box-shadow: 0 1px 3px #777; -webkit-box-shadow: 0 1px 3px #777; box-shadow: 0 1px 3px #777; opacity: 1; }
+.contacts_details_photo:hover { background: #fff; cursor: default; }
#phototools { position:absolute; margin: 5px 0 0 10px; width:auto; height:22px; padding:0px; background-color:#fff; list-style-type:none; border-radius: 0.5em; -moz-box-shadow: 0 1px 3px #777; -webkit-box-shadow: 0 1px 3px #777; box-shadow: 0 1px 3px #777; }
#phototools li { display: inline; }
#phototools li a { float:left; cursor:pointer; width:22px; height:22px; opacity: 0.6; }
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index e5326ad8805..9d41b70a314 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -144,6 +144,31 @@ Contacts={
$('#edit_name').click(function(){Contacts.UI.Card.editName()});
$('#edit_name').keydown(function(){Contacts.UI.Card.editName()});
+ $('#phototools li a').click(function() {
+ $(this).tipsy('hide');
+ });
+ $('#contacts_details_photo_wrapper').hover(
+ function () {
+ $('#phototools').slideDown(200);
+ },
+ function () {
+ $('#phototools').slideUp(200);
+ }
+ );
+ $('#phototools').hover(
+ function () {
+ $(this).removeClass('transparent');
+ },
+ function () {
+ $(this).addClass('transparent');
+ }
+ );
+ $('#phototools .upload').click(function() {
+ $('#file_upload_start').trigger('click');
+ });
+ $('#phototools .cloud').click(function() {
+ OC.dialogs.filepicker(t('contacts', 'Select photo'), Contacts.UI.Card.cloudPhotoSelected, false, 'image', true);
+ });
/* Initialize the photo edit dialog */
$('#edit_photo_dialog').dialog({
autoOpen: false, modal: true, height: 'auto', width: 'auto'
@@ -273,7 +298,7 @@ Contacts={
update:function(id, bookid) {
var newid, firstitem;
if(!id) {
- firstitem = $('#contacts:first-child li:first-child');
+ firstitem = $('#contacts ul').first().find('li:first-child');
if(firstitem.length > 0) {
newid = firstitem.data('id');
bookid = firstitem.data('bookid');
@@ -285,6 +310,7 @@ Contacts={
if(!bookid) {
bookid = $('#contacts h3').first().data('id');
}
+ console.log('bookid: ' +bookid);
var localLoadContact = function(newid, bookid) {
if($('.contacts li').length > 0) {
$('#contacts li[data-id="'+newid+'"]').addClass('active');
@@ -340,6 +366,9 @@ Contacts={
Contacts.UI.Card.add(';;;;;', '', '', true);
return false;
},
+ createEntry:function(data) {
+ return $('<li data-id="'+data.id+'" data-bookid="'+data.addressbookid+'" role="button"><a href="'+OC.linkTo('contacts', 'index.php')+'&id='+data.id+'" style="background: url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+data.id+') no-repeat scroll 0% 0% transparent;">'+data.displayname+'</a></li>');
+ },
add:function(n, fn, aid, isnew){ // add a new contact
aid = aid?aid:$('#contacts h3.active').first().data('id');
var localAddcontact = function(n, fn, aid, isnew) {
@@ -1105,25 +1134,6 @@ Contacts={
loadPhotoHandlers:function(){
$('#phototools li a').tipsy('hide');
$('#phototools li a').tipsy();
- $('#phototools li a').click(function() {
- $(this).tipsy('hide');
- });
- $('#contacts_details_photo_wrapper').hover(
- function () {
- $('#phototools').slideDown(200);
- },
- function () {
- $('#phototools').slideUp(200);
- }
- );
- $('#phototools').hover(
- function () {
- $(this).removeClass('transparent');
- },
- function () {
- $(this).addClass('transparent');
- }
- );
if(this.data.PHOTO) {
$('#phototools .delete').click(function() {
$(this).tipsy('hide');
@@ -1134,16 +1144,12 @@ Contacts={
$(this).tipsy('hide');
Contacts.UI.Card.editCurrentPhoto();
});
+ $('#phototools .delete').show();
+ $('#phototools .edit').show();
} else {
$('#phototools .delete').hide();
$('#phototools .edit').hide();
}
- $('#phototools .upload').click(function() {
- $('#file_upload_start').trigger('click');
- });
- $('#phototools .cloud').click(function() {
- OC.dialogs.filepicker(t('contacts', 'Select photo'), Contacts.UI.Card.cloudPhotoSelected, false, 'image', true);
- });
},
cloudPhotoSelected:function(path){
$.getJSON(OC.filePath('contacts', 'ajax', 'oc_photo.php'),{'path':path,'id':Contacts.UI.Card.id},function(jsondata){
@@ -1158,22 +1164,33 @@ Contacts={
});
},
loadPhoto:function(refresh){
+ var self = this;
+ var refreshstr = (refresh?'&refresh=1'+Math.random():'')
$('#phototools li a').tipsy('hide');
var wrapper = $('#contacts_details_photo_wrapper');
- wrapper.addClass('wait');
+ wrapper.addClass('loading').addClass('wait');
+
+ var img = new Image();
+ $(img).load(function () {
+ $('img.contacts_details_photo').remove()
+ $(this).addClass('contacts_details_photo').hide();
+ wrapper.removeClass('loading').removeClass('wait');
+ $(this).insertAfter($('#phototools')).fadeIn();
+ }).error(function () {
+ // notify the user that the image could not be loaded
+ $(t('contacts','something went wrong.')).insertAfter($('#phototools'));
+ }).attr('src', OC.linkTo('contacts', 'photo.php')+'?id='+self.id+refreshstr);
+
$.getJSON(OC.filePath('contacts', 'ajax', 'loadphoto.php'),{'id':this.id, 'refresh': refresh},function(jsondata){
if(jsondata.status == 'success'){
$('#contacts_details_photo_wrapper').data('checksum', jsondata.data.checksum);
- wrapper.html(jsondata.data.page).ready(function(){ wrapper.removeClass('wait').tipsy() });
Contacts.UI.Card.loadPhotoHandlers();
}
else{
- wrapper.removeClass('wait');
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
$('#file_upload_form').show();
- $('#contacts_propertymenu_dropdown a[data-type="PHOTO"]').parent().hide();
},
editCurrentPhoto:function(){
$.getJSON(OC.filePath('contacts', 'ajax', 'currentphoto.php'),{'id':this.id},function(jsondata){
@@ -1209,15 +1226,15 @@ Contacts={
var target = $('#crop_target');
var form = $('#cropform');
var wrapper = $('#contacts_details_photo_wrapper');
+ var self = this;
wrapper.addClass('wait');
form.submit();
target.load(function(){
var response=jQuery.parseJSON(target.contents().text());
if(response != undefined && response.status == 'success'){
// load cropped photo.
- wrapper.html(response.data.page).ready(function(){ wrapper.removeClass('wait') });
+ self.loadPhoto(true);
Contacts.UI.Card.data.PHOTO = true;
- Contacts.UI.Card.loadPhotoHandlers();
}else{
OC.dialogs.alert(response.data.message, t('contacts', 'Error'));
wrapper.removeClass('wait');
@@ -1532,6 +1549,7 @@ Contacts={
}
},
Contacts:{
+ batchnum:50,
drop:function(event, ui) {
var dragitem = ui.draggable, droptarget = $(this);
//console.log('Drop ' + dragitem.data('id') +' on: ' + droptarget.data('id'));
@@ -1563,64 +1581,79 @@ Contacts={
});
},
// Reload the contacts list.
- update:function(id){
- $.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),{},function(jsondata){
+ update:function(id, aid, start){
+ self = this;
+ console.log('update: ' + aid + ' ' + start);
+ var firstrun = false;
+ var opts = {};
+ opts['startat'] = (start?start:0);
+ if(aid) {
+ opts['aid'] = aid;
+ }
+ $.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),opts,function(jsondata){
if(jsondata.status == 'success'){
- $('#contacts').html(jsondata.data.page).ready(function() {
- /*setTimeout(function() {
- $('.contacts li').unbind('inview');
- $('.contacts li:visible').bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
- if (isInView) {
- if (!$(this).find('a').attr('style')) {
- $(this).find('a').css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+$(this).data('id')+') no-repeat');
- }
+ var books = jsondata.data.entries;
+ $.each(jsondata.data.entries, 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" data-id="'+b+'"></ul>');
+ } else {
+ if(!$('#contacts h3[data-id="'+b+'"]').length) {
+ $('<h3 class="addressbook" data-id="'+b+'">'+book.displayname+'</h3><ul class="contacts" data-id="'+b+'"></ul>')
+ .appendTo('#contacts');
}
- })}, 100);
- setTimeout(Contacts.UI.Contacts.lazyupdate, 500);*/
- if($('#contacts h3').length > 1) {
- $('#contacts h3,#contacts ul').each(function(index) {
- var id = $(this).data('id');
- var accept = 'li:not([data-bookid="'+id+'"])';
- $(this).droppable({
- drop: Contacts.UI.Contacts.drop,
- activeClass: 'ui-state-hover',
- accept: accept
- });
+ }
+ $('#contacts h3[data-id="'+b+'"]').on('click', function(event) {
+ $('#contacts h3').removeClass('active');
+ $(this).addClass('active');
+ $('#contacts ul[data-id="'+b+'"]').slideToggle(300);
+ return false;
});
- $('#contacts li').draggable({
- revert: 'invalid',
- axis: 'y', containment: '#contacts',
- scroll: true, scrollSensitivity: 100,
- opacity: 0.7, helper: 'clone'
+ var accept = 'li:not([data-bookid="'+b+'"])';
+ $('#contacts h3[data-id="'+b+'"]').droppable({
+ drop: Contacts.UI.Contacts.drop,
+ activeClass: 'ui-state-hover',
+ accept: accept
});
- } else {
- $('#contacts h3').first().addClass('active');
+ }
+ var contactlist = $('#contacts ul[data-id="'+b+'"]');
+ for(var c in book.contacts) {
+ if(book.contacts[c].id == undefined) { continue; }
+ var contact = Contacts.UI.Card.createEntry(book.contacts[c]);
+ if(c == self.batchnum-5) {
+ contact.bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
+ $(this).unbind(event);
+ var bookid = $(this).data('bookid');
+ 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);
+ }
+ });
+ }
+ contactlist.append(contact);
}
});
- Contacts.UI.Card.update(id);
+ if($('#contacts h3').length > 1) {
+ $('#contacts li').draggable({
+ revert: 'invalid',
+ axis: 'y', containment: '#contacts',
+ scroll: true, scrollSensitivity: 100,
+ opacity: 0.7, helper: 'clone'
+ });
+ } else {
+ $('#contacts h3').first().addClass('active');
+ }
+ if(opts['startat'] == 0) { // only update card on first load.
+ Contacts.UI.Card.update();
+ }
}
else{
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
- /*setTimeout(function() {
- $('.contacts li').unbind('inview');
- $('.contacts li:visible').bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
- if (isInView) {
- if (!$(this).find('a').attr('style')) {
- $(this).find('a').css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+$(this).data('id')+') no-repeat');
- }
- }
- })}, 500);
- setTimeout(Contacts.UI.Contacts.lazyupdate, 500);*/
- },
- // 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')) {
- $(this).find('a').css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+$(this).data('id')+') no-repeat');
- }
- });
},
refreshThumbnail:function(id){
var item = $('.contacts li[data-id="'+id+'"]').find('a');
@@ -1681,13 +1714,6 @@ $(document).ready(function(){
return false;
});
- $(document).on('click', '.addressbook', function(event){
- $('#contacts h3').removeClass('active');
- $(this).addClass('active');
- $(this).next().slideToggle(300);
- 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
diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php
index bf22be0de74..e3b65605624 100644
--- a/apps/contacts/lib/vcard.php
+++ b/apps/contacts/lib/vcard.php
@@ -47,11 +47,18 @@ class OC_Contacts_VCard{
* The cards are associative arrays. You'll find the original vCard in
* ['carddata']
*/
- public static function all($id){
+ public static function all($id, $start=null, $num=null){
+ $limitsql = '';
+ if(!is_null($num)) {
+ $limitsql = ' LIMIT '.$num;
+ }
+ if(!is_null($start) && !is_null($num)) {
+ $limitsql .= ' OFFSET '.$start.' ';
+ }
$result = null;
if(is_array($id) && count($id)) {
$id_sql = join(',', array_fill(0, count($id), '?'));
- $prep = 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid IN ('.$id_sql.') ORDER BY fullname';
+ $prep = 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid IN ('.$id_sql.') ORDER BY fullname '.$limitsql;
try {
$stmt = OCP\DB::prepare( $prep );
$result = $stmt->execute($id);
@@ -63,7 +70,8 @@ class OC_Contacts_VCard{
}
} elseif(is_int($id) || is_string($id)) {
try {
- $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' );
+ $sql = 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname'.$limitsql;
+ $stmt = OCP\DB::prepare( $sql );
$result = $stmt->execute(array($id));
} catch(Exception $e) {
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
diff --git a/apps/contacts/templates/part.contact.php b/apps/contacts/templates/part.contact.php
index 5757563fe5b..bb574372e52 100644
--- a/apps/contacts/templates/part.contact.php
+++ b/apps/contacts/templates/part.contact.php
@@ -18,7 +18,14 @@ $id = isset($_['id']) ? $_['id'] : '';
<iframe name="file_upload_target" id='file_upload_target' src=""></iframe>
<div class="tip propertycontainer" id="contacts_details_photo_wrapper" title="<?php echo $l->t('Drop photo to upload'); ?> (max <?php echo $_['uploadMaxHumanFilesize']; ?>)" data-element="PHOTO">
+ <ul id="phototools" class="transparent hidden">
+ <li><a class="svg delete" title="<?php echo $l->t('Delete current photo'); ?>"></a></li>
+ <li><a class="svg edit" title="<?php echo $l->t('Edit current photo'); ?>"></a></li>
+ <li><a class="svg upload" title="<?php echo $l->t('Upload new photo'); ?>"></a></li>
+ <li><a class="svg cloud" title="<?php echo $l->t('Select photo from ownCloud'); ?>"></a></li>
+ </ul>
</div>
+ <img />
</div> <!-- contact_photo -->
<div id="contact_identity" class="contactsection">
@@ -104,7 +111,6 @@ $id = isset($_['id']) ? $_['id'] : '';
<div id="contacts_propertymenu">
<button class="button" id="contacts_propertymenu_button"><?php echo $l->t('Add field'); ?></button>
<ul id="contacts_propertymenu_dropdown" role="menu" class="hidden">
- <li><a role="menuitem" data-type="PHOTO"><?php echo $l->t('Profile picture'); ?></a></li>
<li><a role="menuitem" data-type="ORG"><?php echo $l->t('Organization'); ?></a></li>
<li><a role="menuitem" data-type="NICKNAME"><?php echo $l->t('Nickname'); ?></a></li>
<li><a role="menuitem" data-type="BDAY"><?php echo $l->t('Birthday'); ?></a></li>
diff --git a/apps/contacts/templates/part.contactphoto.php b/apps/contacts/templates/part.contactphoto.php
deleted file mode 100644
index bddf4cc8a81..00000000000
--- a/apps/contacts/templates/part.contactphoto.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-$id = $_['id'];
-$wattr = isset($_['width'])?'width="'.$_['width'].'"':'';
-$hattr = isset($_['height'])?'height="'.$_['height'].'"':'';
-$rand = isset($_['refresh'])?'&refresh='.rand():'';
-?>
-<ul id="phototools" class="transparent hidden">
- <li><a class="svg delete" title="<?php echo $l->t('Delete current photo'); ?>"></a></li>
- <li><a class="svg edit" title="<?php echo $l->t('Edit current photo'); ?>"></a></li>
- <li><a class="svg upload" title="<?php echo $l->t('Upload new photo'); ?>"></a></li>
- <li><a class="svg cloud" title="<?php echo $l->t('Select photo from ownCloud'); ?>"></a></li>
-</ul>
-<img class="loading" id="contacts_details_photo" <?php echo $wattr; ?> <?php echo $hattr; ?> src="<?php echo OCP\Util::linkToAbsolute('contacts', 'photo.php'); ?>?id=<?php echo $id.$rand; ?>" />
-<progress id="contacts_details_photo_progress" style="display:none;" value="0" max="100">0 %</progress>
-
-
diff --git a/apps/contacts/templates/part.contacts.php b/apps/contacts/templates/part.contacts.php
deleted file mode 100644
index c33c5832e82..00000000000
--- a/apps/contacts/templates/part.contacts.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-foreach($_['books'] as $id => $addressbook) {
- echo '<h3 class="addressbook" data-id="'.$id.'">'.$addressbook['displayname'].'</h3>';
- echo '<ul class="contacts hidden" data-id="'.$id.'">';
- foreach($addressbook['contacts'] as $contact) {
- echo '<li role="button" data-bookid="'.$contact['addressbookid'].'" data-id="'.$contact['id'].'"><a href="'.link_to('contacts','index.php').'&id='.$contact['id'].'" style="background: url('.link_to('contacts','thumbnail.php').'?id='.$contact['id'].') no-repeat scroll 0 0 transparent;">'.$contact['displayname'].'</a></li>';
- }
- echo '</ul>';
-}
-?>
diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js
index 57188a6a266..49b7710638e 100644
--- a/apps/files_external/js/settings.js
+++ b/apps/files_external/js/settings.js
@@ -27,7 +27,7 @@ OC.MountConfig={
}
});
if (addMountPoint) {
- if ($('#externalStorage').data('admin')) {
+ if ($('#externalStorage').data('admin') === true) {
var isPersonal = false;
var multiselect = $(tr).find('.chzn-select').val();
var oldGroups = $(tr).find('.applicable').data('applicable-groups');
@@ -117,7 +117,7 @@ $(document).ready(function() {
if (mountPoint == '') {
return false;
}
- if ($('#externalStorage').data('admin')) {
+ if ($('#externalStorage').data('admin') === true) {
var isPersonal = false;
var multiselect = $(tr).find('.chzn-select').val();
$.each(multiselect, function(index, value) {
diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php
index b8e5b9b079b..9feb490dac0 100644
--- a/apps/files_external/lib/amazons3.php
+++ b/apps/files_external/lib/amazons3.php
@@ -96,8 +96,8 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
foreach ($response->body->CommonPrefixes as $object) {
$files[] = basename($object->Prefix);
}
- OC_FakeDirStream::$dirs['amazons3'] = $files;
- return opendir('fakedir://amazons3');
+ OC_FakeDirStream::$dirs['amazons3'.$path] = $files;
+ return opendir('fakedir://amazons3'.$path);
}
return false;
}
diff --git a/apps/files_external/personal.php b/apps/files_external/personal.php
index 32e08742442..b758e7e7eb0 100755
--- a/apps/files_external/personal.php
+++ b/apps/files_external/personal.php
@@ -26,7 +26,7 @@ $backends = OC_Mount_Config::getBackends();
// Remove local storage
unset($backends['OC_Filestorage_Local']);
$tmpl = new OCP\Template('files_external', 'settings');
-$tmpl->assign('isAdminPage', false);
+$tmpl->assign('isAdminPage', false, false);
$tmpl->assign('mounts', OC_Mount_Config::getPersonalMountPoints());
$tmpl->assign('backends', $backends);
return $tmpl->fetchPage();
diff --git a/apps/files_external/settings.php b/apps/files_external/settings.php
index 983855ecdcc..acc9036b299 100644
--- a/apps/files_external/settings.php
+++ b/apps/files_external/settings.php
@@ -23,7 +23,7 @@
OCP\Util::addScript('files_external', 'settings');
OCP\Util::addStyle('files_external', 'settings');
$tmpl = new OCP\Template('files_external', 'settings');
-$tmpl->assign('isAdminPage', true);
+$tmpl->assign('isAdminPage', true, false);
$tmpl->assign('mounts', OC_Mount_Config::getSystemMountPoints());
$tmpl->assign('backends', OC_Mount_Config::getBackends());
$tmpl->assign('groups', OC_Group::getGroups());
diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php
index 6c37df8001e..7777593d74d 100644
--- a/apps/files_external/templates/settings.php
+++ b/apps/files_external/templates/settings.php
@@ -1,7 +1,7 @@
<form id="files_external">
<fieldset class="personalblock">
<legend><strong><?php echo $l->t('External Storage'); ?></strong></legend>
- <table id="externalStorage" data-admin="<?php echo json_encode($_['isAdminPage']); ?>">
+ <table id="externalStorage" data-admin='<?php echo json_encode($_['isAdminPage']); ?>'>
<thead>
<tr>
<th><?php echo $l->t('Mount point'); ?></th>
diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php
index fe48434d2cb..f29d1760b6f 100644
--- a/apps/files_versions/ajax/getVersions.php
+++ b/apps/files_versions/ajax/getVersions.php
@@ -13,7 +13,7 @@ if( OCA_Versions\Storage::isversioned( $source ) ) {
$versionsFormatted = array();
foreach ( $versions AS $version ) {
- $versionsFormatted[] = OCP\Util::formatDate( doubleval($version) );
+ $versionsFormatted[] = OCP\Util::formatDate( $version['version'] );
}
$versionsSorted = array_reverse( $versions );
diff --git a/apps/files_versions/appinfo/app.php b/apps/files_versions/appinfo/app.php
index bd06dc0ced3..105c5a102cb 100644
--- a/apps/files_versions/appinfo/app.php
+++ b/apps/files_versions/appinfo/app.php
@@ -9,3 +9,6 @@ OCP\Util::addscript('files_versions', 'versions');
// Listen to write signals
OCP\Util::connectHook('OC_Filesystem', 'post_write', "OCA_Versions\Storage", "write_hook");
+// Listen to delete and rename signals
+OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA_Versions\Storage", "removeVersions");
+OCP\Util::connectHook('OC_Filesystem', 'rename', "OCA_Versions\Storage", "renameVersions"); \ No newline at end of file
diff --git a/apps/files_versions/versions.php b/apps/files_versions/versions.php
index 9c0829ff1de..7ed5f257505 100644
--- a/apps/files_versions/versions.php
+++ b/apps/files_versions/versions.php
@@ -309,5 +309,40 @@ class Storage {
}
-
+ /**
+ * @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 removeVersions($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
+ */
+ public static function renameVersions($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';
+ if(Storage::isversioned($rel_oldpath)) {
+ $versions = Storage::getVersions($rel_oldpath);
+ foreach ($versions as $v){
+ rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']);
+ }
+ }
+ }
}
diff --git a/apps/gallery/lib/managers.php b/apps/gallery/lib/managers.php
index fcce3f40e23..17eb741a660 100644
--- a/apps/gallery/lib/managers.php
+++ b/apps/gallery/lib/managers.php
@@ -4,6 +4,7 @@ namespace OC\Pictures;
class DatabaseManager {
private static $instance = null;
+ protected $cache = array();
const TAG = 'DatabaseManager';
public static function getInstance() {
@@ -12,13 +13,27 @@ class DatabaseManager {
return self::$instance;
}
+ protected function getPathData($path) {
+ $stmt = \OCP\DB::prepare('SELECT * FROM *PREFIX*pictures_images_cache
+ WHERE uid_owner LIKE ? AND path like ? AND path not like ?');
+ $path_match = $path.'/%';
+ $path_notmatch = $path.'/%/%';
+ $result = $stmt->execute(array(\OCP\USER::getUser(), $path_match, $path_notmatch));
+ $this->cache[$path] = array();
+ while (($row = $result->fetchRow()) != false) {
+ $this->cache[$path][$row['path']] = $row;
+ }
+ }
+
public function getFileData($path) {
$gallery_path = \OCP\Config::getSystemValue( 'datadirectory' ).'/'.\OC_User::getUser().'/gallery';
$path = $gallery_path.$path;
- $stmt = \OCP\DB::prepare('SELECT * FROM *PREFIX*pictures_images_cache WHERE uid_owner LIKE ? AND path = ?');
- $result = $stmt->execute(array(\OCP\USER::getUser(), $path));
- if (($row = $result->fetchRow()) != false) {
- return $row;
+ $dir = dirname($path);
+ if (!isset($this->cache[$dir])) {
+ $this->getPathData($dir);
+ }
+ if (isset($this->cache[$dir][$path])) {
+ return $this->cache[$dir][$path];
}
$image = new \OC_Image();
if (!$image->loadFromFile($path)) {
@@ -28,6 +43,7 @@ class DatabaseManager {
$stmt->execute(array(\OCP\USER::getUser(), $path, $image->width(), $image->height()));
$ret = array('path' => $path, 'width' => $image->width(), 'height' => $image->height());
unset($image);
+ $this->cache[$dir][$path] = $ret;
return $ret;
}
diff --git a/lib/app.php b/lib/app.php
index 61566ed7522..4c2c43ec26b 100755
--- a/lib/app.php
+++ b/lib/app.php
@@ -350,9 +350,13 @@ class OC_App{
protected static function findAppInDirectories($appid) {
+ static $app_dir = array();
+ if (isset($app_dir[$appid])) {
+ return $app_dir[$appid];
+ }
foreach(OC::$APPSROOTS as $dir) {
if(file_exists($dir['path'].'/'.$appid)) {
- return $dir;
+ return $app_dir[$appid]=$dir;
}
}
}
@@ -569,7 +573,7 @@ class OC_App{
}
/**
- * get the installed version of all papps
+ * get the installed version of all apps
*/
public static function getAppVersions(){
static $versions;
diff --git a/lib/helper.php b/lib/helper.php
index 6ab55f27618..64378da356e 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -38,13 +38,10 @@ class OC_Helper {
*/
public static function linkTo( $app, $file ){
if( $app != '' ){
- $app .= '/';
+ $app_path = OC_App::getAppPath($app);
// Check if the app is in the app folder
- if( file_exists( OC_App::getAppPath($app).'/'.$file )){
+ if( $app_path && file_exists( $app_path.'/'.$file )){
if(substr($file, -3) == 'php' || substr($file, -3) == 'css'){
- if(substr($app, -1, 1) == '/'){
- $app = substr($app, 0, strlen($app) - 1);
- }
$urlLinkTo = OC::$WEBROOT . '/?app=' . $app;
$urlLinkTo .= ($file!='index.php')?'&getfile=' . urlencode($file):'';
}else{
@@ -52,7 +49,7 @@ class OC_Helper {
}
}
else{
- $urlLinkTo = OC::$WEBROOT . '/' . $app . $file;
+ $urlLinkTo = OC::$WEBROOT . '/' . $app . '/' . $file;
}
}
else{
diff --git a/lib/migrate.php b/lib/migrate.php
index f26b4b25673..731b6a6839c 100644
--- a/lib/migrate.php
+++ b/lib/migrate.php
@@ -64,7 +64,7 @@ class OC_Migrate{
$apps = OC_App::getAllApps();
foreach($apps as $app){
- $path = self::getAppPath($app) . '/appinfo/migrate.php';
+ $path = OC_App::getAppPath($app) . '/appinfo/migrate.php';
if( file_exists( $path ) ){
include( $path );
}
@@ -398,7 +398,7 @@ class OC_Migrate{
if( OC_App::isEnabled( $provider->getID() ) ){
$success = true;
// Does this app use the database?
- if( file_exists( self::getAppPath($provider->getID()).'/appinfo/database.xml' ) ){
+ if( file_exists( OC_App::getAppPath($provider->getID()).'/appinfo/database.xml' ) ){
// Create some app tables
$tables = self::createAppTables( $provider->getID() );
if( is_array( $tables ) ){
@@ -539,7 +539,7 @@ class OC_Migrate{
}
// There is a database.xml file
- $content = file_get_contents(self::getAppPath($appid) . '/appinfo/database.xml' );
+ $content = file_get_contents(OC_App::getAppPath($appid) . '/appinfo/database.xml' );
$file2 = 'static://db_scheme';
// TODO get the relative path to migration.db from the data dir
diff --git a/lib/setup.php b/lib/setup.php
index 5f1fb1525ec..5387a0ef493 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -150,7 +150,7 @@ class OC_Setup {
$dbpass = $options['dbpass'];
$dbname = $options['dbname'];
$dbhost = $options['dbhost'];
- $dbtableprefix = $options['dbtableprefix'];
+ $dbtableprefix = isset($options['dbtableprefix']) ? $options['dbtableprefix'] : 'oc_';
OC_CONFIG::setValue('dbname', $dbname);
OC_CONFIG::setValue('dbhost', $dbhost);
OC_CONFIG::setValue('dbtableprefix', $dbtableprefix);
@@ -163,6 +163,7 @@ class OC_Setup {
'error' => 'PostgreSQL username and/or password not valid',
'hint' => 'You need to enter either an existing account or the administrator.'
);
+ return $error;
}
else {
//check for roles creation rights in postgresql
@@ -284,13 +285,23 @@ class OC_Setup {
//we cant use OC_BD functions here because we need to connect as the administrative user.
$e_name = pg_escape_string($name);
$e_user = pg_escape_string($user);
- $query = "CREATE DATABASE \"$e_name\" OWNER \"$e_user\"";
+ $query = "select datname from pg_database where datname = '$e_name'";
$result = pg_query($connection, $query);
if(!$result) {
$entry='DB Error: "'.pg_last_error($connection).'"<br />';
$entry.='Offending command was: '.$query.'<br />';
echo($entry);
}
+ if(! pg_fetch_row($result)) {
+ //The database does not exists... let's create it
+ $query = "CREATE DATABASE \"$e_name\" OWNER \"$e_user\"";
+ $result = pg_query($connection, $query);
+ if(!$result) {
+ $entry='DB Error: "'.pg_last_error($connection).'"<br />';
+ $entry.='Offending command was: '.$query.'<br />';
+ echo($entry);
+ }
+ }
$query = "REVOKE ALL PRIVILEGES ON DATABASE \"$e_name\" FROM PUBLIC";
$result = pg_query($connection, $query);
}
@@ -298,13 +309,33 @@ class OC_Setup {
private static function pg_createDBUser($name,$password,$connection) {
$e_name = pg_escape_string($name);
$e_password = pg_escape_string($password);
- $query = "CREATE USER \"$e_name\" CREATEDB PASSWORD '$e_password';";
+ $query = "select * from pg_roles where rolname='$e_name';";
$result = pg_query($connection, $query);
if(!$result) {
$entry='DB Error: "'.pg_last_error($connection).'"<br />';
$entry.='Offending command was: '.$query.'<br />';
echo($entry);
}
+
+ if(! pg_fetch_row($result)) {
+ //user does not exists let's create it :)
+ $query = "CREATE USER \"$e_name\" CREATEDB PASSWORD '$e_password';";
+ $result = pg_query($connection, $query);
+ if(!$result) {
+ $entry='DB Error: "'.pg_last_error($connection).'"<br />';
+ $entry.='Offending command was: '.$query.'<br />';
+ echo($entry);
+ }
+ }
+ else { // change password of the existing role
+ $query = "ALTER ROLE \"$e_name\" WITH PASSWORD '$e_password';";
+ $result = pg_query($connection, $query);
+ if(!$result) {
+ $entry='DB Error: "'.pg_last_error($connection).'"<br />';
+ $entry.='Offending command was: '.$query.'<br />';
+ echo($entry);
+ }
+ }
}
/**