Example #1
0
function blockAllocations()
{
    global $user;
    if (!checkUserHasPerm('Manage Block Allocations (global)') && !checkUserHasPerm('Manage Block Allocations (affiliation only)')) {
        print "<H2>" . i("Block Allocations") . "</H2>\n";
        print i("Block Allocations are a way to have a set of machines preloaded with a particular environment at specified times and made available to a specific group of users. This is very useful for classroom use and for workshops. They can be made available on a repeating schedule such as when a course meets each week. Block Allocations only allocate machines for the group of users - they do not create the actual, end user reservations for the machines. All users still must log in to the VCL web site and make their own reservations DURING the period a block allocation is active. The forms here provide a way for you to submit a request for a Block Allocation for review by a sysadmin. If you just need to use a machine through VCL, use the New Reservation page for that.");
        print "<br><br>";
        print i("Please submit Block Allocation requests at least one full business day in advance to allow time for them to be approved.") . "<br><br>\n";
        print "<button dojoType=\"dijit.form.Button\" type=\"button\">\n";
        print i("Request New Block Allocation") . "\n";
        print "  <script type=\"dojo/method\" event=\"onClick\">\n";
        print "    location.href = '" . BASEURL . SCRIPT . "?mode=requestBlockAllocation';\n";
        print "  </script>\n";
        print "</button>\n";
        print getUserCurrentBlockHTML();
    } else {
        print "<h2>" . i("Manage Block Allocations") . "</h2>\n";
        $cont = addContinuationsEntry('viewBlockAllocatedMachines');
        print "<a href=\"" . BASEURL . SCRIPT . "?continuation={$cont}\">";
        print i("View Block Allocated Machines") . "</a>\n";
        print "<div id=\"blocklist\">\n";
        print getCurrentBlockHTML();
        print "</div>\n";
        print "<button dojoType=\"dijit.form.Button\" type=\"button\">\n";
        print "  " . i("Create New Block Allocation") . "\n";
        print "  <script type=\"dojo/method\" event=\"onClick\">\n";
        $cont = addContinuationsEntry('newBlockAllocation');
        print "    location.href = '" . BASEURL . SCRIPT . "?continuation={$cont}';\n";
        print "  </script>\n";
        print "</button>\n";
        print "<h2>" . i("Block Allocation Requests") . "</h2>\n";
        print "<div id=\"pendinglist\">\n";
        print getPendingBlockHTML();
        print "</div>\n";
    }
    $blockids = getBlockAllocationIDs($user);
    if (!count($blockids)) {
        return;
    }
    $inids = implode(',', $blockids);
    $query = "SELECT id, " . "name " . "FROM blockRequest " . "WHERE id in ({$inids}) AND " . "status = 'accepted'";
    $qh = doQuery($query, 101);
    while ($row = mysql_fetch_assoc($qh)) {
        $blocks[$row['id']] = $row['name'];
    }
    print "<hr>\n";
    print "<h2>" . i("Your Active Block Allocations") . "</h2>\n";
    print i("You are currently a member of the following Block Allocations.") . "<br>\n";
    print i("Click an item to view its current status.") . "<br>\n";
    foreach ($blocks as $id => $name) {
        $cont = addContinuationsEntry('viewBlockStatus', array('id' => $id));
        print "<a href=\"" . BASEURL . SCRIPT . "?continuation={$cont}\">";
        print "{$name}</a><br>\n";
    }
}
Example #2
0
function getUserInfo($id, $noupdate = 0, $numeric = 0)
{
    $affilid = DEFAULT_AFFILID;
    if (!$numeric) {
        $rc = getAffilidAndLogin($id, $affilid);
        if ($rc == -1) {
            return NULL;
        }
    }
    $user = array();
    $query = "SELECT u.unityid AS unityid, " . "u.affiliationid, " . "af.name AS affiliation, " . "u.firstname AS firstname, " . "u.lastname AS lastname, " . "u.preferredname AS preferredname, " . "u.email AS email, " . "u.emailnotices, " . "i.name AS IMtype, " . "u.IMid AS IMid, " . "u.id AS id, " . "u.width AS width, " . "u.height AS height, " . "u.bpp AS bpp, " . "u.audiomode AS audiomode, " . "u.mapdrives AS mapdrives, " . "u.mapprinters AS mapprinters, " . "u.mapserial AS mapserial, " . "COALESCE(u.rdpport, 3389) AS rdpport, " . "u.showallgroups, " . "u.lastupdated AS lastupdated, " . "u.usepublickeys, " . "u.sshpublickeys, " . "af.shibonly " . "FROM user u, " . "IMtype i, " . "affiliation af " . "WHERE u.IMtypeid = i.id AND " . "u.affiliationid = af.id AND ";
    if ($numeric) {
        $query .= "u.id = {$id}";
    } else {
        $query .= "u.unityid = '{$id}' AND af.id = {$affilid}";
    }
    $qh = doQuery($query, "105");
    if ($user = mysql_fetch_assoc($qh)) {
        $user['sshpublickeys'] = htmlspecialchars($user['sshpublickeys']);
        if (datetimeToUnix($user["lastupdated"]) > time() - SECINDAY || $user['unityid'] == 'vclreload' || $user['affiliation'] == 'Local' || $user['shibonly'] || $noupdate) {
            # get user's groups
            $user["groups"] = getUsersGroups($user["id"], 1);
            $user["groupperms"] = getUsersGroupPerms(array_keys($user['groups']));
            checkExpiredDemoUser($user['id'], $user['groups']);
            # get user's privileges
            $user["privileges"] = getOverallUserPrivs($user["id"]);
            if (preg_match('/@/', $user['unityid'])) {
                $tmparr = explode('@', $user['unityid']);
                $user['login'] = $tmparr[0];
            } else {
                $user['login'] = $user['unityid'];
            }
            $blockids = getBlockAllocationIDs($user);
            $user['memberCurrentBlock'] = count($blockids);
            return $user;
        }
    }
    if ($numeric) {
        $user = updateUserData($id, "numeric");
    } else {
        $user = updateUserData($id, "loginid", $affilid);
    }
    if (!is_null($user)) {
        $blockids = getBlockAllocationIDs($user);
        $user['memberCurrentBlock'] = count($blockids);
    }
    return $user;
}