3 * @file mod/crepair.php
7 use Friendica\Core\Logger;
8 use Friendica\Core\Protocol;
9 use Friendica\Core\Renderer;
10 use Friendica\Database\DBA;
14 use Friendica\Util\Strings;
16 function crepair_init(App $a)
23 function crepair_post(App $a)
29 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
33 $contact = DBA::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
36 if (!DBA::isResult($contact)) {
40 $name = ($_POST['name'] ?? '') ?: $contact['name'];
41 $nick = $_POST['nick'] ?? '';
42 $url = $_POST['url'] ?? '';
43 $alias = $_POST['alias'] ?? '';
44 $request = $_POST['request'] ?? '';
45 $confirm = $_POST['confirm'] ?? '';
46 $notify = $_POST['notify'] ?? '';
47 $poll = $_POST['poll'] ?? '';
48 $attag = $_POST['attag'] ?? '';
49 $photo = $_POST['photo'] ?? '';
50 $remote_self = $_POST['remote_self'] ?? false;
51 $nurl = Strings::normaliseLink($url);
61 'request' => $request,
62 'confirm' => $confirm,
66 'remote_self' => $remote_self,
68 ['id' => $contact['id'], 'uid' => local_user()]
72 Logger::log('mod-crepair: updating photo from ' . $photo);
74 Model\Contact::updateAvatar($photo, local_user(), $contact['id']);
78 info(DI::l10n()->t('Contact settings applied.') . EOL);
80 notice(DI::l10n()->t('Contact update failed.') . EOL);
86 function crepair_content(App $a)
89 notice(DI::l10n()->t('Permission denied.') . EOL);
93 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
97 $contact = DBA::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
100 if (!DBA::isResult($contact)) {
101 notice(DI::l10n()->t('Contact not found.') . EOL);
105 if (empty(DI::page()['aside'])) {
106 DI::page()['aside'] = '';
109 if (DBA::isResult($contact)) {
110 $a->data['contact'] = $contact;
111 Model\Profile::load($a, "", 0, Model\Contact::getDetailsByURL($contact["url"]));
114 $warning = DI::l10n()->t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
115 $info = DI::l10n()->t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
117 $returnaddr = "contact/$cid";
119 $allow_remote_self = DI::config()->get('system', 'allow_users_remote_self');
121 // Disable remote self for everything except feeds.
122 // There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter
123 // Problem is, you couldn't reply to both networks.
124 if (!in_array($contact['network'], [Protocol::FEED, Protocol::DFRN, Protocol::DIASPORA, Protocol::TWITTER])) {
125 $allow_remote_self = false;
128 if ($contact['network'] == Protocol::FEED) {
129 $remote_self_options = ['0' => DI::l10n()->t('No mirroring'), '1' => DI::l10n()->t('Mirror as forwarded posting'), '2' => DI::l10n()->t('Mirror as my own posting')];
131 $remote_self_options = ['0' => DI::l10n()->t('No mirroring'), '2' => DI::l10n()->t('Mirror as my own posting')];
134 $update_profile = in_array($contact['network'], Protocol::FEDERATED);
136 $tab_str = Module\Contact::getTabsHTML($a, $contact, 6);
138 $tpl = Renderer::getMarkupTemplate('crepair.tpl');
139 $o = Renderer::replaceMacros($tpl, [
140 '$tab_str' => $tab_str,
141 '$warning' => $warning,
143 '$returnaddr' => $returnaddr,
144 '$return' => DI::l10n()->t('Return to contact editor'),
145 '$update_profile' => $update_profile,
146 '$udprofilenow' => DI::l10n()->t('Refetch contact data'),
147 '$contact_id' => $contact['id'],
148 '$lbl_submit' => DI::l10n()->t('Submit'),
149 '$label_remote_self' => DI::l10n()->t('Remote Self'),
150 '$allow_remote_self' => $allow_remote_self,
151 '$remote_self' => ['remote_self',
152 DI::l10n()->t('Mirror postings from this contact'),
153 $contact['remote_self'],
154 DI::l10n()->t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'),
158 '$name' => ['name', DI::l10n()->t('Name') , $contact['name']],
159 '$nick' => ['nick', DI::l10n()->t('Account Nickname'), $contact['nick']],
160 '$attag' => ['attag', DI::l10n()->t('@Tagname - overrides Name/Nickname'), $contact['attag']],
161 '$url' => ['url', DI::l10n()->t('Account URL'), $contact['url']],
162 '$alias' => ['alias', DI::l10n()->t('Account URL Alias'), $contact['alias']],
163 '$request' => ['request', DI::l10n()->t('Friend Request URL'), $contact['request']],
164 'confirm' => ['confirm', DI::l10n()->t('Friend Confirm URL'), $contact['confirm']],
165 'notify' => ['notify', DI::l10n()->t('Notification Endpoint URL'), $contact['notify']],
166 'poll' => ['poll', DI::l10n()->t('Poll/Feed URL'), $contact['poll']],
167 'photo' => ['photo', DI::l10n()->t('New photo from this URL'), ''],