Changeset 170

Show
Ignore:
Timestamp:
12/29/08 13:22:10 (1 year ago)
Author:
bettse
Message:

This does two things

  • At a user's first login, enable notifications for their account by default
  • At a user's first login, if their username exists but has no email address defined, use the SSO data to update their user info (This allows us to create new users by creating new usernames, then the extra user data (email,

name, etc) will be filled in by the system at their first login).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • elgg/trunk/auth/sso/lib.php

    r55 r170  
    6565        if (record_exists('users','username',$username)) { 
    6666            // onid usernames are unique, so if it's already in the db, we're good to go 
    67             return true; 
     67 
     68            //since a user name have been created by being defined as a member of a project without having previously logged in 
     69            //we check if they have a name defined and if not, we update from sso. 
     70            if($temp = get_record('users','username',$username, 'name', '')) {//if the username exists, but the name is blank 
     71 
     72                $user = new StdClass; 
     73                $user->ident = $temp->ident; 
     74                $user->email = $user_info["email"]; 
     75                $user->name  = $user_info["firstname"]; 
     76                $user->name  = $user->name . " " . $user_info["lastname"]; 
     77                $user->username = $username; 
     78                $user->password = md5($password); 
     79                $user->user_type = 'person'; 
     80                $user->owner = -1; 
     81 
     82                update_record('users',$user); 
     83                //Since this is the first time the user has logged in, do normal user creation stuff 
     84                $rssresult = run("weblogs:rss:publish", array($user->ident, false)); 
     85                $rssresult = run("files:rss:publish", array($user->ident, false)); 
     86                $rssresult = run("profile:rss:publish", array($user->ident, false)); 
     87                user_flag_set("emailnotifications", '1', $user->ident); 
     88 
     89           } 
     90           return true; 
    6891        } else { 
    69             // Everythink OK, create user 
     92            // Everything OK, create user 
    7093            $user = new StdClass; 
    7194            $user->email = $user_info["email"]; 
     
    83106                $rssresult = run("files:rss:publish", array($user_id, false)); 
    84107                $rssresult = run("profile:rss:publish", array($user_id, false)); 
     108                user_flag_set("emailnotifications", '1', $user_id); 
    85109            } else { 
    86110                // User creation failed