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]);
25 if (empty($contact_id)) {
29 $contact = DBA::selectFirst('contact', ['name', 'url', 'request', 'photo'], ['id' => $contact_id, 'uid' => local_user()]);
30 if (!DBA::isResult($contact)) {
31 notice(L10n::t('Contact not found.') . EOL);
35 $note = Strings::escapeHtml(trim(defaults($_POST, 'note', '')));
37 $new_contact = intval($_POST['suggest']);
38 if (empty($new_contact)) {
42 if (!DBA::exists('contact', ['id' => $new_contact])) {
46 $fields = ['uid' => local_user(),'cid' => $contact_id, 'name' => $contact['name'],
47 'url' => $contact['url'], 'request' => $contact['request'],
48 'photo' => $contact['photo'], 'note' => $note, 'created' => DateTimeFormat::utcNow()];
49 DBA::insert('fsuggest', $fields);
51 Worker::add(PRIORITY_HIGH, 'Notifier', 'suggest', DBA::lastInsertId());
53 info(L10n::t('Friend suggestion sent.') . EOL);
56 function fsuggest_content(App $a)
59 notice(L10n::t('Permission denied.') . EOL);
67 $contact_id = intval($a->argv[1]);
69 $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
70 if (! DBA::isResult($contact)) {
71 notice(L10n::t('Contact not found.') . EOL);
75 $o = '<h3>' . L10n::t('Suggest Friends') . '</h3>';
77 $o .= '<div id="fsuggest-desc" >' . L10n::t('Suggest a friend for %s', $contact['name']) . '</div>';
79 $o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >';
81 $o .= ACL::getSuggestContactSelectHTML(
84 ['size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true]
88 $o .= '<div id="fsuggest-submit-wrapper"><input id="fsuggest-submit" type="submit" name="submit" value="' . L10n::t('Submit') . '" /></div>';