4 use Friendica\Core\System;
6 require_once('include/security.php');
7 require_once('include/bbcode.php');
8 require_once('include/items.php');
10 function mood_init(App $a) {
17 $verb = notags(trim($_GET['verb']));
22 $verbs = get_mood_verbs();
24 if(! in_array($verb,$verbs))
27 $activity = ACTIVITY_MOOD . '#' . urlencode($verb);
29 $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : 0);
32 logger('mood: verb ' . $verb, LOGGER_DEBUG);
36 $r = q("select uri, private, allow_cid, allow_gid, deny_cid, deny_gid
37 from item where id = %d and parent = %d and uid = %d limit 1",
42 if (dbm::is_result($r)) {
43 $parent_uri = $r[0]['uri'];
44 $private = $r[0]['private'];
45 $allow_cid = $r[0]['allow_cid'];
46 $allow_gid = $r[0]['allow_gid'];
47 $deny_cid = $r[0]['deny_cid'];
48 $deny_gid = $r[0]['deny_gid'];
55 $allow_cid = $a->user['allow_cid'];
56 $allow_gid = $a->user['allow_gid'];
57 $deny_cid = $a->user['deny_cid'];
58 $deny_gid = $a->user['deny_gid'];
61 $poster = $a->contact;
63 $uri = item_new_uri($a->get_hostname(),$uid);
65 $action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' , $verbs[$verb]);
68 $arr['guid'] = get_guid(32);
71 $arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri);
72 $arr['type'] = 'activity';
74 $arr['contact-id'] = $poster['id'];
75 $arr['owner-name'] = $poster['name'];
76 $arr['owner-link'] = $poster['url'];
77 $arr['owner-avatar'] = $poster['thumb'];
78 $arr['author-name'] = $poster['name'];
79 $arr['author-link'] = $poster['url'];
80 $arr['author-avatar'] = $poster['thumb'];
82 $arr['allow_cid'] = $allow_cid;
83 $arr['allow_gid'] = $allow_gid;
84 $arr['deny_cid'] = $deny_cid;
85 $arr['deny_gid'] = $deny_gid;
86 $arr['last-child'] = 1;
88 $arr['verb'] = $activity;
89 $arr['private'] = $private;
92 $arr['body'] = $action;
94 $item_id = item_store($arr);
96 q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
97 dbesc(System::baseUrl() . '/display/' . $poster['nickname'] . '/' . $item_id),
101 proc_run(PRIORITY_HIGH, "include/notifier.php", "tag", $item_id);
105 call_hooks('post_local_end', $arr);
107 proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $post_id);
114 function mood_content(App $a) {
116 if (! local_user()) {
117 notice( t('Permission denied.') . EOL);
121 $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : '0');
125 $verbs = get_mood_verbs();
127 $shortlist = array();
128 foreach($verbs as $k => $v)
129 if($v !== 'NOTRANSLATION')
130 $shortlist[] = array($k,$v);
133 $tpl = get_markup_template('mood_content.tpl');
135 $o = replace_macros($tpl,array(
136 '$title' => t('Mood'),
137 '$desc' => t('Set your current mood and tell your friends'),
138 '$verbs' => $shortlist,
139 '$parent' => $parent,
140 '$submit' => t('Submit'),