|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* ***************************************************************************** |
|
5
|
|
|
* Contributions to this work were made on behalf of the GÉANT project, a |
|
6
|
|
|
* project that has received funding from the European Union’s Framework |
|
7
|
|
|
* Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus), |
|
8
|
|
|
* Horizon 2020 research and innovation programme under Grant Agreements No. |
|
9
|
|
|
* 691567 (GN4-1) and No. 731122 (GN4-2). |
|
10
|
|
|
* On behalf of the aforementioned projects, GEANT Association is the sole owner |
|
11
|
|
|
* of the copyright in all material which was developed by a member of the GÉANT |
|
12
|
|
|
* project. GÉANT Vereniging (Association) is registered with the Chamber of |
|
13
|
|
|
* Commerce in Amsterdam with registration number 40535155 and operates in the |
|
14
|
|
|
* UK as a branch of GÉANT Vereniging. |
|
15
|
|
|
* |
|
16
|
|
|
* Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. |
|
17
|
|
|
* UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK |
|
18
|
|
|
* |
|
19
|
|
|
* License: see the web/copyright.inc.php file in the file structure or |
|
20
|
|
|
* <base_url>/copyright.php after deploying the software |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* This is the definition of the CAT class |
|
25
|
|
|
* @author Stefan Winter <[email protected]> |
|
26
|
|
|
* @author Tomasz Wolniewicz <[email protected]> |
|
27
|
|
|
* |
|
28
|
|
|
* @package Developer |
|
29
|
|
|
*/ |
|
30
|
|
|
/** |
|
31
|
|
|
* necessary includes |
|
32
|
|
|
*/ |
|
33
|
|
|
|
|
34
|
|
|
namespace core; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Define some variables which need to be globally accessible |
|
38
|
|
|
* and some general purpose methods |
|
39
|
|
|
* |
|
40
|
|
|
* @author Stefan Winter <[email protected]> |
|
41
|
|
|
* @author Tomasz Wolniewicz <[email protected]> |
|
42
|
|
|
* |
|
43
|
|
|
* @package Developer |
|
44
|
|
|
*/ |
|
45
|
|
|
class CAT extends \core\common\Entity |
|
46
|
|
|
{ |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* which version is this? |
|
50
|
|
|
* even if we are unreleased, keep track of internal version-to-be |
|
51
|
|
|
* developers need to set this in code. The user-displayed string |
|
52
|
|
|
* is generated into $CAT_VERSION_STRING and $CAT_COPYRIGHT below |
|
53
|
|
|
*/ |
|
54
|
|
|
public const VERSION_MAJOR = 2; |
|
55
|
|
|
public const VERSION_MINOR = 1; |
|
56
|
|
|
public const VERSION_PATCH = 0; |
|
57
|
|
|
public const VERSION_EXTRA = "alpha1"; |
|
58
|
|
|
private const RELEASE_VERSION = FALSE; |
|
59
|
|
|
private const USER_API_VERSION = 2; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* trying to keep up with the name changes of copyright holder and consortia |
|
63
|
|
|
* updating those on *one* place should change display everywhere! |
|
64
|
|
|
*/ |
|
65
|
|
|
private const COPYRIGHT_HOLDER = "GÉANT Association"; |
|
66
|
|
|
private const COPYRIGHT_CONSORTIA = "the GÉANT Projects funded by EU"; |
|
67
|
|
|
private const COPYRIGHT_MIN_YEAR = 2011; |
|
68
|
|
|
private const COPYRIGHT_MAX_YEAR = 2020; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* This is the user-displayed string; controlled by the four options above |
|
72
|
|
|
* It is generated in the constructor. |
|
73
|
|
|
* |
|
74
|
|
|
* @var string |
|
75
|
|
|
*/ |
|
76
|
|
|
public $catVersionString; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* The entire copyright line, generated in constructor |
|
80
|
|
|
* |
|
81
|
|
|
* @var string |
|
82
|
|
|
*/ |
|
83
|
|
|
public $catCopyright; |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* all known federation, in an array with ISO short name as an index, and localised version of the pretty-print name as value. |
|
87
|
|
|
* The static value is only filled with meaningful content after the first object has been instantiated. That is because it is not |
|
88
|
|
|
* possible to define static properties with function calls like _(). |
|
89
|
|
|
* |
|
90
|
|
|
* @var array of all known federations |
|
91
|
|
|
*/ |
|
92
|
|
|
public $knownFederations; |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* the default database to query in this class. |
|
96
|
|
|
*/ |
|
97
|
|
|
const DB_TYPE = "INST"; |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Constructor sets the language by calling set_lang |
|
101
|
|
|
* and stores language settings in object properties |
|
102
|
|
|
*/ |
|
103
|
|
|
public function __construct() |
|
104
|
|
|
{ |
|
105
|
|
|
parent::__construct(); |
|
106
|
|
|
common\Entity::intoThePotatoes(); |
|
107
|
|
|
|
|
108
|
|
|
$this->catVersionString = sprintf(_("Unreleased %s Git Revision"), "<a href='https://github.com/GEANT/CAT/tree/master/Changes.md'>") . "</a>"; |
|
109
|
|
|
if (CAT::RELEASE_VERSION) { |
|
110
|
|
|
$major = CAT::VERSION_MAJOR; |
|
111
|
|
|
$minor = CAT::VERSION_MINOR; |
|
112
|
|
|
$patch = CAT::VERSION_PATCH; |
|
113
|
|
|
$extra = CAT::VERSION_EXTRA; |
|
114
|
|
|
$temp_version = "CAT-$major.$minor"; |
|
115
|
|
|
$branch = "release_$major" . "_$minor"; |
|
116
|
|
|
if (CAT::VERSION_PATCH != 0) { |
|
117
|
|
|
$temp_version .= ".$patch"; |
|
118
|
|
|
} |
|
119
|
|
|
if (CAT::VERSION_EXTRA != "") { |
|
120
|
|
|
$temp_version .= "-$extra"; |
|
121
|
|
|
} |
|
122
|
|
|
$this->catVersionString = sprintf(_("Release <a href='%s'>%s</a>"), "https://github.com/GEANT/CAT/tree/" . $branch . "/Changes.md", $temp_version); |
|
123
|
|
|
} |
|
124
|
|
|
$product = \config\Master::APPEARANCE['productname']; |
|
125
|
|
|
$minYear = self::COPYRIGHT_MIN_YEAR; |
|
126
|
|
|
$maxYear = self::COPYRIGHT_MAX_YEAR; |
|
127
|
|
|
$holder = self::COPYRIGHT_HOLDER; |
|
128
|
|
|
$consortia = self::COPYRIGHT_CONSORTIA; |
|
129
|
|
|
$this->catCopyright = "$product - " . $this->catVersionString . " © $minYear-$maxYear $holder<br/>on behalf of $consortia; and others <a href='copyright.php'>Full Copyright and Licenses</a>"; |
|
130
|
|
|
|
|
131
|
|
|
|
|
132
|
|
|
/* Federations are created in DB with bootstrapFederation, and listed via listFederations |
|
133
|
|
|
*/ |
|
134
|
|
|
|
|
135
|
|
|
$this->knownFederations = [ |
|
136
|
|
|
'AD' => _("Andorra"), |
|
137
|
|
|
'AT' => _("Austria"), |
|
138
|
|
|
'BE' => _("Belgium"), |
|
139
|
|
|
'BG' => _("Bulgaria"), |
|
140
|
|
|
'CY' => _("Cyprus"), |
|
141
|
|
|
'CZ' => _("Czech Republic"), |
|
142
|
|
|
'DK' => _("Denmark"), |
|
143
|
|
|
'EE' => _("Estonia"), |
|
144
|
|
|
'FI' => _("Finland"), |
|
145
|
|
|
'FR' => _("France"), |
|
146
|
|
|
'DE' => _("Germany"), |
|
147
|
|
|
'GR' => _("Greece"), |
|
148
|
|
|
'HR' => _("Croatia"), |
|
149
|
|
|
'IE' => _("Ireland"), |
|
150
|
|
|
'IS' => _("Iceland"), |
|
151
|
|
|
'IT' => _("Italy"), |
|
152
|
|
|
'HU' => _("Hungary"), |
|
153
|
|
|
'LU' => _("Luxembourg"), |
|
154
|
|
|
'LV' => _("Latvia"), |
|
155
|
|
|
'LT' => _("Lithuania"), |
|
156
|
|
|
'MK' => _("Macedonia"), |
|
157
|
|
|
'RS' => _("Serbia"), |
|
158
|
|
|
'NL' => _("Netherlands"), |
|
159
|
|
|
'NO' => _("Norway"), |
|
160
|
|
|
'PL' => _("Poland"), |
|
161
|
|
|
'PT' => _("Portugal"), |
|
162
|
|
|
'RO' => _("Romania"), |
|
163
|
|
|
'SI' => _("Slovenia"), |
|
164
|
|
|
'ES' => _("Spain"), |
|
165
|
|
|
'SE' => _("Sweden"), |
|
166
|
|
|
'SK' => _("Slovakia"), |
|
167
|
|
|
'CH' => _("Switzerland"), |
|
168
|
|
|
'TR' => _("Turkey"), |
|
169
|
|
|
'UK' => _("United Kingdom"), |
|
170
|
|
|
'TEST' => 'TEST Country', |
|
171
|
|
|
'AU' => _("Australia"), |
|
172
|
|
|
'CA' => _("Canada"), |
|
173
|
|
|
'IL' => _("Israel"), |
|
174
|
|
|
'JP' => _("Japan"), |
|
175
|
|
|
'NZ' => _("New Zealand"), |
|
176
|
|
|
'US' => _("U.S.A."), |
|
177
|
|
|
'BR' => _("Brazil"), |
|
178
|
|
|
'CL' => _("Chile"), |
|
179
|
|
|
'PE' => _("Peru"), |
|
180
|
|
|
'VE' => _("Venezuela"), |
|
181
|
|
|
'DEFAULT' => _("Default"), |
|
182
|
|
|
'AM' => _("Armenia"), |
|
183
|
|
|
'AZ' => _("Azerbaijan"), |
|
184
|
|
|
'BY' => _("Belarus"), |
|
185
|
|
|
'EC' => _("Ecuador"), |
|
186
|
|
|
'HK' => _("Hong Kong"), |
|
187
|
|
|
'KE' => _("Kenya"), |
|
188
|
|
|
'KG' => _("Kyrgyzstan"), |
|
189
|
|
|
'KR' => _("Korea"), |
|
190
|
|
|
'KZ' => _("Kazakhstan"), |
|
191
|
|
|
'MA' => _("Morocco"), |
|
192
|
|
|
'MD' => _("Moldova"), |
|
193
|
|
|
'ME' => _("Montenegro"), |
|
194
|
|
|
'MO' => _("Macau"), |
|
195
|
|
|
'MT' => _("Malta"), |
|
196
|
|
|
'RU' => _("Russia"), |
|
197
|
|
|
'SG' => _("Singapore"), |
|
198
|
|
|
'TH' => _("Thailand"), |
|
199
|
|
|
'TW' => _("Taiwan"), |
|
200
|
|
|
'ZA' => _("South Africa"), |
|
201
|
|
|
'AF' => 'Afghanistan', |
|
202
|
|
|
'AL' => 'Albania', |
|
203
|
|
|
'DZ' => 'Algeria', |
|
204
|
|
|
'AS' => 'American Samoa', |
|
205
|
|
|
'AO' => 'Angola', |
|
206
|
|
|
'AI' => 'Anguilla', |
|
207
|
|
|
'AQ' => 'Antarctica', |
|
208
|
|
|
'AG' => 'Antigua And Barbuda', |
|
209
|
|
|
'AR' => 'Argentina', |
|
210
|
|
|
'AW' => 'Aruba', |
|
211
|
|
|
'BS' => 'Bahamas, The', |
|
212
|
|
|
'BH' => 'Bahrain', |
|
213
|
|
|
'BD' => 'Bangladesh', |
|
214
|
|
|
'BB' => 'Barbados', |
|
215
|
|
|
'BZ' => 'Belize', |
|
216
|
|
|
'BJ' => 'Benin', |
|
217
|
|
|
'BM' => 'Bermuda', |
|
218
|
|
|
'BT' => 'Bhutan', |
|
219
|
|
|
'BO' => 'Bolivia', |
|
220
|
|
|
'BA' => 'Bosnia And Herzegovina', |
|
221
|
|
|
'BW' => 'Botswana', |
|
222
|
|
|
'BV' => 'Bouvet Island', |
|
223
|
|
|
'IO' => 'British Indian Ocean Territory', |
|
224
|
|
|
'BN' => 'Brunei', |
|
225
|
|
|
'BF' => 'Burkina Faso', |
|
226
|
|
|
'MM' => 'Burma', |
|
227
|
|
|
'BI' => 'Burundi', |
|
228
|
|
|
'KH' => 'Cambodia', |
|
229
|
|
|
'CM' => 'Cameroon', |
|
230
|
|
|
'CV' => 'Cape Verde', |
|
231
|
|
|
'KY' => 'Cayman Islands', |
|
232
|
|
|
'CF' => 'Central African Republic', |
|
233
|
|
|
'TD' => 'Chad', |
|
234
|
|
|
'CN' => 'China', |
|
235
|
|
|
'CX' => 'Christmas Island', |
|
236
|
|
|
'CC' => 'Cocos (keeling) Islands', |
|
237
|
|
|
'CO' => 'Colombia', |
|
238
|
|
|
'KM' => 'Comoros', |
|
239
|
|
|
'CG' => 'Congo (brazzaville) ', |
|
240
|
|
|
'CD' => 'Congo (kinshasa)', |
|
241
|
|
|
'CK' => 'Cook Islands', |
|
242
|
|
|
'CR' => 'Costa Rica', |
|
243
|
|
|
'CI' => 'CÔte D’ivoire', |
|
244
|
|
|
'CU' => 'Cuba', |
|
245
|
|
|
'CW' => 'CuraÇao', |
|
246
|
|
|
'DJ' => 'Djibouti', |
|
247
|
|
|
'DM' => 'Dominica', |
|
248
|
|
|
'DO' => 'Dominican Republic', |
|
249
|
|
|
'EG' => 'Egypt', |
|
250
|
|
|
'SV' => 'El Salvador', |
|
251
|
|
|
'GQ' => 'Equatorial Guinea', |
|
252
|
|
|
'ER' => 'Eritrea', |
|
253
|
|
|
'ET' => 'Ethiopia', |
|
254
|
|
|
'FK' => 'Falkland Islands (islas Malvinas)', |
|
255
|
|
|
'FO' => 'Faroe Islands', |
|
256
|
|
|
'FJ' => 'Fiji', |
|
257
|
|
|
'GF' => 'French Guiana', |
|
258
|
|
|
'PF' => 'French Polynesia', |
|
259
|
|
|
'TF' => 'French Southern And Antarctic Lands', |
|
260
|
|
|
'GA' => 'Gabon', |
|
261
|
|
|
'GM' => 'Gambia, The', |
|
262
|
|
|
'GE' => 'Georgia', |
|
263
|
|
|
'GEANT' => 'The GEANT country', |
|
264
|
|
|
'GH' => 'Ghana', |
|
265
|
|
|
'GI' => 'Gibraltar', |
|
266
|
|
|
'GL' => 'Greenland', |
|
267
|
|
|
'GD' => 'Grenada', |
|
268
|
|
|
'GP' => 'Guadeloupe', |
|
269
|
|
|
'GU' => 'Guam', |
|
270
|
|
|
'GT' => 'Guatemala', |
|
271
|
|
|
'GG' => 'Guernsey', |
|
272
|
|
|
'GN' => 'Guinea', |
|
273
|
|
|
'GW' => 'Guinea-bissau', |
|
274
|
|
|
'GY' => 'Guyana', |
|
275
|
|
|
'HT' => 'Haiti', |
|
276
|
|
|
'HM' => 'Heard Island And Mcdonald Islands', |
|
277
|
|
|
'HN' => 'Honduras', |
|
278
|
|
|
'IN' => 'India', |
|
279
|
|
|
'ID' => 'Indonesia', |
|
280
|
|
|
'IR' => 'Iran', |
|
281
|
|
|
'IQ' => 'Iraq', |
|
282
|
|
|
'IM' => 'Isle Of Man', |
|
283
|
|
|
'JM' => 'Jamaica', |
|
284
|
|
|
'JE' => 'Jersey', |
|
285
|
|
|
'JO' => 'Jordan', |
|
286
|
|
|
'KI' => 'Kiribati', |
|
287
|
|
|
'KP' => 'Korea, North', |
|
288
|
|
|
'KW' => 'Kuwait', |
|
289
|
|
|
'LA' => 'Laos', |
|
290
|
|
|
'LB' => 'Lebanon', |
|
291
|
|
|
'LS' => 'Lesotho', |
|
292
|
|
|
'LR' => 'Liberia', |
|
293
|
|
|
'LY' => 'Libya', |
|
294
|
|
|
'LI' => 'Liechtenstein', |
|
295
|
|
|
'MG' => 'Madagascar', |
|
296
|
|
|
'MW' => 'Malawi', |
|
297
|
|
|
'MY' => 'Malaysia', |
|
298
|
|
|
'MV' => 'Maldives', |
|
299
|
|
|
'ML' => 'Mali', |
|
300
|
|
|
'MH' => 'Marshall Islands', |
|
301
|
|
|
'MQ' => 'Martinique', |
|
302
|
|
|
'MR' => 'Mauritania', |
|
303
|
|
|
'MU' => 'Mauritius', |
|
304
|
|
|
'YT' => 'Mayotte', |
|
305
|
|
|
'MX' => 'Mexico', |
|
306
|
|
|
'FM' => 'Micronesia, Federated States Of', |
|
307
|
|
|
'MC' => 'Monaco', |
|
308
|
|
|
'MN' => 'Mongolia', |
|
309
|
|
|
'MS' => 'Montserrat', |
|
310
|
|
|
'MZ' => 'Mozambique', |
|
311
|
|
|
'NA' => 'Namibia', |
|
312
|
|
|
'NR' => 'Nauru', |
|
313
|
|
|
'NP' => 'Nepal', |
|
314
|
|
|
'NC' => 'New Caledonia', |
|
315
|
|
|
'NI' => 'Nicaragua', |
|
316
|
|
|
'NE' => 'Niger', |
|
317
|
|
|
'NG' => 'Nigeria', |
|
318
|
|
|
'NU' => 'Niue', |
|
319
|
|
|
'NF' => 'Norfolk Island', |
|
320
|
|
|
'MP' => 'Northern Mariana Islands', |
|
321
|
|
|
'OM' => 'Oman', |
|
322
|
|
|
'PK' => 'Pakistan', |
|
323
|
|
|
'PW' => 'Palau', |
|
324
|
|
|
'PA' => 'Panama', |
|
325
|
|
|
'PG' => 'Papua New Guinea', |
|
326
|
|
|
'PY' => 'Paraguay', |
|
327
|
|
|
'PH' => 'Philippines', |
|
328
|
|
|
'PN' => 'Pitcairn Islands', |
|
329
|
|
|
'PR' => 'Puerto Rico', |
|
330
|
|
|
'QA' => 'Qatar', |
|
331
|
|
|
'RE' => 'Reunion', |
|
332
|
|
|
'RW' => 'Rwanda', |
|
333
|
|
|
'BL' => 'Saint Barthelemy', |
|
334
|
|
|
'SH' => 'Saint Helena, Ascension, And Tristan Da Cunha', |
|
335
|
|
|
'KN' => 'Saint Kitts And Nevis', |
|
336
|
|
|
'LC' => 'Saint Lucia', |
|
337
|
|
|
'MF' => 'Saint Martin', |
|
338
|
|
|
'PM' => 'Saint Pierre And Miquelon', |
|
339
|
|
|
'VC' => 'Saint Vincent And The Grenadines', |
|
340
|
|
|
'WS' => 'Samoa', |
|
341
|
|
|
'SM' => 'San Marino', |
|
342
|
|
|
'ST' => 'Sao Tome And Principe', |
|
343
|
|
|
'SA' => 'Saudi Arabia', |
|
344
|
|
|
'SN' => 'Senegal', |
|
345
|
|
|
'SC' => 'Seychelles', |
|
346
|
|
|
'SL' => 'Sierra Leone', |
|
347
|
|
|
'SX' => 'Sint Maarten', |
|
348
|
|
|
'SB' => 'Solomon Islands', |
|
349
|
|
|
'SO' => 'Somalia', |
|
350
|
|
|
'GS' => 'South Georgia And South Sandwich Islands', |
|
351
|
|
|
'SS' => 'South Sudan', |
|
352
|
|
|
'LK' => 'Sri Lanka', |
|
353
|
|
|
'SD' => 'Sudan', |
|
354
|
|
|
'SR' => 'Suriname', |
|
355
|
|
|
'SZ' => 'Swaziland', |
|
356
|
|
|
'SY' => 'Syria', |
|
357
|
|
|
'TJ' => 'Tajikistan', |
|
358
|
|
|
'TZ' => 'Tanzania', |
|
359
|
|
|
'TL' => 'Timor-leste', |
|
360
|
|
|
'TG' => 'Togo', |
|
361
|
|
|
'TK' => 'Tokelau', |
|
362
|
|
|
'TO' => 'Tonga', |
|
363
|
|
|
'TT' => 'Trinidad And Tobago', |
|
364
|
|
|
'TN' => 'Tunisia', |
|
365
|
|
|
'TM' => 'Turkmenistan', |
|
366
|
|
|
'TC' => 'Turks And Caicos Islands', |
|
367
|
|
|
'TV' => 'Tuvalu', |
|
368
|
|
|
'UG' => 'Uganda', |
|
369
|
|
|
'UA' => 'Ukraine', |
|
370
|
|
|
'AE' => 'United Arab Emirates', |
|
371
|
|
|
'GB' => 'United Kingdom', |
|
372
|
|
|
'UY' => 'Uruguay', |
|
373
|
|
|
'UZ' => 'Uzbekistan', |
|
374
|
|
|
'VU' => 'Vanuatu', |
|
375
|
|
|
'VA' => 'Vatican City', |
|
376
|
|
|
'VN' => 'Vietnam', |
|
377
|
|
|
'VG' => 'Virgin Islands, British', |
|
378
|
|
|
'VI' => 'Virgin Islands, United States ', |
|
379
|
|
|
'WF' => 'Wallis And Futuna', |
|
380
|
|
|
'EH' => 'Western Sahara', |
|
381
|
|
|
'YE' => 'Yemen', |
|
382
|
|
|
'ZM' => 'Zambia', |
|
383
|
|
|
'ZW' => 'Zimbabwe', |
|
384
|
|
|
]; |
|
385
|
|
|
|
|
386
|
|
|
common\Entity::outOfThePotatoes(); |
|
387
|
|
|
} |
|
388
|
|
|
|
|
389
|
|
|
/** |
|
390
|
|
|
* Calculates the number of IdPs overall in the system |
|
391
|
|
|
* |
|
392
|
|
|
* @param string $level completeness level of IdPs that are to be taken into consideration for counting |
|
393
|
|
|
* @return int |
|
394
|
|
|
*/ |
|
395
|
|
|
public function totalIdPs($level) |
|
396
|
|
|
{ |
|
397
|
|
|
$handle = DBConnection::handle(CAT::DB_TYPE); |
|
398
|
|
|
switch ($level) { |
|
399
|
|
|
case "ALL": |
|
400
|
|
|
$idpcount = $handle->exec("SELECT COUNT(inst_id) AS instcount FROM institution"); |
|
401
|
|
|
break; |
|
402
|
|
|
case "VALIDPROFILE": |
|
403
|
|
|
$idpcount = $handle->exec("SELECT COUNT(DISTINCT institution.inst_id) AS instcount FROM institution,profile WHERE institution.inst_id = profile.inst_id AND profile.sufficient_config = 1"); |
|
404
|
|
|
break; |
|
405
|
|
|
case "PUBLICPROFILE": |
|
406
|
|
|
$idpcount = $handle->exec("SELECT COUNT(DISTINCT institution.inst_id) AS instcount FROM institution,profile WHERE institution.inst_id = profile.inst_id AND profile.showtime = 1"); |
|
407
|
|
|
break; |
|
408
|
|
|
default: |
|
409
|
|
|
return -1; |
|
410
|
|
|
} |
|
411
|
|
|
// SELECTs never return a booleans, always an object |
|
412
|
|
|
$dbresult = mysqli_fetch_object(/** @scrutinizer ignore-type */ $idpcount); |
|
413
|
|
|
return $dbresult->instcount; |
|
414
|
|
|
} |
|
415
|
|
|
|
|
416
|
|
|
/** |
|
417
|
|
|
* Lists all identity providers in the database |
|
418
|
|
|
* adding information required by DiscoJuice. |
|
419
|
|
|
* |
|
420
|
|
|
* @param int $activeOnly if set to non-zero will cause listing of only those institutions which have some valid profiles defined. |
|
421
|
|
|
* @param string $country if set, only list IdPs in a specific country |
|
422
|
|
|
* @return array the list of identity providers |
|
423
|
|
|
* |
|
424
|
|
|
*/ |
|
425
|
|
|
public function listAllIdentityProviders($activeOnly = 0, $country = "") |
|
426
|
|
|
{ |
|
427
|
|
|
common\Entity::intoThePotatoes(); |
|
428
|
|
|
$handle = DBConnection::handle("INST"); |
|
429
|
|
|
$handle->exec("SET SESSION group_concat_max_len=10000"); |
|
430
|
|
|
$query = "SELECT distinct institution.inst_id AS inst_id, institution.country AS country, |
|
431
|
|
|
group_concat(concat_ws('===',institution_option.option_name,LEFT(institution_option.option_value,200), institution_option.option_lang) separator '---') AS options |
|
432
|
|
|
FROM institution "; |
|
433
|
|
|
if ($activeOnly == 1) { |
|
434
|
|
|
$query .= "JOIN v_active_inst ON institution.inst_id = v_active_inst.inst_id "; |
|
435
|
|
|
} |
|
436
|
|
|
$query .= "JOIN institution_option ON institution.inst_id = institution_option.institution_id "; |
|
437
|
|
|
$query .= "WHERE (institution_option.option_name = 'general:instname' |
|
438
|
|
|
OR institution_option.option_name = 'general:geo_coordinates' |
|
439
|
|
|
OR institution_option.option_name = 'general:logo_file') "; |
|
440
|
|
|
|
|
441
|
|
|
$query .= ($country != "" ? "AND institution.country = ? " : ""); |
|
442
|
|
|
|
|
443
|
|
|
$query .= "GROUP BY institution.inst_id ORDER BY inst_id"; |
|
444
|
|
|
|
|
445
|
|
|
$allIDPs = ($country != "" ? $handle->exec($query, "s", $country) : $handle->exec($query)); |
|
446
|
|
|
$returnarray = []; |
|
447
|
|
|
// SELECTs never return a booleans, always an object |
|
448
|
|
|
while ($queryResult = mysqli_fetch_object(/** @scrutinizer ignore-type */ $allIDPs)) { |
|
449
|
|
|
$institutionOptions = explode('---', $queryResult->options); |
|
450
|
|
|
$oneInstitutionResult = []; |
|
451
|
|
|
$geo = []; |
|
452
|
|
|
$names = []; |
|
453
|
|
|
|
|
454
|
|
|
$oneInstitutionResult['entityID'] = $queryResult->inst_id; |
|
455
|
|
|
$oneInstitutionResult['country'] = strtoupper($queryResult->country); |
|
456
|
|
|
foreach ($institutionOptions as $institutionOption) { |
|
457
|
|
|
$opt = explode('===', $institutionOption); |
|
458
|
|
|
switch ($opt[0]) { |
|
459
|
|
|
case 'general:logo_file': |
|
460
|
|
|
$oneInstitutionResult['icon'] = $queryResult->inst_id; |
|
461
|
|
|
break; |
|
462
|
|
|
case 'general:geo_coordinates': |
|
463
|
|
|
$at1 = json_decode($opt[1], true); |
|
464
|
|
|
$geo[] = $at1; |
|
465
|
|
|
break; |
|
466
|
|
|
case 'general:instname': |
|
467
|
|
|
$names[] = [ |
|
468
|
|
|
'lang' => $opt[2], |
|
469
|
|
|
'value' => $opt[1] |
|
470
|
|
|
]; |
|
471
|
|
|
break; |
|
472
|
|
|
default: |
|
473
|
|
|
break; |
|
474
|
|
|
} |
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
$name = _("Unnamed Entity"); |
|
478
|
|
|
if (count($names) != 0) { |
|
479
|
|
|
$langObject = new \core\common\Language(); |
|
480
|
|
|
$name = $langObject->getLocalisedValue($names); |
|
481
|
|
|
} |
|
482
|
|
|
$oneInstitutionResult['title'] = $name; |
|
483
|
|
|
if (count($geo) > 0) { |
|
484
|
|
|
$oneInstitutionResult['geo'] = $geo; |
|
485
|
|
|
} |
|
486
|
|
|
$returnarray[] = $oneInstitutionResult; |
|
487
|
|
|
} |
|
488
|
|
|
common\Entity::outOfThePotatoes(); |
|
489
|
|
|
return $returnarray; |
|
490
|
|
|
} |
|
491
|
|
|
|
|
492
|
|
|
/** |
|
493
|
|
|
* Prepares a list of countries known to the CAT. |
|
494
|
|
|
* |
|
495
|
|
|
* @param int $activeOnly is set and nonzero will cause that only countries with some institutions underneath will be listed |
|
496
|
|
|
* @return array Array indexed by (uppercase) lang codes and sorted according to the current locale |
|
497
|
|
|
*/ |
|
498
|
|
|
public function printCountryList($activeOnly = 0) |
|
499
|
|
|
{ |
|
500
|
|
|
$olddomain = $this->languageInstance->setTextDomain("core"); |
|
501
|
|
|
$handle = DBConnection::handle(CAT::DB_TYPE); |
|
502
|
|
|
$returnArray = []; // in if -> the while might never be executed, so initialise |
|
503
|
|
|
if ($activeOnly) { |
|
504
|
|
|
$federations = $handle->exec("SELECT DISTINCT UPPER(institution.country) AS country FROM institution JOIN profile |
|
505
|
|
|
ON institution.inst_id = profile.inst_id WHERE profile.showtime = 1 ORDER BY country"); |
|
506
|
|
|
// SELECT never returns a boolean, always a mysqli_object |
|
507
|
|
|
while ($activeFederations = mysqli_fetch_object(/** @scrutinizer ignore-type */ $federations)) { |
|
508
|
|
|
$fedIdentifier = $activeFederations->country; // UPPER() has capitalised this for us |
|
509
|
|
|
$returnArray[$fedIdentifier] = isset($this->knownFederations[$fedIdentifier]) ? $this->knownFederations[$fedIdentifier] : $fedIdentifier; |
|
510
|
|
|
} |
|
511
|
|
|
} else { |
|
512
|
|
|
$returnArray = $this->knownFederations; |
|
513
|
|
|
} |
|
514
|
|
|
asort($returnArray, SORT_LOCALE_STRING); |
|
515
|
|
|
$this->languageInstance->setTextDomain($olddomain); |
|
516
|
|
|
return($returnArray); |
|
517
|
|
|
} |
|
518
|
|
|
|
|
519
|
|
|
/** |
|
520
|
|
|
* get additional details about an institution from the EXTERNAL customer DB |
|
521
|
|
|
* (if any; for eduroam, this would be the official eduroam database) |
|
522
|
|
|
* |
|
523
|
|
|
* @param string $externalId the ID of the institution in the external DB |
|
524
|
|
|
* @param string $realm the function can also try to find an inst by its realm in the external DB |
|
525
|
|
|
* @return array a list of institutions, ideally with only one member |
|
526
|
|
|
* @throws \Exception |
|
527
|
|
|
*/ |
|
528
|
|
|
public function getExternalDBEntityDetails($externalId, $realm = NULL) |
|
529
|
|
|
{ |
|
530
|
|
|
$list = []; |
|
531
|
|
|
if (\config\ConfAssistant::CONSORTIUM['name'] == "eduroam" && isset(\config\ConfAssistant::CONSORTIUM['deployment-voodoo']) && \config\ConfAssistant::CONSORTIUM['deployment-voodoo'] == "Operations Team") { // SW: APPROVED |
|
532
|
|
|
$scanforrealm = ""; |
|
533
|
|
|
if ($realm !== NULL) { |
|
534
|
|
|
$scanforrealm = "OR inst_realm LIKE '%$realm%'"; |
|
535
|
|
|
} |
|
536
|
|
|
$externalHandle = DBConnection::handle("EXTERNAL"); |
|
537
|
|
|
$infoList = $externalHandle->exec("SELECT name AS collapsed_name, inst_realm as realmlist, contact AS collapsed_contact, country, type FROM view_active_institution WHERE id_institution = $externalId $scanforrealm"); |
|
538
|
|
|
// split names and contacts into proper pairs |
|
539
|
|
|
// SELECT never returns a boolean, always a mysqli_object |
|
540
|
|
|
while ($externalEntityQuery = mysqli_fetch_object(/** @scrutinizer ignore-type */ $infoList)) { |
|
541
|
|
|
$names = explode('#', $externalEntityQuery->collapsed_name); |
|
542
|
|
|
foreach ($names as $name) { |
|
543
|
|
|
$perlang = explode(': ', $name, 2); |
|
544
|
|
|
$list['names'][$perlang[0]] = $perlang[1]; |
|
545
|
|
|
} |
|
546
|
|
|
$contacts = explode('#', $externalEntityQuery->collapsed_contact); |
|
547
|
|
|
foreach ($contacts as $contact) { |
|
548
|
|
|
$email1 = explode('e: ', $contact); |
|
549
|
|
|
$email2 = explode(',', $email1[1]); |
|
550
|
|
|
$list['admins'][] = ["email" => $email2[0]]; |
|
551
|
|
|
} |
|
552
|
|
|
$list['country'] = strtoupper($externalEntityQuery->country); |
|
553
|
|
|
$list['realmlist'] = $externalEntityQuery->realmlist; |
|
554
|
|
|
switch ($externalEntityQuery->type) { |
|
555
|
|
|
case ExternalEduroamDBData::TYPE_IDP: |
|
556
|
|
|
$list['type'] = IdP::TYPE_IDP; |
|
557
|
|
|
break; |
|
558
|
|
|
case ExternalEduroamDBData::TYPE_SP: |
|
559
|
|
|
$list['type'] = IdP::TYPE_SP; |
|
560
|
|
|
break; |
|
561
|
|
|
case ExternalEduroamDBData::TYPE_IDPSP: |
|
562
|
|
|
$list['type'] = IdP::TYPE_IDPSP; |
|
563
|
|
|
break; |
|
564
|
|
|
default: |
|
565
|
|
|
throw new \Exception("Eduroam DB returned a participant type we do not know."); |
|
566
|
|
|
} |
|
567
|
|
|
} |
|
568
|
|
|
} |
|
569
|
|
|
return $list; |
|
570
|
|
|
} |
|
571
|
|
|
|
|
572
|
|
|
/** |
|
573
|
|
|
* the list of countries as per external DB |
|
574
|
|
|
* @return array the list |
|
575
|
|
|
*/ |
|
576
|
|
|
public function getExternalCountriesList() |
|
577
|
|
|
{ |
|
578
|
|
|
$olddomain = $this->languageInstance->setTextDomain("core"); |
|
579
|
|
|
$returnArray = []; // in if -> the while might never be executed, so initialise |
|
580
|
|
|
if (\config\ConfAssistant::CONSORTIUM['name'] == "eduroam" && isset(\config\ConfAssistant::CONSORTIUM['deployment-voodoo']) && \config\ConfAssistant::CONSORTIUM['deployment-voodoo'] == "Operations Team") { // SW: APPROVED |
|
581
|
|
|
$handle = DBConnection::handle("EXTERNAL"); |
|
582
|
|
|
$timeStart = microtime(true); |
|
583
|
|
|
$federations = $handle->exec("SELECT DISTINCT UPPER(country) AS country FROM view_country_eduroamdb ORDER BY country"); |
|
584
|
|
|
$timeEnd = microtime(true); |
|
585
|
|
|
$timeElapsed = $timeEnd - $timeStart; |
|
586
|
|
|
// the query yielded a mysqli_result because it's a SELECT, this never gives back a boolean |
|
587
|
|
|
while ($eduroamFederations = mysqli_fetch_object(/** @scrutinizer ignore-type */ $federations)) { |
|
588
|
|
|
$fedIdentifier = $eduroamFederations->country; |
|
589
|
|
|
$returnArray[$fedIdentifier] = isset($this->knownFederations[$fedIdentifier]) ? $this->knownFederations[$fedIdentifier] : $fedIdentifier; |
|
590
|
|
|
} |
|
591
|
|
|
asort($returnArray, SORT_LOCALE_STRING); |
|
592
|
|
|
$returnArray['time'] = $timeElapsed; |
|
593
|
|
|
} |
|
594
|
|
|
$this->languageInstance->setTextDomain($olddomain); |
|
595
|
|
|
return($returnArray); |
|
596
|
|
|
} |
|
597
|
|
|
|
|
598
|
|
|
/** |
|
599
|
|
|
* the (HTML) root path of the CAT deployment |
|
600
|
|
|
* |
|
601
|
|
|
* @return string |
|
602
|
|
|
*/ |
|
603
|
|
|
public static function getRootUrlPath() |
|
604
|
|
|
{ |
|
605
|
|
|
return substr(\config\Master::PATHS['cat_base_url'], -1) === '/' ? substr(\config\Master::PATHS['cat_base_url'], 0, -1) : \config\Master::PATHS['cat_base_url']; |
|
606
|
|
|
} |
|
607
|
|
|
|
|
608
|
|
|
/** |
|
609
|
|
|
* takes care of starting our session |
|
610
|
|
|
* |
|
611
|
|
|
* @return void |
|
612
|
|
|
*/ |
|
613
|
|
|
public static function sessionStart() |
|
614
|
|
|
{ |
|
615
|
|
|
if (session_status() != PHP_SESSION_ACTIVE) { |
|
616
|
|
|
session_name("CAT"); |
|
617
|
|
|
session_set_cookie_params(0, "/", $_SERVER['SERVER_NAME'], (isset($_SERVER['HTTPS']) ? TRUE : FALSE)); |
|
618
|
|
|
session_start(); |
|
619
|
|
|
} |
|
620
|
|
|
} |
|
621
|
|
|
|
|
622
|
|
|
/** |
|
623
|
|
|
* determines which external DB to use, and returns an object instance |
|
624
|
|
|
* |
|
625
|
|
|
* @return \core\ExternalEduroamDBData|\core\ExternalNothing |
|
626
|
|
|
*/ |
|
627
|
|
|
public static function determineExternalConnection() |
|
628
|
|
|
{ |
|
629
|
|
|
if (\config\ConfAssistant::CONSORTIUM['name'] == "eduroam" && isset(\config\ConfAssistant::CONSORTIUM['deployment-voodoo']) && \config\ConfAssistant::CONSORTIUM['deployment-voodoo'] == "Operations Team") { |
|
630
|
|
|
return new ExternalEduroamDBData(); |
|
631
|
|
|
} |
|
632
|
|
|
return new ExternalNothing(); |
|
633
|
|
|
} |
|
634
|
|
|
|
|
635
|
|
|
public function getSuperglueZone() |
|
636
|
|
|
{ |
|
637
|
|
|
$externalDB = CAT::determineExternalConnection(); |
|
638
|
|
|
return $externalDB->listExternalRealms(); |
|
639
|
|
|
} |
|
640
|
|
|
} |