Beispiel #1
0
function AJeditRequest()
{
    global $submitErr, $user;
    $requestid = getContinuationVar('requestid', 0);
    $request = getRequestInfo($requestid, 1);
    # check to see if reservation exists
    if (is_null($request) || $request['stateid'] == 11 || $request['stateid'] == 12 || $request['stateid'] == 14 && ($request['laststateid'] == 11 || $request['laststateid'] == 12)) {
        sendJSON(array('status' => 'resgone'));
        return;
    }
    $unixstart = datetimeToUnix($request["start"]);
    $unixend = datetimeToUnix($request["end"]);
    $duration = $unixend - $unixstart;
    $now = time();
    $maxtimes = getUserMaxTimes();
    $groupid = getUserGroupID('Specify End Time', 1);
    $members = getUserGroupMembers($groupid);
    if (array_key_exists($user['id'], $members) || $request['serverrequest']) {
        $openend = 1;
    } else {
        $openend = 0;
    }
    $groupid = getUserGroupID('Allow No User Check', 1);
    $members = getUserGroupMembers($groupid);
    if (array_key_exists($user['id'], $members)) {
        $nousercheck = 1;
    } else {
        $nousercheck = 0;
    }
    $h = '';
    # determine the current total length of the reservation
    $reslen = ($unixend - unixFloor15($unixstart)) / 60;
    $timeval = getdate($unixstart);
    if ($timeval["minutes"] % 15 != 0) {
        $reslen -= 15;
    }
    $cdata = array('requestid' => $requestid, 'openend' => $openend, 'nousercheck' => $nousercheck, 'modifystart' => 0, 'allowindefiniteend' => 0);
    # generate HTML
    if ($request['serverrequest']) {
        if (empty($request['servername'])) {
            $request['servername'] = $request['reservations'][0]['prettyimage'];
        }
        $h .= i("Name") . ": <input type=\"text\" name=\"servername\" id=\"servername\" ";
        $h .= "dojoType=\"dijit.form.TextBox\" style=\"width: 330px\" ";
        $h .= "value=\"{$request['servername']}\"><br>";
        if ($user['showallgroups']) {
            $groups = getUserGroups();
        } else {
            $groups = getUserGroups(0, $user['affiliationid']);
        }
        $h .= "<div style=\"display: table-row;\">\n";
        $h .= "<div style=\"display: table-cell;\">\n";
        $h .= i("Admin User Group") . ": ";
        $h .= "</div>\n";
        $h .= "<div style=\"display: table-cell;\">\n";
        $disabled = '';
        if ($request['stateid'] == 14 && $request['laststateid'] == 24) {
            $disabled = "disabled=\"true\"";
        }
        if (USEFILTERINGSELECT && count($groups) < FILTERINGSELECTTHRESHOLD) {
            $h .= "<select dojoType=\"dijit.form.FilteringSelect\" id=\"admingrpsel\" ";
            $h .= "{$disabled} highlightMatch=\"all\" autoComplete=\"false\">";
        } else {
            $h .= "<select id=\"admingrpsel\" {$disabled}>";
        }
        if (!empty($request['admingroupid']) && !array_key_exists($request['admingroupid'], $groups)) {
            $id = $request['admingroupid'];
            $name = getUserGroupName($request['admingroupid'], 1);
            $h .= "<option value=\"{$id}\">{$name}</option>\n";
        }
        $h .= "<option value=\"0\">" . i("None") . "</option>\n";
        foreach ($groups as $id => $group) {
            if ($id == $request['admingroupid']) {
                $h .= "<option value=\"{$id}\" selected>{$group['name']}</option>";
            } else {
                $h .= "<option value=\"{$id}\">{$group['name']}</option>";
            }
        }
        $h .= "</select><br>";
        $imageinfo = getImages(0, $request['reservations'][0]['imageid']);
        if ($imageinfo[$request['reservations'][0]['imageid']]['rootaccess'] == 0) {
            $h .= "<div style=\"width: 240px; margin: 3px 0 3px 0; padding: 1px; border: 1px solid;\">";
            $h .= i("Administrative access has been disabled for this image. Users in the Admin User Group will have control of the reservaion on the Reservations page but will not have administrative access within the reservation.");
            $h .= "</div>\n";
        }
        $h .= "</div>\n";
        $h .= "</div>\n";
        $h .= i("Access User Group") . ": ";
        if (USEFILTERINGSELECT && count($groups) < FILTERINGSELECTTHRESHOLD) {
            $h .= "<select dojoType=\"dijit.form.FilteringSelect\" id=\"logingrpsel\" ";
            $h .= "{$disabled} highlightMatch=\"all\" autoComplete=\"false\">";
        } else {
            $h .= "<select id=\"logingrpsel\" {$disabled}>";
        }
        if (!empty($request['logingroupid']) && !array_key_exists($request['logingroupid'], $groups)) {
            $id = $request['logingroupid'];
            $name = getUserGroupName($request['logingroupid'], 1);
            $h .= "<option value=\"{$id}\">{$name}</option>\n";
        }
        $h .= "<option value=\"0\">None</option>\n";
        foreach ($groups as $id => $group) {
            if ($id == $request['logingroupid']) {
                $h .= "<option value=\"{$id}\" selected>{$group['name']}</option>";
            } else {
                $h .= "<option value=\"{$id}\">{$group['name']}</option>";
            }
        }
        $h .= "</select><br><br>";
    } elseif ($nousercheck) {
        $extra = array();
        if ($request['checkuser'] == 0) {
            $extra['checked'] = 'checked';
        }
        $h .= labeledFormItem('newnousercheck', i('Disable timeout for disconnected users'), 'check', '', '', '1', '', '', $extra);
        $h .= "<br>\n";
    }
    // if future, allow start to be modified
    if ($unixstart > $now) {
        $cdata['modifystart'] = 1;
        $txt = i("Modify reservation for") . " <b>{$request['reservations'][0]['prettyimage']}</b> ";
        $txt .= i("starting") . " " . prettyDatetime($request["start"]) . ": <br>";
        $h .= preg_replace("/(.{1,60}([ \n]|\$))/", '\\1<br>', $txt);
        $days = array();
        $startday = date('l', $unixstart);
        for ($cur = time(), $end = $cur + DAYSAHEAD * SECINDAY; $cur < $end; $cur += SECINDAY) {
            $index = date('Ymd', $cur);
            $days[$index] = date('l', $cur);
        }
        $cdata['startdays'] = array_keys($days);
        $h .= i("Start") . ": <select dojoType=\"dijit.form.Select\" id=\"day\" ";
        $h .= "onChange=\"resetEditResBtn();\">";
        foreach ($days as $id => $name) {
            if ($name == $startday) {
                $h .= "<option value=\"{$id}\" selected=\"selected\">{$name}</option>";
            } else {
                $h .= "<option value=\"{$id}\">{$name}</option>";
            }
        }
        $h .= "</select>";
        $h .= i("&nbsp;At&nbsp;");
        $tmp = explode(' ', $request['start']);
        $stime = $tmp[1];
        $h .= "<div type=\"text\" dojoType=\"dijit.form.TimeTextBox\" ";
        $h .= "id=\"editstarttime\" style=\"width: 78px\" value=\"T{$stime}\" ";
        $h .= "onChange=\"resetEditResBtn();\"></div>";
        $h .= "<small>(" . date('T') . ")</small><br><br>";
        $durationmatch = 0;
        if ($request['serverrequest']) {
            $cdata['allowindefiniteend'] = 1;
            if ($request['end'] == '2038-01-01 00:00:00') {
                $h .= "<INPUT type=\"radio\" name=\"ending\" id=\"indefiniteradio\" ";
                $h .= "checked onChange=\"resetEditResBtn();\">";
            } else {
                $h .= "<INPUT type=\"radio\" name=\"ending\" id=\"indefiniteradio\" ";
                $h .= "onChange=\"resetEditResBtn();\">";
            }
            $h .= "<label for=\"indefiniteradio\">" . i("Indefinite Ending") . "</label>";
        } else {
            $durationmin = $duration / 60;
            if ($request['forimaging'] && $maxtimes['initial'] < 720) {
                # make sure at least 12 hours available for imaging reservations
                $maxtimes['initial'] = 720;
            }
            $imgdata = getImages(1, $request['reservations'][0]['imageid']);
            $maxlen = $imgdata[$request['reservations'][0]['imageid']]['maxinitialtime'];
            if ($maxlen > 0 && $maxlen < $maxtimes['initial']) {
                $maxtimes['initial'] = $maxlen;
            }
            $lengths = array();
            if ($maxtimes["initial"] >= 30) {
                $lengths["30"] = "30 " . i("minutes");
                if ($durationmin == 30) {
                    $durationmatch = 1;
                }
            }
            if ($maxtimes["initial"] >= 45) {
                $lengths["45"] = "45 " . i("minutes");
                if ($durationmin == 45) {
                    $durationmatch = 1;
                }
            }
            if ($maxtimes["initial"] >= 60) {
                $lengths["60"] = "1 " . i("hour");
                if ($durationmin == 60) {
                    $durationmatch = 1;
                }
            }
            for ($i = 120; $i <= $maxtimes["initial"] && $i < 2880; $i += 120) {
                $lengths[$i] = $i / 60 . " " . i("hours");
                if ($durationmin == $i) {
                    $durationmatch = 1;
                }
            }
            for ($i = 2880; $i <= $maxtimes["initial"]; $i += 1440) {
                $lengths[$i] = $i / 1440 . " " . i("days");
                if ($durationmin == $i) {
                    $durationmatch = 1;
                }
            }
            if ($openend) {
                if ($durationmatch) {
                    $h .= "<INPUT type=\"radio\" name=\"ending\" id=\"lengthradio\" ";
                    $h .= "onChange=\"resetEditResBtn();\" checked>";
                } else {
                    $h .= "<INPUT type=\"radio\" name=\"ending\" id=\"lengthradio\" ";
                    $h .= "onChange=\"resetEditResBtn();\">";
                }
                $h .= "<label for=\"lengthradio\">";
            }
            $h .= i("Duration") . ':';
            if ($openend) {
                $h .= "</label>";
            }
            $h .= "<select dojoType=\"dijit.form.Select\" id=\"length\" ";
            $h .= "onChange=\"selectLength();\">";
            $cdata['lengths'] = array_keys($lengths);
            foreach ($lengths as $id => $name) {
                if ($id == $duration / 60) {
                    $h .= "<option value=\"{$id}\" selected=\"selected\">{$name}</option>";
                } else {
                    $h .= "<option value=\"{$id}\">{$name}</option>";
                }
            }
            $h .= "</select>";
        }
        if ($openend) {
            if ($request['serverrequest'] && $request['end'] == '2038-01-01 00:00:00') {
                $h .= "<br><INPUT type=\"radio\" name=\"ending\" id=\"dateradio\" ";
                $h .= "onChange=\"resetEditResBtn();\">";
                $edate = '';
                $etime = '';
            } else {
                if (!$request['serverrequest'] && $durationmatch) {
                    $h .= "<br><INPUT type=\"radio\" name=\"ending\" id=\"dateradio\" ";
                    $h .= "onChange=\"resetEditResBtn();\">";
                } else {
                    $h .= "<br><INPUT type=\"radio\" name=\"ending\" id=\"dateradio\" ";
                    $h .= "checked onChange=\"resetEditResBtn();\">";
                }
                $tmp = explode(' ', $request['end']);
                $edate = $tmp[0];
                $etime = $tmp[1];
            }
            $h .= "<label for=\"dateradio\">";
            $h .= i("End:");
            $h .= "</label>";
            $h .= "<div type=\"text\" dojoType=\"dijit.form.DateTextBox\" ";
            $h .= "id=\"openenddate\" style=\"width: 78px\" value=\"{$edate}\" ";
            $h .= "onChange=\"selectEnding();\"></div>";
            $h .= "<div type=\"text\" dojoType=\"dijit.form.TimeTextBox\" ";
            $h .= "id=\"openendtime\" style=\"width: 78px\" value=\"T{$etime}\" ";
            $h .= "onChange=\"selectEnding();\"></div>";
            $h .= "<small>(" . date('T') . ")</small>";
        }
        $h .= "<br><br>";
        $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0);
        $data = array('status' => 'modify', 'html' => $h, 'requestid' => $requestid, 'cont' => $cont);
        sendJSON($data);
        return;
    }
    # check for max time being reached
    if ($request['forimaging'] && $maxtimes['total'] < 720) {
        $maxcheck = 720;
    } else {
        $maxcheck = $maxtimes['total'];
    }
    if (!$openend && $reslen >= $maxcheck) {
        $h = sprintf(i("You are only allowed to extend your reservation such that it has a total length of %s. "), minToHourMin($maxcheck));
        $h .= i("This reservation already meets that length. Therefore, you are not allowed to extend your reservation any further.");
        $h = preg_replace("/(.{1,60}([ \n]|\$))/", '\\1<br>', $h) . "<br>";
        sendJSON(array('status' => 'nomodify', 'html' => $h));
        return;
    }
    // if started, only allow end to be modified
    # check for following reservations
    $timeToNext = timeToNextReservation($request);
    # check for 30 minutes because need 15 minute buffer and min can
    # extend by is 15 min
    if ($timeToNext < 30) {
        $movedall = 1;
        $lockedall = 1;
        if (count($request['reservations']) > 1) {
            # get semaphore on each existing node in cluster so that nothing
            # can get moved to the nodes during this process
            $resources = getUserResources(array("imageAdmin", "imageCheckOut"));
            $tmp = array_keys($resources['image']);
            $semimageid = $tmp[0];
            $semrevid = getProductionRevisionid($semimageid);
            $checkend = unixToDatetime($unixend + 900);
            foreach ($request["reservations"] as $res) {
                if (!retryGetSemaphore($semimageid, $semrevid, $res['managementnodeid'], $res['computerid'], $request['start'], $checkend, $requestid)) {
                    $lockedall = 0;
                    break;
                }
            }
        }
        if ($lockedall) {
            foreach ($request["reservations"] as $res) {
                if (!moveReservationsOffComputer($res["computerid"], 1)) {
                    $movedall = 0;
                    break;
                }
            }
        }
        cleanSemaphore();
        if (!$request['serverrequest'] && (!$movedall || !$lockedall)) {
            $msg = i("The computer you are using has another reservation immediately following yours. Therefore, you cannot extend your reservation because it would overlap with the next one.");
            $h = preg_replace("/(.{1,60}( |\$))/", '\\1<br>', $msg) . "<br>";
            sendJSON(array('status' => 'nomodify', 'html' => $h));
            return;
        }
        $timeToNext = timeToNextReservation($request);
    }
    if ($timeToNext >= 15) {
        $timeToNext -= 15;
    }
    //if have time left to extend it, create an array of lengths based on maxextend that has a cap
    # so we don't run into another reservation and we can't extend past the totalmax
    $lengths = array();
    if ($request['forimaging'] && $maxtimes['total'] < 720) {
        # make sure at least 12 hours available for imaging reservations
        $maxtimes['total'] = 720;
    }
    if ($timeToNext == -1) {
        // there is no following reservation
        if ($reslen + 15 <= $maxtimes["total"] && 15 <= $maxtimes["extend"]) {
            $lengths["15"] = "15 " . i("minutes");
        }
        if ($reslen + 30 <= $maxtimes["total"] && 30 <= $maxtimes["extend"]) {
            $lengths["30"] = "30 " . i("minutes");
        }
        if ($reslen + 45 <= $maxtimes["total"] && 45 <= $maxtimes["extend"]) {
            $lengths["45"] = "45 " . i("minutes");
        }
        if ($reslen + 60 <= $maxtimes["total"] && 60 <= $maxtimes["extend"]) {
            $lengths["60"] = i("1 hour");
        }
        for ($i = 120; $reslen + $i <= $maxtimes["total"] && $i <= $maxtimes["extend"] && $i < 2880; $i += 120) {
            $lengths[$i] = $i / 60 . " " . i("hours");
        }
        for ($i = 2880; $reslen + $i <= $maxtimes["total"] && $i <= $maxtimes["extend"]; $i += 1440) {
            $lengths[$i] = $i / 1440 . " " . i("days");
        }
    } else {
        if ($timeToNext >= 15 && $reslen + 15 <= $maxtimes["total"] && 15 <= $maxtimes["extend"]) {
            $lengths["15"] = "15 " . i("minutes");
        }
        if ($timeToNext >= 30 && $reslen + 30 <= $maxtimes["total"] && 30 <= $maxtimes["extend"]) {
            $lengths["30"] = "30 " . i("minutes");
        }
        if ($timeToNext >= 45 && $reslen + 45 <= $maxtimes["total"] && 45 <= $maxtimes["extend"]) {
            $lengths["45"] = "45 " . i("minutes");
        }
        if ($timeToNext >= 60 && $reslen + 60 <= $maxtimes["total"] && 60 <= $maxtimes["extend"]) {
            $lengths["60"] = i("1 hour");
        }
        for ($i = 120; $i <= $timeToNext && $reslen + $i <= $maxtimes["total"] && $i <= $maxtimes["extend"] && $i < 2880; $i += 120) {
            $lengths[$i] = $i / 60 . " " . i("hours");
        }
        for ($i = 2880; $i <= $timeToNext && $reslen + $i <= $maxtimes["total"] && $i <= $maxtimes["extend"]; $i += 1440) {
            $lengths[$i] = $i / 1440 . " " . i("days");
        }
    }
    $cdata['lengths'] = array_keys($lengths);
    if ($timeToNext == -1 || $timeToNext >= $maxtimes['total']) {
        if ($openend) {
            if (!empty($lengths)) {
                $m = i("You can extend this reservation by a selected amount or change the end time to a specified date and time.");
                $h .= preg_replace("/(.{1,55}([ \n]|\$))/", '\\1<br>', $m) . "<br>";
            } else {
                $h .= i("Modify the end time for this reservation:") . "<br><br>";
            }
        } else {
            if ($request['forimaging'] && $maxtimes['total'] < 720) {
                $maxcheck = 720;
            } else {
                $maxcheck = $maxtimes['total'];
            }
            $m = sprintf(i("You can extend this reservation by up to %s but not exceeding %s for your total reservation time."), minToHourMin($maxtimes['extend']), minToHourMin($maxcheck));
            $h .= preg_replace("/(.{1,60}([ \n]|\$))/", '\\1<br>', $m) . "<br>";
        }
    } elseif (!$request['serverrequest']) {
        $m = sprintf(i("The computer you are using has another reservation following yours. Therefore, you can only extend this reservation for another %s."), prettyLength($timeToNext));
        $h .= preg_replace("/(.{1,60}( |\$))/", '\\1<br>', $m);
    }
    # extend by drop down
    # extend by specifying end time if $openend
    $noindefinite = 0;
    if ($openend) {
        if ($request['serverrequest']) {
            $cdata['allowindefiniteend'] = 1;
            $endchecked = 0;
            if ($request['end'] == '2038-01-01 00:00:00') {
                $h .= "<INPUT type=\"radio\" name=\"ending\" id=\"indefiniteradio\" ";
                $h .= "checked onChange=\"resetEditResBtn();\">";
                $h .= "<label for=\"indefiniteradio\">" . i("Indefinite Ending") . "</label>";
                $h .= "<br><INPUT type=\"radio\" name=\"ending\" id=\"dateradio\" ";
                $h .= "onChange=\"resetEditResBtn();\">";
            } else {
                $h .= "<INPUT type=\"radio\" name=\"ending\" id=\"indefiniteradio\" ";
                $h .= "onChange=\"resetEditResBtn();\">";
                $h .= "<label id=\"indefinitelabel\" for=\"indefiniteradio\">";
                $h .= i("Indefinite Ending") . "</label>";
                $h .= "<br><INPUT type=\"radio\" name=\"ending\" id=\"dateradio\" ";
                $h .= "checked onChange=\"resetEditResBtn();\">";
                $endchecked = 1;
            }
            $h .= "<label for=\"dateradio\">";
        } elseif (!empty($lengths)) {
            $h .= "<INPUT type=\"radio\" name=\"ending\" id=\"lengthradio\" ";
            $h .= "checked onChange=\"resetEditResBtn();\">";
            $h .= "<label for=\"lengthradio\">" . i("Extend reservation by:") . "</label>";
            $h .= "<select dojoType=\"dijit.form.Select\" id=\"length\" ";
            $h .= "onChange=\"selectLength();\" maxHeight=\"250\">";
            foreach ($lengths as $id => $name) {
                $h .= "<option value=\"{$id}\">{$name}</option>";
            }
            $h .= "</select>";
            $h .= "<br><INPUT type=\"radio\" name=\"ending\" id=\"dateradio\" ";
            $h .= "onChange=\"resetEditResBtn();\">";
            $h .= "<label for=\"dateradio\">";
        }
        if ($request['serverrequest']) {
            $h .= i("End:");
            if ($endchecked) {
                $tmp = explode(' ', $request['end']);
                $edate = $tmp[0];
                $etime = $tmp[1];
            } else {
                $edate = '';
                $etime = '';
            }
        } else {
            $h .= i("Change ending to:");
            $tmp = explode(' ', $request['end']);
            $edate = $tmp[0];
            $etime = $tmp[1];
        }
        if (!empty($lengths) || $request['serverrequest']) {
            $h .= "</label>";
        }
        $h .= "<div type=\"text\" dojoType=\"dijit.form.DateTextBox\" ";
        $h .= "id=\"openenddate\" style=\"width: 78px\" value=\"{$edate}\" ";
        $h .= "onChange=\"selectEnding();\"></div>";
        $h .= "<div type=\"text\" dojoType=\"dijit.form.TimeTextBox\" ";
        $h .= "id=\"openendtime\" style=\"width: 78px\" value=\"T{$etime}\" ";
        $h .= "onChange=\"selectEnding();\"></div>";
        $h .= "<small>(" . date('T') . ")</small>";
        $h .= "<INPUT type=\"hidden\" name=\"enddate\" id=\"enddate\">";
        if ($request['serverrequest'] && $timeToNext == 0) {
            $h .= "<br><br><font color=red>";
            $m = "<strong>" . i("NOTE:") . "</strong> ";
            $m .= i("Due to an upcoming reservation on the same computer, you cannot extend this reservation.");
            $h .= preg_replace("/(.{1,80}([ \n]|\$))/", '\\1<br>', $m);
            $h .= "</font>";
            $noindefinite = 1;
        } elseif ($timeToNext > -1) {
            $extend = $unixend + $timeToNext * 60;
            $extend = date('m/d/Y g:i A', $extend);
            $h .= "<br><br><font color=red>";
            $m = "<strong>" . i("NOTE:") . "</strong> ";
            $m .= sprintf(i("Due to an upcoming reservation on the same computer, you can only extend this reservation until %s."), $extend);
            $h .= preg_replace("/(.{1,80}([ \n]|\$))/", '\\1<br>', $m);
            $h .= "</font>";
            $cdata['maxextend'] = $extend;
            $noindefinite = 1;
        }
    } else {
        $h .= i("Extend reservation by:");
        $h .= "<select dojoType=\"dijit.form.Select\" id=\"length\">";
        foreach ($lengths as $id => $name) {
            $h .= "<option value=\"{$id}\">{$name}</option>";
        }
        $h .= "</select>";
    }
    $h .= "<br>";
    $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0);
    $data = array('status' => 'modify', 'html' => $h, 'requestid' => $requestid, 'cont' => $cont);
    if ($noindefinite) {
        $data['status'] = 'noindefinite';
    }
    sendJSON($data);
    return;
}
Beispiel #2
0
 function addEditDialogHTML($add)
 {
     global $user;
     # dialog for on page editing
     $h = '';
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"addeditdlg\"\n";
     $h .= "      title=\"Edit {$this->restypename}\"\n";
     $h .= "      duration=250\n";
     $h .= "      draggable=true>\n";
     $h .= "<div id=\"addeditdlgcontent\">\n";
     $h .= "<div id=\"computerdlgcontent\">\n";
     # id
     $h .= "<input type=\"hidden\" id=\"editresid\">\n";
     $types = array("blade" => "Bare Metal", "lab" => "Lab", "virtualmachine" => "Virtual Machine");
     $provisioning = getProvisioning();
     $provtypes = getProvisioningTypes();
     $states = array('blade' => array(2 => 'available', 10 => 'maintenance', 20 => 'vmhostinuse'), 'lab' => array(2 => 'available', 10 => 'maintenance'), 'virtualmachine' => array(10 => 'maintenance'));
     $h .= "<script type=\"text/javascript\">\n";
     $h .= "var options = {\n";
     $options = array();
     foreach ($types as $type => $tmp) {
         $opt = '';
         $opt .= "  {$type}: {\n";
         $opt .= "    provisioning: [\n";
         $arr = array();
         foreach ($provtypes[$type] as $key => $val) {
             $arr[] = "      {value: '{$key}', label: '{$val}'}";
         }
         $opt .= implode(",\n", $arr);
         $opt .= "\n    ],\n";
         $opt .= "    states: [\n";
         $arr = array();
         foreach ($states[$type] as $key => $val) {
             $arr[] = "      {value: '{$key}', label: '{$val}'}";
         }
         $opt .= implode(",\n", $arr);
         $opt .= "\n    ]\n";
         $opt .= "  }";
         $options[] = $opt;
     }
     $h .= implode(",\n", $options);
     $h .= "\n}\n";
     $h .= "</script>\n";
     # add single or multiple
     $h .= "<div id=\"singlemultiplediv\" class=\"hidden\">\n";
     /*$h .= "<label for=\"addsingle\">Add Single Computer</label><span ";
     		$h .= "class=\"labeledform\"><input type=\"radio\" name=\"mode\" ";
     		$h .= "id=\"addsingle\" checked=\"checked\" onclick=\"toggleAddSingle();\">";
     		$h .= "</span><br><br>\n";
     		$h .= "<label for=\"addmultiple\">Add Multiple Computers</label><span ";
     		$h .= "class=\"labeledform\"><input type=\"radio\" name=\"mode\" ";
     		$h .= "id=\"addmultiple\" onclick=\"toggleAddMultiple();\"><br><br>\n";*/
     $extra = array('onChange' => 'toggleSingleMultiple();');
     $modes = array('single' => 'Single Computer', 'multiple' => 'Multiple Computers');
     $h .= labeledFormItem('mode', i('Add') . ' ', 'select', $modes, 1, '', '', '', $extra);
     $h .= "<br>\n";
     $h .= "</div>\n";
     # singlemultiplediv
     # add multiple note
     $h .= "<div id=\"multiplenotediv\" class=\"hidden\">\n";
     $h .= "<b>NOTE</b>: 'Start IP' and 'End IP' can only differ in the number ";
     $h .= "after the last '.'. The<br>hostnames will be generated from the ";
     $h .= "'Hostname' field. The hostnames for each<br>computer can only differ ";
     $h .= "by the value of a number in the first part of the hostname.<br>Place ";
     $h .= "a '%' character in the 'Hostname' field where that number will be. ";
     $h .= "Then fill in<br>'Start value' and 'End value' with the first and last ";
     $h .= "values to be used in the hostname.<br><br>";
     $h .= "</div>\n";
     # multiplenotediv
     # div for canceling moving blade to vmhostinuse
     $h .= "<div class=\"highlightnoticewarn hidden\" id=\"cancelvmhostinusediv\">\n";
     $h .= "<span id=\"tohostfuturespan\">\n";
     $h .= "NOTICE: This computer is scheduled to start being reloaded as a vmhost at<br>";
     $h .= "<span id=\"tohostfuturetimespan\"></span>";
     $h .= ". You may cancel this scheduled<br>reload by clicking the button below.";
     $h .= "<br><br></span>\n";
     $h .= "<span id=\"tohostnowspan\">\n";
     $h .= "NOTICE: This computer is currently being reloaded as a vmhost. You may cancel this<br>";
     $h .= "process by clicking on the button below. After canceling the reload, it may take several<br>";
     $h .= "minutes for the cancellation process to complete.";
     $h .= "<br><br></span>\n";
     $h .= "<input type=\"hidden\" id=\"tohostcancelcont\">\n";
     $h .= "<button dojoType=\"dijit.form.Button\">\n";
     $h .= "\tCancel Scheduled Reload\n";
     $h .= "\t<script type=\"dojo/method\" event=onClick>\n";
     $h .= "\t\tcancelScheduledtovmhostinuse();\n";
     $h .= "\t</script>\n";
     $h .= "</button>\n";
     $h .= "</div>\n";
     # cancelvmhostinusediv
     $h .= "<div class=\"highlightnoticenotify hidden\" id=\"cancelvmhostinuseokdiv\"></div>\n";
     # hostname
     $errmsg = i("Name can only contain letters, numbers, dashes(-), periods(.), and underscores(_). It can be from 1 to 36 characters long.");
     $h .= labeledFormItem('name', i('Name') . '*', 'text', '^([a-zA-Z0-9_][-a-zA-Z0-9_\\.]{1,35})$', 1, '', $errmsg);
     # start/end
     $h .= "<div id=\"startenddiv\" class=\"hidden\">\n";
     $extra = array('smallDelta' => 1, 'largeDelta' => 10);
     $h .= labeledFormItem('startnum', i('Start') . '*', 'spinner', '{min:0,max:255,places:0}', 1);
     $h .= labeledFormItem('endnum', i('End') . '*', 'spinner', '{min:0,max:255,places:0}', 1);
     $h .= "</div>\n";
     # startenddiv
     # owner
     $extra = array('onKeyPress' => 'setOwnerChecking');
     $h .= labeledFormItem('owner', i('Owner') . '*', 'text', '', 1, "{$user['unityid']}@{$user['affiliation']}", i('Unknown user'), 'checkOwner', $extra);
     $cont = addContinuationsEntry('AJvalidateUserid');
     $h .= "<input type=\"hidden\" id=\"valuseridcont\" value=\"{$cont}\">\n";
     # type
     $extra = array('onChange' => 'selectType();');
     $h .= labeledFormItem('type', i('Type'), 'select', $types, 1, '', '', '', $extra);
     # single computer fields
     $h .= "<div id=\"singleipmacdiv\">\n";
     # public IP
     $ipreg = '(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)';
     $ipreg1 = "^{$ipreg}\$";
     $errmsg = i("Invalid Public IP address specified - must be a valid IPV4 address");
     $h .= labeledFormItem('ipaddress', i('Public IP Address') . '*', 'text', $ipreg1, 1, '', $errmsg);
     # private IP
     $errmsg = i("Invalid Private IP address specified - must be a valid IPV4 address");
     $h .= labeledFormItem('privateipaddress', i('Private IP Address'), 'text', $ipreg1, 0, '', $errmsg);
     # Public MAC
     $macreg = '^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$';
     $errmsg = i("Invalid Public MAC address specified");
     $h .= labeledFormItem('publicmac', i('Public MAC Address'), 'text', $macreg, 0, '', $errmsg);
     # private MAC
     $errmsg = i("Invalid Private MAC address specified");
     $h .= labeledFormItem('privatemac', i('Private MAC Address'), 'text', $macreg, 0, '', $errmsg);
     $h .= "</div>\n";
     # singleipmacdiv
     # multi computer fields
     $h .= "<div id=\"multiipmacdiv\" class=\"hidden\">\n";
     # start public IP
     $errmsg = i("Invalid Start Public IP Address specified - must be a valid IPV4 address");
     $h .= labeledFormItem('startpubipaddress', i('Start Public IP Address') . '*', 'text', $ipreg1, 1, '', $errmsg);
     # end public IP
     $errmsg = i("Invalid End Public IP Address specified - must be a valid IPV4 address");
     $h .= labeledFormItem('endpubipaddress', i('End Public IP Address') . '*', 'text', $ipreg1, 1, '', $errmsg);
     # start private IP
     $errmsg = i("Invalid Start Private IP Address specified - must be a valid IPV4 address");
     $h .= labeledFormItem('startprivipaddress', i('Start Private IP Address') . '*', 'text', $ipreg1, 1, '', $errmsg);
     # end private IP
     $errmsg = i("Invalid End Private IP Address specified - must be a valid IPV4 address");
     $h .= labeledFormItem('endprivipaddress', i('End Private IP Address') . '*', 'text', $ipreg1, 1, '', $errmsg);
     # start MAC
     $errmsg = i("Invalid Start MAC Address specified");
     $h .= labeledFormItem('startmac', i('Start MAC Address'), 'text', $macreg, 0, '', $errmsg);
     $h .= "</div>\n";
     # multiipsdiv
     # provisioning engine
     $extra = array('onChange' => 'selectProvisioning();');
     $h .= labeledFormItem('provisioningid', i('Provisioning Engine'), 'selectonly', $provisioning, 1, '', '', '', $extra);
     # state
     $extra = array('onChange' => 'selectState();');
     $states = array(2 => 'available', 23 => 'hpc', 10 => 'maintenance', 20 => 'vmhostinuse');
     $h .= labeledFormItem('stateid', i('State'), 'selectonly', $states, 1, '', '', '', $extra);
     # maintenance notes
     $h .= "<div id=\"notesspan\">\n";
     $h .= labeledFormItem('notes', i('Reason for maintenance'), 'textarea');
     $h .= "</div>\n";
     # VMhost profile
     $profiles = getVMProfiles();
     uasort($profiles, 'sortKeepIndex');
     $h .= "<div id=\"vmprofilespan\">\n";
     $h .= labeledFormItem('vmprofileid', i('VM Host Porfile'), 'select', $profiles);
     $h .= "</div>\n";
     # platform
     $platforms = getPlatforms();
     $h .= labeledFormItem('platformid', i('Platform'), 'select', $platforms);
     # schedule
     $tmp = getUserResources(array("scheduleAdmin"), array("manageGroup"));
     $schedules = $tmp["schedule"];
     $h .= labeledFormItem('scheduleid', i('Schedule'), 'selectonly', $schedules);
     # current image
     $h .= "<div id=\"curimgspan\">\n";
     $h .= "<label for=\"curimg\">Current Image:</label>\n";
     $h .= "<span class=\"labeledform\" id=\"curimg\"></span><br>\n";
     $h .= "</div>\n";
     # ram
     $extra = array('smallDelta' => 1024, 'largeDelta' => 4096);
     $h .= labeledFormItem('ram', i('RAM (MB)') . '*', 'spinner', '{min:500,max:16777215,places:0}', 1);
     # cores
     $extra = array('smallDelta' => 1, 'largeDelta' => 4);
     $h .= labeledFormItem('cores', i('No. Cores') . '*', 'spinner', '{min:1,max:255,places:0}', 1);
     # proc speed
     $extra = array('smallDelta' => 100, 'largeDelta' => 1000);
     $h .= labeledFormItem('procspeed', i('Processor Speed (MHz)') . '*', 'spinner', '{min:500,max:10000,places:0}', 1);
     # network speed
     $tmpArr = array("10" => "10", "100" => "100", "1000" => "1000", "10000" => "10000", "100000" => "100000");
     $h .= labeledFormItem('network', i('Network'), 'select', $tmpArr);
     # predictive loading module
     $vals = getPredictiveModules();
     $h .= labeledFormItem('predictivemoduleid', i('Predictive Loading Module'), 'select', $vals);
     # NAT
     $h .= "<div class=\"boxedoptions\">\n";
     # use NAT
     $extra = array('onChange' => "toggleNAT('natenabled', 'nathostid');");
     $h .= labeledFormItem('natenabled', i('Connect Using NAT'), 'check', '', '', '1', '', '', $extra);
     # which NAT host
     $nathosts = getNAThosts(0, 1);
     $h .= labeledFormItem('nathostid', i('NAT Host'), 'selectonly', $nathosts);
     $h .= "</div>\n";
     # NAT
     # NAT Host
     $h .= "<div id=\"nathost\" class=\"boxedoptions\">\n";
     # use as NAT host
     $extra = array('onChange' => "toggleNAThost();");
     $h .= labeledFormItem('nathostenabled', i('Use as NAT Host'), 'check', '', '', '1', '', '', $extra);
     # public IP
     $errmsg = i("Invalid NAT Public IP address specified - must be a valid IPV4 address");
     $h .= labeledFormItem('natpublicipaddress', i('NAT Public IP Address'), 'text', $ipreg1, 1, '', $errmsg);
     # internal IP
     $errmsg = i("Invalid NAT Internal IP address specified - must be a valid IPV4 address");
     $h .= labeledFormItem('natinternalipaddress', i('NAT Internal IP Address'), 'text', $ipreg1, 1, '', $errmsg);
     $h .= "</div>\n";
     # NAT Host
     # compid
     $h .= "<div id=\"compidspan\">\n";
     $h .= "<label for=\"compid\">Computer ID:</label>\n";
     $h .= "<span class=\"labeledform\" id=\"compid\"></span><br>\n";
     $h .= "</div>\n";
     # location
     $errmsg = i("Location can be up to 255 characters long and may contain letters, numbers, spaces, and these characters: - , . _ @ # ( )");
     $h .= labeledFormItem('location', i('Location'), 'text', '^([-a-zA-Z0-9_\\. ,@#\\(\\)]{0,255})$', 0, '', $errmsg);
     $h .= "</div>\n";
     # computerdlgcontent
     $h .= "</div>\n";
     # addeditdlgcontent
     $h .= "<div id=\"addeditdlgerrmsg\" class=\"nperrormsg\"></div>\n";
     $h .= "<div id=\"editdlgbtns\" align=\"center\">\n";
     $h .= dijitButton('addeditbtn', "Confirm", "saveResource();");
     $h .= dijitButton('', "Cancel", "dijit.byId('addeditdlg').hide();");
     $h .= "</div>\n";
     # editdlgbtns
     $h .= "</div>\n";
     # dialog
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"groupingnote\"\n";
     $h .= "      title=\"Computer Grouping\"\n";
     $h .= "      duration=250\n";
     $h .= "      draggable=true>\n";
     $h .= "Computer(s) successfully added. Each computer needs<br>to be a member of a computer resource group. The<br>following dialog<br>will allow you to add the new<br>computer(s) to a group.<br><br>\n";
     $h .= "<div align=\"center\">\n";
     $h .= dijitButton('', "Close", "dijit.byId('groupingnote').hide();");
     $h .= "</div>\n";
     # btn div
     $h .= "</div>\n";
     # groupingnote
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"groupdlg\"\n";
     $h .= "      title=\"Computer Grouping\"\n";
     $h .= "      duration=250\n";
     $h .= "      draggable=true>\n";
     $h .= "<div id=\"groupdlgcontent\"></div>\n";
     $h .= "<div align=\"center\">\n";
     $script = "    dijit.byId('groupdlg').hide();\n";
     $script .= "    checkFirstAdd();\n";
     $h .= dijitButton('', "Close", $script);
     $h .= "</div>\n";
     # btn div
     $h .= "</div>\n";
     # groupdlg
     return $h;
 }
Beispiel #3
0
 function addEditDialogHTML($add = 0)
 {
     global $user;
     # dialog for on page editing
     $h = '';
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"addeditdlg\"\n";
     if ($add) {
         $h .= "      title=\"" . i("Add {$this->restypename}") . "\"\n";
     } else {
         $h .= "      title=\"" . i("Edit {$this->restypename}") . "\"\n";
     }
     $h .= "      duration=250\n";
     $h .= "      draggable=true>\n";
     $h .= "<div id=\"addeditdlgcontent\">\n";
     # id
     $h .= "<input type=\"hidden\" id=\"editresid\">\n";
     if (!$add) {
         $h .= "<div style=\"width: 80%; margin-left: 10%; overflow: auto; height: 80%;\">\n";
     }
     # name
     $errmsg = i("Name cannot contain dashes (-), single (') or double (&quot;) quotes, less than (&lt;), or greater than (&gt;) and can be from 2 to 60 characters long");
     $h .= labeledFormItem('name', i('Name'), 'text', '^([A-Za-z0-9!@#$%^&\\*\\(\\)_=\\+\\[\\]{}\\\\|:;,\\./\\?~` ]){2,60}$', 1, '', $errmsg);
     # owner
     $extra = array('onKeyPress' => 'setOwnerChecking');
     $h .= labeledFormItem('owner', i('Owner'), 'text', '', 1, '', i('Unknown user'), 'checkOwner', $extra);
     #$h .= labeledFormItem('owner', i('Owner'), 'text', '{$user['unityid']}@{$user['affiliation']}',
     #                      1, '', i('Unknown user'), 'checkOwner', 'onKeyPress', 'setOwnerChecking');
     $cont = addContinuationsEntry('AJvalidateUserid');
     $h .= "<input type=\"hidden\" id=\"valuseridcont\" value=\"{$cont}\">\n";
     # description
     $h .= "<fieldset>\n";
     $h .= "<legend>" . i("Image Description") . "</legend>\n";
     $h .= i("Description of image (required - users will see this on the <strong>New Reservations</strong> page):");
     $h .= "<br>\n";
     $h .= "<textarea dojoType=\"dijit.form.Textarea\" id=\"description\" ";
     $h .= "style=\"width: 400px; text-align: left;\"></textarea>\n";
     $h .= "</fieldset>\n";
     # usage notes
     $h .= "<fieldset>\n";
     $h .= "<legend>" . i("Usage Notes") . "</legend>\n";
     $msg = i("Optional notes to the user explaining how to use the image (users will see this on the <strong>Connect!</strong> page):");
     $h .= preg_replace("/(.{1,100}([ \n]|\$))/", '\\1<br>', $msg);
     $h .= "<textarea dojoType=\"dijit.form.Textarea\" id=\"usage\" ";
     $h .= "style=\"width: 400px; text-align: left;\"></textarea>\n";
     $h .= "</fieldset>\n";
     if ($add) {
         $h .= "<fieldset>\n";
         $h .= "<legend>" . i("Revision Comments") . "</legend>\n";
         $msg = i("Notes for yourself and other admins about how the image was setup/installed. These are optional and are not visible to end users.");
         $h .= preg_replace("/(.{1,80}([ \n]|\$))/", '\\1<br>', $msg);
         $h .= "<textarea dojoType=\"dijit.form.Textarea\" id=\"imgcomments\" ";
         $h .= "style=\"width: 400px; text-align: left;\"></textarea>";
         $h .= "</fieldset>\n";
     }
     # advanced options
     $h .= "<div dojoType=\"dijit.TitlePane\" title=\"";
     $h .= i("Advanced Options - leave default values unless you really know what you are doing (click to expand)");
     $h .= "\" open=\"false\" style=\"width: 460px\" id=\"advancedoptions\" ";
     $h .= "onShow=\"delayedEditResize();\" onHide=\"delayedEditResize();\">\n";
     # RAM
     $extra = array('smallDelta' => 256, 'largeDelta' => 1024);
     $h .= labeledFormItem('ram', i('Required RAM'), 'spinner', '{min:512, max:8388607}', 1, 1024, '', '', $extra);
     # cores
     $extra = array('smallDelta' => 1, 'largeDelta' => 2);
     $h .= labeledFormItem('cores', i('Required Cores'), 'spinner', '{min:1, max:255}', 1, 1, '', '', $extra);
     # proc speed
     $extra = array('smallDelta' => 500, 'largeDelta' => 8000);
     $h .= labeledFormItem('cpuspeed', i('Processor Speed'), 'spinner', '{min:500, max:8000}', 1, 1000, '', '', $extra);
     # network speed
     $vals = array('10' => '10 Mbps', '100' => '100 Mbps', '1000' => '1 Gbps', '10000' => '10 Gbps', '100000' => '100 Gbps');
     $h .= labeledFormItem('networkspeed', i('Minimum Network Speed'), 'select', $vals);
     # concurrent usage
     $extra = array('smallDelta' => 1, 'largeDelta' => 10);
     $h .= labeledFormItem('concurrent', i('Max Concurrent Usage'), 'spinner', '{min:0, max:255}', 1, 0, '', '', $extra, '', i('(0 = unlimited)'));
     # reload time
     if (!$add) {
         $extra = array('smallDelta' => 1, 'largeDelta' => 5);
         $h .= labeledFormItem('reload', i('Estimated Reload Time'), 'spinner', '{min:1, max:255}', 1, 5, '', '', $extra);
     }
     # for checkout
     $yesno = array('1' => 'Yes', '0' => 'No');
     $h .= labeledFormItem('checkout', i('Available for checkout'), 'select', $yesno);
     # check user
     $h .= labeledFormItem('checkuser', i('Check for logged in user'), 'select', $yesno);
     # admin access
     $h .= labeledFormItem('rootaccess', i('Users have administrative access'), 'select', $yesno);
     # set hostname
     $h .= "<div id=\"sethostnamediv\">\n";
     $h .= labeledFormItem('sethostname', i('Set computer hostname'), 'select', $yesno);
     $h .= "</div>\n";
     # sysprep
     if ($add) {
         $h .= "<div id=\"sysprepdiv\">\n";
         $h .= labeledFormItem('sysprep', i('Use sysprep'), 'select', $yesno);
         $h .= "</div>\n";
     }
     # connect methods
     $h .= "<label for=\"connectmethodlist\">" . i("Connect methods:") . "</label>\n";
     $h .= "<div class=\"labeledform\"><span id=\"connectmethodlist\"></span><br>\n";
     $h .= "<div dojoType=\"dijit.form.DropDownButton\" id=\"connectmethoddlg\">\n";
     $h .= "  <span>" . i("Modify Connection Methods") . "</span>\n";
     // if leave off the href attribute, inital sizing of popup is wrong
     $h .= "  <div dojoType=\"dijit.TooltipDialog\" id=\"connectmethodttd\" href=\"\"></div>\n";
     $h .= "</div>\n";
     if ($add) {
         $h .= "<input type=\"hidden\" name=\"connectmethodids\" ";
         $h .= "id=\"connectmethodids\">\n";
     }
     $h .= "</div>\n";
     #labeledform
     # subimages
     if (!$add) {
         $h .= "<br>\n";
         $h .= "<div align=\"center\">\n";
         $h .= "<div dojoType=\"dijit.form.DropDownButton\" id=\"subimagebtn\">";
         $h .= "  <span>" . i("Manage Subimages") . "</span>\n";
         // if leave off the href attribute, inital sizing of popup is wrong
         $h .= "  <div dojoType=\"dijit.TooltipDialog\" id=\"subimagedlg\" href=\"\"></div>\n";
         $h .= "</div>\n";
         $h .= "</div>\n";
     }
     if (!$add) {
         $h .= "</div>\n";
     }
     $h .= "</div>\n";
     $h .= "<div id=\"addeditdlgerrmsg\" class=\"nperrormsg\"></div>\n";
     if (!$add) {
         $h .= "<div id=revisiondiv>\n";
         $h .= "</div>\n";
     }
     $h .= "</div>\n";
     # addeditdlgcontent
     $h .= "<div id=\"editdlgbtns\" align=\"center\">\n";
     $h .= dijitButton('addeditbtn', i("Confirm"), "saveResource();");
     $script = "    dijit.byId('addeditdlg').hide();\n";
     $script .= "    dijit.registry.filter(function(widget, index){return widget.id.match(/^comments/);}).forEach(function(widget) {widget.destroy();});\n";
     $h .= dijitButton('', i("Cancel"), $script);
     $h .= "</div>\n";
     # editdlgbtns
     $h .= "</div>\n";
     # addeditdlg
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"autoconfirmdlg\"\n";
     $h .= "      title=\"" . i("Confirm Manual Install") . "\"\n";
     $h .= "      duration=250\n";
     $h .= "      draggable=true>\n";
     $h .= "<strong><span id=\"autoconfirmcontent\"></span></strong><br><br>\n";
     $h .= "<div style=\"width: 230px;\">\n";
     $h .= i("This method cannot be automatically added to the image by VCL. The image must be created with the software for this method already installed. If this image already has software for this method installed in it, please click <strong>Software is Manually Installed</strong>. Otherwise, click cancel.");
     $h .= "</div><br><br>\n";
     $h .= "   <div align=\"center\">\n";
     $script = "       dijit.byId('autoconfirmdlg').hide();\n";
     $script .= "       addConnectMethod3();\n";
     $script .= "       dijit.byId('connectmethoddlg').openDropDown();\n";
     $h .= dijitButton('', i("Software is Manually Installed"), $script);
     $script = "       dijit.byId('autoconfirmdlg').hide();\n";
     $script .= "       dijit.byId('connectmethoddlg').openDropDown();\n";
     $h .= dijitButton('', i("Cancel"), $script);
     $h .= "   </div>\n";
     $h .= "</div>\n";
     # autoconfirmdlg
     return $h;
 }
Beispiel #4
0
 function getHTML()
 {
     global $user;
     $val = getVariable($this->key, $this->defaultval);
     $h = "<div class=\"configwidget\" style=\"width: 100%;\">\n";
     $h .= "<h3>{$this->name}</h3>\n";
     $h .= "<span class=\"siteconfigdesc\">\n";
     $h .= $this->desc;
     $h .= "<br><br></span>\n";
     switch ($this->type) {
         case 'numeric':
             $extra = array('smallDelta' => 1, 'largeDelta' => 10);
             $h .= labeledFormItem($this->domidbase, $this->label, 'spinner', "{min:{$this->minval}, max:{$this->maxval}}", 1, $val, '', '', $extra);
             break;
         case 'boolean':
             $extra = array();
             if ($val == 1) {
                 $extra = array('checked' => 'checked');
             }
             $h .= labeledFormItem($this->domidbase, $this->label, 'check', '', 1, 1, '', '', $extra);
             break;
         case 'textarea':
             $h .= labeledFormItem($this->domidbase, $this->label, 'textarea', '', 1, $val, '', '', '', '120px');
             break;
         default:
             $h .= labeledFormItem($this->domidbase, $this->label, 'text', '', 1, $val);
             break;
     }
     $h .= "<div id=\"{$this->domidbase}msg\"></div>\n";
     $h .= dijitButton("{$this->domidbase}btn", i('Submit Changes'), "{$this->jsname}.saveSettings();", 1);
     $cdata = $this->basecdata;
     $cont = addContinuationsEntry('AJupdateAllSettings', $cdata);
     $h .= "<input type=\"hidden\" id=\"{$this->domidbase}cont\" value=\"{$cont}\">\n";
     $h .= "</div>\n";
     return $h;
 }
Beispiel #5
0
 function addEditDialogHTML($add = 0)
 {
     global $user;
     # dialog for on page editing
     $h = '';
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"addeditdlg\"\n";
     $h .= "      title=\"Edit {$this->restypename}\"\n";
     $h .= "      duration=250\n";
     $h .= "      draggable=true>\n";
     $h .= "<div id=\"addeditdlgcontent\">\n";
     $h .= "<div id=\"mgmtnodedlgcontent\">\n";
     $h .= "<div style=\"text-align: center;\">\n";
     $h .= "<small>* denotes required fields</small><br><br>\n";
     $h .= "</div>\n";
     # id
     $h .= "<input type=\"hidden\" id=\"editresid\">\n";
     #$h .= "<div style=\"width: 80%; margin-left: 10%;\">\n";
     # name
     $errmsg = i("Name can only contain letters, numbers, dashes(-), periods(.), and underscores(_). It can be from 1 to 50 characters long.");
     $h .= labeledFormItem('name', i('Name') . '*', 'text', '^([a-zA-Z0-9_][-a-zA-Z0-9_\\.]{1,49})$', 1, '', $errmsg);
     # owner
     $extra = array('onKeyPress' => 'setOwnerChecking');
     $h .= labeledFormItem('owner', i('Owner') . '*', 'text', '', 1, "{$user['unityid']}@{$user['affiliation']}", i('Unknown user'), 'checkOwner', $extra);
     $cont = addContinuationsEntry('AJvalidateUserid');
     $h .= "<input type=\"hidden\" id=\"valuseridcont\" value=\"{$cont}\">\n";
     # IP address
     $ipreg = '(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)';
     $ipreg1 = "^{$ipreg}\$";
     $errmsg = i("Invalid IP address specified - must be a valid IPV4 address");
     $h .= labeledFormItem('ipaddress', i('IP Address') . '*', 'text', $ipreg1, 1, '', $errmsg);
     # State
     $vals = array(2 => "available", 10 => "maintenance", 5 => "failed");
     $h .= labeledFormItem('stateid', i('State'), 'select', $vals);
     # sysadmin email
     $reg = '^([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4},)*([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4})$';
     $errmsg = i("Invalid email address(es) specified");
     $h .= labeledFormItem('sysadminemail', i("SysAdmin Email Address(es)"), 'text', $reg, 0, '', $errmsg, '', '', '', helpIcon('sysadminemailhelp'));
     # shared mailbox
     $reg = '^([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4})$';
     $errmsg = i("Invalid email address specified");
     $h .= labeledFormItem('sharedmailbox', i('Address for Shadow Emails'), 'text', $reg, 0, '', $errmsg, '', '', '', helpIcon('sharedmailboxhelp'));
     # checkininterval
     $extra = array('smallDelta' => 1, 'largeDelta' => 2);
     $h .= labeledFormItem('checkininterval', i('Check-in Interval (sec)'), 'spinner', '{min:5,max:30,places:0}', 1, '6', '', '', $extra, '', helpIcon('checkinhelp'));
     # installpath
     $reg = '^([-a-zA-Z0-9_\\.\\/]){2,100}$';
     $errmsg = i("Invalid install path specified");
     $h .= labeledFormItem('installpath', i('Install Path'), 'text', $reg, 0, '', $errmsg, '', '', '', helpIcon('installpathhelp'));
     # timeserver list
     $reg = '^(([a-zA-Z0-9_][-a-zA-Z0-9_\\.]{1,49})(,?)){1,5}$';
     $errmsg = i("Invalid time server(s) specified. Must be comman delimited list of hostnames or IP addresses, with up to 5 allowed");
     $val = getVariable('timesource|global');
     $h .= labeledFormItem('timeservers', i('Time Server(s)'), 'text', $reg, 0, $val, $errmsg, '', '', '', helpIcon('timeservershelp'));
     # keys
     $reg = '^([-a-zA-Z0-9_\\.\\/,]){2,1024}$';
     $errmsg = i("Invalid path to identity key files");
     $h .= labeledFormItem('keys', i('End Node SSH Identity Key Files'), 'text', $reg, 0, '', $errmsg, '', '', '', helpIcon('identityhelp'));
     # sshport
     $extra = array('smallDelta' => 1, 'largeDelta' => 2);
     $h .= labeledFormItem('sshport', i('SSH Port for this node'), 'spinner', '{min:1,max:65535,places:0}', 1, '22', '', '', $extra, '', helpIcon('sshporthelp'));
     # image library
     $h .= "<div class=\"boxedoptions\">\n";
     # imagelibenable
     $extra = array('onChange' => 'toggleImageLibrary();');
     $h .= labeledFormItem('imagelibenable', i('Enable Image Library'), 'check', '', '', '', '', '', $extra, '', helpIcon('imagelibhelp'));
     # imagelibgroupid
     $disabled = array('disabled' => 'true');
     $vals = getUserResources(array('mgmtNodeAdmin'), array("manageGroup"), 1);
     $h .= labeledFormItem('imagelibgroupid', i('Image Library Management Node Group'), 'select', $vals['managementnode'], '', '', '', '', $disabled, '', helpIcon('imagelibgrouphelp'));
     # imagelibuser
     $reg = '^([-a-zA-Z0-9_\\.\\/,]){2,20}$';
     $errmsg = i("Invalid image library user");
     $h .= labeledFormItem('imagelibuser', i('Image Library User'), 'text', $reg, 0, '', $errmsg, '', $disabled, '', helpIcon('imagelibuserhelp'));
     # imagelibkey
     $reg = '^([-a-zA-Z0-9_\\.\\/,]){2,100}$';
     $errmsg = i("Invalid image library identity key");
     $h .= labeledFormItem('imagelibkey', i('Image Library SSH Identity Key File'), 'text', $reg, 0, '', $errmsg, '', $disabled, '', helpIcon('imagelibkeyhelp'));
     $h .= "</div>\n";
     # image library
     # IP config method
     $h .= "<div class=\"boxedoptions\">\n";
     # publicIPconfig
     $extra = array('onChange' => 'togglePublic();');
     $vals = array('dynamicDHCP' => 'Dynamic DHCP', 'manualDHCP' => 'Manual DHCP', 'static' => 'Static');
     $h .= labeledFormItem('publicIPconfig', i('Public NIC configuration method'), 'select', $vals, '', '', '', '', $extra, '', helpIcon('ipconfighelp'));
     # netmask
     $errmsg = i("Invalid public netmask");
     $h .= labeledFormItem('publicnetmask', i('Public Netmask'), 'text', $ipreg1, 0, '', $errmsg, '', $disabled, '', helpIcon('netmaskhelp'));
     # gateway
     $reg = '^[a-zA-Z0-9_][-a-zA-Z0-9_\\.]{1,56}$';
     $errmsg = i("Invalid public gateway");
     $h .= labeledFormItem('publicgateway', i('Public Gateway'), 'text', $reg, 0, '', $errmsg, '', $disabled, '', helpIcon('gatewayhelp'));
     # dnsserver
     $reg = "^({$ipreg},)*({$ipreg})\$";
     $errmsg = i("Invalid public DNS server");
     $h .= labeledFormItem('publicdnsserver', i('Public DNS Server'), 'text', $reg, 0, '', $errmsg, '', $disabled, '', helpIcon('dnsserverhelp'));
     $h .= "</div>\n";
     # IP config method
     # available public networks
     $h .= labeledFormItem('availablenetworks', i('Available Public Networks'), 'textarea', '', 1, '', '', '', '', '', helpIcon('availnetshelp'));
     # federated auth
     $h .= labeledFormItem('federatedauth', i('Affiliations using Federated Authentication for Linux Images'), 'textarea', '', 1, '', '', '', '', '', helpIcon('federatedauthhelp'));
     # NAT Host
     $h .= "<div id=\"nathost\" class=\"boxedoptions\">\n";
     # use as NAT host
     $extra = array('onChange' => "toggleNAThost();");
     $h .= labeledFormItem('nathostenabled', i('Use as NAT Host'), 'check', '', '', '1', '', '', $extra);
     # public IP
     $errmsg = i("Invalid NAT Public IP address specified - must be a valid IPV4 address");
     $h .= labeledFormItem('natpublicipaddress', i('NAT Public IP Address'), 'text', $ipreg1, 1, '', $errmsg, '', '', '', helpIcon('natpubliciphelp'));
     # internal IP
     $errmsg = i("Invalid NAT Internal IP address specified - must be a valid IPV4 address");
     $h .= labeledFormItem('natinternalipaddress', i('NAT Internal IP Address'), 'text', $ipreg1, 1, '', $errmsg, '', '', '', helpIcon('natinternaliphelp'));
     $h .= "</div>\n";
     # NAT Host
     $h .= "</div>\n";
     # mgmtnodedlgcontent
     $h .= "</div>\n";
     # addeditdlgcontent
     $h .= "<div id=\"addeditdlgerrmsg\" class=\"nperrormsg\"></div>\n";
     $h .= "<div id=\"editdlgbtns\" align=\"center\">\n";
     $h .= dijitButton('addeditbtn', "Confirm", "saveResource();");
     $h .= dijitButton('', "Cancel", "dijit.byId('addeditdlg').hide();");
     $h .= "</div>\n";
     # editdlgbtns
     $h .= "</div>\n";
     # addeditdlg
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"groupingnote\"\n";
     $h .= "      title=\"Management Node Grouping\"\n";
     $h .= "      duration=250\n";
     $h .= "      draggable=true>\n";
     $h .= "Each managemente node needs to be a member of a<br>management node resource group. The following dialog<br>will allow you to add the new management node to a group.<br><br>\n";
     $h .= "<div align=\"center\">\n";
     $h .= dijitButton('', "Close", "dijit.byId('groupingnote').hide();");
     $h .= "</div>\n";
     # btn div
     $h .= "</div>\n";
     # groupingnote
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"groupdlg\"\n";
     $h .= "      title=\"Management Node Grouping\"\n";
     $h .= "      duration=250\n";
     $h .= "      draggable=true>\n";
     $h .= "<div id=\"groupdlgcontent\"></div>\n";
     $h .= "<div align=\"center\">\n";
     $script = "    dijit.byId('groupdlg').hide();\n";
     $script .= "    checkFirstAdd();\n";
     $h .= dijitButton('', "Close", $script);
     $h .= "</div>\n";
     # btn div
     $h .= "</div>\n";
     # groupdlg
     $h .= "<div id=\"tooltips\">\n";
     $h .= helpTooltip('sysadminemailhelp', i("Comma delimited list of email addresses for sysadmins who should receive error emails from this management node. Leave empty to disable this feature."));
     $h .= helpTooltip('sharedmailboxhelp', i("Single email address to which copies of all user emails should be sent. This is a high traffic set of emails. Leave empty to disable this feature."));
     $h .= helpTooltip('checkinhelp', i("the number of seconds that this management node will wait before checking the database for tasks."));
     $h .= helpTooltip('installpathhelp', i("path to parent directory of image repository directories (typically /install) - only needed with bare metal installs or VMWare with local disk"));
     $h .= helpTooltip('timeservershelp', i("comma delimited list of time servers for this management node"));
     $h .= helpTooltip('identityhelp', i("comma delimited list of full paths to ssh identity keys to try when connecting to end nodes (optional)"));
     $h .= helpTooltip('sshporthelp', i("SSH port this node is listening on for image file transfers"));
     $h .= helpTooltip('imagelibhelp', i("Enable sharing of images between management nodes. This allows a management node to attempt fetching files for a requested image from other management nodes if it does not have them."));
     $h .= helpTooltip('imagelibgrouphelp', i("This management node will try to get image files from other nodes in the selected group."));
     $h .= helpTooltip('imagelibuserhelp', i("userid to use for scp when copying image files from another management node"));
     $h .= helpTooltip('imagelibkeyhelp', i("path to ssh identity key file to use for scp when copying image files from another management node"));
     $h .= helpTooltip('ipconfighelp', i("Method by which public NIC on nodes controlled by this management node recive their network configuration <ul><li>Dynamic DHCP - nodes receive an address via DHCP from a pool of addresses</li><li>Manual DHCP - nodes always receive the same address via DHCP</li><li>Static - VCL will configure the public address of the node</li></ul>"));
     $h .= helpTooltip('netmaskhelp', i("Netmask for public NIC"));
     $h .= helpTooltip('gatewayhelp', i("IP address of gateway for public NIC"));
     $h .= helpTooltip('dnsserverhelp', i("comma delimited list of IP addresses of DNS servers for public network"));
     $h .= helpTooltip('availnetshelp', i("This is a list of IP networks, one per line, available to nodes deployed by this management node. Networks should be specified in x.x.x.x/yy form.  It is for deploying servers having a fixed IP address to ensure a node is selected that can actually be on the specified network."));
     $h .= helpTooltip('federatedauthhelp', i("Comma delimited list of affiliations for which user passwords are not set for Linux image reservations under this management node. Each Linux image is then required to have federated authentication set up so that users' passwords are passed along to the federated authentication system when a user attempts to log in. (for clarity, not set setting user passwords does not mean users have an empty password, but that a federated system must authenticate the users)"));
     $h .= helpTooltip('natpubliciphelp', i("message"));
     $h .= helpTooltip('natinternaliphelp', i("message 2"));
     $h .= "</div>\n";
     # tooltips
     return $h;
 }
Beispiel #6
0
 function addEditDialogHTML($add = 0)
 {
     global $user, $days;
     # dialog for on page editing
     $h = '';
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"addeditdlg\"\n";
     $h .= "      title=\"Edit {$this->restypename}\"\n";
     $h .= "      duration=250\n";
     $h .= "      style=\"width: 70%;\"\n";
     $h .= "      draggable=true>\n";
     $h .= "<div id=\"addeditdlgcontent\">\n";
     # id
     $h .= "<input type=\"hidden\" id=\"editresid\">\n";
     $h .= "<div style=\"text-align: center;\">\n";
     # name
     $errmsg = i("Name cannot contain single (') or double (&quot;) quotes, less than (&lt;), or greater than (&gt;) and can be from 2 to 30 characters long");
     $h .= labeledFormItem('name', i('Name'), 'text', '^([A-Za-z0-9-!@#$%^&\\*\\(\\)_=\\+\\[\\]{}\\\\|:;,\\./\\?~` ]){2,30}$', 1, '', $errmsg, '', '', '200px');
     # owner
     $extra = array('onKeyPress' => 'setOwnerChecking');
     $h .= labeledFormItem('owner', i('Owner'), 'text', '', 1, "{$user['unityid']}@{$user['affiliation']}", i('Unknown user'), 'checkOwner', $extra, '200px');
     #$h .= labeledFormItem('owner', i('Owner'), 'text', '{$user['unityid']}@{$user['affiliation']}',
     #                      1, '', i('Unknown user'), 'checkOwner', 'onKeyPress', 'setOwnerChecking');
     $cont = addContinuationsEntry('AJvalidateUserid');
     $h .= "<input type=\"hidden\" id=\"valuseridcont\" value=\"{$cont}\">\n";
     # table of times
     $h .= "<br>";
     $h .= "<span style=\"text-align: center;\"><h3>Schedule Times</h3></span>\n";
     $h .= "The start and end day/times are based on a week's time period with ";
     $h .= "the start/end point being 'Sunday 12:00&nbsp;am'. i.e. The earliest ";
     $h .= "start day/time is 'Sunday 12:00&nbsp;am' and the latest end day/";
     $h .= "time is 'Sunday 12:00&nbsp;am'<br><br>\n";
     $h .= "Start:";
     $h .= selectInputAutoDijitHTML('startday', $days, 'startday');
     $h .= "<input type=\"text\" id=\"starttime\" dojoType=\"dijit.form.TimeTextBox\" ";
     $h .= "required=\"true\" value=\"T00:00:00\"/>\n";
     $h .= "End:";
     $h .= selectInputAutoDijitHTML('endday', $days, 'endday');
     $h .= "<input type=\"text\" id=\"endtime\" dojoType=\"dijit.form.TimeTextBox\" ";
     $h .= "required=\"true\" value=\"T00:00:00\" />\n";
     $h .= dijitButton('addTimeBtn', "Add", "addTime();");
     $h .= "</div>\n";
     # text-align: center
     $h .= "<div dojoType=\"dojo.data.ItemFileWriteStore\" jsId=\"scheduleStore\" ";
     $h .= "data=\"scheduleTimeData\"></div>\n";
     $h .= "<table dojoType=\"dojox.grid.DataGrid\" jsId=\"scheduleGrid\" sortInfo=1 ";
     $h .= "store=\"scheduleStore\" style=\"width: 520px; height: 165px;\">\n";
     $h .= "<thead>\n";
     $h .= "<tr>\n";
     $h .= "<th field=\"startday\" width=\"94px\" formatter=\"formatDay\">Start Day</th>\n";
     $h .= "<th field=\"startday\" width=\"94px\" formatter=\"formatTime\">Start Time</th>\n";
     $h .= "<th field=\"endday\" width=\"94px\" formatter=\"formatDay\">End Day</th>\n";
     $h .= "<th field=\"endday\" width=\"94px\" formatter=\"formatTime\">End Time</th>\n";
     $h .= "<th field=\"remove\" width=\"80px\">Remove</th>\n";
     $h .= "</tr>\n";
     $h .= "</thead>\n";
     $h .= "</table>\n";
     $h .= "</div>\n";
     # addeditdlgcontent
     $h .= "<div id=\"addeditdlgerrmsg\" class=\"nperrormsg\"></div>\n";
     $h .= "<div id=\"editdlgbtns\" align=\"center\">\n";
     $h .= dijitButton('addeditbtn', "Confirm", "saveResource();");
     $h .= dijitButton('', "Cancel", "addEditDlgHide();");
     $h .= "</div>\n";
     # editdlgbtns
     $h .= "</div>\n";
     # addeditdlg
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"groupingnote\"\n";
     $h .= "      title=\"Schedule Grouping\"\n";
     $h .= "      duration=250\n";
     $h .= "      draggable=true>\n";
     $h .= "Each schedule should be a member of a schedule<br>resource group. The following dialog will allow you<br>to add the new schedule to a group.<br><br>\n";
     $h .= "<div align=\"center\">\n";
     $h .= dijitButton('', "Close", "dijit.byId('groupingnote').hide();");
     $h .= "</div>\n";
     # btn div
     $h .= "</div>\n";
     # groupingnote
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"groupdlg\"\n";
     $h .= "      title=\"Schedule Grouping\"\n";
     $h .= "      duration=250\n";
     $h .= "      draggable=true>\n";
     $h .= "<div id=\"groupdlgcontent\"></div>\n";
     $h .= "<div align=\"center\">\n";
     $script = "    dijit.byId('groupdlg').hide();\n";
     $script .= "    checkFirstAdd();\n";
     $h .= dijitButton('', "Close", $script);
     $h .= "</div>\n";
     # btn div
     $h .= "</div>\n";
     # groupdlg
     return $h;
 }