3 require_once('include/security.php');
4 require_once('include/bbcode.php');
5 require_once('include/items.php');
8 function mood_init(&$a) {
14 $verb = notags(trim($_GET['verb']));
19 $verbs = get_mood_verbs();
21 if(! in_array($verb,$verbs))
24 $activity = ACTIVITY_MOOD . '#' . urlencode($verb);
26 $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : 0);
29 logger('mood: verb ' . $verb, LOGGER_DEBUG);
33 $r = q("select uri, private, allow_cid, allow_gid, deny_cid, deny_gid
34 from item where id = %d and parent = %d and uid = %d limit 1",
40 $parent_uri = $r[0]['uri'];
41 $private = $r[0]['private'];
42 $allow_cid = $r[0]['allow_cid'];
43 $allow_gid = $r[0]['allow_gid'];
44 $deny_cid = $r[0]['deny_cid'];
45 $deny_gid = $r[0]['deny_gid'];
52 $allow_cid = $a->user['allow_cid'];
53 $allow_gid = $a->user['allow_gid'];
54 $deny_cid = $a->user['deny_cid'];
55 $deny_gid = $a->user['deny_gid'];
58 $poster = $a->contact;
60 $uri = item_new_uri($a->get_hostname(),$uid);
62 $action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' , $verbs[$verb]);
68 $arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri);
69 $arr['type'] = 'activity';
71 $arr['contact-id'] = $poster['id'];
72 $arr['owner-name'] = $poster['name'];
73 $arr['owner-link'] = $poster['url'];
74 $arr['owner-avatar'] = $poster['thumb'];
75 $arr['author-name'] = $poster['name'];
76 $arr['author-link'] = $poster['url'];
77 $arr['author-avatar'] = $poster['thumb'];
79 $arr['allow_cid'] = $allow_cid;
80 $arr['allow_gid'] = $allow_gid;
81 $arr['deny_cid'] = $deny_cid;
82 $arr['deny_gid'] = $deny_gid;
83 $arr['last-child'] = 1;
85 $arr['verb'] = $activity;
86 $arr['private'] = $private;
89 $arr['body'] = $action;
91 $item_id = item_store($arr);
93 q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
94 dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
98 proc_run('php',"include/notifier.php","tag","$item_id");
102 call_hooks('post_local_end', $arr);
104 proc_run('php',"include/notifier.php","like","$post_id");
111 function mood_content(&$a) {
114 notice( t('Permission denied.') . EOL);
118 $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : '0');
122 $verbs = get_mood_verbs();
124 $shortlist = array();
125 foreach($verbs as $k => $v)
126 if($v !== 'NOTRANSLATION')
127 $shortlist[] = array($k,$v);
130 $tpl = get_markup_template('mood_content.tpl');
132 $o = replace_macros($tpl,array(
133 '$title' => t('Mood'),
134 '$desc' => t('Set your current mood and tell your friends'),
135 '$verbs' => $shortlist,
136 '$parent' => $parent,
137 '$submit' => t('Submit'),