mood mostly working
This commit is contained in:
parent
4af6d77de3
commit
aa88165383
2
done
2
done
@ -127,7 +127,7 @@ mod/
|
|||||||
match.php
|
match.php
|
||||||
message.php
|
message.php
|
||||||
modexp.php
|
modexp.php
|
||||||
mood.php
|
? mood.php
|
||||||
msearch.php
|
msearch.php
|
||||||
? network.php
|
? network.php
|
||||||
nogroup.php
|
nogroup.php
|
||||||
|
@ -83,7 +83,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
|
|||||||
* Render actions localized
|
* Render actions localized
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function localize_item(&$item,$brief = false){
|
function localize_item(&$item){
|
||||||
|
|
||||||
$extracted = item_extract_images($item['body']);
|
$extracted = item_extract_images($item['body']);
|
||||||
if($extracted['images'])
|
if($extracted['images'])
|
||||||
@ -93,18 +93,16 @@ function localize_item(&$item,$brief = false){
|
|||||||
|
|
||||||
if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){
|
if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){
|
||||||
|
|
||||||
$obj= json_decode($item['object']);
|
$obj= json_decode($item['object'],true);
|
||||||
|
|
||||||
// logger('object: ' . print_r($obj,true));
|
if($obj['author'] && $obj['author']['link'])
|
||||||
|
$author_link = get_rel_link($obj['author']['link'],'alternate');
|
||||||
if($obj->author && $obj->author->link)
|
|
||||||
$author_link = get_json_rel_link($obj->author->link,'alternate');
|
|
||||||
else
|
else
|
||||||
$author_link = '';
|
$author_link = '';
|
||||||
|
|
||||||
$author_name = (($obj->author && $obj->author->name) ? $obj->author->name : '');
|
$author_name = (($obj['author'] && $obj['author']['name']) ? $obj['author']['name'] : '');
|
||||||
|
|
||||||
$item_url = get_json_rel_link($obj->link,'alternate');
|
$item_url = get_rel_link($obj['link'],'alternate');
|
||||||
|
|
||||||
|
|
||||||
// If we couldn't parse something useful, don't bother translating.
|
// If we couldn't parse something useful, don't bother translating.
|
||||||
@ -139,7 +137,7 @@ function localize_item(&$item,$brief = false){
|
|||||||
elseif(activity_match($item['verb'],ACTIVITY_DISLIKE)) {
|
elseif(activity_match($item['verb'],ACTIVITY_DISLIKE)) {
|
||||||
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
|
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
|
||||||
}
|
}
|
||||||
$item['body'] = sprintf($bodyverb, $author, $objauthor, $plink);
|
$item['body'] = $item['localize'] = sprintf($bodyverb, $author, $objauthor, $plink);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,56 +147,48 @@ function localize_item(&$item,$brief = false){
|
|||||||
|
|
||||||
if ($item['obj_type']=="" || $item['obj_type']!== ACTIVITY_OBJ_PERSON) return;
|
if ($item['obj_type']=="" || $item['obj_type']!== ACTIVITY_OBJ_PERSON) return;
|
||||||
|
|
||||||
$Aname = $item['author-name'];
|
$Aname = $item['author']['xchan_name'];
|
||||||
$Alink = $item['author-link'];
|
$Alink = $item['author']['xchan_url'];
|
||||||
|
|
||||||
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
|
|
||||||
|
|
||||||
$obj = parse_xml_string($xmlhead.$item['object']);
|
$obj= json_decode($item['object'],true);
|
||||||
$links = parse_xml_string($xmlhead."<links>".unxmlify($obj->link)."</links>");
|
|
||||||
|
|
||||||
$Bname = $obj->title;
|
$Blink = $Bphoto = '';
|
||||||
$Blink = ""; $Bphoto = "";
|
|
||||||
foreach ($links->link as $l){
|
|
||||||
$atts = $l->attributes();
|
|
||||||
switch($atts['rel']){
|
|
||||||
case "alternate": $Blink = $atts['href'];
|
|
||||||
case "photo": $Bphoto = $atts['href'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if($obj['link']) {
|
||||||
|
$Blink = get_rel_link($obj['link'],'alternate');
|
||||||
|
$Bphoto = get_rel_link($obj['link'],'photo');
|
||||||
}
|
}
|
||||||
|
$Bname = $obj['title'];
|
||||||
|
|
||||||
|
|
||||||
$A = '[url=' . zid($Alink) . ']' . $Aname . '[/url]';
|
$A = '[url=' . zid($Alink) . ']' . $Aname . '[/url]';
|
||||||
$B = '[url=' . zid($Blink) . ']' . $Bname . '[/url]';
|
$B = '[url=' . zid($Blink) . ']' . $Bname . '[/url]';
|
||||||
if ($Bphoto!="") $Bphoto = '[url=' . zid($Blink) . '][img]' . $Bphoto . '[/img][/url]';
|
if ($Bphoto!="") $Bphoto = '[url=' . zid($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]';
|
||||||
|
|
||||||
$item['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$Bphoto;
|
|
||||||
|
|
||||||
|
$item['body'] = $item['localize'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B);
|
||||||
|
$item['body'] .= "\n\n\n" . $Bphoto;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stristr($item['verb'],ACTIVITY_POKE)) {
|
if (stristr($item['verb'],ACTIVITY_POKE)) {
|
||||||
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
|
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
|
||||||
if(! $verb)
|
if(! $verb)
|
||||||
return;
|
return;
|
||||||
if ($item['obj_type']=="" || $item['obj_type']!== ACTIVITY_OBJ_PERSON) return;
|
if ($item['obj_type']=="" || $item['obj_type']!== ACTIVITY_OBJ_PERSON) return;
|
||||||
|
|
||||||
$Aname = $item['author-name'];
|
$Aname = $item['author']['xchan_name'];
|
||||||
$Alink = $item['author-link'];
|
$Alink = $item['author']['xchan_url'];
|
||||||
|
|
||||||
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
|
|
||||||
|
|
||||||
$obj = parse_xml_string($xmlhead.$item['object']);
|
$obj= json_decode($item['object'],true);
|
||||||
$links = parse_xml_string($xmlhead."<links>".unxmlify($obj->link)."</links>");
|
|
||||||
|
|
||||||
$Bname = $obj->title;
|
$Blink = $Bphoto = '';
|
||||||
$Blink = ""; $Bphoto = "";
|
|
||||||
foreach ($links->link as $l){
|
|
||||||
$atts = $l->attributes();
|
|
||||||
switch($atts['rel']){
|
|
||||||
case "alternate": $Blink = $atts['href'];
|
|
||||||
case "photo": $Bphoto = $atts['href'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if($obj['link']) {
|
||||||
|
$Blink = get_rel_link($obj['link'],'alternate');
|
||||||
|
$Bphoto = get_rel_link($obj['link'],'photo');
|
||||||
}
|
}
|
||||||
|
$Bname = $obj['title'];
|
||||||
|
|
||||||
$A = '[url=' . zid($Alink) . ']' . $Aname . '[/url]';
|
$A = '[url=' . zid($Alink) . ']' . $Aname . '[/url]';
|
||||||
$B = '[url=' . zid($Blink) . ']' . $Bname . '[/url]';
|
$B = '[url=' . zid($Blink) . ']' . $Bname . '[/url]';
|
||||||
@ -215,7 +205,8 @@ function localize_item(&$item,$brief = false){
|
|||||||
|
|
||||||
// then do the sprintf on the translation string
|
// then do the sprintf on the translation string
|
||||||
|
|
||||||
$item['body'] = sprintf($txt, $A, $B). "\n\n\n" . $Bphoto;
|
$item['body'] = $item['localize'] = sprintf($txt, $A, $B);
|
||||||
|
$item['body'] .= "\n\n\n" . $Bphoto;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (stristr($item['verb'],ACTIVITY_MOOD)) {
|
if (stristr($item['verb'],ACTIVITY_MOOD)) {
|
||||||
@ -223,14 +214,18 @@ function localize_item(&$item,$brief = false){
|
|||||||
if(! $verb)
|
if(! $verb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$Aname = $item['author-name'];
|
$Aname = $item['author']['xchan_name'];
|
||||||
$Alink = $item['author-link'];
|
$Alink = $item['author']['xchan_url'];
|
||||||
|
|
||||||
$A = '[url=' . zid($Alink) . ']' . $Aname . '[/url]';
|
$A = '[url=' . zid($Alink) . ']' . $Aname . '[/url]';
|
||||||
|
|
||||||
$txt = t('%1$s is currently %2$s');
|
$txt = t('%1$s is currently %2$s');
|
||||||
|
|
||||||
$item['body'] = sprintf($txt, $A, t($verb));
|
$item['body'] = sprintf($txt, $A, t($verb));
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
// FIXME store parent item as object or target
|
||||||
|
// (and update to json storage)
|
||||||
|
|
||||||
if (activity_match($item['verb'],ACTIVITY_TAG)) {
|
if (activity_match($item['verb'],ACTIVITY_TAG)) {
|
||||||
$r = q("SELECT * from `item`,`contact` WHERE
|
$r = q("SELECT * from `item`,`contact` WHERE
|
||||||
@ -269,13 +264,14 @@ function localize_item(&$item,$brief = false){
|
|||||||
$item['body'] = sprintf( t('%1$s tagged %2$s\'s %3$s with %4$s'), $author, $objauthor, $plink, $tag );
|
$item['body'] = sprintf( t('%1$s tagged %2$s\'s %3$s with %4$s'), $author, $objauthor, $plink, $tag );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activity_match($item['verb'],ACTIVITY_FAVORITE)){
|
if (activity_match($item['verb'],ACTIVITY_FAVORITE)){
|
||||||
|
|
||||||
if ($item['obj_type']== "")
|
if ($item['obj_type']== "")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$Aname = $item['author-name'];
|
$Aname = $item['author']['xchan_name'];
|
||||||
$Alink = $item['author-link'];
|
$Alink = $item['author']['xchan_url'];
|
||||||
|
|
||||||
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
|
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
|
||||||
|
|
||||||
@ -297,6 +293,8 @@ function localize_item(&$item,$brief = false){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
$matches = null;
|
$matches = null;
|
||||||
if(preg_match_all('/@\[url=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) {
|
if(preg_match_all('/@\[url=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) {
|
||||||
foreach($matches as $mtch) {
|
foreach($matches as $mtch) {
|
||||||
|
@ -13,17 +13,17 @@ return array();
|
|||||||
// Call localize_item with the "brief" flag to get a one line status for activities.
|
// Call localize_item with the "brief" flag to get a one line status for activities.
|
||||||
// This should set $item['localized'] to indicate we have a brief summary.
|
// This should set $item['localized'] to indicate we have a brief summary.
|
||||||
|
|
||||||
localize_item($item,true);
|
localize_item($item);
|
||||||
|
|
||||||
// FIXME - we may need the parent
|
// FIXME - we may need the parent
|
||||||
|
|
||||||
if(! $item['localized']) {
|
if(! $item['localize']) {
|
||||||
$itemem_text = (($item['item_flags'] & ITEM_THREAD_TOP)
|
$itemem_text = (($item['item_flags'] & ITEM_THREAD_TOP)
|
||||||
? sprintf( t("%s created a new post"), $item['author']['xchan_name'])
|
? sprintf( t("%s created a new post"), $item['author']['xchan_name'])
|
||||||
: sprintf( t("%s commented on %s's post"), $item['author']['xchan_name'], $item['pname']));
|
: sprintf( t("%s commented on %s's post"), $item['author']['xchan_name'], $item['pname']));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$itemem_text = $item['body'];
|
$itemem_text = $item['localize'];
|
||||||
|
|
||||||
// convert this logic into a json array just like the system notifications
|
// convert this logic into a json array just like the system notifications
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@ function item_message_id() {
|
|||||||
$dups = false;
|
$dups = false;
|
||||||
$hash = random_string();
|
$hash = random_string();
|
||||||
|
|
||||||
$uri = $hash . '@' . $hostname;
|
$uri = $hash . '@' . get_app()->get_hostname();
|
||||||
|
|
||||||
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
|
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
|
||||||
dbesc($uri));
|
dbesc($uri));
|
||||||
@ -527,8 +527,8 @@ function contact_block() {
|
|||||||
$o = '';
|
$o = '';
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
logger('contact block');
|
|
||||||
$shown = get_pconfig($a->profile['uid'],'system','display_friend_count');
|
$shown = get_pconfig($a->profile['uid'],'system','display_friend_count');
|
||||||
|
|
||||||
if($shown === false)
|
if($shown === false)
|
||||||
$shown = 24;
|
$shown = 24;
|
||||||
if($shown == 0)
|
if($shown == 0)
|
||||||
@ -1730,11 +1730,11 @@ function find_xchan_in_array($xchan,$arr) {
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_json_rel_link($j,$rel) {
|
function get_rel_link($j,$rel) {
|
||||||
if(count($j))
|
if(count($j))
|
||||||
foreach($j as $l)
|
foreach($j as $l)
|
||||||
if($l->rel === $rel)
|
if($l['rel'] === $rel)
|
||||||
return $l->href;
|
return $l['href'];
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
59
mod/mood.php
59
mod/mood.php
@ -30,7 +30,7 @@ function mood_init(&$a) {
|
|||||||
|
|
||||||
|
|
||||||
if($parent) {
|
if($parent) {
|
||||||
$r = q("select uri, private, allow_cid, allow_gid, deny_cid, deny_gid
|
$r = q("select uri, owner_xchan, private, allow_cid, allow_gid, deny_cid, deny_gid
|
||||||
from item where id = %d and parent = %d and uid = %d limit 1",
|
from item where id = %d and parent = %d and uid = %d limit 1",
|
||||||
intval($parent),
|
intval($parent),
|
||||||
intval($parent),
|
intval($parent),
|
||||||
@ -47,62 +47,55 @@ function mood_init(&$a) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
$private = 0;
|
$private = 0;
|
||||||
|
$channel = $a->get_channel();
|
||||||
|
|
||||||
$allow_cid = $a->user['allow_cid'];
|
$allow_cid = $channel['channel_allow_cid'];
|
||||||
$allow_gid = $a->user['allow_gid'];
|
$allow_gid = $channel['channel_allow_gid'];
|
||||||
$deny_cid = $a->user['deny_cid'];
|
$deny_cid = $channel['channel_deny_cid'];
|
||||||
$deny_gid = $a->user['deny_gid'];
|
$deny_gid = $channel['channel_deny_gid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$poster = $a->contact;
|
$poster = $a->get_observer();
|
||||||
|
|
||||||
$uri = item_message_id();
|
$uri = item_message_id();
|
||||||
|
|
||||||
$action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' , $verbs[$verb]);
|
$action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['xchan_url'] . ']' . $poster['xchan_name'] . '[/url]' , $verbs[$verb]);
|
||||||
|
$item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_UNSEEN;
|
||||||
|
if(! $parent_uri)
|
||||||
|
$item_flags |= ITEM_THREAD_TOP;
|
||||||
|
|
||||||
|
|
||||||
$arr = array();
|
$arr = array();
|
||||||
|
|
||||||
|
$arr['aid'] = get_account_id();
|
||||||
$arr['uid'] = $uid;
|
$arr['uid'] = $uid;
|
||||||
$arr['uri'] = $uri;
|
$arr['uri'] = $uri;
|
||||||
$arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri);
|
$arr['parent_uri'] = (($parent_uri) ? $parent_uri : $uri);
|
||||||
$arr['type'] = 'activity';
|
$arr['item_flags'] = $item_flags;
|
||||||
$arr['wall'] = 1;
|
$arr['author_xchan'] = $poster['xchan_hash'];
|
||||||
$arr['contact-id'] = $poster['id'];
|
$arr['owner_xchan'] = (($parent_uri) ? $r[0]['owner_xchan'] : $poster['xchan_hash']);
|
||||||
$arr['owner-name'] = $poster['name'];
|
|
||||||
$arr['owner-link'] = $poster['url'];
|
|
||||||
$arr['owner-avatar'] = $poster['thumb'];
|
|
||||||
$arr['author-name'] = $poster['name'];
|
|
||||||
$arr['author-link'] = $poster['url'];
|
|
||||||
$arr['author-avatar'] = $poster['thumb'];
|
|
||||||
$arr['title'] = '';
|
$arr['title'] = '';
|
||||||
$arr['allow_cid'] = $allow_cid;
|
$arr['allow_cid'] = $allow_cid;
|
||||||
$arr['allow_gid'] = $allow_gid;
|
$arr['allow_gid'] = $allow_gid;
|
||||||
$arr['deny_cid'] = $deny_cid;
|
$arr['deny_cid'] = $deny_cid;
|
||||||
$arr['deny_gid'] = $deny_gid;
|
$arr['deny_gid'] = $deny_gid;
|
||||||
$arr['last-child'] = 1;
|
|
||||||
$arr['visible'] = 1;
|
|
||||||
$arr['verb'] = $activity;
|
$arr['verb'] = $activity;
|
||||||
$arr['private'] = $private;
|
|
||||||
|
|
||||||
$arr['origin'] = 1;
|
|
||||||
$arr['body'] = $action;
|
$arr['body'] = $action;
|
||||||
|
|
||||||
$item_id = item_store($arr);
|
$item_id = item_store($arr);
|
||||||
if($item_id) {
|
if($item_id) {
|
||||||
q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
|
// q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
|
||||||
dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
|
// dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
|
||||||
intval($uid),
|
// intval($uid),
|
||||||
intval($item_id)
|
// intval($item_id)
|
||||||
);
|
// );
|
||||||
proc_run('php',"include/notifier.php","tag","$item_id");
|
|
||||||
|
proc_run('php',"include/notifier.php","activity", $item_id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
call_hooks('post_local_end', $arr);
|
call_hooks('post_local_end', $arr);
|
||||||
|
|
||||||
proc_run('php',"include/notifier.php","like","$post_id");
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user