]> git.mxchange.org Git - friendica.git/blob - mod/crepair.php
DE update to the strings
[friendica.git] / mod / crepair.php
1 <?php
2 require_once("include/contact_selectors.php");
3 require_once("mod/contacts.php");
4
5 function crepair_init(&$a) {
6         if(! local_user())
7                 return;
8
9         $contact_id = 0;
10
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",
14                         intval(local_user()),
15                         intval($contact_id)
16                 );
17                 if(! count($r)) {
18                         $contact_id = 0;
19                 }
20         }
21
22         if(! x($a->page,'aside'))
23                 $a->page['aside'] = '';
24
25         if($contact_id) {
26                 $a->data['contact'] = $r[0];
27                 $contact = $r[0];
28                 profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
29         }
30 }
31
32
33 function crepair_post(&$a) {
34         if(! local_user())
35                 return;
36
37         $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
38
39         if($cid) {
40                 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
41                         intval($cid),
42                         intval(local_user())
43                 );
44         }
45
46         if(! count($r))
47                 return;
48
49         $contact = $r[0];
50
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);
62
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",
65                 dbesc($name),
66                 dbesc($nick),
67                 dbesc($url),
68                 dbesc($nurl),
69                 dbesc($request),
70                 dbesc($confirm),
71                 dbesc($notify),
72                 dbesc($poll),
73                 dbesc($attag),
74                 intval($remote_self),
75                 intval($contact['id']),
76                 local_user()
77         );
78
79         if($photo) {
80                 logger('mod-crepair: updating photo from ' . $photo);
81                 require_once("include/Photo.php");
82
83                 $photos = import_profile_photo($photo,local_user(),$contact['id']);
84
85                 $x = q("UPDATE `contact` SET `photo` = '%s',
86                         `thumb` = '%s',
87                         `micro` = '%s',
88                         `name-date` = '%s',
89                         `uri-date` = '%s',
90                         `avatar-date` = '%s'
91                         WHERE `id` = %d
92                         ",
93                         dbesc($photos[0]),
94                         dbesc($photos[1]),
95                         dbesc($photos[2]),
96                         dbesc(datetime_convert()),
97                         dbesc(datetime_convert()),
98                         dbesc(datetime_convert()),
99                         intval($contact['id'])
100                 );
101         }
102
103         if($r)
104                 info( t('Contact settings applied.') . EOL);
105         else
106                 notice( t('Contact update failed.') . EOL);
107
108
109         return;
110 }
111
112
113
114 function crepair_content(&$a) {
115
116         if(! local_user()) {
117                 notice( t('Permission denied.') . EOL);
118                 return;
119         }
120
121         $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
122
123         if($cid) {
124                 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
125                         intval($cid),
126                         intval(local_user())
127                 );
128         }
129
130         if(! count($r)) {
131                 notice( t('Contact not found.') . EOL);
132                 return;
133         }
134
135         $contact = $r[0];
136
137         $warning = t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
138         $info = t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
139
140         $returnaddr = "contacts/$cid";
141
142         $allow_remote_self = get_config('system','allow_users_remote_self');
143
144         // Disable remote self for everything except feeds.
145         // There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter
146         // Problem is, you couldn't reply to both networks.
147         if (!in_array($contact['network'], array(NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA)))
148                 $allow_remote_self = false;
149
150         if ($contact['network'] == NETWORK_FEED)
151                 $remote_self_options = array('0'=>t('No mirroring'), '1'=>t('Mirror as forwarded posting'), '2'=>t('Mirror as my own posting'));
152         else
153                 $remote_self_options = array('0'=>t('No mirroring'), '2'=>t('Mirror as my own posting'));
154
155         $update_profile = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DSPR, NETWORK_OSTATUS));
156
157         $tab_str = contacts_tab($a, $contact['id'], 5);
158
159
160         $tpl = get_markup_template('crepair.tpl');
161         $o .= replace_macros($tpl, array(
162                 //'$title'      => t('Repair Contact Settings'),
163                 '$tab_str'      => $tab_str,
164                 '$warning'      => $warning,
165                 '$info'         => $info,
166                 '$returnaddr'   => $returnaddr,
167                 '$return'       => t('Return to contact editor'),
168                 '$update_profile' => update_profile,
169                 '$udprofilenow' => t('Refetch contact data'),
170                 '$label_name' => t('Name'),
171                 '$label_nick' => t('Account Nickname'),
172                 '$label_attag' => t('@Tagname - overrides Name/Nickname'),
173                 '$label_url' => t('Account URL'),
174                 '$label_request' => t('Friend Request URL'),
175                 '$label_confirm' => t('Friend Confirm URL'),
176                 '$label_notify' => t('Notification Endpoint URL'),
177                 '$label_poll' => t('Poll/Feed URL'),
178                 '$label_photo' => t('New photo from this URL'),
179                 '$label_remote_self' => t('Remote Self'),
180                 '$allow_remote_self' => $allow_remote_self,
181                 '$remote_self' => array('remote_self',
182                                         t('Mirror postings from this contact'),
183                                         $contact['remote_self'],
184                                         t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'),
185                                         $remote_self_options
186                                 ),
187                 '$contact_name' => htmlentities($contact['name']),
188                 '$contact_nick' => htmlentities($contact['nick']),
189                 '$contact_id'   => $contact['id'],
190                 '$contact_url'  => $contact['url'],
191                 '$request'      => $contact['request'],
192                 '$confirm'      => $contact['confirm'],
193                 '$notify'       => $contact['notify'],
194                 '$poll'         => $contact['poll'],
195                 '$contact_attag'  => $contact['attag'],
196                 '$lbl_submit'   => t('Submit')
197         ));
198
199         return $o;
200
201 }