Merge remote-tracking branch 'mike/master' into dev

This commit is contained in:
Mario Vavti 2018-04-26 09:05:47 +02:00
commit 09666ae8e9
8 changed files with 66 additions and 47 deletions

View File

@ -747,8 +747,8 @@ class Enotify {
// generate a mime boundary // generate a mime boundary
$mimeBoundary = rand(0, 9) . "-" $mimeBoundary = rand(0, 9) . "-"
.rand(10000000000, 9999999999) . "-" .rand(100000000, 999999999) . "-"
.rand(10000000000, 9999999999) . "=:" .rand(100000000, 999999999) . "=:"
.rand(10000, 99999); .rand(10000, 99999);
// generate a multipart/alternative message header // generate a multipart/alternative message header

View File

@ -268,15 +268,15 @@ class Acl extends \Zotlabs\Web\Controller {
}); });
} }
} }
if(intval(get_config('system','taganyone')) || intval(get_pconfig(local_channel(),'system','taganyone'))) { if((count($r) < 100) && $type == 'c') {
if((count($r) < 100) && $type == 'c') { $r2 = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags, 0 as abook_self
$r2 = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags, 0 as abook_self FROM xchan
FROM xchan WHERE xchan_deleted = 0 and not xchan_network in ('rss','anon','unknown') $sql_extra2 order by $order_extra2 xchan_name asc"
WHERE xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc" );
); if($r2) {
if($r2) $r = array_merge($r,$r2);
$r = array_merge($r,$r2); $r = unique_multidim_array($r,'hash');
} }
} }
} }
elseif($type == 'm') { elseif($type == 'm') {

View File

@ -218,15 +218,13 @@ class Network extends \Zotlabs\Web\Controller {
$contact_str = ''; $contact_str = '';
$contacts = group_get_members($group); $contacts = group_get_members($group);
if($contacts) { if($contacts) {
foreach($contacts as $c) { $contact_str = ids_to_querystr($contacts,'xchan',true);
if($contact_str)
$contact_str .= ',';
$contact_str .= "'" . $c['xchan'] . "'";
}
} }
else { else {
$contact_str = ' 0 '; $contact_str = " '0' ";
info( t('Privacy group is empty')); if(! $update) {
info( t('Privacy group is empty'));
}
} }
$item_thread_top = ''; $item_thread_top = '';
$sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str )) or allow_gid like '" . protect_sprintf('%<' . dbesc($group_hash) . '>%') . "' ) and id = parent $item_normal ) "; $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str )) or allow_gid like '" . protect_sprintf('%<' . dbesc($group_hash) . '>%') . "' ) and id = parent $item_normal ) ";
@ -480,7 +478,6 @@ class Network extends \Zotlabs\Web\Controller {
$ordering = "commented"; $ordering = "commented";
if($load) { if($load) {
// Fetch a page full of parent items for this page // Fetch a page full of parent items for this page
$r = q("SELECT item.parent AS item_id FROM item $r = q("SELECT item.parent AS item_id FROM item
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )

View File

@ -234,9 +234,11 @@ function oembed_fetch_url($embedurl){
if(preg_match('#\<iframe(.*?)src\=[\'\"](.*?)[\'\"]#',$j['html'],$matches)) { if(preg_match('#\<iframe(.*?)src\=[\'\"](.*?)[\'\"]#',$j['html'],$matches)) {
$x = z_fetch_url($matches[2]); $x = z_fetch_url($matches[2]);
$j['html'] = $x['body']; $orig = $j['html'] = $x['body'];
} }
logger('frame src: ' . $j['html'], LOGGER_DATA);
$j['html'] = purify_html($j['html'],$allow_position); $j['html'] = purify_html($j['html'],$allow_position);
if($j['html'] != $orig) { if($j['html'] != $orig) {
logger('oembed html was purified. original: ' . $orig . ' purified: ' . $j['html'], LOGGER_DEBUG, LOG_INFO); logger('oembed html was purified. original: ' . $orig . ' purified: ' . $j['html'], LOGGER_DEBUG, LOG_INFO);

View File

@ -3402,3 +3402,18 @@ function unpunify($s) {
} }
function unique_multidim_array($array, $key) {
$temp_array = array();
$i = 0;
$key_array = array();
foreach($array as $val) {
if (!in_array($val[$key], $key_array)) {
$key_array[$i] = $val[$key];
$temp_array[$i] = $val;
}
$i++;
}
return $temp_array;
}

View File

@ -8,20 +8,20 @@ function contact_search(term, callback, backend_url, type, extra_channels, spine
$(spinelement).show(); $(spinelement).show();
} }
// Check if there is a cached result that contains the same information we would get with a full server-side search // Check if there is a cached result that contains the same information we would get with a full server-side search
var bt = backend_url+type; // var bt = backend_url+type;
if(!(bt in contact_search.cache)) contact_search.cache[bt] = {}; // if(!(bt in contact_search.cache)) contact_search.cache[bt] = {};
var lterm = term.toLowerCase(); // Ignore case // var lterm = term.toLowerCase(); // Ignore case
for(var t in contact_search.cache[bt]) { // for(var t in contact_search.cache[bt]) {
if(lterm.indexOf(t) >= 0) { // A more broad search has been performed already, so use those results // if(lterm.indexOf(t) >= 0) { // A more broad search has been performed already, so use those results
$(spinelement).hide(); // $(spinelement).hide();
// Filter old results locally // Filter old results locally
var matching = contact_search.cache[bt][t].filter(function (x) { return (x.name.toLowerCase().indexOf(lterm) >= 0 || (typeof x.nick !== 'undefined' && x.nick.toLowerCase().indexOf(lterm) >= 0)); }); // Need to check that nick exists because groups don't have one // var matching = contact_search.cache[bt][t].filter(function (x) { return (x.name.toLowerCase().indexOf(lterm) >= 0 || (typeof x.nick !== 'undefined' && x.nick.toLowerCase().indexOf(lterm) >= 0)); }); // Need to check that nick exists because groups don't have one
matching.unshift({taggable:false, text: term, replace: term}); // matching.unshift({taggable:false, text: term, replace: term});
setTimeout(function() { callback(matching); } , 1); // Use "pseudo-thread" to avoid some problems // setTimeout(function() { callback(matching); } , 1); // Use "pseudo-thread" to avoid some problems
return; // return;
} // }
} // }
var postdata = { var postdata = {
start:0, start:0,
@ -41,9 +41,9 @@ function contact_search(term, callback, backend_url, type, extra_channels, spine
success: function(data){ success: function(data){
// Cache results if we got them all (more information would not improve results) // Cache results if we got them all (more information would not improve results)
// data.count represents the maximum number of items // data.count represents the maximum number of items
if(data.items.length -1 < data.count) { // if(data.items.length -1 < data.count) {
contact_search.cache[bt][lterm] = data.items; // contact_search.cache[bt][lterm] = data.items;
} // }
var items = data.items.slice(0); var items = data.items.slice(0);
items.unshift({taggable:false, text: term, replace: term}); items.unshift({taggable:false, text: term, replace: term});
callback(items); callback(items);

View File

@ -568,11 +568,14 @@ $( document ).on( "click", ".wall-item-delete-link,.page-delete-link,.layout-del
function postSaveChanges(action, type) { function postSaveChanges(action, type) {
if({{$auto_save_draft}}) { if({{$auto_save_draft}}) {
var doctype = $('#jot-webpage').val();
var postid = '-' + doctype + '-' + $('#jot-postid').val();
if(action != 'clean') { if(action != 'clean') {
localStorage.setItem("post_title", $("#jot-title").val()); localStorage.setItem("post_title" + postid, $("#jot-title").val());
localStorage.setItem("post_body", $("#profile-jot-text").val()); localStorage.setItem("post_body" + postid, $("#profile-jot-text").val());
if($("#jot-category").length) if($("#jot-category").length)
localStorage.setItem("post_category", $("#jot-category").val()); localStorage.setItem("post_category + postid", $("#jot-category").val());
} }
if(action == 'start') { if(action == 'start') {
@ -589,9 +592,9 @@ $( document ).on( "click", ".wall-item-delete-link,.page-delete-link,.layout-del
if(action == 'clean') { if(action == 'clean') {
clearTimeout(postSaveTimer); clearTimeout(postSaveTimer);
postSaveTimer = null; postSaveTimer = null;
localStorage.removeItem("post_title"); localStorage.removeItem("post_title" + postid);
localStorage.removeItem("post_body"); localStorage.removeItem("post_body" + postid);
localStorage.removeItem("post_category"); localStorage.removeItem("post_category" + postid);
} }
} }
@ -602,9 +605,11 @@ $( document ).on( "click", ".wall-item-delete-link,.page-delete-link,.layout-del
var cleaned = false; var cleaned = false;
if({{$auto_save_draft}}) { if({{$auto_save_draft}}) {
var postTitle = localStorage.getItem("post_title"); var doctype = $('#jot-webpage').val();
var postBody = localStorage.getItem("post_body"); var postid = '-' + doctype + '-' + $('#jot-postid').val();
var postCategory = (($("#jot-category").length) ? localStorage.getItem("post_category") : ''); var postTitle = localStorage.getItem("post_title" + postid);
var postBody = localStorage.getItem("post_body" + postid);
var postCategory = (($("#jot-category").length) ? localStorage.getItem("post_category" + postid) : '');
var openEditor = false; var openEditor = false;
if(postTitle) { if(postTitle) {

View File

@ -21,8 +21,8 @@
<input type="hidden" name="media_str" id="jot-media" value="" /> <input type="hidden" name="media_str" id="jot-media" value="" />
<input type="hidden" name="source" id="jot-source" value="{{$source}}" /> <input type="hidden" name="source" id="jot-source" value="{{$source}}" />
<input type="hidden" name="coord" id="jot-coord" value="" /> <input type="hidden" name="coord" id="jot-coord" value="" />
<input type="hidden" name="post_id" value="{{$post_id}}" /> <input type="hidden" id="jot-postid" name="post_id" value="{{$post_id}}" />
<input type="hidden" name="webpage" value="{{$webpage}}" /> <input type="hidden" id="jot-webpage" name="webpage" value="{{$webpage}}" />
<input type="hidden" name="preview" id="jot-preview" value="0" /> <input type="hidden" name="preview" id="jot-preview" value="0" />
<input type="hidden" id="jot-consensus" name="consensus" value="{{if $consensus}}{{$consensus}}{{else}}0{{/if}}" /> <input type="hidden" id="jot-consensus" name="consensus" value="{{if $consensus}}{{$consensus}}{{else}}0{{/if}}" />
<input type="hidden" id="jot-nocomment" name="nocomment" value="{{if $nocomment}}{{$nocomment}}{{else}}0{{/if}}" /> <input type="hidden" id="jot-nocomment" name="nocomment" value="{{if $nocomment}}{{$nocomment}}{{else}}0{{/if}}" />