" . i("VCL go Configurator") . "\n"; printf(i("VCL gos are for use with the %sVCL iOS app%s. VCL gos can be managed here but can only be used from an iOS device.") . "

\n", "", ""); if(count($oneclicks)) { if($mode == 'submitEditOneClick' || $mode == 'deleteOneClick') { $tab1sel = ""; $tab2sel = "selected=\"true\""; } else { $tab1sel = "selected=\"true\""; $tab2sel = ""; } print "
\n"; print "
\n"; } if(! $submitErr && $mode == 'submitOneClick') print "
" . i("VCL go successfully created") . "
\n"; print "
\n"; # name of OneClick print "
\n"; print i("Choose a name for your new VCL go configuration") . "
\n"; printSubmitErr(NAMEERR); print "" . i("Name:") . "\n"; print "and periods(.) and can be from 3 to 70 characters long"); print "\" regExp=\"^([-a-zA-Z0-9\. \(\)]){3,70}$\" style=\"width: 300px\">"; print "

\n"; # resources; image types $resources = getUserResources(array("imageAdmin", "imageCheckOut")); $resources["image"] = removeNoCheckout($resources["image"]); print i("Please select the resource you want to use from the list:") . "
\n"; printSubmitErr(IMAGEERR); print "
\n"; $images = getImages(); # list of images print "\n"; print "

\n"; # list of duration of the reservation from this OneClick if(array_key_exists($imageid, $images)) $maxlength = $images[$imageid]['maxinitialtime']; else $maxlength = 0; # create an array of usage times based on the user's max times $maxtimes = getUserMaxTimes(); if($maxlength > 0 && $maxlength < $maxtimes['initial']) $maxtimes['initial'] = $maxlength; $lengths = array(); if($maxtimes["initial"] >= 30) $lengths["30"] = "30 " . i("minutes"); if($maxtimes["initial"] >= 60) $lengths["60"] = "1 " . i("hour"); for($i = 120; $i <= $maxtimes["initial"] && $i < 2880; $i += 60) $lengths[$i] = $i / 60 . " " . i("hours"); for($i = 2880; $i <= $maxtimes["initial"]; $i += 1440) $lengths[$i] = $i / 1440 . " " . i("days"); $last = $i; print "" . i("Duration:") . " \n"; printSelectInput("length", $lengths, $length, 0, 0, 'reqlength'); print "

\n"; # other choice print ""; print i("Auto Login"); print "

\n"; # submit button $cdata = array('maxlength' => $last); $cont = addContinuationsEntry('submitOneClick', $cdata, SECINDAY, 1, 0); print "\n"; print "\n"; print "
\n"; # end of first tab print "
\n"; if(count($oneclicks)) { # the tab that list all the OneClicks the user have print "
\n"; if($mode == 'submitEditOneClick') { print "
" . i("VCL go successfully updated"); print "

\n"; } elseif($mode == 'deleteOneClick') { print "
" . i("VCL go successfully deleted"); print "

\n"; } } foreach($oneclicks as $oneclick) { print "
\n"; print i("VCL go Name:") . "\n"; $oneclickname = $oneclick['name']; print "" . htmlentities($oneclickname) . "\n"; print "

\n"; $oneclickid = $oneclick['id']; print i("Resource:") . " " . htmlentities($oneclick['imagename']) . "
\n"; # Duration $duration = $oneclick['duration']; if($duration < 60) { print i("Duration:") . " " . $duration . " " . i("minutes") . "
\n"; } else { if($duration < (60 * 24)) { $hourduration = (int) $duration / 60; print i("Duration:") . " " . $hourduration . " " . i("hour") . ($hourduration == 1 ? "" : "s") . "
"; } else { $dayduration = (int) $duration / (60 * 24); print i("Duration:") . " " . $dayduration . " " . i("day") . ($dayduration == 1 ? "" : "s") . "
"; } } print i("Auto Login") . ": " . ($oneclick['autologin'] == 1 ? i("Yes") : i("No")) . "
\n"; print "
\n"; $cdata = array('oneclickid' => $oneclickid, 'oneclickname' => $oneclickname, 'maxlength' => $last); # edit button print "
\n"; $cont = addContinuationsEntry('editOneClick', $cdata, SECINDAY, 1); print "\n"; print "\n"; print "
\n"; # Delete button print "
\n"; $cont = addContinuationsEntry('deleteOneClick', $cdata, SECINDAY, 1); print "\n"; print "\n"; print "
\n"; print "
\n"; print "

\n"; } if(count($oneclicks)) { print "
\n"; print "
\n"; } } //////////////////////////////////////////////////////////////////////////////// /// /// \fn submitOneClick() /// /// \to create one Button from Web Configurator /// //////////////////////////////////////////////////////////////////////////////// function submitOneClick() { global $user, $submitErr, $submitErrMsg; $maxlength = getContinuationVar('maxlength'); $imageid = processInputVar("imageid", ARG_NUMERIC); $name = processInputVar("newOneClickName", ARG_STRING); $duration = processInputVar("length", ARG_NUMERIC); $autologin = processInputVar("autologin", ARG_NUMERIC) == 1 ? 1 : 0; # validate access to $imageid $resources = getUserResources(array("imageAdmin", "imageCheckOut")); $images = removeNoCheckout($resources["image"]); if(! array_key_exists($imageid, $images)) { $submitErr |= IMAGEERR; $submitErrMsg[IMAGEERR] = i("Invalid image submitted."); } # validate $name if(! preg_match('/^([-a-zA-Z0-9\. \(\)]){3,70}$/', $name)) { $submitErr |= NAMEERR; $submitErrMsg[NAMEERR] = i("Name can only contain letters, numbers, spaces, dashes(-), parenthesis,
and periods(.) and can be from 3 to 70 characters long"); } if($submitErr) { newOneClick(); return; } if($duration > $maxlength) $duration = $maxlength; $query = "INSERT INTO oneclick" . "(userid, " . "imageid, " . "name, " . "duration, " . "autologin, " . "status) " . "VALUES " . "({$user['id']}, " . "$imageid, " . "'$name', " . "$duration, " . "$autologin, " . "1) "; doQuery($query, 101); newOneClick(); } //////////////////////////////////////////////////////////////////////////////// /// /// \fn deleteOneClick() /// /// \to delete one Button from Web Configurator /// //////////////////////////////////////////////////////////////////////////////// function deleteOneClick() { $oneclickid = getContinuationVar('oneclickid'); $query = "UPDATE oneclick SET status = 0 WHERE id = $oneclickid"; doQuery($query, 150); newOneClick(); } //////////////////////////////////////////////////////////////////////////////// /// /// \fn editOneClick() /// /// \to edit one Button from Web Configurator /// //////////////////////////////////////////////////////////////////////////////// function editOneClick() { global $user, $submitErr; $oneclickid = getContinuationVar('oneclickid'); if($submitErr) $delfromself = 1; else $delfromself = 0; $query = "SELECT o.imageid, " . "o.name, " . "o.duration, " . "o.autologin, " . "i.prettyname AS imagename, " . "i.id AS imageid " . "FROM oneclick o " . "LEFT JOIN image i ON (o.imageid = i.id) " . "WHERE o.status = 1 AND " . "o.id = $oneclickid AND " . "o.userid = {$user['id']}"; $qh = doQuery($query, 101); print "
\n"; if(! ($row = mysql_fetch_assoc($qh))) { print i("VCL go not found") . "\n"; return NULL; } print "

" . i("VCL go Editor") . "

\n"; print "
\n"; # infomations # Name printSubmitErr(NAMEERR); print i("VCL go Name:") . " \n"; print "and periods(.) and can be from 3 to 70 characters long"); print "\" regExp=\"^([-a-zA-Z0-9\. \(\)]){3,70}$\" style=\"width: 300px\" "; print "value=\"" . htmlentities($row['name']) . "\">\n"; print "

\n"; # Image print i("Resource:") . " " . htmlentities($row['imagename']) . "
\n"; print "
\n"; # Duration $preduration = $row['duration']; $images = getImages(0, $row['imageid']); $maxlength = $images[$row['imageid']]['maxinitialtime']; $maxtimes = getUserMaxTimes(); if($maxlength == 0 || $maxlength < 0) $maxlength = $maxtimes['initial']; else $maxlength = $maxtimes['initial'] > $maxlength ? $maxlength : $maxtimes['initial']; $iteri = 30; print "" . i("Duration:") . "\n"; print " \n"; print "

\n"; # Auto Login print ""; print i("Auto Login"); print "

\n"; # submit $cdata = array('oneclickid' => $oneclickid, 'maxlength' => $maxlength); $cont = addContinuationsEntry('submitEditOneClick', $cdata, SECINDAY, $delfromself, 0); print "\n"; print "\n"; print "
\n"; # cancel print "
\n"; $cont = addContinuationsEntry('newOneClick', array(), SECINDAY); print "\n"; print "\n"; print "
\n"; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn submitEditOneClick() /// /// \to submit the change to one Button /// //////////////////////////////////////////////////////////////////////////////// function submitEditOneClick() { global $submitErr, $submitErrMsg; $oneclickid = getContinuationVar('oneclickid'); $maxlength = getContinuationVar('maxlength'); $name = processInputVar('name', ARG_STRING); $duration = processInputVar("duration", ARG_NUMERIC); $autologin = processInputVar("autologin", ARG_NUMERIC) == 1 ? 1 : 0; # validate $name if(! preg_match('/^([-a-zA-Z0-9\. \(\)]){3,70}$/', $name)) { $submitErr |= NAMEERR; $submitErrMsg[NAMEERR] = i("Name can only contain letters, numbers, spaces, dashes(-), parenthesis,
and periods(.) and can be from 3 to 70 characters long"); editOneClick(); return; } # validate $duration if($duration > $maxlength) $duration = $maxlength; $query = "UPDATE oneclick " . "SET duration = $duration, " . "name = '$name', " . "autologin = $autologin " . "WHERE id = $oneclickid"; doQuery($query, 150); newOneClick(); } ?>