5 * Poke, prod, finger, or otherwise do unspeakable things to somebody - who must be a connection in your address book
6 * This function can be invoked with the required arguments (verb and cid and private and possibly parent) silently via ajax or
7 * other web request. You must be logged in and connected to a profile.
8 * If the required arguments aren't present, we'll display a simple form to choose a recipient and a verb.
9 * parent is a special argument which let's you attach this activity as a comment to an existing conversation, which
10 * may have started with somebody else poking (etc.) somebody, but this isn't necessary. This can be used in the more pokes
11 * plugin version to have entire conversations where Alice poked Bob, Bob fingered Alice, Alice hugged Bob, etc.
13 * private creates a private conversation with the recipient. Otherwise your profile's default post privacy is used.
17 require_once('include/security.php');
18 require_once('include/bbcode.php');
19 require_once('include/items.php');
22 function poke_init(&$a) {
28 $verb = notags(trim($_GET['verb']));
33 $verbs = get_poke_verbs();
35 if(! array_key_exists($verb,$verbs))
38 $activity = ACTIVITY_POKE . '#' . urlencode($verbs[$verb][0]);
40 $contact_id = intval($_GET['cid']);
44 $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : 0);
47 logger('poke: verb ' . $verb . ' contact ' . $contact_id, LOGGER_DEBUG);
50 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
56 logger('poke: no contact ' . $contact_id);
63 $r = q("SELECT `uri`, `private`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`
64 FROM `item` WHERE `id` = %d AND `parent` = %d AND `uid` = %d LIMIT 1",
70 $parent_uri = $r[0]['uri'];
71 $private = $r[0]['private'];
72 $allow_cid = $r[0]['allow_cid'];
73 $allow_gid = $r[0]['allow_gid'];
74 $deny_cid = $r[0]['deny_cid'];
75 $deny_gid = $r[0]['deny_gid'];
80 $private = ((x($_GET,'private')) ? intval($_GET['private']) : 0);
82 $allow_cid = (($private) ? '<' . $target['id']. '>' : $a->user['allow_cid']);
83 $allow_gid = (($private) ? '' : $a->user['allow_gid']);
84 $deny_cid = (($private) ? '' : $a->user['deny_cid']);
85 $deny_gid = (($private) ? '' : $a->user['deny_gid']);
88 $poster = $a->contact;
90 $uri = item_new_uri($a->get_hostname(),$uid);
94 $arr['guid'] = get_guid(32);
97 $arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri);
98 $arr['type'] = 'activity';
100 $arr['contact-id'] = $poster['id'];
101 $arr['owner-name'] = $poster['name'];
102 $arr['owner-link'] = $poster['url'];
103 $arr['owner-avatar'] = $poster['thumb'];
104 $arr['author-name'] = $poster['name'];
105 $arr['author-link'] = $poster['url'];
106 $arr['author-avatar'] = $poster['thumb'];
108 $arr['allow_cid'] = $allow_cid;
109 $arr['allow_gid'] = $allow_gid;
110 $arr['deny_cid'] = $deny_cid;
111 $arr['deny_gid'] = $deny_gid;
112 $arr['last-child'] = 1;
114 $arr['verb'] = $activity;
115 $arr['private'] = $private;
116 $arr['object-type'] = ACTIVITY_OBJ_PERSON;
119 $arr['body'] = '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' . ' ' . t($verbs[$verb][0]) . ' ' . '[url=' . $target['url'] . ']' . $target['name'] . '[/url]';
121 $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $target['name'] . '</title><id>' . $a->get_baseurl() . '/contact/' . $target['id'] . '</id>';
122 $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $target['url'] . '" />' . "\n");
124 $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $target['photo'] . '" />' . "\n");
125 $arr['object'] .= '</link></object>' . "\n";
127 $item_id = item_store($arr);
129 //q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
130 // dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
134 proc_run(PRIORITY_HIGH, "include/notifier.php", "tag", $item_id);
138 call_hooks('post_local_end', $arr);
140 proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $post_id);
147 function poke_content(&$a) {
150 notice( t('Permission denied.') . EOL);
157 if(intval($_GET['c'])) {
158 $r = q("SELECT `id`,`name` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
163 $name = $r[0]['name'];
169 $base = $a->get_baseurl();
171 $head_tpl = get_markup_template('poke_head.tpl');
172 $a->page['htmlhead'] .= replace_macros($head_tpl,array(
173 '$baseurl' => $a->get_baseurl(true),
178 $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : '0');
181 $verbs = get_poke_verbs();
183 $shortlist = array();
184 foreach($verbs as $k => $v)
185 if($v[1] !== 'NOTRANSLATION')
186 $shortlist[] = array($k,$v[1]);
189 $tpl = get_markup_template('poke_content.tpl');
191 $o = replace_macros($tpl,array(
192 '$title' => t('Poke/Prod'),
193 '$desc' => t('poke, prod or do other things to somebody'),
194 '$clabel' => t('Recipient'),
195 '$choice' => t('Choose what you wish to do to recipient'),
196 '$verbs' => $shortlist,
197 '$parent' => $parent,
198 '$prv_desc' => t('Make this post private'),
199 '$submit' => t('Submit'),