Merge pull request #3363 from sesom42/develop
authorHypolite Petovan <mrpetovan@gmail.com>
Wed, 19 Apr 2017 19:45:38 +0000 (15:45 -0400)
committerGitHub <noreply@github.com>
Wed, 19 Apr 2017 19:45:38 +0000 (15:45 -0400)
displays the correct profile for contacts that have set the default profile

16 files changed:
boot.php
htconfig.php
include/Contact.php
include/pgettext.php
js/acl.js
js/autocomplete.js
js/main.js
mod/admin.php
mod/network.php
mod/notifications.php
mod/search.php
view/templates/admin_site.tpl
view/theme/frio/js/textedit.js
view/theme/frio/js/theme.js
view/theme/frio/templates/comment_item.tpl
view/theme/frost/templates/admin_site.tpl

index becb9bd..c445994 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -1367,11 +1367,15 @@ class App {
                $cmdline = implode($args, " ");
 
                if (get_config('system', 'proc_windows')) {
-                       proc_close(proc_open('cmd /c start /b ' . $cmdline, array(), $foo, dirname(__FILE__)));
+                       $resource = proc_open('cmd /c start /b ' . $cmdline, array(), $foo, dirname(__FILE__));
                } else {
-                       proc_close(proc_open($cmdline . " &", array(), $foo, dirname(__FILE__)));
+                       $resource = proc_open($cmdline . " &", array(), $foo, dirname(__FILE__));
                }
-
+               if (!is_resource($resource)) {
+                       logger('We got no resource for command '.$cmdline, LOGGER_DEBUG);
+                       return;
+               }
+               proc_close($resource);
        }
 
        /**
index 5967e79..b3e4ef9 100644 (file)
@@ -87,7 +87,7 @@ $a->config['system']['no_regfullname'] = true;
 //$a->config['system']['block_local_dir'] = false;
 
 // Location of the global directory
-$a->config['system']['directory'] = 'http://dir.friendi.ca';
+$a->config['system']['directory'] = 'https://dir.friendica.social';
 
 // Allowed protocols in link URLs; HTTP protocols always are accepted
 $a->config['system']['allowed_link_protocols'] = array('ftp', 'ftps', 'mailto', 'cid', 'gopher');
index 4e86b32..6f662cd 100644 (file)
@@ -212,6 +212,10 @@ function unmark_for_death($contact) {
 function get_contact_details_by_url($url, $uid = -1, $default = array()) {
        static $cache = array();
 
+       if ($url == '') {
+               return $default;
+       }
+
        if ($uid == -1) {
                $uid = local_user();
        }
@@ -328,6 +332,10 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
 function get_contact_details_by_addr($addr, $uid = -1) {
        static $cache = array();
 
+       if ($addr == '') {
+               return array();
+       }
+
        if ($uid == -1) {
                $uid = local_user();
        }
@@ -534,6 +542,10 @@ function get_contact($url, $uid = 0, $no_update = false) {
        $data = array();
        $contact_id = 0;
 
+       if ($url == '') {
+               return 0;
+       }
+
        // We first try the nurl (http://server.tld/nick), most common case
        $contacts = q("SELECT `id`, `avatar-date` FROM `contact`
                                        WHERE `nurl` = '%s'
index 335869e..b42dcec 100644 (file)
@@ -44,7 +44,7 @@ function get_browser_language() {
        // check if we have translations for the preferred languages and pick the 1st that has
        for ($i=0; $i<count($lang_list); $i++) {
                $lang = $lang_list[$i];
-               if(file_exists("view/lang/$lang") && is_dir("view/lang/$lang")) {
+               if ($lang === 'en' || (file_exists("view/lang/$lang") && is_dir("view/lang/$lang"))) {
                        $preferred = $lang;
                        break;
                }
index 4924ac1..054f509 100644 (file)
--- a/js/acl.js
+++ b/js/acl.js
@@ -65,7 +65,7 @@ ACL.prototype.add_mention = function(id) {
        if (this.element.val().indexOf( searchText) >= 0 ) {
                return;
        }
-       this.element.val(searchText + this.element.val());
+       this.element.val(searchText + this.element.val()).trigger('change');
 }
 
 ACL.prototype.on_submit = function(){
index 8702abb..3ed9fa3 100644 (file)
@@ -166,7 +166,7 @@ function listNewLineAutocomplete(id) {
        if (word != null) {
                var textBefore = text.value.substring(0, caretPos);
                var textAfter  = text.value.substring(caretPos, text.length);
-               $('#' + id).val(textBefore + '\r\n[*] ' + textAfter);
+               $('#' + id).val(textBefore + '\r\n[*] ' + textAfter).trigger('change');
                setCaretPosition(text, caretPos + 5);
                return true;
        }
index c85aab4..5df33ed 100644 (file)
                        var start = textarea.selectionStart;
                        var end = textarea.selectionEnd;
                        textarea.value = textarea.value.substring(0, start) + bbcode + textarea.value.substring(end, textarea.value.length);
+                       $(textarea).trigger('change');
                });
 
 
index fe89faf..c57e7f3 100644 (file)
@@ -653,7 +653,6 @@ function admin_page_site_post(App $a) {
        $force_ssl              =       ((x($_POST,'force_ssl'))                ? True                                          : False);
        $hide_help              =       ((x($_POST,'hide_help'))                ? True                                          : False);
        $suppress_tags          =       ((x($_POST,'suppress_tags'))            ? True                                          : False);
-       $use_fulltext_engine    =       ((x($_POST,'use_fulltext_engine'))      ? True                                          : False);
        $itemcache              =       ((x($_POST,'itemcache'))                ? notags(trim($_POST['itemcache']))             : '');
        $itemcache_duration     =       ((x($_POST,'itemcache_duration'))       ? intval($_POST['itemcache_duration'])          : 0);
        $max_comments           =       ((x($_POST,'max_comments'))             ? intval($_POST['max_comments'])                : 0);
@@ -802,7 +801,6 @@ function admin_page_site_post(App $a) {
 
        set_config('system', 'force_ssl', $force_ssl);
        set_config('system', 'hide_help', $hide_help);
-       set_config('system', 'use_fulltext_engine', $use_fulltext_engine);
        set_config('system', 'itemcache', $itemcache);
        set_config('system', 'itemcache_duration', $itemcache_duration);
        set_config('system', 'max_comments', $max_comments);
@@ -1031,7 +1029,6 @@ function admin_page_site(App $a) {
 
                '$nodeinfo'             => array('nodeinfo', t("Publish server information"), get_config('system','nodeinfo'), t("If enabled, general server and usage data will be published. The data contains the name and version of the server, number of users with public profiles, number of posts and the activated protocols and connectors. See <a href='http://the-federation.info/'>the-federation.info</a> for details.")),
 
-               '$use_fulltext_engine'  => array('use_fulltext_engine', t("Use MySQL full text engine"), get_config('system','use_fulltext_engine'), t("Activates the full text engine. Speeds up search - but can only search for four and more characters.")),
                '$suppress_tags'        => array('suppress_tags', t("Suppress Tags"), get_config('system','suppress_tags'), t("Suppress showing a list of hashtags at the end of the posting.")),
                '$itemcache'            => array('itemcache', t("Path to item cache"), get_config('system','itemcache'), t("The item caches buffers generated bbcode and external images.")),
                '$itemcache_duration'   => array('itemcache_duration', t("Cache duration in seconds"), get_config('system','itemcache_duration'), t("How long should the cache files be hold? Default value is 86400 seconds (One day). To disable the item cache, set the value to -1.")),
index 5e94429..db4bb91 100644 (file)
@@ -581,11 +581,7 @@ function network_content(App $a, $update = 0) {
                        $sql_order = "`item`.`id`";
                        $order_mode = "id";
                } else {
-                       // Disabled until final decision what to do with this
-                       //if (get_config('system','use_fulltext_engine'))
-                       //      $sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
-                       //else
-                               $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
+                       $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
                        $sql_order = "`item`.`id`";
                        $order_mode = "id";
                }
index 0c08b66..bab5fd6 100644 (file)
@@ -292,7 +292,7 @@ function notifications_content(App $a) {
                                '$item_link' => $it['link'],
                                '$item_image' => $it['image'],
                                '$item_url' => $it['url'],
-                               '$item_text' => htmlentities($it['text']),
+                               '$item_text' => $it['text'],
                                '$item_when' => $it['when'],
                                '$item_ago' => $it['ago'],
                                '$item_seen' => $it['seen'],
index f274b2a..a804ca3 100644 (file)
@@ -203,12 +203,7 @@ function search_content(App $a) {
        } else {
                logger("Start fulltext search for '".$search."'", LOGGER_DEBUG);
 
-               // Disabled until finally is decided how to proceed with this
-               //if (get_config('system','use_fulltext_engine')) {
-               //      $sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
-               //} else {
-                       $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
-               //}
+               $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
 
                $r = q("SELECT %s
                        FROM `item` %s
index 86efb26..196bc47 100644 (file)
        <div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
 
        <h3>{{$performance}}</h3>
-       <!-- {{include file="field_checkbox.tpl" field=$use_fulltext_engine}} -->
        {{include file="field_checkbox.tpl" field=$only_tag_search}}
        {{include file="field_input.tpl" field=$itemcache}}
        {{include file="field_input.tpl" field=$itemcache_duration}}
index d212ee0..8794658 100644 (file)
@@ -30,6 +30,8 @@ function insertFormatting(BBcode,id) {
                }
        }
 
+       $(textarea).trigger('change');
+
        return true;
 }
 
index 4e32f91..41a437d 100644 (file)
@@ -275,7 +275,38 @@ $(document).ready(function(){
 
        });
 
+       /*
+        * This event handler hides all comment UI when the user clicks anywhere on the page
+        * It ensures that we aren't closing the current comment box
+        *
+        * We are making an exception for buttons because of a race condition with the
+        * comment opening button that results in an already closed comment UI.
+        */
+       $(document).on('click', function(event) {
+               if (event.target.type === 'button') {
+                       return true;
+               }
+
+               var $dontclosethis = $(event.target).closest('.wall-item-comment-wrapper').find('.comment-edit-form');
+               $('.wall-item-comment-wrapper .comment-edit-submit-wrapper:visible').each(function() {
+                       var $parent = $(this).parent('.comment-edit-form');
+                       var itemId = $parent.data('itemId');
+
+                       if ($dontclosethis[0] != $parent[0]) {
+                               var textarea = $parent.find('textarea').get(0)
+
+                               commentCloseUI(textarea, itemId);
+                       }
+               });
+       });
 
+       /*
+        * This event listeners ensures that the textarea size is updated event if the
+        * value is changed externally (textcomplete, insertFormatting, fbrowser...)
+        */
+       $(document).on('change', 'textarea', function(event) {
+               autosize.update(event.target);
+       });
 });
 
 function openClose(theID) {
index 8ce7805..168576b 100644 (file)
@@ -4,7 +4,7 @@
 {{else}}
 <div class="comment-wwedit-wrapper" id="comment-edit-wrapper-{{$id}}" style="display: block;">
 {{/if}}
-       <form class="comment-edit-form" style="display: block;" id="comment-edit-form-{{$id}}" action="item" method="post" onsubmit="post_comment({{$id}}); return false;">
+       <form class="comment-edit-form" style="display: block;" data-item-id="{{$id}}" id="comment-edit-form-{{$id}}" action="item" method="post" onsubmit="post_comment({{$id}}); return false;">
                <input type="hidden" name="type" value="{{$type}}" />
                <input type="hidden" name="profile_uid" value="{{$profile_uid}}" />
                <input type="hidden" name="parent" value="{{$parent}}" />
@@ -14,7 +14,7 @@
                <input type="hidden" name="post_id_random" value="{{$rand_num}}" />
 
                <div class="bb form-group">
-                       <textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty form-control text-autosize" name="body" placeholder="{{$comment}}" onFocus="commentOpenUI(this,{{$id}});" onBlur="commentCloseUI(this,{{$id}});"></textarea>
+                       <textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty form-control text-autosize" name="body" placeholder="{{$comment}}" onFocus="commentOpenUI(this,{{$id}});"></textarea>
                </div>
                {{if $qcomment}}
                        <select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
index 535242a..ab0b6af 100644 (file)
@@ -65,7 +65,6 @@
        {{include file="field_input.tpl" field=$basepath}}
 
        <h3>{{$performance}}</h3>
-       {{include file="field_checkbox.tpl" field=$use_fulltext_engine}}
        {{include file="field_input.tpl" field=$itemcache}}
        {{include file="field_input.tpl" field=$itemcache_duration}}