]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #804: A relationship is created between a new user and the site it was created on.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sun, 31 Jan 2010 01:29:24 +0000 (01:29 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sun, 31 Jan 2010 01:29:24 +0000 (01:29 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@3867 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/users.php

index 0171e838dfe84988823149f4ea491036e2c7a677..341024a45a0cdecffdf0b4c3bdd48ea9d198b418 100644 (file)
@@ -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');