3 * @file mod/fsuggest.php
6 use Friendica\Core\L10n;
7 use Friendica\Core\Worker;
8 use Friendica\Database\DBM;
10 function fsuggest_post(App $a) {
20 $contact_id = intval($a->argv[1]);
22 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
26 if (! DBM::is_result($r)) {
27 notice(L10n::t('Contact not found.') . EOL);
32 $new_contact = intval($_POST['suggest']);
34 $hash = random_string();
36 $note = escape_tags(trim($_POST['note']));
39 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
43 if (DBM::is_result($r)) {
45 $x = q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`)
46 VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')",
51 dbesc($r[0]['request']),
52 dbesc($r[0]['photo']),
54 dbesc(datetime_convert())
56 $r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1",
60 if (DBM::is_result($r)) {
61 $fsuggest_id = $r[0]['id'];
62 q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d",
67 Worker::add(PRIORITY_HIGH, 'Notifier', 'suggest', $fsuggest_id);
70 info(L10n::t('Friend suggestion sent.') . EOL);
80 function fsuggest_content(App $a)
82 require_once 'include/acl_selectors.php';
85 notice(L10n::t('Permission denied.') . EOL);
93 $contact_id = intval($a->argv[1]);
96 "SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
100 if (! DBM::is_result($r)) {
101 notice(L10n::t('Contact not found.') . EOL);
106 $o = '<h3>' . t('Suggest Friends') . '</h3>';
108 $o .= '<div id="fsuggest-desc" >' . sprintf(t('Suggest a friend for %s'), $contact['name']) . '</div>';
110 $o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >';
112 $o .= contact_selector(
115 ['size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true],
120 $o .= '<div id="fsuggest-submit-wrapper"><input id="fsuggest-submit" type="submit" name="submit" value="' . t('Submit') . '" /></div>';