}
function blockem_display_item(&$a,&$b) {
+ if (empty($b['output']['body'])) {
+ return;
+ }
+
if(strstr($b['output']['body'],'id="blockem-wrap-'))
$b['output']['thumb'] = $a->get_baseurl() . "/images/person-80.jpg";
}
$blocked = false;
$author = $b['item']['author-link'];
- if(is_array($a->data['blockem'])) {
+ if(!empty($a->data['blockem'])) {
foreach($a->data['blockem'] as $bloke) {
if(link_compare($bloke,$author)) {
$blocked = true;
$lastdate = 0;
- if (!is_array($activities->items))
+ if (empty($activities->items))
return;
$reversed = array_reverse($activities->items);
return;
}
- if ($_GET["mode"] == "minimal") {
+ if (defaults($_GET, "mode", '') == "minimal") {
return;
}
$cleanedurlpart = explode("%", $urldata["host"]);
$hostname = explode(".", $cleanedurlpart[0]);
+ if (empty($hostname)) {
+ return false;
+ }
+
$site = $hostname[sizeof($hostname) - 2].".".$hostname[sizeof($hostname) - 1];
return (isset($sites[$site]));
use Friendica\Core\Config;
use Friendica\Core\L10n;
-function newmemberwidget_install () {
- Addon::registerHook( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init');
- logger('newmemberwidget installed');
+function newmemberwidget_install()
+{
+ Addon::registerHook( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init');
+ logger('newmemberwidget installed');
}
-function newmemberwidget_uninstall () {
- Addon::unregisterHook( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init');
+
+function newmemberwidget_uninstall()
+{
+ Addon::unregisterHook( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init');
}
-function newmemberwidget_network_mod_init ( $a, $b) {
- if (x($_SESSION['new_member'])) {
+function newmemberwidget_network_mod_init ($a, $b)
+{
+ if (empty($_SESSION['new_member'])) {
+ return;
+ }
+
$t = '<div id="newmember_widget" class="widget">'.EOL;
$t .= '<h3>'.L10n::t('New Member').'</h3>'.EOL;
$t .= '<a href="newmember" id="newmemberwidget-tips">' . L10n::t('Tips for New Members') . '</a><br />'.EOL;
- if (Config::get('newmemberwidget','linkglobalsupport')==1)
- $t .= '<a href="https://forum.friendi.ca/profile/helpers" target="_new">'.L10n::t('Global Support Forum').'</a><br />'.EOL;
- if (Config::get('newmemberwidget','linklocalsupport')==1)
- $t .= '<a href="'.$a->get_baseurl().'/profile/'.Config::get('newmemberwidget','localsupport').'" target="_new">'.L10n::t('Local Support Forum').'</a><br />'.EOL;
- $ft = Config::get('newmemberwidget','freetext');
- if (!trim($ft)=="")
- $t .= '<p>'.BBCode::convert(trim($ft)).'</p>';
+
+ if (Config::get('newmemberwidget','linkglobalsupport', false)) {
+ $t .= '<a href="https://forum.friendi.ca/profile/helpers" target="_new">'.L10n::t('Global Support Forum').'</a><br />'.EOL;
+ }
+
+ if (Config::get('newmemberwidget','linklocalsupport', false)) {
+ $t .= '<a href="'.$a->get_baseurl().'/profile/'.Config::get('newmemberwidget','localsupport').'" target="_new">'.L10n::t('Local Support Forum').'</a><br />'.EOL;
+ }
+
+ $ft = Config::get('newmemberwidget','freetext', '');
+ if (!empty($ft)) {
+ $t .= '<p>'.BBCode::convert(trim($ft)).'</p>';
+ }
+
$t .= '</div><div class="clear"></div>';
- $a->page['aside'] = $t . $a->page['aside'];
- }
+ $a->page['aside'] = $t . $a->page['aside'];
}
function newmemberwidget_addon_admin_post(&$a)
}
}
- if ($target == "") {
+ if (empty($target)) {
$target = $nomserver.'?q='.urlencode($item['location']);
}
'objectType' => "note",
'content' => $content];
- if ($title != "") {
+ if (!empty($title)) {
$params["object"]["displayName"] = $title;
}
- if (count($receiver["to"])) {
+ if (!empty($receiver["to"])) {
$params["to"] = $receiver["to"];
}
- if (count($receiver["bto"])) {
+ if (!empty($receiver["bto"])) {
$params["bto"] = $receiver["bto"];
}
- if (count($receiver["cc"])) {
+ if (!empty($receiver["cc"])) {
$params["cc"] = $receiver["cc"];
}
- if (count($receiver["bcc"])) {
+ if (!empty($receiver["bcc"])) {
$params["bcc"] = $receiver["bcc"];
}
} else {
function pumpio_sync(&$a)
{
- $r = q("SELECT * FROM `addon` WHERE `installed` = 1 AND `name` = 'pumpio'",
- $plugin);
+ $r = q("SELECT * FROM `addon` WHERE `installed` = 1 AND `name` = 'pumpio'");
if (!DBM::is_result($r)) {
return;
logger('pumpio: fetching for user '.$uid.' '.$url.' C:'.$client->client_id.' CS:'.$client->client_secret.' T:'.$client->access_token.' TS:'.$client->access_token_secret);
- $username = $user.'@'.$host;
+ $useraddr = $username.'@'.$hostname;
if (pumpio_reachable($url)) {
$success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError'=>true], $user);
}
if (!$success) {
- logger('pumpio: error fetching posts for user '.$uid." ".$username." ".print_r($user, true));
+ logger('pumpio: error fetching posts for user '.$uid." ".$useraddr." ".print_r($user, true));
return;
}
{
require_once('include/items.php');
- if ($post->object->id == "") {
+ if (empty($post->object->id)) {
logger('Got empty like: '.print_r($post, true), LOGGER_DEBUG);
return;
}
$likedata['gravity'] = GRAVITY_ACTIVITY;
$likedata['uid'] = $uid;
$likedata['wall'] = 0;
+ $likedata['network'] = NETWORK_PUMPIO;
$likedata['uri'] = Item::newURI($uid);
$likedata['parent-uri'] = $orig_post["uri"];
$likedata['contact-id'] = $contactid;
$reply = new stdClass;
$reply->verb = "note";
- $reply->cc = $post->cc;
+
+ if (isset($post->cc)) {
+ $reply->cc = $post->cc;
+ }
+
$reply->to = $post->to;
$reply->object = new stdClass;
$reply->object->objectType = $post->object->inReplyTo->objectType;
$postarray['parent-uri'] = $post->object->inReplyTo->id;
}
- if ($post->object->pump_io->proxyURL) {
+ if (!empty($post->object->pump_io->proxyURL)) {
$postarray['extid'] = $post->object->pump_io->proxyURL;
}
$postarray['body'] = HTML::toBBCode($post->object->content);
$postarray['object'] = json_encode($post);
- if ($post->object->fullImage->url != "") {
+ if (!empty($post->object->fullImage->url)) {
$postarray["body"] = "[url=".$post->object->fullImage->url."][img]".$post->object->image->url."[/img][/url]\n".$postarray["body"];
}
- if ($post->object->displayName != "") {
+ if (!empty($post->object->displayName)) {
$postarray['title'] = $post->object->displayName;
}
$success = false;
}
+ if (!$success) {
+ return;
+ }
+
if ($user->items) {
$posts = array_reverse($user->items);
$like->object->id = $item->id;
$like->actor = new stdClass;
$like->actor->displayName = $item->displayName;
- $like->actor->preferredUsername = $item->preferredUsername;
+ //$like->actor->preferredUsername = $item->preferredUsername;
+ //$like->actor->image = $item->image;
$like->actor->url = $item->url;
- $like->actor->image = $item->image;
$like->generator = new stdClass;
$like->generator->displayName = "pumpio";
pumpio_dolike($a, $uid, $self, $post, $own_id, false);
$ignored_modules = ["fbrowser"];
$ignored = in_array($a->module, $ignored_modules);
- if (is_site_admin() && ($_GET["mode"] != "minimal") && !$a->is_mobile && !$a->is_tablet && !$ignored) {
+ if (is_site_admin() && (defaults($_GET, "mode", '') != "minimal") && !$a->is_mobile && !$a->is_tablet && !$ignored) {
$o = $o.'<div class="renderinfo">'. L10n::t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s",
round($a->performance["database"] - $a->performance["database_write"], 3),
round($a->performance["database_write"], 3),
if (get_body_length($hook_data['html']) > $chars) {
$found = true;
$shortened = trim(showmore_cutitem($hook_data['html'], $chars)) . "...";
+ } else {
+ $found = false;
}
if ($found) {
$postarray['uid'] = $uid;
$postarray['wall'] = 0;
- if (is_object($post->retweeted_status)) {
+ if (!empty($post->retweeted_status)) {
$content = $post->retweeted_status;
statusnet_fetch_contact($uid, $content->user, false);
} else {
$contactid = 0;
- if ($content->in_reply_to_status_id != "") {
+ if (!empty($content->in_reply_to_status_id)) {
$parent = $hostname . "::" . $content->in_reply_to_status_id;
$postarray['created'] = DateTimeFormat::utc($content->created_at);
$postarray['edited'] = DateTimeFormat::utc($content->created_at);
- if (is_string($content->place->name)) {
+ if (!empty($content->place->name)) {
$postarray["location"] = $content->place->name;
}
- if (is_string($content->place->full_name)) {
+ if (!empty($content->place->full_name)) {
$postarray["location"] = $content->place->full_name;
}
- if (is_array($content->geo->coordinates)) {
+ if (!empty($content->geo->coordinates)) {
$postarray["coord"] = $content->geo->coordinates[0] . " " . $content->geo->coordinates[1];
}
- if (is_array($content->coordinates->coordinates)) {
+ if (!empty($content->coordinates->coordinates)) {
$postarray["coord"] = $content->coordinates->coordinates[1] . " " . $content->coordinates->coordinates[0];
}
switch ($action) {
case "delete":
// To-Do: $result = $connection->post('statuses/destroy', $post);
+ $result = [];
break;
case "like":
$result = $connection->post('favorites/create', $post);
case "unlike":
$result = $connection->post('favorites/destroy', $post);
break;
+ default:
+ logger('Unhandled action ' . $action, LOGGER_DEBUG);
+ $result = [];
}
logger("twitter_action '" . $action . "' send, result: " . print_r($result, true), LOGGER_DEBUG);
}
// $datarray['object'] = json_encode($post); // Activate for debugging
$datarray["title"] = "";
- if (is_object($post->retweeted_status)) {
+ if (!empty($post->retweeted_status)) {
// We don't support nested shares, so we mustn't show quotes as shares on retweets
$item = twitter_createpost($a, $uid, $post->retweeted_status, ['id' => 0], false, false, true);
$oembed_data = OEmbed::fetchURL($expanded_url);
+ if (empty($oembed_data) || empty($oembed_data->type)) {
+ continue;
+ }
+
// Quickfix: Workaround for URL with "[" and "]" in it
if (strpos($expanded_url, "[") || strpos($expanded_url, "]")) {
$expanded_url = $url->url;
function twitter_media_entities($post, &$postarray)
{
// There are no media entities? So we quit.
- if (!is_array($post->extended_entities->media)) {
+ if (empty($post->extended_entities->media)) {
return "";
}
// This is a pure media post, first search for all media urls
$media = [];
foreach ($post->extended_entities->media AS $medium) {
+ if (!isset($media[$medium->url])) {
+ $media[$medium->url] = '';
+ }
switch ($medium->type) {
case 'photo':
$media[$medium->url] .= "\n[img]" . $medium->media_url_https . "[/img]";
if ($post->user->protected) {
$postarray['private'] = 1;
$postarray['allow_cid'] = '<' . $self['id'] . '>';
+ } else {
+ $postarray['private'] = 0;
+ $postarray['allow_cid'] = '';
}
if (is_string($post->full_text)) {
$statustext = $converted["plain"];
- if (is_string($post->place->name)) {
+ if (!empty($post->place->name)) {
$postarray["location"] = $post->place->name;
}
- if (is_string($post->place->full_name)) {
+ if (!empty($post->place->full_name)) {
$postarray["location"] = $post->place->full_name;
}
- if (is_array($post->geo->coordinates)) {
+ if (!empty($post->geo->coordinates)) {
$postarray["coord"] = $post->geo->coordinates[0] . " " . $post->geo->coordinates[1];
}
- if (is_array($post->coordinates->coordinates)) {
+ if (!empty($post->coordinates->coordinates)) {
$postarray["coord"] = $post->coordinates->coordinates[1] . " " . $post->coordinates->coordinates[0];
}
- if (is_object($post->retweeted_status)) {
+ if (!empty($post->retweeted_status)) {
$retweet = twitter_createpost($a, $uid, $post->retweeted_status, $self, false, false, $noquote);
- $retweet['object'] = $postarray['object'];
+ //$retweet['object'] = $postarray['object']; // Activate for debugging
$retweet['private'] = $postarray['private'];
$retweet['allow_cid'] = $postarray['allow_cid'];
$retweet['contact-id'] = $postarray['contact-id'];
$postarray = $retweet;
}
- if (is_object($post->quoted_status) && !$noquote) {
+ if (!empty($post->quoted_status) && !$noquote) {
$quoted = twitter_createpost($a, $uid, $post->quoted_status, $self, false, false, true);
$postarray['body'] = $statustext;
$posts = array_reverse($posts);
- if (count($posts)) {
+ if (!empty($posts)) {
foreach ($posts as $post) {
$postarray = twitter_createpost($a, $uid, $post, $self, false, false, false);
- if (trim($postarray['body']) == "") {
+ if (empty($postarray['body'])) {
continue;
}
$item = Item::insert($postarray);
- if ($notify) {
- $item = $notify;
- }
-
$postarray["id"] = $item;
logger('twitter_fetchparentpost: User ' . $self["nick"] . ' posted parent timeline item ' . $item);
$postarray = twitter_createpost($a, $uid, $post, $self, $create_user, true, false);
- if (trim($postarray['body']) == "") {
+ if (empty($postarray['body']) || trim($postarray['body']) == "") {
continue;
}
return;
}
- if ($_GET["mode"] == "minimal") {
+ if (defaults($_GET, "mode", '') == "minimal") {
return;
}