From 39fb85265f4e22ff2f87633d2347cecb233e65e5 Mon Sep 17 00:00:00 2001 From: brettp Date: Sun, 31 Jan 2010 01:29:24 +0000 Subject: Fixes #804: A relationship is created between a new user and the site it was created on. git-svn-id: http://code.elgg.org/elgg/trunk@3867 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/users.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'engine/lib') diff --git a/engine/lib/users.php b/engine/lib/users.php index 0171e838d..341024a45 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -76,7 +76,7 @@ class ElggUser extends ElggEntity // Is $guid is an ElggUser? Use a copy constructor else if ($guid instanceof ElggUser) { elgg_log('This type of usage of the ElggUser constructor was deprecated in 1.7. Please use the clone method.', 'WARNING'); - + foreach ($guid->attributes as $key => $value) { $this->attributes[$key] = $value; } @@ -1445,6 +1445,20 @@ function new_user_enable_permissions_check($hook, $entity_type, $returnvalue, $p return $returnvalue; } +/** + * Creates a relationship between this site and the user. + * + * @param $event + * @param $object_type + * @param $object + * @return bool + */ +function user_create_hook_add_site_relationship($event, $object_type, $object) { + global $CONFIG; + + add_entity_relationship($object->getGUID(), 'member_of_site', $CONFIG->site->getGUID()); +} + /** * Sets up user-related menu items * @@ -1517,6 +1531,8 @@ function users_init() { register_plugin_hook('usersettings:save','user','users_settings_save'); + register_elgg_event_handler('create', 'user', 'user_create_hook_add_site_relationship'); + // Handle a special case for newly created users when the user is not logged in // TODO: handle this better! register_plugin_hook('permissions_check','all','new_user_enable_permissions_check'); -- cgit v1.2.3