3 * @file mod/crepair.php
6 use Friendica\Core\Config;
7 use Friendica\Core\L10n;
8 use Friendica\Database\DBM;
9 use Friendica\Model\Contact;
10 use Friendica\Model\Profile;
12 require_once 'mod/contacts.php';
14 function crepair_init(App $a)
21 if (($a->argc == 2) && intval($a->argv[1])) {
22 $contact = dba::selectFirst('contact', [], ['uid' => local_user(), 'id' => $a->argv[1]]);
25 if (!x($a->page, 'aside')) {
26 $a->page['aside'] = '';
29 if (DBM::is_result($contact)) {
30 $a->data['contact'] = $contact;
31 Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
35 function crepair_post(App $a)
41 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
45 $contact = dba::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
48 if (!DBM::is_result($contact)) {
52 $name = defaults($_POST, 'name' , $contact['name']);
53 $nick = defaults($_POST, 'nick' , '');
54 $url = defaults($_POST, 'url' , '');
55 $request = defaults($_POST, 'request' , '');
56 $confirm = defaults($_POST, 'confirm' , '');
57 $notify = defaults($_POST, 'notify' , '');
58 $poll = defaults($_POST, 'poll' , '');
59 $attag = defaults($_POST, 'attag' , '');
60 $photo = defaults($_POST, 'photo' , '');
61 $remote_self = defaults($_POST, 'remote_self', false);
62 $nurl = normalise_link($url);
64 $r = q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `url` = '%s', `nurl` = '%s', `request` = '%s', `confirm` = '%s', `notify` = '%s', `poll` = '%s', `attag` = '%s' , `remote_self` = %d
65 WHERE `id` = %d AND `uid` = %d",
76 intval($contact['id']),
81 logger('mod-crepair: updating photo from ' . $photo);
83 Contact::updateAvatar($photo, local_user(), $contact['id']);
87 info(L10n::t('Contact settings applied.') . EOL);
89 notice(L10n::t('Contact update failed.') . EOL);
95 function crepair_content(App $a)
98 notice(L10n::t('Permission denied.') . EOL);
102 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
106 $contact = dba::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
109 if (!DBM::is_result($contact)) {
110 notice(L10n::t('Contact not found.') . EOL);
114 $warning = 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 = L10n::t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
117 $returnaddr = "contacts/$cid";
119 $allow_remote_self = 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'], [NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA])) {
125 $allow_remote_self = false;
128 if ($contact['network'] == NETWORK_FEED) {
129 $remote_self_options = ['0' => L10n::t('No mirroring'), '1' => L10n::t('Mirror as forwarded posting'), '2' => L10n::t('Mirror as my own posting')];
131 $remote_self_options = ['0' => L10n::t('No mirroring'), '2' => L10n::t('Mirror as my own posting')];
134 $update_profile = in_array($contact['network'], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]);
136 $tab_str = contacts_tab($a, $contact['id'], 5);
138 $tpl = get_markup_template('crepair.tpl');
139 $o = replace_macros($tpl, [
140 '$tab_str' => $tab_str,
141 '$warning' => $warning,
143 '$returnaddr' => $returnaddr,
144 '$return' => L10n::t('Return to contact editor'),
145 '$update_profile' => $update_profile,
146 '$udprofilenow' => L10n::t('Refetch contact data'),
147 '$contact_id' => $contact['id'],
148 '$lbl_submit' => L10n::t('Submit'),
149 '$label_remote_self' => L10n::t('Remote Self'),
150 '$allow_remote_self' => $allow_remote_self,
151 '$remote_self' => ['remote_self',
152 L10n::t('Mirror postings from this contact'),
153 $contact['remote_self'],
154 L10n::t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'),
158 '$name' => ['name', L10n::t('Name') , htmlentities($contact['name'])],
159 '$nick' => ['nick', L10n::t('Account Nickname'), htmlentities($contact['nick'])],
160 '$attag' => ['attag', L10n::t('@Tagname - overrides Name/Nickname'), $contact['attag']],
161 '$url' => ['url', L10n::t('Account URL'), $contact['url']],
162 '$request' => ['request', L10n::t('Friend Request URL'), $contact['request']],
163 'confirm' => ['confirm', L10n::t('Friend Confirm URL'), $contact['confirm']],
164 'notify' => ['notify', L10n::t('Notification Endpoint URL'), $contact['notify']],
165 'poll' => ['poll', L10n::t('Poll/Feed URL'), $contact['poll']],
166 'photo' => ['photo', L10n::t('New photo from this URL'), ''],