4 * Poke, prod, finger, or otherwise do unspeakable things to somebody - who must be a connection in your address book
5 * This function can be invoked with the required arguments (verb and cid and private and possibly parent) silently via ajax or
6 * other web request. You must be logged in and connected to a profile.
7 * If the required arguments aren't present, we'll display a simple form to choose a recipient and a verb.
8 * parent is a special argument which let's you attach this activity as a comment to an existing conversation, which
9 * may have started with somebody else poking (etc.) somebody, but this isn't necessary. This can be used in the more pokes
10 * plugin version to have entire conversations where Alice poked Bob, Bob fingered Alice, Alice hugged Bob, etc.
12 * private creates a private conversation with the recipient. Otherwise your profile's default post privacy is used.
18 use Friendica\Core\System;
20 require_once('include/security.php');
21 require_once('include/bbcode.php');
22 require_once('include/items.php');
24 function poke_init(App $a) {
31 $verb = notags(trim($_GET['verb']));
37 $verbs = get_poke_verbs();
39 if (! array_key_exists($verb,$verbs)) {
43 $activity = ACTIVITY_POKE . '#' . urlencode($verbs[$verb][0]);
45 $contact_id = intval($_GET['cid']);
50 $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : 0);
53 logger('poke: verb ' . $verb . ' contact ' . $contact_id, LOGGER_DEBUG);
56 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
61 if (! dbm::is_result($r)) {
62 logger('poke: no contact ' . $contact_id);
69 $r = q("SELECT `uri`, `private`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`
70 FROM `item` WHERE `id` = %d AND `parent` = %d AND `uid` = %d LIMIT 1",
75 if (dbm::is_result($r)) {
76 $parent_uri = $r[0]['uri'];
77 $private = $r[0]['private'];
78 $allow_cid = $r[0]['allow_cid'];
79 $allow_gid = $r[0]['allow_gid'];
80 $deny_cid = $r[0]['deny_cid'];
81 $deny_gid = $r[0]['deny_gid'];
86 $private = ((x($_GET,'private')) ? intval($_GET['private']) : 0);
88 $allow_cid = (($private) ? '<' . $target['id']. '>' : $a->user['allow_cid']);
89 $allow_gid = (($private) ? '' : $a->user['allow_gid']);
90 $deny_cid = (($private) ? '' : $a->user['deny_cid']);
91 $deny_gid = (($private) ? '' : $a->user['deny_gid']);
94 $poster = $a->contact;
96 $uri = item_new_uri($a->get_hostname(),$uid);
100 $arr['guid'] = get_guid(32);
103 $arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri);
104 $arr['type'] = 'activity';
106 $arr['contact-id'] = $poster['id'];
107 $arr['owner-name'] = $poster['name'];
108 $arr['owner-link'] = $poster['url'];
109 $arr['owner-avatar'] = $poster['thumb'];
110 $arr['author-name'] = $poster['name'];
111 $arr['author-link'] = $poster['url'];
112 $arr['author-avatar'] = $poster['thumb'];
114 $arr['allow_cid'] = $allow_cid;
115 $arr['allow_gid'] = $allow_gid;
116 $arr['deny_cid'] = $deny_cid;
117 $arr['deny_gid'] = $deny_gid;
118 $arr['last-child'] = 1;
120 $arr['verb'] = $activity;
121 $arr['private'] = $private;
122 $arr['object-type'] = ACTIVITY_OBJ_PERSON;
125 $arr['body'] = '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' . ' ' . t($verbs[$verb][0]) . ' ' . '[url=' . $target['url'] . ']' . $target['name'] . '[/url]';
127 $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $target['name'] . '</title><id>' . System::baseUrl() . '/contact/' . $target['id'] . '</id>';
128 $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $target['url'] . '" />' . "\n");
130 $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $target['photo'] . '" />' . "\n");
131 $arr['object'] .= '</link></object>' . "\n";
133 $item_id = item_store($arr);
135 //q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
136 // dbesc(System::baseUrl() . '/display/' . $poster['nickname'] . '/' . $item_id),
140 proc_run(PRIORITY_HIGH, "include/notifier.php", "tag", $item_id);
144 call_hooks('post_local_end', $arr);
146 proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $post_id);
153 function poke_content(App $a) {
155 if (! local_user()) {
156 notice( t('Permission denied.') . EOL);
163 if(intval($_GET['c'])) {
164 $r = q("SELECT `id`,`name` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
168 if (dbm::is_result($r)) {
169 $name = $r[0]['name'];
175 $base = System::baseUrl();
177 $head_tpl = get_markup_template('poke_head.tpl');
178 $a->page['htmlhead'] .= replace_macros($head_tpl,array(
179 '$baseurl' => System::baseUrl(true),
184 $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : '0');
187 $verbs = get_poke_verbs();
189 $shortlist = array();
190 foreach($verbs as $k => $v)
191 if($v[1] !== 'NOTRANSLATION')
192 $shortlist[] = array($k,$v[1]);
195 $tpl = get_markup_template('poke_content.tpl');
197 $o = replace_macros($tpl,array(
198 '$title' => t('Poke/Prod'),
199 '$desc' => t('poke, prod or do other things to somebody'),
200 '$clabel' => t('Recipient'),
201 '$choice' => t('Choose what you wish to do to recipient'),
202 '$verbs' => $shortlist,
203 '$parent' => $parent,
204 '$prv_desc' => t('Make this post private'),
205 '$submit' => t('Submit'),