diff options
Diffstat (limited to 'engine')
| -rw-r--r-- | engine/lib/entities.php | 6 | ||||
| -rw-r--r-- | engine/lib/users.php | 32 | 
2 files changed, 36 insertions, 2 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index fb161bbd1..66f421a6d 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -488,8 +488,10 @@  		$access_id = (int)$access_id;  		$time = time(); -		if ($type=="") throw new InvalidParameterException("Entity type must be set."); -		if ($owner_guid==0) throw new InvalidParameterException("owner_guid must not be 0"); +		if ($type=="") throw new InvalidParameterException("Entity type must be set.");
 +
 +		// Erased by Ben: sometimes we need unauthenticated users to create things! (eg users on registration) +		// if ($owner_guid==0) throw new InvalidParameterException("owner_guid must not be 0");  		return insert_data("INSERT into {$CONFIG->dbprefix}entities (type, subtype, owner_guid, access_id, time_created, time_updated) values ('$type',$subtype, $owner_guid, $access_id, $time, $time)");  	} diff --git a/engine/lib/users.php b/engine/lib/users.php index e8e6554f9..2c2465ced 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -457,4 +457,36 @@  		return false;
  	} +
 +	function register_user(string $username, string $password, string $name, string $email) {
 +		
 +		// Load the configuration
 +			global $CONFIG;
 +			
 +		// A little sanity checking
 +			if (empty($username)
 +				|| empty($password)
 +				|| empty($name)
 +				|| empty($email))
 +				return false;			
 +			
 +		// Check to see if $username exists already
 +			if ($user = get_user_by_username($username)) {
 +				return false;
 +			}
 +			
 +		// Otherwise ...
 +			$user = new ElggUser();
 +			$user->username = $username;
 +			$user->password = md5($password);
 +			$user->email = $email;
 +			$user->name = $name;
 +			return $user->save();
 +		
 +	}
 +	
 +	//register actions *************************************************************
 +   
 +   		register_action("register",true);
 +	
  ?>
\ No newline at end of file  | 
