4 function fsuggest_post(App &$a) {
14 $contact_id = intval($a->argv[1]);
16 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
20 if (! dbm::is_result($r)) {
21 notice( t('Contact not found.') . EOL);
26 $new_contact = intval($_POST['suggest']);
28 $hash = random_string();
30 $note = escape_tags(trim($_POST['note']));
33 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
37 if (dbm::is_result($r)) {
39 $x = q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`)
40 VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')",
45 dbesc($r[0]['request']),
46 dbesc($r[0]['photo']),
48 dbesc(datetime_convert())
50 $r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1",
54 if (dbm::is_result($r)) {
55 $fsuggest_id = $r[0]['id'];
56 q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d",
61 proc_run(PRIORITY_HIGH, 'include/notifier.php', 'suggest', $fsuggest_id);
64 info( t('Friend suggestion sent.') . EOL);
74 function fsuggest_content(App &$a) {
76 require_once('include/acl_selectors.php');
79 notice( t('Permission denied.') . EOL);
86 $contact_id = intval($a->argv[1]);
88 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
92 if (! dbm::is_result($r)) {
93 notice( t('Contact not found.') . EOL);
98 $o = '<h3>' . t('Suggest Friends') . '</h3>';
100 $o .= '<div id="fsuggest-desc" >' . sprintf( t('Suggest a friend for %s'), $contact['name']) . '</div>';
102 $o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >';
104 $o .= contact_selector('suggest','suggest-select', false,
105 array('size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true));
108 $o .= '<div id="fsuggest-submit-wrapper"><input id="fsuggest-submit" type="submit" name="submit" value="' . t('Submit') . '" /></div>';