Merge pull request #779 from MrPetovan/task/remove-x
authorMichael Vogel <icarus@dabo.de>
Sat, 1 Dec 2018 15:34:08 +0000 (16:34 +0100)
committerGitHub <noreply@github.com>
Sat, 1 Dec 2018 15:34:08 +0000 (16:34 +0100)
 Replace x() by !empty() or defaults()

1  2 
statusnet/statusnet.php
twitter/twitter.php

diff --combined statusnet/statusnet.php
@@@ -123,7 -123,7 +123,7 @@@ function statusnet_settings_post(App $a
                return;
        }
        // don't check GNU Social settings if GNU Social submit button is not clicked
-       if (!x($_POST, 'statusnet-submit')) {
+       if (empty($_POST['statusnet-submit'])) {
                return;
        }
  
@@@ -447,7 -447,7 +447,7 @@@ function statusnet_post_local(App $a, &
        }
  
        $statusnet_post = PConfig::get(local_user(), 'statusnet', 'post');
-       $statusnet_enable = (($statusnet_post && x($_REQUEST, 'statusnet_enable')) ? intval($_REQUEST['statusnet_enable']) : 0);
+       $statusnet_enable = (($statusnet_post && !empty($_REQUEST['statusnet_enable'])) ? intval($_REQUEST['statusnet_enable']) : 0);
  
        // if API is used, default to the chosen settings
        if ($b['api_source'] && intval(PConfig::get(local_user(), 'statusnet', 'post_by_default'))) {
@@@ -667,12 -667,12 +667,12 @@@ function statusnet_addon_admin_post(Ap
                }
                $secret = trim($_POST['secret'][$id]);
                $key = trim($_POST['key'][$id]);
-               //$applicationname = ((x($_POST, 'applicationname')) ? Strings::escapeTags(trim($_POST['applicationname'][$id])):'');
+               //$applicationname = (!empty($_POST['applicationname']) ? Strings::escapeTags(trim($_POST['applicationname'][$id])):'');
                if ($sitename != "" &&
                        $apiurl != "" &&
                        $secret != "" &&
                        $key != "" &&
-                       !x($_POST['delete'][$id])) {
+                       empty($_POST['delete'][$id])) {
  
                        $sites[] = [
                                'sitename' => $sitename,
@@@ -1534,7 -1534,7 +1534,7 @@@ function statusnet_convertmsg(App $a, $
                        if ($mtch[1] == "#") {
                                // Replacing the hash tags that are directed to the GNU Social server with internal links
                                $snhash = "#[url=" . $mtch[2] . "]" . $mtch[3] . "[/url]";
 -                              $frdchash = '#[url=' . $a->getBaseURL() . '/search?tag=' . rawurlencode($mtch[3]) . ']' . $mtch[3] . '[/url]';
 +                              $frdchash = '#[url=' . $a->getBaseURL() . '/search?tag=' . $mtch[3] . ']' . $mtch[3] . '[/url]';
                                $body = str_replace($snhash, $frdchash, $body);
  
                                $str_tags .= $frdchash;
diff --combined twitter/twitter.php
@@@ -446,7 -446,7 +446,7 @@@ function twitter_post_local(App $a, arr
        }
  
        $twitter_post = intval(PConfig::get(local_user(), 'twitter', 'post'));
-       $twitter_enable = (($twitter_post && x($_REQUEST, 'twitter_enable')) ? intval($_REQUEST['twitter_enable']) : 0);
+       $twitter_enable = (($twitter_post && !empty($_REQUEST['twitter_enable'])) ? intval($_REQUEST['twitter_enable']) : 0);
  
        // if API is used, default to the chosen settings
        if ($b['api_source'] && intval(PConfig::get(local_user(), 'twitter', 'post_by_default'))) {
@@@ -703,8 -703,8 +703,8 @@@ function twitter_post_hook(App $a, arra
  
  function twitter_addon_admin_post(App $a)
  {
-       $consumerkey    = x($_POST, 'consumerkey')    ? Strings::escapeTags(trim($_POST['consumerkey']))    : '';
-       $consumersecret = x($_POST, 'consumersecret') ? Strings::escapeTags(trim($_POST['consumersecret'])) : '';
+       $consumerkey    = !empty($_POST['consumerkey'])    ? Strings::escapeTags(trim($_POST['consumerkey']))    : '';
+       $consumersecret = !empty($_POST['consumersecret']) ? Strings::escapeTags(trim($_POST['consumersecret'])) : '';
        Config::set('twitter', 'consumerkey', $consumerkey);
        Config::set('twitter', 'consumersecret', $consumersecret);
        info(L10n::t('Settings updated.') . EOL);
@@@ -1201,7 -1201,7 +1201,7 @@@ function twitter_expand_entities(App $a
        $tags_arr = [];
  
        foreach ($item->entities->hashtags AS $hashtag) {
 -              $url = '#[url=' . $a->getBaseURL() . '/search?tag=' . rawurlencode($hashtag->text) . ']' . $hashtag->text . '[/url]';
 +              $url = '#[url=' . $a->getBaseURL() . '/search?tag=' . $hashtag->text . ']' . $hashtag->text . '[/url]';
                $tags_arr['#' . $hashtag->text] = $url;
                $body = str_replace('#' . $hashtag->text, $url, $body);
        }
                                }
  
                                $basetag = str_replace('_', ' ', substr($tag, 1));
 -                              $url = '#[url=' . $a->getBaseURL() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
 +                              $url = '#[url=' . $a->getBaseURL() . '/search?tag=' . $basetag . ']' . $basetag . '[/url]';
                                $body = str_replace($tag, $url, $body);
                                $tags_arr['#' . $basetag] = $url;
                        } elseif (strpos($tag, '@') === 0) {