Commit f3b2fd67 authored by Mario's avatar Mario

Merge branch 'dev' of https://framagit.org/hubzilla/addons into dev

parents ccb75350 d7ab2fe3
......@@ -1803,7 +1803,7 @@ class Diaspora_Receiver {
}
$image_url = unxmlify($this->xmlbase['image_url']);
$birthday = unxmlify($this->xmlbase['birthday']);
$edited = datetime_convert('UTC','UTC',$this->xmlbase['edited_at']);
$handle_parts = explode("@", $diaspora_handle);
if($name === '') {
......@@ -1815,8 +1815,25 @@ class Diaspora_Receiver {
}
require_once('include/photo/photo_driver.php');
$images = import_xchan_photo($image_url,$contact['xchan_hash']);
if($edited > $contact['xchan_photo_date']) {
$images = import_xchan_photo($image_url,$contact['xchan_hash']);
$newimg = true;
} else {
$images = array($contact['xchan_photo_l'],$contact['xchan_photo_m'],$contact['xchan_photo_s'],$contact['xchan_photo_mimetype']);
$newimg = false;
}
$r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s'",
dbesc($name),
dbesc(($name != $contact['xchan_name'] ? $edited : $contact['xchan_name_date'])),
dbesc(($newimg ? $edited : $contact['xchan_photo_date'])),
dbesc($images[0]),
dbesc($images[1]),
dbesc($images[2]),
dbesc($images[3]),
dbesc($contact['xchan_hash'])
);
// Somebody is sending us birthday arrays.
......@@ -1846,17 +1863,6 @@ class Diaspora_Receiver {
// if(substr($birthday,5) === substr($contact['bd'],5))
// $birthday = $contact['bd'];
$r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s' ",
dbesc($name),
dbesc(datetime_convert()),
dbesc($images[0]),
dbesc($images[1]),
dbesc($images[2]),
dbesc($images[3]),
dbesc(datetime_convert()),
intval($contact['xchan_hash'])
);
return;
}
......@@ -2303,15 +2309,15 @@ class Diaspora_Receiver {
if(substr($birthday,5) === substr($new_contact['bd'],5))
$birthday = $new_contact['bd'];
$r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s' ",
$r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s'",
dbesc($name),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc($images[0]),
dbesc($images[1]),
dbesc($images[2]),
dbesc($images[3]),
dbesc(datetime_convert()),
intval($new_contact['xchan_hash'])
dbesc($new_contact['xchan_hash'])
);
$r = q("update abook set abook_xchan = '%s' where abook_xchan = '%s' and abook_channel = %d",
......
This diff is collapsed.
......@@ -6,12 +6,14 @@ Your learning progress will be kept private.
<img src="/addon/flashcards/view/img/leitner-system.png" align="center" width="70%">
## Two Scenarios to use the Addon...
### Two Scenarios to use the Addon...
In both cases serveral learners can share a box of flashcards, for example "English-Italian".
- a centralised school like version where the "school" owns the flashcards
- a decentralised version where every learner owns his own copy
- Every user can edit cards of "English-Italian". The changes are synchronized between learners so every learners sees the same version of "English-Italian".
- If a user has cloned his account to different hubs the flashcards are synchronized automatically from hub to hub (clone to clone).
In both cases serveral learners can share a box of flashcards, lets say to learn "English-Italian".
Every learner can edit and add cards for "English-Italian". The changes are shared between the learners.
### Scenario 1: Students use Flashcards of a School
......@@ -53,7 +55,7 @@ Anna creates a new box of flashcards "English-Italian". The URL could be somethi
Bob wants to learn "English-Italian" from Anna. Bob opens his own addon at https://bob.org/flashcards/bob and imports "English-Italian" from Anna using the URL https://anna.org/flashcards/anna/xy12tlsel89q81o .
Both will see the same content if one of them changes or adds cards. The syncronization is done automatically - this time from hub to hub.
Both are able to changes or adds cards. The syncronization is done automatically - this time from hub to hub.
#### Permissions and Technically
......@@ -63,4 +65,4 @@ If Bob imports "English-Italian" his hub will receive a copy from Annas hub. Bob
Anna CAN NOT withdraw the permissions for Bob (on Bobs hub) or delete the flashcards of Bob.
Both Anna and Bob can switch off the synchronization from hub to hub.
Both Anna and Bob can switch off the synchronization from hub to hub. Bob may decide to not merge changes from each other.
......@@ -889,14 +889,10 @@ var sortByColumn = 0;
var sortReversOrder = false;
var timezoneOffsetMilliseconds = 0;
var isDownloadButton = true;
function setShareButton() {
isDownloadButton = true;
$("#button_share_box").css({ 'color': '' });
if(box.hasChanges()) {
$("#button_share_box").css({ 'color': 'red' });
isDownloadButton = false;
}
var counter = 0;
if(box.content.cards) {
......@@ -914,13 +910,7 @@ function setShareButton() {
logger.log('Share button: ' + counter + ' card with changes');
$("#button_share_box_counter").html('<sup>' + counter + '</sup>');
$("#button_share_box").css({ 'color': 'red' });
isDownloadButton = false;
}
if(isDownloadButton) {
$('#button_share_box').find('.fa').removeClass("fa-cloud-upload").addClass("fa-cloud-download");
} else {
$('#button_share_box').find('.fa').removeClass("fa-cloud-download").addClass("fa-cloud-upload");
}
$("#button_share_box").show();
}
......@@ -1553,8 +1543,10 @@ $(document).on("click", "#button_delete_box", function() {
var boxid_delete = $($(this)).attr("boxid");
// $('a[href$="' + link_box_delete + '"]').hide();
$('#delete_box_modal').modal('hide');
animate_on();
logger.log('Sending request to delete box id: ' + boxid_delete + '...');
$.post(postUrl + "/delete", {boxID: boxid_delete} , function(data) {
animate_off();
if (data['status']) {
logger.log("Successfully deleted box " + boxid_delete + " on server. Status: " + data['status']);
loadCloudBoxes()
......@@ -1567,14 +1559,17 @@ $(document).on("click", "#button_delete_box", function() {
'json');
});
function animate_on() {
$('#button_share_box').find('.fa').addClass("fa-spin").addClass("fa-fw");
}
function animate_off() {
$('#button_share_box').find('.fa').removeClass("fa-spin").removeClass("fa-fw");
}
$(document).on("click", "#button_share_box", function() {
logger.log('clicked button share box');
if(isDownloadButton) {
uploadBox();
// downLoadBoxForURL();
} else {
uploadBox();
}
uploadBox();
});
function uploadBox() {
......@@ -1586,13 +1581,13 @@ function uploadBox() {
return;
}
// var contact_allow = acl.allow_cid;
var boxUpload = box.getContentToUpload();
logger.log('Sending request to upload a box: ' + boxUpload.content.title + '...');
// $.post("flashcards/a/upload", {box: boxUpload.content, contact_allow: contact_allow} , function(data) {
animate_on();
$.post(postUrl + "/upload", {box: boxUpload.content} , function(data) {
animate_off();
if (data['status']) {
logger.log("Successfully uploaded box " + box.content.title + " on server. Status: " + data['status']);
var box_id = data['resource_id'];
......@@ -1663,8 +1658,10 @@ function downLoadBoxForURL() {
logger.log("Do not download a box for the URL. Why? The URL path (" + path + ") was splitted by slashes. The fourth part does not exist. It should be the box ID.");
return false;
}
animate_on();
logger.log('Sending request to download a box: ' + box_id + '...');
$.post(postUrl + "/download/", {boxID: box_id} , function(data) {
animate_off();
if (data['status']) {
logger.log("Successfully downloaded box " + box_id + " on server. Status: " + data['status']);
// Merge the remote changes.
......@@ -1673,11 +1670,6 @@ function downLoadBoxForURL() {
remoteBox.setContent(data['box']);
remoteBox.removeAllUploadMarkers();
importBox(remoteBox);
// logger.log(data['boxACL']);
// $("#flashcards-acl-modal").html(data['boxACL']).show();
// redirectToAppRoot();
} else {
logger.log("Error downloading box: " + data['errormsg']);
loadCloudBoxes(); // TODO: Show list of boxes of "New box"
......@@ -1706,8 +1698,8 @@ function importBox(importBox) {
} else {
logger.log('ID of remote box is different from local one. Do not merge the boxes. Instead: Import the remote box and display it...');
box = importBox;
loadStartPage();
}
loadStartPage();
box.store();
}
......@@ -1827,8 +1819,10 @@ $(document).on("click", "#flashcards_show_boxes", function() {
});
function loadCloudBoxes() {
animate_on();
logger.log('Sending request to download a list of cloud boxes...');
$.post(postUrl + '/list/', '' , function(data) {
animate_off();
if (data['status']) {
logger.log("Donwnload of boxes successfull. Status: " + data['status']);
$("#panel_flashcards_cards").hide();
......@@ -1882,7 +1876,11 @@ function createBoxList(boxes) {
html += ' ' + description + '';
html += ' <br><b>Size: </b>' + cloudBox["size"] + '';
if(cloudBox["boxID"] !== box.content.boxID) {
html += ' &nbsp;<b>Delete box: </b>&nbsp;';
if(is_owner) {
html += ' &nbsp;<b>Delete box: </b>&nbsp;';
} else {
html += ' &nbsp;<b>Delete learn results: </b>&nbsp;';
}
html += ' <i class="fa fa-trash" id="link_delete_box" boxid="' + cloudBox["boxID"] + '" title_box_delete="' + cloudBox["title"] + '"></i>';
}
html += '</div>';
......
......@@ -5,7 +5,7 @@
<div class="dropdown-menu">
<a class="dropdown-item" id="flashcards_new_box">New Box</a>
<a class="dropdown-item" id="flashcards_edit_box">Edit Box</a>
<a class="dropdown-item" id="flashcards_show_boxes">Cloud Boxes</a>
<a class="dropdown-item" id="flashcards_show_boxes">List Boxes</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item disabled" href="#">Search</a>
</div>
......@@ -17,7 +17,7 @@
<button class="btn flashcards_nav" id="button_flashcards_learn_play"><i class="fa fa-play fa-lg"></i> <sup><span id="span_flashcards_cards_due"></span></sup></button>
</div>
<button class="btn btn-default nav-pill ml-auto" id="button_share_box">
<i class="fa fa-cloud-upload fa-lg"></i>
<i class="fa fa-refresh fa-lg"></i>
<span id="button_share_box_counter"></span>
</button>
<button class="btn btn-default nav-pill ml-auto" id="button_flashcards_list_close" style="display: none;">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment