From 35f7ec0ec96e6dd98b5245d1178a03e896a500b5 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Tue, 4 Nov 2014 12:45:37 +0100 Subject: [PATCH] Add more query parameters for generating random data --- plugins/calendar/calendar.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index 13661418..9b815bc8 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -1675,17 +1675,23 @@ class calendar extends rcube_plugin /** * TEMPORARY: generate random event data for testing - * Create events by opening http:///?_task=calendar&_action=randomdata&_num=500 + * Create events by opening http:///?_task=calendar&_action=randomdata&_num=500&_date=2014-08-01&_dev=120 */ public function generate_randomdata() { + @set_time_limit(0); + $num = $_REQUEST['_num'] ? intval($_REQUEST['_num']) : 100; + $date = $_REQUEST['_date'] ?: 'now'; + $dev = $_REQUEST['_dev'] ?: 30; $cats = array_keys($this->driver->list_categories()); $cals = $this->driver->list_calendars(true); $count = 0; while ($count++ < $num) { - $start = round((time() + rand(-2600, 2600) * 1000) / 300) * 300; + $spread = intval($dev) * 86400; // days + $refdate = strtotime($date); + $start = round(($refdate + rand(-$spread, $spread)) / 600) * 600; $duration = round(rand(30, 360) / 30) * 30 * 60; $allday = rand(0,20) > 18; $alarm = rand(-30,12) * 5;