3 * @file mod/crepair.php
6 use Friendica\Core\Config;
7 use Friendica\Database\DBM;
8 use Friendica\Model\Contact;
9 use Friendica\Model\Profile;
11 require_once 'mod/contacts.php';
13 function crepair_init(App $a)
20 if (($a->argc == 2) && intval($a->argv[1])) {
21 $contact = dba::selectFirst('contact', [], ['uid' => local_user(), 'id' => $a->argv[1]]);
24 if (!x($a->page, 'aside')) {
25 $a->page['aside'] = '';
28 if (DBM::is_result($contact)) {
29 $a->data['contact'] = $contact;
30 Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
34 function crepair_post(App $a)
40 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
44 $contact = dba::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
47 if (!DBM::is_result($contact)) {
51 $name = defaults($_POST, 'name' , $contact['name']);
52 $nick = defaults($_POST, 'nick' , '');
53 $url = defaults($_POST, 'url' , '');
54 $request = defaults($_POST, 'request' , '');
55 $confirm = defaults($_POST, 'confirm' , '');
56 $notify = defaults($_POST, 'notify' , '');
57 $poll = defaults($_POST, 'poll' , '');
58 $attag = defaults($_POST, 'attag' , '');
59 $photo = defaults($_POST, 'photo' , '');
60 $remote_self = defaults($_POST, 'remote_self', false);
61 $nurl = normalise_link($url);
63 $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
64 WHERE `id` = %d AND `uid` = %d",
75 intval($contact['id']),
80 logger('mod-crepair: updating photo from ' . $photo);
82 Contact::updateAvatar($photo, local_user(), $contact['id']);
86 info(t('Contact settings applied.') . EOL);
88 notice(t('Contact update failed.') . EOL);
94 function crepair_content(App $a)
97 notice(t('Permission denied.') . EOL);
101 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
105 $contact = dba::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
108 if (!DBM::is_result($contact)) {
109 notice(t('Contact not found.') . EOL);
113 $warning = t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
114 $info = t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
116 $returnaddr = "contacts/$cid";
118 $allow_remote_self = Config::get('system', 'allow_users_remote_self');
120 // Disable remote self for everything except feeds.
121 // There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter
122 // Problem is, you couldn't reply to both networks.
123 if (!in_array($contact['network'], [NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA])) {
124 $allow_remote_self = false;
127 if ($contact['network'] == NETWORK_FEED) {
128 $remote_self_options = ['0' => t('No mirroring'), '1' => t('Mirror as forwarded posting'), '2' => t('Mirror as my own posting')];
130 $remote_self_options = ['0' => t('No mirroring'), '2' => t('Mirror as my own posting')];
133 $update_profile = in_array($contact['network'], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]);
135 $tab_str = contacts_tab($a, $contact['id'], 5);
137 $tpl = get_markup_template('crepair.tpl');
138 $o = replace_macros($tpl, [
139 '$tab_str' => $tab_str,
140 '$warning' => $warning,
142 '$returnaddr' => $returnaddr,
143 '$return' => t('Return to contact editor'),
144 '$update_profile' => $update_profile,
145 '$udprofilenow' => t('Refetch contact data'),
146 '$contact_id' => $contact['id'],
147 '$lbl_submit' => t('Submit'),
148 '$label_remote_self' => t('Remote Self'),
149 '$allow_remote_self' => $allow_remote_self,
150 '$remote_self' => ['remote_self',
151 t('Mirror postings from this contact'),
152 $contact['remote_self'],
153 t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'),
157 '$name' => ['name', t('Name') , htmlentities($contact['name'])],
158 '$nick' => ['nick', t('Account Nickname'), htmlentities($contact['nick'])],
159 '$attag' => ['attag', t('@Tagname - overrides Name/Nickname'), $contact['attag']],
160 '$url' => ['url', t('Account URL'), $contact['url']],
161 '$request' => ['request', t('Friend Request URL'), $contact['request']],
162 'confirm' => ['confirm', t('Friend Confirm URL'), $contact['confirm']],
163 'notify' => ['notify', t('Notification Endpoint URL'), $contact['notify']],
164 'poll' => ['poll', t('Poll/Feed URL'), $contact['poll']],
165 'photo' => ['photo', t('New photo from this URL'), ''],