diff options
Diffstat (limited to 'mod/profile')
-rw-r--r-- | mod/profile/actions/iconupload.php | 45 | ||||
-rw-r--r-- | mod/profile/editicon.php | 25 | ||||
-rw-r--r-- | mod/profile/graphics/defaultlarge.jpg | bin | 0 -> 9782 bytes | |||
-rw-r--r-- | mod/profile/graphics/defaultmedium.jpg | bin | 0 -> 4096 bytes | |||
-rw-r--r-- | mod/profile/graphics/defaultsmall.jpg | bin | 0 -> 1975 bytes | |||
-rw-r--r-- | mod/profile/icon.php | 41 | ||||
-rw-r--r-- | mod/profile/languages/en.php | 2 | ||||
-rw-r--r-- | mod/profile/start.php | 24 | ||||
-rw-r--r-- | mod/profile/views/default/profile/editicon.php | 32 | ||||
-rw-r--r-- | mod/profile/views/default/profile/icon.php | 36 | ||||
-rw-r--r-- | mod/profile/views/default/user/user.php | 12 |
11 files changed, 213 insertions, 4 deletions
diff --git a/mod/profile/actions/iconupload.php b/mod/profile/actions/iconupload.php new file mode 100644 index 000000000..bdb925838 --- /dev/null +++ b/mod/profile/actions/iconupload.php @@ -0,0 +1,45 @@ +<?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()
+ && $small = get_resized_image_from_uploaded_file('profileicon',50,50)
+ && $medium = get_resized_image_from_uploaded_file('profileicon',100,100)
+ && $large = get_resized_image_from_uploaded_file('profileicon',200,200)
+ ) {
+
+ $filehandler = new ElggFile();
+ $filehandler->setFilename($_SESSION['user']->username . "large.jpg");
+ $filehandler->open("write");
+ $filehandler->write($large);
+ $filehandler->close();
+ $filehandler->setFilename($_SESSION['user']->username . "medium.jpg");
+ $filehandler->open("write");
+ $filehandler->write($medium);
+ $filehandler->close();
+ $filehandler->setFilename($_SESSION['user']->username . "small.jpg");
+ $filehandler->open("write");
+ $filehandler->write($small);
+ $filehandler->close();
+
+ system_message(elgg_echo("profile:icon:uploaded"));
+
+ } else {
+
+ system_message(elgg_echo("profile:icon:notfound"));
+
+ }
+
+ if (isloggedin()) forward($_SESSION['user']->getURL());
+
+?>
\ No newline at end of file diff --git a/mod/profile/editicon.php b/mod/profile/editicon.php new file mode 100644 index 000000000..2b33abb62 --- /dev/null +++ b/mod/profile/editicon.php @@ -0,0 +1,25 @@ +<?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
+ $body = 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 differnew file mode 100644 index 000000000..a4492b666 --- /dev/null +++ b/mod/profile/graphics/defaultlarge.jpg diff --git a/mod/profile/graphics/defaultmedium.jpg b/mod/profile/graphics/defaultmedium.jpg Binary files differnew file mode 100644 index 000000000..b54cbe88b --- /dev/null +++ b/mod/profile/graphics/defaultmedium.jpg diff --git a/mod/profile/graphics/defaultsmall.jpg b/mod/profile/graphics/defaultsmall.jpg Binary files differnew file mode 100644 index 000000000..58d6c23b5 --- /dev/null +++ b/mod/profile/graphics/defaultsmall.jpg diff --git a/mod/profile/icon.php b/mod/profile/icon.php new file mode 100644 index 000000000..dd87ff939 --- /dev/null +++ b/mod/profile/icon.php @@ -0,0 +1,41 @@ +<?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')))
+ $size = "medium";
+
+ // Try and get the icon
+
+ $filehandler = new ElggFile();
+ $filehandler->setFilename($username . $size . ".jpg");
+ if ($filehandler->open("read") && $contents = $filehandler->read($filehandler->size())) {
+ } else {
+
+ global $CONFIG;
+ $contents = @file_get_contents($CONFIG->pluginspath . "profile/graphics/default{$size}.jpg");
+
+ }
+
+ header("Content-type: image/jpeg");
+ echo $contents;
+
+?>
\ No newline at end of file diff --git a/mod/profile/languages/en.php b/mod/profile/languages/en.php index 79a3300cf..6227f6657 100644 --- a/mod/profile/languages/en.php +++ b/mod/profile/languages/en.php @@ -21,6 +21,7 @@ 'profile:user' => "%s's profile",
'profile:edit' => "Edit profile",
+ 'profile:editicon' => "Change your profile picture",
'profile:description' => "About me",
'profile:location' => "Location",
@@ -43,6 +44,7 @@ '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.",
);
diff --git a/mod/profile/start.php b/mod/profile/start.php index 03fe0eda1..86faded71 100644 --- a/mod/profile/start.php +++ b/mod/profile/start.php @@ -31,6 +31,7 @@ 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"),
));
}
@@ -53,6 +54,7 @@ // Register a page handler, so we can have nice URLs
register_page_handler('profile','profile_page_handler');
+ register_page_handler('icon','profile_icon_handler');
}
@@ -75,6 +77,27 @@ }
/**
+ * 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
@@ -91,6 +114,7 @@ // 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");
?>
\ No newline at end of file diff --git a/mod/profile/views/default/profile/editicon.php b/mod/profile/views/default/profile/editicon.php new file mode 100644 index 000000000..8e71f2f75 --- /dev/null +++ b/mod/profile/views/default/profile/editicon.php @@ -0,0 +1,32 @@ +<?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
+ */
+
+?>
+
+ <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" value="<?php echo elgg_echo("upload"); ?>" />
+ </p>
+ </form>
\ No newline at end of file diff --git a/mod/profile/views/default/profile/icon.php b/mod/profile/views/default/profile/icon.php new file mode 100644 index 000000000..577620b6f --- /dev/null +++ b/mod/profile/views/default/profile/icon.php @@ -0,0 +1,36 @@ +<?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;
+
+ // Get size
+ if (!in_array($vars['size'],array('small','medium','large')))
+ $vars['size'] = "medium";
+
+ // Get any align and js
+ if (!empty($vars['align'])) {
+ $align = " align=\"{$vars['align']}\" ";
+ } else {
+ $align = "";
+ }
+
+?>
+
+ <a href="<?php echo $vars['entity']->getURL(); ?>"><img src="<?php echo $vars['url']; ?>pg/icon/<?php echo $username; ?>/<?php echo $vars['size']; ?>/icon.jpg" border="0" <?php echo $align; ?> title="<?php echo $name; ?>" <?php echo $vars['js']; ?> /></a>
\ No newline at end of file diff --git a/mod/profile/views/default/user/user.php b/mod/profile/views/default/user/user.php index d2411c3d9..e11c463ca 100644 --- a/mod/profile/views/default/user/user.php +++ b/mod/profile/views/default/user/user.php @@ -12,12 +12,16 @@ * @uses $vars['entity'] The user entity
*/
-?>
+ echo elgg_view(
+ "profile/icon", array(
+ 'entity' => $vars['entity'],
+ 'align' => "right",
+ 'size' => "large",
+ )
+ );
+?>
<h2><a href="<?php echo $vars['entity']->getUrl(); ?>"><?php echo $vars['entity']->name; ?></a></h2>
- <p>
- *** USER ICON TO COME ***
- </p>
<?php
if ($vars['full'] == true) {
|