diff options
Diffstat (limited to 'mod/profile')
33 files changed, 380 insertions, 672 deletions
diff --git a/mod/profile/graphics/defaultlarge.gif b/mod/profile/graphics/defaultlarge.gif Binary files differdeleted file mode 100644 index 6ea3bd4cd..000000000 --- a/mod/profile/graphics/defaultlarge.gif +++ /dev/null diff --git a/mod/profile/graphics/defaultmaster.gif b/mod/profile/graphics/defaultmaster.gif Binary files differdeleted file mode 100644 index 5bfd67a2d..000000000 --- a/mod/profile/graphics/defaultmaster.gif +++ /dev/null diff --git a/mod/profile/graphics/defaultmedium.gif b/mod/profile/graphics/defaultmedium.gif Binary files differdeleted file mode 100644 index c6b2e6a6d..000000000 --- a/mod/profile/graphics/defaultmedium.gif +++ /dev/null diff --git a/mod/profile/graphics/defaultsmall.gif b/mod/profile/graphics/defaultsmall.gif Binary files differdeleted file mode 100644 index 661d72f04..000000000 --- a/mod/profile/graphics/defaultsmall.gif +++ /dev/null diff --git a/mod/profile/graphics/defaulttiny.gif b/mod/profile/graphics/defaulttiny.gif Binary files differdeleted file mode 100644 index 1775346bc..000000000 --- a/mod/profile/graphics/defaulttiny.gif +++ /dev/null diff --git a/mod/profile/graphics/defaulttopbar.gif b/mod/profile/graphics/defaulttopbar.gif Binary files differdeleted file mode 100644 index c3616aeb5..000000000 --- a/mod/profile/graphics/defaulttopbar.gif +++ /dev/null diff --git a/mod/profile/graphics/drag_handle.png b/mod/profile/graphics/drag_handle.png Binary files differdeleted file mode 100644 index 2e9bc42be..000000000 --- a/mod/profile/graphics/drag_handle.png +++ /dev/null diff --git a/mod/profile/graphics/speech_bubble_tail.gif b/mod/profile/graphics/speech_bubble_tail.gif Binary files differdeleted file mode 100644 index 31d1bc90d..000000000 --- a/mod/profile/graphics/speech_bubble_tail.gif +++ /dev/null diff --git a/mod/profile/graphics/twitter16px.png b/mod/profile/graphics/twitter16px.png Binary files differdeleted file mode 100644 index de51c6953..000000000 --- a/mod/profile/graphics/twitter16px.png +++ /dev/null diff --git a/mod/profile/icon.php b/mod/profile/icon.php deleted file mode 100644 index 48ccc16c2..000000000 --- a/mod/profile/icon.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -/** -* Elgg profile icon -* -* @package ElggProfile -*/ - -require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); - -// Get the owning user -$user = elgg_get_page_owner(); - -// Get the size -$size = strtolower(get_input('size')); -if (!in_array($size,array('large','medium','small','tiny','master','topbar'))) - $size = "medium"; - -// If user doesn't exist, return default icon -if (!$user) { - $path = elgg_view("icon/user/default/$size"); - header("Location: $path"); - exit; -} - -// Try and get the icon -$filehandler = new ElggFile(); -$filehandler->owner_guid = $user->getGUID(); -$filehandler->setFilename("profile/" . $user->getGUID() . $size . ".jpg"); - -$success = false; -if ($filehandler->open("read")) { - if ($contents = $filehandler->read($filehandler->size())) { - $success = true; - } -} - -if (!$success) { - global $CONFIG; - $path = elgg_view('icon/user/default/'.$size); - header("Location: {$path}"); - exit; -} - -header("Content-type: image/jpeg"); -header('Expires: ' . date('r',time() + 864000)); -header("Pragma: public"); -header("Cache-Control: public"); -header("Content-Length: " . strlen($contents)); - -$splitString = str_split($contents, 1024); - -foreach($splitString as $chunk) { - echo $chunk; -}
\ No newline at end of file diff --git a/mod/profile/icondirect.php b/mod/profile/icondirect.php index fe4726d1a..5f1599e0d 100644 --- a/mod/profile/icondirect.php +++ b/mod/profile/icondirect.php @@ -1,38 +1,47 @@ <?php - /** * Elgg profile icon cache/bypass * + * * @package ElggProfile */ - // Get DB settings require_once(dirname(dirname(dirname(__FILE__))). '/engine/settings.php'); global $CONFIG; -$joindate = (int)$_GET['joindate']; +// won't be able to serve anything if no joindate or guid +if (!isset($_GET['joindate']) || !isset($_GET['guid'])) { + header("HTTP/1.1 404 Not Found"); + exit; +} + +$join_date = (int)$_GET['joindate']; +$last_cache = (int)$_GET['lastcache']; // icontime $guid = (int)$_GET['guid']; +// If is the same ETag, content didn't changed. +$etag = $last_cache . $guid; +if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == "\"$etag\"") { + header("HTTP/1.1 304 Not Modified"); + exit; +} + $size = strtolower($_GET['size']); -if (!in_array($size,array('large','medium','small','tiny','master','topbar'))) { +if (!in_array($size, array('large', 'medium', 'small', 'tiny', 'master', 'topbar'))) { $size = "medium"; } -$mysql_dblink = @mysql_connect($CONFIG->dbhost,$CONFIG->dbuser,$CONFIG->dbpass, true); +$mysql_dblink = @mysql_connect($CONFIG->dbhost, $CONFIG->dbuser, $CONFIG->dbpass, true); if ($mysql_dblink) { - if (@mysql_select_db($CONFIG->dbname,$mysql_dblink)) { - - // get dataroot and simplecache_enabled in one select for efficiency - if ($result = mysql_query("select name, value from {$CONFIG->dbprefix}datalists where name in ('dataroot','simplecache_enabled')",$mysql_dblink)) { - $simplecache_enabled = true; + if (@mysql_select_db($CONFIG->dbname, $mysql_dblink)) { + $result = mysql_query("select name, value from {$CONFIG->dbprefix}datalists where name='dataroot'", $mysql_dblink); + if ($result) { $row = mysql_fetch_object($result); while ($row) { if ($row->name == 'dataroot') { - $dataroot = $row->value; - } else if ($row->name == 'simplecache_enabled') { - $simplecache_enabled = $row->value; + $data_root = $row->value; } $row = mysql_fetch_object($result); } @@ -40,23 +49,21 @@ if ($mysql_dblink) { @mysql_close($mysql_dblink); - // if the simplecache is enabled, we get icon directly - if ($simplecache_enabled) { + if (isset($data_root)) { - // first try to read icon directly - $user_path = date('Y/m/d/', $joindate) . $guid; - $filename = "$dataroot$user_path/profile/{$guid}{$size}.jpg"; - $contents = @file_get_contents($filename); - if (!empty($contents)) { + // this depends on ElggDiskFilestore::makeFileMatrix() + $user_path = date('Y/m/d/', $join_date) . $guid; + + $filename = "$data_root$user_path/profile/{$guid}{$size}.jpg"; + $filesize = @filesize($filename); + if ($filesize) { header("Content-type: image/jpeg"); - header('Expires: ' . date('r',time() + 864000)); + header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+6 months")), true); header("Pragma: public"); header("Cache-Control: public"); - header("Content-Length: " . strlen($contents)); - $splitString = str_split($contents, 1024); - foreach($splitString as $chunk) { - echo $chunk; - } + header("Content-Length: $filesize"); + header("ETag: \"$etag\""); + readfile($filename); exit; } } @@ -64,8 +71,7 @@ if ($mysql_dblink) { } -// simplecache is not turned on or something went wrong so load engine and try that way +// something went wrong so load engine and try to forward to default icon require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); -$user = get_entity($guid); -set_input('username', $user->username); -require_once(dirname(__FILE__).'/icon.php'); +elgg_log("Profile icon direct failed.", "WARNING"); +forward("_graphics/icons/user/default{$size}.gif"); diff --git a/mod/profile/languages/en.php b/mod/profile/languages/en.php index 6017a590c..50f04bb33 100644 --- a/mod/profile/languages/en.php +++ b/mod/profile/languages/en.php @@ -4,121 +4,8 @@ */ $english = array( - -/** - * Profile - */ - - 'profile' => "Profile", - 'profile:edit:default' => 'Profile fields', - 'profile:preview' => 'Preview', - -/** - * Profile menu items and titles - */ - - 'profile:yours' => "My profile", - 'profile:user' => "%s's profile", - - 'profile:edit' => "Edit profile", - 'profile:profilepictureinstructions' => "Your avatar is the image that's displayed on your profile page. <br /> You can change it as often as you'd like. (File formats accepted: GIF, JPG or PNG)", - 'profile:icon' => "Avatar", - 'profile:createicon' => "Create your avatar", - 'profile:currentavatar' => "Current avatar", - 'profile:createicon:header' => "Profile picture", - 'profile:profilepicturecroppingtool' => "Avatar cropping tool", - 'profile:createicon:instructions' => "Click and drag a square below to match how you want your avatar cropped. A preview will appear in the box on the right. When you are happy with the preview, click 'Create your avatar'. This cropped version will be used throughout the site as your avatar. ", - - 'profile:editdetails' => "Edit profile", - 'profile:editicon' => "Edit avatar", - - 'profile:aboutme' => "About me", - 'profile:description' => "About me", - 'profile:briefdescription' => "Brief description", - 'profile:location' => "Location", - 'profile:skills' => "Skills", - 'profile:interests' => "Interests", - 'profile:contactemail' => "Contact email", - 'profile:phone' => "Telephone", - 'profile:mobile' => "Mobile phone", - 'profile:website' => "Website", - - 'profile:banned' => 'This user account has been suspended.', - 'profile:deleteduser' => 'Deleted user', - - 'profile:river:update' => "%s updated their profile", - 'profile:river:iconupdate' => "%s updated their profile icon", - - 'profile:label' => "Profile label", - 'profile:type' => "Profile type", - 'profile:twitter' => "Twitter username", - 'twitter:visit' => "Visit this Twitter account", - 'profile:editdefault:fail' => 'Default profile could not be saved', - 'profile:editdefault:success' => 'Item successfully added to default profile', - - - 'profile:editdefault:delete:fail' => 'Removed default profile item field failed', - 'profile:editdefault:delete:success' => 'Default profile item deleted!', - - 'profile:defaultprofile:reset' => 'Default system profile reset', - - 'profile:resetdefault' => 'Reset default profile', - 'profile:explainchangefields' => 'You can replace the existing profile fields with your own using the form below. <br /><br />Give the new profile field a label, for example, \'Favorite team\', then select the field type (eg. text, url, tags), and click the \'Add\' button. To re-order the fields drag on the handle next to the field label. To edit a field label - click on the label\'s text to make it editable. <br />At any time you can revert back to the default profile set up, but you will loose any information already entered into custom fields on profile pages.', - - -/** - * Profile status messages - */ - - 'profile:saved' => "Your profile was successfully saved.", - 'profile:icon:uploaded' => "Your profile picture was successfully uploaded.", - -/** - * Profile comment wall - **/ - 'profile:commentwall:add' => "Add to the wall", - 'profile:commentwall' => "Comment Wall", - 'profile:commentwall:posted' => "You successfully posted on the comment wall.", - 'profile:commentwall:deleted' => "You successfully deleted the message.", - 'profile:commentwall:blank' => "Sorry; you need to actually put something in the message area before we can save it.", - 'profile:commentwall:notfound' => "Sorry; we could not find the specified item.", - 'profile:commentwall:notdeleted' => "Sorry; we could not delete this message.", - 'profile:commentwall:none' => "No comment wall posts found.", - 'profile:commentwall:somethingwentwrong' => "Something went wrong when trying to save your message, make sure you actually wrote a message.", - 'profile:commentwall:failure' => "An unexpected error occurred when adding your message. Please try again.", - -/** - * Email messages commentwall - */ - - 'profile:comment:subject' => 'You have a new message on your comment wall!', - 'profile:comment:body' => "You have a new message on your comment wall from %s. It reads: - - -%s - - -To view your message board comments, click here: - - %s - -To view %s's profile, click here: - - %s - -You cannot reply to this email.", - -/** - * Profile error messages - */ - - 'profile:no_friends' => 'This person hasn\'t added any friends yet!', - 'profile:no_groups' => 'This user has not joined any groups yet.', - 'profile:noaccess' => "You do not have permission to edit this profile.", - 'profile:notfound' => "Sorry, we could not find the specified profile.", - 'profile:icon:notfound' => "Sorry, there was a problem uploading your profile picture.", - 'profile:icon:noaccess' => 'You cannot change this profile icon', - 'profile:field_too_long' => 'Cannot save your profile information because the "%s" section is too long.', + 'profile' => 'Profile', + 'profile:notfound' => 'Sorry. We could not find the requested profile.', ); diff --git a/mod/profile/manifest.xml b/mod/profile/manifest.xml index a1307f24d..86fbc7b7b 100644 --- a/mod/profile/manifest.xml +++ b/mod/profile/manifest.xml @@ -1,14 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> -<plugin_manifest> - <field key="author" value="Curverider ltd" /> - <field key="version" value="1.8" /> - <field key="category" value="bundled" /> - <field key="category" value="social" /> - <field key="description" value="Elgg profile plugin." /> - <field key="website" value="http://www.elgg.org/" /> - <field key="copyright" value="(C) Curverider 2008-2010" /> - <field key="licence" value="GNU Public License version 2" /> - <field key="elgg_version" value="2010030101" /> - <field key="elgg_install_state" value="enabled" /> - <field key="admin_interface" value="advanced" /> +<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8"> + <name>Profile</name> + <description>The default profile plugin.</description> + <author>Core developers</author> + <version>1.8</version> + <category>bundled</category> + <category>social</category> + <website>http://elgg.org/</website> + <copyright>See COPYRIGHT.txt</copyright> + <license>GNU General Public License Version 2</license> + <activate_on_install>true</activate_on_install> + <requires> + <type>elgg_release</type> + <version>1.8</version> + </requires> </plugin_manifest> diff --git a/mod/profile/start.php b/mod/profile/start.php index 017f91378..ab596f235 100644 --- a/mod/profile/start.php +++ b/mod/profile/start.php @@ -7,59 +7,61 @@ elgg_register_event_handler('init', 'system', 'profile_init', 1); +// Metadata on users needs to be independent +// outside of init so it happens earlier in boot. See #3316 +register_metadata_as_independent('user'); + /** - * Profile init function; sets up the profile functions - * + * Profile init function */ function profile_init() { - global $CONFIG; // Register a URL handler for users - this means that profile_url() // will dictate the URL for all ElggUser objects - register_entity_url_handler('profile_url', 'user', 'all'); + elgg_register_entity_url_handler('user', 'all', 'profile_url'); - // Metadata on users needs to be independent - register_metadata_as_independent('user'); + elgg_register_plugin_hook_handler('entity:icon:url', 'user', 'profile_override_avatar_url'); + elgg_unregister_plugin_hook_handler('entity:icon:url', 'user', 'user_avatar_hook'); - elgg_view_register_simplecache('icon/user/default/tiny'); - elgg_view_register_simplecache('icon/user/default/topbar'); - elgg_view_register_simplecache('icon/user/default/small'); - elgg_view_register_simplecache('icon/user/default/medium'); - elgg_view_register_simplecache('icon/user/default/large'); - elgg_view_register_simplecache('icon/user/default/master'); - // Register a page handler, so we can have nice URLs - register_page_handler('profile', 'profile_page_handler'); + elgg_register_simplecache_view('icon/user/default/tiny'); + elgg_register_simplecache_view('icon/user/default/topbar'); + elgg_register_simplecache_view('icon/user/default/small'); + elgg_register_simplecache_view('icon/user/default/medium'); + elgg_register_simplecache_view('icon/user/default/large'); + elgg_register_simplecache_view('icon/user/default/master'); - elgg_extend_view('html_head/extend', 'profile/metatags'); - elgg_extend_view('css/screen', 'profile/css'); + elgg_register_page_handler('profile', 'profile_page_handler'); - // Register actions - elgg_register_action("profile/addcomment", $CONFIG->pluginspath . "profile/actions/addcomment.php"); - elgg_register_action("profile/deletecomment", $CONFIG->pluginspath . "profile/actions/deletecomment.php"); + elgg_extend_view('page/elements/head', 'profile/metatags'); + elgg_extend_view('css/elgg', 'profile/css'); + elgg_extend_view('js/elgg', 'profile/js'); - elgg_register_event_handler('profileupdate', 'all', 'object_notifications'); - // allow ECML in parts of the profile elgg_register_plugin_hook_handler('get_views', 'ecml', 'profile_ecml_views_hook'); + + // allow admins to set default widgets for users on profiles + elgg_register_plugin_hook_handler('get_list', 'default_widgets', 'profile_default_widgets_hook'); } /** * Profile page handler * - * @param array $page Array of page elements, forwarded by the page handling mechanism + * @param array $page Array of URL segments passed by the page handling mechanism + * @return bool */ function profile_page_handler($page) { - global $CONFIG; 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() && !isadminloggedin())) { + if (!$user || ($user->isBanned() && !elgg_is_admin_logged_in())) { register_error(elgg_echo('profile:notfound')); forward(); } @@ -70,64 +72,117 @@ function profile_page_handler($page) { } if ($action == 'edit') { - // use for the core profile edit page - require $CONFIG->path . 'pages/profile/edit.php'; - return; + // use the core profile edit page + $base_dir = elgg_get_root_path(); + require "{$base_dir}pages/profile/edit.php"; + return true; } // main profile page $params = array( - 'box' => elgg_view('profile/box'), + 'content' => elgg_view('profile/wrapper'), 'num_columns' => 3, ); $content = elgg_view_layout('widgets', $params); $body = elgg_view_layout('one_column', array('content' => $content)); - echo elgg_view_page($title, $body); + echo elgg_view_page($user->name, $body); + return true; } /** - * Returns the html for a user profile. - * - * @param string $username The username of the profile to display - * @param string $section Which section is currently selected. + * Profile URL generator for $user->getUrl(); * - * @todo - This should really use a plugin hook to get the list of plugin tabs + * @param ElggUser $user + * @return string User URL + */ +function profile_url($user) { + return elgg_get_site_url() . "profile/" . $user->username; +} + +/** + * Use a URL for avatars that avoids loading Elgg engine for better performance * - * @return mixed FALSE or html for the profile. + * @param string $hook + * @param string $entity_type + * @param string $return_value + * @param array $params + * @return string */ -function profile_get_user_profile_html($user, $section = 'activity') { - $body = elgg_view('profile/tab_navigation', array('section' => $section, 'entity' => $user)); - $view_options = array('entity' => $user); +function profile_override_avatar_url($hook, $entity_type, $return_value, $params) { - $content = elgg_view("profile/tabs/$section", $view_options); + // if someone already set this, quit + if ($return_value) { + return null; + } - $body .= elgg_view('profile/content_wrapper', array('content' => $content)); + $user = $params['entity']; + $size = $params['size']; + + if (!elgg_instanceof($user, 'user')) { + return null; + } - $body .= elgg_view('profile/sidebar', array('section' => $section)); - return $body; + $user_guid = $user->getGUID(); + $icon_time = $user->icontime; + + if (!$icon_time) { + return "_graphics/icons/user/default{$size}.gif"; + } + + if ($user->isBanned()) { + return null; + } + + $filehandler = new ElggFile(); + $filehandler->owner_guid = $user_guid; + $filehandler->setFilename("profile/{$user_guid}{$size}.jpg"); + + try { + if ($filehandler->exists()) { + $join_date = $user->getTimeCreated(); + return "mod/profile/icondirect.php?lastcache=$icon_time&joindate=$join_date&guid=$user_guid&size=$size"; + } + } catch (InvalidParameterException $e) { + elgg_log("Unable to get profile icon for user with GUID $user_guid", 'ERROR'); + return "_graphics/icons/default/$size.png"; + } + + return null; } /** - * Profile URL generator for $user->getUrl(); + * Parse ECML on parts of the profile * - * @param ElggUser $user - * @return string User URL + * @param string $hook + * @param string $entity_type + * @param array $return_value + * @return array */ -function profile_url($user) { - return elgg_get_site_url() . "pg/profile/" . $user->username; +function profile_ecml_views_hook($hook, $entity_type, $return_value) { + $return_value['profile/profile_content'] = elgg_echo('profile'); + + return $return_value; } /** - * Parse ECML on parts of the profile + * Register profile widgets with default widgets * - * @param unknown_type $hook - * @param unknown_type $entity_type - * @param unknown_type $return_value - * @param unknown_type $params + * @param string $hook + * @param string $type + * @param array $return + * @return array */ -function profile_ecml_views_hook($hook, $entity_type, $return_value, $params) { - $return_value['profile/profile_content'] = elgg_echo('profile'); +function profile_default_widgets_hook($hook, $type, $return) { + $return[] = array( + 'name' => elgg_echo('profile'), + 'widget_context' => 'profile', + 'widget_columns' => 3, + + 'event' => 'create', + 'entity_type' => 'user', + 'entity_subtype' => ELGG_ENTITIES_ANY_VALUE, + ); - return $return_value; + return $return; } diff --git a/mod/profile/views/default/icon/user/default/large.php b/mod/profile/views/default/icon/user/default/large.php deleted file mode 100644 index ac28f8e9a..000000000 --- a/mod/profile/views/default/icon/user/default/large.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - echo elgg_get_site_url() . "mod/profile/graphics/defaultlarge.gif"; -?>
\ No newline at end of file diff --git a/mod/profile/views/default/icon/user/default/master.php b/mod/profile/views/default/icon/user/default/master.php deleted file mode 100644 index 129b0d375..000000000 --- a/mod/profile/views/default/icon/user/default/master.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - echo elgg_get_site_url() . "mod/profile/graphics/defaultmaster.gif"; -?>
\ No newline at end of file diff --git a/mod/profile/views/default/icon/user/default/medium.php b/mod/profile/views/default/icon/user/default/medium.php deleted file mode 100644 index 8815a65bc..000000000 --- a/mod/profile/views/default/icon/user/default/medium.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - echo elgg_get_site_url() . "mod/profile/graphics/defaultmedium.gif"; -?>
\ No newline at end of file diff --git a/mod/profile/views/default/icon/user/default/small.php b/mod/profile/views/default/icon/user/default/small.php deleted file mode 100644 index 895aa15cc..000000000 --- a/mod/profile/views/default/icon/user/default/small.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - echo elgg_get_site_url() . "mod/profile/graphics/defaultsmall.gif"; -?>
\ No newline at end of file diff --git a/mod/profile/views/default/icon/user/default/tiny.php b/mod/profile/views/default/icon/user/default/tiny.php deleted file mode 100644 index 866c61533..000000000 --- a/mod/profile/views/default/icon/user/default/tiny.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - echo elgg_get_site_url() . "mod/profile/graphics/defaulttiny.gif"; -?>
\ No newline at end of file diff --git a/mod/profile/views/default/icon/user/default/topbar.php b/mod/profile/views/default/icon/user/default/topbar.php deleted file mode 100644 index 0ff3dbaaa..000000000 --- a/mod/profile/views/default/icon/user/default/topbar.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - echo elgg_get_site_url() . "mod/profile/graphics/defaulttopbar.gif"; -?>
\ No newline at end of file diff --git a/mod/profile/views/default/profile/box.php b/mod/profile/views/default/profile/box.php deleted file mode 100644 index 77c408536..000000000 --- a/mod/profile/views/default/profile/box.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php -/** - * Profile info box - */ - -?> -<div class="profile elgg-col-2of3"> - <div class="elgg-inner clearfix"> -<?php - echo elgg_view('profile/sidebar', array('section' => 'details')); - echo elgg_view('profile/details', array('entity' => elgg_get_page_owner())); -?> - </div> -</div> - -<script type="text/javascript"> - $(document).ready(function() { - $('#elgg-widget-col-1').css('min-height', $('.profile').outerHeight(true)); - //$(selector).each(function() { - // if ($(this).height() > maxHeight) { - // maxHeight = $(this).height(); - // } - //}) - //$(selector).css('min-height', maxHeight); - }); -</script>
\ No newline at end of file diff --git a/mod/profile/views/default/profile/css.php b/mod/profile/views/default/profile/css.php index 754276c69..e24f555a9 100644 --- a/mod/profile/views/default/profile/css.php +++ b/mod/profile/views/default/profile/css.php @@ -1,12 +1,12 @@ <?php /** - * Elgg Profile + * Elgg Profile CSS * * @package Profile */ ?> /* *************************************** - main layout blocks + Profile *************************************** */ .profile { float: left; @@ -14,156 +14,113 @@ } .profile .elgg-inner { margin: 0 5px; - border: 2px solid #eeeeee; + border: 2px solid #eee; + -webkit-border-radius: 8px; -moz-border-radius: 8px; -} -#profile-sidebar { - width:230px; - float:left; + border-radius: 8px; } #profile-details { padding: 15px; } - -/* *************************************** - ownerblock in sidebar -*************************************** */ -#profile-sidebar #owner_block { - background-color: #eeeeee; - padding:15px; -} -#owner_block .owner_block_icon.large { - overflow: hidden; +/*** ownerblock ***/ +#profile-owner-block { + width: 200px; + float: left; + background-color: #eee; + padding: 15px; } -#owner_block .profile_actions { - margin-top:10px; +#profile-owner-block .large { + margin-bottom: 10px; } -#owner_block .profile_actions a.elgg-action-button { - margin-bottom:4px; +#profile-owner-block a.elgg-button-action { + margin-bottom: 4px; display: table; } -/* ownerblock links to owners tools */ -#owner_block .owners_content_links { - border-top:1px dotted #cccccc; - margin-top:4px; - padding-top:2px; -} -#owner_block .owners_content_links ul { - margin:0; - padding:0; -} -#owner_block .owners_content_links ul li { - display:block; - float:left; - width:95px; - font-size: 90%; -} -/* profile pages - ownerblock links to owners tools */ -.owner_block_links { - margin-top:5px; -} -.owner_block_links ul { - margin:0; - padding:0; - list-style: none; -} -.owner_block_links ul li.selected a { - background: #4690D6; - color:white; -} -.owner_block_links ul li a { - display:block; - -webkit-border-radius: 8px; +.profile-content-menu a { + display: block; + + -webkit-border-radius: 8px; -moz-border-radius: 8px; - background-color:white; - margin:3px 0 5px 0; - padding:2px 4px 2px 8px; + border-radius: 8px; + + background-color: white; + margin: 3px 0 5px 0; + padding: 2px 4px 2px 8px; } -.owner_block_links ul li a:hover { - background:#0054A7; - color:white; - text-decoration:none; +.profile-content-menu a:hover { + background: #0054A7; + color: white; + text-decoration: none; } - - -/* *************************************** - admin menu in sidebar -*************************************** */ -.owner_block_links .admin_menu_options { +.profile-admin-menu { display: none; } -.owner_block_links ul.admin_menu { - background-color:white; +.profile-admin-menu-wrapper a { + display: block; + -webkit-border-radius: 8px; -moz-border-radius: 8px; - cursor:pointer; + border-radius: 8px; + + background-color: white; + margin: 3px 0 5px 0; + padding: 2px 4px 2px 8px; } -.owner_block_links ul.admin_menu li a { +.profile-admin-menu-wrapper { background-color: white; - color:red; - margin-bottom:0; -} -.owner_block_links ul.admin_menu li a:hover { - color:black; -} -.owner_block_links ul.admin_menu li ul.admin_menu_options li a { - color:red; - background-color:white; - display:block; - margin:0px; - padding:2px 4px 2px 13px; -} -.owner_block_links ul.admin_menu li ul.admin_menu_options li a:hover { - color:black; - background:none; - text-decoration: underline; -} - - -/* *************************************** - full profile info panel -*************************************** */ + + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + border-radius: 8px; +} +.profile-admin-menu-wrapper li a { + background-color: white; + color: red; + margin-bottom: 0; +} +.profile-admin-menu-wrapper a:hover { + color: black; +} +/*** profile details ***/ #profile-details .odd { - background-color:#f4f4f4; + background-color: #f4f4f4; + -webkit-border-radius: 4px; -moz-border-radius: 4px; - margin:0 0 7px 0; - padding:2px 4px 2px 4px; + border-radius: 4px; + + margin: 0 0 7px; + padding: 2px 4px; } #profile-details .even { background-color:#f4f4f4; + -webkit-border-radius: 4px; -moz-border-radius: 4px; - margin:0 0 7px 0; - padding:2px 4px 2px 4px; + border-radius: 4px; + + margin: 0 0 7px; + padding: 2px 4px; } -#profile-details .aboutme_title { +.profile-aboutme-title { background-color:#f4f4f4; + -webkit-border-radius: 4px; -moz-border-radius: 4px; - margin:0 0 0px 0; - padding:2px 4px 2px 4px; -} -#profile-details .aboutme_contents { - padding:2px 0 0 3px; -} - -/* *************************************** - banned user -*************************************** */ -/* banned user full profile panel */ -#profile_content .banned_user { - border:2px solid red; - padding:4px 8px; + border-radius: 4px; + + margin: 0; + padding: 2px 4px; +} +.profile-aboutme-contents { + padding: 2px 0 0 3px; +} +.profile-banned-user { + border: 2px solid red; + padding: 4px 8px; + -webkit-border-radius: 6px; -moz-border-radius: 6px; + border-radius: 6px; } -/* banned user in friends lists */ -.entity-listing-info p.entity-title.user.banned { - text-decoration: line-through; -} -.entity-listing-info p.entity-title.user.banned a { - color:red; -} - diff --git a/mod/profile/views/default/profile/details.php b/mod/profile/views/default/profile/details.php index c2f4cc01b..da4e95690 100644 --- a/mod/profile/views/default/profile/details.php +++ b/mod/profile/views/default/profile/details.php @@ -4,41 +4,63 @@ * @uses $vars['entity'] The user entity */ +$user = elgg_get_page_owner_entity(); + +$profile_fields = elgg_get_config('profile_fields'); + echo '<div id="profile-details" class="elgg-body pll">'; -echo "<h2>{$vars['entity']->name}</h2>"; +echo "<h2>{$user->name}</h2>"; + +echo elgg_view("profile/status", array("entity" => $user)); $even_odd = null; -if (is_array($vars['config']->profile) && sizeof($vars['config']->profile) > 0) { - foreach($vars['config']->profile as $shortname => $valtype) { - if ($shortname != "description") { - $value = $vars['entity']->$shortname; - if (!empty($value)) { - //This function controls the alternating class - $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; - ?> - <p class="<?php echo $even_odd; ?>"> - <b><?php - echo elgg_echo("profile:{$shortname}"); - ?>: </b> +if (is_array($profile_fields) && sizeof($profile_fields) > 0) { + foreach ($profile_fields as $shortname => $valtype) { + if ($shortname == "description") { + // skip about me and put at bottom + continue; + } + $value = $user->$shortname; + + if (!empty($value)) { + + // fix profile URLs populated by https://github.com/Elgg/Elgg/issues/5232 + // @todo Replace with upgrade script, only need to alter users with last_update after 1.8.13 + if ($valtype == 'url' && $value == 'http://') { + $user->$shortname = ''; + continue; + } + + // validate urls + if ($valtype == 'url' && !preg_match('~^https?\://~i', $value)) { + $value = "http://$value"; + } + + // this controls the alternating class + $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; + ?> + <div class="<?php echo $even_odd; ?>"> + <b><?php echo elgg_echo("profile:{$shortname}"); ?>: </b> <?php - echo elgg_view("output/{$valtype}", array('value' => $vars['entity']->$shortname)); + echo elgg_view("output/{$valtype}", array('value' => $value)); ?> - </p> - <?php - } + </div> + <?php } } } -if (!get_plugin_setting('user_defined_fields', 'profile')) { - if ($vars['entity']->isBanned()) { - echo "<div class='banned_user'>"; - echo elgg_echo('profile:banned'); - echo "</div>"; +if (!elgg_get_config('profile_custom_fields')) { + if ($user->isBanned()) { + echo "<p class='profile-banned-user'>"; + echo elgg_echo('banned'); + echo "</p>"; } else { - if ($vars['entity']->description) { - echo "<p class='aboutme_title'><b>" . elgg_echo("profile:aboutme") . "</b></p>"; - echo "<div class='aboutme_contents'>" . elgg_view('output/longtext', array('value' => $vars['entity']->description)) . "</div>"; + if ($user->description) { + echo "<p class='profile-aboutme-title'><b>" . elgg_echo("profile:aboutme") . "</b></p>"; + echo "<div class='profile-aboutme-contents'>"; + echo elgg_view('output/longtext', array('value' => $user->description, 'class' => 'mtn')); + echo "</div>"; } } } diff --git a/mod/profile/views/default/profile/js.php b/mod/profile/views/default/profile/js.php new file mode 100644 index 000000000..5a08a90bd --- /dev/null +++ b/mod/profile/views/default/profile/js.php @@ -0,0 +1,9 @@ + +// force the first column to at least be as large as the profile box in cols 2 and 3 +// we also want to run before the widget init happens so priority is < 500 +elgg.register_hook_handler('init', 'system', function() { + // only do this on the profile page's widget canvas. + if ($('.profile').length) { + $('#elgg-widget-col-1').css('min-height', $('.profile').outerHeight(true) + 1); + } +}, 400); diff --git a/mod/profile/views/default/profile/listing.php b/mod/profile/views/default/profile/listing.php deleted file mode 100644 index 489b1d50e..000000000 --- a/mod/profile/views/default/profile/listing.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * Elgg user display (small) - * - * @package ElggProfile - * - * @uses $vars['entity'] The user entity - */ - -$icon = elgg_view( - "profile/icon", array( - 'entity' => $vars['entity'], - 'size' => 'tiny', - ) -); - -$banned = $vars['entity']->isBanned(); - -// Simple XFN -$rel_type = ""; -if (get_loggedin_userid() == $vars['entity']->guid) { - $rel_type = 'me'; -} elseif (check_entity_relationship(get_loggedin_userid(), 'friend', $vars['entity']->guid)) { - $rel_type = 'friend'; -} - -if ($rel_type) { - $rel = "rel=\"$rel_type\""; -} - -if (!$banned) { - $info .= "<p class='entity-title user'><a href=\"" . $vars['entity']->getUrl() . "\" $rel>" . $vars['entity']->name . "</a></p>"; - $location = $vars['entity']->location; - if (!empty($location)) { - $info .= "<p class='entity-subtext user'>" . elgg_echo("profile:location") . ": " . elgg_view("output/tags",array('value' => $vars['entity']->location)) . "</p>"; - } - //create a view that a status plugin could extend - in the default case, this is the wire - $info .= elgg_view("profile/status", array("entity" => $vars['entity'])); -}else{ - $info .= "<p class='entity-title user banned'>"; - if (isadminloggedin()) - $info .= "<a href=\"" . $vars['entity']->getUrl() . "\">"; - $info .= $vars['entity']->name; - if (isadminloggedin()) - $info .= "</a>"; - $info .= "</p>"; -} - -echo elgg_view_image_block($icon, $info); diff --git a/mod/profile/views/default/profile/menu/adminlinks.php b/mod/profile/views/default/profile/menu/adminlinks.php deleted file mode 100644 index 39807764a..000000000 --- a/mod/profile/views/default/profile/menu/adminlinks.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** - * Profile admin context links - * - * @package ElggProfile - * - * @uses $vars['entity'] The user entity - */ - -if (isadminloggedin()){ - if (get_loggedin_userid()!=$vars['entity']->guid){ -?> - <a href="<?php echo elgg_get_site_url(); ?>pg/settings/user/<?php echo $vars['entity']->username; ?>/"><?php echo elgg_echo('profile:editdetails'); ?></a> -<?php - if (!$vars['entity']->isBanned()) { - echo elgg_view('output/confirmlink', array('text' => elgg_echo("ban"), 'href' => "action/admin/user/ban?guid={$vars['entity']->guid}")); - } else { - echo elgg_view('output/confirmlink', array('text' => elgg_echo("unban"), 'href' => "action/admin/user/unban?guid={$vars['entity']->guid}")); - } - echo elgg_view('output/confirmlink', array('text' => elgg_echo("delete"), 'href' => "action/admin/user/delete?guid={$vars['entity']->guid}")); - echo elgg_view('output/confirmlink', array('text' => elgg_echo("resetpassword"), 'href' => "action/admin/user/resetpassword?guid={$vars['entity']->guid}")); - if (!$vars['entity']->isAdmin()) { - echo elgg_view('output/confirmlink', array('text' => elgg_echo("makeadmin"), 'href' => "action/admin/user/makeadmin?guid={$vars['entity']->guid}")); - } else { - echo elgg_view('output/confirmlink', array('text' => elgg_echo("removeadmin"), 'href' => "action/admin/user/removeadmin?guid={$vars['entity']->guid}")); - } - } - } diff --git a/mod/profile/views/default/profile/menu/friendlinks.php b/mod/profile/views/default/profile/menu/friendlinks.php deleted file mode 100644 index ed13edb8b..000000000 --- a/mod/profile/views/default/profile/menu/friendlinks.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php -/** - * Elgg profile icon avatar menu: Add / Remove friend links - * - * @package ElggProfile - * - * @uses $vars['entity'] The user entity. If none specified, the current user is assumed. - */ -$ts = time(); -$token = generate_action_token($ts); -if ($vars['entity']->isFriend()) { - echo elgg_view('output/confirmlink', array( - 'href' => "action/friends/remove?friend={$vars['entity']->getGUID()}", - 'text' => elgg_echo('friend:remove'), - 'class' => 'remove_friend' - )); -} else { - echo elgg_view('output/confirmlink', array( - 'href' => "action/friends/add?friend={$vars['entity']->getGUID()}", - 'text' => elgg_echo('friend:add'), - 'class' => 'add_friend' - )); -}
\ No newline at end of file diff --git a/mod/profile/views/default/profile/menu/links.php b/mod/profile/views/default/profile/menu/links.php deleted file mode 100644 index 4233d7ec5..000000000 --- a/mod/profile/views/default/profile/menu/links.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php -/** - * Elgg profile icon avatar menu: view for plugins to extend - * - * @package ElggProfile - * - * @uses $vars['entity'] The user entity. If none specified, the current user is assumed. - */ -?> diff --git a/mod/profile/views/default/profile/metatags.php b/mod/profile/views/default/profile/metatags.php index 1197a2e0a..52048b8a7 100644 --- a/mod/profile/views/default/profile/metatags.php +++ b/mod/profile/views/default/profile/metatags.php @@ -6,9 +6,11 @@ * */ -if (elgg_get_page_owner()) { +$owner = elgg_get_page_owner_entity(); + +if (elgg_instanceof($owner, 'user')) { ?> - <link rel="meta" type="application/rdf+xml" title="FOAF" href="<?php echo full_url(); ?>?view=foaf" /> + <link rel="meta" type="application/rdf+xml" title="FOAF" href="<?php echo current_page_url(); ?>?view=foaf" /> <?php -}
\ No newline at end of file +} diff --git a/mod/profile/views/default/profile/owner_block.php b/mod/profile/views/default/profile/owner_block.php new file mode 100644 index 000000000..63cb5391a --- /dev/null +++ b/mod/profile/views/default/profile/owner_block.php @@ -0,0 +1,66 @@ +<?php +/** + * Profile owner block + */ + +$user = elgg_get_page_owner_entity(); + +if (!$user) { + // no user so we quit view + echo elgg_echo('viewfailure', array(__FILE__)); + return TRUE; +} + +$icon = elgg_view_entity_icon($user, 'large', array( + 'use_hover' => false, + 'use_link' => false, +)); + +// grab the actions and admin menu items from user hover +$menu = elgg_trigger_plugin_hook('register', "menu:user_hover", array('entity' => $user), array()); +$builder = new ElggMenuBuilder($menu); +$menu = $builder->getMenu(); +$actions = elgg_extract('action', $menu, array()); +$admin = elgg_extract('admin', $menu, array()); + +$profile_actions = ''; +if (elgg_is_logged_in() && $actions) { + $profile_actions = '<ul class="elgg-menu profile-action-menu mvm">'; + foreach ($actions as $action) { + $profile_actions .= '<li>' . $action->getContent(array('class' => 'elgg-button elgg-button-action')) . '</li>'; + } + $profile_actions .= '</ul>'; +} + +// if admin, display admin links +$admin_links = ''; +if (elgg_is_admin_logged_in() && elgg_get_logged_in_user_guid() != elgg_get_page_owner_guid()) { + $text = elgg_echo('admin:options'); + + $admin_links = '<ul class="profile-admin-menu-wrapper">'; + $admin_links .= "<li><a rel=\"toggle\" href=\"#profile-menu-admin\">$text…</a>"; + $admin_links .= '<ul class="profile-admin-menu" id="profile-menu-admin">'; + foreach ($admin as $menu_item) { + $admin_links .= elgg_view('navigation/menu/elements/item', array('item' => $menu_item)); + } + $admin_links .= '</ul>'; + $admin_links .= '</li>'; + $admin_links .= '</ul>'; +} + +// content links +$content_menu = elgg_view_menu('owner_block', array( + 'entity' => elgg_get_page_owner_entity(), + 'class' => 'profile-content-menu', +)); + +echo <<<HTML + +<div id="profile-owner-block"> + $icon + $profile_actions + $content_menu + $admin_links +</div> + +HTML; diff --git a/mod/profile/views/default/profile/ownerblock.php b/mod/profile/views/default/profile/ownerblock.php deleted file mode 100755 index 7670f5699..000000000 --- a/mod/profile/views/default/profile/ownerblock.php +++ /dev/null @@ -1,91 +0,0 @@ -<?php -/** - * A simple owner block which houses info about the user whose 'stuff' you are looking at - */ - -// get the user who owns this profile -if ($vars['entity']) { - if ($vars['context'] == 'edit') { - $user = get_entity($vars['entity']->container_guid); - } else { - $user = get_entity($vars['entity']->guid); - } -} else { - $user = elgg_get_page_owner(); -} -if (!$user) { - // no user so we quit view - echo elgg_echo('viewfailure', array(__FILE__)); - return TRUE; -} - -$more_info = ''; - -$location = elgg_view("output/tags",array('value' => $user->location)); - -$icon = elgg_view("profile/icon",array('entity' => $user, 'size' => 'large', 'override' => 'true')); -$icon_class = "large"; - -// @todo pull out into menu -$profile_actions = ""; -if (isloggedin() && (get_loggedin_userid() == elgg_get_page_owner_guid())) { - $profile_actions = "<div class='clearfix profile_actions'>"; - $profile_actions .= "<a href='".elgg_get_site_url()."pg/profile/{$user->username}/edit/details' class='elgg-action-button'>". elgg_echo('profile:edit') ."</a>"; - $profile_actions .= "<a href='".elgg_get_site_url()."pg/avatar/edit/{$user->username}' class='elgg-action-button'>". elgg_echo('avatar:edit') ."</a>"; - $profile_actions .= "</div>"; -} else { - $profile_actions = "<div class='profile_actions'>"; - if (isloggedin()) { - if (get_loggedin_userid() != $user->getGUID()) { - if ($user->isFriend()) { - $url = elgg_get_site_url()."action/friends/remove?friend={$user->getGUID()}"; - $url = elgg_add_action_tokens_to_url($url); - $profile_actions .= "<a href=\"$url\" class='elgg-action-button'>" . elgg_echo('friend:remove') . "</a>"; - } else { - $url = elgg_get_site_url()."action/friends/add?friend={$user->getGUID()}"; - $url = elgg_add_action_tokens_to_url($url); - $profile_actions .= "<a href=\"$url\" class='elgg-action-button'>" . elgg_echo('friend:add') . "</a>"; - } - } - } - if (is_plugin_enabled('messages') && isloggedin()) { - $profile_actions .= "<a href=\"".elgg_get_site_url()."mod/messages/send.php?send_to={$user->guid}\" class='elgg-action-button'>". elgg_echo('messages:send') ."</a>"; - } - $profile_actions .= "</div>"; -} - - -// if admin, display admin links -$admin_links = ''; -if (isadminloggedin() && get_loggedin_userid() != elgg_get_page_owner_guid()) { - $params = array( - 'user' => elgg_get_page_owner(), - 'toggle' => true, - 'sort_by' => 'order', - ); - $admin_links = elgg_view_menu('user_admin', $params); - $admin_links = "<div class=\"owner_block_links\">$admin_links</div>"; -} - -// content links -$menu = elgg_view_menu('user_ownerblock', array('user' => elgg_get_page_owner())); - -//contruct the display -$display = <<<EOT - -<div id="owner_block"> - <div class="owner_block_icon {$icon_class}"> - {$icon} - </div> - {$more_info} - {$profile_actions} - <div class="owner_block_links"> - $menu - </div> - <!-- if admin user --> - {$admin_links} -</div> - -EOT; - -echo $display; diff --git a/mod/profile/views/default/profile/sidebar.php b/mod/profile/views/default/profile/sidebar.php deleted file mode 100644 index d98964f5b..000000000 --- a/mod/profile/views/default/profile/sidebar.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php -/** - * Elgg profile icon edit form - * - * @package ElggProfile - */ -?> -<div id="profile-sidebar"> -<?php - $section = $vars['section']; - echo elgg_view('profile/ownerblock', array('section' => $section)); -?> -</div>
\ No newline at end of file diff --git a/mod/profile/views/default/profile/wrapper.php b/mod/profile/views/default/profile/wrapper.php new file mode 100644 index 000000000..73b7934f2 --- /dev/null +++ b/mod/profile/views/default/profile/wrapper.php @@ -0,0 +1,12 @@ +<?php +/** + * Profile info box + */ + +?> +<div class="profile elgg-col-2of3"> + <div class="elgg-inner clearfix"> + <?php echo elgg_view('profile/owner_block'); ?> + <?php echo elgg_view('profile/details'); ?> + </div> +</div>
\ No newline at end of file |
