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']);
31 $private = ((x($_GET,'private')) ? intval($_GET['private']) : 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);
48 $poster = $a->contact;
50 $uri = item_new_uri($a->get_hostname(),$owner_uid);
56 $arr['parent-uri'] = $uri;
57 $arr['type'] = 'activity';
59 $arr['contact-id'] = $poster['id'];
60 $arr['owner-name'] = $poster['name'];
61 $arr['owner-link'] = $poster['url'];
62 $arr['owner-avatar'] = $poster['thumb'];
63 $arr['author-name'] = $poster['name'];
64 $arr['author-link'] = $poster['url'];
65 $arr['author-avatar'] = $poster['thumb'];
67 $arr['allow_cid'] = (($private) ? '<' . $target['id']. '>' : $a->user['allow_cid']);
68 $arr['allow_gid'] = (($private) ? '' : $a->user['allow_gid']);
69 $arr['deny_cid'] = (($private) ? '' : $a->user['deny_cid']);
70 $arr['deny_gid'] = (($private) ? '' : $a->user['deny_gid']);
71 $arr['last-child'] = 1;
73 $arr['verb'] = $activity;
74 $arr['private'] = $private;
75 $arr['object-type'] = ACTIVITY_OBJ_PERSON;
78 $arr['body'] = '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' . ' ' . t($verbs[$verb][0]) . ' ' . '[url=' . $target['url'] . ']' . $target['name'] . '[/url]';
80 $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $target['name'] . '</title><id>' . $a->get_baseurl() . '/contact/' . $target['id'] . '</id>';
81 $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $target['url'] . '" />' . "\n");
83 $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $target['photo'] . '" />' . "\n");
84 $arr['object'] .= '</link></object>' . "\n";
86 $item_id = item_store($arr);
88 q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
89 dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
93 proc_run('php',"include/notifier.php","tag","$item_id");
97 call_hooks('post_local_end', $arr);
99 proc_run('php',"include/notifier.php","like","$post_id");
106 function poke_content(&$a) {
109 notice( t('Permission denied.') . EOL);
116 if(intval($_GET['c'])) {
117 $r = q("select id,name from contact where id = %d and uid = %d limit 1",
122 $name = $r[0]['name'];
128 $base = $a->get_baseurl();
130 $a->page['htmlhead'] .= '<script src="' . $a->get_baseurl(true) . '/library/jquery_ac/friendica.complete.js" ></script>';
131 $a->page['htmlhead'] .= <<< EOT
133 <script>$(document).ready(function() {
135 a = $("#recip").autocomplete({
136 serviceUrl: '$base/acl',
139 onSelect: function(value,data) {
140 $("#recip-complete").val(data);
143 a.setOptions({ params: { type: 'a' }});
152 $verbs = get_poke_verbs();
154 $shortlist = array();
155 foreach($verbs as $k => $v)
156 if($v[1] !== 'NOTRANSLATION')
157 $shortlist[] = array($k,$v[1]);
160 $tpl = get_markup_template('poke_content.tpl');
162 $o = replace_macros($tpl,array(
163 '$title' => t('Poke/Prod'),
164 '$desc' => t('poke, prod or do other things to somebody'),
165 '$clabel' => t('Recipient'),
166 '$choice' => t('Choose what you wish to do to recipient'),
167 '$verbs' => $shortlist,
168 '$prv_desc' => t('Make this post private'),
169 '$submit' => t('Submit'),