3 * @copyright Copyright (C) 2020, Friendica
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 use Friendica\Content\Widget;
24 use Friendica\Core\Renderer;
25 use Friendica\Database\DBA;
27 use Friendica\Model\Contact;
28 use Friendica\Module\Contact as ModuleContact;
30 function suggest_init(App $a)
37 function suggest_post(App $a)
39 if (!empty($_POST['ignore']) && !empty($_POST['confirm'])) {
40 DBA::insert('gcign', ['uid' => local_user(), 'gcid' => $_POST['ignore']]);
41 notice(DI::l10n()->t('Contact suggestion successfully ignored.'));
44 DI::baseUrl()->redirect('suggest');
47 function suggest_content(App $a)
52 notice(DI::l10n()->t('Permission denied.'));
56 $_SESSION['return_path'] = DI::args()->getCommand();
58 DI::page()['aside'] .= Widget::findPeople();
59 DI::page()['aside'] .= Widget::follow();
62 $contacts = Contact::getSuggestions(local_user());
63 if (!DBA::isResult($contacts)) {
64 $o .= DI::l10n()->t('No suggestions available. If this is a new site, please try again in 24 hours.');
69 if (!empty($_GET['ignore'])) {
70 // <form> can't take arguments in its "action" parameter
71 // so add any arguments as hidden inputs
72 $query = explode_querystring(DI::args()->getQueryString());
74 foreach ($query['args'] as $arg) {
75 if (strpos($arg, 'confirm=') === false) {
76 $arg_parts = explode('=', $arg);
77 $inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]];
81 return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
83 '$message' => DI::l10n()->t('Do you really want to delete this suggestion?'),
84 '$extra_inputs' => $inputs,
85 '$confirm' => DI::l10n()->t('Yes'),
86 '$confirm_url' => $query['base'],
87 '$confirm_name' => 'confirm',
88 '$cancel' => DI::l10n()->t('Cancel'),
93 foreach ($contacts as $contact) {
94 $entries[] = ModuleContact::getContactTemplateVars($contact);
97 $tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
99 $o .= Renderer::replaceMacros($tpl,[
100 '$title' => DI::l10n()->t('Friend Suggestions'),
101 '$contacts' => $entries,