Subversion Repositories oidplus

Rev

Rev 328 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 328 Rev 360
Line 22... Line 22...
22
        public function action($actionID, $params) {
22
        public function action($actionID, $params) {
23
                if ($actionID == 'change_ra_data') {
23
                if ($actionID == 'change_ra_data') {
24
                        $email = $params['email'];
24
                        $email = $params['email'];
25
 
25
 
26
                        if (!OIDplus::authUtils()::isRaLoggedIn($email) && !OIDplus::authUtils()::isAdminLoggedIn()) {
26
                        if (!OIDplus::authUtils()::isRaLoggedIn($email) && !OIDplus::authUtils()::isAdminLoggedIn()) {
27
                                throw new OIDplusException('Authentication error. Please log in as the RA to update its data.');
27
                                throw new OIDplusException(_L('Authentication error. Please log in as admin, or as the RA to update its data.'));
28
                        }
28
                        }
29
 
29
 
30
                        $res = OIDplus::db()->query("select * from ###ra where email = ?", array($email));
30
                        $res = OIDplus::db()->query("select * from ###ra where email = ?", array($email));
31
                        if ($res->num_rows() == 0) {
31
                        if ($res->num_rows() == 0) {
32
                                throw new OIDplusException('RA does not exist');
32
                                throw new OIDplusException(_L('RA does not exist'));
33
                        }
33
                        }
34
 
34
 
35
                        OIDplus::logger()->log("[?WARN/!OK]RA($email)?/[?INFO/!OK]A?", "Changed RA '$email' contact data/details");
35
                        OIDplus::logger()->log("[?WARN/!OK]RA($email)?/[?INFO/!OK]A?", "Changed RA '$email' contact data/details");
36
 
36
 
37
                        OIDplus::db()->query("UPDATE ###ra ".
37
                        OIDplus::db()->query("UPDATE ###ra ".
Line 65... Line 65...
65
                                )
65
                                )
66
                        );
66
                        );
67
 
67
 
68
                        return array("status" => 0);
68
                        return array("status" => 0);
69
                } else {
69
                } else {
70
                        throw new OIDplusException("Unknown action ID");
70
                        throw new OIDplusException(_L('Unknown action ID'));
71
                }
71
                }
72
        }
72
        }
73
 
73
 
74
        public function init($html=true) {
74
        public function init($html=true) {
75
                // Nothing
75
                // Nothing
Line 79... Line 79...
79
                if (explode('$',$id)[0] == 'oidplus:edit_ra') {
79
                if (explode('$',$id)[0] == 'oidplus:edit_ra') {
80
                        $handled = true;
80
                        $handled = true;
81
 
81
 
82
                        $ra_email = explode('$',$id)[1];
82
                        $ra_email = explode('$',$id)[1];
83
 
83
 
84
                        $out['title'] = 'Edit RA contact data';
84
                        $out['title'] = _L('Edit RA contact data');
85
                        $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
85
                        $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
86
 
86
 
87
                        if (!OIDplus::authUtils()::isRaLoggedIn($ra_email) && !OIDplus::authUtils()::isAdminLoggedIn()) {
87
                        if (!OIDplus::authUtils()::isRaLoggedIn($ra_email) && !OIDplus::authUtils()::isAdminLoggedIn()) {
88
                                $out['icon'] = 'img/error_big.png';
88
                                $out['icon'] = 'img/error_big.png';
89
                                $out['text'] = '<p>You need to <a '.OIDplus::gui()->link('oidplus:login').'>log in</a> as the requested RA <b>'.htmlentities($ra_email).'</b>.</p>';
89
                                $out['text'] = '<p>'._L('You need to <a %1>log in</a> as the requested RA %2.',OIDplus::gui()->link('oidplus:login'),'<b>'.htmlentities($ra_email).'</b>').'</p>';
90
                                return;
90
                                return;
91
                        }
91
                        }
92
 
92
 
93
                        $out['text'] = '<p>Your email address: <b>'.htmlentities($ra_email).'</b>';
93
                        $out['text'] = '<p>'._L('Your email address: %1','<b>'.htmlentities($ra_email).'</b>').'</p>';
94
 
94
 
95
                        $res = OIDplus::db()->query("select * from ###ra where email = ?", array($ra_email));
95
                        $res = OIDplus::db()->query("select * from ###ra where email = ?", array($ra_email));
96
                        if ($res->num_rows() == 0) {
96
                        if ($res->num_rows() == 0) {
97
                                $out['icon'] = 'img/error_big.png';
97
                                $out['icon'] = 'img/error_big.png';
98
                                $out['text'] = 'RA <b>'.htmlentities($ra_email).'</b> does not exist';
98
                                $out['text'] = _L('RA "%1" does not exist','<b>'.htmlentities($ra_email).'</b>');
99
                                return;
99
                                return;
100
                        }
100
                        }
101
                        $row = $res->fetch_array();
101
                        $row = $res->fetch_array();
102
 
102
 
103
                        if (class_exists('OIDplusPageRaChangeEMail') && OIDplus::config()->getValue('allow_ra_email_change')) {
103
                        if (class_exists('OIDplusPageRaChangeEMail') && OIDplus::config()->getValue('allow_ra_email_change')) {
104
                                $out['text'] .= '<p><a '.OIDplus::gui()->link('oidplus:change_ra_email$'.$ra_email).'>Change email address</a></p>';
104
                                $out['text'] .= '<p><a '.OIDplus::gui()->link('oidplus:change_ra_email$'.$ra_email).'>'._L('Change email address').'</a></p>';
105
                        } else {
105
                        } else {
106
                                $out['text'] .= '<p><abbr title="To change the email address, you need to contact the admin or superior RA. They will need to change the email address and invite you (with your new email address) again.">How to change the email address?</abbr></p>';
106
                                $out['text'] .= '<p><abbr title="'._L('To change the email address, you need to contact the admin or superior RA. They will need to change the email address and invite you (with your new email address) again.').'">'._L('How to change the email address?').'</abbr></p>';
107
                        }
107
                        }
108
 
108
 
109
                        // ---
109
                        // ---
110
 
110
 
111
                        $out['text'] .= '<p>Change basic information (public):</p>
111
                        $out['text'] .= '<p>'._L('Change basic information (public)').':</p>
112
                          <form id="raChangeContactDataForm" onsubmit="return raChangeContactDataFormOnSubmit();">
112
                          <form id="raChangeContactDataForm" onsubmit="return raChangeContactDataFormOnSubmit();">
113
                            <input type="hidden" id="email" value="'.htmlentities($ra_email).'"/>
113
                            <input type="hidden" id="email" value="'.htmlentities($ra_email).'"/>
114
                            <div><label class="padding_label">RA Name:</label><input type="text" id="ra_name" value="'.htmlentities($row['ra_name']).'"/></div>
114
                            <div><label class="padding_label">'._L('RA Name').':</label><input type="text" id="ra_name" value="'.htmlentities($row['ra_name']).'"/></div>
115
                            <div><label class="padding_label">Organization:</label><input type="text" id="organization" value="'.htmlentities($row['organization']).'"/></div>
115
                            <div><label class="padding_label">'._L('Organization').':</label><input type="text" id="organization" value="'.htmlentities($row['organization']).'"/></div>
116
                            <div><label class="padding_label">Office:</label><input type="text" id="office" value="'.htmlentities($row['office']).'"/></div>
116
                            <div><label class="padding_label">'._L('Office').':</label><input type="text" id="office" value="'.htmlentities($row['office']).'"/></div>
117
                            <div><label class="padding_label">Person name:</label><input type="text" id="personal_name" value="'.htmlentities($row['personal_name']).'"/></div>
117
                            <div><label class="padding_label">'._L('Person name').':</label><input type="text" id="personal_name" value="'.htmlentities($row['personal_name']).'"/></div>
118
                            <br>
118
                            <br>
119
                            <div><label class="padding_label">Privacy</label><input type="checkbox" id="privacy" value="" '.($row['privacy'] == 1 ? ' checked' : '').'/> <label for="privacy">Hide postal address and Phone/Fax/Mobile Numbers</label></div>
119
                            <div><label class="padding_label">'._L('Privacy').'</label><input type="checkbox" id="privacy" value="" '.($row['privacy'] == 1 ? ' checked' : '').'/> <label for="privacy">'._L('Hide postal address and Phone/Fax/Mobile Numbers').'</label></div>
120
                            <div><label class="padding_label">Street:</label><input type="text" id="street" value="'.htmlentities($row['street']).'"/></div>
120
                            <div><label class="padding_label">'._L('Street').':</label><input type="text" id="street" value="'.htmlentities($row['street']).'"/></div>
121
                            <div><label class="padding_label">ZIP/Town:</label><input type="text" id="zip_town" value="'.htmlentities($row['zip_town']).'"/></div>
121
                            <div><label class="padding_label">'._L('ZIP/Town').':</label><input type="text" id="zip_town" value="'.htmlentities($row['zip_town']).'"/></div>
122
                            <div><label class="padding_label">Country:</label><input type="text" id="country" value="'.htmlentities($row['country']).'"/></div>
122
                            <div><label class="padding_label">'._L('Country').':</label><input type="text" id="country" value="'.htmlentities($row['country']).'"/></div>
123
                            <div><label class="padding_label">Phone:</label><input type="text" id="phone" value="'.htmlentities($row['phone']).'"/></div>
123
                            <div><label class="padding_label">'._L('Phone').':</label><input type="text" id="phone" value="'.htmlentities($row['phone']).'"/></div>
124
                            <div><label class="padding_label">Mobile:</label><input type="text" id="mobile" value="'.htmlentities($row['mobile']).'"/></div>
124
                            <div><label class="padding_label">'._L('Mobile').':</label><input type="text" id="mobile" value="'.htmlentities($row['mobile']).'"/></div>
125
                            <div><label class="padding_label">Fax:</label><input type="text" id="fax" value="'.htmlentities($row['fax']).'"/></div>
125
                            <div><label class="padding_label">'._L('Fax').':</label><input type="text" id="fax" value="'.htmlentities($row['fax']).'"/></div>
126
                            <br><input type="submit" value="Change data">
126
                            <br><input type="submit" value="'._L('Change data').'">
127
                          </form><br><br>';
127
                          </form><br><br>';
128
 
128
 
129
                        $out['text'] .= '<p><a href="#" onclick="return deleteRa('.js_escape($ra_email).',\'oidplus:system\')">Delete profile</a> (objects stay active)</p>';
129
                        $out['text'] .= '<p><a href="#" onclick="return deleteRa('.js_escape($ra_email).',\'oidplus:system\')">'._L('Delete profile').'</a> '._L('(objects stay active)').'</p>';
130
                }
130
                }
131
        }
131
        }
132
 
132
 
133
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
133
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
134
                if (!$ra_email) return false;
134
                if (!$ra_email) return false;
Line 141... Line 141...
141
                }
141
                }
142
 
142
 
143
                $json[] = array(
143
                $json[] = array(
144
                        'id' => 'oidplus:edit_ra$'.$ra_email,
144
                        'id' => 'oidplus:edit_ra$'.$ra_email,
145
                        'icon' => $tree_icon,
145
                        'icon' => $tree_icon,
146
                        'text' => 'Edit RA contact data'
146
                        'text' => _L('Edit RA contact data')
147
                );
147
                );
148
 
148
 
149
                return true;
149
                return true;
150
        }
150
        }
151
 
151