Ejemplo n.º 1
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;
}
Ejemplo n.º 2
0
function getUserInfo($id)
{
    $affilid = DEFAULT_AFFILID;
    if (!is_numeric($id)) {
        getAffilidAndLogin($id, $affilid);
    }
    $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, " . "a.name AS adminlevel, " . "a.id AS adminlevelid, " . "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, " . "u.showallgroups, " . "u.lastupdated AS lastupdated, " . "af.shibonly " . "FROM user u, " . "IMtype i, " . "affiliation af, " . "adminlevel a " . "WHERE u.IMtypeid = i.id AND " . "u.adminlevelid = a.id AND " . "u.affiliationid = af.id AND ";
    if (is_numeric($id)) {
        $query .= "u.id = {$id}";
    } else {
        $query .= "u.unityid = '{$id}' AND af.id = {$affilid}";
    }
    $qh = doQuery($query, "105");
    if ($user = mysql_fetch_assoc($qh)) {
        if (datetimeToUnix($user["lastupdated"]) > time() - SECINDAY || $user['unityid'] == 'vclreload' || $user['affiliation'] == 'Local' || $user['shibonly']) {
            # get user's groups
            $user["groups"] = getUsersGroups($user["id"], 1);
            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'];
            }
            return $user;
        }
    }
    if (is_numeric($id)) {
        return updateUserData($id, "numeric");
    }
    return updateUserData($id, "loginid", $affilid);
}
Ejemplo n.º 3
0
function updateITECSUser($userid)
{
    global $ENABLE_ITECSAUTH;
    if (!$ENABLE_ITECSAUTH) {
        return NULL;
    }
    $query = "SELECT id AS uid, " . "first, " . "last, " . "email, " . "created " . "FROM user " . "WHERE email = '{$userid}'";
    $qh = doQuery($query, 101, "accounts");
    if (!($userData = mysql_fetch_assoc($qh))) {
        return NULL;
    }
    $now = unixToDatetime(time());
    // select desired data from db
    $query = "SELECT i.name AS IMtype, " . "u.IMid AS IMid, " . "u.affiliationid, " . "af.name AS affiliation, " . "a.name AS adminlevel, " . "a.id AS adminlevelid, " . "u.preferredname AS preferredname, " . "u.uid AS uid, " . "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, " . "u.showallgroups " . "FROM user u, " . "IMtype i, " . "affiliation af, " . "adminlevel a " . "WHERE u.IMtypeid = i.id AND " . "u.adminlevelid = a.id AND " . "u.affiliationid = af.id AND " . "u.uid = " . $userData["uid"];
    $qh = doQuery($query, 255);
    // if get a row
    //    update db
    //    update results from select
    $esc_userid = mysql_escape_string($userid);
    $first = mysql_escape_string($userData['first']);
    $last = mysql_escape_string($userData['last']);
    $email = mysql_escape_string($userData['email']);
    if ($user = mysql_fetch_assoc($qh)) {
        $user["unityid"] = $userid;
        $user["firstname"] = $userData['first'];
        $user["lastname"] = $userData["last"];
        $user["email"] = $userData["email"];
        $user["lastupdated"] = $now;
        $query = "UPDATE user " . "SET unityid = '{$esc_userid}', " . "firstname = '{$first}', " . "lastname = '{$last}', " . "email = '{$email}', " . "lastupdated = '{$now}' " . "WHERE uid = " . $userData["uid"];
        doQuery($query, 256, 'vcl', 1);
    } else {
        //    call addITECSUser
        $id = addITECSUser($userid);
        $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, " . "i.name AS IMtype, " . "u.IMid AS IMid, " . "u.uid AS uid, " . "u.id AS id, " . "a.name AS adminlevel, " . "a.id AS adminlevelid, " . "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, " . "u.showallgroups, " . "u.lastupdated AS lastupdated " . "FROM user u, " . "IMtype i, " . "affiliation af, " . "adminlevel a " . "WHERE u.IMtypeid = i.id AND " . "u.adminlevelid = a.id AND " . "u.affiliationid = af.id AND " . "u.id = {$id}";
        $qh = doQuery($query, 101);
        $user = mysql_fetch_assoc($qh);
        # add account to demo group
        $demoid = getUserGroupID('demo', getAffiliationID('ITECS'));
        updateGroups(array($demoid), $user['id']);
    }
    $user["groups"] = getUsersGroups($user["id"], 1);
    checkExpiredDemoUser($user['id'], $user['groups']);
    $user["privileges"] = getOverallUserPrivs($user["id"]);
    $tmparr = explode('@', $user['unityid']);
    $user['login'] = $tmparr[0];
    return $user;
}