5 require_once('include/security.php');
6 require_once('include/bbcode.php');
7 require_once('include/items.php');
9 function mood_init(App $a) {
16 $verb = notags(trim($_GET['verb']));
21 $verbs = get_mood_verbs();
23 if(! in_array($verb,$verbs))
26 $activity = ACTIVITY_MOOD . '#' . urlencode($verb);
28 $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : 0);
31 logger('mood: verb ' . $verb, LOGGER_DEBUG);
35 $r = q("select uri, private, allow_cid, allow_gid, deny_cid, deny_gid
36 from item where id = %d and parent = %d and uid = %d limit 1",
41 if (dbm::is_result($r)) {
42 $parent_uri = $r[0]['uri'];
43 $private = $r[0]['private'];
44 $allow_cid = $r[0]['allow_cid'];
45 $allow_gid = $r[0]['allow_gid'];
46 $deny_cid = $r[0]['deny_cid'];
47 $deny_gid = $r[0]['deny_gid'];
54 $allow_cid = $a->user['allow_cid'];
55 $allow_gid = $a->user['allow_gid'];
56 $deny_cid = $a->user['deny_cid'];
57 $deny_gid = $a->user['deny_gid'];
60 $poster = $a->contact;
62 $uri = item_new_uri($a->get_hostname(),$uid);
64 $action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' , $verbs[$verb]);
67 $arr['guid'] = get_guid(32);
70 $arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri);
71 $arr['type'] = 'activity';
73 $arr['contact-id'] = $poster['id'];
74 $arr['owner-name'] = $poster['name'];
75 $arr['owner-link'] = $poster['url'];
76 $arr['owner-avatar'] = $poster['thumb'];
77 $arr['author-name'] = $poster['name'];
78 $arr['author-link'] = $poster['url'];
79 $arr['author-avatar'] = $poster['thumb'];
81 $arr['allow_cid'] = $allow_cid;
82 $arr['allow_gid'] = $allow_gid;
83 $arr['deny_cid'] = $deny_cid;
84 $arr['deny_gid'] = $deny_gid;
85 $arr['last-child'] = 1;
87 $arr['verb'] = $activity;
88 $arr['private'] = $private;
91 $arr['body'] = $action;
93 $item_id = item_store($arr);
95 q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
96 dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
100 proc_run(PRIORITY_HIGH, "include/notifier.php", "tag", $item_id);
104 call_hooks('post_local_end', $arr);
106 proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $post_id);
113 function mood_content(App $a) {
115 if (! local_user()) {
116 notice( t('Permission denied.') . EOL);
120 $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : '0');
124 $verbs = get_mood_verbs();
126 $shortlist = array();
127 foreach($verbs as $k => $v)
128 if($v !== 'NOTRANSLATION')
129 $shortlist[] = array($k,$v);
132 $tpl = get_markup_template('mood_content.tpl');
134 $o = replace_macros($tpl,array(
135 '$title' => t('Mood'),
136 '$desc' => t('Set your current mood and tell your friends'),
137 '$verbs' => $shortlist,
138 '$parent' => $parent,
139 '$submit' => t('Submit'),