4 * @file mod/crepair.php
7 use Friendica\Core\Config;
8 use Friendica\Database\DBM;
9 use Friendica\Model\Contact;
11 require_once 'mod/contacts.php';
13 function crepair_init(App $a)
21 if (($a->argc == 2) && intval($a->argv[1])) {
22 $contact_id = intval($a->argv[1]);
23 $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
27 if (!DBM::is_result($r)) {
32 if (!x($a->page, 'aside')) {
33 $a->page['aside'] = '';
37 $a->data['contact'] = $r[0];
39 profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
43 function crepair_post(App $a)
49 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
52 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
58 if (!DBM::is_result($r)) {
64 $name = defaults($_POST, 'name' , $contact['name']);
65 $nick = defaults($_POST, 'nick' , '');
66 $url = defaults($_POST, 'url' , '');
67 $request = defaults($_POST, 'request' , '');
68 $confirm = defaults($_POST, 'confirm' , '');
69 $notify = defaults($_POST, 'notify' , '');
70 $poll = defaults($_POST, 'poll' , '');
71 $attag = defaults($_POST, 'attag' , '');
72 $photo = defaults($_POST, 'photo' , '');
73 $remote_self = defaults($_POST, 'remote_self', false);
74 $nurl = normalise_link($url);
76 $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
77 WHERE `id` = %d AND `uid` = %d",
88 intval($contact['id']),
93 logger('mod-crepair: updating photo from ' . $photo);
95 Contact::updateAvatar($photo, local_user(), $contact['id']);
99 info(t('Contact settings applied.') . EOL);
101 notice(t('Contact update failed.') . EOL);
107 function crepair_content(App $a)
110 notice(t('Permission denied.') . EOL);
114 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
117 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
123 if (!DBM::is_result($r)) {
124 notice(t('Contact not found.') . EOL);
130 $warning = t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
131 $info = t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
133 $returnaddr = "contacts/$cid";
135 $allow_remote_self = Config::get('system', 'allow_users_remote_self');
137 // Disable remote self for everything except feeds.
138 // There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter
139 // Problem is, you couldn't reply to both networks.
140 if (!in_array($contact['network'], array(NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA))) {
141 $allow_remote_self = false;
144 if ($contact['network'] == NETWORK_FEED) {
145 $remote_self_options = array('0' => t('No mirroring'), '1' => t('Mirror as forwarded posting'), '2' => t('Mirror as my own posting'));
147 $remote_self_options = array('0' => t('No mirroring'), '2' => t('Mirror as my own posting'));
150 $update_profile = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS));
152 $tab_str = contacts_tab($a, $contact['id'], 5);
154 $tpl = get_markup_template('crepair.tpl');
155 $o = replace_macros($tpl, array(
156 '$tab_str' => $tab_str,
157 '$warning' => $warning,
159 '$returnaddr' => $returnaddr,
160 '$return' => t('Return to contact editor'),
161 '$update_profile' => $update_profile,
162 '$udprofilenow' => t('Refetch contact data'),
163 '$contact_id' => $contact['id'],
164 '$lbl_submit' => t('Submit'),
165 '$label_remote_self' => t('Remote Self'),
166 '$allow_remote_self' => $allow_remote_self,
167 '$remote_self' => array('remote_self',
168 t('Mirror postings from this contact'),
169 $contact['remote_self'],
170 t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'),
174 '$name' => array('name', t('Name') , htmlentities($contact['name'])),
175 '$nick' => array('nick', t('Account Nickname'), htmlentities($contact['nick'])),
176 '$attag' => array('attag', t('@Tagname - overrides Name/Nickname'), $contact['attag']),
177 '$url' => array('url', t('Account URL'), $contact['url']),
178 '$request' => array('request', t('Friend Request URL'), $contact['request']),
179 'confirm' => array('confirm', t('Friend Confirm URL'), $contact['confirm']),
180 'notify' => array('notify', t('Notification Endpoint URL'), $contact['notify']),
181 'poll' => array('poll', t('Poll/Feed URL'), $contact['poll']),
182 'photo' => array('photo', t('New photo from this URL'), ''),