4 * @file mod/crepair.php
7 use Friendica\Core\Config;
8 use Friendica\Database\DBM;
9 use Friendica\Model\Contact;
11 require_once 'include/contact_selectors.php';
12 require_once 'mod/contacts.php';
14 function crepair_init(App $a)
22 if (($a->argc == 2) && intval($a->argv[1])) {
23 $contact_id = intval($a->argv[1]);
24 $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
28 if (!DBM::is_result($r)) {
33 if (!x($a->page, 'aside')) {
34 $a->page['aside'] = '';
38 $a->data['contact'] = $r[0];
40 profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
44 function crepair_post(App $a)
50 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
53 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
59 if (!DBM::is_result($r)) {
65 $name = defaults($_POST, 'name' , $contact['name']);
66 $nick = defaults($_POST, 'nick' , '');
67 $url = defaults($_POST, 'url' , '');
68 $request = defaults($_POST, 'request' , '');
69 $confirm = defaults($_POST, 'confirm' , '');
70 $notify = defaults($_POST, 'notify' , '');
71 $poll = defaults($_POST, 'poll' , '');
72 $attag = defaults($_POST, 'attag' , '');
73 $photo = defaults($_POST, 'photo' , '');
74 $remote_self = defaults($_POST, 'remote_self', false);
75 $nurl = normalise_link($url);
77 $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
78 WHERE `id` = %d AND `uid` = %d",
89 intval($contact['id']),
94 logger('mod-crepair: updating photo from ' . $photo);
96 Contact::updateAvatar($photo, local_user(), $contact['id']);
100 info(t('Contact settings applied.') . EOL);
102 notice(t('Contact update failed.') . EOL);
108 function crepair_content(App $a)
111 notice(t('Permission denied.') . EOL);
115 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
118 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
124 if (!DBM::is_result($r)) {
125 notice(t('Contact not found.') . EOL);
131 $warning = t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
132 $info = t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
134 $returnaddr = "contacts/$cid";
136 $allow_remote_self = Config::get('system', 'allow_users_remote_self');
138 // Disable remote self for everything except feeds.
139 // There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter
140 // Problem is, you couldn't reply to both networks.
141 if (!in_array($contact['network'], array(NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA))) {
142 $allow_remote_self = false;
145 if ($contact['network'] == NETWORK_FEED) {
146 $remote_self_options = array('0' => t('No mirroring'), '1' => t('Mirror as forwarded posting'), '2' => t('Mirror as my own posting'));
148 $remote_self_options = array('0' => t('No mirroring'), '2' => t('Mirror as my own posting'));
151 $update_profile = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS));
153 $tab_str = contacts_tab($a, $contact['id'], 5);
155 $tpl = get_markup_template('crepair.tpl');
156 $o = replace_macros($tpl, array(
157 '$tab_str' => $tab_str,
158 '$warning' => $warning,
160 '$returnaddr' => $returnaddr,
161 '$return' => t('Return to contact editor'),
162 '$update_profile' => $update_profile,
163 '$udprofilenow' => t('Refetch contact data'),
164 '$contact_id' => $contact['id'],
165 '$lbl_submit' => t('Submit'),
166 '$label_remote_self' => t('Remote Self'),
167 '$allow_remote_self' => $allow_remote_self,
168 '$remote_self' => array('remote_self',
169 t('Mirror postings from this contact'),
170 $contact['remote_self'],
171 t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'),
175 '$name' => array('name', t('Name') , htmlentities($contact['name'])),
176 '$nick' => array('nick', t('Account Nickname'), htmlentities($contact['nick'])),
177 '$attag' => array('attag', t('@Tagname - overrides Name/Nickname'), $contact['attag']),
178 '$url' => array('url', t('Account URL'), $contact['url']),
179 '$request' => array('request', t('Friend Request URL'), $contact['request']),
180 'confirm' => array('confirm', t('Friend Confirm URL'), $contact['confirm']),
181 'notify' => array('notify', t('Notification Endpoint URL'), $contact['notify']),
182 'poll' => array('poll', t('Poll/Feed URL'), $contact['poll']),
183 'photo' => array('photo', t('New photo from this URL'), ''),