Example #1
0
 public function __construct($href, $rel, $type = null)
 {
     parent::__construct();
     parent::setAttribute((new Attribute('href'))->append($href));
     parent::setAttribute((new Attribute('rel'))->append($rel));
     if (isset($type)) {
         parent:
         setAttribute((new Attribute('type'))->append($type));
     }
 }
Example #2
0
function viewRequests()
{
    global $user, $inContinuation, $mode, $skin;
    if ($inContinuation) {
        $lengthchanged = getContinuationVar('lengthchanged', 0);
    } else {
        $lengthchanged = processInputVar('lengthchanged', ARG_NUMERIC, 0);
    }
    $incPaneDetails = processInputVar('incdetails', ARG_NUMERIC, 0);
    $refreqid = processInputVar('reqid', ARG_NUMERIC, 0);
    $requests = getUserRequests("all");
    $images = getImages();
    $computers = getComputers();
    $resources = getUserResources(array("imageAdmin"));
    $text = '';
    $newbtnh = '';
    if (in_array("imageCheckOut", $user["privileges"]) || in_array("imageAdmin", $user["privileges"])) {
        $newbtnh .= "<button id=\"newrequestbtn\" dojoType=\"dijit.form.Button\">\n";
        $newbtnh .= "  " . i("New Reservation") . "\n";
        $newbtnh .= "  <script type=\"dojo/method\" event=\"onClick\">\n";
        $newbtnh .= "    showNewResDlg();\n";
        $newbtnh .= "  </script>\n";
        $newbtnh .= "</button><br><br>\n";
    }
    if ($mode != 'AJviewRequests') {
        print "<H2>" . i("Current Reservations") . "</H2>\n";
        if (count($requests) == 0) {
            print "<span id=\"noresspan\">\n";
        } else {
            print "<span id=\"noresspan\" class=\"hidden\">\n";
        }
        if ($newbtnh == '') {
            print i("You have no current reservations and do not have access to create new ones.") . "<br><br>\n";
        } else {
            print i("You have no current reservations.") . "<br><br>\n";
        }
        print "</span>\n";
        print $newbtnh;
    }
    if ($newbtnh == '' && count($requests) == 0) {
        return;
    }
    if ($mode != 'AJviewRequests') {
        print "<div id=subcontent>\n";
    }
    $refresh = 0;
    $connect = 0;
    $failed = 0;
    $normal = '';
    $imaging = '';
    $long = '';
    $server = '';
    $pendingcnt = 0;
    $reqids = array();
    if (checkUserHasPerm('View Debug Information')) {
        $nodes = getManagementNodes();
    }
    if ($count = count($requests)) {
        $now = time();
        for ($i = 0, $failed = 0, $timedout = 0, $text = '', $showcreateimage = 0, $cluster = 0; $i < $count; $i++, $failed = 0, $timedout = 0, $text = '', $cluster = 0) {
            if ($requests[$i]['forcheckout'] == 0 && $requests[$i]['forimaging'] == 0) {
                continue;
            }
            if (count($requests[$i]['reservations'])) {
                $cluster = 1;
            }
            $cdata = array('requestid' => $requests[$i]['id']);
            $reqids[] = $requests[$i]['id'];
            $imageid = $requests[$i]["imageid"];
            $text .= "  <TR valign=top id=reqrow{$requests[$i]['id']}>\n";
            if (requestIsReady($requests[$i]) && $requests[$i]['useraccountready']) {
                $connect = 1;
                # request is ready, print Connect! and End buttons
                $cont = addContinuationsEntry('AJconnectRequest', $cdata, SECINDAY);
                $text .= getViewRequestHTMLitem('connectbtn', $cont);
                if ($requests[$i]['serveradmin']) {
                    $cdata2 = $cdata;
                    $cdata2['notbyowner'] = 0;
                    if ($user['id'] != $requests[$i]['userid']) {
                        $cdata2['notbyowner'] = 1;
                    }
                    $cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata2, SECINDAY);
                    $text .= getViewRequestHTMLitem('deletebtn', $cont);
                } else {
                    $text .= "    <TD></TD>\n";
                }
            } elseif ($requests[$i]["currstateid"] == 5) {
                # request has failed
                $text .= getViewRequestHTMLitem('failedblock', $requests[$i]['id']);
                if ($requests[$i]['serveradmin']) {
                    $cont = addContinuationsEntry('AJconfirmRemoveRequest', $cdata, SECINDAY);
                    $text .= getViewRequestHTMLitem('removebtn', $cont);
                } else {
                    $text .= "    <TD></TD>\n";
                }
                $failed = 1;
            } elseif (datetimeToUnix($requests[$i]["start"]) < $now) {
                # other cases where the reservation start time has been reached
                if ($requests[$i]["currstateid"] == 12 && $requests[$i]['laststateid'] == 11 || $requests[$i]["currstateid"] == 11 || $requests[$i]["currstateid"] == 14 && $requests[$i]["laststateid"] == 11) {
                    # request has timed out
                    $text .= getViewRequestHTMLitem('timeoutblock');
                    $timedout = 1;
                    if ($requests[$i]['serveradmin']) {
                        $cont = addContinuationsEntry('AJconfirmRemoveRequest', $cdata, SECINDAY);
                        $text .= getViewRequestHTMLitem('removebtn', $cont);
                    } else {
                        $text .= "    <TD></TD>\n";
                    }
                } else {
                    # computer is loading, print Pending... and Delete button
                    # TODO figure out a different way to estimate for reboot and reinstall states
                    # TODO if user account not ready, print accurate information in details
                    $pendingcnt++;
                    $remaining = 1;
                    if (isComputerLoading($requests[$i], $computers)) {
                        if (datetimeToUnix($requests[$i]["daterequested"]) >= datetimeToUnix($requests[$i]["start"])) {
                            $startload = datetimeToUnix($requests[$i]["daterequested"]);
                        } else {
                            $startload = datetimeToUnix($requests[$i]["start"]);
                        }
                        $imgLoadTime = getImageLoadEstimate($imageid);
                        if ($imgLoadTime == 0) {
                            $imgLoadTime = $images[$imageid]['reloadtime'] * 60;
                        }
                        $tmp = ($imgLoadTime - ($now - $startload)) / 60;
                        $remaining = sprintf("%d", $tmp) + 1;
                        if ($remaining < 1) {
                            $remaining = 1;
                        }
                    }
                    $data = array('text' => '');
                    if ($requests[$i]['currstateid'] != 26 && $requests[$i]['currstateid'] != 27 && $requests[$i]['currstateid'] != 28 && $requests[$i]['currstateid'] != 24 && ($requests[$i]["currstateid"] != 14 || $requests[$i]['laststateid'] != 26 && $requests[$i]['laststateid'] != 27 && $requests[$i]['laststateid'] != 28 && $requests[$i]['laststateid'] != 24)) {
                        $data['text'] = i("<br>Est:&nbsp;") . $remaining . i("&nbsp;min remaining\n");
                    }
                    $text .= getViewRequestHTMLitem('pendingblock', $requests[$i]['id'], $data);
                    $refresh = 1;
                    if ($requests[$i]['serveradmin'] && $requests[$i]['laststateid'] != 24) {
                        $cdata2 = $cdata;
                        $cdata2['notbyowner'] = 0;
                        if ($user['id'] != $requests[$i]['userid']) {
                            $cdata2['notbyowner'] = 1;
                        }
                        $cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata2, SECINDAY);
                        $text .= getViewRequestHTMLitem('deletebtn', $cont);
                    } else {
                        $text .= "    <TD></TD>\n";
                    }
                }
            } else {
                # reservation is in the future
                $text .= "    <TD></TD>\n";
                if ($requests[$i]['serveradmin']) {
                    $cdata2 = $cdata;
                    $cdata2['notbyowner'] = 0;
                    if ($user['id'] != $requests[$i]['userid']) {
                        $cdata2['notbyowner'] = 1;
                    }
                    $cont = addContinuationsEntry('AJconfirmDeleteRequest', $cdata2, SECINDAY);
                    $text .= getViewRequestHTMLitem('deletebtn', $cont);
                } else {
                    $text .= "    <TD></TD>\n";
                }
            }
            if (!$failed && !$timedout) {
                # print edit button
                $editcont = addContinuationsEntry('AJeditRequest', $cdata, SECINDAY);
                $imgcont = addContinuationsEntry('AJstartImage', $cdata, SECINDAY);
                if ($requests[$i]['serveradmin']) {
                    $text .= getViewRequestHTMLitem('openmoreoptions');
                    $text .= getViewRequestHTMLitem('editoption', $editcont);
                    if (array_key_exists($imageid, $resources['image']) && !$cluster && ($requests[$i]['currstateid'] == 8 || $requests[$i]['laststateid'] == 8)) {
                        # reservation has been in inuse state
                        $text .= getViewRequestHTMLitem('endcreateoption', $imgcont);
                    }
                    /*else
                    		$text .= getViewRequestHTMLitem('endcreateoptiondisable');*/
                    if (array_key_exists($imageid, $resources['image']) && !$cluster && $requests[$i]['server'] && ($requests[$i]['currstateid'] == 8 || $requests[$i]['currstateid'] == 14 && $requests[$i]['laststateid'] == 8)) {
                        $chkcdata = $cdata;
                        $chkcdata['checkpoint'] = 1;
                        $imgcont = addContinuationsEntry('AJstartImage', $chkcdata, SECINDAY);
                        $text .= getViewRequestHTMLitem('checkpointoption', $imgcont);
                    } elseif ($requests[$i]['server'] && $requests[$i]['currstateid'] == 24) {
                        $text .= getViewRequestHTMLitem('checkpointoptiondisable');
                    }
                    if ($requests[$i]['currstateid'] == 8 || !$cluster && $requests[$i]['OSinstalltype'] != 'none' && $requests[$i]['currstateid'] != 3 && $requests[$i]['laststateid'] != 3 && $requests[$i]['currstateid'] != 13 && $requests[$i]['laststateid'] != 13 && $requests[$i]['currstateid'] != 24 && $requests[$i]['laststateid'] != 24 && $requests[$i]['currstateid'] != 16 && $requests[$i]['laststateid'] != 16 && $requests[$i]['currstateid'] != 26 && $requests[$i]['laststateid'] != 26 && $requests[$i]['currstateid'] != 28 && $requests[$i]['laststateid'] != 28 && $requests[$i]['currstateid'] != 27 && $requests[$i]['laststateid'] != 27) {
                        $cont = addContinuationsEntry('AJrebootRequest', $cdata, SECINDAY);
                        $text .= getViewRequestHTMLitem('rebootoption', $cont);
                        $cont = addContinuationsEntry('AJshowReinstallRequest', $cdata, SECINDAY);
                        $text .= getViewRequestHTMLitem('reinstalloption', $cont);
                    } else {
                        $text .= getViewRequestHTMLitem('rebootoptiondisable');
                        $text .= getViewRequestHTMLitem('reinstalloptiondisable');
                    }
                    $text .= "       </div>\n";
                    $text .= "     </div>\n";
                    $text .= getViewRequestHTMLitem('timeoutdata', $requests[$i]['id'], $requests[$i]);
                    $text .= "    </TD>\n";
                } else {
                    $text .= "    <TD>";
                    $text .= getViewRequestHTMLitem('timeoutdata', $requests[$i]['id'], $requests[$i]);
                    $text .= "</TD>\n";
                }
            } else {
                $text .= "    <TD></TD>\n";
            }
            # print name of server request
            if ($requests[$i]['server']) {
                if ($requests[$i]['servername'] == '') {
                    $text .= getViewRequestHTMLitem('servername', $requests[$i]['prettyimage']);
                } else {
                    $text .= getViewRequestHTMLitem('servername', $requests[$i]['servername']);
                }
            }
            # print name of image, add (Testing) if it is the test version of an image
            if (!$requests[$i]['server']) {
                $data = array('addtest' => 0);
                if ($requests[$i]["test"]) {
                    $data['addtest'] = 1;
                }
                $text .= getViewRequestHTMLitem('imagename', $requests[$i]['prettyimage'], $data);
            }
            # print start time
            if (!$requests[$i]['server']) {
                $data = array('start' => $requests[$i]['start'], 'requested' => $requests[$i]['daterequested']);
                $text .= getViewRequestHTMLitem('starttime', '', $data);
            }
            # print end time
            $data = array('end' => $requests[$i]['end']);
            $text .= getViewRequestHTMLitem('endtime', '', $data);
            # print date requested
            if (!$requests[$i]['server']) {
                $text .= getViewRequestHTMLitem('requesttime', $requests[$i]['daterequested']);
            }
            # print server request details
            if ($requests[$i]['server']) {
                $data = array('owner' => getUserUnityID($requests[$i]['userid']), 'requesttime' => $requests[$i]['daterequested'], 'admingroup' => $requests[$i]['serveradmingroup'], 'logingroup' => $requests[$i]['serverlogingroup'], 'image' => $requests[$i]['prettyimage'], 'starttime' => $requests[$i]['start']);
                if ($requests[$i]['currstateid'] == 14) {
                    $data['stateid'] = $requests[$i]['laststateid'];
                } else {
                    $data['stateid'] = $requests[$i]['currstateid'];
                }
                $text .= getViewRequestHTMLitem('serverdetails', $requests[$i]['id'], $data);
            }
            if (checkUserHasPerm('View Debug Information')) {
                if (!is_null($requests[$i]['vmhostid'])) {
                    $query = "SELECT c.hostname " . "FROM computer c, " . "vmhost v " . "WHERE v.id = {$requests[$i]['vmhostid']} AND " . "v.computerid = c.id";
                    $qh = doQuery($query, 101);
                    $row = mysql_fetch_assoc($qh);
                    $vmhost = $row['hostname'];
                }
                $text .= "    <TD align=center><a id=\"req{$requests[$i]['id']}\" ";
                $text .= "tabindex=0>{$requests[$i]["id"]}</a>\n";
                $text .= "<div dojoType=\"vcldojo.HoverTooltip\" connectId=\"req{$requests[$i]['id']}\">";
                $text .= "<b>Mgmt node</b>: {$nodes[$requests[$i]["managementnodeid"]]['hostname']}<br>\n";
                $text .= "<b>Computer ID</b>: {$requests[$i]['computerid']}<br>\n";
                $text .= "<b>Comp hostname</b>: {$computers[$requests[$i]["computerid"]]["hostname"]}<br>\n";
                $text .= "<b>Comp IP</b>: {$requests[$i]["IPaddress"]}<br>\n";
                $text .= "<b>Comp State ID</b>: {$computers[$requests[$i]["computerid"]]["stateid"]}<br>\n";
                $text .= "<b>Comp Type</b>: {$requests[$i]['comptype']}<br>\n";
                if (!is_null($requests[$i]['vmhostid'])) {
                    $text .= "<b>VM Host</b>: {$vmhost}<br>\n";
                }
                $text .= "<b>Current State ID</b>: {$requests[$i]["currstateid"]}<br>\n";
                $text .= "<b>Last State ID</b>: {$requests[$i]["laststateid"]}<br>\n";
                $text .= "</div></TD>\n";
            }
            $text .= "  </TR>\n";
            if ($requests[$i]['server']) {
                $server .= $text;
            } elseif ($requests[$i]['forimaging']) {
                $imaging .= $text;
            } elseif ($requests[$i]['longterm']) {
                $long .= $text;
            } else {
                $normal .= $text;
            }
        }
    }
    if (!empty($normal)) {
        if (!empty($imaging) || !empty($long)) {
            $text .= i("You currently have the following <strong>normal</strong> reservations:") . "<br>\n";
        } else {
            $text .= i("You currently have the following normal reservations:") . "<br>\n";
        }
        if ($lengthchanged) {
            $text .= "<font color=red>";
            $text .= i("NOTE: The maximum allowed reservation length for one of these reservations was less than the length you submitted, and the length of that reservation has been adjusted accordingly.");
            $text .= "</font>\n";
        }
        $text .= "<table id=reslisttable summary=\"lists reservations you currently have\" cellpadding=5>\n";
        $text .= "  <TR>\n";
        $text .= "    <TD colspan=3></TD>\n";
        $text .= "    <TH>" . i("Environment") . "</TH>\n";
        $text .= "    <TH>" . i("Starting") . "</TH>\n";
        $text .= "    <TH>" . i("Ending") . "</TH>\n";
        $text .= "    <TH>" . i("Initially requested") . "</TH>\n";
        if (checkUserHasPerm('View Debug Information')) {
            $text .= "    <TH>" . i("Req ID") . "</TH>\n";
        }
        $text .= "  </TR>\n";
        $text .= $normal;
        $text .= "</table>\n";
    }
    if (!empty($imaging)) {
        if (!empty($normal)) {
            $text .= "<hr>\n";
        }
        $text .= i("You currently have the following <strong>imaging</strong> reservations:") . "<br>\n";
        $text .= "<table id=imgreslisttable summary=\"lists imaging reservations you currently have\" cellpadding=5>\n";
        $text .= "  <TR>\n";
        $text .= "    <TD colspan=3></TD>\n";
        $text .= "    <TH>" . i("Environment") . "</TH>\n";
        $text .= "    <TH>" . i("Starting") . "</TH>\n";
        $text .= "    <TH>" . i("Ending") . "</TH>\n";
        $text .= "    <TH>" . i("Initially requested") . "</TH>\n";
        $computers = getComputers();
        if (checkUserHasPerm('View Debug Information')) {
            $text .= "    <TH>Req ID</TH>\n";
        }
        $text .= "  </TR>\n";
        $text .= $imaging;
        $text .= "</table>\n";
    }
    if (!empty($long)) {
        if (!empty($normal) || !empty($imaging)) {
            $text .= "<hr>\n";
        }
        $text .= i("You currently have the following <strong>long term</strong> reservations:") . "<br>\n";
        $text .= "<table id=\"longreslisttable\" summary=\"lists long term reservations you currently have\" cellpadding=5>\n";
        $text .= "  <TR>\n";
        $text .= "    <TD colspan=3></TD>\n";
        $text .= "    <TH>" . i("Environment") . "</TH>\n";
        $text .= "    <TH>" . i("Starting") . "</TH>\n";
        $text .= "    <TH>" . i("Ending") . "</TH>\n";
        $text .= "    <TH>" . i("Initially requested") . "</TH>\n";
        $computers = getComputers();
        if (checkUserHasPerm('View Debug Information')) {
            $text .= "    <TH>Req ID</TH>\n";
        }
        $text .= "  </TR>\n";
        $text .= $long;
        $text .= "</table>\n";
    }
    if (!empty($server)) {
        if (!empty($normal) || !empty($imaging) || !empty($long)) {
            $text .= "<hr>\n";
        }
        $text .= i("You currently have the following <strong>server</strong> reservations:") . "<br>\n";
        $text .= "<table id=\"longreslisttable\" summary=\"lists server reservations you currently have\" cellpadding=5>\n";
        $text .= "  <TR>\n";
        $text .= "    <TD colspan=3></TD>\n";
        $text .= "    <TH>" . i("Name") . "</TH>\n";
        $text .= "    <TH>" . i("Ending") . "</TH>\n";
        $computers = getComputers();
        $text .= "    <TH>" . i("Details") . "</TH>\n";
        if (checkUserHasPerm('View Debug Information')) {
            $text .= "    <TH>" . i("Req ID") . "</TH>\n";
        }
        $text .= "  </TR>\n";
        $text .= $server;
        $text .= "</table>\n";
    }
    # connect div
    if ($connect) {
        $text .= "<br><br>";
        $text .= i("Click the <b>Connect!</b> button to get further information about connecting to the reserved system. You must click the button from a web browser running on the same computer from which you will be connecting to the remote computer; otherwise, you may be denied access to the machine.") . "\n";
    }
    if ($refresh) {
        $text .= "<br><br>";
        $text .= i("This page will automatically update every 20 seconds until the <font color=red><i>Pending...</i></font> reservation is ready.") . "\n";
    }
    if ($failed) {
        $text .= "<br><br>";
        $text .= i("An error has occurred that has kept one of your reservations from being processed. We apologize for any inconvenience this may have caused.") . "\n";
    }
    $cont = addContinuationsEntry('AJviewRequests', array(), SECINDAY);
    $text .= "<INPUT type=hidden id=resRefreshCont value=\"{$cont}\">\n";
    $cont = addContinuationsEntry('AJpreviewClickThrough', array());
    $text .= "<INPUT type=hidden id=previewclickthroughcont value=\"{$cont}\">\n";
    $text .= "</div>\n";
    if ($mode != 'AJviewRequests') {
        $text .= newReservationHTML();
        $text .= newReservationConfigHTML();
        /*$text .= "<div dojoType=dijit.Dialog\n";
        		$text .= "      id=\"imageRevisionDlg\"\n";
        		$text .= "      title=\"" . i("Select Image Revisions") . "\"\n";
        		$text .= "      duration=250\n";
        		$text .= "      draggable=true\n";
        		$text .= "      width=\"50%\"\n";
        		#$text .= "      height=\"80%\">\n";
        		#$text .= "      style=\"height: 80%; width: 50%;\">\n";
        		$text .= "      style=\"width: 50%;\">\n";
        		#$text .= "<div dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\" style=\"width: 100%; height: 90%;\">\n";
        		#$text .= "<div dojoType=\"dijit.layout.ContentPane\" region=\"top\" style=\"height: 25px;\">\n";
        		$text .= i("There are multiple versions of this environment available.");
        		$text .= "<br>" . i("Please select the version you would like to check out:");
        		#$text .= "\n</div>\n"; # ContentPane
        		#$text .= " <div dojoType=\"dijit.layout.ContentPane\" region=\"center\">\n";
        		#$text .= "   <div id=\"imageRevisionContent\"></div>\n";
        		$text .= "   <div id=\"imageRevisionContent\" style=\"height: 85%; overflow: auto;\"></div>\n";
        		#$text .= "</div>\n"; # ContentPane
        		#$text .= " <div dojoType=\"dijit.layout.ContentPane\" region=\"bottom\" style=\"height: 25px;\">\n";
        		$text .= "   <div align=\"center\">\n";
        		$text .= "   <button id=\"imageRevBtn\" dojoType=\"dijit.form.Button\">\n";
        		$text .= "    " . i("Create Reservation") . "\n";
        		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        		$text .= "       submitNewReservation();\n";
        		$text .= "     </script>\n";
        		$text .= "   </button>\n";
        		$text .= "   <button dojoType=\"dijit.form.Button\">\n";
        		$text .= "     " . i("Cancel") . "\n";
        		$text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        		$text .= "       dijit.byId('imageRevisionDlg').hide();\n";
        		$text .= "     </script>\n";
        		$text .= "   </button>\n";
        		$text .= "   </div>\n"; # center
        		#$text .= "</div>\n"; # ContentPane
        		#$text .= "</div>\n"; # BorderContainer
        		$text .= "</div>\n"; # Dialog*/
        $text .= "<div dojoType=dojox.layout.FloatingPane\n";
        $text .= "      id=resStatusPane\n";
        $text .= "      resizable=true\n";
        $text .= "      closable=true\n";
        $text .= "      title=\"" . i("Detailed Reservation Status") . "\"\n";
        $text .= "      style=\"width: 350px; ";
        $text .= "height: 300px; ";
        $text .= "position: absolute; ";
        $text .= "left: 0px; ";
        $text .= "top: 0px; ";
        $text .= "visibility: hidden; ";
        $text .= "border: solid 1px #7EABCD;\"\n";
        $text .= ">\n";
        $text .= "<script type=\"dojo/method\" event=minimize>\n";
        $text .= "  this.hide();\n";
        $text .= "</script>\n";
        $text .= "<script type=\"dojo/method\" event=close>\n";
        $text .= "  this.hide();\n";
        $text .= "  return false;\n";
        $text .= "</script>\n";
        $text .= "<div id=resStatusText></div>\n";
        $text .= "<input type=hidden id=detailreqid value=0>\n";
        $text .= "</div>\n";
        $text .= "<div dojoType=dijit.Dialog\n";
        $text .= "      id=\"endResDlg\"\n";
        $text .= "      title=\"" . i("Delete Reservation") . "\"\n";
        $text .= "      duration=250\n";
        $text .= "      draggable=true\n";
        $text .= "      style=\"width: 315px;\">\n";
        $text .= "   <div id=\"endResDlgContent\"></div>\n";
        $text .= "   <input type=\"hidden\" id=\"endrescont\">\n";
        $text .= "   <input type=\"hidden\" id=\"endresid\">\n";
        $text .= "   <div align=\"center\">\n";
        $text .= "   <button id=\"endResDlgBtn\" dojoType=\"dijit.form.Button\">\n";
        $text .= "    " . i("Delete Reservation") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       submitDeleteReservation();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   <button dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Cancel") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       dijit.byId('endResDlg').hide();\n";
        $text .= "       dojo.byId('endResDlgContent').innerHTML = '';\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   </div>\n";
        $text .= "</div>\n";
        $text .= "<div dojoType=dijit.Dialog\n";
        $text .= "      id=\"remResDlg\"\n";
        $text .= "      title=\"" . i("Remove Reservation") . "\"\n";
        $text .= "      duration=250\n";
        $text .= "      draggable=true>\n";
        $text .= "   <div id=\"remResDlgContent\"></div>\n";
        $text .= "   <input type=\"hidden\" id=\"remrescont\">\n";
        $text .= "   <div align=\"center\">\n";
        $text .= "   <button id=\"remResDlgBtn\" dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Remove Reservation") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       submitRemoveReservation();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   <button dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Cancel") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       dijit.byId('remResDlg').hide();\n";
        $text .= "       dojo.byId('remResDlgContent').innerHTML = '';\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   </div>\n";
        $text .= "</div>\n";
        $text .= "<div dojoType=dijit.Dialog\n";
        $text .= "      id=\"editResDlg\"\n";
        $text .= "      title=\"" . i("Modify Reservation") . "\"\n";
        $text .= "      duration=250\n";
        $text .= "      draggable=true>\n";
        $text .= "    <script type=\"dojo/connect\" event=onHide>\n";
        $text .= "      hideEditResDlg();\n";
        $text .= "    </script>\n";
        $text .= "   <div id=\"editResDlgContent\"></div>\n";
        $text .= "   <input type=\"hidden\" id=\"editrescont\">\n";
        $text .= "   <input type=\"hidden\" id=\"editresid\">\n";
        $text .= "   <div id=\"editResDlgErrMsg\" class=\"rederrormsg\"></div>\n";
        $text .= "   <div align=\"center\">\n";
        $text .= "   <button id=\"editResDlgBtn\" dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Modify Reservation") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       submitEditReservation();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   <button dojoType=\"dijit.form.Button\" id=\"editResCancelBtn\">\n";
        $text .= "     " . i("Cancel") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       dijit.byId('editResDlg').hide();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   </div>\n";
        $text .= "</div>\n";
        $text .= "<div dojoType=dijit.Dialog\n";
        $text .= "      id=\"rebootdlg\"\n";
        $text .= "      title=\"" . i("Reboot Reservation") . "\"\n";
        $text .= "      duration=250\n";
        $text .= "      draggable=true>\n";
        $text .= "    <script type=\"dojo/connect\" event=onHide>\n";
        $text .= "      hideRebootResDlg();\n";
        $text .= "    </script>\n";
        $text .= "   <div id=\"rebootResDlgContent\">";
        $h = i("You can select either a soft or a hard reboot. A soft reboot issues a reboot command to the operating system. A hard reboot is akin to toggling the power switch on a computer. After issuing the reboot, it may take several minutes before the machine is available again. It is also possible that it will not come back up at all. Are you sure you want to continue?");
        $text .= preg_replace("/(.{1,60}([ \n]|\$))/", '\\1<br>', $h);
        $text .= "<br><br></div>\n";
        $text .= "   <div id=\"rebootRadios\" style=\"margin-left: 90px;\">\n";
        $text .= "   <input type=\"radio\" name=\"reboottype\" id=\"softreboot\" checked>\n";
        $text .= "   <label for=\"softreboot\">" . i("Soft Reboot") . "</label><br>\n";
        $text .= "   <input type=\"radio\" name=\"reboottype\" id=\"hardreboot\">\n";
        $text .= "   <label for=\"hardreboot\">" . i("Hard Reboot") . "</label><br><br>\n";
        $text .= "   </div>\n";
        $text .= "   <input type=\"hidden\" id=\"rebootrescont\">\n";
        $text .= "   <div id=\"rebootResDlgErrMsg\" class=\"rederrormsg\"></div>\n";
        $text .= "   <div align=\"center\">\n";
        $text .= "   <button id=\"rebootResDlgBtn\" dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Reboot Reservation") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       submitRebootReservation();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   <button dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Cancel") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       dijit.byId('rebootdlg').hide();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   </div>\n";
        $text .= "</div>\n";
        $text .= "<div dojoType=dijit.Dialog\n";
        $text .= "      id=\"reinstalldlg\"\n";
        $text .= "      title=\"" . i("Reinstall Reservation") . "\"\n";
        $text .= "      duration=250\n";
        $text .= "      draggable=true>\n";
        $text .= "    <script type=\"dojo/connect\" event=onHide>\n";
        $text .= "      hideReinstallResDlg();\n";
        $text .= "    </script>\n";
        $text .= "   <div id=\"reinstallloading\" style=\"text-align: center\">";
        $text .= "<img src=\"themes/{$skin}/css/dojo/images/loading.gif\" ";
        $text .= "style=\"vertical-align: middle;\"> " . i("Loading...") . "</div>\n";
        $text .= "   <div id=\"reinstallResDlgContent\"></div>\n";
        $text .= "   <input type=\"hidden\" id=\"reinstallrescont\">\n";
        $text .= "   <div id=\"reinstallResDlgErrMsg\" class=\"rederrormsg\"></div>\n";
        $text .= "   <div align=\"center\" id=\"reinstallbtns\" class=\"hidden\">\n";
        $text .= "   <button id=\"reinstallResDlgBtn\" dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Reinstall Reservation") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       submitReinstallReservation();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   <button dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Cancel") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       dijit.byId('reinstalldlg').hide();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   </div>\n";
        $text .= "</div>\n";
        $text .= "<div dojoType=dijit.Dialog\n";
        $text .= "      id=\"suggestedTimes\"\n";
        $text .= "      title=\"" . i("Available Times") . "\"\n";
        $text .= "      duration=250\n";
        $text .= "      draggable=true>\n";
        $text .= "   <div id=\"suggestloading\" style=\"text-align: center\">";
        $text .= "<img src=\"themes/{$skin}/css/dojo/images/loading.gif\" ";
        $text .= "style=\"vertical-align: middle;\"> " . i("Loading...") . "</div>\n";
        $text .= "   <div id=\"suggestContent\"></div>\n";
        $text .= "   <input type=\"hidden\" id=\"suggestcont\">\n";
        $text .= "   <input type=\"hidden\" id=\"selectedslot\">\n";
        $text .= "   <div align=\"center\">\n";
        $text .= "   <button id=\"suggestDlgBtn\" dojoType=\"dijit.form.Button\" disabled>\n";
        $text .= "     " . i("Use Selected Time") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       useSuggestedEditSlot();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   <button id=\"suggestDlgCancelBtn\" dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Cancel") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       dijit.byId('suggestDlgBtn').set('disabled', true);\n";
        $text .= "       dojo.removeClass('suggestDlgBtn', 'hidden');\n";
        $text .= "       showDijitButton('suggestDlgBtn');\n";
        $text .= "       dijit.byId('suggestDlgCancelBtn').set('label', '" . i("Cancel") . "');\n";
        $text .= "       dijit.byId('suggestedTimes').hide();\n";
        $text .= "       dojo.byId('suggestContent').innerHTML = '';\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   </div>\n";
        $text .= "</div>\n";
        $text .= "<div dojoType=dijit.Dialog\n";
        $text .= "      id=\"startimagedlg\"\n";
        $text .= "      title=\"" . i("Create / Update Image") . "\"\n";
        $text .= "      duration=250\n";
        $text .= "      draggable=true>\n";
        $text .= "    <script type=\"dojo/connect\" event=onHide>\n";
        $text .= "      hideStartImageDlg();\n";
        $text .= "    </script>\n";
        $text .= "<div id=\"imageendrescontent\">\n";
        $text .= "<H2>" . i("Create / Update an Image") . "</H2>\n";
        $text .= "</div>\n";
        # imageendrescontent
        $text .= "<div id=\"imagekeeprescontent\">\n";
        $text .= "<H2>" . i("Keep Reservation &amp; Create / Update an Image") . "</H2>\n";
        $h = i("This process will create a new image or new revision of the image while allowing you to keep your reservation. The node will be taken <strong>offline</strong> during the image capture process.");
        $h .= "\n \n";
        $h .= "<strong>" . i("NOTE: The same sanitizing that occurs during normal image capture will take place. This includes things such as deleting temporary files, cleaning out firewall rules, removing user home space, and removing user accounts.");
        $h .= "\n</strong> \n";
        $h .= i("After the imaging occurs, you will be able to connect to the reservation again. The image will appear to you as if you had just made a new reservation for it.");
        $h .= "\n \n";
        $text .= preg_replace("/(.{1,80}([ \n]|\$))/", '\\1<br>', $h);
        $text .= "</div>\n";
        # imagekeeprescontent
        $text .= i("Are you creating a new image or updating an existing image?") . "<br><br>\n";
        $text .= "<input type=radio name=imgmode id=newimage value=\"\" checked>\n";
        $text .= "<label for=newimage>" . i("Creating New Image") . "</label><br>\n";
        $text .= "<input type=radio name=imgmode id=updateimage value=\"\">\n";
        $text .= "<label for=updateimage id=\"updateimagelabel\">";
        $text .= i("Update Existing Image") . "</label>";
        $text .= "<br><br>\n";
        $text .= "   <div align=\"center\" id=\"imagebtns\">\n";
        $text .= "   <button id=\"imageDlgBtn\" dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Submit") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       submitCreateUpdateImage();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   <button dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Cancel") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       dijit.byId('startimagedlg').hide();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   </div>\n";
        $text .= "</div>\n";
        $text .= "<div dojoType=dijit.Dialog\n";
        $text .= "      id=\"startimagedisableddlg\"\n";
        $text .= "      title=\"" . i("Create / Update Image") . "\"\n";
        $text .= "      duration=250\n";
        $text .= "      style=\"width: 30%;\"\n";
        $text .= "      draggable=true>\n";
        $text .= "<H2>" . i("Create / Update an Image") . "</H2>\n";
        $text .= i("You cannot create new images from this image because the owner of the image has set \"Users have administrative access\" to No under the Advanced Options of the image.");
        $text .= "<br><br>\n";
        $text .= "   <div align=\"center\">\n";
        $text .= "   <button dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Close") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       dijit.byId('startimagedisableddlg').hide();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   </div>\n";
        $text .= "</div>\n";
        $text .= "<div dojoType=dijit.Dialog\n";
        $text .= "      id=\"connectDlg\"\n";
        $text .= "      title=\"" . i("Connect") . "\"\n";
        $text .= "      duration=250\n";
        $text .= "      autofocus=false\n";
        $text .= "      draggable=true>\n";
        $text .= "   <div dojoType=\"dijit.layout.ContentPane\" id=\"connectDlgContent\" ";
        $text .= "        style=\"overflow: auto; width: 500px;\"></div>\n";
        $text .= "   <div align=\"center\">\n";
        $text .= "   <button dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Close") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       dijit.byId('connectDlg').hide();\n";
        $text .= "       dijit.byId('connectDlgContent').set('content', '');\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   </div>\n";
        $text .= "</div>\n";
        $text .= "<div dojoType=dijit.Dialog\n";
        $text .= "      id=\"timeoutdlg\"\n";
        $text .= "      title=\"" . i("Reservation Timed Out") . "\"\n";
        $text .= "      duration=250\n";
        $text .= "      draggable=false>\n";
        $h = i("This reservation has timed out and is no longer available.");
        $text .= preg_replace("/(.{1,30}([ \n]|\$))/", '\\1<br>', $h);
        $text .= "<br><br>\n";
        $text .= "   <div align=\"center\">\n";
        $text .= "   <button dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Okay") . "\n";
        $text .= "\t   <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       dijit.byId('timeoutdlg').hide();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   </div>\n";
        $text .= "</div>\n";
        $text .= "<input type=hidden id=addresourcecont>\n";
        $obj = new Image();
        $text .= $obj->addEditDialogHTML(1);
        $text .= "<div dojoType=dijit.Dialog\n";
        $text .= "      id=\"updateimagedlg\"\n";
        $text .= "      title=\"" . i("Update Existing Image") . "\"\n";
        $text .= "      duration=250\n";
        $text .= "      draggable=true>\n";
        $text .= "    <script type=\"dojo/connect\" event=onHide>\n";
        $text .= "      hideUpdateImageDlg();\n";
        $text .= "    </script>\n";
        $text .= "   <div id=\"updateimageDlgContent\">\n";
        $text .= "      <h3>" . i("New Revision Comments") . "</h3>\n";
        $h = i("Enter any notes for yourself and other admins about the current state of the image. These are optional and are not visible to end users:");
        $text .= preg_replace("/(.{1,85}([ \n]|\$))/", '\\1<br>', $h);
        $text .= "      <textarea dojoType=\"dijit.form.Textarea\" id=\"newcomments\" ";
        $text .= "      style=\"width: 400px; text-align: left;\">\n\n</textarea>\n";
        $text .= "      <h3>" . i("Previous Revision Comments") . "</h3>\n";
        $text .= "      <div id=\"previouscomments\"></div>\n";
        $text .= "   </div>\n";
        $text .= "   <div align=\"center\">\n";
        $text .= "   <button id=\"updateImageDlgBtn\" dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Submit") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       submitUpdateImage();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   <button dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Cancel") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       dijit.byId('updateimagedlg').hide();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   </div>\n";
        $text .= "</div>\n";
        $text .= "<div dojoType=dijit.Dialog\n";
        $text .= "      id=\"clickthroughdlg\"\n";
        $text .= "      duration=250\n";
        $text .= "      draggable=true>\n";
        $text .= "    <script type=\"dojo/connect\" event=onHide>\n";
        $text .= "      hideClickThroughDlg();\n";
        $text .= "    </script>\n";
        $text .= "   <div id=\"clickthroughDlgContent\">\n";
        $text .= "   </div>\n";
        $text .= "   <div align=\"center\" id=\"imagebtns\">\n";
        $text .= "   <button id=\"clickthroughDlgBtn\" dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("I agree") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       clickThroughAgree();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   <button dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("I do not agree") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       dijit.byId('clickthroughdlg').hide();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   </div>\n";
        $text .= "</div>\n";
        $text .= "<div dojoType=dijit.Dialog\n";
        $text .= "      id=\"clickthroughpreviewdlg\"\n";
        $text .= "      duration=250\n";
        $text .= "      draggable=true>\n";
        $text .= "   <div id=\"clickthroughPreviewDlgContent\"></div>\n";
        $text .= "   <div align=\"center\">\n";
        $text .= "   <button dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Close") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       dijit.byId('clickthroughpreviewdlg').hide();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   </div>\n";
        $text .= "</div>\n";
        $text .= "<div dojoType=dijit.Dialog\n";
        $text .= "      id=\"serverdeletedlg\"\n";
        $text .= "      duration=250\n";
        $text .= "      draggable=true>\n";
        $text .= "   <div id=\"serverDeleteDlgContent\">\n";
        $text .= "   <h2>Confirm Server Delete</h2>\n";
        $text .= "   <span class=\"rederrormsg\"><big>\n";
        $warn = i("WARNING: You are not the owner of this reservation. You have been granted access to manage this reservation by another user. Hover over the details icon to see who the owner is. You should not delete this reservation unless the owner is aware that you are deleting it.");
        $text .= preg_replace("/(.{1,80}([ \n]|\$))/", '\\1<br>', $warn);
        $text .= "   </big></span>\n";
        $text .= "   </div><br>\n";
        $text .= "   <div align=\"center\">\n";
        $text .= "   <input type=\"hidden\" id=\"deletecontholder\">\n";
        $text .= "   <button id=\"serverDeleteDlgBtn\" dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Confirm Delete Reservation") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       endServerReservation();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   <button dojoType=\"dijit.form.Button\">\n";
        $text .= "     " . i("Cancel") . "\n";
        $text .= "     <script type=\"dojo/method\" event=\"onClick\">\n";
        $text .= "       dijit.byId('serverdeletedlg').hide();\n";
        $text .= "     </script>\n";
        $text .= "   </button>\n";
        $text .= "   </div>\n";
        $text .= "</div>\n";
        print $text;
    } else {
        $text = str_replace("\n", ' ', $text);
        $text = str_replace("('", "(\\'", $text);
        $text = str_replace("')", "\\')", $text);
        print "document.body.style.cursor = 'default';";
        if (count($requests) == 0) {
            print "dojo.removeClass('noresspan', 'hidden');";
        } else {
            print "dojo.addClass('noresspan', 'hidden');";
        }
        if ($refresh) {
            print "refresh_timer = setTimeout(resRefresh, 20000);\n";
        }
        print setAttribute('subcontent', 'innerHTML', $text);
        print "AJdojoCreate('subcontent');";
        if ($incPaneDetails) {
            $text = detailStatusHTML($refreqid);
            print setAttribute('resStatusText', 'innerHTML', $text);
        }
        print "checkResGone(" . json_encode($reqids) . ");";
        if ($pendingcnt) {
            print "document.title = '{$pendingcnt} Pending :: VCL :: Virtual Computing Lab';";
        } else {
            print "document.title = 'VCL :: Virtual Computing Lab';";
        }
        return;
    }
}
Example #3
0
function AJrejectBlockAllocationSubmit()
{
    global $mysql_link_vcl;
    $blockid = getContinuationVar('blockid');
    $comments = getContinuationVar('comments');
    $validemail = getContinuationVar('validemail');
    $emailuser = getContinuationVar('emailuser');
    $email = getContinuationVar('email');
    $emailtext = processInputVar('emailtext', ARG_STRING);
    $err = 0;
    if ($email == $emailtext) {
        $errmsg = i("Please include a reason for rejecting the block allocation in the email.");
        $err = 1;
    }
    if (get_magic_quotes_gpc()) {
        $emailtext = stripslashes($emailtext);
    }
    if (!$err && preg_match('/[<>|]/', $emailtext)) {
        if ($validemail) {
            $errmsg = i("<>\\'s and pipes (|) are not allowed in the email text.");
        } else {
            $errmsg = i("<>\\'s and pipes (|) are not allowed in the reject reason.");
        }
        $err = 1;
    }
    if (!$err && !preg_match('/[A-Za-z]{2,}/', $emailtext)) {
        if ($validemail) {
            $errmsg = i("Something must be filled in for the email text.");
        } else {
            $errmsg = i("Something must be filled in for the reject reason.");
        }
        $err = 1;
    }
    if (!$err) {
        # update values for block allocation
        if ($validemail) {
            $esccomments = mysql_real_escape_string("COMMENTS: {$comments}|EMAIL: {$emailtext}");
        } else {
            $esccomments = mysql_real_escape_string("COMMENTS: {$comments}|REJECTREASON: {$emailtext}");
        }
        $query = "UPDATE blockRequest " . "SET name = 'rejected', " . "status = 'rejected', " . "comments = '{$esccomments}' " . "WHERE id = {$blockid}";
        doQuery($query, 101);
        if (!mysql_affected_rows($mysql_link_vcl)) {
            $errmsg = i("Error encountered while updating status of block allocation.");
            $err = 1;
        }
    }
    if ($err) {
        print "alert('{$errmsg}');";
        $cdata = getContinuationVar();
        $cont = addContinuationsEntry('AJrejectBlockAllocationSubmit', $cdata, SECINDAY, 1, 0);
        print "dojo.byId('submitrejectcont').value = '{$cont}';";
        print "document.body.style.cursor = 'default';";
        return;
    }
    # send reject email to requestor
    $message = $emailtext . "\n\nVCL Admins";
    $mailParams = "-f" . ENVELOPESENDER;
    mail($emailuser, i("VCL Block Allocation Rejected"), $message, '', $mailParams);
    print "clearHideConfirmReject();";
    $html = getPendingBlockHTML(1);
    $html = str_replace("\n", '', $html);
    $html = str_replace("'", "\\'", $html);
    $html = preg_replace("/>\\s*</", "><", $html);
    print setAttribute('pendinglist', 'innerHTML', $html);
    print "AJdojoCreate('pendinglist');";
}
Example #4
0
function viewRequests()
{
    global $user, $viewmode, $inContinuation, $mode;
    if ($inContinuation) {
        $lengthchanged = getContinuationVar('lengthchanged', 0);
    } else {
        $lengthchanged = processInputVar('lengthchanged', ARG_NUMERIC, 0);
    }
    $incPaneDetails = processInputVar('incdetails', ARG_NUMERIC, 0);
    $refreqid = processInputVar('reqid', ARG_NUMERIC, 0);
    $requests = getUserRequests("all");
    $images = getImages();
    $computers = getComputers();
    if ($mode != 'AJviewRequests') {
        print "<div id=subcontent>\n";
    }
    $refresh = 0;
    $failed = 0;
    $connect = 0;
    $normal = '';
    $imaging = '';
    $long = '';
    if ($count = count($requests)) {
        $now = time();
        for ($i = 0, $noedit = 0, $text = ''; $i < $count; $i++, $noedit = 0, $text = '') {
            if ($requests[$i]['forcheckout'] == 0 && $requests[$i]['forimaging'] == 0) {
                continue;
            }
            $imageid = $requests[$i]["imageid"];
            $text .= "  <TR valign=top id=reqrow{$requests[$i]['id']}>\n";
            if (requestIsReady($requests[$i])) {
                $connect = 1;
                # request is ready, print Connect! and End buttons
                $cdata = array('requestid' => $requests[$i]['id']);
                $text .= "    <TD>\n";
                $text .= "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                $cont = addContinuationsEntry('connectRequest', $cdata, SECINDAY);
                $text .= "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
                $text .= "      <INPUT type=submit value=\"Connect!\">\n";
                $text .= "      </FORM>\n";
                $text .= "    </TD>\n";
                if ($requests[$i]['forimaging']) {
                    # this is the imaging case, need to do sanity check here for if the request
                    #   state currstateid or laststateid are "inuse", otherwise disable out the
                    #   create image button
                    $noedit = 1;
                    $text .= "    <TD>\n";
                    if ($requests[$i]['currstateid'] == 8 || $requests[$i]['laststateid'] == 8) {
                        # the user has connected successfully so we will allow create image button
                        #   to be displayed
                        $text .= "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                        $cont = addContinuationsEntry('startImage', $cdata);
                        $text .= "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
                        $text .= "      <INPUT type=submit value=\"Create\nImage\">\n";
                        $text .= "      </FORM>\n";
                    }
                    $text .= "    </TD>\n";
                    $text .= "    <TD>\n";
                    $text .= "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                    $cdata = array('requestid' => $requests[$i]['id']);
                    $cont = addContinuationsEntry('confirmDeleteRequest', $cdata, SECINDAY);
                    $text .= "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
                    $text .= "      <INPUT type=submit value=Cancel>\n";
                    $text .= "      </FORM>\n";
                    $text .= "    </TD>\n";
                } else {
                    $text .= "    <TD>\n";
                    $text .= "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                    $cont = addContinuationsEntry('confirmDeleteRequest', $cdata, SECINDAY);
                    $text .= "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
                    $text .= "      <INPUT type=submit value=End>\n";
                    $text .= "      </FORM>\n";
                    $text .= "    </TD>\n";
                }
                $startstamp = datetimeToUnix($requests[$i]["start"]);
            } elseif ($requests[$i]["currstateid"] == 5) {
                # request has failed
                $cdata = array('requestid' => $requests[$i]['id']);
                $text .= "    <TD colspan=2 nowrap>\n";
                $text .= "      <span class=scriptonly>\n";
                $text .= "      <span class=compstatelink>";
                $text .= "<a onClick=\"showResStatusPane({$requests[$i]['id']}); ";
                $text .= "return false;\" href=\"#\">Reservation failed</a></span>\n";
                $text .= "      </span>\n";
                $text .= "      <noscript>\n";
                $text .= "      <span class=scriptoff>\n";
                $text .= "      <span class=compstatelink>";
                $text .= "Reservation failed</span>\n";
                $text .= "      </span>\n";
                $text .= "      </noscript>\n";
                $text .= "    </TD>\n";
                $failed = 1;
                $noedit = 1;
            } elseif (datetimeToUnix($requests[$i]["start"]) < $now) {
                # other cases where the reservation start time has been reached
                if ($requests[$i]["currstateid"] == 12 && $requests[$i]['laststateid'] == 11 || $requests[$i]["currstateid"] == 11 || $requests[$i]["currstateid"] == 14 && $requests[$i]["laststateid"] == 11) {
                    # request has timed out
                    if ($requests[$i]['forimaging']) {
                        $text .= "    <TD colspan=3>\n";
                    } else {
                        $text .= "    <TD colspan=2>\n";
                    }
                    $text .= "      <span class=compstatelink>Reservation has ";
                    $text .= "timed out</span>\n";
                    $noedit = 1;
                    $text .= "    </TD>\n";
                } else {
                    # computer is loading, print Pending... and Delete button
                    $remaining = 1;
                    if ($requests[$i]['forimaging']) {
                        $noedit = 1;
                    }
                    if (isComputerLoading($requests[$i], $computers)) {
                        if (datetimeToUnix($requests[$i]["daterequested"]) >= datetimeToUnix($requests[$i]["start"])) {
                            $startload = datetimeToUnix($requests[$i]["daterequested"]);
                        } else {
                            $startload = datetimeToUnix($requests[$i]["start"]);
                        }
                        $imgLoadTime = getImageLoadEstimate($imageid);
                        if ($imgLoadTime == 0) {
                            $imgLoadTime = $images[$imageid]['reloadtime'] * 60;
                        }
                        $tmp = ($imgLoadTime - ($now - $startload)) / 60;
                        $remaining = sprintf("%d", $tmp) + 1;
                        if ($remaining < 1) {
                            $remaining = 1;
                        }
                    }
                    # computer is loading, print Pending... and Delete button
                    if ($requests[$i]['forimaging']) {
                        $text .= "    <TD colspan=2>\n";
                    } else {
                        $text .= "    <TD>\n";
                    }
                    $text .= "      <span class=scriptonly>\n";
                    $text .= "      <span class=compstatelink><i>";
                    $text .= "<a onClick=\"showResStatusPane({$requests[$i]['id']}); ";
                    $text .= "return false;\" href=\"#\">Pending...</a></i></span>";
                    $text .= "      </span>\n";
                    $text .= "      <noscript>\n";
                    $text .= "      <span class=scriptoff>\n";
                    $text .= "      <span class=compstatelink>";
                    $text .= "<i>Pending...</i></span>\n";
                    $text .= "      </span>\n";
                    $text .= "      </noscript>\n";
                    $text .= "<br>Est:&nbsp;{$remaining}&nbsp;min remaining\n";
                    $refresh = 1;
                    $text .= "    </TD>\n";
                    $text .= "    <TD>\n";
                    $text .= "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                    $cdata = array('requestid' => $requests[$i]['id']);
                    $cont = addContinuationsEntry('confirmDeleteRequest', $cdata, SECINDAY);
                    $text .= "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
                    $text .= "      <INPUT type=submit value=Delete>\n";
                    $text .= "      </FORM>\n";
                    $text .= "    </TD>\n";
                }
            } else {
                # reservation is in the future
                $text .= "    <TD></TD>\n";
                $text .= "    <TD>\n";
                $text .= "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                $cdata = array('requestid' => $requests[$i]['id']);
                $cont = addContinuationsEntry('confirmDeleteRequest', $cdata, SECINDAY);
                $text .= "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
                $text .= "      <INPUT type=submit value=Delete>\n";
                $text .= "      </FORM>\n";
                $text .= "    </TD>\n";
            }
            if (!$noedit) {
                # print edit button
                $text .= "    <TD align=right>\n";
                $text .= "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                $cdata = array('requestid' => $requests[$i]['id']);
                $cont = addContinuationsEntry('editRequest', $cdata);
                $text .= "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
                $text .= "      <INPUT type=submit value=Edit>\n";
                $text .= "      </FORM>\n";
                $text .= "    </TD>\n";
            } elseif ($requests[$i]['forimaging'] == 0) {
                $text .= "    <TD></TD>\n";
            }
            # print name of image, add (Testing) if it is the test version of an image
            $text .= "    <TD>" . str_replace("'", "&#39;", $requests[$i]["prettyimage"]);
            if ($requests[$i]["test"]) {
                $text .= " (Testing)";
            }
            $text .= "</TD>\n";
            # print start time
            if (datetimeToUnix($requests[$i]["start"]) < datetimeToUnix($requests[$i]["daterequested"])) {
                $text .= "    <TD>" . prettyDatetime($requests[$i]["daterequested"]) . "</TD>\n";
            } else {
                $text .= "    <TD>" . prettyDatetime($requests[$i]["start"]) . "</TD>\n";
            }
            # print end time
            $text .= "    <TD>" . prettyDatetime($requests[$i]["end"]) . "</TD>\n";
            # print date requested
            $text .= "    <TD>" . prettyDatetime($requests[$i]["daterequested"]) . "</TD>\n";
            if ($viewmode == ADMIN_DEVELOPER) {
                $text .= "    <TD align=center>" . $requests[$i]["id"] . "</TD>\n";
                $text .= "    <TD align=center>" . $requests[$i]["computerid"] . "</TD>\n";
                $text .= "    <TD>" . $requests[$i]["IPaddress"] . "</TD>\n";
                $text .= "    <TD align=center>" . $requests[$i]["currstateid"];
                $text .= "</TD>\n";
                $text .= "    <TD align=center>" . $requests[$i]["laststateid"];
                $text .= "</TD>\n";
                $text .= "    <TD align=center>";
                $text .= $computers[$requests[$i]["computerid"]]["stateid"] . "</TD>\n";
            }
            $text .= "  </TR>\n";
            if ($requests[$i]['forimaging']) {
                $imaging .= $text;
            } elseif ($requests[$i]['longterm']) {
                $long .= $text;
            } else {
                $normal .= $text;
            }
        }
    }
    $text = "<H2>Current Reservations</H2>\n";
    if (!empty($normal)) {
        if (!empty($imaging) || !empty($long)) {
            $text .= "You currently have the following <strong>normal</strong> reservations:<br>\n";
        } else {
            $text .= "You currently have the following normal reservations:<br>\n";
        }
        if ($lengthchanged) {
            $text .= "<font color=red>NOTE: The maximum allowed reservation ";
            $text .= "length for one of these reservations was less than the ";
            $text .= "length you submitted, and the length of that reservation ";
            $text .= "has been adjusted accordingly.</font>\n";
        }
        $text .= "<table id=reslisttable summary=\"lists reservations you currently have\" cellpadding=5>\n";
        $text .= "  <TR>\n";
        $text .= "    <TD colspan=3></TD>\n";
        $text .= "    <TH>Environment</TH>\n";
        $text .= "    <TH>Starting</TH>\n";
        $text .= "    <TH>Ending</TH>\n";
        $text .= "    <TH>Initially requested</TH>\n";
        if ($viewmode == ADMIN_DEVELOPER) {
            $text .= "    <TH>Req ID</TH>\n";
            $text .= "    <TH>Comp ID</TH>\n";
            $text .= "    <TH>IP address</TH>\n";
            $text .= "    <TH>Current State</TH>\n";
            $text .= "    <TH>Last State</TH>\n";
            $text .= "    <TH>Computer State</TH>\n";
        }
        $text .= "  </TR>\n";
        $text .= $normal;
        $text .= "</table>\n";
    }
    if (!empty($imaging)) {
        if (!empty($normal)) {
            $text .= "<hr>\n";
        }
        $text .= "You currently have the following <strong>imaging</strong> reservations:<br>\n";
        $text .= "<table id=imgreslisttable summary=\"lists imaging reservations you currently have\" cellpadding=5>\n";
        $text .= "  <TR>\n";
        $text .= "    <TD colspan=3></TD>\n";
        $text .= "    <TH>Environment</TH>\n";
        $text .= "    <TH>Starting</TH>\n";
        $text .= "    <TH>Ending</TH>\n";
        $text .= "    <TH>Initially requested</TH>\n";
        $computers = getComputers();
        if ($viewmode == ADMIN_DEVELOPER) {
            $text .= "    <TH>Req ID</TH>\n";
            $text .= "    <TH>Comp ID</TH>\n";
            $text .= "    <TH>IP address</TH>\n";
            $text .= "    <TH>Current State</TH>\n";
            $text .= "    <TH>Last State</TH>\n";
            $text .= "    <TH>Computer State</TH>\n";
        }
        $text .= "  </TR>\n";
        $text .= $imaging;
        $text .= "</table>\n";
    }
    if (!empty($long)) {
        if (!empty($normal) || !empty($imaging)) {
            $text .= "<hr>\n";
        }
        $text .= "You currently have the following <strong>long term</strong> reservations:<br>\n";
        $text .= "<table id=\"longreslisttable\" summary=\"lists long term reservations you currently have\" cellpadding=5>\n";
        $text .= "  <TR>\n";
        $text .= "    <TD colspan=3></TD>\n";
        $text .= "    <TH>Environment</TH>\n";
        $text .= "    <TH>Starting</TH>\n";
        $text .= "    <TH>Ending</TH>\n";
        $text .= "    <TH>Initially requested</TH>\n";
        $computers = getComputers();
        if ($viewmode == ADMIN_DEVELOPER) {
            $text .= "    <TH>Req ID</TH>\n";
            $text .= "    <TH>Comp ID</TH>\n";
            $text .= "    <TH>IP address</TH>\n";
            $text .= "    <TH>Current State</TH>\n";
            $text .= "    <TH>Last State</TH>\n";
            $text .= "    <TH>Computer State</TH>\n";
        }
        $text .= "  </TR>\n";
        $text .= $long;
        $text .= "</table>\n";
    }
    # connect div
    if ($connect) {
        $text .= "<br><br>Click the <strong>";
        $text .= "Connect!</strong> button to get further ";
        $text .= "information about connecting to the reserved system. You must ";
        $text .= "click the button from a web browser running on the same computer ";
        $text .= "from which you will be connecting to the remote computer; ";
        $text .= "otherwise, you may be denied access to the machine.\n";
    }
    if ($refresh) {
        $text .= "<br><br>This page will automatically update ";
        $text .= "every 20 seconds until the <font color=red><i>Pending...</i>";
        #$text .= "</font> reservation is ready.<br></div>\n";
        $text .= "</font> reservation is ready.\n";
        $cont = addContinuationsEntry('AJviewRequests', $cdata, SECINDAY);
        $text .= "<INPUT type=hidden id=resRefreshCont value=\"{$cont}\">\n";
    }
    if ($failed) {
        $text .= "<br><br>An error has occurred that has kept one of your reservations ";
        $text .= "from being processed. We apologize for any inconvenience ";
        $text .= "this may have caused.\n";
        if (!$refresh) {
            $cont = addContinuationsEntry('AJviewRequests', $cdata, SECINDAY);
            $text .= "<INPUT type=hidden id=resRefreshCont value=\"{$cont}\">\n";
        }
    }
    if (empty($normal) && empty($imaging) && empty($long)) {
        $text .= "You have no current reservations.<br>\n";
    }
    $text .= "</div>\n";
    if ($mode != 'AJviewRequests') {
        if ($refresh || $failed) {
            $text .= "<div dojoType=FloatingPane\n";
            $text .= "      id=resStatusPane\n";
            $text .= "      constrainToContainer=false\n";
            $text .= "      hasShadow=true\n";
            $text .= "      resizable=true\n";
            $text .= "      windowState=minimized\n";
            $text .= "      displayMinimizeAction=true\n";
            $text .= "      style=\"width: 350px; height: 280px; position: absolute; left: 130; top: 0px;\"\n";
            $text .= ">\n";
            $text .= "<div id=resStatusText></div>\n";
            $text .= "<input type=hidden id=detailreqid value=0>\n";
            $text .= "</div>\n";
            $text .= "<script type=\"text/javascript\">\n";
            $text .= "dojo.addOnLoad(showScriptOnly);\n";
            $text .= "dojo.byId('resStatusPane').title = \"Detailed Reservation Status\";\n";
            $text .= "</script>\n";
        }
        print $text;
    } else {
        $text = str_replace("\n", ' ', $text);
        if ($refresh) {
            print "refresh_timer = setTimeout(resRefresh, 20000);\n";
        }
        print setAttribute('subcontent', 'innerHTML', $text);
        print "AJdojoCreate('subcontent');";
        if ($incPaneDetails) {
            $text = detailStatusHTML($refreqid);
            print setAttribute('resStatusText', 'innerHTML', $text);
        }
        dbDisconnect();
        exit;
    }
}
Example #5
0
function siteMaintenance()
{
    $update = getContinuationVar('update', 0);
    $items = getMaintItems();
    $rt = '';
    if (!$update) {
        $rt .= "<h2>Site Maintenance</h2>\n";
        $rt .= "<div id=\"maintenancediv\">\n";
    }
    $rt .= "<button dojoType=\"dijit.form.Button\" type=\"button\">\n";
    $rt .= "  Schedule Site Maintenance\n";
    $rt .= "  <script type=\"dojo/method\" event=\"onClick\">\n";
    $cont = addContinuationsEntry('AJcreateSiteMaintenance', array('update' => 1));
    $rt .= "    showAddSiteMaintenance('{$cont}');\n";
    $rt .= "  </script>\n";
    $rt .= "</button><br>\n";
    if (count($items)) {
        $rt .= "<table>\n";
        $rt .= "<tr>\n";
        $rt .= "<td colspan=2></td>\n";
        $rt .= "<th style=\"vertical-align: bottom;\">Start</th>\n";
        $rt .= "<th style=\"vertical-align: bottom;\">End</th>\n";
        $rt .= "<th style=\"vertical-align: bottom;\">Owner</th>\n";
        $rt .= "<th style=\"vertical-align: bottom;\">Created</th>\n";
        $rt .= "<th style=\"vertical-align: bottom;\">Reason <small>(hover for more)</small></th>\n";
        $rt .= "<th style=\"vertical-align: bottom;\">User Message <small>(hover for more)</small></th>\n";
        $rt .= "<th style=\"vertical-align: bottom;\">Inform Hours Ahead</th>\n";
        $rt .= "<th style=\"vertical-align: bottom;\">Allow Reservations</th>\n";
        $rt .= "</tr>\n";
        foreach ($items as $item) {
            $tmp = datetimeToUnix($item['start']);
            $start = date('g:i&\\n\\b\\s\\p;A n/j/Y', $tmp);
            $tmp = datetimeToUnix($item['end']);
            $end = date('g:i&\\n\\b\\s\\p;A n/j/Y', $tmp);
            $tmp = datetimeToUnix($item['created']);
            $created = date('g:i&\\n\\b\\s\\p;A n/j/Y', $tmp);
            $rt .= "<tr>\n";
            $rt .= "<td>\n";
            $rt .= "<button dojoType=\"dijit.form.Button\" type=\"button\">\n";
            $rt .= "  Edit\n";
            $rt .= "  <script type=\"dojo/method\" event=\"onClick\">\n";
            $data = array('id' => $item['id']);
            $cont = addContinuationsEntry('AJgetSiteMaintenanceData', $data);
            $rt .= "    showEditSiteMaintenance('{$cont}');\n";
            $rt .= "  </script>\n";
            $rt .= "</button>\n";
            $rt .= "</td>\n";
            $rt .= "<td>\n";
            $rt .= "<button dojoType=\"dijit.form.Button\" type=\"button\">\n";
            $rt .= "  Delete\n";
            $rt .= "  <script type=\"dojo/method\" event=\"onClick\">\n";
            $cont = addContinuationsEntry('AJgetDelSiteMaintenanceData', $data);
            $rt .= "    confirmDeleteSiteMaintenance('{$cont}');\n";
            $rt .= "  </script>\n";
            $rt .= "</button>\n";
            $rt .= "</td>\n";
            $rt .= "<td align=center>{$start}</td>\n";
            $rt .= "<td align=center>{$end}</td>\n";
            $rt .= "<td align=center>{$item['owner']}</td>\n";
            $rt .= "<td align=center>{$created}</td>\n";
            if (strlen($item['reason']) < 30) {
                $rt .= "<td align=center>{$item['reason']}</td>\n";
            } else {
                $rt .= "<td align=center>\n";
                $reason = substr($item['reason'], 0, 30) . '...';
                $rt .= "  <span id=\"morereason\">{$reason}</span>\n";
                $rt .= "  <div dojoType=\"dijit.Tooltip\" connectId=\"morereason\">\n";
                $reason = preg_replace("/(.{1,50}([ \n]|\$))/", '\\1<br>', $item['reason']);
                $reason = preg_replace("/\n<br>\n/", "<br><br>\n", $reason);
                $rt .= "{$reason}</div>\n";
                $rt .= "</td>\n";
            }
            if (strlen($item['usermessage']) < 30) {
                $rt .= "<td align=center>{$item['usermessage']}</td>\n";
            } else {
                $rt .= "<td align=center>\n";
                $msg = substr($item['usermessage'], 0, 30) . '...';
                $rt .= "  <span id=\"moreusermsg\">{$msg}</span>\n";
                $rt .= "  <div dojoType=\"dijit.Tooltip\" connectId=\"moreusermsg\">\n";
                $msg = preg_replace("/(.{1,50}([ \n]|\$))/", "<br>", $item['usermessage']);
                $msg = preg_replace('/\\n<br>\\n/', "<br><br>\n", $msg);
                $rt .= "{$msg}</div>\n";
                $rt .= "</td>\n";
            }
            $hours = $item['informhoursahead'] % 24;
            if ($hours == 1) {
                $hours = (int) ($item['informhoursahead'] / 24) . " days, 1 hour";
            } else {
                $hours = (int) ($item['informhoursahead'] / 24) . " days, {$hours} hours";
            }
            $rt .= "<td align=center>{$hours}</td>\n";
            if ($item['allowreservations']) {
                $rt .= "<td align=center>Yes</td>\n";
            } else {
                $rt .= "<td align=center>No</td>\n";
            }
            $rt .= "</tr>\n";
        }
        $rt .= "</table>\n";
    }
    if ($update) {
        $send = str_replace("\n", '', $rt);
        $send = str_replace("'", "\\'", $send);
        $send = preg_replace("/>\\s*</", "><", $send);
        print setAttribute('maintenancediv', 'innerHTML', $send);
        print "AJdojoCreate('maintenancediv');";
        return;
    }
    print $rt;
    print "</div>\n";
    # end maintenancediv
    print "<div id=\"editDialog\" dojoType=\"dijit.Dialog\" autofocus=\"false\">\n";
    print "<h2><span id=\"editheader\"></span></h2>\n";
    print "<span id=\"edittext\"></span><br><br>\n";
    print "<table summary=\"\">\n";
    print "  <tr>\n";
    print "    <th align=\"right\">Start:</th>\n";
    print "    <td>\n";
    print "      <div type=\"text\" id=\"starttime\" dojoType=\"dijit.form.TimeTextBox\" ";
    print "required=\"true\" style=\"width: 80px\"></div>\n";
    print "      <div type=\"text\" id=\"startdate\" dojoType=\"dijit.form.DateTextBox\" ";
    print "required=\"true\" style=\"width: 100px\"></div>\n";
    print "    </td>\n";
    print "  </tr>\n";
    print "  <tr>\n";
    print "    <th align=\"right\">End:</th>\n";
    print "    <td>\n";
    print "      <div type=\"text\" id=\"endtime\" dojoType=\"dijit.form.TimeTextBox\" ";
    print "required=\"true\" style=\"width: 80px\"></div>\n";
    print "      <div type=\"text\" id=\"enddate\" dojoType=\"dijit.form.DateTextBox\" ";
    print "required=\"true\" style=\"width: 100px\"></div>\n";
    print "    </td>\n";
    print "  </tr>\n";
    print "  <tr valign=\"top\">\n";
    print "    <th align=\"right\">Inform Hours Ahead:</th>\n";
    print "    <td>\n";
    print "      <input dojoType=\"dijit.form.NumberSpinner\"\n";
    print "             constraints=\"{min:1,max:65535}\"\n";
    print "             maxlength=\"3\"\n";
    print "             id=\"hoursahead\"\n";
    print "             format=\"updateDaysHours\"\n";
    print "             required=\"true\"\n";
    print "             style=\"width: 70px\">\n";
    print "      <span id=dayshours></span>\n";
    print "    </td>\n";
    print "  </tr>\n";
    print "  <tr valign=\"top\">\n";
    print "    <th align=\"right\">Allow Reservations:</th>\n";
    print "    <td>\n";
    print "      <select id=allowreservations dojoType=\"dijit.form.Select\">";
    print "        <option value=\"1\">Yes</option>\n";
    print "        <option value=\"0\">No</option>\n";
    print "      </select>\n";
    print "    </td>\n";
    print "  </tr>\n";
    print "</table>\n";
    print "<b>Reason</b> (this is not displayed to any users and is just for your records):<br>\n";
    print "<textarea id=\"reason\" dojoType=\"dijit.form.Textarea\" style=\"width: 400px;\">\n";
    print "</textarea><br>\n";
    print "<b>User Message</b> (this will be displayed on the site during the maintenance window):<br>\n";
    print "<textarea id=\"usermessage\" dojoType=\"dijit.form.Textarea\" style=\"width: 400px;\">\n";
    print "</textarea>\n";
    print "<input type=\"hidden\" id=\"submitcont\">\n";
    print "<div align=\"center\">\n";
    print "<button dojoType=\"dijit.form.Button\" type=\"button\" id=\"editsubmitbtn\">\n";
    print "  Save Changes\n";
    print "  <script type=\"dojo/method\" event=\"onClick\">\n";
    print "    editSubmit();\n";
    print "  </script>\n";
    print "</button>\n";
    print "<button dojoType=\"dijit.form.Button\" type=\"button\">\n";
    print "  Cancel\n";
    print "  <script type=\"dojo/method\" event=\"onClick\">\n";
    print "    clearEdit();\n";
    print "  </script>\n";
    print "</button>\n";
    print "</div>\n";
    print "</div>\n";
    # edit dialog
    print "<div id=\"confirmDialog\" dojoType=\"dijit.Dialog\" title=\"Delete Site Maintenance\">\n";
    print "<h2>Delete Site Maintenance</h2>\n";
    print "Click <b>Delete Entry</b> to delete this site maintenance entry<br><br>\n";
    print "<table summary=\"\">\n";
    print "  <tr>\n";
    print "    <th align=\"right\">Start:</th>\n";
    print "    <td><span id=\"start\"></span></td>\n";
    print "  </tr>\n";
    print "  <tr>\n";
    print "    <th align=\"right\">End:</th>\n";
    print "    <td><span id=\"end\"></span></td>\n";
    print "  </tr>\n";
    print "  <tr>\n";
    print "    <th align=\"right\">Owner:</th>\n";
    print "    <td><span id=\"owner\"></span></td>\n";
    print "  </tr>\n";
    print "  <tr>\n";
    print "    <th align=\"right\">Created:</th>\n";
    print "    <td><span id=\"created\"></span></td>\n";
    print "  </tr>\n";
    print "  <tr valign=\"top\">\n";
    print "    <th align=\"right\">Inform Hours Ahead:</th>\n";
    print "    <td><span id=\"informhoursahead\"></span></td>\n";
    print "  </tr>\n";
    print "  <tr valign=\"top\">\n";
    print "    <th align=\"right\">Allow Reservations:</th>\n";
    print "    <td><span id=\"delallowreservations\"></span></td>\n";
    print "  </tr>\n";
    print "  <tr valign=top>\n";
    print "    <th align=\"right\">Reason:</th>\n";
    print "    <td><span id=\"delreason\"></span></td>\n";
    print "  </tr>\n";
    print "  <tr valign=top>\n";
    print "    <th align=\"right\">User Message:</th>\n";
    print "    <td><span id=\"delusermessage\"></span></td>\n";
    print "  </tr>\n";
    print "</table>\n";
    print "<input type=\"hidden\" id=\"delsubmitcont\">\n";
    print "<div align=\"center\">\n";
    print "<button dojoType=\"dijit.form.Button\" type=\"button\">\n";
    print "  Delete Entry\n";
    print "  <script type=\"dojo/method\" event=\"onClick\">\n";
    print "    deleteSiteMaintenance();\n";
    print "  </script>\n";
    print "</button>\n";
    print "<button dojoType=\"dijit.form.Button\" type=\"button\">\n";
    print "  Cancel\n";
    print "  <script type=\"dojo/method\" event=\"onClick\">\n";
    print "    dijit.byId('confirmDialog').hide();\n";
    print "  </script>\n";
    print "</button>\n";
    print "</div>\n";
    print "</div>\n";
    # confirm dialog
}
 function enviar_error($t_cont, $msjE, $target, $request, $response)
 {
     request . setAttribute("error", msjE);
     request . setAttribute("t_cont", t_cont);
     // 		RequestDispatcher rd = getServletContext().getRequestDispatcher(target);
     $rd = getServletContext() . getRequestDispatcher(target);
     if (rd != null) {
         if (!response . isCommitted()) {
             response . resetBuffer();
             rd . forward(request, response);
         } else {
             System . err . printf("error en redireccion. target: %s Error original: %s\n", target, msjE);
         }
     } else {
         System . err . printf("error en redireccion. El RequestDispatcher es nulo. target: %s Error original: %s\n", target, msjE);
     }
 }
Example #7
0
 function unsetAttribute($name)
 {
     setAttribute($name, NULL);
 }
Example #8
0
function AJsubmitAddResourcePriv()
{
    global $user;
    $node = processInputVar("activeNode", ARG_NUMERIC);
    if (!checkUserHasPriv("resourceGrant", $user["id"], $node)) {
        $text = "You do not have rights to add new resource groups at this node.";
        print "addUserGroupPaneHide(); ";
        print "alert('{$text}');";
        dbDisconnect();
        exit;
    }
    $newgroupid = processInputVar("newgroupid", ARG_NUMERIC);
    # FIXME validate newgroupid
    $perms = explode(':', processInputVar('perms', ARG_STRING));
    $privtypes = array("block", "cascade", "available", "administer", "manageGroup");
    $newgroupprivs = array();
    foreach ($privtypes as $type) {
        if (in_array($type, $perms)) {
            array_push($newgroupprivs, $type);
        }
    }
    if (empty($newgroupprivs) || count($newgroupprivs) == 1 && in_array("cascade", $newgroupprivs)) {
        $text = "<font color=red>No resource group privileges were specified</font>";
        print setAttribute('addResourceGroupPrivStatus', 'innerHTML', $text);
        dbDisconnect();
        exit;
    }
    updateResourcePrivs($newgroupid, $node, $newgroupprivs, array());
    clearPrivCache();
    print "addResourceGroupPaneHide(); ";
    print "refreshPerms(); ";
    dbDisconnect();
    exit;
}
 }
 //echo 'template version: '.$root->getAttribute('template_version');
 //Step 3: Fill in <teiHeader>
 //Step 3.1 <fileDesc><titleStmt><title><!-- Insert Audio File INFO here --> Transcription</title>
 $titleValue = $projectID . ' ' . $informantID . ' ' . $reelID . ' ' . $regionID;
 setValue('//teiHeader/fileDesc/titleStmt/title', $titleValue);
 //Step 3.2 <fileDesc><extent><!-- Duration of interview --></extent>
 $durationValue = $_POST['mediaDuration'];
 setValue('//teiHeader/fileDesc/extent', durationSecondsToHrsMinSec($durationValue));
 //Step 3.3 <fileDesc><sourceDesc><recordingStmt><recording type="audio" corresp=""/> File path should be used for correspondence attribute.
 setAttribute('//teiHeader/fileDesc/sourceDesc/recordingStmt/recording', 'corresp', $_POST['mediaPath']);
 //Step 3.4  <revisionDesc> insert <change who="first and last name" affiliation="institution name" contact="e-mail address" when="month/day/year" >Transcribed interview audio.</change>
 setAttribute('//teiHeader/revisionDesc/change', 'who', $scribeName);
 setAttribute('//teiHeader/revisionDesc/change', 'affiliation', $scribeInstitution);
 setAttribute('//teiHeader/revisionDesc/change', 'contact', $scribeEmail);
 setAttribute('//teiHeader/revisionDesc/change', 'when', date("m/d/Y"));
 if ($scribeComments != "") {
     setValue('//teiHeader/revisionDesc/change', $scribeComments, true);
 }
 //Step 4: Fill in <body>
 $bodyElement;
 $bodyNodeset = $xpath->query('//text/body');
 if ($bodyNodeset->length > 0) {
     $bodyElement = $bodyNodeset->item(0);
 }
 //...Timeline
 /*  <timeline origin="#TS-p1" unit="s">
 					<when xml:id="TS-p1" absolute="00:00:00"/>
 					<when xml:id="TS-p2" interval="5.0" since="TS-p1"/>
 					<when xml:id="TS-p3" interval="5.0" since="TS-p2"/>
 					-- the segments would be labeled going forward according to however many we have
            changeAttribut($att_id, $bezeichnung, $beschreibung);
        } else {
            $nachricht = "Die Bezeichnung muss eingegeben werden.";
            $nachricht = getUebersetzung($nachricht, $sprache, $link);
            $fehler = true;
        }
    }
    $bezeichnung = "";
    $beschreibung = "";
    if (isset($_POST["bezeichnung_neu"])) {
        $bezeichnung = $_POST["bezeichnung_neu"];
    }
    if (isset($_POST["beschreibung_neu"])) {
        $beschreibung = $_POST["beschreibung_neu"];
    }
    if (!empty($bezeichnung)) {
        setAttribute($bezeichnung, $beschreibung);
    }
    //in der gesamtübersicht anzeigen?
    $showInGesamtuebersicht = "false";
    if (isset($_POST["showInGesamtuebersicht"]) && $_POST["showInGesamtuebersicht"] == "true") {
        $showInGesamtuebersicht = "true";
    }
    setProperty(SHOW_ZIMMER_ATTRIBUTE_GESAMTUEBERSICHT, $showInGesamtuebersicht, $unterkunft_id, $link);
    if ($fehler != true) {
        $nachricht = "Die Attribute wurden erfolgreich gespeichert.";
        $nachricht = getUebersetzung($nachricht, $sprache, $link);
    }
    include_once "./attributeHinzufuegen.php";
    exit;
}
Example #11
0
<?php

$title = $_POST["title"];
try {
    // Connect to DB and set error modes.
    $db = new PDO('sqlite.path/to.db');
    $db = setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    // Insert thread using SQLite syntax.
    $db->exec("insert into threads values (threadID, timeCreated, '{$_POST['title']}', gameMaster, forumID)");
    // Disconnect from DB.
    $db = NULL;
    echo "<br/>";
    echo "Thread successfully created.";
} catch (PDOException $e) {
    echo "<br/>";
    echo "Exception: " . $e->getMessage();
}
Example #12
0
<?php

function setAttribute()
{
    if (($v_size = func_num_args()) == 0) {
        return true;
    }
    $v_att_list =& func_get_args();
    return true;
}
setAttribute('a');
Example #13
0
            if (strtolower($answer) == 'y') {
                setAttribute($moduleDir . $k, 'Access', $v);
            }
        } else {
            $opts = "";
            foreach ($res_acts as $i => $tmp) {
                $r = $tmp[0];
                $a = $tmp[1];
                $opts .= "\n   {$i}. " . $r . "." . $a;
            }
            echo " - {$k}";
            echo $opts;
            echo "\n   Please select one? ";
            $answer = trim(fgets(STDIN));
            if (isset($res_acts[$answer])) {
                setAttribute($moduleDir . $k, 'Access', $r . "." . $a);
            }
        }
    }
}
function setAttribute($xmlfile, $attrName, $attrVal)
{
    $doc = new DomDocument();
    $doc->load($xmlfile);
    $elem = $doc->documentElement;
    $elem->setAttribute($attrName, $attrVal);
    // save xml file
    $doc->formatOutput = true;
    $doc->save($xmlfile);
}
function list_mod_accesses($moduleDir)
Example #14
0
function AJsubmitAddResourcePriv()
{
    global $user;
    $node = processInputVar("activeNode", ARG_NUMERIC);
    if (!checkUserHasPriv("resourceGrant", $user["id"], $node)) {
        $text = "You do not have rights to add new resource groups at this node.";
        print "addResourceGroupPaneHide(); ";
        print "alert('{$text}');";
        return;
    }
    $newgroupid = processInputVar("newgroupid", ARG_NUMERIC);
    $privs = array("computerAdmin", "mgmtNodeAdmin", "imageAdmin", "scheduleAdmin", "serverProfileAdmin");
    $resourcegroups = getUserResources($privs, array("manageGroup"), 1);
    $groupdata = getResourceGroups('', $newgroupid);
    if (empty($groupdata)) {
        $text = "Invalid resource group submitted.";
        print "addResourceGroupPaneHide(); ";
        print "alert('{$text}');";
        return;
    }
    list($newtype, $tmp) = explode('/', $groupdata[$newgroupid]['name']);
    if (!array_key_exists($newgroupid, $resourcegroups[$newtype])) {
        $text = "You do not have rights to manage the specified resource group.";
        print "addResourceGroupPaneHide(); ";
        print "alert('{$text}');";
        return;
    }
    $perms = explode(':', processInputVar('perms', ARG_STRING));
    $privtypes = getResourcePrivs();
    $newgroupprivs = array();
    foreach ($privtypes as $type) {
        if (in_array($type, $perms)) {
            array_push($newgroupprivs, $type);
        }
    }
    if (empty($newgroupprivs) || count($newgroupprivs) == 1 && in_array("cascade", $newgroupprivs)) {
        $text = "<font color=red>No resource group privileges were specified</font>";
        print setAttribute('addResourceGroupPrivStatus', 'innerHTML', $text);
        return;
    }
    updateResourcePrivs($newgroupid, $node, $newgroupprivs, array());
    clearPrivCache();
    print "refreshPerms(); ";
    print "addResourceGroupPaneHide(); ";
}