com web/master: Fetch usegroups listings and event feed: scripts/update-backend scripts/usergroups_udate_infos
| From: | Hannes Magnusson | Date: | Wed, 26 Mar 2014 05:08:06 +0000 |
| Subject: | com web/master: Fetch usegroups listings and event feed: scripts/update-backend scripts/usergroups_udate_infos | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-18597@lists.php.net to get a copy of this message | ||
Commit: f82d11721e41493f1d7f3ae63dde9da6c755410f
Author: Andreas Heigl <andreas@heigl.org> Tue, 25 Mar 2014 22:08:06 -0700
Committer: Hannes Magnusson <bjori@mongodb.com> Tue, 25 Mar 2014 22:08:06 -0700
Parents: 0d0df72c143e095c8b28f056fc2876b8135d4c3b
Branches: master
Link: http://git.php.net/?p=web/master.git;a=commitdiff;h=f82d11721e41493f1d7f3ae63dde9da6c755410f
Log:
Fetch usegroups listings and event feed
Changed paths:
M scripts/update-backend
A scripts/usergroups_udate_infos
Diff:
diff --git a/scripts/update-backend b/scripts/update-backend
index 3f984de..b2e989e 100755
--- a/scripts/update-backend
+++ b/scripts/update-backend
@@ -55,6 +55,9 @@ pregen_flickr(
100
);
+include 'usergroups_update_infos';
+usergroups_update_infos($root);
+
// Fetch data into a temporary file first, and then
// overwrite the real file with the new data
function fetch_into_file($url, $file)
diff --git a/scripts/usergroups_udate_infos b/scripts/usergroups_udate_infos
new file mode 100644
index 0000000..c7af49a
--- /dev/null
+++ b/scripts/usergroups_udate_infos
@@ -0,0 +1,27 @@
+<?php /* vim: set noet ts=4 sw=4 ft=php: : */
+
+define('USERGROUP_JSON_URL', 'http://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 = $group['icalendar_url'];
+ $usergroupIcalFileCache = $root . "/backend/events/" . md5($url);
+ if (strncmp("webcal://", $url, strlen("webcal://")) == 0) {
+ $url = str_replace("webcal://", "http://", $url);
+ }
+ fetch_into_file($url, $usergroupIcalFileCache);
+ }
+}
\ No newline at end of file