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 2010/07/16 19:58:12 UTC
svn commit: r964890 [3/4] - in /incubator/vcl/trunk/web: .ht-inc/ images/
js/ js/vcldojo/ themes/default/css/
Modified: incubator/vcl/trunk/web/.ht-inc/conf.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/conf.php?rev=964890&r1=964889&r2=964890&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/conf.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/conf.php Fri Jul 16 17:58:12 2010
@@ -35,6 +35,9 @@ define("HOMEURL", "http://vcl.example.or
date_default_timezone_set('America/New_York'); // set this to your timezone; a list of available values can
// be found at http://php.net/manual/en/timezones.php
+$blockNotifyUsers = "adminuser@example.org"; // comma delimited list of email addresses to which
+ // a notification will be sent when new block allocation
+ // requests are submitted and awaiting approval
$clickThroughText =
"<center><h2>Installer Agreement</h2></center>
<p>As the creator of the VCL image, you are responsible for understanding and
Modified: incubator/vcl/trunk/web/.ht-inc/errors.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/errors.php?rev=964890&r1=964889&r2=964890&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/errors.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/errors.php Fri Jul 16 17:58:12 2010
@@ -58,6 +58,7 @@ $ERRORS = array (
"111" => "Failed to execute query 2 in showTimeTable",
"112" => "Failed to execute query 3 in showTimeTable",
"113" => "Failed to get reservation data in getCompLoadLog",
+ "114" => "Failed to get start date in getPendingBlockHTML",
"115" => "Failed to execute query 1 in getOSList",
"120" => "Failed to execute query 1 in getImages",
"125" => "Failed to execute query 1 in isAvailable",
Modified: incubator/vcl/trunk/web/.ht-inc/requests.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/requests.php?rev=964890&r1=964889&r2=964890&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/requests.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/requests.php Fri Jul 16 17:58:12 2010
@@ -24,30 +24,11 @@ define("STARTDAYERR", 1);
/// signifies an error with the submitted start hour
define("STARTHOURERR", 1 << 1);
/// signifies an error with the submitted end date
-define("ENDDAYERR", 1 << 2);
+//define("ENDDAYERR", 1 << 2);
/// signifies an error with the submitted end hour
-define("ENDHOURERR", 1 << 3);
-/// signifies an error with the submitted starting date
-define("STARTDATEERR", 1 << 4);
+//define("ENDHOURERR", 1 << 3);
/// signifies an error with the submitted endding date and time
-define("ENDDATEERR", 1 << 5);
-/// signifies an error with the selected imageid
-define("IMAGEIDERR", 1 << 6);
-/// signifies an error with the number of block machines
-define("BLOCKCNTERR", 1 << 7);
-/// signifies an error with the selected groupid
-define("USERGROUPIDERR", 1 << 8);
-/// signifies an error with the selected availibility time
-define("AVAILABLEERR", 1 << 9);
-/// signifies an error with the selected week number
-define("WEEKNUMERR", 1 << 10);
-/// signifies an error with the selected day of the week
-define("DAYERR", 1 << 11);
-/// signifies an error with the specified name
-define("BLOCKNAMEERR", 1 << 12);
-/// signifies an error with the selected admin groupid
-define("ADMINGROUPIDERR", 1 << 13);
-
+define("ENDDATEERR", 1 << 4);
////////////////////////////////////////////////////////////////////////////////
///
@@ -561,1336 +542,6 @@ function submitRequest() {
////////////////////////////////////////////////////////////////////////////////
///
-/// \fn blockRequest()
-///
-/// \brief prints a page for selecting block request stuff
-///
-////////////////////////////////////////////////////////////////////////////////
-function blockRequest() {
- global $viewmode, $user;
- print "<H2>Block Reservation</H2>\n";
- if($viewmode == ADMIN_DEVELOPER) {
- print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
- $cont = addContinuationsEntry('newBlockRequest');
- print "<INPUT type=radio id=newblock name=continuation value=\"$cont\">\n";
- print "<label for=newblock>New Block Reservation</label><br>\n";
- $cont = addContinuationsEntry('selectEditBlockRequest');
- print "<INPUT type=radio id=editblock name=continuation value=\"$cont\" checked>\n";
- print "<label for=editblock>Edit/Delete Block Reservation</label><br>\n";
- print "<INPUT type=submit value=Submit>\n";
- print "</FORM><br>\n";
- }
- $blockids = getBlockRequestIDs($user);
- if(! count($blockids))
- return;
- $inids = implode(',', $blockids);
- $query = "SELECT id, "
- . "name "
- . "FROM blockRequest "
- . "WHERE id in ($inids)";
- $qh = doQuery($query, 101);
- while($row = mysql_fetch_assoc($qh))
- $blocks[$row['id']] = $row['name'];
- print "You are currently a member of the following Block Reservations.<br>\n";
- print "Click an item to view its current status.<br>\n";
- foreach($blocks as $id => $name) {
- $cont = addContinuationsEntry('viewBlockStatus', array('id' => $id));
- print "<a href=\"" . BASEURL . SCRIPT . "?continuation=$cont\">";
- print "$name</a><br>\n";
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \fn newBlockRequest()
-///
-/// \brief prints form for submitting a new block request
-///
-////////////////////////////////////////////////////////////////////////////////
-function newBlockRequest() {
- global $submitErr, $user, $days;
- $data = processBlockRequestInput(0);
-
- if(! $submitErr) {
- if($data['state'])
- print "<H2>Edit Block Reservation</H2>\n";
- else {
- print "<H2>New Block Reservation</H2>\n";
- $data['machinecnt'] = '';
- }
- }
- else {
- foreach($days as $day) {
- if(in_array($day, $data['wdays']))
- $data['wdayschecked'][$day] = 'checked';
- }
- }
- print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
- print "Enter a name for the Block Reservation:<br>\n";
- print "<INPUT type=text name=blockname size=30 value=\"{$data['blockname']}\">";
- printSubmitErr(BLOCKNAMEERR);
- print "<br><br>\n";
- print "Select an environment from the list:<br>\n";
- printSubmitErr(IMAGEIDERR);
-
- $resources = getUserResources(array("imageAdmin", "imageCheckOut"));
- $resources["image"] = removeNoCheckout($resources["image"]);
- $OSs = getOSList();
-
- // list of images
- uasort($resources["image"], "sortKeepIndex");
- printSelectInput("imageid", $resources["image"], $data['imageid'], 1);
- print "<br><br>\n";
-
- print "How many machines do you need for the block request?<br>\n";
- print "<INPUT type=text name=machinecnt size=3 value={$data['machinecnt']}>";
- printSubmitErr(BLOCKCNTERR);
- print "<br><br>\n";
-
- print "What user group should be allowed to check out machines in this ";
- print "block request?<br>\n";
- $groups = getUserGroups(0, $user['affiliationid']);
- if(array_key_exists(82, $groups))
- unset($groups[82]); # remove None group
- if(! empty($data['usergroupid']) &&
- ! array_key_exists($data['usergroupid'], $groups)) {
- $groups[$data['usergroupid']] =
- array('name' => getUserGroupName($data['usergroupid'], 1));
- uasort($groups, "sortKeepIndex");
- }
- printSelectInput('usergroupid', $groups, $data['usergroupid']);
- printSubmitErr(USERGROUPIDERR);
- print "<br><br>\n";
-
- print "What user group should be allowed to manage (administer) this ";
- print "block request?<br>\n";
- if(! empty($data['admingroupid']) &&
- ! array_key_exists($data['admingroupid'], $groups)) {
- $groups[$data['admingroupid']] =
- array('name' => getUserGroupName($data['admingroupid'], 1));
- uasort($groups, "sortKeepIndex");
- }
- $nonegroups = array_reverse($groups, TRUE);
- $nonegroups[0] = array('name' => 'None (owner only)');
- $nonegroups = array_reverse($nonegroups, TRUE);
- printSelectInput('admingroupid', $nonegroups, $data['admingroupid']);
- printSubmitErr(ADMINGROUPIDERR);
- print "<br><br>\n";
-
- $checked = array('weekly' => '',
- 'monthly' => '',
- 'list' => '');
- if($data['available'] == "weekly")
- $checked['weekly'] = 'checked';
- elseif($data['available'] == 'monthly')
- $checked['monthly'] = 'checked';
- elseif($data['available'] == 'list')
- $checked['list'] = 'checked';
- print "When do you need the block of machines to be available?<br>\n";
- print "<INPUT type=radio name=available id=rweekly value=\"weekly\"";
- print "{$checked['weekly']} onclick=javascript:show('weekly');>";
- print "<label for=rweekly>Repeating Weekly</label>\n";
- print "<INPUT type=radio name=available id=rmonthly value=\"monthly\"";
- print "{$checked['monthly']} onclick=javascript:show('monthly');>";
- print "<label for=rmonthly>Repeating Monthly</label>\n";
- print "<INPUT type=radio name=available id=rlist value=\"list\"";
- print "{$checked['list']} onclick=javascript:show('list');>";
- print "<label for=rlist>List of dates/times</label><br>\n";
-
- print "<fieldset id=weekly class=shown>\n";
- print "<legend>Repeating Weekly</legend>\n";
- print "<table summary=\"\">\n";
- print " <TR>\n";
- print " <TH>Day</TH>\n";
- print " <TH>Time</TH>\n";
- print " </TR>\n";
- print " <TR>\n";
- print " <TD>\n";
- foreach($days as $day) {
- print " <INPUT type=checkbox name=wdays[] value=$day {$data['wdayschecked'][$day]}>$day<br>\n";
- }
- printSubmitErr(STARTDAYERR);
- print " </TD>\n";
- print " <TD valign=top>\n";
- print " <table summary=\"\">\n";
- print " <TR>\n";
- print " <TH>Start</TH>\n";
- print " <TD></TD>\n";
- print " <TH>End</TH>\n";
- print " </TR>\n";
- for($i = 0; $i < 4; $i++) {
- if(count($data['swhour']) < 4) {
- $data['swhour'][$i] = 1;
- $data['swminute'][$i] = "zero";
- $data['swmeridian'][$i] = "am";
- $data['ewhour'][$i] = 1;
- $data['ewminute'][$i] = "zero";
- $data['ewmeridian'][$i] = "am";
- }
- print " <TR>\n";
- print " <TD nowrap>\n";
- print " Slot" . ($i + 1) . ":\n";
- printBlockStartEnd($i, 'w', $data['swhour'],
- $data['swminute'],
- $data['swmeridian'],
- $data['ewhour'],
- $data['ewminute'],
- $data['ewmeridian']);
- print " </TD>\n";
- print " <TD>\n";
- if($data['available'] == 'weekly') {
- printSubmitErr(STARTHOURERR, $i);
- printSubmitErr(ENDHOURERR, $i);
- }
- print " </TD>\n";
- print " </TR>\n";
- }
- print " </table>\n";
- print " </TD>\n";
- print " </TR>\n";
- print "</table>\n";
- print "<table summary=\"\">\n";
- print " <TR>\n";
- print " <TH>Starting date:</TH>\n";
- print " <TD><INPUT type=text name=swdate size=10 maxlength=8 value=\"{$data['swdate']}\"></TD>\n";
- print " <TD><small>(mm/dd/yy) </small>";
- if($data['available'] == 'weekly')
- printSubmitErr(STARTDATEERR);
- print "</TD>\n";
- print " </TR>\n";
- print " <TR>\n";
- print " <TH>Ending date:</TH>\n";
- print " <TD><INPUT type=text name=ewdate size=10 maxlength=8 value=\"{$data['ewdate']}\"></TD>\n";
- print " <TD><small>(mm/dd/yy) </small>";
- if($data['available'] == 'weekly')
- printSubmitErr(ENDDATEERR);
- print "</TD>\n";
- print " </TR>\n";
- print "</table>\n";
- print "</fieldset>\n";
-
- print "<fieldset id=monthly class=shown>\n";
- print "<legend>Repeating Monthly</legend>\n";
- $weeknumArr = array(1 => "1st",
- 2 => "2nd",
- 3 => "3rd",
- 4 => "4th",
- 5 => "5th");
- $dayArr = array(1 => "Sunday",
- 2 => "Monday",
- 3 => "Tuesday",
- 4 => "Wednesday",
- 5 => "Thursday",
- 6 => "Friday",
- 7 => "Saturday");
- printSelectInput('weeknum', $weeknumArr, $data['weeknum']);
- printSelectInput('day', $dayArr, $data['day']);
- print " of every month<br>\n";
- print "<table summary=\"\">\n";
- print " <TR>\n";
- print " <TH>Start</TH>\n";
- print " <TD></TD>\n";
- print " <TH>End</TH>\n";
- print " </TR>\n";
- for($i = 0; $i < 4; $i++) {
- if(count($data['smhour']) < 4) {
- $data['smhour'][$i] = 1;
- $data['smminute'][$i] = "zero";
- $data['smmeridian'][$i] = "am";
- $data['emhour'][$i] = 1;
- $data['emminute'][$i] = "zero";
- $data['emmeridian'][$i] = "am";
- }
- print " <TR>\n";
- print " <TD nowrap>\n";
- print " Slot" . ($i + 1) . ":\n";
- printBlockStartEnd($i, 'm', $data['smhour'],
- $data['smminute'],
- $data['smmeridian'],
- $data['emhour'],
- $data['emmeridian'],
- $data['emmeridian']);
- print " </TD>\n";
- print " <TD>\n";
- if($data['available'] == 'monthly') {
- printSubmitErr(STARTHOURERR, $i);
- printSubmitErr(ENDHOURERR, $i);
- }
- print " </TD>\n";
- print " </TR>\n";
- }
- print "</table>\n";
- print "<table summary=\"\">\n";
- print " <TR>\n";
- print " <TH>Starting date:</TH>\n";
- print " <TD><INPUT type=text name=smdate size=10 value=\"{$data['smdate']}\"></TD>\n";
- print " <TD><small>(mm/dd/yy) </small>";
- if($data['available'] == 'monthly')
- printSubmitErr(STARTDATEERR);
- print "</TD>\n";
- print " </TR>\n";
- print " <TR>\n";
- print " <TH>Ending date:</TH>\n";
- print " <TD><INPUT type=text name=emdate size=10 value=\"{$data['emdate']}\"></TD>\n";
- print " <TD><small>(mm/dd/yy) </small>\n";
- if($data['available'] == 'monthly')
- printSubmitErr(ENDDATEERR);
- print "</TD>\n";
- print " </TR>\n";
- print "</table>\n";
- print "</fieldset>\n";
-
- print "<fieldset id=list class=shown>\n";
- print "<legend>List of dates/times</legend>\n";
- print "<table summary=\"\">\n";
- print " <TR>\n";
- print " <TH nowrap>Date <small>(mm/dd/yy)</small></TH>\n";
- print " <TH>Start</TH>\n";
- print " <TD></TD>\n";
- print " <TH>End</TH>\n";
- print " </TR>\n";
- for($i = 0; $i < 4; $i++) {
- if(count($data['slhour']) < 4) {
- $data['slhour'][$i] = 1;
- $data['slminute'][$i] = "zero";
- $data['slmeridian'][$i] = "am";
- $data['elhour'][$i] = 1;
- $data['elminute'][$i] = "zero";
- $data['elmeridian'][$i] = "am";
- $data['date'][$i] = "";
- }
- print " <TR>\n";
- $slot = $i + 1;
- print " <TD nowrap>Slot $slot:<INPUT type=text name=date[] size=10 value={$data['date'][$i]}></TD>\n";
- print " <TD nowrap>\n";
- printBlockStartEnd($i, 'l', $data['slhour'],
- $data['slminute'],
- $data['slmeridian'],
- $data['elhour'],
- $data['elminute'],
- $data['elmeridian']);
- print " </TD>\n";
- print " <TD>\n";
- if($data['available'] == 'list') {
- printSubmitErr(STARTDATEERR, $i);
- printSubmitErr(STARTHOURERR, $i);
- printSubmitErr(ENDHOURERR, $i);
- }
- print " </TD>\n";
- print " </TR>\n";
- }
- print "</table>\n";
- print "</fieldset>\n";
-
- $cdata = array('state' => $data['state'],
- 'blockRequestid' => $data['blockRequestid']);
- $cont = addContinuationsEntry('confirmBlockRequest', $cdata, SECINDAY, 0, 1, 1);
- print "<INPUT type=hidden name=continuation value=\"$cont\">\n";
- print "<INPUT type=submit value=Confirm>\n";
- print "</FORM>\n";
- printBlockRequestJavascript($data['available']);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \fn selectEditBlockRequest()
-///
-/// \brief prints a page with summary info on each block request allowing one
-/// to be select for editing
-///
-////////////////////////////////////////////////////////////////////////////////
-function selectEditBlockRequest() {
- global $user, $days;
- $groups = getUserEditGroups($user['id']);
- $groupids = implode(',', array_keys($groups));
- $query = "SELECT b.id, "
- . "b.name AS blockname, "
- . "b.imageid, "
- . "i.prettyname AS image, "
- . "b.numMachines AS machinecnt, "
- . "b.groupid as usergroupid, "
- . "CONCAT(g.name, '@', a.name) AS `group`, "
- . "b.admingroupid as admingroupid, "
- . "CONCAT(ga.name, '@', aa.name) AS `admingroup`, "
- . "b.repeating AS available "
- . "FROM image i, "
- . "usergroup g, "
- . "affiliation a, "
- . "blockRequest b "
- . "LEFT JOIN usergroup ga ON (b.admingroupid = ga.id) "
- . "LEFT JOIN affiliation aa ON (ga.affiliationid = aa.id) "
- . "WHERE (b.ownerid = {$user['id']} ";
- if(! empty($groupids))
- $query .= "OR b.admingroupid IN ($groupids) ";
- $query .= ") AND b.imageid = i.id AND "
- . "b.groupid = g.id AND "
- . "g.affiliationid = a.id "
- . "ORDER BY b.name";
- $qh = doQuery($query, 101);
- while($row = mysql_fetch_assoc($qh)) {
- $blockrequest[$row['id']] = $row;
- $query2 = "SELECT DATE_FORMAT(start, '%c/%e/%y<br>%l:%i %p') AS start1, "
- . "UNIX_TIMESTAMP(start) AS unixstart, "
- . "UNIX_TIMESTAMP(end) AS unixend "
- . "FROM blockTimes "
- . "WHERE blockRequestid = {$row['id']} "
- . "ORDER BY start "
- . "LIMIT 1";
- $qh2 = doQuery($query2, 101);
- if($row2 = mysql_fetch_assoc($qh2)) {
- $blockrequest[$row['id']]['nextstart'] = $row2['start1'];
- if(time() > ($row2['unixstart'] - 1800) &&
- time() < $row2['unixend'])
- $blockrequest[$row['id']]['nextstartactive'] = 1;
- else
- $blockrequest[$row['id']]['nextstartactive'] = 0;
- }
- else {
- $blockrequest[$row['id']]['nextstart'] = "none found";
- $blockrequest[$row['id']]['nextstartactive'] = 0;
- }
- }
- print "<h2>Edit Block Reservation</h2>\n";
- if(empty($blockrequest)) {
- print "There are currently no block reservations.<br>\n";
- return;
- }
- foreach($blockrequest as $id => $request) {
- if($request['available'] == 'weekly') {
- $query = "SELECT DATE_FORMAT(start, '%m/%d/%y') AS swdate, "
- . "DATE_FORMAT(end, '%m/%d/%y')AS ewdate, "
- . "days "
- . "FROM blockWebDate "
- . "WHERE blockRequestid = $id";
- $qh = doQuery($query, 101);
- if(! $row = mysql_fetch_assoc($qh))
- abort(101);
- $blockrequest[$id] = array_merge($request, $row);
- $wdays = array();
- for($i = 0; $i < 7; $i++) {
- if($row['days'] & (1 << $i))
- array_push($wdays, $days[$i]);
- }
- unset($blockrequest[$id]['days']);
- $blockrequest[$id]['wdays'] = $wdays;
- $query = "SELECT starthour, "
- . "startminute, "
- . "startmeridian, "
- . "endhour, "
- . "endminute, "
- . "endmeridian, "
- . "`order` "
- . "FROM blockWebTime "
- . "WHERE blockRequestid = {$request['id']}";
- $qh = doQuery($query, 101);
- while($row = mysql_fetch_assoc($qh)) {
- $blockrequest[$id]['swhour'][$row['order']] = $row['starthour'];
- $blockrequest[$id]['swminute'][$row['order']] = $row['startminute'];
- $blockrequest[$id]['swmeridian'][$row['order']] = $row['startmeridian'];
- $blockrequest[$id]['ewhour'][$row['order']] = $row['endhour'];
- $blockrequest[$id]['ewminute'][$row['order']] = $row['endminute'];
- $blockrequest[$id]['ewmeridian'][$row['order']] = $row['endmeridian'];
- }
- }
- elseif($request['available'] == 'monthly') {
- $query = "SELECT DATE_FORMAT(start, '%m/%d/%y') AS smdate, "
- . "DATE_FORMAT(end, '%m/%d/%y')AS emdate, "
- . "days AS day, "
- . "weeknum "
- . "FROM blockWebDate "
- . "WHERE blockRequestid = $id";
- $qh = doQuery($query, 101);
- if(! $row = mysql_fetch_assoc($qh))
- abort(101);
- $blockrequest[$id] = array_merge($request, $row);
- $query = "SELECT starthour, "
- . "startminute, "
- . "startmeridian, "
- . "endhour, "
- . "endminute, "
- . "endmeridian, "
- . "`order` "
- . "FROM blockWebTime "
- . "WHERE blockRequestid = {$request['id']}";
- $qh = doQuery($query, 101);
- while($row = mysql_fetch_assoc($qh)) {
- $blockrequest[$id]['smhour'][$row['order']] = $row['starthour'];
- $blockrequest[$id]['smminute'][$row['order']] = $row['startminute'];
- $blockrequest[$id]['smmeridian'][$row['order']] = $row['startmeridian'];
- $blockrequest[$id]['emhour'][$row['order']] = $row['endhour'];
- $blockrequest[$id]['emminute'][$row['order']] = $row['endminute'];
- $blockrequest[$id]['emmeridian'][$row['order']] = $row['endmeridian'];
- }
- }
- elseif($request['available'] == 'list') {
- $query = "SELECT DATE_FORMAT(start, '%m/%d/%y') AS date, "
- #. "DATE_FORMAT(end, '%m/%d/%y')AS ewdate, "
- . "days AS `order` "
- . "FROM blockWebDate "
- . "WHERE blockRequestid = $id";
- $qh = doQuery($query, 101);
- while($row = mysql_fetch_assoc($qh)) {
- if($row['date'] == '00/00/00')
- $blockrequest[$id]['date'][$row['order']] = '';
- else
- $blockrequest[$id]['date'][$row['order']] = $row['date'];
- }
- $query = "SELECT starthour, "
- . "startminute, "
- . "startmeridian, "
- . "endhour, "
- . "endminute, "
- . "endmeridian, "
- . "`order` "
- . "FROM blockWebTime "
- . "WHERE blockRequestid = {$request['id']}";
- $qh = doQuery($query, 101);
- while($row = mysql_fetch_assoc($qh)) {
- $blockrequest[$id]['slhour'][$row['order']] = $row['starthour'];
- $blockrequest[$id]['slminute'][$row['order']] = $row['startminute'];
- $blockrequest[$id]['slmeridian'][$row['order']] = $row['startmeridian'];
- $blockrequest[$id]['elhour'][$row['order']] = $row['endhour'];
- $blockrequest[$id]['elminute'][$row['order']] = $row['endminute'];
- $blockrequest[$id]['elmeridian'][$row['order']] = $row['endmeridian'];
- }
- }
- }
- print "Select a block reservation to edit:<br>\n";
- print "<table summary=\"lists current block reservations\">\n";
- print " <TR align=center>\n";
- print " <TD colspan=2></TD>\n";
- print " <TH>Name</TH>\n";
- print " <TH>Image</TH>\n";
- print " <TH>Reserved<br>Machines</TH>\n";
- print " <TH>Reserved<br>For</TH>\n";
- print " <TH>Manageable<br>By</TH>\n";
- print " <TH>Repeating</TH>\n";
- print " <TH>Next Start Time</TH>\n";
- print " </TR>\n";
- foreach($blockrequest as $request) {
- print " <TR align=center>\n";
- print " <TD>\n";
- print " <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
- print " <INPUT type=submit value=Edit>\n";
- $cdata = $request;
- $cdata['state'] = 1; # 1 = edit
- $cdata['blockRequestid'] = $request['id'];
- $cont = addContinuationsEntry('newBlockRequest', $cdata);
- print " <INPUT type=hidden name=continuation value=\"$cont\">\n";
- print " </FORM>\n";
- print " </TD>\n";
- print " <TD>\n";
- print " <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
- print " <INPUT type=submit value=Delete>\n";
- $cdata = $request;
- $cdata['state'] = 2; # 2 = delete
- $cdata['blockRequestid'] = $request['id'];
- $cont = addContinuationsEntry('confirmBlockRequest', $cdata);
- print " <INPUT type=hidden name=continuation value=\"$cont\">\n";
- print " </FORM>\n";
- print " </TD>\n";
- print " <TD>{$request['blockname']}</TD>\n";
- print " <TD>{$request['image']}</TD>\n";
- print " <TD>{$request['machinecnt']}</TD>\n";
- print " <TD>{$request['group']}</TD>\n";
- if(empty($request['admingroup']))
- print " <TD>None (owner only)</TD>\n";
- else
- print " <TD>{$request['admingroup']}</TD>\n";
- print " <TD>{$request['available']}</TD>\n";
- if($request['nextstartactive']) {
- $cont = addContinuationsEntry('viewBlockStatus', array('id' => $request['id']));
- print " <TD><a href=\"" . BASEURL . SCRIPT . "?continuation=$cont\">";
- print "{$request['nextstart']}</a></TD>\n";
- }
- else
- print " <TD>{$request['nextstart']}</TD>\n";
- print " </TR>\n";
- }
- print "</table>\n";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \fn confirmBlockRequest()
-///
-/// \brief prints a confirmation page displaying information on submitted block
-/// request
-///
-////////////////////////////////////////////////////////////////////////////////
-function confirmBlockRequest() {
- global $submitErr, $user, $days, $mode;
- $data = processBlockRequestInput();
- if($submitErr) {
- newBlockRequest();
- return;
- }
- $images = getImages();
- $groups = getUserGroups(0, $user['affiliationid']);
- if(! array_key_exists($data['usergroupid'], $groups))
- $groups[$data['usergroupid']] =
- array('name' => getUserGroupName($data['usergroupid'], 1));
- if(! array_key_exists($data['admingroupid'], $groups))
- $groups[$data['admingroupid']] =
- array('name' => getUserGroupName($data['admingroupid'], 1));
- $groups[0] = array('name' => 'None (owner only)');
- if($data['state'] == 2) {
- print "<H2>Delete Block Reservation</H2>\n";
- print "Delete the following block reservation?<br>\n";
- }
- elseif($data['state'] == 1) {
- print "<H2>Edit Block Reservation</H2>\n";
- print "Modify the following block reservation?<br>\n";
- }
- else {
- print "<H2>New Block Reservation</H2>\n";
- print "Create the following block reservation?<br>\n";
- }
- print "<table summary=\"\">\n";
- print " <TR>\n";
- print " <TH align=right nowrap>Name:</TH>\n";
- print " <TD>{$data['blockname']}</TD>\n";
- print " </TR>\n";
- print " <TR>\n";
- print " <TH align=right nowrap>Image:</TH>\n";
- print " <TD>{$images[$data['imageid']]['prettyname']}</TD>\n";
- print " </TR>\n";
- print " <TR>\n";
- print " <TH align=right nowrap>Reserved Machines:</TH>\n";
- print " <TD>{$data['machinecnt']}</TD>\n";
- print " </TR>\n";
- print " <TR>\n";
- print " <TH align=right nowrap>Reserved for:</TH>\n";
- print " <TD>{$groups[$data['usergroupid']]['name']}</TD>\n";
- print " </TR>\n";
- print " <TR>\n";
- print " <TH align=right nowrap>Manageable by:</TH>\n";
- print " <TD>{$groups[$data['admingroupid']]['name']}</TD>\n";
- print " </TR>\n";
- if($data['available'] == 'weekly') {
- print " <TR>\n";
- print " <TH align=right nowrap>Repeating:</TH>\n";
- print " <TD>Weekly</TD>\n";
- print " </TR>\n";
- print " <TR valign='top'>\n";
- print " <TH valign='top' align=right nowrap>On these days:</TH>\n";
- print " <TD>";
- foreach($data['wdays'] as $day) {
- print "$day<br>";
- }
- print "</TD>\n";
- print " </TR>\n";
- print " <TR>\n";
- print " <TH align=right>For these timeslots on<br>each of the above days:</TH>\n";
- print " <TD>";
- for($i = 0; $i < 4; $i++) {
- if($data['stime'][$i] == $data['etime'][$i])
- continue;
- if($data['swminute'][$i] == 0)
- $data['swminute'][$i] = "00";
- if($data['ewminute'][$i] == 0)
- $data['ewminute'][$i] = "00";
- print "{$data['swhour'][$i]}:{$data['swminute'][$i]} {$data['swmeridian'][$i]} - ";
- print "{$data['ewhour'][$i]}:{$data['ewminute'][$i]} {$data['ewmeridian'][$i]}<br>\n";
- }
- print "</TD>\n";
- print " </TR>\n";
- print " <TR>\n";
- print " <TH align=right nowrap>Starting:</TH>\n";
- print " <TD>{$data['swdate']}</TD>\n";
- print " </TR>\n";
- print " <TR>\n";
- print " <TH align=right nowrap>Ending:</TH>\n";
- print " <TD>{$data['ewdate']}</TD>\n";
- print " </TR>\n";
- }
- elseif($data['available'] == 'monthly') {
- $weeknumArr = array(1 => "1st",
- 2 => "2nd",
- 3 => "3rd",
- 4 => "4th",
- 5 => "5th");
- print " <TR>\n";
- print " <TH align=right nowrap>Repeating:</TH>\n";
- print " <TD>The {$weeknumArr[$data['weeknum']]} {$days[$data['day'] - 1]} of each month</TD>\n";
- print " </TR>\n";
- print " <TR>\n";
- print " <TH align=right>For these timeslots on<br>the above day of the month:</TH>\n";
- print " <TD>";
- for($i = 0; $i < 4; $i++) {
- if($data['stime'][$i] == $data['etime'][$i])
- continue;
- if($data['smminute'][$i] == 0)
- $data['smminute'][$i] = "00";
- if($data['emminute'][$i] == 0)
- $data['emminute'][$i] = "00";
- print "{$data['smhour'][$i]}:{$data['smminute'][$i]} {$data['smmeridian'][$i]} - ";
- print "{$data['emhour'][$i]}:{$data['emminute'][$i]} {$data['emmeridian'][$i]}<br>\n";
- }
- print "</TD>\n";
- print " </TR>\n";
- print " <TR>\n";
- print " <TH align=right nowrap>Starting:</TH>\n";
- print " <TD>{$data['smdate']}</TD>\n";
- print " </TR>\n";
- print " <TR>\n";
- print " <TH align=right nowrap>Ending:</TH>\n";
- print " <TD>{$data['emdate']}</TD>\n";
- print " </TR>\n";
- }
- elseif($data['available'] == 'list') {
- print " <TR valign=top>\n";
- print " <TH align=right>For the following dates and times:</TH>\n";
- print " <TD>\n";
- for($i = 0; $i < 4; $i++) {
- if($data['slhour'][$i] == $data['elhour'][$i] &&
- $data['slminute'][$i] == $data['elminute'][$i] &&
- $data['slmeridian'][$i] == $data['elmeridian'][$i])
- continue;
- if($data['slminute'][$i] == 0)
- $data['slminute'][$i] = '00';
- if($data['elminute'][$i] == 0)
- $data['elminute'][$i] = '00';
- print "{$data['date'][$i]} {$data['slhour'][$i]}:{$data['slminute'][$i]} {$data['slmeridian'][$i]} to {$data['elhour'][$i]}:{$data['elminute'][$i]} {$data['elmeridian'][$i]}<br>\n";
- }
- print " </TD>\n";
- print " </TR>\n";
- }
- print "</table>\n";
- print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
- if($data['state'] == 2) {
- print "<INPUT type=submit value=Delete>\n";
- $cont = addContinuationsEntry('submitDeleteBlockRequest', $data, SECINDAY, 0, 0);
- }
- else {
- print "<INPUT type=submit value=Submit>\n";
- $cont = addContinuationsEntry('submitBlockRequest', $data, SECINDAY, 0, 0);
- }
- print "<INPUT type=hidden name=continuation value=\"$cont\">\n";
- print "</FORM>\n";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \fn submitBlockRequest()
-///
-/// \brief processes submitted block request information
-///
-////////////////////////////////////////////////////////////////////////////////
-function submitBlockRequest() {
- global $submitErr, $user, $days;
- $data = processBlockRequestInput();
- if($submitErr) {
- newBlockRequest();
- return;
- }
-
- # FIXME need to handle creation of a block time that we're currently in the
- # middle of if there wasn't already one we're in the middle of
- if($data['state'] == 1) {
- # get blockTime entry for this request if we're in the middle of one
- $checkCurBlockTime = 0;
- $query = "SELECT id, "
- . "start, "
- . "end "
- . "FROM blockTimes "
- . "WHERE start <= NOW() AND "
- . "end > NOW() AND "
- . "blockRequestid = {$data['blockRequestid']}";
- $qh = doQuery($query, 101);
- if($row = mysql_fetch_assoc($qh)) {
- $checkCurBlockTime = 1;
- $curBlockTime = $row;
- }
- # delete entries from blockTimes that start later than now
- $query = "DELETE FROM blockTimes "
- . "WHERE blockRequestid = {$data['blockRequestid']} AND "
- . "start > NOW()";
- doQuery($query, 101);
- # delete entries from blockWebDate and blockWebTime
- $query = "DELETE FROM blockWebDate WHERE blockRequestid = {$data['blockRequestid']}";
- doQuery($query, 101);
- $query = "DELETE FROM blockWebTime WHERE blockRequestid = {$data['blockRequestid']}";
- doQuery($query, 101);
- }
-
- if($data['available'] == 'weekly') {
- $daymask = 0;
- $startarr = split('/', $data['swdate']);
- $startdate = "20{$startarr[2]}-{$startarr[0]}-{$startarr[1]}";
- $startts = datetimeToUnix("20{$startarr[2]}-{$startarr[0]}-{$startarr[1]} 00:00:00");
- $endarr = split('/', $data['ewdate']);
- $enddt = "20{$endarr[2]}-{$endarr[0]}-{$endarr[1]} 23:59:59";
- $enddate = "20{$endarr[2]}-{$endarr[0]}-{$endarr[1]}";
- $endts = datetimeToUnix($enddt);
- foreach($data['wdays'] as $day) {
- $key = array_search($day, $days);
- $daymask |= (1 << $key);
- }
- }
- elseif($data['available'] == 'monthly') {
- $startarr = split('/', $data['smdate']);
- $startdate = "20{$startarr[2]}-{$startarr[0]}-{$startarr[1]}";
- $startts = datetimeToUnix("20{$startarr[2]}-{$startarr[0]}-{$startarr[1]} 00:00:00");
- $endarr = split('/', $data['emdate']);
- $enddt = "20{$endarr[2]}-{$endarr[0]}-{$endarr[1]} 23:59:59";
- $enddate = "20{$endarr[2]}-{$endarr[0]}-{$endarr[1]}";
- $endts = datetimeToUnix($enddt);
- $selectedday = $data['day'];
- }
- elseif($data['available'] == 'list') {
- $last = -1;
- $enddtArr[-1] = '1970-01-01 00:00:00';
- for($i = 0; $i < 4; $i++) {
- $data['slhour24'][$i] = hour12to24($data['slhour'][$i], $data['slmeridian'][$i]);
- $data['elhour24'][$i] = hour12to24($data['elhour'][$i], $data['elmeridian'][$i]);
- if(empty($data['date'][$i])) {
- $startdtArr[$i] = "0000-00-00 00:00:00";
- $enddtArr[$i] = "0000-00-00 00:00:00";
- }
- else {
- $datearr = explode('/', $data['date'][$i]);
- $startdtArr[$i] = "20{$datearr[2]}-{$datearr[0]}-{$datearr[1]} {$data['slhour24'][$i]}:{$data['slminute'][$i]}:00";
- $enddtArr[$i] = "20{$datearr[2]}-{$datearr[0]}-{$datearr[1]} {$data['elhour24'][$i]}:{$data['elminute'][$i]}:00";
- }
- if($data['stime'][$i] == $data['etime'][$i])
- continue;
- if($startdtArr[$i] != $enddtArr[$i] &&
- datetimeToUnix($enddtArr[$last]) < datetimeToUnix($enddtArr[$i])) {
- $last = $i;
- }
- }
- unset($enddtArr[-1]);
- $endts = datetimeToUnix($enddtArr[$last]);
- $enddt = $enddtArr[$last];
- }
-
- if($data['state'] == 1) {
- $query = "UPDATE blockRequest "
- . "SET name = '{$data['blockname']}', "
- . "imageid = {$data['imageid']}, "
- . "numMachines = {$data['machinecnt']}, "
- . "groupid = {$data['usergroupid']}, "
- . "admingroupid = {$data['admingroupid']}, "
- . "repeating = '{$data['available']}', "
- . "expireTime = '$enddt' "
- . "WHERE id = {$data['blockRequestid']}";
- doQuery($query, 101);
- $blockreqid = $data['blockRequestid'];
- }
- else {
- $managementnodes = getManagementNodes('future');
- if(empty($managementnodes))
- abort(40);
- $mnid = array_rand($managementnodes);
- $query = "INSERT INTO blockRequest "
- . "(name, "
- . "imageid, "
- . "numMachines, "
- . "groupid, "
- . "repeating, "
- . "ownerid, "
- . "admingroupid, "
- . "managementnodeid, "
- . "expireTime) "
- . "VALUES "
- . "('{$data['blockname']}', "
- . "{$data['imageid']}, "
- . "{$data['machinecnt']}, "
- . "{$data['usergroupid']}, "
- . "'{$data['available']}', "
- . "{$user['id']}, "
- . "{$data['admingroupid']}, "
- . "$mnid, "
- . "'$enddt')";
- doQuery($query, 101);
- $qh = doQuery("SELECT LAST_INSERT_ID() FROM blockRequest", 101);
- if(! $row = mysql_fetch_row($qh)) {
- abort(380);
- }
- $blockreqid = $row[0];
- }
-
- if($data['available'] == 'weekly') {
- $query = "INSERT INTO blockWebDate "
- . "(blockRequestid, "
- . "start, "
- . "end, "
- . "days) "
- . "VALUES "
- . "($blockreqid, "
- . "'$startdate', "
- . "'$enddate', "
- . "$daymask)";
- doQuery($query, 101);
- for($i = 0; $i < 4; $i++) {
- $query = "INSERT INTO blockWebTime "
- . "(blockRequestid, "
- . "starthour, "
- . "startminute, "
- . "startmeridian, "
- . "endhour, "
- . "endminute, "
- . "endmeridian, "
- . "`order`) "
- . "VALUES "
- . "($blockreqid, "
- . "'{$data['swhour'][$i]}', "
- . "'{$data['swminute'][$i]}', "
- . "'{$data['swmeridian'][$i]}', "
- . "'{$data['ewhour'][$i]}', "
- . "'{$data['ewminute'][$i]}', "
- . "'{$data['ewmeridian'][$i]}', "
- . "$i)";
- doQuery($query, 101);
- }
- for($day = $startts; $day <= $endts; $day += SECINDAY) {
- if(! in_array(date('l', $day), $data['wdays']))
- continue;
- for($i = 0; $i < 4; $i++) {
- if($data['stime'][$i] == $data['etime'][$i])
- continue;
- $data['swhour'][$i] = hour12to24($data['swhour'][$i], $data['swmeridian'][$i]);
- $data['ewhour'][$i] = hour12to24($data['ewhour'][$i], $data['ewmeridian'][$i]);
- $start = date("Y-m-d", $day) . " {$data['swhour'][$i]}:{$data['swminute'][$i]}:00";
- $end = date("Y-m-d", $day) . " {$data['ewhour'][$i]}:{$data['ewminute'][$i]}:00";
- $query = "INSERT INTO blockTimes "
- . "(blockRequestid, "
- . "start, "
- . "end) "
- . "VALUES "
- . "($blockreqid, "
- . "'$start', "
- . "'$end')";
- doQuery($query, 101);
- }
- }
- }
- elseif($data['available'] == 'monthly') {
- $query = "INSERT INTO blockWebDate "
- . "(blockRequestid, "
- . "start, "
- . "end, "
- . "days, "
- . "weeknum) "
- . "VALUES "
- . "($blockreqid, "
- . "'$startdate', "
- . "'$enddate', "
- . "$selectedday, "
- . "{$data['weeknum']})";
- doQuery($query, 101);
- for($i = 0; $i < 4; $i++) {
- $query = "INSERT INTO blockWebTime "
- . "(blockRequestid, "
- . "starthour, "
- . "startminute, "
- . "startmeridian, "
- . "endhour, "
- . "endminute, "
- . "endmeridian, "
- . "`order`) "
- . "VALUES "
- . "($blockreqid, "
- . "'{$data['smhour'][$i]}', "
- . "'{$data['smminute'][$i]}', "
- . "'{$data['smmeridian'][$i]}', "
- . "'{$data['emhour'][$i]}', "
- . "'{$data['emminute'][$i]}', "
- . "'{$data['emmeridian'][$i]}', "
- . "$i)";
- doQuery($query, 101);
- }
- for($day = $startts; $day <= $endts; $day += SECINDAY) {
- if((date('w', $day) + 1) != $data['day'])
- continue;
- $dayofmon = date('j', $day);
- if(($data['weeknum'] == 1 && ($dayofmon < 8)) ||
- ($data['weeknum'] == 2 && (7 < $dayofmon) && ($dayofmon < 15)) ||
- ($data['weeknum'] == 3 && (14 < $dayofmon) && ($dayofmon < 22)) ||
- ($data['weeknum'] == 4 && (21 < $dayofmon) && ($dayofmon < 29)) ||
- ($data['weeknum'] == 5 && (28 < $dayofmon) && ($dayofmon < 32))) {
- $thedate = date("Y-m-d", $day);
- for($i = 0; $i < 4; $i++) {
- if($data['stime'][$i] == $data['etime'][$i])
- continue;
- $data['smhour'][$i] = hour12to24($data['smhour'][$i], $data['smmeridian'][$i]);
- $data['emhour'][$i] = hour12to24($data['emhour'][$i], $data['emmeridian'][$i]);
- $start = "$thedate {$data['smhour'][$i]}:{$data['smminute'][$i]}:00";
- $end = "$thedate {$data['emhour'][$i]}:{$data['emminute'][$i]}:00";
- $query = "INSERT INTO blockTimes "
- . "(blockRequestid, "
- . "start, "
- . "end) "
- . "VALUES "
- . "($blockreqid, "
- . "'$start', "
- . "'$end')";
- doQuery($query, 101);
- }
- }
- }
- }
- elseif($data['available'] == 'list') {
- for($i = 0; $i < 4; $i++) {
- $query = "INSERT INTO blockWebDate "
- . "(blockRequestid, "
- . "start, "
- . "end, "
- . "days) "
- . "VALUES "
- . "($blockreqid, "
- . "'{$startdtArr[$i]}', "
- . "'{$enddtArr[$i]}', "
- . "$i)";
- doQuery($query, 101);
- $query = "INSERT INTO blockWebTime "
- . "(blockRequestid, "
- . "starthour, "
- . "startminute, "
- . "startmeridian, "
- . "endhour, "
- . "endminute, "
- . "endmeridian, "
- . "`order`) "
- . "VALUES "
- . "($blockreqid, "
- . "'{$data['slhour'][$i]}', "
- . "'{$data['slminute'][$i]}', "
- . "'{$data['slmeridian'][$i]}', "
- . "'{$data['elhour'][$i]}', "
- . "'{$data['elminute'][$i]}', "
- . "'{$data['elmeridian'][$i]}', "
- . "$i)";
- doQuery($query, 101);
- if($data['stime'][$i] == $data['etime'][$i])
- continue;
- $query = "INSERT INTO blockTimes "
- . "(blockRequestid, "
- . "start, "
- . "end) "
- . "VALUES "
- . "($blockreqid, "
- . "'{$startdtArr[$i]}', "
- . "'{$enddtArr[$i]}')";
- doQuery($query, 101);
- }
- }
- if($data['state'] == 1) {
- if($checkCurBlockTime) {
- $query = "SELECT id, "
- . "start, "
- . "end "
- . "FROM blockTimes "
- . "WHERE start <= NOW() AND "
- . "end > NOW() AND "
- . "blockRequestid = {$data['blockRequestid']} AND "
- . "id != {$curBlockTime['id']}";
- $qh = doQuery($query, 101);
- if($row = mysql_fetch_assoc($qh)) {
- if($curBlockTime['end'] != $row['end']) {
- # update old end time
- $query = "UPDATE blockTimes "
- . "SET end = '{$row['end']}' "
- . "WHERE id = {$curBlockTime['id']}";
- doQuery($query, 101);
- }
- # delete $row entry
- doQuery("DELETE FROM blockTimes WHERE id = {$row['id']}", 101);
- }
- else {
- # the blockTime we were in the middle of was not recreated, so
- # delete the old one
- doQuery("DELETE FROM blockTimes WHERE id = {$curBlockTime['id']}", 101);
- }
- }
- print "<H2>Edit Block Reservation</H2>\n";
- print "Block request has been updated<br>\n";
- }
- else {
- print "<H2>New Block Reservation</H2>\n";
- print "Block request added to database<br>\n";
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \fn submitDeleteBlockRequest()
-///
-/// \brief delete a block request
-///
-////////////////////////////////////////////////////////////////////////////////
-function submitDeleteBlockRequest() {
- $data = processBlockRequestInput();
- $query = "DELETE FROM blockRequest WHERE id = {$data['blockRequestid']}";
- doQuery($query, 101);
- print "<H2>Delete Block Reservation</H2>\n";
- print "Block reservation <strong>{$data['blockname']}</strong> has been deleted.<br>\n";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \fn printBlockStartEnd($cnt, $type, $shour, $sminute, $smeridian, $ehour,
-/// $eminute, $emeridian)
-///
-/// \param $cnt - index number for row
-/// \param $type - 'w', 'm', or 'l' to signify week, month, or list
-/// \param $shour - array of input data
-/// \param $sminute - array of input data
-/// \param $smeridian - array of input data
-/// \param $ehour - array of input data
-/// \param $eminute - array of input data
-/// \param $emeridian - array of input data
-///
-/// \brief prints 4 rows of select boxes for start and end times
-///
-////////////////////////////////////////////////////////////////////////////////
-function printBlockStartEnd($cnt, $type, $shour, $sminute, $smeridian, $ehour, $eminute, $emeridian) {
- $hrArr = array();
- for($i = 1; $i < 13; $i++) {
- $hrArr[$i] = $i;
- }
- $minutes = array("zero" => "00",
- "15" => "15",
- "30" => "30",
- "45" => "45");
- $t_shour = 's' . $type . 'hour[]';
- $t_sminute = 's' . $type . 'minute[]';
- $t_smeridian = 's' . $type . 'meridian[]';
- $t_ehour = 'e' . $type . 'hour[]';
- $t_eminute = 'e' . $type . 'minute[]';
- $t_emeridian = 'e' . $type . 'meridian[]';
- printSelectInput($t_shour, $hrArr, $shour[$cnt]);
- printSelectInput($t_sminute, $minutes, $sminute[$cnt]);
- printSelectInput($t_smeridian, array("am" => "am", "pm" => "pm"), $smeridian[$cnt]);
- print " </TD>\n";
- print " <TD nowrap width=5px></TD>\n";
- print " <TD nowrap>\n";
- printSelectInput($t_ehour, $hrArr, $ehour[$cnt]);
- printSelectInput($t_eminute, $minutes, $eminute[$cnt]);
- printSelectInput($t_emeridian, array("am" => "am", "pm" => "pm"), $emeridian[$cnt]);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \fn printBlockRequestJavascript($show)
-///
-/// \param $show - 'weekly', 'monthly', or 'list'
-///
-/// \brief prints javascript to display the right frameset
-///
-////////////////////////////////////////////////////////////////////////////////
-function printBlockRequestJavascript($show) {
- print <<<HTMLdone
-<script language="Javascript">
-function show(id) {
- document.getElementById("weekly").className = "hidden";
- document.getElementById("monthly").className = "hidden";
- document.getElementById("list").className = "hidden";
- document.getElementById(id).className = "shown";
-}
-HTMLdone;
-print "show(\"$show\")\n";
-print "</script>\n";
-
-}
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \fn viewBlockStatus()
-///
-/// \brief prints a page with information about an active block reservation
-///
-////////////////////////////////////////////////////////////////////////////////
-function viewBlockStatus() {
- $blockid = getContinuationVar('id');
- print "<H2>Block Reservation</H2>\n";
- $data = getBlockRequestStatus($blockid);
- if(is_null($data)) {
- print "The selected Block Request no longer exists.";
- return;
- }
- $startunix = datetimeToUnix($data['start']);
- $endunix = datetimeToUnix($data['end']);
- $start = date('g:ia n/j/Y', $startunix);
- $end = date('g:ia n/j/Y', $endunix);
- print "<div id=statusdiv>\n";
- print "<table class=blockStatusData summary=\"lists attributes of block reservation\">\n";
- print " <tr>\n";
- print " <th>Name:</th>\n";
- print " <td>{$data['name']}</td>\n";
- print " </tr>\n";
- print " <tr>\n";
- print " <th>Image:</th>\n";
- print " <td>{$data['image']}</td>\n";
- print " </tr>\n";
- print " <tr>\n";
- print " <th>Resources:</th>\n";
- if($data['subimages'])
- print " <td>{$data['numMachines']} clusters</td>\n";
- else
- print " <td>{$data['numMachines']} computers</td>\n";
- print " </tr>\n";
- print " <tr>\n";
- print " <th>Starting:</th>\n";
- print " <td>$start</td>\n";
- print " </tr>\n";
- print " <tr>\n";
- print " <th>Ending:</th>\n";
- print " <td>$end</td>\n";
- print " </tr>\n";
- print "</table><br>\n";
- if(! $data['subimages']) {
- $available = 0;
- $reloading = 0;
- $used = 0;
- foreach($data['comps'] as $id => $comp) {
- if($comp['state'] == 'available')
- $available++;
- elseif($comp['state'] == 'reloading')
- $reloading++;
- elseif($comp['state'] == 'reserved' ||
- $comp['state'] == 'inuse')
- $used++;
- }
- $failed = $data['numMachines'] - $available - $reloading - $used;
- print "Current status of computers:<br>\n";
- }
- else {
- $imgdata = getImages(0, $data['imageid']);
- $imageids = $imgdata[$data['imageid']]['subimages'];
- array_unshift($imageids, $data['imageid']);
- $imgavailable = array();
- $imgreloading = array();
- $imgused = array();
- $imgfailed = array();
- foreach($imageids AS $id) {
- $imgavailable[$id] = 0;
- $imgreloading[$id] = 0;
- $imgused[$id] = 0;
- $imgfailed[$id] = 0;
- }
- foreach($data['comps'] as $id => $comp) {
- if($comp['state'] == 'available')
- $imgavailable[$comp['designatedimageid']]++;
- elseif($comp['state'] == 'reloading')
- $imgreloading[$comp['designatedimageid']]++;
- elseif($comp['state'] == 'reserved' ||
- $comp['state'] == 'inuse')
- $imgused[$comp['designatedimageid']]++;
- }
- $failed = 0;
- $available = $data['numMachines'];
- $used = $imgused[$data['imageid']];
- foreach($imageids AS $id) {
- $imgfailed[$id] = $data['numMachines'] - $imgavailable[$id] - $imgreloading[$id] - $used;
- if($failed < $imgfailed[$id])
- $failed = $imgfailed[$id];
- if($available > $imgavailable[$id])
- $available = $imgavailable[$id];
- }
- $reloading = $data['numMachines'] - $available - $used - $failed;
- print "Current status of clusters:<br>\n";
- }
- print "<table class=blockStatusData summary=\"lists status of block reservation\">\n";
- print " <tr>\n";
- print " <th><font color=green>Available:</th>\n";
- print " <td id=available>$available</td>\n";
- print " </tr>\n";
- print " <tr>\n";
- print " <th>Reloading:</th>\n";
- print " <td id=reloading>$reloading</td>\n";
- print " </tr>\n";
- print " <tr>\n";
- print " <th nowrap><font color=#e58304>Reserved/In use:</th>\n";
- print " <td id=used>$used</td>\n";
- print " </tr>\n";
- print " <tr>\n";
- print " <th><font color=red>Failed:</th>\n";
- print " <td id=failed>$failed</td>\n";
- print " </tr>\n";
- print "</table>\n";
- print "</div>\n";
- $cont = addContinuationsEntry('AJupdateBlockStatus', array('id' => $blockid));
- print "<input type=hidden id=updatecont value=\"$cont\">\n";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \fn AJupdateBlockStatus()
-///
-/// \brief
-///
-////////////////////////////////////////////////////////////////////////////////
-function AJupdateBlockStatus() {
- $id = getContinuationVar('id');
- $data = getBlockRequestStatus($id);
- if(is_null($data)) {
- $arr = array('status' => 'gone');
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
- return;
- }
- if(! $data['subimages']) {
- $available = 0;
- $reloading = 0;
- $used = 0;
- foreach($data['comps'] as $id => $comp) {
- if($comp['state'] == 'available')
- $available++;
- elseif($comp['state'] == 'reloading')
- $reloading++;
- elseif($comp['state'] == 'reserved' ||
- $comp['state'] == 'inuse')
- $used++;
- }
- $failed = $data['numMachines'] - $available - $reloading - $used;
- }
- else {
- $imgdata = getImages(0, $data['imageid']);
- $imageids = $imgdata[$data['imageid']]['subimages'];
- array_unshift($imageids, $data['imageid']);
- $imgavailable = array();
- $imgreloading = array();
- $imgused = array();
- $imgfailed = array();
- foreach($imageids AS $id) {
- $imgavailable[$id] = 0;
- $imgreloading[$id] = 0;
- $imgused[$id] = 0;
- $imgfailed[$id] = 0;
- }
- foreach($data['comps'] as $id => $comp) {
- if($comp['state'] == 'available')
- $imgavailable[$comp['designatedimageid']]++;
- elseif($comp['state'] == 'reloading')
- $imgreloading[$comp['designatedimageid']]++;
- elseif($comp['state'] == 'reserved' ||
- $comp['state'] == 'inuse')
- $imgused[$comp['designatedimageid']]++;
- }
- $failed = 0;
- $available = $data['numMachines'];
- $used = $imgused[$data['imageid']];
- foreach($imageids AS $id) {
- $imgfailed[$id] = $data['numMachines'] - $imgavailable[$id] - $imgreloading[$id] - $used;
- if($failed < $imgfailed[$id])
- $failed = $imgfailed[$id];
- if($available > $imgavailable[$id])
- $available = $imgavailable[$id];
- }
- $reloading = $data['numMachines'] - $available - $used - $failed;
- }
- $arr = array('available' => $available,
- 'reloading' => $reloading,
- 'used' => $used,
- 'failed' => $failed);
- header('Content-Type: text/json-comment-filtered; charset=utf-8');
- print '/*{"items":' . json_encode($arr) . '}*/';
-}
-
-////////////////////////////////////////////////////////////////////////////////
-///
/// \fn viewRequests
///
/// \brief prints user's reservations
@@ -3729,27 +2380,6 @@ function connectRequest() {
////////////////////////////////////////////////////////////////////////////////
///
-/// \fn removeNoCheckout($images)
-///
-/// \param $images - an array of images
-///
-/// \return an array of images with the images that have forcheckout == 0
-/// removed
-///
-/// \brief removes any images in $images that have forcheckout == 0
-///
-////////////////////////////////////////////////////////////////////////////////
-function removeNoCheckout($images) {
- $allimages = getImages();
- foreach(array_keys($images) as $id) {
- if(array_key_exists($id, $allimages) && ! $allimages[$id]["forcheckout"])
- unset($images[$id]);
- }
- return $images;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-///
/// \fn processRequestInput($checks)
///
/// \param $checks - (optional) 1 to perform validation, 0 not to
@@ -3877,393 +2507,4 @@ function processRequestInput($checks=1)
$return["testjavascript"] = 0;
return $return;
}
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \fn processBlockRequestInput($checks)
-///
-/// \param $checks - 1 to validate input, 0 to skip validation
-///
-/// \return an array with these keys:\n
-/// \b blockname - name of block request\n
-/// \b imageid - selected image id\n
-/// \b machinecnt - number of machines to allocate\n
-/// \b swhour - array of start hours for weekly available selection\n
-/// \b swminute - array of start minutes for weekly available selection\n
-/// \b swmeridian - array of start meridians for weekly available selection\n
-/// \b ewhour - array of end hours for weekly available selection\n
-/// \b ewminute - array of end minutes for weekly available selection\n
-/// \b ewmeridian - array of end meridians for weekly available selection\n
-/// \b smhour - array of start hours for monthly available selection\n
-/// \b smminute - array of start minutes for monthly available selection\n
-/// \b smmeridian - array of start meridians for monthly available selection\n
-/// \b emhour - array of end hours for weekly monthly selection\n
-/// \b emminute - array of end minutes for weekly monthly selection\n
-/// \b emmeridian - array of end meridians for weekly monthly selection\n
-/// \b slhour - array of start hours for list available selection\n
-/// \b slminute - array of start minutes for list available selection\n
-/// \b slmeridian - array of start meridians for list available selection\n
-/// \b elhour - array of end hours for list available selection\n
-/// \b elminute - array of end minutes for list available selection\n
-/// \b elmeridian - array of end meridians for list available selection\n
-/// \b weeknum - week of the month for monthly available selection\n
-/// \b day - day of the week (1-7) for monthly available selection\n
-/// \b date - array of start dates for list available selection\n
-/// \b available - 'weekly', 'monthly', or 'list'\n
-/// \b usergroupid - user group id\n
-/// \b admingroupid - user group id for group that can edit this request\n
-/// \b swdate - start date for weekly available selection\n
-/// \b ewdate - end date for weekly available selection\n
-/// \b smdate - start date for monthly available selection\n
-/// \b emdate - end date for monthly available selection\n
-/// \b wdays - array of selected days of the week for weekly available selection\n
-/// \b state - 0 if submitted as a new request, 1 for edit, 2 for delete\n
-/// \b blockRequestid - id of the request if editing\n
-/// \b wdayschecked - array to help determine which days of the week should be
-/// checked for weekly available selection if printing the
-/// page with error messages
-///
-/// \brief processes input for blockrequests
-///
-////////////////////////////////////////////////////////////////////////////////
-function processBlockRequestInput($checks=1) {
- global $submitErr, $submitErrMsg, $mode, $user, $days;
- $return = array();
- $return['blockname'] = getContinuationVar("blockname", processInputVar("blockname", ARG_STRING));
- $return['imageid'] = getContinuationVar("imageid", processInputVar("imageid", ARG_NUMERIC));
- $return['machinecnt'] = getContinuationVar("machinecnt", processInputVar("machinecnt", ARG_NUMERIC, 0));
- $return['swhour'] = getContinuationVar("swhour", processInputVar("swhour", ARG_MULTINUMERIC));
- $return['swminute'] = getContinuationVar("swminute", processInputVar("swminute", ARG_MULTINUMERIC));
- $return['swmeridian'] = getContinuationVar("swmeridian", processInputVar("swmeridian", ARG_MULTISTRING));
- $return['ewhour'] = getContinuationVar("ewhour", processInputVar("ewhour", ARG_MULTINUMERIC));
- $return['ewminute'] = getContinuationVar("ewminute", processInputVar("ewminute", ARG_MULTINUMERIC));
- $return['ewmeridian'] = getContinuationVar("ewmeridian", processInputVar("ewmeridian", ARG_MULTISTRING));
- $return['smhour'] = getContinuationVar("smhour", processInputVar("smhour", ARG_MULTINUMERIC));
- $return['smminute'] = getContinuationVar("smminute", processInputVar("smminute", ARG_MULTINUMERIC));
- $return['smmeridian'] = getContinuationVar("smmeridian", processInputVar("smmeridian", ARG_MULTISTRING));
- $return['emhour'] = getContinuationVar("emhour", processInputVar("emhour", ARG_MULTINUMERIC));
- $return['emminute'] = getContinuationVar("emminute", processInputVar("emminute", ARG_MULTINUMERIC));
- $return['emmeridian'] = getContinuationVar("emmeridian", processInputVar("emmeridian", ARG_MULTISTRING));
- $return['slhour'] = getContinuationVar("slhour", processInputVar("slhour", ARG_MULTINUMERIC));
- $return['slminute'] = getContinuationVar("slminute", processInputVar("slminute", ARG_MULTINUMERIC));
- $return['slmeridian'] = getContinuationVar("slmeridian", processInputVar("slmeridian", ARG_MULTISTRING));
- $return['elhour'] = getContinuationVar("elhour", processInputVar("elhour", ARG_MULTINUMERIC));
- $return['elminute'] = getContinuationVar("elminute", processInputVar("elminute", ARG_MULTINUMERIC));
- $return['elmeridian'] = getContinuationVar("elmeridian", processInputVar("elmeridian", ARG_MULTISTRING));
- $return['weeknum'] = getContinuationVar("weeknum", processInputVar("weeknum", ARG_NUMERIC));
- $return['day'] = getContinuationVar("day", processInputVar("day", ARG_NUMERIC));
- $return['date'] = getContinuationVar("date", processInputVar("date", ARG_MULTISTRING));
- $return['available'] = getContinuationVar("available", processInputVar("available", ARG_STRING, 'weekly'));
- $return['usergroupid'] = getContinuationVar("usergroupid", processInputVar("usergroupid", ARG_NUMERIC));
- $return['admingroupid'] = getContinuationVar("admingroupid", processInputVar("admingroupid", ARG_NUMERIC));
- $return['swdate'] = getContinuationVar("swdate", processInputVar("swdate", ARG_STRING));
- $return['ewdate'] = getContinuationVar("ewdate", processInputVar("ewdate", ARG_STRING));
- $return['smdate'] = getContinuationVar("smdate", processInputVar("smdate", ARG_STRING));
- $return['emdate'] = getContinuationVar("emdate", processInputVar("emdate", ARG_STRING));
- $return['wdays'] = getContinuationVar("wdays", processInputVar("wdays", ARG_MULTISTRING));
- $return['state'] = getContinuationVar("state", 0);
- $return['blockRequestid'] = getContinuationVar("blockRequestid", processInputVar("blockRequestid", ARG_NUMERIC));
-
- $return['wdayschecked'] = array();
- foreach($days as $day) {
- if(in_array($day, $return['wdays']))
- $return['wdayschecked'][$day] = 'checked';
- else
- $return['wdayschecked'][$day] = '';
- }
- if(! $checks)
- return $return;
-
- if(! preg_match('/^([-a-zA-Z0-9\. ]){3,80}$/', $return["blockname"])) {
- $submitErr |= BLOCKNAMEERR;
- $submitErrMsg[BLOCKNAMEERR] = "Name can only contain letters, numbers, spaces, dashes(-),<br>and periods(.) and can be from 3 to 80 characters long";
- }
-
- $resources = getUserResources(array("imageAdmin", "imageCheckOut"));
- $resources["image"] = removeNoCheckout($resources["image"]);
- if(! in_array($return['imageid'], array_keys($resources['image']))) {
- $submitErr |= IMAGEIDERR;
- $submitErrMsg[IMAGEIDERR] = "The submitted image is invalid.";
- }
-
- if($return['machinecnt'] < MIN_BLOCK_MACHINES) {
- $submitErr |= BLOCKCNTERR;
- $submitErrMsg[BLOCKCNTERR] = "You must request at least " . MIN_BLOCK_MACHINES . " machines";
- }
- elseif($return['machinecnt'] > MAX_BLOCK_MACHINES) {
- $submitErr |= BLOCKCNTERR;
- $submitErrMsg[BLOCKCNTERR] = "You cannot request more than " . MAX_BLOCK_MACHINES . " machines";
- }
-
- $groups = getUserGroups();
- if(! array_key_exists($return['usergroupid'], $groups)) {
- $submitErr |= USERGROUPIDERR;
- $submitErrMsg[USERGROUPIDERR] = "The submitted user group is invalid.";
- }
-
- if(! array_key_exists($return['admingroupid'], $groups) &&
- $return['admingroupid'] != 0) {
- $submitErr |= ADMINGROUPIDERR;
- $submitErrMsg[ADMINGROUPIDERR] = "The submitted user group is invalid.";
- }
-
- if($return['available'] == 'weekly') {
- $keys = array('1' => 'swhour',
- '2' => 'ewhour',
- '3' => 'swminute',
- '4' => 'ewminute',
- '5' => 'swmeridian',
- '6' => 'ewmeridian',
- '7' => 'swdate',
- '8' => 'ewdate');
-
- // check days of week
- foreach($return['wdays'] as $index => $day) {
- if(! in_array($day, $days))
- unset($return['wdays'][$index]);
- }
- /*foreach($days as $day) {
- if(in_array($day, $return['wdays']))
- $return['wdayschecked'][$day] = 'checked';
- }*/
- if(! count($return['wdays'])) {
- $submitErr |= STARTDAYERR;
- $submitErrMsg[STARTDAYERR] = "You must select at least one day of the week";
- }
- }
- elseif($return['available'] == 'monthly') {
- $keys = array('1' => 'smhour',
- '2' => 'emhour',
- '3' => 'smminute',
- '4' => 'emminute',
- '5' => 'smmeridian',
- '6' => 'emmeridian',
- '7' => 'smdate',
- '8' => 'emdate');
-
- // check weeknum
- if($return['weeknum'] < 1 || $return['weeknum'] > 5) {
- $submitErr |= WEEKNUMERR;
- $submitErrMsg[WEEKNUMERR] = "Invalid week of the month submitted";
- }
-
- // check day
- if($return['day'] < 1 || $return['day'] > 7) {
- $submitErr |= DAYERR;
- $submitErrMsg[DAYERR] = "Invalid day of the week submitted";
- }
-
- }
- elseif($return['available'] == 'list') {
- $keys = array('1' => 'slhour',
- '2' => 'elhour',
- '3' => 'slminute',
- '4' => 'elminute',
- '5' => 'slmeridian',
- '6' => 'elmeridian');
- }
-
- // check each timeslot
- for($i = 0; $i < 4; $i++) {
- $submitErrMsg[STARTHOURERR][$i] = "";
- $submitErrMsg[ENDHOURERR][$i] = "";
- // start hour
- if($return[$keys[1]][$i] < 1 || $return[$keys[1]][$i] > 12) {
- $submitErr |= STARTHOURERR;
- $submitErrMsg[STARTHOURERR][$i] = "The start hour must be between 1 and 12.";
- }
- // end hour
- if($return[$keys[2]][$i] < 1 || $return[$keys[2]][$i] > 12) {
- $submitErr |= ENDHOURERR;
- $submitErrMsg[ENDHOURERR][$i] = " The end hour must be between 1 and 12.";
- }
- // start minute
- if($return[$keys[3]][$i] < 0 || $return[$keys[3]][$i] > 59) {
- $submitErr |= STARTHOURERR; // we reuse STARTHOURERR here, it overwrites the last one, but oh well
- $submitErrMsg[STARTHOURERR][$i] = "The start minute must be between 0 and 59.";
- }
- // end minute
- if($return[$keys[4]][$i] < 0 || $return[$keys[4]][$i] > 59) {
- $submitErr |= ENDHOURERR;
- $submitErrMsg[ENDHOURERR][$i] = " The end minute must be between 0 and 59.";
- }
- // start meridian
- if($return[$keys[5]][$i] != 'am' && $return[$keys[5]][$i] != 'pm') {
- $return[$keys[5]][$i] = 'pm'; // just set it to one of them
- }
- // end meridian
- if($return[$keys[6]][$i] != 'am' && $return[$keys[6]][$i] != 'pm') {
- $return[$keys[6]][$i] = 'am'; // just set it to one of them
- }
- // check that start is before end
- $return['stime'][$i] = minuteOfDay2("{$return[$keys[1]][$i]}:{$return[$keys[3]][$i]} {$return[$keys[5]][$i]}");
- $return['etime'][$i] = minuteOfDay2("{$return[$keys[2]][$i]}:{$return[$keys[4]][$i]} {$return[$keys[6]][$i]}");
- if($return['stime'][$i] > $return['etime'][$i]) {
- $submitErr |= STARTHOURERR; // we reuse STARTHOURERR here, it overwrites the last one, but oh well
- $submitErrMsg[STARTHOURERR][$i] = "The start time must be before the end time (or be equal to ignore this slot)";
- }
- }
- if($return['available'] == 'weekly' ||
- $return['available'] == 'monthly') {
- // check that timeslots do not overlap
- if(! ($submitErr & STARTHOURERR) && ! ($submitErr & ENDHOURERR)) {
- for($i = 0; $i < 4; $i++) {
- for($j = $i + 1; $j < 4; $j++) {
- if($return['etime'][$i] > $return['stime'][$j] &&
- $return['stime'][$i] < $return['etime'][$j]) {
- $submitErr |= STARTHOURERR;
- $submitErrMsg[STARTHOURERR][$i] = "This timeslot overlaps with Slot" . ($j + 1);
- }
- }
- }
- }
- // check that start date is valid
- $startarr = split('/', $return[$keys[7]]);
- if(! preg_match('/^((\d){1,2})\/((\d){1,2})\/(\d){2}$/', $return[$keys[7]])) {
- $submitErr |= STARTDATEERR;
- $submitErrMsg[STARTDATEERR] = "The start date must be in the form mm/dd/yy.";
- }
- elseif(! checkdate($startarr[0], $startarr[1], $startarr[2])) {
- $submitErr |= STARTDATEERR;
- $submitErrMsg[STARTDATEERR] = "This is an invalid date.";
- }
- elseif(datetimeToUnix("{$startarr[2]}-{$startarr[0]}-{$startarr[1]} 23:59:59") < time()) {
- $submitErr |= STARTDATEERR;
- $submitErrMsg[STARTDATEERR] = "The start date must be today or later.";
- }
- // check that end date is valid
- $endarr = split('/', $return[$keys[8]]);
- if(! preg_match('/^((\d){1,2})\/((\d){1,2})\/(\d){2}$/', $return[$keys[8]])) {
- $submitErr |= ENDDATEERR;
- $submitErrMsg[ENDDATEERR] = "The end date must be in the form mm/dd/yy.";
- }
- elseif(! checkdate($endarr[0], $endarr[1], $endarr[2])) {
- $submitErr |= ENDDATEERR;
- $submitErrMsg[ENDDATEERR] = "This is an invalid date.";
- }
- elseif(datetimeToUnix("{$startarr[2]}-{$startarr[0]}-{$startarr[1]} 00:00:00") >
- datetimeToUnix("{$endarr[2]}-{$endarr[0]}-{$endarr[1]} 00:00:00")) {
- $submitErr |= ENDDATEERR;
- $submitErrMsg[ENDDATEERR] = "The end date must be later than the start date.";
- }
- }
- elseif($return['available'] == 'list') {
- if(! ($submitErr & STARTHOURERR) && ! ($submitErr & ENDHOURERR)) {
- // check date[1-n]
- for($i = 0; $i < 4; $i++) {
- $submitErrMsg[STARTDATEERR][$i] = "";
- if($return['stime'][$i] == $return['etime'][$i])
- continue;
- $submitErrMsg[STARTDATEERR][$i] = "";
- $datearr = split('/', $return['date'][$i]);
- if(! preg_match('/^((\d){1,2})\/((\d){1,2})\/(\d){2}$/', $return['date'][$i])) {
- $submitErr |= STARTDATEERR;
- $submitErrMsg[STARTDATEERR][$i] = "The date must be in the form mm/dd/yy.";
- }
- elseif(! checkdate($datearr[0], $datearr[1], $datearr[2])) {
- $submitErr |= STARTDATEERR;
- $submitErrMsg[STARTDATEERR][$i] = "Invalid date submitted.";
- }
- elseif(datetimeToUnix("{$datearr[2]}-{$datearr[0]}-{$datearr[1]} 23:59:59") < time()) {
- $submitErr |= STARTDATEERR;
- $submitErrMsg[STARTDATEERR][$i] = "The date must be today or later.";
- }
- }
- }
- }
- if(0) {
- # FIXME
- $submitErr |= AVAILABLEERR;
- $submitErrMsg[AVAILABLEERR] = "The submitted availability selection is invalid.";
- }
- return $return;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \fn getBlockRequestStatus($id)
-///
-/// \param $id - id of a block request
-///
-/// \return if $id, an array with these keys (NULL otherwise):\n
-/// \b name - name of block request\n
-/// \b imageid - id of image\n
-/// \b image - pretty name of image\n
-/// \b subimages - 0 or 1; if image has subimages\n
-/// \b numMachines - number of machines allocated for block request\n
-/// \b groupid - id of group associated with block request\n
-/// \b group - name of group associated with block request\n
-/// \b processing - flag from table\n
-/// \b timeid - id of associated block time having earliest start time\n
-/// \b start - start time of associated block time (datetime)\n
-/// \b end - end time of associated block time (datetime)\n
-/// \b processed - flag from table\n
-/// \b comps - array of data from blockComputers with these keys:\n
-/// \b id - id of computer\n
-/// \b state - state of computer\n
-/// \b currentimageid - current imageid of computer\n
-/// \b curentimage - current image of computer\n
-/// \b designatedimageid - id of image to be loaded on computer\n
-/// \b designatedimage - image to be loaded on computer\n
-/// \b hostname - hostname of computer\n
-/// \b type - the computer type
-///
-/// \brief gets status information about the passed in block request id
-///
-////////////////////////////////////////////////////////////////////////////////
-function getBlockRequestStatus($id) {
- $query = "SELECT r.name, "
- . "r.imageid, "
- . "i.prettyname AS image, "
- . "im.subimages, "
- . "r.numMachines, "
- . "r.groupid, "
- . "g.name AS 'group', "
- . "r.processing, "
- . "t.id AS timeid, "
- . "t.start, "
- . "t.end, "
- . "t.processed "
- . "FROM blockRequest r, "
- . "blockTimes t, "
- . "usergroup g, "
- . "image i "
- . "LEFT JOIN imagemeta im ON (i.imagemetaid = im.id) "
- . "WHERE t.blockRequestid = $id AND "
- . "r.id = $id AND "
- . "r.imageid = i.id AND "
- . "r.groupid = g.id "
- . "ORDER BY t.start "
- . "LIMIT 1";
- $qh = doQuery($query, 101);
- if($data = mysql_fetch_assoc($qh)) {
- if(! is_numeric($data['subimages']))
- $data['subimages'] = 0;
- $query = "SELECT c.id, "
- . "s.name AS state, "
- . "c.currentimageid, "
- . "ci.prettyname AS curentimage, "
- . "bc.imageid AS designatedimageid, "
- . "di.prettyname AS designatedimage, "
- . "c.hostname, "
- . "c.type "
- . "FROM blockComputers bc, "
- . "computer c, "
- . "state s, "
- . "image ci, "
- . "image di "
- . "WHERE bc.blockTimeid = {$data['timeid']} AND "
- . "bc.computerid = c.id AND "
- . "c.currentimageid = ci.id AND "
- . "bc.imageid = di.id AND "
- . "c.stateid = s.id";
- $qh = doQuery($query, 101);
- $data['comps'] = array();
- while($row = mysql_fetch_assoc($qh))
- $data['comps'][$row['id']] = $row;
- return $data;
- }
- else
- return NULL;
-}
?>
Modified: incubator/vcl/trunk/web/.ht-inc/states.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/states.php?rev=964890&r1=964889&r2=964890&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/states.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/states.php Fri Jul 16 17:58:12 2010
@@ -28,7 +28,7 @@ $actions["nextmodes"] = array();
$actions["entry"] = array('main',
'newRequest',
'viewRequests',
- 'blockRequest',
+ 'blockAllocations',
'userpreferences',
'viewGroups',
'selectImageOption',
@@ -53,6 +53,7 @@ $actions["entry"] = array('main',
'auth',
'editVMInfo',
'continuationsError',
+ 'requestBlockAllocation',
);
$noHTMLwrappers = array('sendRDPfile',
@@ -121,6 +122,14 @@ $noHTMLwrappers = array('sendRDPfile',
'subimageDialogContent',
'AJaddSubimage',
'AJremSubimage',
+ 'AJblockAllocationSubmit',
+ 'AJpopulateBlockStore',
+ 'AJdeleteBlockAllocationConfirm',
+ 'AJdeleteBlockAllocationSubmit',
+ 'AJacceptBlockAllocationConfirm',
+ 'AJacceptBlockAllocationSubmit',
+ 'AJrejectBlockAllocationConfirm',
+ 'AJrejectBlockAllocationSubmit',
);
# main
@@ -165,25 +174,35 @@ $actions['pages']['sendRDPfile'] = "curr
#$actions['pages']['connectMindterm'] = "currentReservations";
#$actions['pages']['connectRDPapplet'] = "currentReservations";
-# block reservations
-$actions['mode']['blockRequest'] = "blockRequest"; # entry
-$actions['mode']['newBlockRequest'] = "newBlockRequest";
-$actions['mode']['confirmBlockRequest'] = "confirmBlockRequest";
-$actions['mode']['submitBlockRequest'] = "submitBlockRequest";
-$actions['mode']['selectEditBlockRequest'] = "selectEditBlockRequest";
-$actions['mode']['editBlockRequest'] = "editBlockRequest";
-$actions['mode']['submitDeleteBlockRequest'] = "submitDeleteBlockRequest";
+# block allocations
+$actions['mode']['blockAllocations'] = "blockAllocations"; # entry
+$actions['mode']['newBlockAllocation'] = "blockAllocationForm";
+$actions['mode']['editBlockAllocation'] = "blockAllocationForm";
+$actions['mode']['requestBlockAllocation'] = "blockAllocationForm";
+$actions['mode']['AJblockAllocationSubmit'] = "AJblockAllocationSubmit";
+$actions['mode']['AJdeleteBlockAllocationConfirm'] = "AJdeleteBlockAllocationConfirm";
+$actions['mode']['AJdeleteBlockAllocationSubmit'] = "AJdeleteBlockAllocationSubmit";
+$actions['mode']['AJacceptBlockAllocationConfirm'] = "AJacceptBlockAllocationConfirm";
+$actions['mode']['AJacceptBlockAllocationSubmit'] = "AJacceptBlockAllocationSubmit";
+$actions['mode']['AJrejectBlockAllocationConfirm'] = "AJrejectBlockAllocationConfirm";
+$actions['mode']['AJrejectBlockAllocationSubmit'] = "AJrejectBlockAllocationSubmit";
$actions['mode']['viewBlockStatus'] = "viewBlockStatus";
$actions['mode']['AJupdateBlockStatus'] = "AJupdateBlockStatus";
-$actions['pages']['blockRequest'] = "blockReservations";
-$actions['pages']['newBlockRequest'] = "blockReservations";
-$actions['pages']['confirmBlockRequest'] = "blockReservations";
-$actions['pages']['submitBlockRequest'] = "blockReservations";
-$actions['pages']['selectEditBlockRequest'] = "blockReservations";
-$actions['pages']['editBlockRequest'] = "blockReservations";
-$actions['pages']['submitDeleteBlockRequest'] = "blockReservations";
-$actions['pages']['viewBlockStatus'] = "blockReservations";
-$actions['pages']['AJupdateBlockStatus'] = "blockReservations";
+$actions['mode']['AJpopulateBlockStore'] = "AJpopulateBlockStore";
+$actions['pages']['blockAllocations'] = "blockAllocations";
+$actions['pages']['newBlockAllocation'] = "blockAllocations";
+$actions['pages']['editBlockAllocation'] = "blockAllocations";
+$actions['pages']['requestBlockAllocation'] = "blockAllocations";
+$actions['pages']['AJblockAllocationSubmit'] = "blockAllocations";
+$actions['pages']['AJdeleteBlockAllocationConfirm'] = "blockAllocations";
+$actions['pages']['AJdeleteBlockAllocationSubmit'] = "blockAllocations";
+$actions['pages']['AJacceptBlockAllocationConfirm'] = "blockAllocations";
+$actions['pages']['AJacceptBlockAllocationSubmit'] = "blockAllocations";
+$actions['pages']['AJrejectBlockAllocationConfirm'] = "blockAllocations";
+$actions['pages']['AJrejectBlockAllocationSubmit'] = "blockAllocations";
+$actions['pages']['viewBlockStatus'] = "blockAllocations";
+$actions['pages']['AJupdateBlockStatus'] = "blockAllocations";
+$actions['pages']['AJpopulateBlockStore'] = "blockAllocations";
# user preferences
$actions['mode']['userpreferences'] = "userpreferences"; # entry