3 function crepair_init(&$a) {
9 if(($a->argc == 2) && intval($a->argv[1])) {
10 $contact_id = intval($a->argv[1]);
11 $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
20 if(! x($a->page,'aside'))
21 $a->page['aside'] = '';
24 $a->data['contact'] = $r[0];
25 $tpl = get_markup_template("vcard-widget.tpl");
26 $vcard_widget .= replace_macros($tpl, array(
27 '$name' => htmlentities($a->data['contact']['name']),
28 '$photo' => $a->data['contact']['photo']
30 $a->page['aside'] .= $vcard_widget;
36 function crepair_post(&$a) {
40 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
43 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
54 $name = ((x($_POST,'name')) ? $_POST['name'] : $contact['name']);
55 $nick = ((x($_POST,'nick')) ? $_POST['nick'] : '');
56 $url = ((x($_POST,'url')) ? $_POST['url'] : '');
57 $request = ((x($_POST,'request')) ? $_POST['request'] : '');
58 $confirm = ((x($_POST,'confirm')) ? $_POST['confirm'] : '');
59 $notify = ((x($_POST,'notify')) ? $_POST['notify'] : '');
60 $poll = ((x($_POST,'poll')) ? $_POST['poll'] : '');
61 $attag = ((x($_POST,'attag')) ? $_POST['attag'] : '');
62 $photo = ((x($_POST,'photo')) ? $_POST['photo'] : '');
63 $remote_self = ((x($_POST,'remote_self')) ? $_POST['remote_self'] : false);
64 $nurl = normalise_link($url);
66 $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
67 WHERE `id` = %d AND `uid` = %d",
78 intval($contact['id']),
83 logger('mod-crepair: updating photo from ' . $photo);
84 require_once("include/Photo.php");
86 $photos = import_profile_photo($photo,local_user(),$contact['id']);
88 $x = q("UPDATE `contact` SET `photo` = '%s',
99 dbesc(datetime_convert()),
100 dbesc(datetime_convert()),
101 dbesc(datetime_convert()),
102 intval($contact['id'])
107 info( t('Contact settings applied.') . EOL);
109 notice( t('Contact update failed.') . EOL);
117 function crepair_content(&$a) {
120 notice( t('Permission denied.') . EOL);
124 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
127 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
134 notice( t('Contact not found.') . EOL);
140 $warning = t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
141 $info = t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
143 $returnaddr = "contacts/$cid";
145 $allow_remote_self = get_config('system','allow_users_remote_self');
147 // Disable remote self for everything except feeds.
148 // There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter
149 // Problem is, you couldn't reply to both networks.
150 if (!in_array($contact['network'], array(NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA)))
151 $allow_remote_self = false;
153 if ($contact['network'] == NETWORK_FEED)
154 $remote_self_options = array('0'=>t('No mirroring'), '1'=>t('Mirror as forwarded posting'), '2'=>t('Mirror as my own posting'));
156 $remote_self_options = array('0'=>t('No mirroring'), '2'=>t('Mirror as my own posting'));
158 $update_profile = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DSPR, NETWORK_OSTATUS));
160 $tpl = get_markup_template('crepair.tpl');
161 $o .= replace_macros($tpl, array(
162 '$title' => t('Repair Contact Settings'),
163 '$warning' => $warning,
165 '$returnaddr' => $returnaddr,
166 '$return' => t('Return to contact editor'),
167 '$update_profile' => update_profile,
168 '$udprofilenow' => t('Refetch contact data'),
169 '$label_name' => t('Name'),
170 '$label_nick' => t('Account Nickname'),
171 '$label_attag' => t('@Tagname - overrides Name/Nickname'),
172 '$label_url' => t('Account URL'),
173 '$label_request' => t('Friend Request URL'),
174 '$label_confirm' => t('Friend Confirm URL'),
175 '$label_notify' => t('Notification Endpoint URL'),
176 '$label_poll' => t('Poll/Feed URL'),
177 '$label_photo' => t('New photo from this URL'),
178 '$label_remote_self' => t('Remote Self'),
179 '$allow_remote_self' => $allow_remote_self,
180 '$remote_self' => array('remote_self',
181 t('Mirror postings from this contact'),
182 $contact['remote_self'],
183 t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'),
186 '$contact_name' => htmlentities($contact['name']),
187 '$contact_nick' => htmlentities($contact['nick']),
188 '$contact_id' => $contact['id'],
189 '$contact_url' => $contact['url'],
190 '$request' => $contact['request'],
191 '$confirm' => $contact['confirm'],
192 '$notify' => $contact['notify'],
193 '$poll' => $contact['poll'],
194 '$contact_attag' => $contact['attag'],
195 '$lbl_submit' => t('Submit')