diff options
Diffstat (limited to 'mod/profile')
37 files changed, 589 insertions, 1666 deletions
diff --git a/mod/profile/actions/cropicon.php b/mod/profile/actions/cropicon.php deleted file mode 100644 index bcd8ea756..000000000 --- a/mod/profile/actions/cropicon.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php
-
- /**
- * Elgg profile plugin upload new user icon action
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- */
-
- $x1 = (int) get_input('x_1',0);
- $y1 = (int) get_input('y_1',0);
- $x2 = (int) get_input('x_2',0);
- $y2 = (int) get_input('y_2',0);
-
- $user = page_owner_entity();
-
- $filehandler = new ElggFile();
- $filehandler->owner_guid = $user->getGUID();
- $filehandler->setFilename("profile/" . $user->username . "master" . ".jpg");
- $filename = $filehandler->getFilenameOnFilestore();
-
- $tiny = get_resized_image_from_existing_file($filename,25,25, true, $x1, $y1, $x2, $y2);
- $small = get_resized_image_from_existing_file($filename,40,40, true, $x1, $y1, $x2, $y2);
- $medium = get_resized_image_from_existing_file($filename,100,100, true, $x1, $y1, $x2, $y2);
-
- if ($small !== false
- && $medium !== false
- && $tiny !== false) {
-
- $filehandler = new ElggFile();
- $filehandler->owner_guid = $_SESSION['user']->getGUID();
- $filehandler->setFilename("profile/" . $_SESSION['user']->username . "medium.jpg");
- $filehandler->open("write");
- $filehandler->write($medium);
- $filehandler->close();
- $filehandler->setFilename("profile/" . $_SESSION['user']->username . "small.jpg");
- $filehandler->open("write");
- $filehandler->write($small);
- $filehandler->close();
- $filehandler->setFilename("profile/" . $_SESSION['user']->username . "tiny.jpg");
- $filehandler->open("write");
- $filehandler->write($tiny);
- $filehandler->close();
-
- $user->x1 = $x1;
- $user->x2 = $x2;
- $user->y1 = $y1;
- $user->y2 = $y2;
-
- $_SESSION['user']->icontime = time();
-
- system_message(elgg_echo("profile:icon:uploaded"));
-
- } else {
- system_message(elgg_echo("profile:icon:notfound"));
- }
-
- //forward the user back to the upload page to crop
-
- $url = $vars['url'] . "mod/profile/editicon.php";
-
- if (isloggedin()) forward($url);
-
-?>
\ No newline at end of file diff --git a/mod/profile/actions/edit.php b/mod/profile/actions/edit.php deleted file mode 100644 index 7a74535cd..000000000 --- a/mod/profile/actions/edit.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php
-
- /**
- * Elgg profile plugin edit action
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- */
-
- // Load configuration
- global $CONFIG;
-
- // Get profile fields
- $input = array();
- foreach($CONFIG->profile as $shortname => $valuetype) {
- $input[$shortname] = get_input($shortname);
- if ($valuetype == 'tags')
- $input[$shortname] = string_to_tag_array($input[$shortname]);
- }
-
- // Save stuff if we can, and forward to the user's profile
-
- if ($user = page_owner()) {
- $user = page_owner_entity();
- } else {
- $user = $_SESSION['user'];
- set_page_owner($user->getGUID());
- }
- if ($user->canEdit()) {
-
- // Save stuff
- if (sizeof($input) > 0)
- foreach($input as $shortname => $value) {
- $user->$shortname = $value;
- }
- $user->save();
-
- system_message(elgg_echo("profile:saved"));
-
- // Forward to the user's profile
- forward($user->getUrl());
-
- } else {
- // If we can't, display an error
-
- system_message(elgg_echo("profile:cantedit"));
- }
-
-?>
\ No newline at end of file diff --git a/mod/profile/actions/iconupload.php b/mod/profile/actions/iconupload.php deleted file mode 100644 index bb3b19528..000000000 --- a/mod/profile/actions/iconupload.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php
-
- /**
- * Elgg profile plugin upload new user icon action
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- */
-
- // If we were given a correct icon
- if (
- isloggedin()
- ) {
-
- $tiny = get_resized_image_from_uploaded_file('profileicon',25,25, true);
- $small = get_resized_image_from_uploaded_file('profileicon',40,40, true);
- $medium = get_resized_image_from_uploaded_file('profileicon',100,100, true);
- $large = get_resized_image_from_uploaded_file('profileicon',200,200);
- $master = get_resized_image_from_uploaded_file('profileicon',600,600);
-
- if ($small !== false
- && $medium !== false
- && $large !== false
- && $tiny !== false) {
-
- $filehandler = new ElggFile();
- $filehandler->owner_guid = $_SESSION['user']->getGUID();
- $filehandler->setFilename("profile/" . $_SESSION['user']->username . "large.jpg");
- $filehandler->open("write");
- $filehandler->write($large);
- $filehandler->close();
- $filehandler->setFilename("profile/" . $_SESSION['user']->username . "medium.jpg");
- $filehandler->open("write");
- $filehandler->write($medium);
- $filehandler->close();
- $filehandler->setFilename("profile/" . $_SESSION['user']->username . "small.jpg");
- $filehandler->open("write");
- $filehandler->write($small);
- $filehandler->close();
- $filehandler->setFilename("profile/" . $_SESSION['user']->username . "tiny.jpg");
- $filehandler->open("write");
- $filehandler->write($tiny);
- $filehandler->close();
- $filehandler->setFilename("profile/" . $_SESSION['user']->username . "master.jpg");
- $filehandler->open("write");
- $filehandler->write($master);
- $filehandler->close();
-
- $_SESSION['user']->icontime = time();
-
- system_message(elgg_echo("profile:icon:uploaded"));
-
- } else {
- system_message(elgg_echo("profile:icon:notfound"));
- }
-
- } else {
-
- system_message(elgg_echo("profile:icon:notfound"));
-
- }
-
- //forward the user back to the upload page to crop
-
- $url = $vars['url'] . "mod/profile/editicon.php";
-
- if (isloggedin()) forward($url);
-
-?>
\ No newline at end of file diff --git a/mod/profile/edit.php b/mod/profile/edit.php deleted file mode 100644 index 69ca332e1..000000000 --- a/mod/profile/edit.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php
-
- /**
- * Elgg profile editor
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- */
-
- // Get the Elgg engine
- require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
- // If we're not logged on, forward the user elsewhere
- if (!isloggedin()) forward();
-
- // Get current user for now
- if ($user = page_owner()) {
- $user = page_owner_entity();
- } else {
- $user = $_SESSION['user']; - if (!$user) $user = get_entity($_SESSION['id']);
- set_page_owner($user->getGUID());
- }
-
- // Get form, if we're allowed to edit
- if ($user->canEdit()) {
-
- $area1 = elgg_view("profile/edit",array('entity' => $user));
-
- } else {
-
- $area1 = elgg_echo("profile:noaccess");
-
- }
-
- // get the required canvas area
- $body = elgg_view_layout("one_column", $area1);
-
- // Draw the page
- page_draw(elgg_echo("profile:edit"),$body);
-
-?>
\ No newline at end of file diff --git a/mod/profile/editicon.php b/mod/profile/editicon.php deleted file mode 100644 index 145932795..000000000 --- a/mod/profile/editicon.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php
-
- /**
- * Elgg upload new profile icon
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- */
-
- // Load the Elgg framework
- require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
- // Make sure we're logged in
- if (!isloggedin()) forward();
-
- // Get the form and correct canvas area
- $body = elgg_view_layout("one_column", elgg_view("profile/editicon"));
-
- // Draw the page
- page_draw(elgg_echo("profile:editicon"),$body);
-
-?>
\ No newline at end of file diff --git a/mod/profile/graphics/defaultlarge.jpg b/mod/profile/graphics/defaultlarge.jpg Binary files differdeleted file mode 100644 index 785bacdc3..000000000 --- a/mod/profile/graphics/defaultlarge.jpg +++ /dev/null diff --git a/mod/profile/graphics/defaultmedium.jpg b/mod/profile/graphics/defaultmedium.jpg Binary files differdeleted file mode 100644 index 767a16f48..000000000 --- a/mod/profile/graphics/defaultmedium.jpg +++ /dev/null diff --git a/mod/profile/graphics/defaultsmall.jpg b/mod/profile/graphics/defaultsmall.jpg Binary files differdeleted file mode 100644 index bbd647505..000000000 --- a/mod/profile/graphics/defaultsmall.jpg +++ /dev/null diff --git a/mod/profile/graphics/defaulttiny.jpg b/mod/profile/graphics/defaulttiny.jpg Binary files differdeleted file mode 100644 index 689fec201..000000000 --- a/mod/profile/graphics/defaulttiny.jpg +++ /dev/null diff --git a/mod/profile/icon.php b/mod/profile/icon.php deleted file mode 100644 index 4a9c8cbfe..000000000 --- a/mod/profile/icon.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php
-
- /**
- * Elgg profile icon
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- */
-
- // Load the Elgg framework
- require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
- // Get the owning user
-
- $user = page_owner_entity(); // page_owner_entity();
- $username = $user->username;
-
- // Get the size
- $size = strtolower(get_input('size'));
- if (!in_array($size,array('large','medium','small','tiny','master')))
- $size = "medium";
-
- // Try and get the icon
-
- $filehandler = new ElggFile();
- $filehandler->owner_guid = $user->getGUID();
- $filehandler->setFilename("profile/" . $username . $size . ".jpg");
-
- $success = false;
- if ($filehandler->open("read")) {
- if ($contents = $filehandler->read($filehandler->size())) {
- $success = true;
- }
- }
-
- if (!$success) {
-
- global $CONFIG;
- $contents = @file_get_contents($CONFIG->pluginspath . "profile/graphics/default{$size}.jpg");
-
- }
-
- header("Content-type: image/jpeg");
- header("Pragma: public");
- header("Cache-Control: public");
- echo $contents;
-
-?>
\ No newline at end of file diff --git a/mod/profile/icondirect.php b/mod/profile/icondirect.php new file mode 100644 index 000000000..5f1599e0d --- /dev/null +++ b/mod/profile/icondirect.php @@ -0,0 +1,77 @@ +<?php +/** + * Elgg profile icon cache/bypass + * + * + * @package ElggProfile + */ + +// Get DB settings +require_once(dirname(dirname(dirname(__FILE__))). '/engine/settings.php'); + +global $CONFIG; + +// 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'))) { + $size = "medium"; +} + +$mysql_dblink = @mysql_connect($CONFIG->dbhost, $CONFIG->dbuser, $CONFIG->dbpass, true); +if ($mysql_dblink) { + 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') { + $data_root = $row->value; + } + $row = mysql_fetch_object($result); + } + } + + @mysql_close($mysql_dblink); + + if (isset($data_root)) { + + // 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: ' . 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: $filesize"); + header("ETag: \"$etag\""); + readfile($filename); + exit; + } + } + } + +} + +// something went wrong so load engine and try to forward to default icon +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); +elgg_log("Profile icon direct failed.", "WARNING"); +forward("_graphics/icons/user/default{$size}.gif"); diff --git a/mod/profile/index.php b/mod/profile/index.php deleted file mode 100644 index e1f4f1651..000000000 --- a/mod/profile/index.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php
-
- /**
- * Elgg profile index
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- */
-
- // Get the Elgg engine
- require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
- // Get the username
- $username = get_input('username');
-
- // Try and get the user from the username and set the page body accordingly
- if ($user = get_user_by_username($username)) {
-
- $body = elgg_view_entity($user,"",true);
- $title = $user->name;
-
- } else {
-
- $body = elgg_echo("profile:notfound");
- $title = elgg_echo("profile");
-
- }
- - $body = elgg_view_layout('widgets',$body);
-
- page_draw($title, $body);
-
-?>
\ No newline at end of file diff --git a/mod/profile/javascript.php b/mod/profile/javascript.php deleted file mode 100644 index f5af590bf..000000000 --- a/mod/profile/javascript.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php
-
- /**
- * Elgg profile JS
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- */
-
- // Get engine
- require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
- echo elgg_view('profile/javascript');
-
-?>
\ No newline at end of file diff --git a/mod/profile/languages/en.php b/mod/profile/languages/en.php index 33e210f88..50f04bb33 100644 --- a/mod/profile/languages/en.php +++ b/mod/profile/languages/en.php @@ -1,61 +1,12 @@ -<?php
-
- /**
- * Elgg profile plugin language pack
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- */
-
- $english = array(
-
- /**
- * Menu items and titles
- */
-
- 'profile' => "Profile",
- 'profile:yours' => "Your profile",
- 'profile:user' => "%s's profile",
-
- 'profile:edit' => "Edit profile",
- 'profile:editicon' => "Change your profile picture",
- 'profile:icon' => "Profile icon",
- 'profile:createicon' => "Create your avatar",
- 'profile:createicon:instructions' => "Click and drag to crop your image",
-
- 'profile:aboutme' => "About me",
- 'profile:description' => "About me",
- 'profile:location' => "Location",
- 'profile:skills' => "Skills",
- 'profile:interests' => "Interests",
- 'profile:contactemail' => "Contact email",
- 'profile:phone' => "Telephone",
- 'profile:mobile' => "Mobile phone",
- 'profile:website' => "Website",
-
- 'profile:river:update' => "%s updated their profile",
-
- /**
- * Status messages
- */
-
- 'profile:saved' => "Your profile was successfully saved.",
- 'profile:icon:uploaded' => "Your profile icon was successfully uploaded.",
-
- /**
- * Error messages
- */
-
- 'profile:noaccess' => "You do not have permission to edit this profile.",
- 'profile:notfound' => "Sorry; we could not find the specified profile.",
- 'profile:cantedit' => "Sorry; you do not have permission to edit this profile.",
- 'profile:icon:notfound' => "Sorry; there was a problem uploading your profile icon.",
-
- );
-
- add_translation("en",$english);
-
-?>
\ No newline at end of file +<?php +/** + * Elgg profile plugin language pack + */ + +$english = array( + 'profile' => 'Profile', + 'profile:notfound' => 'Sorry. We could not find the requested profile.', + +); + +add_translation('en', $english);
\ No newline at end of file diff --git a/mod/profile/manifest.xml b/mod/profile/manifest.xml index 6cff874ed..86fbc7b7b 100644 --- a/mod/profile/manifest.xml +++ b/mod/profile/manifest.xml @@ -1,8 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> -<plugin_manifest> - <field key="author" value="Ben Werdmuller" /> - <field key="version" value="1.0" /> - <field key="description" value="Elgg profile plugin." /> - <field key="website" value="http://www.elgg.org/" /> - <field key="copyright" value="(C) Curverider 2008" /> +<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 0cd8f2100..ab596f235 100644 --- a/mod/profile/start.php +++ b/mod/profile/start.php @@ -1,127 +1,188 @@ -<?php
-
- /**
- * Elgg profile plugin
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- */
-
- /**
- * Profile init function; sets up the profile functions
- *
- */
- function profile_init() {
-
- // Get config
- global $CONFIG;
-
- // Load the language file
- register_translations($CONFIG->pluginspath . "profile/languages/");
-
- // 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');
-
- // Set up menu for logged in users
- if (isloggedin()) {
- add_menu(elgg_echo('profile'), $CONFIG->wwwroot . "pg/profile/" . $_SESSION['user']->username,array(
- menu_item(elgg_echo('profile:yours'),$CONFIG->wwwroot . "pg/profile/" . $_SESSION['user']->username),
- menu_item(elgg_echo('profile:edit'),$CONFIG->wwwroot."mod/profile/edit.php"),
- menu_item(elgg_echo('profile:editicon'),$CONFIG->wwwroot."mod/profile/editicon.php"),
- ),'profile');
- }
-
- // For now, we'll hard code the profile items as follows:
- // 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
- 'description' => 'longtext',
- 'location' => 'tags',
- 'interests' => 'tags',
- 'skills' => 'tags',
- 'contactemail' => 'email',
- 'phone' => 'text',
- 'mobile' => 'text',
- 'website' => 'url',
-
- );
-
- // Register a page handler, so we can have nice URLs
- register_page_handler('profile','profile_page_handler');
- register_page_handler('icon','profile_icon_handler');
-
- // Add Javascript reference to the page header
- extend_view('metatags','profile/metatags');
- extend_view('css','profile/css');
-
- }
-
- /**
- * Profile page handler
- *
- * @param array $page Array of page elements, forwarded by the page handling mechanism
- */
- function profile_page_handler($page) {
-
- global $CONFIG;
-
- // The username should be the file we're getting
- if (isset($page[0])) {
- set_input('username',$page[0]);
- }
- // Include the standard profile index
- include($CONFIG->pluginspath . "profile/index.php");
-
- }
-
- /**
- * Profile icon page handler
- *
- * @param array $page Array of page elements, forwarded by the page handling mechanism
- */
- function profile_icon_handler($page) {
-
- global $CONFIG;
-
- // The username should be the file we're getting
- if (isset($page[0])) {
- set_input('username',$page[0]);
- }
- if (isset($page[1])) {
- set_input('size',$page[1]);
- }
- // Include the standard profile index
- include($CONFIG->pluginspath . "profile/icon.php");
-
- }
-
- /**
- * Profile URL generator for $user->getUrl();
- *
- * @param ElggUser $user
- * @return string User URL
- */
- function profile_url($user) {
- global $CONFIG;
- return $CONFIG->wwwroot . "pg/profile/" . $user->username;
- }
-
- // Make sure the profile initialisation function is called on initialisation
- register_elgg_event_handler('init','system','profile_init',1);
-
- // Register actions
- global $CONFIG;
- register_action("profile/edit",false,$CONFIG->pluginspath . "profile/actions/edit.php");
- register_action("profile/iconupload",false,$CONFIG->pluginspath . "profile/actions/iconupload.php");
- register_action("profile/cropicon",false,$CONFIG->pluginspath . "profile/actions/cropicon.php");
-
- // Define widgets for use in this context
- use_widgets('profile');
-
-?>
\ No newline at end of file +<?php +/** + * Elgg profile plugin + * + * @package ElggProfile + */ + +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 + */ +function profile_init() { + + // Register a URL handler for users - this means that profile_url() + // will dictate the URL for all ElggUser objects + elgg_register_entity_url_handler('user', 'all', 'profile_url'); + + 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_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_register_page_handler('profile', 'profile_page_handler'); + + elgg_extend_view('page/elements/head', 'profile/metatags'); + elgg_extend_view('css/elgg', 'profile/css'); + elgg_extend_view('js/elgg', 'profile/js'); + + // 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 URL segments passed by the page handling mechanism + * @return bool + */ +function profile_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]; + } + + if ($action == 'edit') { + // 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( + '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($user->name, $body); + return true; +} + +/** + * Profile URL generator for $user->getUrl(); + * + * @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 + * + * @param string $hook + * @param string $entity_type + * @param string $return_value + * @param array $params + * @return string + */ +function profile_override_avatar_url($hook, $entity_type, $return_value, $params) { + + // if someone already set this, quit + if ($return_value) { + return null; + } + + $user = $params['entity']; + $size = $params['size']; + + if (!elgg_instanceof($user, 'user')) { + return null; + } + + $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; +} + +/** + * Parse ECML on parts of the profile + * + * @param string $hook + * @param string $entity_type + * @param array $return_value + * @return array + */ +function profile_ecml_views_hook($hook, $entity_type, $return_value) { + $return_value['profile/profile_content'] = elgg_echo('profile'); + + return $return_value; +} + +/** + * Register profile widgets with default widgets + * + * @param string $hook + * @param string $type + * @param array $return + * @return array + */ +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; +} diff --git a/mod/profile/views/default/js/jquery.imgareaselect-0.4.2.js b/mod/profile/views/default/js/jquery.imgareaselect-0.4.2.js deleted file mode 100644 index 637332d07..000000000 --- a/mod/profile/views/default/js/jquery.imgareaselect-0.4.2.js +++ /dev/null @@ -1,355 +0,0 @@ -/* - * imgAreaSelect jQuery plugin - * version 0.4.2 - * - * Copyright (c) 2008 Michal Wojciechowski (odyniec.net) - * - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. - * - * http://odyniec.net/projects/imgareaselect/ - * - */ - -jQuery.imgAreaSelect = function (img, options) { - var $area = jQuery('<div></div>'), - $border1 = jQuery('<div></div>'), - $border2 = jQuery('<div></div>'), - $outLeft = jQuery('<div></div>'), - $outTop = jQuery('<div></div>'), - $outRight = jQuery('<div></div>'), - $outBottom = jQuery('<div></div>'), - imgOfs, imgWidth, imgHeight, zIndex = 0, fixed = false, $p, - startX, startY, moveX, moveY, - resizeMargin = 10, resize = [ ], V = 0, H = 1, - d, aspectRatio, - x1, x2, y1, y2, x, y, - selection = { x1: 0, y1: 0, x2: 0, y2: 0, width: 0, height: 0 }; - - var $a = $area.add($border1).add($border2); - var $o = $outLeft.add($outTop).add($outRight).add($outBottom); - - function update() - { - $a.css({ - left: (selection.x1 + imgOfs.left) + 'px', - top: (selection.y1 + imgOfs.top) + 'px', - width: Math.max(selection.width - options.borderWidth * 2, 0) + 'px', - height: Math.max(selection.height - options.borderWidth * 2, 0) + 'px' - }); - $outLeft.css({ left: imgOfs.left + 'px', top: imgOfs.top + 'px', - width: selection.x1 + 'px', height: imgHeight + 'px' }); - $outTop.css({ left: imgOfs.left + selection.x1 + 'px', top: imgOfs.top + 'px', - width: selection.width + 'px', height: selection.y1 + 'px' }); - $outRight.css({ left: imgOfs.left + selection.x2 + 'px', top: imgOfs.top + 'px', - width: imgWidth - selection.x2 + 'px', height: imgHeight + 'px' }); - $outBottom.css({ left: imgOfs.left + selection.x1 + 'px', top: imgOfs.top + selection.y2 + 'px', - width: selection.width + 'px', height: imgHeight - selection.y2 + 'px' }); - } - - function areaMouseMove(event) - { - x = event.pageX - selection.x1 - imgOfs.left; - y = event.pageY - selection.y1 - imgOfs.top; - - resize = [ ]; - - if (options.resizable) { - if (y <= resizeMargin) - resize[V] = 'n'; - else if (y >= selection.height - resizeMargin) - resize[V] = 's'; - if (x <= resizeMargin) - resize[H] = 'w'; - else if (x >= selection.width - resizeMargin) - resize[H] = 'e'; - } - - $border2.css('cursor', resize.length ? resize.join('') + '-resize' : - options.movable ? 'move' : ''); - } - - function areaMouseDown(event) - { - if (event.which != 1) return false; - - if (options.resizable && resize.length > 0) { - jQuery('body').css('cursor', resize.join('') + '-resize'); - - x1 = (resize[H] == 'w' ? selection.x2 : selection.x1) + imgOfs.left; - y1 = (resize[V] == 'n' ? selection.y2 : selection.y1) + imgOfs.top; - - jQuery(document).mousemove(selectingMouseMove); - $border2.unbind('mousemove', areaMouseMove); - - jQuery(document).one('mouseup', function () { - resize = [ ]; - - jQuery('body').css('cursor', ''); - - if (options.autoHide) - $a.add($o).hide(); - - options.onSelectEnd(img, selection); - - jQuery(document).unbind('mousemove', selectingMouseMove); - $border2.mousemove(areaMouseMove); - }); - } - else if (options.movable) { - moveX = selection.x1 + imgOfs.left; - moveY = selection.y1 + imgOfs.top; - startX = event.pageX; - startY = event.pageY; - - jQuery(document) - .mousemove(movingMouseMove) - .one('mouseup', function () { - options.onSelectEnd(img, selection); - - jQuery(document).unbind('mousemove', movingMouseMove); - }); - } - else - jQuery(img).mousedown(event); - - return false; - } - - function aspectRatioXY() - { - x2 = Math.max(imgOfs.left, Math.min(imgOfs.left + imgWidth, - x1 + Math.abs(y2 - y1) * aspectRatio * (x2 > x1 ? 1 : -1))); - y2 = Math.round(Math.max(imgOfs.top, Math.min(imgOfs.top + imgHeight, - y1 + Math.abs(x2 - x1) / aspectRatio * (y2 > y1 ? 1 : -1)))); - x2 = Math.round(x2); - } - - function aspectRatioYX() - { - y2 = Math.max(imgOfs.top, Math.min(imgOfs.top + imgHeight, - y1 + Math.abs(x2 - x1) / aspectRatio * (y2 > y1 ? 1 : -1))); - x2 = Math.round(Math.max(imgOfs.left, Math.min(imgOfs.left + imgWidth, - x1 + Math.abs(y2 - y1) * aspectRatio * (x2 > x1 ? 1 : -1)))); - y2 = Math.round(y2); - } - - function selectingMouseMove(event) - { - x2 = !resize.length || resize[H] || aspectRatio ? event.pageX : selection.x2 + imgOfs.left; - y2 = !resize.length || resize[V] || aspectRatio ? event.pageY : selection.y2 + imgOfs.top; - - if (options.minWidth && Math.abs(x2 - x1) < options.minWidth) { - x2 = x1 - options.minWidth * (x2 < x1 ? 1 : -1); - - if (x2 < imgOfs.left) - x1 = imgOfs.left + options.minWidth; - else if (x2 > imgOfs.left + imgWidth) - x1 = imgOfs.left + imgWidth - options.minWidth; - } - - if (options.minHeight && Math.abs(y2 - y1) < options.minHeight) { - y2 = y1 - options.minHeight * (y2 < y1 ? 1 : -1); - - if (y2 < imgOfs.top) - y1 = imgOfs.top + options.minHeight; - else if (y2 > imgOfs.top + imgHeight) - y1 = imgOfs.top + imgHeight - options.minHeight; - } - - x2 = Math.max(imgOfs.left, Math.min(x2, imgOfs.left + imgWidth)); - y2 = Math.max(imgOfs.top, Math.min(y2, imgOfs.top + imgHeight)); - - if (aspectRatio) - if (Math.abs(x2 - x1) / aspectRatio > Math.abs(y2 - y1)) - aspectRatioYX(); - else - aspectRatioXY(); - - if (options.maxWidth && Math.abs(x2 - x1) > options.maxWidth) { - x2 = x1 - options.maxWidth * (x2 < x1 ? 1 : -1); - if (aspectRatio) aspectRatioYX(); - } - - if (options.maxHeight && Math.abs(y2 - y1) > options.maxHeight) { - y2 = y1 - options.maxHeight * (y2 < y1 ? 1 : -1); - if (aspectRatio) aspectRatioXY(); - } - - selection.x1 = Math.min(x1, x2) - imgOfs.left; - selection.x2 = Math.max(x1, x2) - imgOfs.left; - selection.y1 = Math.min(y1, y2) - imgOfs.top; - selection.y2 = Math.max(y1, y2) - imgOfs.top; - selection.width = Math.abs(x2 - x1); - selection.height = Math.abs(y2 - y1); - - update(); - - options.onSelectChange(img, selection); - - return false; - } - - function movingMouseMove(event) - { - x1 = Math.max(imgOfs.left, Math.min(moveX + event.pageX - startX, - imgOfs.left + imgWidth - selection.width)); - y1 = Math.max(imgOfs.top, Math.min(moveY + event.pageY - startY, - imgOfs.top + imgHeight - selection.height)); - x2 = x1 + selection.width; - y2 = y1 + selection.height; - - selection.x1 = x1 - imgOfs.left; - selection.y1 = y1 - imgOfs.top; - selection.x2 = x2 - imgOfs.left; - selection.y2 = y2 - imgOfs.top; - - update(); - - options.onSelectChange(img, selection); - event.preventDefault(); - - return false; - } - - function imgMouseDown(event) - { - if (event.which != 1) return false; - - startX = x1 = event.pageX; - startY = y1 = event.pageY; - selection.x1 = selection.x2 = x1 - imgOfs.left; - selection.y1 = selection.y2 = y1 - imgOfs.top; - selection.width = 0; - selection.height = 0; - - resize = [ ]; - - update(); - $a.add($o).show(); - - jQuery(document).mousemove(selectingMouseMove); - $border2.unbind('mousemove', areaMouseMove); - - options.onSelectStart(img, selection); - - jQuery(document).one('mouseup', function () { - if (options.autoHide) - $a.add($o).hide(); - - options.onSelectEnd(img, selection); - - jQuery(document).unbind('mousemove', selectingMouseMove); - $border2.mousemove(areaMouseMove); - }); - - return false; - } - - this.setOptions = function(newOptions) - { - options = jQuery.extend(options, newOptions); - - if (newOptions.x1 != null) { - selection.x1 = newOptions.x1; - selection.y1 = newOptions.y1; - selection.x2 = newOptions.x2; - selection.y2 = newOptions.y2; - newOptions.show = true; - } - - imgWidth = jQuery(img).width(); - imgHeight = jQuery(img).height(); - imgOfs = jQuery(img).offset(); - - $p = jQuery(img); - - while ($p.length && !$p.is('body')) { - if (!isNaN($p.css('z-index')) && $p.css('z-index') > zIndex) - zIndex = $p.css('z-index'); - if ($p.css('position') == 'fixed') fixed = true; - - $p = $p.parent(); - } - - x1 = selection.x1 + imgOfs.left; - y1 = selection.y1 + imgOfs.top; - x2 = selection.x2 + imgOfs.left; - y2 = selection.y2 + imgOfs.top; - selection.width = x2 - x1; - selection.height = y2 - y1; - - update(); - - if (newOptions.hide) - $a.add($o).hide(); - else if (newOptions.show) - $a.add($o).show(); - - $a.css({ borderWidth: options.borderWidth + 'px' }); - $area.css({ backgroundColor: options.selectionColor, opacity: options.selectionOpacity }); - $border1.css({ borderStyle: 'solid', borderColor: options.borderColor1 }); - $border2.css({ borderStyle: 'dashed', borderColor: options.borderColor2 }); - $o.css({ opacity: options.outerOpacity, backgroundColor: options.outerColor }); - - aspectRatio = options.aspectRatio && (d = options.aspectRatio.split(/:/)) ? - d[0] / d[1] : null; - - if (options.disable || options.enable === false) { - $a.unbind('mousemove', areaMouseMove).unbind('mousedown', areaMouseDown); - jQuery(img).add($o).unbind('mousedown', imgMouseDown); - } - else if (options.enable || options.disable === false) { - if (options.resizable || options.movable) - $a.mousemove(areaMouseMove).mousedown(areaMouseDown); - - jQuery(img).add($o).mousedown(imgMouseDown); - } - - options.enable = options.disable = undefined; - }; - - if (jQuery.browser.msie) - jQuery(img).attr('unselectable', 'on'); - - $a.add($o).css({ display: 'none', position: fixed ? 'fixed' : 'absolute', overflow: 'hidden', - zIndex: zIndex > 0 ? zIndex : null }); - $area.css({ borderStyle: 'solid' }); - - jQuery('body').append($o.add($a)); - - initOptions = { - borderColor1: '#000', - borderColor2: '#fff', - borderWidth: 1, - movable: true, - resizable: true, - selectionColor: '#fff', - selectionOpacity: 0.2, - outerColor: '#000', - outerOpacity: 0.2, - onSelectStart: function () {}, - onSelectChange: function () {}, - onSelectEnd: function () {} - }; - - options = jQuery.extend(initOptions, options); - this.setOptions(options); -}; - -jQuery.fn.imgAreaSelect = function (options) { - options = options || {}; - - this.each(function () { - if (jQuery(this).data('imgAreaSelect')) - jQuery(this).data('imgAreaSelect').setOptions(options); - else { - if (options.enable === undefined && options.disable === undefined) - options.enable = true; - - jQuery(this).data('imgAreaSelect', new jQuery.imgAreaSelect(this, options)); - } - }); - - return this; -}; diff --git a/mod/profile/views/default/js/jquery.imgareaselect-0.4.2.min.js b/mod/profile/views/default/js/jquery.imgareaselect-0.4.2.min.js deleted file mode 100644 index 0c07deebd..000000000 --- a/mod/profile/views/default/js/jquery.imgareaselect-0.4.2.min.js +++ /dev/null @@ -1 +0,0 @@ -jQuery.imgAreaSelect=function(img,options){var $area=jQuery('<div></div>'),$border1=jQuery('<div></div>'),$border2=jQuery('<div></div>'),$outLeft=jQuery('<div></div>'),$outTop=jQuery('<div></div>'),$outRight=jQuery('<div></div>'),$outBottom=jQuery('<div></div>'),imgOfs,imgWidth,imgHeight,zIndex=0,fixed=false,$p,startX,startY,moveX,moveY,resizeMargin=10,resize=[],V=0,H=1,d,aspectRatio,x1,x2,y1,y2,x,y,selection={x1:0,y1:0,x2:0,y2:0,width:0,height:0};var $a=$area.add($border1).add($border2);var $o=$outLeft.add($outTop).add($outRight).add($outBottom);function update(){$a.css({left:(selection.x1+imgOfs.left)+'px',top:(selection.y1+imgOfs.top)+'px',width:Math.max(selection.width-options.borderWidth*2,0)+'px',height:Math.max(selection.height-options.borderWidth*2,0)+'px'});$outLeft.css({left:imgOfs.left+'px',top:imgOfs.top+'px',width:selection.x1+'px',height:imgHeight+'px'});$outTop.css({left:imgOfs.left+selection.x1+'px',top:imgOfs.top+'px',width:selection.width+'px',height:selection.y1+'px'});$outRight.css({left:imgOfs.left+selection.x2+'px',top:imgOfs.top+'px',width:imgWidth-selection.x2+'px',height:imgHeight+'px'});$outBottom.css({left:imgOfs.left+selection.x1+'px',top:imgOfs.top+selection.y2+'px',width:selection.width+'px',height:imgHeight-selection.y2+'px'})}function areaMouseMove(event){x=event.pageX-selection.x1-imgOfs.left;y=event.pageY-selection.y1-imgOfs.top;resize=[];if(options.resizable){if(y<=resizeMargin)resize[V]='n';else if(y>=selection.height-resizeMargin)resize[V]='s';if(x<=resizeMargin)resize[H]='w';else if(x>=selection.width-resizeMargin)resize[H]='e'}$border2.css('cursor',resize.length?resize.join('')+'-resize':options.movable?'move':'')}function areaMouseDown(event){if(event.which!=1)return false;if(options.resizable&&resize.length>0){jQuery('body').css('cursor',resize.join('')+'-resize');x1=(resize[H]=='w'?selection.x2:selection.x1)+imgOfs.left;y1=(resize[V]=='n'?selection.y2:selection.y1)+imgOfs.top;jQuery(document).mousemove(selectingMouseMove);$border2.unbind('mousemove',areaMouseMove);jQuery(document).one('mouseup',function(){resize=[];jQuery('body').css('cursor','');if(options.autoHide)$a.add($o).hide();options.onSelectEnd(img,selection);jQuery(document).unbind('mousemove',selectingMouseMove);$border2.mousemove(areaMouseMove)})}else if(options.movable){moveX=selection.x1+imgOfs.left;moveY=selection.y1+imgOfs.top;startX=event.pageX;startY=event.pageY;jQuery(document).mousemove(movingMouseMove).one('mouseup',function(){options.onSelectEnd(img,selection);jQuery(document).unbind('mousemove',movingMouseMove)})}else jQuery(img).mousedown(event);return false}function aspectRatioXY(){x2=Math.max(imgOfs.left,Math.min(imgOfs.left+imgWidth,x1+Math.abs(y2-y1)*aspectRatio*(x2>x1?1:-1)));y2=Math.round(Math.max(imgOfs.top,Math.min(imgOfs.top+imgHeight,y1+Math.abs(x2-x1)/aspectRatio*(y2>y1?1:-1))));x2=Math.round(x2)}function aspectRatioYX(){y2=Math.max(imgOfs.top,Math.min(imgOfs.top+imgHeight,y1+Math.abs(x2-x1)/aspectRatio*(y2>y1?1:-1)));x2=Math.round(Math.max(imgOfs.left,Math.min(imgOfs.left+imgWidth,x1+Math.abs(y2-y1)*aspectRatio*(x2>x1?1:-1))));y2=Math.round(y2)}function selectingMouseMove(event){x2=!resize.length||resize[H]||aspectRatio?event.pageX:selection.x2+imgOfs.left;y2=!resize.length||resize[V]||aspectRatio?event.pageY:selection.y2+imgOfs.top;if(options.minWidth&&Math.abs(x2-x1)<options.minWidth){x2=x1-options.minWidth*(x2<x1?1:-1);if(x2<imgOfs.left)x1=imgOfs.left+options.minWidth;else if(x2>imgOfs.left+imgWidth)x1=imgOfs.left+imgWidth-options.minWidth}if(options.minHeight&&Math.abs(y2-y1)<options.minHeight){y2=y1-options.minHeight*(y2<y1?1:-1);if(y2<imgOfs.top)y1=imgOfs.top+options.minHeight;else if(y2>imgOfs.top+imgHeight)y1=imgOfs.top+imgHeight-options.minHeight}x2=Math.max(imgOfs.left,Math.min(x2,imgOfs.left+imgWidth));y2=Math.max(imgOfs.top,Math.min(y2,imgOfs.top+imgHeight));if(aspectRatio)if(Math.abs(x2-x1)/aspectRatio>Math.abs(y2-y1))aspectRatioYX();else aspectRatioXY();if(options.maxWidth&&Math.abs(x2-x1)>options.maxWidth){x2=x1-options.maxWidth*(x2<x1?1:-1);if(aspectRatio)aspectRatioYX()}if(options.maxHeight&&Math.abs(y2-y1)>options.maxHeight){y2=y1-options.maxHeight*(y2<y1?1:-1);if(aspectRatio)aspectRatioXY()}selection.x1=Math.min(x1,x2)-imgOfs.left;selection.x2=Math.max(x1,x2)-imgOfs.left;selection.y1=Math.min(y1,y2)-imgOfs.top;selection.y2=Math.max(y1,y2)-imgOfs.top;selection.width=Math.abs(x2-x1);selection.height=Math.abs(y2-y1);update();options.onSelectChange(img,selection);return false}function movingMouseMove(event){x1=Math.max(imgOfs.left,Math.min(moveX+event.pageX-startX,imgOfs.left+imgWidth-selection.width));y1=Math.max(imgOfs.top,Math.min(moveY+event.pageY-startY,imgOfs.top+imgHeight-selection.height));x2=x1+selection.width;y2=y1+selection.height;selection.x1=x1-imgOfs.left;selection.y1=y1-imgOfs.top;selection.x2=x2-imgOfs.left;selection.y2=y2-imgOfs.top;update();options.onSelectChange(img,selection);event.preventDefault();return false}function imgMouseDown(event){if(event.which!=1)return false;startX=x1=event.pageX;startY=y1=event.pageY;selection.x1=selection.x2=x1-imgOfs.left;selection.y1=selection.y2=y1-imgOfs.top;selection.width=0;selection.height=0;resize=[];update();$a.add($o).show();jQuery(document).mousemove(selectingMouseMove);$border2.unbind('mousemove',areaMouseMove);options.onSelectStart(img,selection);jQuery(document).one('mouseup',function(){if(options.autoHide)$a.add($o).hide();options.onSelectEnd(img,selection);jQuery(document).unbind('mousemove',selectingMouseMove);$border2.mousemove(areaMouseMove)});return false}this.setOptions=function(newOptions){options=jQuery.extend(options,newOptions);if(newOptions.x1!=null){selection.x1=newOptions.x1;selection.y1=newOptions.y1;selection.x2=newOptions.x2;selection.y2=newOptions.y2;newOptions.show=true}imgWidth=jQuery(img).width();imgHeight=jQuery(img).height();imgOfs=jQuery(img).offset();$p=jQuery(img);while($p.length&&!$p.is('body')){if(!isNaN($p.css('z-index'))&&$p.css('z-index')>zIndex)zIndex=$p.css('z-index');if($p.css('position')=='fixed')fixed=true;$p=$p.parent()}x1=selection.x1+imgOfs.left;y1=selection.y1+imgOfs.top;x2=selection.x2+imgOfs.left;y2=selection.y2+imgOfs.top;selection.width=x2-x1;selection.height=y2-y1;update();if(newOptions.hide)$a.add($o).hide();else if(newOptions.show)$a.add($o).show();$a.css({borderWidth:options.borderWidth+'px'});$area.css({backgroundColor:options.selectionColor,opacity:options.selectionOpacity});$border1.css({borderStyle:'solid',borderColor:options.borderColor1});$border2.css({borderStyle:'dashed',borderColor:options.borderColor2});$o.css({opacity:options.outerOpacity,backgroundColor:options.outerColor});aspectRatio=options.aspectRatio&&(d=options.aspectRatio.split(/:/))?d[0]/d[1]:null;if(options.disable||options.enable===false){$a.unbind('mousemove',areaMouseMove).unbind('mousedown',areaMouseDown);jQuery(img).add($o).unbind('mousedown',imgMouseDown)}else if(options.enable||options.disable===false){if(options.resizable||options.movable)$a.mousemove(areaMouseMove).mousedown(areaMouseDown);jQuery(img).add($o).mousedown(imgMouseDown)}options.enable=options.disable=undefined};if(jQuery.browser.msie)jQuery(img).attr('unselectable','on');$a.add($o).css({display:'none',position:fixed?'fixed':'absolute',overflow:'hidden',zIndex:zIndex>0?zIndex:null});$area.css({borderStyle:'solid'});jQuery('body').append($o.add($a));initOptions={borderColor1:'#000',borderColor2:'#fff',borderWidth:1,movable:true,resizable:true,selectionColor:'#fff',selectionOpacity:0.2,outerColor:'#000',outerOpacity:0.2,onSelectStart:function(){},onSelectChange:function(){},onSelectEnd:function(){}};options=jQuery.extend(initOptions,options);this.setOptions(options)};jQuery.fn.imgAreaSelect=function(options){options=options||{};this.each(function(){if(jQuery(this).data('imgAreaSelect'))jQuery(this).data('imgAreaSelect').setOptions(options);else{if(options.enable===undefined&&options.disable===undefined)options.enable=true;jQuery(this).data('imgAreaSelect',new jQuery.imgAreaSelect(this,options))}});return this}; diff --git a/mod/profile/views/default/profile/css.php b/mod/profile/views/default/profile/css.php index 43c081457..e24f555a9 100644 --- a/mod/profile/views/default/profile/css.php +++ b/mod/profile/views/default/profile/css.php @@ -1,46 +1,126 @@ -<?php
-
-?>
-
-/* ***************************************
- AVATAR CONTEXTUAL MENU
-*************************************** */
-
-.usericon {
- position:relative;
-}
-
-.avatar_menu_button {
- width:15px;
- height:15px;
- position:absolute;
- cursor:pointer;
- display:none;
- right:0;
- bottom:0;
-}
-
-.usericon div.sub_menu {
- z-index:9999;
- display:none;
- position:absolute;
- padding:2px;
- margin:0;
- border-top:solid 1px #E5E5E5;
- border-left:solid 1px #E5E5E5;
- border-right:solid 1px #999999;
- border-bottom:solid 1px #999999;
- width:160px;
- background:#FFFFFF;
- text-align:left;
-}
-
-* html .usericon div.sub_menu { } /* IE6 */
-*+html .usericon div.sub_menu { } /* IE7 */
-
-.usericon div.sub_menu a {margin:0;padding:2px;}
-.usericon div.sub_menu a:link,
-.usericon div.sub_menu a:visited,
-.usericon div.sub_menu a:hover{ display:block;}
-.usericon div.sub_menu a:hover{ background:#cccccc; text-decoration:none;}
-.usericon a.item_line { border-top:solid 1px #dddddd;}
\ No newline at end of file +<?php +/** + * Elgg Profile CSS + * + * @package Profile + */ +?> +/* *************************************** + Profile +*************************************** */ +.profile { + float: left; + margin-bottom: 15px; +} +.profile .elgg-inner { + margin: 0 5px; + border: 2px solid #eee; + + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + border-radius: 8px; +} +#profile-details { + padding: 15px; +} +/*** ownerblock ***/ +#profile-owner-block { + width: 200px; + float: left; + background-color: #eee; + padding: 15px; +} +#profile-owner-block .large { + margin-bottom: 10px; +} +#profile-owner-block a.elgg-button-action { + margin-bottom: 4px; + display: table; +} +.profile-content-menu a { + display: block; + + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + border-radius: 8px; + + background-color: white; + margin: 3px 0 5px 0; + padding: 2px 4px 2px 8px; +} +.profile-content-menu a:hover { + background: #0054A7; + color: white; + text-decoration: none; +} +.profile-admin-menu { + display: none; +} +.profile-admin-menu-wrapper a { + display: block; + + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + border-radius: 8px; + + background-color: white; + margin: 3px 0 5px 0; + padding: 2px 4px 2px 8px; +} +.profile-admin-menu-wrapper { + background-color: white; + + -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; + + -webkit-border-radius: 4px; + -moz-border-radius: 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; + border-radius: 4px; + + margin: 0 0 7px; + padding: 2px 4px; +} +.profile-aboutme-title { + background-color:#f4f4f4; + + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + 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; +} diff --git a/mod/profile/views/default/profile/details.php b/mod/profile/views/default/profile/details.php new file mode 100644 index 000000000..da4e95690 --- /dev/null +++ b/mod/profile/views/default/profile/details.php @@ -0,0 +1,68 @@ +<?php +/** + * Elgg user display (details) + * @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>{$user->name}</h2>"; + +echo elgg_view("profile/status", array("entity" => $user)); + +$even_odd = null; +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' => $value)); + ?> + </div> + <?php + } + } +} + +if (!elgg_get_config('profile_custom_fields')) { + if ($user->isBanned()) { + echo "<p class='profile-banned-user'>"; + echo elgg_echo('banned'); + echo "</p>"; + } else { + 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>"; + } + } +} + +echo '</div>';
\ No newline at end of file diff --git a/mod/profile/views/default/profile/edit.php b/mod/profile/views/default/profile/edit.php deleted file mode 100644 index 8822988d6..000000000 --- a/mod/profile/views/default/profile/edit.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php
-
- /**
- * Elgg profile edit form
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- *
- * @uses $vars['entity'] The user entity
- * @uses $vars['profile'] Profile items from $CONFIG->profile, defined in profile/start.php for now
- */
-
-?>
-
-<form action="<?php echo $vars['url']; ?>action/profile/edit" method="post">
-
-<?php
-
- //var_export($vars['profile']);
- if (is_array($vars['config']->profile) && sizeof($vars['config']->profile) > 0)
- foreach($vars['config']->profile as $shortname => $valtype) {
-
-?>
-
- <p>
- <label>
- <?php echo elgg_echo("profile:{$shortname}") ?><br />
- <?php echo elgg_view("input/{$valtype}",array(
- 'internalname' => $shortname,
- 'value' => $vars['entity']->$shortname,
- )); ?>
- </label>
- </p>
-
-<?php
-
- }
-
-?>
-
- <p>
- <input type="hidden" name="username" value="<?php echo page_owner_entity()->username; ?>" />
- <input type="submit" class="submit_button" value="<?php echo elgg_echo("save"); ?>" />
- </p>
-
-</form>
\ No newline at end of file diff --git a/mod/profile/views/default/profile/editicon.php b/mod/profile/views/default/profile/editicon.php deleted file mode 100644 index 7bc142a26..000000000 --- a/mod/profile/views/default/profile/editicon.php +++ /dev/null @@ -1,138 +0,0 @@ -<?php
-
- /**
- * Elgg profile icon edit form
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- *
- * @uses $vars['entity'] The user entity
- * @uses $vars['profile'] Profile items from $CONFIG->profile, defined in profile/start.php for now
- */
-
-?>
-<!-- grab the required js for icon cropping -->
-<script type="text/javascript" src="<?php echo $vars['url']; ?>mod/profile/views/default/js/jquery.imgareaselect-0.4.2.js"></script>
-
- <form action="<?php echo $vars['url']; ?>action/profile/iconupload" method="post" enctype="multipart/form-data">
- <p>
- <?php echo elgg_echo("profile:editicon"); ?>:
- </p>
- <p>
- <?php
-
- echo elgg_view("input/file",array('internalname' => 'profileicon'));
-
- ?>
- </p>
- <p>
- <input type="submit" class="submit_button" value="<?php echo elgg_echo("upload"); ?>" />
- </p>
- </form>
-
-<?php
-
- echo elgg_echo("profile:createicon:instructions") . ": <br />";
- //display the current user photo
- $user_master_image = $vars['url'] . "pg/icon/" . $_SESSION['user']->username . "/master/" . $_SESSION['user']->icontime . ".jpg";
-
-?>
-
-<script>
-
- //function to display a preview of the users cropped section
- function preview(img, selection) {
- var origWidth = $("#user_avatar").width(); //get the width of the users master photo
- var origHeight = $("#user_avatar").height(); //get the height of the users master photo
- var scaleX = 100 / selection.width;
- var scaleY = 100 / selection.height;
- $('#user_avatar + div > img').css({
- width: Math.round(scaleX * origWidth) + 'px',
- height: Math.round(scaleY * origHeight) + 'px',
- marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px',
- marginTop: '-' + Math.round(scaleY * selection.y1) + 'px'
- });
- }
-
- //variables for the newly cropped avatar
- var $x1, $y1, $x2, $y2, $w, $h;
-
- function selectChange(img, selection){
-
- //delete this once we have tested, it is for the coordinate display
- $x1.text(selection.x1);
- $y1.text(selection.y1);
- $x2.text(selection.x2);
- $y2.text(selection.y2);
- $w.text(selection.width);
- $h.text(selection.height);
-
- //populate the form with the correct coordinates once a user has cropped their image
- document.getElementById('x_1').value = selection.x1;
- document.getElementById('x_2').value = selection.x2;
- document.getElementById('y_1').value = selection.y1;
- document.getElementById('y_2').value = selection.y2;
-
- }
-
- $(document).ready(function () {
-
- //get and set the coordinates
- $x1 = $('#x1');
- $y1 = $('#y1');
- $x2 = $('#x2');
- $y2 = $('#y2');
- $w = $('#w');
- $h = $('#h');
-
- $('<div><img src="<?php echo $user_master_image; ?>" style="position: relative;" /></div>')
- .css({ float: 'left', position: 'relative', overflow: 'hidden', width: '100px', height: '100px' })
- .insertAfter($('#user_avatar'));
-
- });
-
- $(window).load(function () {
-
- //this produces the coordinates
- $('#user_avatar').imgAreaSelect({ selectionOpacity: 0, onSelectEnd: selectChange });
- //show the preview
- $('#user_avatar').imgAreaSelect({ aspectRatio: '1:1', onSelectChange: preview });
-
- });
-
-</script>
-
-<p>
-<img id="user_avatar" src="<?php echo $user_master_image; ?>" alt="<?php echo elgg_echo("profile:icon"); ?>"
- style="float: left; margin-right: 10px;" />
- <br />
-</p>
-
- <div style="float: right; margin-left: 10px; margin-top:-200px;">
- <p style="background: #eee; border: solid 1px #ddd; margin: 0; padding: 10px;">
- <b>Selection coordinates:</b><br />
-
- <b>X<sub>1</sub>:</b> <span id="x1"></span><br />
- <b>Y<sub>1</sub>:</b> <span id="y1"></span><br />
- <b>X<sub>2</sub>:</b> <span id="x2"></span><br />
-
- <b>Y<sub>2</sub>:</b> <span id="y2"></span><br />
- <br />
- <b>Selection dimensions:</b><br />
- <b>Width:</b> <span id="w"></span><br />
- <b>Height:</b> <span id="h"></span>
-
- </p>
- </div>
-
-<form action="<?php echo $vars['url']; ?>action/profile/cropicon" method="post" />
- <input type="hidden" name="username" value="<?php echo $vars['user']->username; ?>" />
- <input type="hidden" name="x_1" value="<?php echo $vars['user']->x1; ?>" id="x_1" />
- <input type="hidden" name="x_2" value="<?php echo $vars['user']->x2; ?>" id="x_2" />
- <input type="hidden" name="y_1" value="<?php echo $vars['user']->y1; ?>" id="y_1" />
- <input type="hidden" name="y_2" value="<?php echo $vars['user']->y2; ?>" id="y_2" />
- <input type="submit" name="submit" value="<?php echo elgg_echo("profile:createicon"); ?>" />
-</form>
\ No newline at end of file diff --git a/mod/profile/views/default/profile/hoverover.php b/mod/profile/views/default/profile/hoverover.php deleted file mode 100644 index 73f94a8f3..000000000 --- a/mod/profile/views/default/profile/hoverover.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php
-
- /**
- * Elgg profile icon hover over
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- *
- * @uses $vars['entity'] The user entity. If none specified, the current user is assumed.
- */
-
-?>
-
- <p class="user_menu_name">
- <b><?php echo $vars['entity']->name; ?></b>
- </p>
-
-<?php
-
- echo elgg_view("profile/hoverover/actions",$vars);
- echo elgg_view("profile/hoverover/links",$vars);
-
-?>
\ No newline at end of file diff --git a/mod/profile/views/default/profile/icon.php b/mod/profile/views/default/profile/icon.php deleted file mode 100644 index 9b991374b..000000000 --- a/mod/profile/views/default/profile/icon.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php
-
- /**
- * Elgg profile icon
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- *
- * @uses $vars['entity'] The user entity. If none specified, the current user is assumed.
- * @uses $vars['size'] The size - small, medium or large. If none specified, medium is assumed.
- */
-
- // Get entity
- if (empty($vars['entity']))
- $vars['entity'] = $vars['user'];
-
- $name = htmlentities($vars['entity']->name);
- $username = $vars['entity']->username;
-
- if ($icontime = $vars['entity']->icontime) {
- $icontime = "{$icontime}";
- } else {
- $icontime = "default";
- }
-
- // Get size
- if (!in_array($vars['size'],array('small','medium','large','tiny','master')))
- $vars['size'] = "medium";
-
- // Get any align and js
- if (!empty($vars['align'])) {
- $align = " align=\"{$vars['align']}\" ";
- } else {
- $align = "";
- }
-
- // Get the hoverover menu
- $hoverover = elgg_view('profile/hoverover',$vars);
- $hoverover = htmlentities($hoverover);
- $hoverover = str_replace("\n","",$hoverover);
- $hoverover = str_replace("\r","",$hoverover);
- $hoverover = str_replace("\t","",$hoverover);
-
-?>
-
-<div class="usericon">
-<div class="avatar_menu_button"><img src="<?php echo $vars['url']; ?>_graphics/avatar_menu_arrow.gif" width="15" height="15" class="arrow" /></div>
-
- <div class="sub_menu">
- <a href="<?php echo $vars['entity']->getURL(); ?>"><h3><?php echo $vars['entity']->name; ?></h3></a>
- <?php
-
- $actions = elgg_view('profile/menu/actions',$vars);
- if (!empty($actions)) {
-
- echo "<div class=\"item_line\">{$actions}</div>";
-
- }
- if ($vars['entity']->getGUID() == $vars['user']->getGUID()) {
- echo elgg_view('profile/menu/linksownpage',$vars);
- } else {
- echo elgg_view('profile/menu/links',$vars);
- }
-
- ?>
-
- </div>
- <a href="<?php echo $vars['entity']->getURL(); ?>" class="icon" rel="<?php echo $hoverover; ?>"><img src="<?php echo $vars['url']; ?>pg/icon/<?php echo $username; ?>/<?php echo $vars['size']; ?>/<?php echo $icontime; ?>.jpg" border="0" <?php echo $align; ?> title="<?php echo $name; ?>" <?php echo $vars['js']; ?> /></a>
-</div>
\ No newline at end of file diff --git a/mod/profile/views/default/profile/javascript.php b/mod/profile/views/default/profile/javascript.php deleted file mode 100644 index b7770de05..000000000 --- a/mod/profile/views/default/profile/javascript.php +++ /dev/null @@ -1,95 +0,0 @@ -<?php
-
- /**
- * Elgg profile image Javascript
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Pete Harris <pete@elgg.com>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- *
- * @uses $vars['entity'] The user entity
- */
-
- header("Content-type: text/javascript");
-
-?>
-
-$(document).ready(function() {
-
- // avatar image menu link
- $("div.usericon img").mouseover(function() {
- // find nested avatar_menu_button and show
- $(this.parentNode.parentNode).children("[class=avatar_menu_button]").show();
- })
- .mouseout(function() {
- if($(this).parent().parent().find("div.sub_menu").css('display')!="block"){
- $(this.parentNode.parentNode).children("[class=avatar_menu_button]").hide();
- }
- else {
- $(this.parentNode.parentNode).children("[class=avatar_menu_button]").show();
- }
- });
-
-
- // avatar contextual menu
- $(".avatar_menu_button img.arrow").click(function(e) {
-
- var submenu = $(this).parent().parent().find("div.sub_menu");
-
- // close submenu if arrow is clicked & menu already open
- if(submenu.css('display') == "block") {
- submenu.hide();
- $(this).attr('src','<?php echo $vars['url']; ?>_graphics/avatar_menu_arrow_hover.gif');
- }
- else {
- // get avatar dimensions
- var avatar = $(this).parent().parent().parent().find("div.usericon");
- //alert( "avatarWidth: " + avatar.width() + ", avatarHeight: " + avatar.height() );
-
- // move submenu position so it aligns with arrow graphic
- if (e.pageX < 840) { // popup menu to left of arrow if we're at edge of page
- submenu.css("top",(avatar.height()) + "px")
- .css("left",(avatar.width()-15) + "px")
- .fadeIn('normal');
- }
- else {
- submenu.css("top",(avatar.height()) + "px")
- .css("left",(avatar.width()-166) + "px")
- .fadeIn('normal');
- }
- // change arrow to 'on' state
- $(this).attr('src','<?php echo $vars['url']; ?>_graphics/avatar_menu_arrow_open.gif');
- }
-
- // hide any other open submenus and reset arrows
- $("div.sub_menu:visible").not(submenu).hide();
- $(".usericon img.arrow").not(this).attr('src','<?php echo $vars['url']; ?>_graphics/avatar_menu_arrow.gif');
- $(".avatar_menu_button").not(this).hide();
- })
- // hover arrow each time mouseover enters arrow graphic (eg. when menu is already shown)
- .mouseover(function() { $(this).attr('src','<?php echo $vars['url']; ?>_graphics/avatar_menu_arrow_hover.gif'); })
- // if menu not shown revert arrow, else show 'menu open' arrow
- .mouseout(function() {
- if($(this).parent().parent().find("div.sub_menu").css('display')!="block"){
- $(this).attr('src','<?php echo $vars['url']; ?>_graphics/avatar_menu_arrow.gif');
- }
- else {
- $(this).attr('src','<?php echo $vars['url']; ?>_graphics/avatar_menu_arrow_open.gif');
- }
- });
-
- // hide avatar menu if click occurs outside of menu
- // and hide arrow button
- $(document).click(function(event) {
- var target = $(event.target);
- if (target.parents(".usericon").length == 0) {
- $(".usericon div.sub_menu").fadeOut();
- $(".usericon img.arrow").attr('src','<?php echo $vars['url']; ?>_graphics/avatar_menu_arrow.gif');
- $(".avatar_menu_button").hide();
- }
- });
-
-
-});
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 3b322f799..000000000 --- a/mod/profile/views/default/profile/listing.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php
-
- /**
- * Elgg user display (small)
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- *
- * @uses $vars['entity'] The user entity
- */
-
- $icon = elgg_view(
- "profile/icon", array(
- 'entity' => $vars['entity'],
- 'size' => 'small',
- )
- );
-
- $info = "<p><b><a href=\"" . $vars['entity']->getUrl() . "\">" . $vars['entity']->name . "</a></b></p>";
-
- $location = $vars['entity']->location;
- if (!empty($location)) {
- $info .= "<p>" . elgg_echo("profile:location") . ": " . elgg_view("output/tags",array('value' => $vars['entity']->location)) . "</p>";
- }
-
- echo elgg_view_listing($icon, $info);
-
-?>
\ No newline at end of file diff --git a/mod/profile/views/default/profile/menu/actions.php b/mod/profile/views/default/profile/menu/actions.php deleted file mode 100644 index f69ad1316..000000000 --- a/mod/profile/views/default/profile/menu/actions.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php
-
- /**
- * Elgg profile icon hover over: actions
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- *
- * @uses $vars['entity'] The user entity. If none specified, the current user is assumed.
- */
-
- if (isloggedin()) {
- if ($_SESSION['user']->getGUID() != $vars['entity']->getGUID()) {
- if ($vars['entity']->isFriend()) {
- echo "<p class=\"user_menu_removefriend\"><a href=\"{$vars['url']}action/friends/remove?friend={$vars['entity']->getGUID()}\">" . elgg_echo("friend:remove") . "</a></p>";
- } else {
- echo "<p><a href=\"{$vars['url']}action/friends/add?friend={$vars['entity']->getGUID()}\">" . elgg_echo("friend:add") . "</a></p>";
- }
- }
- }
-
-?>
\ 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 c60de7456..000000000 --- a/mod/profile/views/default/profile/menu/links.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php
-
- /**
- * Elgg profile icon hover over: passive links
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- *
- * @uses $vars['entity'] The user entity. If none specified, the current user is assumed.
- */
-
-?>
-
- <p class="user_menu_profile">
- <a href="<?php echo $vars['entity']->getURL(); ?>"><?php echo elgg_echo("profile"); ?></a>
- </p>
- <p class="user_menu_friends">
- <a href="<?php echo $vars['url']; ?>pg/friends/<?php echo $vars['entity']->username; ?>/"><?php echo elgg_echo("friends"); ?></a>
- </p>
- <p class="user_menu_friends_of">
- <a href="<?php echo $vars['url']; ?>pg/friendsof/<?php echo $vars['entity']->username; ?>/"><?php echo elgg_echo("friends:of"); ?></a>
- </p>
\ No newline at end of file diff --git a/mod/profile/views/default/profile/menu/linksownpage.php b/mod/profile/views/default/profile/menu/linksownpage.php deleted file mode 100644 index 04f031506..000000000 --- a/mod/profile/views/default/profile/menu/linksownpage.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php
-
- /**
- * Elgg profile icon / profile links: passive links when looking at your own icon / profile
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Dave Tosh <dave@elgg.com>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- *
- * @uses $vars['entity'] The user entity. If none specified, the current user is assumed.
- */
-
-?>
-
- <p class="user_menu_friends">
- <a href="<?php echo $vars['url']; ?>pg/friends/<?php echo $vars['entity']->username; ?>/"><?php echo elgg_echo("friends"); ?></a>
- </p>
- <p class="user_menu_friends_of">
- <a href="<?php echo $vars['url']; ?>pg/friendsof/<?php echo $vars['entity']->username; ?>/"><?php echo elgg_echo("friends:of"); ?></a>
- </p>
\ No newline at end of file diff --git a/mod/profile/views/default/profile/metatags.php b/mod/profile/views/default/profile/metatags.php index 77b5544e4..52048b8a7 100644 --- a/mod/profile/views/default/profile/metatags.php +++ b/mod/profile/views/default/profile/metatags.php @@ -1,16 +1,16 @@ -<?php
-
- /**
- * Adds metatags to load Javascript required for the profile
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- *
- */
-
-?>
-
- <script type="text/javascript" src="<?php echo $vars['url']; ?>mod/profile/javascript.php" ></script>
+<?php +/** + * FOAF + * + * @package ElggProfile + * + */ + +$owner = elgg_get_page_owner_entity(); + +if (elgg_instanceof($owner, 'user')) { +?> + <link rel="meta" type="application/rdf+xml" title="FOAF" href="<?php echo current_page_url(); ?>?view=foaf" /> +<?php + +} 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/profilelinks.php b/mod/profile/views/default/profile/profilelinks.php deleted file mode 100644 index fda223a31..000000000 --- a/mod/profile/views/default/profile/profilelinks.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php
-
- /**
- * Elgg profile links
- * We need to make sure that the correct links display depending on whether you are looking at your own
- * profile or someone else's
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Dave Tosh <dave@elgg.com>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- *
- * @uses $vars['entity'] The user entity. If none specified, the current user is assumed.
- */
-
-?>
-
-<?php
-
- //check to see if the user is looking at their own profile
- if($_SESSION['user']->guid == page_owner()){
-
- echo "<div id=\"profile_menu_wrapper\">"; //start the wrapper div
- echo elgg_view("profile/menu/actions",$vars);//grab action links such as make friend
- echo elgg_view("profile/menu/linksownpage",$vars); // an different view for user's own profile
- echo "</div>"; //close wrapper div
-
- } else {
-
- echo "<div id=\"profile_menu_wrapper\">"; //start the wrapper div
- echo elgg_view("profile/menu/actions",$vars); //grab action links such as make friend
- echo elgg_view("profile/menu/links",$vars); //passive links to items such as user blog etc
- echo "</div>"; //close wrapper div
-
- }
-
-?>
\ No newline at end of file diff --git a/mod/profile/views/default/profile/userdetails.php b/mod/profile/views/default/profile/userdetails.php deleted file mode 100644 index a6f381328..000000000 --- a/mod/profile/views/default/profile/userdetails.php +++ /dev/null @@ -1,136 +0,0 @@ -<?php - - /** - * Elgg user display (details) - * - * @package ElggProfile - * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 - * @author Ben Werdmuller <ben@curverider.co.uk> - * @copyright Curverider Ltd 2008 - * @link http://elgg.com/ - * - * @uses $vars['entity'] The user entity - */ - - if ($vars['full'] == true) { - $iconsize = "large"; - } else { - $iconsize = "medium"; - } - - // wrap all profile info - echo "<div id=\"profile_info\">"; - -?> - -<table> -<tr> -<td> - -<?php - - // wrap the icon and links in a div - echo "<div id=\"profile_info_column_left\">"; - - // get the user's main profile picture - echo elgg_view( - "profile/icon", array( - 'entity' => $vars['entity'], - //'align' => "left", - 'size' => $iconsize, - ) - ); - - // display relevant links - echo elgg_view("profile/profilelinks", array("entity" => $vars['entity'])); - - // close the icon and links div - echo "</div>"; - -?> -<!-- /#profile_info_column_left --> -</td> -<td> - - <div id="profile_info_column_right" > - - <?php - - // display the users name - echo "<h2><a href=\"" . $vars['entity']->getUrl() . "\">" . $vars['entity']->name . "</a></h2> <br />"; - - if ($vars['full'] == true) { - - ?> - <?php - - 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)) { - - ?> - - <p> - <b><?php - - echo elgg_echo("profile:{$shortname}"); - - ?>: </b> - <?php - - echo elgg_view("output/{$valtype}",array('value' => $vars['entity']->$shortname)); - - ?> - - </p> - - <?php - } - } - } - - } - - ?> - </div><!-- /#profile_info_column_right --> - -</td> -</tr> -</table> - - <div id="profile_info_wide"> - <p><b><?php echo elgg_echo("profile:aboutme"); ?></b><br /><?php echo nl2br($vars['entity']->description); ?></p> - -<?php - - if ($vars['entity']->canEdit()) { - -?> - <p class="profile_info_edit_buttons"> - <a href="<?php echo $vars['url']; ?>mod/profile/edit.php"><?php echo elgg_echo("edit"); ?></a> - -<?php - - } - - // TODO: Add admin console options here - if (isadminloggedin()){ - if ($_SESSION['id']!=$vars['entity']->guid){ -?> - - <a href="<?php echo $vars['url']; ?>actions/admin/user/ban?guid=<?php echo $vars['entity']->guid; ?>"><?php echo elgg_echo("ban"); ?></a> - - <a href="<?php echo $vars['url']; ?>actions/admin/user/delete?guid=<?php echo $vars['entity']->guid; ?>"><?php echo elgg_echo("delete"); ?></a> - - <a href="<?php echo $vars['url']; ?>actions/admin/user/resetpassword?guid=<?php echo $vars['entity']->guid; ?>"><?php echo elgg_echo("resetpassword"); ?></a> - -<?php - } - } -?> -</p> -</div><!-- /#profile_info_wide --> - -</div><!-- /#profile_info --> 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 diff --git a/mod/profile/views/default/river/ElggUser/update.php b/mod/profile/views/default/river/ElggUser/update.php deleted file mode 100644 index c9b710512..000000000 --- a/mod/profile/views/default/river/ElggUser/update.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php
-
- $performed_by = $vars['performed_by'];
-
- $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
- $string = sprintf(elgg_echo("profile:river:update"),$url);
-
-?>
-
-<?php echo $string; ?>
\ No newline at end of file diff --git a/mod/profile/views/default/user/user.php b/mod/profile/views/default/user/user.php deleted file mode 100644 index a913ef3f8..000000000 --- a/mod/profile/views/default/user/user.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php
-
- /**
- * Elgg user display
- *
- * @package ElggProfile
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Ben Werdmuller <ben@curverider.co.uk>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- *
- * @uses $vars['entity'] The user entity
- */
-
- if ($vars['full']) {
- echo elgg_view("profile/userdetails",$vars);
- } else {
- echo elgg_view("profile/listing",$vars);
- }
-
-?>
\ No newline at end of file |
