No Description

start.php 3.1KB

    <?php /** * AvidMind Profile plugin for elgg * * @package avid-profiles */ elgg_register_event_handler('init', 'system', 'avidprofile_init', 1); register_metadata_as_independent('user'); function avidprofile_init() { elgg_register_plugin_hook_handler('entity:url', 'user', 'avidprofile_set_url'); elgg_register_plugin_hook_handler('entity:icon:url', 'user','avidprofile_set_icon_url'); elgg_register_plugin_hook_handler('entity:icon:url', 'user','avidprofile_set_icon_url_fallback', 1000); # we don't want the default icon url handler, as it ignores any other # setting - which makes it hard to chain handlers elgg_unregister_plugin_hook_handler('entity:icon:url', 'user','user_avatar_hook'); elgg_register_page_handler('u', 'avidprofile_page_handler'); elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'avidprofile_owner_block_menu'); } function avidprofile_page_handler($page) { if (isset($page[0])) { $username = $page[0]; $user = get_user_by_username($username); elgg_set_page_owner_guid($user->guid); } elseif (elgg_is_logged_in()) { forward(elgg_get_logged_in_user_entity()->getURL()); } // short circuit if invalid or banned username if (!$user || ($user->isBanned() && !elgg_is_admin_logged_in())) { register_error(elgg_echo('profile:notfound')); forward(); } $action = NULL; if (isset($page[1])) { $action = $page[1]; } $content = ''; if ($action == 'edit') { $base_dir = elgg_get_root_path(); require "{$base_dir}pages/profile/edit.php"; return true; } elseif ($action === NULL and function_exists('avidelgg_list_stream')) { $content = avidelgg_list_stream(array(users=>array($user))); } else { $content = elgg_view('profile/about', array('entity' => $user)); } $body = elgg_view_layout('one_sidebar', array( 'content' => $content )); echo elgg_view_page($user->name, $body); return true; } function avidprofile_owner_block_menu($hook, $type, $return, $params) { elgg_log('avidprofile_owner_block_menu'); if (elgg_instanceof($params['entity'], 'user')) { $luser = elgg_get_logged_in_user_entity(); $owner = $params['entity']; if (function_exists('avidelgg_list_stream')) { $url = "u/{$owner->username}/about"; $item = new ElggMenuItem('profile_about', elgg_echo('profile:about', array('user'=>$owner->name)), $url); $result[] = $item; } } return $result; } function avidprofile_set_url($hook, $type, $url, $params) { $user = $params['entity']; return 'u/'.$user->username; } function avidprofile_set_icon_url($hook, $type, $url, $params) { if ($url) { return; } $user = $params['entity']; $size = $params['size']; $user_guid = $user->getGUID(); $icon_time = $user->icontime; if (!$icon_time) { return; } return "avatar/view/$user->username/$size/$user->icontime"; } function avidprofile_set_icon_url_fallback($hook, $type, $url, $params) { if ($url) { return; } $size = $params['size']; return "_graphics/icons/user/default{$size}.gif"; }