2 require_once("include/contact_selectors.php");
3 require_once("mod/contacts.php");
5 function crepair_init(&$a) {
11 if(($a->argc == 2) && intval($a->argv[1])) {
12 $contact_id = intval($a->argv[1]);
13 $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
22 if(! x($a->page,'aside'))
23 $a->page['aside'] = '';
26 $a->data['contact'] = $r[0];
28 profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
33 function crepair_post(&$a) {
37 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
40 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
51 $name = ((x($_POST,'name')) ? $_POST['name'] : $contact['name']);
52 $nick = ((x($_POST,'nick')) ? $_POST['nick'] : '');
53 $url = ((x($_POST,'url')) ? $_POST['url'] : '');
54 $request = ((x($_POST,'request')) ? $_POST['request'] : '');
55 $confirm = ((x($_POST,'confirm')) ? $_POST['confirm'] : '');
56 $notify = ((x($_POST,'notify')) ? $_POST['notify'] : '');
57 $poll = ((x($_POST,'poll')) ? $_POST['poll'] : '');
58 $attag = ((x($_POST,'attag')) ? $_POST['attag'] : '');
59 $photo = ((x($_POST,'photo')) ? $_POST['photo'] : '');
60 $remote_self = ((x($_POST,'remote_self')) ? $_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);
81 require_once("include/Photo.php");
83 update_contact_avatar($photo,local_user(),$contact['id']);
87 info( t('Contact settings applied.') . EOL);
89 notice( t('Contact update failed.') . EOL);
97 function crepair_content(&$a) {
100 notice( t('Permission denied.') . EOL);
104 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
107 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
114 notice( t('Contact not found.') . EOL);
120 $warning = t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
121 $info = t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
123 $returnaddr = "contacts/$cid";
125 $allow_remote_self = get_config('system','allow_users_remote_self');
127 // Disable remote self for everything except feeds.
128 // There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter
129 // Problem is, you couldn't reply to both networks.
130 if (!in_array($contact['network'], array(NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA)))
131 $allow_remote_self = false;
133 if ($contact['network'] == NETWORK_FEED)
134 $remote_self_options = array('0'=>t('No mirroring'), '1'=>t('Mirror as forwarded posting'), '2'=>t('Mirror as my own posting'));
136 $remote_self_options = array('0'=>t('No mirroring'), '2'=>t('Mirror as my own posting'));
138 $update_profile = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DSPR, NETWORK_OSTATUS));
140 $tab_str = contacts_tab($a, $contact['id'], 5);
143 $tpl = get_markup_template('crepair.tpl');
144 $o .= replace_macros($tpl, array(
145 //'$title' => t('Repair Contact Settings'),
146 '$tab_str' => $tab_str,
147 '$warning' => $warning,
149 '$returnaddr' => $returnaddr,
150 '$return' => t('Return to contact editor'),
151 '$update_profile' => update_profile,
152 '$udprofilenow' => t('Refetch contact data'),
153 '$label_name' => t('Name'),
154 '$label_nick' => t('Account Nickname'),
155 '$label_attag' => t('@Tagname - overrides Name/Nickname'),
156 '$label_url' => t('Account URL'),
157 '$label_request' => t('Friend Request URL'),
158 '$label_confirm' => t('Friend Confirm URL'),
159 '$label_notify' => t('Notification Endpoint URL'),
160 '$label_poll' => t('Poll/Feed URL'),
161 '$label_photo' => t('New photo from this URL'),
162 '$label_remote_self' => t('Remote Self'),
163 '$allow_remote_self' => $allow_remote_self,
164 '$remote_self' => array('remote_self',
165 t('Mirror postings from this contact'),
166 $contact['remote_self'],
167 t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'),
170 '$contact_name' => htmlentities($contact['name']),
171 '$contact_nick' => htmlentities($contact['nick']),
172 '$contact_id' => $contact['id'],
173 '$contact_url' => $contact['url'],
174 '$request' => $contact['request'],
175 '$confirm' => $contact['confirm'],
176 '$notify' => $contact['notify'],
177 '$poll' => $contact['poll'],
178 '$contact_attag' => $contact['attag'],
179 '$lbl_submit' => t('Submit')