2012-08-23 04:36:55 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once('include/security.php');
|
|
|
|
require_once('include/bbcode.php');
|
|
|
|
require_once('include/items.php');
|
|
|
|
|
2016-02-07 14:11:34 +00:00
|
|
|
|
2017-01-09 12:14:25 +00:00
|
|
|
function mood_init(App $a) {
|
2012-08-23 04:36:55 +00:00
|
|
|
|
2016-12-20 10:56:34 +00:00
|
|
|
if (! local_user()) {
|
2012-08-23 04:36:55 +00:00
|
|
|
return;
|
2016-12-20 10:56:34 +00:00
|
|
|
}
|
2012-08-23 04:36:55 +00:00
|
|
|
|
|
|
|
$uid = local_user();
|
|
|
|
$verb = notags(trim($_GET['verb']));
|
2014-03-11 22:52:32 +00:00
|
|
|
|
|
|
|
if(! $verb)
|
2012-08-23 04:36:55 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
$verbs = get_mood_verbs();
|
|
|
|
|
|
|
|
if(! in_array($verb,$verbs))
|
|
|
|
return;
|
|
|
|
|
|
|
|
$activity = ACTIVITY_MOOD . '#' . urlencode($verb);
|
|
|
|
|
|
|
|
$parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : 0);
|
|
|
|
|
|
|
|
|
|
|
|
logger('mood: verb ' . $verb, LOGGER_DEBUG);
|
|
|
|
|
|
|
|
|
|
|
|
if($parent) {
|
2014-03-11 22:52:32 +00:00
|
|
|
$r = q("select uri, private, allow_cid, allow_gid, deny_cid, deny_gid
|
2012-08-23 04:36:55 +00:00
|
|
|
from item where id = %d and parent = %d and uid = %d limit 1",
|
|
|
|
intval($parent),
|
|
|
|
intval($parent),
|
|
|
|
intval($uid)
|
|
|
|
);
|
2016-12-14 08:41:33 +00:00
|
|
|
if (dbm::is_result($r)) {
|
2012-08-23 04:36:55 +00:00
|
|
|
$parent_uri = $r[0]['uri'];
|
|
|
|
$private = $r[0]['private'];
|
|
|
|
$allow_cid = $r[0]['allow_cid'];
|
|
|
|
$allow_gid = $r[0]['allow_gid'];
|
|
|
|
$deny_cid = $r[0]['deny_cid'];
|
|
|
|
$deny_gid = $r[0]['deny_gid'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
$private = 0;
|
|
|
|
|
|
|
|
$allow_cid = $a->user['allow_cid'];
|
|
|
|
$allow_gid = $a->user['allow_gid'];
|
|
|
|
$deny_cid = $a->user['deny_cid'];
|
|
|
|
$deny_gid = $a->user['deny_gid'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$poster = $a->contact;
|
|
|
|
|
|
|
|
$uri = item_new_uri($a->get_hostname(),$uid);
|
|
|
|
|
2017-01-09 12:14:25 +00:00
|
|
|
$action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' , $verbs[$verb]);
|
2012-08-23 04:36:55 +00:00
|
|
|
|
|
|
|
$arr = array();
|
2016-03-20 14:01:50 +00:00
|
|
|
$arr['guid'] = get_guid(32);
|
2012-08-23 04:36:55 +00:00
|
|
|
$arr['uid'] = $uid;
|
|
|
|
$arr['uri'] = $uri;
|
|
|
|
$arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri);
|
|
|
|
$arr['type'] = 'activity';
|
|
|
|
$arr['wall'] = 1;
|
|
|
|
$arr['contact-id'] = $poster['id'];
|
|
|
|
$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['allow_cid'] = $allow_cid;
|
|
|
|
$arr['allow_gid'] = $allow_gid;
|
|
|
|
$arr['deny_cid'] = $deny_cid;
|
|
|
|
$arr['deny_gid'] = $deny_gid;
|
|
|
|
$arr['last-child'] = 1;
|
|
|
|
$arr['visible'] = 1;
|
|
|
|
$arr['verb'] = $activity;
|
|
|
|
$arr['private'] = $private;
|
|
|
|
|
|
|
|
$arr['origin'] = 1;
|
|
|
|
$arr['body'] = $action;
|
|
|
|
|
|
|
|
$item_id = item_store($arr);
|
|
|
|
if($item_id) {
|
2014-03-11 22:52:32 +00:00
|
|
|
q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
|
2016-12-19 13:26:13 +00:00
|
|
|
dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
|
2012-08-23 04:36:55 +00:00
|
|
|
intval($uid),
|
|
|
|
intval($item_id)
|
|
|
|
);
|
2016-08-01 05:48:43 +00:00
|
|
|
proc_run(PRIORITY_HIGH, "include/notifier.php", "tag", $item_id);
|
2012-08-23 04:36:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
call_hooks('post_local_end', $arr);
|
|
|
|
|
2016-08-01 05:48:43 +00:00
|
|
|
proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $post_id);
|
2012-08-23 04:36:55 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-02-07 14:11:34 +00:00
|
|
|
|
|
|
|
|
2017-01-09 12:14:25 +00:00
|
|
|
function mood_content(App $a) {
|
2012-08-23 04:36:55 +00:00
|
|
|
|
2016-12-20 10:56:34 +00:00
|
|
|
if (! local_user()) {
|
2012-08-23 04:36:55 +00:00
|
|
|
notice( t('Permission denied.') . EOL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : '0');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$verbs = get_mood_verbs();
|
|
|
|
|
|
|
|
$shortlist = array();
|
|
|
|
foreach($verbs as $k => $v)
|
|
|
|
if($v !== 'NOTRANSLATION')
|
|
|
|
$shortlist[] = array($k,$v);
|
|
|
|
|
|
|
|
|
|
|
|
$tpl = get_markup_template('mood_content.tpl');
|
|
|
|
|
|
|
|
$o = replace_macros($tpl,array(
|
|
|
|
'$title' => t('Mood'),
|
|
|
|
'$desc' => t('Set your current mood and tell your friends'),
|
|
|
|
'$verbs' => $shortlist,
|
|
|
|
'$parent' => $parent,
|
|
|
|
'$submit' => t('Submit'),
|
|
|
|
));
|
|
|
|
|
|
|
|
return $o;
|
2016-02-07 14:11:34 +00:00
|
|
|
|
2014-03-11 22:52:32 +00:00
|
|
|
}
|