]> git.mxchange.org Git - friendica.git/blob - mod/crepair.php
don't use load_view_file() except in email templates and install of htconfig - to...
[friendica.git] / mod / crepair.php
1 <?php
2
3 function crepair_post(&$a) {
4         if(! local_user())
5                 return;
6
7         $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
8
9         if($cid) {
10                 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
11                         intval($cid),
12                         intval(local_user())
13                 );
14         }
15
16         if(! count($r))
17                 return;
18
19         $contact = $r[0];
20
21         $nick    = ((x($_POST,'nick')) ? $_POST['nick'] : null);
22         $url     = ((x($_POST,'url')) ? $_POST['url'] : null);
23         $request = ((x($_POST,'request')) ? $_POST['request'] : null);
24         $confirm = ((x($_POST,'confirm')) ? $_POST['confirm'] : null);
25         $notify  = ((x($_POST,'notify')) ? $_POST['notify'] : null);
26         $poll    = ((x($_POST,'poll')) ? $_POST['poll'] : null);
27
28
29         $r = q("UPDATE `contact` SET `nick` = '%s', `url` = '%s', `request` = '%s', `confirm` = '%s', `notify` = '%s', `poll` = '%s'
30                 WHERE `id` = %d AND `uid` = %d LIMIT 1",
31                 dbesc($nick),
32                 dbesc($url),
33                 dbesc($request),
34                 dbesc($confirm),
35                 dbesc($notify),
36                 dbesc($poll),
37                 intval($contact['id']),
38                 local_user()
39         );
40
41         if($r)
42                 notice( t('Contact settings applied.') . EOL);
43         else
44                 notice( t('Contact update failed.') . EOL);
45
46         return;
47 }
48
49
50
51 function crepair_content(&$a) {
52
53         if(! local_user()) {
54                 notice( t('Permission denied.') . EOL);
55                 return;
56         }
57
58         $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
59
60         if($cid) {
61                 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
62                         intval($cid),
63                         intval(local_user())
64                 );
65         }
66
67         if(! count($r)) {
68                 notice( t('Contact not found.') . EOL);
69                 return;
70         }
71
72         $contact = $r[0];
73
74         $msg1 = t('Repair Contact Settings');
75
76         $msg2 = t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact will stop working.');
77         $msg3 = t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
78
79         $o .= '<h2>' . $msg1 . '</h2>';
80
81         $o .= '<div class="error-message">' . $msg2 . EOL . EOL. $msg3 . '</div>';
82
83         $tpl = file_get_contents('view/crepair.tpl');
84         $o .= replace_macros($tpl, array(
85                 '$label_name' => t('Name'),
86                 '$label_nick' => t('Account Nickname'),
87                 '$label_url' => t('Account URL'),
88                 '$label_request' => t('Friend Request URL'),
89                 '$label_confirm' => t('Friend Confirm URL'),
90                 '$label_notify' => t('Notification Endpoint URL'),
91                 '$label_poll' => t('Poll/Feed URL'),
92                 '$contact_name' => $contact['name'],
93                 '$contact_nick' => $contact['nick'],
94                 '$contact_id'   => $contact['id'],
95                 '$contact_url'  => $contact['url'],
96                 '$request'      => $contact['request'],
97                 '$confirm'      => $contact['confirm'],
98                 '$notify'       => $contact['notify'],
99                 '$poll'         => $contact['poll'],
100                 '$lbl_submit'   => t('Submit')
101         ));
102
103         return $o;
104
105 }