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