users" where /// is the name field from the affiliation table /// //////////////////////////////////////////////////////////////////////////////// function updateShibGroups($usernid, $groups) { if(is_array($groups) && array_key_exists('shibaffil', $groups)) { $shibaffil = $groups['shibaffil']; $groups = ''; } $groups = explode(';', $groups); $newusergroups = array(); foreach($groups as $group) { # make sure $group contains non-whitespace if(! preg_match('/\w/', $group)) continue; list($name, $shibaffil) = explode('@', $group); # get id for the group's affiliation $query = "SELECT id FROM affiliation WHERE shibname = '$shibaffil'"; $qh = doQuery($query, 101); $row = mysql_fetch_assoc($qh); $affilid = $row['id']; # prepend shib- and escape it for mysql $grp = mysql_real_escape_string("shib-" . $name); array_push($newusergroups, getUserGroupID($grp, $affilid)); } $query = "SELECT id, name FROM affiliation WHERE shibname = '$shibaffil'"; $qh = doQuery($query, 101); $row = mysql_fetch_assoc($qh); $affilid = $row['id']; $grp = mysql_real_escape_string("All {$row['name']} Users"); array_push($newusergroups, getUserGroupID($grp, $affilid)); $newusergroups = array_unique($newusergroups); if(! empty($newusergroups)) updateGroups($newusergroups, $usernid); } //////////////////////////////////////////////////////////////////////////////// /// /// \fn addShibUserStub($affilid, $userid) /// /// \param $affilid - id of user's affiliation /// \param $userid - user's login id /// /// \return an array of user information with the following keys:\n /// \b first - empty string\n /// \b last - empty string\n /// \b email - empty string\n /// \b emailnotices - 0 or 1, whether or not emails should be sent to user /// /// \brief adds $userid to database with both lastupdate and validated set to 0 /// //////////////////////////////////////////////////////////////////////////////// function addShibUserStub($affilid, $userid) { global $mysql_link_vcl; $query = "INSERT INTO user " . "(unityid, " . "affiliationid, " . "emailnotices, " . "lastupdated, " . "validated) " . "VALUES (" . "'$userid', " . "'$affilid', " . "0, " . "0, " . "0)"; doQuery($query); if(mysql_affected_rows($mysql_link_vcl)) return dbLastInsertID(); else return NULL; } ?>