From f7fa53526b70e20ac09ccdda701ee2ede1887273 Mon Sep 17 00:00:00 2001 From: marcus Date: Mon, 13 Oct 2008 09:35:29 +0000 Subject: Refs #235: Now possible for plugins to change default profile (plugin hook 'profile:fields', 'profile'. git-svn-id: https://code.elgg.org/elgg/trunk@2232 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/profile/start.php | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'mod/profile/start.php') diff --git a/mod/profile/start.php b/mod/profile/start.php index ecaed078d..82dc80396 100644 --- a/mod/profile/start.php +++ b/mod/profile/start.php @@ -27,8 +27,11 @@ register_metadata_as_independent('user'); // For now, we'll hard code the profile items as follows: - // TODO make this user configurable - $CONFIG->profile = array( + // TODO make this user configurable + + + + /*$CONFIG->profile = array( // Language short codes must be of the form "profile:key" // where key is the array key below @@ -42,7 +45,7 @@ 'mobile' => 'text', 'website' => 'url', - ); + );*/ // Register a page handler, so we can have nice URLs register_page_handler('profile','profile_page_handler'); @@ -68,8 +71,36 @@ } // Now override icons - register_plugin_hook('entity:icon:url', 'user', 'profile_usericon_hook'); - } + register_plugin_hook('entity:icon:url', 'user', 'profile_usericon_hook'); + + + } + + /** + * This function loads a set of default fields into the profile, then triggers a hook letting other plugins to edit + * add and delete fields. + * + * Note: This is a secondary system:init call and is run at a super low priority to guarantee that it is called after all + * other plugins have initialised. + */ + function profile_fields_setup() + { + global $CONFIG; + + $profile_defaults = array ( + 'description' => 'longtext', + 'briefdescription' => 'text', + 'location' => 'tags', + 'interests' => 'tags', + 'skills' => 'tags', + 'contactemail' => 'email', + 'phone' => 'text', + 'mobile' => 'text', + 'website' => 'url', + ); + + $CONFIG->profile = trigger_plugin_hook('profile:fields', 'profile', NULL, $profile_defaults); + } /** * Profile page handler @@ -172,10 +203,12 @@ return $url; } } - } + } // Make sure the profile initialisation function is called on initialisation - register_elgg_event_handler('init','system','profile_init',1); + register_elgg_event_handler('init','system','profile_init',1); + register_elgg_event_handler('init','system','profile_fields_setup', 10000); + // Register actions global $CONFIG; -- cgit v1.2.3