diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-03-03 17:53:05 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-03-03 17:53:05 +0000 |
commit | 4766f36a4d74924f21ff329c4318ce4e069ffa04 (patch) | |
tree | 969b84632f2a8b0db79788a8a6db8e41d63e5cb4 /mod/profile/actions/iconupload.php | |
parent | 57a217fd6b708844407486046a1faa23b46cac08 (diff) | |
download | elgg-4766f36a4d74924f21ff329c4318ce4e069ffa04.tar.gz elgg-4766f36a4d74924f21ff329c4318ce4e069ffa04.tar.bz2 |
Pulled in the interface changes.
git-svn-id: http://code.elgg.org/elgg/trunk@5257 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/profile/actions/iconupload.php')
-rw-r--r-- | mod/profile/actions/iconupload.php | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/mod/profile/actions/iconupload.php b/mod/profile/actions/iconupload.php new file mode 100644 index 000000000..f1d290694 --- /dev/null +++ b/mod/profile/actions/iconupload.php @@ -0,0 +1,91 @@ +<?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 Curverider Ltd <info@elgg.com> + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + gatekeeper(); + + $user = page_owner_entity(); + if (!$user) + $user = $_SESSION['user']; + + // If we were given a correct icon + if ( + (isloggedin()) && + ($user) && + ($user->canEdit()) + ) { + + + $topbar = get_resized_image_from_uploaded_file('profileicon',16,16, true); + $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',550,550); + + if ($small !== false + && $medium !== false + && $large !== false + && $tiny !== false) { + + $filehandler = new ElggFile(); + $filehandler->owner_guid = $user->getGUID(); + $filehandler->setFilename("profile/" . $user->username . "large.jpg"); + $filehandler->open("write"); + $filehandler->write($large); + $filehandler->close(); + $filehandler->setFilename("profile/" . $user->username . "medium.jpg"); + $filehandler->open("write"); + $filehandler->write($medium); + $filehandler->close(); + $filehandler->setFilename("profile/" . $user->username . "small.jpg"); + $filehandler->open("write"); + $filehandler->write($small); + $filehandler->close(); + $filehandler->setFilename("profile/" . $user->username . "tiny.jpg"); + $filehandler->open("write"); + $filehandler->write($tiny); + $filehandler->close(); + $filehandler->setFilename("profile/" . $user->username . "topbar.jpg"); + $filehandler->open("write"); + $filehandler->write($topbar); + $filehandler->close(); + $filehandler->setFilename("profile/" . $user->username . "master.jpg"); + $filehandler->open("write"); + $filehandler->write($master); + $filehandler->close(); + + $user->icontime = time(); + + system_message(elgg_echo("profile:icon:uploaded")); + + trigger_elgg_event('profileiconupdate',$user->type,$user); + + //add to river + add_to_river('river/user/default/profileiconupdate','update',$user->guid,$user->guid); + + } 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 = "pg/profile/{$user->username}/editicon/"; + + if (isloggedin()) forward($url); + +?> |