X-Git-Url: https://git.mxchange.org/?p=friendica-addons.git;a=blobdiff_plain;f=statusnet%2Fstatusnet.php;h=9158052a528bc0e43149fe9aaac6415565b78d00;hp=23110d4fd686f556ca40de63f46f147e30c93e98;hb=27b60e003f92dd9f3aebbeddb34ebb905488ca82;hpb=7dcfa83312af114b6ec09054308f45dfddd679c6 diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 23110d4f..9158052a 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -97,7 +97,7 @@ class StatusNetOAuth extends TwitterOAuth */ function http($url, $method, $postfields = NULL) { - $this->http_info = array(); + $this->http_info = []; $ci = curl_init(); /* Curl settings */ $prx = Config::get('system', 'proxy'); @@ -113,9 +113,9 @@ class StatusNetOAuth extends TwitterOAuth curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout); curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout); curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE); - curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:')); + curl_setopt($ci, CURLOPT_HTTPHEADER, ['Expect:']); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer); - curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader')); + curl_setopt($ci, CURLOPT_HEADERFUNCTION, [$this, 'getHeader']); curl_setopt($ci, CURLOPT_HEADER, FALSE); switch ($method) { @@ -331,7 +331,7 @@ function statusnet_settings(App $a, &$s) $mirrorenabled = PConfig::get(local_user(), 'statusnet', 'mirror_posts'); $mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : ''); $import = PConfig::get(local_user(), 'statusnet', 'import'); - $importselected = array("", "", ""); + $importselected = ["", "", ""]; $importselected[$import] = ' selected="selected"'; //$importenabled = PConfig::get(local_user(),'statusnet','import'); //$importchecked = (($importenabled) ? ' checked="checked" ' : ''); @@ -568,19 +568,21 @@ function statusnet_post_hook(App $a, &$b) $nicknameplain = "@" . $nick; logger("statusnet_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], LOGGER_DEBUG); - if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false)) + if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false)) { $b["body"] = $nickname . " " . $b["body"]; + } logger("statusnet_post_hook: parent found " . print_r($orig_post, true), LOGGER_DEBUG); } else { $iscomment = false; - if ($b['private'] || !strstr($b['postopts'], 'statusnet')) + if ($b['private'] || !strstr($b['postopts'], 'statusnet')) { return; + } // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::select('contact', array('id'), array('uid' => $b['uid'], 'self' => true), array('limit' => 1)); + $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } @@ -637,7 +639,7 @@ function statusnet_post_hook(App $a, &$b) $tempfile = ""; require_once "include/plaintext.php"; require_once "include/network.php"; - $msgarr = plaintext($a, $b, $max_char, true, 7); + $msgarr = plaintext($b, $max_char, true, 7); $msg = $msgarr["text"]; if (($msg == "") && isset($msgarr["title"])) @@ -660,9 +662,9 @@ function statusnet_post_hook(App $a, &$b) $img_str = fetch_url($image); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); - $postdata = array("status" => $msg, "media[]" => $tempfile); + $postdata = ["status" => $msg, "media[]" => $tempfile]; } else { - $postdata = array("status" => $msg); + $postdata = ["status" => $msg]; } // and now dent it :-) @@ -706,7 +708,7 @@ function statusnet_post_hook(App $a, &$b) function statusnet_plugin_admin_post(App $a) { - $sites = array(); + $sites = []; foreach ($_POST['sitename'] as $id => $sitename) { $sitename = trim($sitename); @@ -723,13 +725,13 @@ function statusnet_plugin_admin_post(App $a) $key != "" && !x($_POST['delete'][$id])) { - $sites[] = Array( + $sites[] = [ 'sitename' => $sitename, 'apiurl' => $apiurl, 'consumersecret' => $secret, 'consumerkey' => $key, //'applicationname' => $applicationname - ); + ]; } } @@ -739,34 +741,34 @@ function statusnet_plugin_admin_post(App $a) function statusnet_plugin_admin(App $a, &$o) { $sites = Config::get('statusnet', 'sites'); - $sitesform = array(); + $sitesform = []; if (is_array($sites)) { foreach ($sites as $id => $s) { - $sitesform[] = Array( - 'sitename' => Array("sitename[$id]", "Site name", $s['sitename'], ""), - 'apiurl' => Array("apiurl[$id]", "Api url", $s['apiurl'], t("Base API Path \x28remember the trailing /\x29")), - 'secret' => Array("secret[$id]", "Secret", $s['consumersecret'], ""), - 'key' => Array("key[$id]", "Key", $s['consumerkey'], ""), + $sitesform[] = [ + 'sitename' => ["sitename[$id]", "Site name", $s['sitename'], ""], + 'apiurl' => ["apiurl[$id]", "Api url", $s['apiurl'], t("Base API Path \x28remember the trailing /\x29")], + 'secret' => ["secret[$id]", "Secret", $s['consumersecret'], ""], + 'key' => ["key[$id]", "Key", $s['consumerkey'], ""], //'applicationname' => Array("applicationname[$id]", "Application name", $s['applicationname'], ""), - 'delete' => Array("delete[$id]", "Delete", False, "Check to delete this preset"), - ); + 'delete' => ["delete[$id]", "Delete", False, "Check to delete this preset"], + ]; } } /* empty form to add new site */ $id++; - $sitesform[] = Array( - 'sitename' => Array("sitename[$id]", t("Site name"), "", ""), - 'apiurl' => Array("apiurl[$id]", "Api url", "", t("Base API Path \x28remember the trailing /\x29")), - 'secret' => Array("secret[$id]", t("Consumer Secret"), "", ""), - 'key' => Array("key[$id]", t("Consumer Key"), "", ""), + $sitesform[] = [ + 'sitename' => ["sitename[$id]", t("Site name"), "", ""], + 'apiurl' => ["apiurl[$id]", "Api url", "", t("Base API Path \x28remember the trailing /\x29")], + 'secret' => ["secret[$id]", t("Consumer Secret"), "", ""], + 'key' => ["key[$id]", t("Consumer Key"), "", ""], //'applicationname' => Array("applicationname[$id]", t("Application name"), "", ""), - ); + ]; $t = get_markup_template("admin.tpl", "addon/statusnet/"); - $o = replace_macros($t, array( + $o = replace_macros($t, [ '$submit' => t('Save Settings'), '$sites' => $sitesform, - )); + ]); } function statusnet_prepare_body(App $a, &$b) @@ -806,7 +808,7 @@ function statusnet_prepare_body(App $a, &$b) } } - $msgarr = plaintext($a, $item, $max_char, true, 7); + $msgarr = plaintext($item, $max_char, true, 7); $msg = $msgarr["text"]; if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) { @@ -900,7 +902,7 @@ function statusnet_fetchtimeline(App $a, $uid) $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); - $parameters = array("exclude_replies" => true, "trim_user" => true, "contributor_details" => false, "include_rts" => false); + $parameters = ["exclude_replies" => true, "trim_user" => true, "contributor_details" => false, "include_rts" => false]; $first_time = ($lastid == ""); @@ -1004,11 +1006,11 @@ function statusnet_fetch_contact($uid, $contact, $create_user) return -1; } - GContact::update(array("url" => $contact->statusnet_profile_url, + GContact::update(["url" => $contact->statusnet_profile_url, "network" => NETWORK_STATUSNET, "photo" => $contact->profile_image_url, "name" => $contact->name, "nick" => $contact->screen_name, "location" => $contact->location, "about" => $contact->description, - "addr" => statusnet_address($contact), "generation" => 3)); + "addr" => statusnet_address($contact), "generation" => 3]); $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1", intval($uid), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(NETWORK_STATUSNET)); @@ -1141,7 +1143,7 @@ function statusnet_fetchuser(App $a, $uid, $screen_name = "", $user_id = "") return; } - $parameters = array(); + $parameters = []; if ($screen_name != "") { $parameters["screen_name"] = $screen_name; @@ -1172,7 +1174,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex $api = PConfig::get($uid, 'statusnet', 'baseapi'); $hostname = preg_replace("=https?://([\w\.]*)/.*=ism", "$1", $api); - $postarray = array(); + $postarray = []; $postarray['network'] = NETWORK_STATUSNET; $postarray['gravity'] = 0; $postarray['uid'] = $uid; @@ -1193,7 +1195,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex ); if (count($r)) { - return array(); + return []; } $contactid = 0; @@ -1242,7 +1244,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex $postarray['owner-link'] = $r[0]["url"]; $postarray['owner-avatar'] = $r[0]["photo"]; } else { - return array(); + return []; } } // Don't create accounts of people who just comment something @@ -1261,7 +1263,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex if (($contactid == 0) && !$only_existing_contact) { $contactid = $self['id']; } elseif ($contactid <= 0) { - return array(); + return []; } $postarray['contact-id'] = $contactid; @@ -1359,7 +1361,7 @@ function statusnet_checknotification(App $a, $uid, $own_url, $top_item, $postarr $conv_parent = $conv['parent']; - notification(array( + notification([ 'type' => NOTIFY_COMMENT, 'notify_flags' => $user[0]['notify-flags'], 'language' => $user[0]['language'], @@ -1374,7 +1376,7 @@ function statusnet_checknotification(App $a, $uid, $own_url, $top_item, $postarr 'verb' => ACTIVITY_POST, 'otype' => 'item', 'parent' => $conv_parent, - )); + ]); // only send one notification break; @@ -1384,7 +1386,7 @@ function statusnet_checknotification(App $a, $uid, $own_url, $top_item, $postarr function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) { - $conversations = array(); + $conversations = []; $ckey = PConfig::get($uid, 'statusnet', 'consumerkey'); $csecret = PConfig::get($uid, 'statusnet', 'consumersecret'); @@ -1433,7 +1435,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) return; } - $parameters = array("exclude_replies" => false, "trim_user" => false, "contributor_details" => true, "include_rts" => true); + $parameters = ["exclude_replies" => false, "trim_user" => false, "contributor_details" => true, "include_rts" => true]; //$parameters["count"] = 200; if ($mode == 1) { @@ -1567,7 +1569,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) if (($item != 0) && !function_exists("check_item_notification")) { require_once 'include/enotify.php'; - notification(array( + notification([ 'type' => NOTIFY_TAGSELF, 'notify_flags' => $u[0]['notify-flags'], 'language' => $u[0]['language'], @@ -1582,7 +1584,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) 'verb' => ACTIVITY_TAG, 'otype' => 'item', 'parent' => $parent_id, - )); + ]); } } } @@ -1709,7 +1711,7 @@ function statusnet_convertmsg(App $a, $body, $no_tags = false) } if ($no_tags) { - return array("body" => $body, "tags" => ""); + return ["body" => $body, "tags" => ""]; } $str_tags = ''; @@ -1737,7 +1739,7 @@ function statusnet_convertmsg(App $a, $body, $no_tags = false) } } - return array("body" => $body, "tags" => $str_tags); + return ["body" => $body, "tags" => $str_tags]; } function statusnet_fetch_own_contact(App $a, $uid)