3 * @file mod/fsuggest.php
7 use Friendica\Core\ACL;
8 use Friendica\Core\L10n;
9 use Friendica\Core\Worker;
10 use Friendica\Database\DBA;
11 use Friendica\Util\DateTimeFormat;
12 use Friendica\Util\Strings;
14 function fsuggest_post(App $a)
24 $contact_id = intval($a->argv[1]);
26 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
30 if (! DBA::isResult($r)) {
31 notice(L10n::t('Contact not found.') . EOL);
36 $new_contact = intval($_POST['suggest']);
38 $hash = Strings::getRandomHex();
40 $note = Strings::escapeHtml(trim(defaults($_POST, 'note', '')));
43 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
47 if (DBA::isResult($r)) {
48 $x = q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`)
49 VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')",
52 DBA::escape($r[0]['name']),
53 DBA::escape($r[0]['url']),
54 DBA::escape($r[0]['request']),
55 DBA::escape($r[0]['photo']),
57 DBA::escape(DateTimeFormat::utcNow())
59 $r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1",
63 if (DBA::isResult($r)) {
64 $fsuggest_id = $r[0]['id'];
65 q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d",
70 Worker::add(PRIORITY_HIGH, 'Notifier', 'suggest', $fsuggest_id);
73 info(L10n::t('Friend suggestion sent.') . EOL);
78 function fsuggest_content(App $a)
81 notice(L10n::t('Permission denied.') . EOL);
89 $contact_id = intval($a->argv[1]);
92 "SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
96 if (! DBA::isResult($r)) {
97 notice(L10n::t('Contact not found.') . EOL);
102 $o = '<h3>' . L10n::t('Suggest Friends') . '</h3>';
104 $o .= '<div id="fsuggest-desc" >' . L10n::t('Suggest a friend for %s', $contact['name']) . '</div>';
106 $o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >';
108 $o .= ACL::getSuggestContactSelectHTML(
111 ['size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true]
115 $o .= '<div id="fsuggest-submit-wrapper"><input id="fsuggest-submit" type="submit" name="submit" value="' . L10n::t('Submit') . '" /></div>';