2 require_once("include/contact_selectors.php");
3 require_once("mod/contacts.php");
5 function crepair_init(App &$a) {
12 if(($a->argc == 2) && intval($a->argv[1])) {
13 $contact_id = intval($a->argv[1]);
14 $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
18 if (! dbm::is_result($r)) {
23 if(! x($a->page,'aside'))
24 $a->page['aside'] = '';
27 $a->data['contact'] = $r[0];
29 profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
34 function crepair_post(App &$a) {
39 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
42 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
48 if (! dbm::is_result($r)) {
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 update_contact_avatar($photo,local_user(),$contact['id']);
90 info( t('Contact settings applied.') . EOL);
92 notice( t('Contact update failed.') . EOL);
100 function crepair_content(App &$a) {
102 if (! local_user()) {
103 notice( t('Permission denied.') . EOL);
107 $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
110 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
116 if (! dbm::is_result($r)) {
117 notice( t('Contact not found.') . EOL);
123 $warning = t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
124 $info = t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
126 $returnaddr = "contacts/$cid";
128 $allow_remote_self = get_config('system','allow_users_remote_self');
130 // Disable remote self for everything except feeds.
131 // There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter
132 // Problem is, you couldn't reply to both networks.
133 if (!in_array($contact['network'], array(NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA)))
134 $allow_remote_self = false;
136 if ($contact['network'] == NETWORK_FEED)
137 $remote_self_options = array('0'=>t('No mirroring'), '1'=>t('Mirror as forwarded posting'), '2'=>t('Mirror as my own posting'));
139 $remote_self_options = array('0'=>t('No mirroring'), '2'=>t('Mirror as my own posting'));
141 $update_profile = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DSPR, NETWORK_OSTATUS));
143 $tab_str = contacts_tab($a, $contact['id'], 5);
146 $tpl = get_markup_template('crepair.tpl');
147 $o .= replace_macros($tpl, array(
148 //'$title' => t('Repair Contact Settings'),
149 '$tab_str' => $tab_str,
150 '$warning' => $warning,
152 '$returnaddr' => $returnaddr,
153 '$return' => t('Return to contact editor'),
154 '$update_profile' => update_profile,
155 '$udprofilenow' => t('Refetch contact data'),
156 '$contact_id' => $contact['id'],
157 '$lbl_submit' => t('Submit'),
159 '$label_remote_self' => t('Remote Self'),
160 '$allow_remote_self' => $allow_remote_self,
161 '$remote_self' => array('remote_self',
162 t('Mirror postings from this contact'),
163 $contact['remote_self'],
164 t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'),
168 '$name' => array('name', t('Name') , htmlentities($contact['name'])),
169 '$nick' => array('nick', t('Account Nickname'), htmlentities($contact['nick'])),
170 '$attag' => array('attag', t('@Tagname - overrides Name/Nickname'), $contact['attag']),
171 '$url' => array('url', t('Account URL'), $contact['url']),
172 '$request' => array('request', t('Friend Request URL'), $contact['request']),
173 'confirm' => array('confirm', t('Friend Confirm URL'), $contact['confirm']),
174 'notify' => array('notify', t('Notification Endpoint URL'), $contact['notify']),
175 'poll' => array('poll', t('Poll/Feed URL'), $contact['poll']),
176 'photo' => array('photo', t('New photo from this URL'), ''),