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']);
74 $poster = $a->contact;
76 $uri = item_new_uri($a->get_hostname(),$uid);
82 $arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri);
83 $arr['type'] = 'activity';
85 $arr['contact-id'] = $poster['id'];
86 $arr['owner-name'] = $poster['name'];
87 $arr['owner-link'] = $poster['url'];
88 $arr['owner-avatar'] = $poster['thumb'];
89 $arr['author-name'] = $poster['name'];
90 $arr['author-link'] = $poster['url'];
91 $arr['author-avatar'] = $poster['thumb'];
93 $arr['allow_cid'] = $allow_cid;
94 $arr['allow_gid'] = $allow_gid;
95 $arr['deny_cid'] = $deny_cid;
96 $arr['deny_gid'] = $deny_gid;
97 $arr['last-child'] = 1;
99 $arr['verb'] = $activity;
100 $arr['private'] = $private;
101 $arr['object-type'] = ACTIVITY_OBJ_PERSON;
104 $arr['body'] = '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' . ' ' . t($verbs[$verb][0]) . ' ' . '[url=' . $target['url'] . ']' . $target['name'] . '[/url]';
106 $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $target['name'] . '</title><id>' . $a->get_baseurl() . '/contact/' . $target['id'] . '</id>';
107 $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $target['url'] . '" />' . "\n");
109 $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $target['photo'] . '" />' . "\n");
110 $arr['object'] .= '</link></object>' . "\n";
112 $item_id = item_store($arr);
114 //q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
115 // dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
119 proc_run('php',"include/notifier.php","tag","$item_id");
123 call_hooks('post_local_end', $arr);
125 proc_run('php',"include/notifier.php","like","$post_id");
132 function poke_content(&$a) {
135 notice( t('Permission denied.') . EOL);
142 if(intval($_GET['c'])) {
143 $r = q("select id,name from contact where id = %d and uid = %d limit 1",
148 $name = $r[0]['name'];
154 $base = $a->get_baseurl();
156 $a->page['htmlhead'] .= '<script src="' . $a->get_baseurl(true) . '/library/jquery_ac/friendica.complete.js" ></script>';
157 $a->page['htmlhead'] .= <<< EOT
159 <script>$(document).ready(function() {
161 a = $("#poke-recip").autocomplete({
162 serviceUrl: '$base/acl',
165 onSelect: function(value,data) {
166 $("#poke-recip-complete").val(data);
169 a.setOptions({ params: { type: 'a' }});
177 $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'),