summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/avatarsettings.php39
-rw-r--r--actions/joingroup.php2
-rw-r--r--actions/showgroup.php6
3 files changed, 13 insertions, 34 deletions
diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php
index ffbeb5486..2c7af9b7a 100644
--- a/actions/avatarsettings.php
+++ b/actions/avatarsettings.php
@@ -205,37 +205,10 @@ class AvatarsettingsAction extends AccountSettingsAction
function uploadAvatar()
{
- switch ($_FILES['avatarfile']['error']) {
- case UPLOAD_ERR_OK: // success, jump out
- break;
- case UPLOAD_ERR_INI_SIZE:
- case UPLOAD_ERR_FORM_SIZE:
- $this->showForm(_('That file is too big.'));
- return;
- case UPLOAD_ERR_PARTIAL:
- @unlink($_FILES['avatarfile']['tmp_name']);
- $this->showForm(_('Partial upload.'));
- return;
- default:
- $this->showForm(_('System error uploading file.'));
- return;
- }
-
- $info = @getimagesize($_FILES['avatarfile']['tmp_name']);
-
- if (!$info) {
- @unlink($_FILES['avatarfile']['tmp_name']);
- $this->showForm(_('Not an image or corrupt file.'));
- return;
- }
-
- switch ($info[2]) {
- case IMAGETYPE_GIF:
- case IMAGETYPE_JPEG:
- case IMAGETYPE_PNG:
- break;
- default:
- $this->showForm(_('Unsupported image file format.'));
+ try {
+ $imagefile = ImageFile::fromUpload('avatarfile');
+ } catch (Exception $e) {
+ $this->showForm($e->getMessage());
return;
}
@@ -243,13 +216,13 @@ class AvatarsettingsAction extends AccountSettingsAction
$profile = $user->getProfile();
- if ($profile->setOriginal($_FILES['avatarfile']['tmp_name'])) {
+ if ($profile->setOriginal($imagefile->filename)) {
$this->showForm(_('Avatar updated.'), true);
} else {
$this->showForm(_('Failed updating avatar.'));
}
- @unlink($_FILES['avatarfile']['tmp_name']);
+ $imagefile->unlink();
}
/**
diff --git a/actions/joingroup.php b/actions/joingroup.php
index 45470f088..1888ecdab 100644
--- a/actions/joingroup.php
+++ b/actions/joingroup.php
@@ -91,7 +91,7 @@ class JoingroupAction extends Action
$cur = common_current_user();
- if ($cur->isMember($group)) {
+ if ($cur->isMember($this->group)) {
$this->clientError(_('You are already a member of that group'), 403);
return false;
}
diff --git a/actions/showgroup.php b/actions/showgroup.php
index 0a499aff9..534043c24 100644
--- a/actions/showgroup.php
+++ b/actions/showgroup.php
@@ -146,6 +146,12 @@ class ShowgroupAction extends Action
$this->showPage();
}
+ /**
+ * Local menu
+ *
+ * @return void
+ */
+
function showLocalNav()
{
$nav = new GroupNav($this, $this->group);