4 use Friendica\Core\Worker;
5 use Friendica\Database\DBM;
7 function fsuggest_post(App $a) {
17 $contact_id = intval($a->argv[1]);
19 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
23 if (! DBM::is_result($r)) {
24 notice( t('Contact not found.') . EOL);
29 $new_contact = intval($_POST['suggest']);
31 $hash = random_string();
33 $note = escape_tags(trim($_POST['note']));
36 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
40 if (DBM::is_result($r)) {
42 $x = q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`)
43 VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')",
48 dbesc($r[0]['request']),
49 dbesc($r[0]['photo']),
51 dbesc(datetime_convert())
53 $r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1",
57 if (DBM::is_result($r)) {
58 $fsuggest_id = $r[0]['id'];
59 q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d",
64 Worker::add(PRIORITY_HIGH, 'notifier', 'suggest', $fsuggest_id);
67 info( t('Friend suggestion sent.') . EOL);
77 function fsuggest_content(App $a)
79 require_once 'include/acl_selectors.php';
82 notice(t('Permission denied.') . EOL);
90 $contact_id = intval($a->argv[1]);
93 "SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
97 if (! DBM::is_result($r)) {
98 notice(t('Contact not found.') . EOL);
103 $o = '<h3>' . t('Suggest Friends') . '</h3>';
105 $o .= '<div id="fsuggest-desc" >' . sprintf(t('Suggest a friend for %s'), $contact['name']) . '</div>';
107 $o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >';
109 $o .= contact_selector(
112 array('size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true),
117 $o .= '<div id="fsuggest-submit-wrapper"><input id="fsuggest-submit" type="submit" name="submit" value="' . t('Submit') . '" /></div>';