Rev 104 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
104 | daniel-mar | 1 | <?php |
2 | |||
3 | /* |
||
4 | * OIDplus 2.0 |
||
5 | * Copyright 2019 Daniel Marschall, ViaThinkSoft |
||
6 | * |
||
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
8 | * you may not use this file except in compliance with the License. |
||
9 | * You may obtain a copy of the License at |
||
10 | * |
||
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
12 | * |
||
13 | * Unless required by applicable law or agreed to in writing, software |
||
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
16 | * See the License for the specific language governing permissions and |
||
17 | * limitations under the License. |
||
18 | */ |
||
19 | |||
20 | class OIDplusPagePublicRaInfo extends OIDplusPagePlugin { |
||
21 | public function type() { |
||
22 | return 'public'; |
||
23 | } |
||
24 | |||
25 | public function priority() { |
||
26 | return 93; |
||
27 | } |
||
28 | |||
29 | public function action(&$handled) { |
||
30 | } |
||
31 | |||
32 | public function init($html=true) { |
||
33 | } |
||
34 | |||
35 | public function cfgSetValue($name, $value) { |
||
36 | } |
||
37 | |||
38 | public function gui($id, &$out, &$handled) { |
||
39 | if (explode('$',$id)[0] == 'oidplus:rainfo') { |
||
40 | $handled = true; |
||
41 | |||
42 | $ra_email = explode('$',$id)[1]; |
||
43 | $ra_email = str_replace('&', '@', $ra_email); |
||
44 | |||
45 | $out['title'] = 'Registration Authority Information'; // TODO: email addresse reinschreiben? aber wie vor anti spam schützen? |
||
46 | $out['icon'] = 'plugins/publicPages/'.basename(__DIR__).'/rainfo_big.png'; |
||
47 | |||
48 | if (empty($ra_email)) { |
||
49 | $out['text'] = '<p>Following object roots have an undefined Registration Authority:</p>'; |
||
50 | } else { |
||
51 | $out['text'] = $this->showRAInfo($ra_email); |
||
52 | } |
||
53 | |||
54 | $out['text'] .= '<br><br>'; |
||
55 | |||
56 | foreach (OIDplusObject::getRaRoots($ra_email) as $loc_root) { |
||
57 | $ico = $loc_root->getIcon(); |
||
58 | $icon = !is_null($ico) ? $ico : 'plugins/publicPages/'.basename(__DIR__).'/treeicon_link.png'; |
||
59 | $out['text'] .= '<p><a href="?goto='.$loc_root->nodeId().'"><img src="'.$icon.'"> Jump to RA root '.$loc_root->objectTypeTitleShort().' '.$loc_root->crudShowId(OIDplusObject::parse($loc_root::root())).'</a></p>'; |
||
60 | } |
||
61 | |||
62 | if (OIDplus::authUtils()::isRALoggedIn($ra_email)) { |
||
63 | $out['text'] .= '<br><p><a href="?goto=oidplus:edit_ra$'.urlencode($ra_email).'">Edit contact info</a></p>'; |
||
64 | } |
||
65 | |||
66 | if (!empty($ra_email) && OIDplus::authUtils()::isAdminLoggedIn()) { |
||
67 | if (class_exists("OIDplusPageAdminListRAs")) { |
||
68 | $out['text'] .= '<br><p><a href="#" onclick="return deleteRa('.js_escape($ra_email).','.js_escape('oidplus:list_ra').')">Delete this RA</a></p>'; |
||
69 | } else { |
||
70 | $out['text'] .= '<br><p><a href="#" onclick="return deleteRa('.js_escape($ra_email).','.js_escape('oidplus:system').')">Delete this RA</a></p>'; |
||
71 | } |
||
72 | } |
||
73 | } |
||
74 | } |
||
75 | |||
106 | daniel-mar | 76 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
104 | daniel-mar | 77 | return false; |
78 | } |
||
79 | |||
80 | public static function showRAInfo($email) { |
||
81 | $out = ''; |
||
82 | |||
83 | if (empty($email)) { |
||
84 | $out = '<p>The superior RA did not define a RA for this OID.</p>'; |
||
85 | return $out; |
||
86 | } |
||
87 | |||
88 | $res = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."ra where email = '".OIDplus::db()->real_escape_string($email)."'"); |
||
89 | if (OIDplus::db()->num_rows($res) === 0) { |
||
90 | $out = '<p>The RA <a href="mailto:'.htmlentities($email).'">'.htmlentities($email).'</a> is not registered in the database.</p>'; |
||
91 | |||
92 | } else { |
||
93 | $row = OIDplus::db()->fetch_array($res); |
||
94 | $out = '<b>'.htmlentities($row['ra_name']).'</b><br>'; |
||
95 | $out .= 'E-Mail: <a href="mailto:'.htmlentities($email).'">'.htmlentities($email).'</a><br>'; |
||
96 | if (trim($row['personal_name']) !== '') $out .= htmlentities($row['personal_name']).'<br>'; |
||
97 | if (trim($row['organization']) !== '') $out .= htmlentities($row['organization']).'<br>'; |
||
98 | if (trim($row['office']) !== '') $out .= htmlentities($row['office']).'<br>'; |
||
99 | if ($row['privacy']) { |
||
100 | // TODO: meldung nur anzeigen, wenn benutzer überhaupt straße, adresse etc hat |
||
101 | // TODO: aber der admin soll es sehen, und der user selbst (mit anmerkung, dass es privat ist) |
||
102 | $out .= '<p>The RA does not want to publish their personal information.</p>'; |
||
103 | } else { |
||
104 | if (trim($row['street']) !== '') $out .= htmlentities($row['street']).'<br>'; |
||
105 | if (trim($row['zip_town']) !== '') $out .= htmlentities($row['zip_town']).'<br>'; |
||
106 | if (trim($row['country']) !== '') $out .= htmlentities($row['country']).'<br>'; |
||
107 | $out .= '<br>'; |
||
108 | if (trim($row['phone']) !== '') $out .= htmlentities($row['phone']).'<br>'; |
||
109 | if (trim($row['fax']) !== '') $out .= htmlentities($row['fax']).'<br>'; |
||
110 | if (trim($row['mobile']) !== '') $out .= htmlentities($row['mobile']).'<br>'; |
||
111 | $out .= '<br>'; |
||
112 | } |
||
113 | } |
||
114 | |||
115 | return trim_br($out); |
||
116 | } |
||
117 | } |
||
118 | |||
119 | OIDplus::registerPagePlugin(new OIDplusPagePublicRaInfo()); |