$_SESSION['authenticated'] = true;
$_SESSION['uid'] = $uid;
+ unset($_REQUEST);
$_REQUEST['type'] = 'wall';
$_REQUEST['api_source'] = true;
$_REQUEST['body'] = $body;
$_REQUEST['location'] = $location;
- logger('fromgplus: posting for user '.$uid);
+ if (($_REQUEST['title'] == "") AND ($_REQUEST['body'] == "")) {
+ logger('fromgplus: empty post for user '.$uid." ".print_r($_REQUEST, true));
+ return;
+ }
require_once('mod/item.php');
//print_r($_REQUEST);
+ logger('fromgplus: posting for user '.$uid." ".print_r($_REQUEST, true));
item_post($a);
+ logger('fromgplus: done for user '.$uid);
}
function fromgplus_html2bbcode($html) {
return($cleaned);
}
-function fromgplus_handleattachments($item) {
+function fromgplus_handleattachments($item, $displaytext) {
$post = "";
$quote = "";
elseif ($images["full"] != "")
$post .= "\n[img]".$images["full"]."[/img]\n";
- if ($attachment->displayName != "")
+ if (($attachment->displayName != "") AND ($attachment->displayName != $displaytext))
$post .= fromgplus_html2bbcode($attachment->displayName)."\n";
break;
$post .= "\n[url=".$thumb->url."][img]".$image."[/img][/url]\n";
}
break;
+ case "audio":
+ $post .= "\n\n[bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n";
+ break;
//default:
// die($attachment->objectType);
}
$lastdate = 0;
+ if (!is_array($activities->items))
+ return;
+
$reversed = array_reverse($activities->items);
foreach($reversed as $item) {
$post = fromgplus_html2bbcode($item->object->content);
if (is_array($item->object->attachments))
- $post .= fromgplus_handleattachments($item);
+ $post .= fromgplus_handleattachments($item, $item->object->content);
// geocode, placeName
if (isset($item->address))
else
$location = "";
- fromgplus_post($a, $uid, $item->provider->title, $post, $location);
+ // Loop prevention - should be made better
+ if ($item->provider->title != "HootSuite")
+ fromgplus_post($a, $uid, "Google+", $post, $location);
+ //fromgplus_post($a, $uid, $item->provider->title, $post, $location);
break;
case "activity":
$post = fromgplus_html2bbcode($item->annotation)."\n";
- $post .= fromgplus_html2bbcode("♲");
- //$post .= html2bbcode("♻");
- //$post .= fromgplus_html2bbcode("◌");
- $post .= " [url=".$item->object->actor->url."]".$item->object->actor->displayName."[/url] \n";
- /*$post .= "[share author='".$item->object->actor->displayName.
- "' profile='".$item->object->actor->url.
- "' avatar='".$item->object->actor->image->url.
- "' link='".$item->object->url."']\n";*/
+ if (intval(get_config('system','new_share'))) {
+ $post .= "[share author='".str_replace("'", "'",$item->object->actor->displayName).
+ "' profile='".$item->object->actor->url.
+ "' avatar='".$item->object->actor->image->url.
+ "' link='".$item->object->url."']";
- $post .= fromgplus_html2bbcode($item->object->content);
+ $post .= fromgplus_html2bbcode($item->object->content);
- if (is_array($item->object->attachments))
- $post .= "\n".trim(fromgplus_handleattachments($item));
+ if (is_array($item->object->attachments))
+ $post .= "\n".trim(fromgplus_handleattachments($item, $item->object->content));
+
+ $post .= "[/share]";
+ } else {
+ $post .= fromgplus_html2bbcode("♲");
+ $post .= " [url=".$item->object->actor->url."]".$item->object->actor->displayName."[/url] \n";
+ $post .= fromgplus_html2bbcode($item->object->content);
- //$post .= "[/share]";
+ if (is_array($item->object->attachments))
+ $post .= "\n".trim(fromgplus_handleattachments($item, $item->object->content));
+ }
if (isset($item->address))
$location = $item->address;
else
$location = "";
- fromgplus_post($a, $uid, $item->provider->title, $post, $location);
+ // Loop prevention - should be made better
+ if ($item->provider->title != "HootSuite")
+ fromgplus_post($a, $uid, "Google+", $post, $location);
+ //fromgplus_post($a, $uid, $item->provider->title, $post, $location);
break;
}
}