mirror of
https://github.com/php/web-master.git
synced 2026-03-24 15:52:09 +01:00
32 lines
983 B
PHP
32 lines
983 B
PHP
<?php /* vim: set noet ts=4 sw=4 ft=php: : */
|
|
|
|
define('USERGROUP_JSON_URL', 'https://php.ug/api/rest/listtype.json/1');
|
|
|
|
function usergroups_update_infos($root)
|
|
{
|
|
/*
|
|
* Fetch Usergroup-Informations
|
|
*/
|
|
$nameOfUgCacheFile = $root . "/backend/usergroups.json";
|
|
// Get the complete list of usergroups.
|
|
fetch_into_file(USERGROUP_JSON_URL, $nameOfUgCacheFile);
|
|
|
|
$usergroups = json_decode(file_get_contents($nameOfUgCacheFile), true);
|
|
foreach($usergroups['groups'] as $group) {
|
|
|
|
if (! isset($group['icalendar_url'])) {
|
|
continue;
|
|
}
|
|
$url = trim($group['icalendar_url']);
|
|
if ($url === '') {
|
|
continue;
|
|
}
|
|
|
|
$usergroupIcalFileCache = $root . "/backend/events/" . md5($url);
|
|
if (strncmp("webcal://", $url, strlen("webcal://")) == 0) {
|
|
$url = str_replace("webcal://", "http://", $url);
|
|
}
|
|
fetch_into_file($url, $usergroupIcalFileCache);
|
|
}
|
|
}
|