*/
function http($url, $method, $postfields = NULL)
{
- $this->http_info = array();
+ $this->http_info = [];
$ci = curl_init();
/* Curl settings */
$prx = Config::get('system', 'proxy');
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) {
}
}
}
- goaway($a->get_baseurl() . '/settings/connectors');
+ goaway('settings/connectors');
} else {
if (isset($_POST['statusnet-consumersecret'])) {
// check if we can reach the API of the GNU Social server
notice(t('We could not contact the GNU Social API with the Path you entered.') . EOL);
}
}
- goaway($a->get_baseurl() . '/settings/connectors');
+ goaway('settings/connectors');
} else {
if (isset($_POST['statusnet-pin'])) {
// if the user supplied us with a PIN from GNU Social, let the magic of OAuth happen
PConfig::set(local_user(), 'statusnet', 'post', 1);
PConfig::set(local_user(), 'statusnet', 'post_taglinks', 1);
// reload the Addon Settings page, if we don't do it see Bug #42
- goaway($a->get_baseurl() . '/settings/connectors');
+ goaway('settings/connectors');
} else {
// if no PIN is supplied in the POST variables, the user has changed the setting
// to post a dent for every new __public__ posting to the wall
$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" ' : '');
$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;
}
$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"]))
$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 :-)
function statusnet_plugin_admin_post(App $a)
{
- $sites = array();
+ $sites = [];
foreach ($_POST['sitename'] as $id => $sitename) {
$sitename = trim($sitename);
$key != "" &&
!x($_POST['delete'][$id])) {
- $sites[] = Array(
+ $sites[] = [
'sitename' => $sitename,
'apiurl' => $apiurl,
'consumersecret' => $secret,
'consumerkey' => $key,
//'applicationname' => $applicationname
- );
+ ];
}
}
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)
}
}
- $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")) {
$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 == "");
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));
return;
}
- $parameters = array();
+ $parameters = [];
if ($screen_name != "") {
$parameters["screen_name"] = $screen_name;
$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;
);
if (count($r)) {
- return array();
+ return [];
}
$contactid = 0;
$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
if (($contactid == 0) && !$only_existing_contact) {
$contactid = $self['id'];
} elseif ($contactid <= 0) {
- return array();
+ return [];
}
$postarray['contact-id'] = $contactid;
$conv_parent = $conv['parent'];
- notification(array(
+ notification([
'type' => NOTIFY_COMMENT,
'notify_flags' => $user[0]['notify-flags'],
'language' => $user[0]['language'],
'verb' => ACTIVITY_POST,
'otype' => 'item',
'parent' => $conv_parent,
- ));
+ ]);
// only send one notification
break;
function statusnet_fetchhometimeline(App $a, $uid, $mode = 1)
{
- $conversations = array();
+ $conversations = [];
$ckey = PConfig::get($uid, 'statusnet', 'consumerkey');
$csecret = PConfig::get($uid, 'statusnet', 'consumersecret');
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) {
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'],
'verb' => ACTIVITY_TAG,
'otype' => 'item',
'parent' => $parent_id,
- ));
+ ]);
}
}
}
}
if ($no_tags) {
- return array("body" => $body, "tags" => "");
+ return ["body" => $body, "tags" => ""];
}
$str_tags = '';
}
}
- return array("body" => $body, "tags" => $str_tags);
+ return ["body" => $body, "tags" => $str_tags];
}
function statusnet_fetch_own_contact(App $a, $uid)