3 require_once('include/security.php');
4 require_once('include/bbcode.php');
5 require_once('include/items.php');
8 function mood_init(App $a) {
15 $verb = notags(trim($_GET['verb']));
20 $verbs = get_mood_verbs();
22 if(! in_array($verb,$verbs))
25 $activity = ACTIVITY_MOOD . '#' . urlencode($verb);
27 $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : 0);
30 logger('mood: verb ' . $verb, LOGGER_DEBUG);
34 $r = q("select uri, private, allow_cid, allow_gid, deny_cid, deny_gid
35 from item where id = %d and parent = %d and uid = %d limit 1",
40 if (dbm::is_result($r)) {
41 $parent_uri = $r[0]['uri'];
42 $private = $r[0]['private'];
43 $allow_cid = $r[0]['allow_cid'];
44 $allow_gid = $r[0]['allow_gid'];
45 $deny_cid = $r[0]['deny_cid'];
46 $deny_gid = $r[0]['deny_gid'];
53 $allow_cid = $a->user['allow_cid'];
54 $allow_gid = $a->user['allow_gid'];
55 $deny_cid = $a->user['deny_cid'];
56 $deny_gid = $a->user['deny_gid'];
59 $poster = $a->contact;
61 $uri = item_new_uri($a->get_hostname(),$uid);
63 $action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' , $verbs[$verb]);
66 $arr['guid'] = get_guid(32);
69 $arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri);
70 $arr['type'] = 'activity';
72 $arr['contact-id'] = $poster['id'];
73 $arr['owner-name'] = $poster['name'];
74 $arr['owner-link'] = $poster['url'];
75 $arr['owner-avatar'] = $poster['thumb'];
76 $arr['author-name'] = $poster['name'];
77 $arr['author-link'] = $poster['url'];
78 $arr['author-avatar'] = $poster['thumb'];
80 $arr['allow_cid'] = $allow_cid;
81 $arr['allow_gid'] = $allow_gid;
82 $arr['deny_cid'] = $deny_cid;
83 $arr['deny_gid'] = $deny_gid;
84 $arr['last-child'] = 1;
86 $arr['verb'] = $activity;
87 $arr['private'] = $private;
90 $arr['body'] = $action;
92 $item_id = item_store($arr);
94 q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
95 dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
99 proc_run(PRIORITY_HIGH, "include/notifier.php", "tag", $item_id);
103 call_hooks('post_local_end', $arr);
105 proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $post_id);
112 function mood_content(App $a) {
114 if (! local_user()) {
115 notice( t('Permission denied.') . EOL);
119 $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : '0');
123 $verbs = get_mood_verbs();
125 $shortlist = array();
126 foreach($verbs as $k => $v)
127 if($v !== 'NOTRANSLATION')
128 $shortlist[] = array($k,$v);
131 $tpl = get_markup_template('mood_content.tpl');
133 $o = replace_macros($tpl,array(
134 '$title' => t('Mood'),
135 '$desc' => t('Set your current mood and tell your friends'),
136 '$verbs' => $shortlist,
137 '$parent' => $parent,
138 '$submit' => t('Submit'),