diff options
author | friendica <info@friendica.com> | 2015-01-07 14:39:09 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2015-01-07 14:39:09 -0800 |
commit | 0657195125675700eeb9bcd1bc92f4299cac0304 (patch) | |
tree | 2e6d2df8fd42b289b947a16f0c5f0009a2c98043 | |
parent | a1e5a661fa8f87793cab0fe9c34f507dafb65d99 (diff) | |
parent | 087d6744fcd0c77cf3415b4ce6eaf50cdb63b4ef (diff) | |
download | volse-hubzilla-0657195125675700eeb9bcd1bc92f4299cac0304.tar.gz volse-hubzilla-0657195125675700eeb9bcd1bc92f4299cac0304.tar.bz2 volse-hubzilla-0657195125675700eeb9bcd1bc92f4299cac0304.zip |
Merge branch 'master' into trinidad
-rwxr-xr-x | boot.php | 4 | ||||
-rw-r--r-- | include/Contact.php | 2 | ||||
-rw-r--r-- | include/nav.php | 10 | ||||
-rw-r--r-- | library/jquery-textcomplete/jquery.textcomplete.js | 7 | ||||
-rw-r--r-- | mod/acl.php | 48 | ||||
-rw-r--r-- | mod/admin.php | 4 | ||||
-rw-r--r-- | mod/connections.php | 3 | ||||
-rw-r--r-- | mod/connedit.php | 9 | ||||
-rw-r--r-- | version.inc | 2 | ||||
-rw-r--r-- | view/js/autocomplete.js | 90 | ||||
-rw-r--r-- | view/js/main.js | 4 | ||||
-rw-r--r-- | view/js/mod_connections.js | 10 | ||||
-rw-r--r-- | view/js/mod_mail.js | 11 | ||||
-rw-r--r-- | view/js/mod_message.js | 13 | ||||
-rw-r--r-- | view/js/mod_network.js | 7 | ||||
-rw-r--r-- | view/js/mod_photos.js | 18 | ||||
-rw-r--r-- | view/js/mod_poke.js | 13 | ||||
-rw-r--r-- | view/js/mod_sources.js | 18 | ||||
-rwxr-xr-x | view/tpl/display-head.tpl | 4 | ||||
-rwxr-xr-x | view/tpl/jot-header.tpl | 4 | ||||
-rwxr-xr-x | view/tpl/msg-header.tpl | 2 |
21 files changed, 129 insertions, 154 deletions
@@ -221,7 +221,7 @@ define ( 'PAGE_NORMAL', 0x0000 ); define ( 'PAGE_HIDDEN', 0x0001 ); define ( 'PAGE_AUTOCONNECT', 0x0002 ); define ( 'PAGE_APPLICATION', 0x0004 ); -define ( 'PAGE_DIRECTORY_CHANNEL', 0x0008 ); // system channel used for directory synchronisation + define ( 'PAGE_PREMIUM', 0x0010 ); define ( 'PAGE_ADULT', 0x0020 ); define ( 'PAGE_CENSORED', 0x0040 ); // Site admin has blocked this channel from appearing in casual search results and site feeds @@ -554,7 +554,7 @@ define ( 'ITEM_DELAYED_PUBLISH', 0x0080); define ( 'ITEM_BUILDBLOCK', 0x0100); // Named thusly to make sure nobody confuses this with ITEM_BLOCKED define ( 'ITEM_PDL', 0x0200); // Page Description Language - e.g. Comanche define ( 'ITEM_BUG', 0x0400); // Is a bug, can be used by the internal bug tracker -define ( 'ITEM_PENDING_REMOVE', 0x0800); // deleted, notification period has lapsed +define ( 'ITEM_PENDING_REMOVE', 0x0800); // deleted, notification period has lapsed /** * Item Flags diff --git a/include/Contact.php b/include/Contact.php index 233798181..4f7a2a19f 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -519,6 +519,8 @@ function contact_remove($channel_id, $abook_id) { if((! $channel_id) || (! $abook_id)) return false; + logger('removing contact ' . $abook_id . ' for channel ' . $channel_id,LOGGER_DEBUG); + $archive = get_pconfig($channel_id, 'system','archive_removed_contacts'); if($archive) { q("update abook set abook_flags = ( abook_flags | %d ) where abook_id = %d and abook_channel = %d", diff --git a/include/nav.php b/include/nav.php index a9bff4b29..a567f83c5 100644 --- a/include/nav.php +++ b/include/nav.php @@ -15,15 +15,7 @@ function nav(&$a) { $a->page['htmlhead'] .= <<< EOT <script>$(document).ready(function() { - var a; - a = $("#nav-search-text").autocomplete({ - serviceUrl: '$base/acl', - minChars: 2, - width: 250, - id: 'nav-search-text-ac', - }); - a.setOptions({ autoSubmit: true, params: { type: 'x' }}); - + $("#nav-search-text").search_autocomplete('$base/acl'); }); </script> diff --git a/library/jquery-textcomplete/jquery.textcomplete.js b/library/jquery-textcomplete/jquery.textcomplete.js index 1e61683ea..c8303eaa0 100644 --- a/library/jquery-textcomplete/jquery.textcomplete.js +++ b/library/jquery-textcomplete/jquery.textcomplete.js @@ -124,8 +124,9 @@ if (typeof jQuery === 'undefined') { this.views = []; this.option = $.extend({}, Completer._getDefaults(), option); - if (!this.$el.is('textarea') && !element.isContentEditable && element.contentEditable != 'true') { - throw new Error('textcomplete must be called on a Textarea or a ContentEditable.'); + + if (!this.$el.is('input[type=text]') && !this.$el.is('textarea') && !element.isContentEditable && element.contentEditable != 'true') { + throw new Error('textcomplete must be called on a input[type=text], Textarea or a ContentEditable.'); } if (element === document.activeElement) { @@ -171,7 +172,7 @@ if (typeof jQuery === 'undefined') { if (this.option.adapter) { Adapter = this.option.adapter; } else { - if (this.$el.is('textarea')) { + if (this.$el.is('textarea') || this.$el.is('input[type=text]')) { viewName = typeof element.selectionEnd === 'number' ? 'Textarea' : 'IETextarea'; } else { viewName = 'ContentEditable'; diff --git a/mod/acl.php b/mod/acl.php index e6733351b..f575db55b 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -182,49 +182,29 @@ function acl_init(&$a){ ); } elseif($type == 'x') { - $r = navbar_complete($a); - $x = array(); - $x['query'] = $search; - $x['photos'] = array(); - $x['links'] = array(); - $x['suggestions'] = array(); - $x['data'] = array(); + $contacts = array(); if($r) { foreach($r as $g) { - $x['photos'][] = $g['photo']; - $x['links'][] = $g['url']; - $x['suggestions'][] = '@' . $g['name']; - $x['data'][] = $g['name']; + $contacts[] = array( + "photo" => $g['photo'], + "name" => $g['name'], + "nick" => $g['address'], + ); } } - echo json_encode($x); - killme(); + $o = array( + 'start' => $start, + 'count' => $count, + 'items' => $contacts, + ); + echo json_encode($o); + killme(); } else $r = array(); - - if($type == 'm' || $type == 'a' || $type == 'p') { - $x = array(); - $x['query'] = $search; - $x['photos'] = array(); - $x['links'] = array(); - $x['suggestions'] = array(); - $x['data'] = array(); - if(count($r)) { - foreach($r as $g) { - $x['photos'][] = $g['micro']; - $x['links'][] = $g['url']; - $x['suggestions'][] = $g['name']; - $x['data'][] = (($type === 'p') ? '@' . str_replace(' ','_',$g['name']) : $g['id']); - } - } - echo json_encode($x); - killme(); - } - if(count($r)) { foreach($r as $g){ @@ -284,7 +264,7 @@ function navbar_complete(&$a) { } $dirmode = intval(get_config('system','directory_mode')); - $search = ((x($_REQUEST,'query')) ? htmlentities($_REQUEST['query'],ENT_COMPAT,'UTF-8',false) : ''); + $search = ((x($_REQUEST,'search')) ? htmlentities($_REQUEST['search'],ENT_COMPAT,'UTF-8',false) : ''); if(! $search || mb_strlen($search) < 2) return array(); diff --git a/mod/admin.php b/mod/admin.php index 0e580960a..74a373738 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -827,7 +827,7 @@ function admin_page_channels(&$a){ /* get channels */ $total = q("SELECT count(*) as total FROM channel where not (channel_pageflags & %d)>0", - intval(PAGE_REMOVED) + intval(PAGE_REMOVED|PAGE_SYSTEM) ); if($total) { $a->set_pager_total($total[0]['total']); @@ -837,7 +837,7 @@ function admin_page_channels(&$a){ $order = " order by channel_name asc "; $channels = q("SELECT * from channel where not ( channel_pageflags & %d )>0 $order limit %d offset %d ", - intval(PAGE_REMOVED), + intval(PAGE_REMOVED|PAGE_SYSTEM), intval($a->pager['itemspage']), intval($a->pager['start']) ); diff --git a/mod/connections.php b/mod/connections.php index 70e28913a..d36734ccb 100644 --- a/mod/connections.php +++ b/mod/connections.php @@ -179,7 +179,8 @@ function connections_content(&$a) { $unconnected = false; $all = false; - $_SESSION['return_url'] = $a->query_string; + if(! $_REQUEST['aj']) + $_SESSION['return_url'] = $a->query_string; $search_flags = 0; $head = ''; diff --git a/mod/connedit.php b/mod/connedit.php index 6729029ac..abab0416e 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -216,10 +216,9 @@ function connedit_post(&$a) { $arr = array('channel_id' => local_user(), 'abook' => $a->poi); call_hooks('accept_follow', $arr); } -dbg(1); + if(! is_null($autoperms)) set_pconfig(local_user(),'system','autoperms',(($autoperms) ? $abook_my_perms : 0)); -dbg(0); connedit_clone($a); @@ -242,7 +241,7 @@ function connedit_clone(&$a) { unset($clone['abook_account']); unset($clone['abook_channel']); - build_sync_packet(0 /* use the current local_user */, array('abook' => array($clone))); + build_sync_packet(0 /* use the current local_user */, array(array('abook' => array($clone)))); } /* @brief Generate content of connection edit page @@ -403,9 +402,9 @@ function connedit_content(&$a) { contact_remove(local_user(), $orig_record[0]['abook_id']); build_sync_packet(0 /* use the current local_user */, - array('abook' => array( + array(array('abook' => array( 'abook_xchan' => $orig_record[0]['abook_xchan'], - 'entry_deleted' => true) + 'entry_deleted' => true)) ) ); diff --git a/version.inc b/version.inc index 9c65a441a..dcc95694a 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2015-01-06.911 +2015-01-07.912 diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index e92ce1d56..8572cf708 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -3,13 +3,13 @@ * * require jQuery, jquery.textcomplete */ - -function mysearch(term, callback, backend_url, extra_channels) { - // Check if there is a cached result that contains the tsame information we would get with a full server-side search - for(t in mysearch.cache) { +function contact_search(term, callback, backend_url, type, extra_channels) { + // Check if there is a cached result that contains the same information we would get with a full server-side search + // Assume type hasn't changed + for(t in contact_search.cache) { if(term.indexOf(t) >= 0) { // A more broad search has been performed already, so use those results // Filter old results locally - var matching = mysearch.cache[t].filter(function (x) { return (x.name.indexOf(term) >= 0 || x.nick.indexOf(term) >= 0); }); + var matching = contact_search.cache[t].filter(function (x) { return (x.name.indexOf(term) >= 0 || x.nick.indexOf(term) >= 0); }); callback(matching); return; } @@ -19,10 +19,10 @@ function mysearch(term, callback, backend_url, extra_channels) { start:0, count:100, search:term, - type:'c', + type:type, } - if(extra_channels) + if(typeof extra_channels !== 'undefined' && extra_channels) postdata['extra_channels[]'] = extra_channels; $.ajax({ @@ -34,19 +34,19 @@ function mysearch(term, callback, backend_url, extra_channels) { // Cache results if we got them all (more information would not improve results) // data.count represents the maximum number of items if(data.items.length < data.count) { - mysearch.cache[term] = data.items; + contact_search.cache[term] = data.items; } callback(data.items); }, }).fail(function () {callback([]); }); // Callback must be invoked even if something went wrong. } -mysearch.cache = {}; +contact_search.cache = {}; -function format(item) { +function contact_format(item) { return "<div class='{0}' title='{4}'><img src='{1}'>{2} ({3})</div>".format(item.taggable, item.photo, item.name, ((item.label) ? item.nick + ' ' + item.label : item.nick), item.link ) } -function replace(item) { +function editor_replace(item) { // $2 ensures that prefix (@,@!) is preserved var id = item.id; // 16 chars of hash should be enough. Full hash could be used if it can be done in a visually appealing way. @@ -56,20 +56,28 @@ function replace(item) { return '$1$2'+item.nick.replace(' ','') + '+' + id; } +function basic_replace(item) { + return '$1'+item.name+' '; +} + +function submit_form(e) { + $(e).parents('form').submit(); +} + /** - * jQuery plugin 'contact_autocomplete' + * jQuery plugin 'editor_autocomplete' */ (function( $ ){ - $.fn.contact_autocomplete = function(backend_url, extra_channels) { + $.fn.editor_autocomplete = function(backend_url, extra_channels) { if (typeof extra_channels === 'undefined') extra_channels = false; // Autocomplete contacts contacts = { match: /(^|\s)(@\!*)([^ \n]+)$/, index: 3, - search: function(term, callback) { mysearch(term, callback, backend_url, extra_channels); }, - replace: replace, - template: format, + search: function(term, callback) { contact_search(term, callback, backend_url, 'c', extra_channels); }, + replace: editor_replace, + template: contact_format, } smilies = { @@ -79,6 +87,56 @@ function replace(item) { template: function(item) { return item['icon'] + item['text'] }, replace: function(item) { return "$1"+item['text'] + ' '; }, } + this.attr('autocomplete','off'); this.textcomplete([contacts,smilies],{className:'acpopup'}); }; })( jQuery ); + +/** + * jQuery plugin 'search_autocomplete' + */ +(function( $ ){ + $.fn.search_autocomplete = function(backend_url) { + + // Autocomplete contacts + contacts = { + match: /(^@)([^\n]{2,})$/, + index: 2, + search: function(term, callback) { contact_search(term, callback, backend_url, 'x',[]); }, + replace: basic_replace, + template: contact_format, + } + this.attr('autocomplete','off'); + var a = this.textcomplete([contacts],{className:'acpopup',maxCount:100}); + + a.on('textComplete:select', function(e,value,strategy) { submit_form(this); }); + + }; +})( jQuery ); + +(function( $ ){ + $.fn.contact_autocomplete = function(backend_url, typ, autosubmit, onselect) { + + if(typeof typ === 'undefined') typ = ''; + if(typeof autosubmit === 'undefined') autosubmit = false; + + // Autocomplete contacts + contacts = { + match: /(^)([^\n]+)$/, + index: 2, + search: function(term, callback) { contact_search(term, callback, backend_url, typ,[]); }, + replace: basic_replace, + template: contact_format, + } + + this.attr('autocomplete','off'); + var a = this.textcomplete([contacts],{className:'acpopup'}); + + if(autosubmit) + a.on('textComplete:select', function(e,value,strategy) { submit_form(this); }); + + if(typeof onselect !== 'undefined') + a.on('textComplete:select',function(e,value,strategy) { onselect(value); }); + }; +})( jQuery ); + diff --git a/view/js/main.js b/view/js/main.js index 974f5f971..9d5136c34 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -577,7 +577,7 @@ function updateConvItems(mode,data) { } /* autocomplete @nicknames */ - $(".comment-edit-form textarea").contact_autocomplete(baseurl+"/acl?f=&n=1"); + $(".comment-edit-form textarea").editor_autocomplete(baseurl+"/acl?f=&n=1"); var bimgs = $(".wall-item-body img").not(function() { return this.complete; }); var bimgcount = bimgs.length; @@ -604,7 +604,7 @@ function updateConvItems(mode,data) { $(this).readmore({ collapsedHeight: divmore_height, moreLink: '<a href="#" class="divgrow-showmore">'+aStr['divgrowmore']+'</a>', - lessLink: '<a href="#">'+aStr['divgrowless']+'</a>' + lessLink: '<a href="#" class="divgrow-showmore">'+aStr['divgrowless']+'</a>' }); $(this).addClass('divmore'); } diff --git a/view/js/mod_connections.js b/view/js/mod_connections.js index 8a8f2fee6..f29d96729 100644 --- a/view/js/mod_connections.js +++ b/view/js/mod_connections.js @@ -1,13 +1,5 @@ $(document).ready(function() { - var a; - a = $("#contacts-search").autocomplete({ - serviceUrl: baseurl + '/acl', - minChars: 2, - width: 250, - id: 'contact-search-ac', - }); - a.setOptions({ autoSubmit: true, params: { type: 'a' }}); - + $("#contacts-search").contact_autocomplete(baseurl + '/acl', 'a', true); }); $("#contacts-search").keyup(function(event){ diff --git a/view/js/mod_mail.js b/view/js/mod_mail.js index 82f60f46f..16e06e6f5 100644 --- a/view/js/mod_mail.js +++ b/view/js/mod_mail.js @@ -1,13 +1,6 @@ $(document).ready(function() { - var a; - a = $("#recip").autocomplete({ - serviceUrl: baseurl + '/acl', - minChars: 2, - width: 250, - id: 'recip-ac', - onSelect: function(value,data) { - $("#recip-complete").val(data); - }, + $("#recip").contact_autocomplete(baseurl + '/acl', '', false, function(data) { + $("#recip-complete").val(data.xid); }); }); diff --git a/view/js/mod_message.js b/view/js/mod_message.js deleted file mode 100644 index 82f60f46f..000000000 --- a/view/js/mod_message.js +++ /dev/null @@ -1,13 +0,0 @@ -$(document).ready(function() { - var a; - a = $("#recip").autocomplete({ - serviceUrl: baseurl + '/acl', - minChars: 2, - width: 250, - id: 'recip-ac', - onSelect: function(value,data) { - $("#recip-complete").val(data); - }, - }); - -}); diff --git a/view/js/mod_network.js b/view/js/mod_network.js index 8f1e5132d..1b7ccdc0a 100644 --- a/view/js/mod_network.js +++ b/view/js/mod_network.js @@ -1,10 +1,5 @@ $(document).ready(function() { - var a; - a = $("#search-text").autocomplete({ - serviceUrl: baseurl + '/search_ac', - minChars: 2, - id: 'search-text-ac', - }); + $("#search-text").contact_autocomplete(baseurl + '/acl'); $('.jslider-scale ins').addClass('hidden-xs'); }); diff --git a/view/js/mod_photos.js b/view/js/mod_photos.js index 0a64f8102..4c724c5e1 100644 --- a/view/js/mod_photos.js +++ b/view/js/mod_photos.js @@ -2,19 +2,11 @@ var ispublic = aStr['everybody']; $(document).ready(function() { - - var a; - a = $("#photo-edit-newtag").autocomplete({ - serviceUrl: baseurl + '/acl', - minChars: 2, - width: 250, - id: 'newtag-ac', - onSelect: function(value,data) { - $("#photo-edit-newtag").val(data); - }, - }); - a.setOptions({ params: { type: 'p' }}); - + $(document).ready(function() { + $("#photo-edit-newtag").contact_autocomplete(baseurl + '/acl', 'p', false, function(data) { + $("#photo-edit-newtag").val('@' + data.name.replace(' ','_')); // TODO: Get rid of underscore + }); + }); $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() { var selstr; diff --git a/view/js/mod_poke.js b/view/js/mod_poke.js index 78972888f..58e50588f 100644 --- a/view/js/mod_poke.js +++ b/view/js/mod_poke.js @@ -1,14 +1,5 @@ $(document).ready(function() { - var a; - a = $("#poke-recip").autocomplete({ - serviceUrl: baseurl + '/acl', - minChars: 2, - width: 250, - id: 'poke-recip-ac', - onSelect: function(value,data) { - $("#poke-recip-complete").val(data); - } + $("#poke-recip").contact_autocomplete(baseurl + '/acl', 'a', false, function(data) { + $("#poke-recip-complete").val(data.id); }); - a.setOptions({ params: { type: 'a' }}); - }); diff --git a/view/js/mod_sources.js b/view/js/mod_sources.js index 49880b38f..1bbf89765 100644 --- a/view/js/mod_sources.js +++ b/view/js/mod_sources.js @@ -1,15 +1,7 @@ $(document).ready(function() { - var a; - a = $("#id_name").autocomplete({ - serviceUrl: baseurl + '/acl', - minChars: 2, - width: 250, - id: 'id-name-ac', - onSelect: function(value,data) { - $("#id_abook").val(data); - } - }); - - a.setOptions({ params: { type: 'a' }}); - + $(document).ready(function() { + $("#id_name").contact_autocomplete(baseurl + '/acl', 'a', false, function(data) { + $("#id_abook").val(data.id); + }); + }); }); diff --git a/view/tpl/display-head.tpl b/view/tpl/display-head.tpl index 007d33fe8..913784d98 100755 --- a/view/tpl/display-head.tpl +++ b/view/tpl/display-head.tpl @@ -1,8 +1,8 @@ <script> $(document).ready(function() { - $(".comment-edit-wrapper textarea").contact_autocomplete(baseurl+"/acl?f=&n=1"); + $(".comment-edit-wrapper textarea").editor_autocomplete(baseurl+"/acl?f=&n=1"); // make auto-complete work in more places - $(".wall-item-comment-wrapper textarea").contact_autocomplete(baseurl+"/acl?f=&n=1"); + $(".wall-item-comment-wrapper textarea").editor_autocomplete(baseurl+"/acl?f=&n=1"); }); </script> diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index 8d26fc653..678d16a71 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -11,9 +11,9 @@ function initEditor(cb){ $("#profile-jot-text-loading").spin(false).hide(); $("#profile-jot-text").css({ 'height': 200, 'color': '#000' }); if(typeof channelId === 'undefined') - $("#profile-jot-text").contact_autocomplete(baseurl+"/acl"); + $("#profile-jot-text").editor_autocomplete(baseurl+"/acl"); else - $("#profile-jot-text").contact_autocomplete(baseurl+"/acl",[channelId]); // Also gives suggestions from current channel's connections + $("#profile-jot-text").editor_autocomplete(baseurl+"/acl",[channelId]); // Also gives suggestions from current channel's connections editor = true; $("a#jot-perms-icon").colorbox({ 'inline' : true, diff --git a/view/tpl/msg-header.tpl b/view/tpl/msg-header.tpl index 85fa51b0a..e1d1c6d23 100755 --- a/view/tpl/msg-header.tpl +++ b/view/tpl/msg-header.tpl @@ -41,7 +41,7 @@ if(plaintext != 'none') { }); } else - $("#prvmail-text").contact_autocomplete(baseurl+"/acl"); + $("#prvmail-text").editor_autocomplete(baseurl+"/acl"); </script> |