You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by jf...@apache.org on 2012/06/20 16:43:30 UTC
svn commit: r1352132 - /incubator/vcl/trunk/web/.ht-inc/blockallocations.php
Author: jfthomps
Date: Wed Jun 20 14:43:29 2012
New Revision: 1352132
URL: http://svn.apache.org/viewvc?rev=1352132&view=rev
Log:
VCL-576
Finalizing for 2.3 release
blockallocations.php:
-modified createMonthlyBlockTimes - separated out the code that generates the values for the insert so that it can be called when validating the input to determine if any values would be generated
-added getMonthlyBlockTimes
-modified processBlockAllocationInput - added checks to ensure time slots would be generated for weekly and monthly repeating allocations; fixed but where Sunday only repeating weekly allocations would not be processed properly because $days was getting set to '' since the input was 0 and being treated as a string instead of a number
Modified:
incubator/vcl/trunk/web/.ht-inc/blockallocations.php
Modified: incubator/vcl/trunk/web/.ht-inc/blockallocations.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/blockallocations.php?rev=1352132&r1=1352131&r2=1352132&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/blockallocations.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/blockallocations.php Wed Jun 20 14:43:29 2012
@@ -882,7 +882,7 @@ function createWeeklyBlockTimes($blockid
////////////////////////////////////////////////////////////////////////////////
///
-/// \fn createMonthlyBlockTimes($blockid, $startts, $endts, $day, $weeknum,
+/// \fn createMonthlyBlockTimes($blockid, $startts, $endts, $dayweek, $weeknum,
/// $times)
///
/// \param $blockid - id of block allocation
@@ -898,6 +898,36 @@ function createWeeklyBlockTimes($blockid
////////////////////////////////////////////////////////////////////////////////
function createMonthlyBlockTimes($blockid, $startts, $endts, $dayweek, $weeknum,
$times) {
+ $vals = getMonthlyBlockTimes($blockid, $startts, $endts, $dayweek, $weeknum,
+ $times);
+ $allvals = implode(',', $vals);
+ $query = "INSERT INTO blockTimes "
+ . "(blockRequestid, "
+ . "start, "
+ . "end) "
+ . "VALUES $allvals";
+ doQuery($query, 101);
+ deleteBlockSkipDuplicates($blockid);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn getMonthlyBlockTimes($blockid, $startts, $endts, $dayweek, $weeknum,
+/// $times)
+///
+/// \param $blockid - id of block allocation
+/// \param $startts - unix timestamp for starting time
+/// \param $endts - unix timestamp for ending time
+/// \param $dayweek - day of the week (1 to 7)
+/// \param $weeknum - week of the month (1 to 5)
+/// \param $times - array of times in HH:MM|HH:MM (start|end) format
+///
+/// \brief generates query values for creating entries in the blockTimes table
+/// for a monthly repeating block allocation
+///
+////////////////////////////////////////////////////////////////////////////////
+function getMonthlyBlockTimes($blockid, $startts, $endts, $dayweek, $weeknum,
+ $times) {
$vals = array();
$startts += 3600; # This is a simple way to deal with DST; without it. We end
# up starting at midnight. When we go through the day DST
@@ -926,14 +956,7 @@ function createMonthlyBlockTimes($blocki
}
}
}
- $allvals = implode(',', $vals);
- $query = "INSERT INTO blockTimes "
- . "(blockRequestid, "
- . "start, "
- . "end) "
- . "VALUES $allvals";
- doQuery($query, 101);
- deleteBlockSkipDuplicates($blockid);
+ return $vals;
}
////////////////////////////////////////////////////////////////////////////////
@@ -3085,7 +3108,18 @@ function processBlockAllocationInput() {
}
}
if($type == 'weekly') {
+ $validdays = 0;
+ $errmsg = '';
+ for($day = $return['startts'], $i = 0;
+ $i < 7, $day < ($return['endts'] + SECINDAY);
+ $i++, $day += SECINDAY) {
+ $daynum = date('w', $day);
+ $validdays |= (1 << $daynum);
+ }
$days = processInputVar('days', ARG_STRING);
+ $dayscheck = processInputVar('days', ARG_NUMERIC);
+ if($days == '' && $dayscheck == '0')
+ $days = 0;
$return['daymask'] = 0;
if(! $err) {
foreach(explode(',', $days) as $day) {
@@ -3097,8 +3131,8 @@ function processBlockAllocationInput() {
$return['daymask'] |= (1 << $day);
}
}
- if(! $err && $return['daymask'] == 0) {
- $errmsg = "No valid days submitted.";
+ if(! $err && ($return['daymask'] & $validdays) == 0) {
+ $errmsg = "No valid days submitted for the specified date range.";
$err = 1;
}
}
@@ -3113,6 +3147,12 @@ function processBlockAllocationInput() {
$errmsg = "Invalid day of week submitted.";
$err = 1;
}
+ $times = getMonthlyBlockTimes('', $return['startts'], $return['endts'],
+ $return['day'], $return['weeknum'], $return['times']);
+ if(! $err && empty($times)) {
+ $errmsg = "Specified day of month not found in date range.";
+ $err = 1;
+ }
}
}
if($method == 'request') {