3 require_once('include/security.php');
4 require_once('include/bbcode.php');
5 require_once('include/items.php');
8 function poke_init(&$a) {
14 $verb = notags(trim($_GET['verb']));
19 $verbs = get_poke_verbs();
21 if(! array_key_exists($verb,$verbs))
24 $activity = ACTIVITY_POKE . '#' . urlencode($verbs[$verb][0]);
26 $contact_id = intval($_GET['cid']);
30 $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : 0);
33 logger('poke: verb ' . $verb . ' contact ' . $contact_id, LOGGER_DEBUG);
36 $r = q("SELECT * FROM `contact` WHERE `id` = %d and `uid` = %d LIMIT 1",
42 logger('poke: no contact ' . $contact_id);
49 $r = q("select uri, private, allow_cid, allow_gid, deny_cid, deny_gid
50 from item where id = %d and parent = %d and uid = %d limit 1",
56 $parent_uri = $r[0]['uri'];
57 $private = $r[0]['private'];
58 $allow_cid = $r[0]['allow_cid'];
59 $allow_gid = $r[0]['allow_gid'];
60 $deny_cid = $r[0]['deny_cid'];
61 $deny_gid = $r[0]['deny_gid'];
66 $private = ((x($_GET,'private')) ? intval($_GET['private']) : 0);
68 $allow_cid = (($private) ? '<' . $target['id']. '>' : $a->user['allow_cid']);
69 $allow_gid = (($private) ? '' : $a->user['allow_gid']);
70 $deny_cid = (($private) ? '' : $a->user['deny_cid']);
71 $deny_gid = (($private) ? '' : $a->user['deny_gid']);
77 $poster = $a->contact;
79 $uri = item_new_uri($a->get_hostname(),$owner_uid);
85 $arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri);
86 $arr['type'] = 'activity';
88 $arr['contact-id'] = $poster['id'];
89 $arr['owner-name'] = $poster['name'];
90 $arr['owner-link'] = $poster['url'];
91 $arr['owner-avatar'] = $poster['thumb'];
92 $arr['author-name'] = $poster['name'];
93 $arr['author-link'] = $poster['url'];
94 $arr['author-avatar'] = $poster['thumb'];
96 $arr['allow_cid'] = $allow_cid;
97 $arr['allow_gid'] = $allow_gid;
98 $arr['deny_cid'] = $deny_cid;
99 $arr['deny_gid'] = $deny_gid;
100 $arr['last-child'] = 1;
102 $arr['verb'] = $activity;
103 $arr['private'] = $private;
104 $arr['object-type'] = ACTIVITY_OBJ_PERSON;
107 $arr['body'] = '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' . ' ' . t($verbs[$verb][0]) . ' ' . '[url=' . $target['url'] . ']' . $target['name'] . '[/url]';
109 $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $target['name'] . '</title><id>' . $a->get_baseurl() . '/contact/' . $target['id'] . '</id>';
110 $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $target['url'] . '" />' . "\n");
112 $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $target['photo'] . '" />' . "\n");
113 $arr['object'] .= '</link></object>' . "\n";
115 $item_id = item_store($arr);
117 q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
118 dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
122 proc_run('php',"include/notifier.php","tag","$item_id");
126 call_hooks('post_local_end', $arr);
128 proc_run('php',"include/notifier.php","like","$post_id");
135 function poke_content(&$a) {
138 notice( t('Permission denied.') . EOL);
145 if(intval($_GET['c'])) {
146 $r = q("select id,name from contact where id = %d and uid = %d limit 1",
151 $name = $r[0]['name'];
157 $base = $a->get_baseurl();
159 $a->page['htmlhead'] .= '<script src="' . $a->get_baseurl(true) . '/library/jquery_ac/friendica.complete.js" ></script>';
160 $a->page['htmlhead'] .= <<< EOT
162 <script>$(document).ready(function() {
164 a = $("#poke-recip").autocomplete({
165 serviceUrl: '$base/acl',
168 onSelect: function(value,data) {
169 $("#poke-recip-complete").val(data);
172 a.setOptions({ params: { type: 'a' }});
180 $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : '0');
184 $verbs = get_poke_verbs();
186 $shortlist = array();
187 foreach($verbs as $k => $v)
188 if($v[1] !== 'NOTRANSLATION')
189 $shortlist[] = array($k,$v[1]);
192 $tpl = get_markup_template('poke_content.tpl');
194 $o = replace_macros($tpl,array(
195 '$title' => t('Poke/Prod'),
196 '$desc' => t('poke, prod or do other things to somebody'),
197 '$clabel' => t('Recipient'),
198 '$choice' => t('Choose what you wish to do to recipient'),
199 '$verbs' => $shortlist,
200 '$parent' => $parent,
201 '$prv_desc' => t('Make this post private'),
202 '$submit' => t('Submit'),