3 * @file mod/fsuggest.php
7 use Friendica\Core\ACL;
8 use Friendica\Core\L10n;
9 use Friendica\Core\Worker;
10 use Friendica\Database\DBM;
11 use Friendica\Util\DateTimeFormat;
13 function fsuggest_post(App $a)
23 $contact_id = intval($a->argv[1]);
25 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
29 if (! DBM::is_result($r)) {
30 notice(L10n::t('Contact not found.') . EOL);
35 $new_contact = intval($_POST['suggest']);
37 $hash = random_string();
39 $note = escape_tags(trim($_POST['note']));
42 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
46 if (DBM::is_result($r)) {
47 $x = q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`)
48 VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')",
53 dbesc($r[0]['request']),
54 dbesc($r[0]['photo']),
56 dbesc(DateTimeFormat::utcNow())
58 $r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1",
62 if (DBM::is_result($r)) {
63 $fsuggest_id = $r[0]['id'];
64 q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d",
69 Worker::add(PRIORITY_HIGH, 'Notifier', 'suggest', $fsuggest_id);
72 info(L10n::t('Friend suggestion sent.') . EOL);
77 function fsuggest_content(App $a)
80 notice(L10n::t('Permission denied.') . EOL);
88 $contact_id = intval($a->argv[1]);
91 "SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
95 if (! DBM::is_result($r)) {
96 notice(L10n::t('Contact not found.') . EOL);
101 $o = '<h3>' . L10n::t('Suggest Friends') . '</h3>';
103 $o .= '<div id="fsuggest-desc" >' . L10n::t('Suggest a friend for %s', $contact['name']) . '</div>';
105 $o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >';
107 $o .= ACL::getSuggestContactSelectHTML(
110 ['size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true]
114 $o .= '<div id="fsuggest-submit-wrapper"><input id="fsuggest-submit" type="submit" name="submit" value="' . L10n::t('Submit') . '" /></div>';