4 function fsuggest_post(&$a) {
13 $contact_id = intval($a->argv[1]);
15 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
20 notice( t('Contact not found.') . EOL);
25 $new_contact = intval($_POST['suggest']);
27 $hash = random_string();
29 $note = escape_tags(trim($_POST['note']));
32 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
38 $x = q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`)
39 VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')",
44 dbesc($r[0]['request']),
45 dbesc($r[0]['photo']),
47 dbesc(datetime_convert())
49 $r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1",
54 $fsuggest_id = $r[0]['id'];
55 q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
60 proc_run('php', 'include/notifier.php', 'suggest' , $fsuggest_id);
63 info( t('Friend suggestion sent.') . EOL);
73 function fsuggest_content(&$a) {
75 require_once('include/acl_selectors.php');
78 notice( t('Permission denied.') . EOL);
85 $contact_id = intval($a->argv[1]);
87 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
92 notice( t('Contact not found.') . EOL);
100 $o = '<h3>' . t('Suggest Friends') . '</h3>';
102 $o .= sprintf( t('Suggest a friend for %s'), $contact['name']);
104 $o .= '<form action="fsuggest/' . $contact_id . '" method="post" >';
106 // TODO: selector should have an option to ignore the recipient
107 $o .= contact_select('suggest','suggest-select', $preselect, 4, true);
110 $o .= '<input type="submit" name="submit" value="' . t('Submit') . '" />';