Make group edit and logo great again by XRevan86

This commit is contained in:
Diogo Cordeiro 2019-04-27 17:39:42 +01:00
parent f6dbf66983
commit d75b5d2f4a
2 changed files with 400 additions and 376 deletions

View File

@ -29,7 +29,7 @@
* @link http://status.net/ * @link http://status.net/
*/ */
if (!defined('STATUSNET') && !defined('LACONICA')) { if (!defined('STATUSNET') && !defined('LACONICA') && !defined('GNUSOCIAL')) {
exit(1); exit(1);
} }
@ -42,24 +42,63 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
* @package StatusNet * @package StatusNet
* @author Evan Prodromou <evan@status.net> * @author Evan Prodromou <evan@status.net>
* @author Zach Copley <zach@status.net> * @author Zach Copley <zach@status.net>
* @author Alexei Sorokin <sor.alexei@meowr.ru>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/ * @link http://status.net/
*/ */
class EditgroupAction extends GroupAction class EditgroupAction extends GroupAction
{ {
var $msg; public $message = null;
public $success = null;
protected $canPost = true;
function title() public function title()
{ {
// TRANS: Title for form to edit a group. %s is a group nickname. // TRANS: Title for form to edit a group. %s is a group nickname.
return sprintf(_('Edit %s group'), $this->group->nickname); return sprintf(_('Edit %s group'), $this->group->nickname);
} }
public function showContent()
{
$form = new GroupEditForm($this, $this->group);
$form->show();
}
public function showPageNoticeBlock()
{
parent::showPageNoticeBlock();
if ($this->message) {
$this->element(
'p',
($this->success) ? 'success' : 'error',
$this->message
);
} else {
$this->element(
'p',
'instructions',
// TRANS: Form instructions for group edit form.
_('Use this form to edit the group.')
);
}
}
public function showScripts()
{
parent::showScripts();
$this->autofocus('fullname');
}
/** /**
* Prepare to run * Prepare to run
* @param array $args
* @return bool
* @throws ClientException
* @throws NicknameException
*/ */
protected function prepare(array $args=array()) protected function prepare(array $args = [])
{ {
parent::prepare($args); parent::prepare($args);
@ -74,7 +113,7 @@ class EditgroupAction extends GroupAction
// Permanent redirect on non-canonical nickname // Permanent redirect on non-canonical nickname
if ($nickname_arg != $nickname) { if ($nickname_arg != $nickname) {
$args = array('nickname' => $nickname); $args = ['nickname' => $nickname];
common_redirect(common_local_url('editgroup', $args), 301); common_redirect(common_local_url('editgroup', $args), 301);
} }
@ -109,75 +148,32 @@ class EditgroupAction extends GroupAction
return true; return true;
} }
/** protected function handlePost()
* Handle the request
*
* On GET, show the form. On POST, try to save the group.
*
* @return void
*/
protected function handle()
{ {
parent::handle(); parent::handlePost();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->trySave();
} else {
$this->showForm();
}
}
function showForm($msg=null)
{
$this->msg = $msg;
$this->showPage();
}
function showContent()
{
$form = new GroupEditForm($this, $this->group);
$form->show();
}
function showPageNotice()
{
if ($this->msg) {
$this->element('p', 'error', $this->msg);
} else {
$this->element('p', 'instructions',
// TRANS: Form instructions for group edit form.
_('Use this form to edit the group.'));
}
}
function showScripts()
{
parent::showScripts();
$this->autofocus('fullname');
}
function trySave()
{
$cur = common_current_user(); $cur = common_current_user();
if (!$cur->isAdmin($this->group)) { if (!$cur->isAdmin($this->group)) {
// TRANS: Client error displayed trying to edit a group while not being a group admin. // TRANS: Client error displayed trying to edit a group while not being a group admin.
$this->clientError(_('You must be an admin to edit the group.'), 403); $this->clientError(_('You must be an admin to edit the group.'), 403);
} }
if (Event::handle('StartGroupSaveForm', array($this))) { if (Event::handle('StartGroupSaveForm', [$this])) {
// $nickname will only be set if this changenick value is true. // $nickname will only be set if this changenick value is true.
$nickname = null;
if (common_config('profile', 'changenick') == true) { if (common_config('profile', 'changenick') == true) {
try { try {
$nickname = Nickname::normalize($this->trimmed('newnickname'), true); $nickname = Nickname::normalize($this->trimmed('newnickname'), true);
} catch (NicknameTakenException $e) { } catch (NicknameTakenException $e) {
// Abort only if the nickname is occupied by _another_ group // Abort only if the nickname is occupied by _another_ group
if ($e->profile->id != $this->group->profile_id) { if ($e->profile->id != $this->group->profile_id) {
$this->showForm($e->getMessage()); $this->setMessage($e->getMessage(), true);
return; return;
} }
$nickname = Nickname::normalize($this->trimmed('newnickname')); // without in-use check this time $nickname = Nickname::normalize($this->trimmed('newnickname')); // without in-use check this time
} catch (NicknameException $e) { } catch (NicknameException $e) {
$this->showForm($e->getMessage()); $this->setMessage($e->getMessage(), true);
return; return;
} }
} }
@ -200,40 +196,49 @@ class EditgroupAction extends GroupAction
if (!is_null($homepage) && (strlen($homepage) > 0) && if (!is_null($homepage) && (strlen($homepage) > 0) &&
!common_valid_http_url($homepage)) { !common_valid_http_url($homepage)) {
// TRANS: Group edit form validation error. // TRANS: Group edit form validation error.
$this->showForm(_('Homepage is not a valid URL.')); $this->setMessage(_('Homepage is not a valid URL.'), true);
return; return;
} elseif (!is_null($fullname) && mb_strlen($fullname) > 255) { } elseif (!is_null($fullname) && mb_strlen($fullname) > 255) {
// TRANS: Group edit form validation error. // TRANS: Group edit form validation error.
$this->showForm(_('Full name is too long (maximum 255 characters).')); $this->setMessage(_('Full name is too long (maximum 255 characters).'), true);
return; return;
} elseif (User_group::descriptionTooLong($description)) { } elseif (User_group::descriptionTooLong($description)) {
$this->showForm(sprintf( $this->setMessage(sprintf(
// TRANS: Group edit form validation error. // TRANS: Group edit form validation error.
_m('Description is too long (maximum %d character).', _m(
'Description is too long (maximum %d character).',
'Description is too long (maximum %d characters).', 'Description is too long (maximum %d characters).',
User_group::maxDescription()), User_group::maxDescription()
User_group::maxDescription())); ),
User_group::maxDescription()
), true);
return; return;
} elseif (!is_null($location) && mb_strlen($location) > 255) { } elseif (!is_null($location) && mb_strlen($location) > 255) {
// TRANS: Group edit form validation error. // TRANS: Group edit form validation error.
$this->showForm(_('Location is too long (maximum 255 characters).')); $this->setMessage(_('Location is too long (maximum 255 characters).'), true);
return; return;
} }
if (!empty($aliasstring)) { if (!empty($aliasstring)) {
$aliases = array_map(array('Nickname', 'normalize'), $aliases = array_map(
array_unique(preg_split('/[\s,]+/', $aliasstring))); ['Nickname', 'normalize'],
array_unique(preg_split('/[\s,]+/', $aliasstring))
);
} else { } else {
$aliases = array(); $aliases = [];
} }
if (count($aliases) > common_config('group', 'maxaliases')) { if (count($aliases) > common_config('group', 'maxaliases')) {
// TRANS: Group edit form validation error. // TRANS: Group edit form validation error.
// TRANS: %d is the maximum number of allowed aliases. // TRANS: %d is the maximum number of allowed aliases.
$this->showForm(sprintf(_m('Too many aliases! Maximum %d allowed.', $this->setMessage(sprintf(
_m(
'Too many aliases! Maximum %d allowed.', 'Too many aliases! Maximum %d allowed.',
common_config('group', 'maxaliases')), 'Too many aliases! Maximum %d allowed.',
common_config('group', 'maxaliases'))); common_config('group', 'maxaliases')
),
common_config('group', 'maxaliases')
), true);
return; return;
} }
@ -243,9 +248,9 @@ class EditgroupAction extends GroupAction
if (common_config('profile', 'changenick') == true && $this->group->nickname !== $nickname) { if (common_config('profile', 'changenick') == true && $this->group->nickname !== $nickname) {
assert(Nickname::normalize($nickname) === $nickname); assert(Nickname::normalize($nickname) === $nickname);
common_debug("Changing group nickname from '{$profile->nickname}' to '{$nickname}'."); common_debug("Changing group nickname from '{$this->group->nickname}' to '{$nickname}'.");
$this->group->nickname = $nickname; $this->group->nickname = $nickname;
$this->group->mainpage = common_local_url('showgroup', array('nickname' => $this->group->nickname)); $this->group->mainpage = common_local_url('showgroup', ['nickname' => $this->group->nickname]);
} }
$this->group->fullname = $fullname; $this->group->fullname = $fullname;
$this->group->homepage = $homepage; $this->group->homepage = $homepage;
@ -271,14 +276,20 @@ class EditgroupAction extends GroupAction
$this->group->query('COMMIT'); $this->group->query('COMMIT');
Event::handle('EndGroupSaveForm', array($this)); Event::handle('EndGroupSaveForm', [$this]);
}
if ($this->group->nickname != $orig->nickname) { if ($this->group->nickname != $orig->nickname) {
common_redirect(common_local_url('editgroup', array('nickname' => $this->group->nickname)), 303); common_redirect(common_local_url('editgroup', ['nickname' => $this->group->nickname]), 303);
} else { }
}
// TRANS: Group edit form success message. // TRANS: Group edit form success message.
$this->showForm(_('Options saved.')); $this->setMessage(_('Options saved.'));
} }
public function setMessage($msg, $error = false)
{
$this->message = $msg;
$this->success = !$error;
} }
} }

View File

@ -28,7 +28,9 @@
* @link http://status.net/ * @link http://status.net/
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } if (!defined('GNUSOCIAL')) {
exit(1);
}
/** /**
* Upload an avatar * Upload an avatar
@ -40,111 +42,30 @@ if (!defined('GNUSOCIAL')) { exit(1); }
* @author Evan Prodromou <evan@status.net> * @author Evan Prodromou <evan@status.net>
* @author Zach Copley <zach@status.net> * @author Zach Copley <zach@status.net>
* @author Sarven Capadisli <csarven@status.net> * @author Sarven Capadisli <csarven@status.net>
* @author Alexei Sorokin <sor.alexei@meowr.ru>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/ * @link http://status.net/
*/ */
class GrouplogoAction extends GroupAction class GrouplogoAction extends GroupAction
{ {
var $mode = null; public $mode = null;
var $imagefile = null; public $imagefile = null;
var $filename = null; public $filename = null;
var $msg = null; public $message = null;
var $success = null; public $success = null;
protected $canPost = true;
/**
* Prepare to run
*/
protected function prepare(array $args=array())
{
parent::prepare($args);
if (!common_logged_in()) {
// TRANS: Client error displayed when trying to create a group while not logged in.
$this->clientError(_('You must be logged in to create a group.'));
}
$nickname_arg = $this->trimmed('nickname');
$nickname = common_canonical_nickname($nickname_arg);
// Permanent redirect on non-canonical nickname
if ($nickname_arg != $nickname) {
$args = array('nickname' => $nickname);
common_redirect(common_local_url('grouplogo', $args), 301);
}
if (!$nickname) {
// TRANS: Client error displayed when trying to change group logo settings without providing a nickname.
$this->clientError(_('No nickname.'), 404);
}
$groupid = $this->trimmed('groupid');
if ($groupid) {
$this->group = User_group::getKV('id', $groupid);
} else {
$local = Local_group::getKV('nickname', $nickname);
if ($local) {
$this->group = User_group::getKV('id', $local->group_id);
}
}
if (!$this->group) {
// TRANS: Client error displayed when trying to update logo settings for a non-existing group.
$this->clientError(_('No such group.'), 404);
}
$cur = common_current_user();
if (!$cur->isAdmin($this->group)) {
// TRANS: Client error displayed when trying to change group logo settings while not being a group admin.
$this->clientError(_('You must be an admin to edit the group.'), 403);
}
return true;
}
protected function handle()
{
parent::handle();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->handlePost();
} else {
$this->showForm();
}
}
function showForm($msg = null, $success = false)
{
$this->msg = $msg;
$this->success = $success;
$this->showPage();
}
/** /**
* Title of the page * Title of the page
* *
* @return string Title of the page * @return string Title of the page
*/ */
function title() public function title()
{ {
// TRANS: Title for group logo settings page. // TRANS: Title for group logo settings page.
return _('Group logo'); return _('Group logo');
} }
/**
* Instructions for use
*
* @return instructions for use
*/
function getInstructions()
{
// TRANS: Instructions for group logo page.
// TRANS: %s is the maximum file size for that site.
return sprintf(_('You can upload a logo image for your group. The maximum file size is %s.'), ImageFile::maxFileSize());
}
/** /**
* Content area of the page * Content area of the page
* *
@ -152,7 +73,7 @@ class GrouplogoAction extends GroupAction
* *
* @return void * @return void
*/ */
function showContent() public function showContent()
{ {
if ($this->mode == 'crop') { if ($this->mode == 'crop') {
$this->showCropForm(); $this->showCropForm();
@ -161,7 +82,69 @@ class GrouplogoAction extends GroupAction
} }
} }
function showUploadForm() public function showCropForm()
{
$this->elementStart('form', array('method' => 'post',
'id' => 'form_settings_avatar',
'class' => 'form_settings',
'action' =>
common_local_url(
'grouplogo',
array('nickname' => $this->group->nickname)
)));
$this->elementStart('fieldset');
// TRANS: Legend for group logo settings fieldset.
$this->element('legend', null, _('Avatar settings'));
$this->hidden('token', common_session_token());
$this->elementStart('ul', 'form_data');
$this->elementStart(
'li',
array('id' => 'avatar_original',
'class' => 'avatar_view')
);
// TRANS: Header for originally uploaded file before a crop on the group logo page.
$this->element('h2', null, _('Original'));
$this->elementStart('div', array('id' => 'avatar_original_view'));
$this->element('img', array('src' => Avatar::url($this->filedata['filename']),
'width' => $this->filedata['width'],
'height' => $this->filedata['height'],
'alt' => $this->group->nickname));
$this->elementEnd('div');
$this->elementEnd('li');
$this->elementStart(
'li',
array('id' => 'avatar_preview',
'class' => 'avatar_view')
);
// TRANS: Header for the cropped group logo on the group logo page.
$this->element('h2', null, _('Preview'));
$this->elementStart('div', array('id' => 'avatar_preview_view'));
$this->element('img', array('src' => Avatar::url($this->filedata['filename']),
'width' => AVATAR_PROFILE_SIZE,
'height' => AVATAR_PROFILE_SIZE,
'alt' => $this->group->nickname));
$this->elementEnd('div');
foreach (array('avatar_crop_x', 'avatar_crop_y',
'avatar_crop_w', 'avatar_crop_h') as $crop_info) {
$this->element('input', array('name' => $crop_info,
'type' => 'hidden',
'id' => $crop_info));
}
// TRANS: Button text for cropping an uploaded group logo.
$this->submit('crop', _('Crop'));
$this->elementEnd('li');
$this->elementEnd('ul');
$this->elementEnd('fieldset');
$this->elementEnd('form');
}
public function showUploadForm()
{ {
$user = common_current_user(); $user = common_current_user();
@ -180,8 +163,10 @@ class GrouplogoAction extends GroupAction
'id' => 'form_settings_avatar', 'id' => 'form_settings_avatar',
'class' => 'form_settings', 'class' => 'form_settings',
'action' => 'action' =>
common_local_url('grouplogo', common_local_url(
array('nickname' => $this->group->nickname)))); 'grouplogo',
array('nickname' => $this->group->nickname)
)));
$this->elementStart('fieldset'); $this->elementStart('fieldset');
// TRANS: Group logo form legend. // TRANS: Group logo form legend.
$this->element('legend', null, _('Group logo')); $this->element('legend', null, _('Group logo'));
@ -240,60 +225,121 @@ class GrouplogoAction extends GroupAction
$this->elementEnd('form'); $this->elementEnd('form');
} }
function showCropForm() public function showPageNoticeBlock()
{ {
$this->elementStart('form', array('method' => 'post', parent::showPageNoticeBlock();
'id' => 'form_settings_avatar',
'class' => 'form_settings',
'action' =>
common_local_url('grouplogo',
array('nickname' => $this->group->nickname))));
$this->elementStart('fieldset');
// TRANS: Legend for group logo settings fieldset.
$this->element('legend', null, _('Avatar settings'));
$this->hidden('token', common_session_token());
$this->elementStart('ul', 'form_data'); if ($this->message) {
$this->element(
'div',
($this->success) ? 'success' : 'error',
$this->message
);
} else {
$inst = $this->getInstructions();
$output = common_markup_to_html($inst);
$this->elementStart('li', $this->elementStart('div', 'instructions');
array('id' => 'avatar_original', $this->raw($output);
'class' => 'avatar_view'));
// TRANS: Header for originally uploaded file before a crop on the group logo page.
$this->element('h2', null, _('Original'));
$this->elementStart('div', array('id'=>'avatar_original_view'));
$this->element('img', array('src' => Avatar::url($this->filedata['filename']),
'width' => $this->filedata['width'],
'height' => $this->filedata['height'],
'alt' => $this->group->nickname));
$this->elementEnd('div'); $this->elementEnd('div');
$this->elementEnd('li'); }
$this->elementStart('li',
array('id' => 'avatar_preview',
'class' => 'avatar_view'));
// TRANS: Header for the cropped group logo on the group logo page.
$this->element('h2', null, _('Preview'));
$this->elementStart('div', array('id'=>'avatar_preview_view'));
$this->element('img', array('src' => Avatar::url($this->filedata['filename']),
'width' => AVATAR_PROFILE_SIZE,
'height' => AVATAR_PROFILE_SIZE,
'alt' => $this->group->nickname));
$this->elementEnd('div');
foreach (array('avatar_crop_x', 'avatar_crop_y',
'avatar_crop_w', 'avatar_crop_h') as $crop_info) {
$this->element('input', array('name' => $crop_info,
'type' => 'hidden',
'id' => $crop_info));
} }
// TRANS: Button text for cropping an uploaded group logo. /**
$this->submit('crop', _('Crop')); * Instructions for use
*
* @return string instructions for use
*/
public function getInstructions()
{
// TRANS: Instructions for group logo page.
// TRANS: %s is the maximum file size for that site.
return sprintf(_('You can upload a logo image for your group. The maximum file size is %s.'), ImageFile::maxFileSize());
}
$this->elementEnd('li'); /**
$this->elementEnd('ul'); * Add the jCrop stylesheet
$this->elementEnd('fieldset'); *
$this->elementEnd('form'); * @return void
*/
public function showStylesheets()
{
parent::showStylesheets();
$this->cssLink('js/extlib/jquery-jcrop/css/jcrop.css', 'base', 'screen, projection, tv');
}
/**
* Add the jCrop scripts
*
* @return void
*/
public function showScripts()
{
parent::showScripts();
if ($this->mode == 'crop') {
$this->script('extlib/jquery-jcrop/jcrop.js');
$this->script('jcrop.go.js');
}
$this->autofocus('avatarfile');
}
/**
* Prepare to run
* @param array $args
* @return bool
* @throws ClientException
* @throws NicknameException
*/
protected function prepare(array $args = [])
{
parent::prepare($args);
if (!common_logged_in()) {
// TRANS: Client error displayed when trying to create a group while not logged in.
$this->clientError(_('You must be logged in to create a group.'));
}
$nickname_arg = $this->trimmed('nickname');
$nickname = common_canonical_nickname($nickname_arg);
// Permanent redirect on non-canonical nickname
if ($nickname_arg != $nickname) {
$args = array('nickname' => $nickname);
common_redirect(common_local_url('grouplogo', $args), 301);
}
if (!$nickname) {
// TRANS: Client error displayed when trying to change group logo settings without providing a nickname.
$this->clientError(_('No nickname.'), 404);
}
$groupid = $this->trimmed('groupid');
if ($groupid) {
$this->group = User_group::getKV('id', $groupid);
} else {
$local = Local_group::getKV('nickname', $nickname);
if ($local) {
$this->group = User_group::getKV('id', $local->group_id);
}
}
if (!$this->group) {
// TRANS: Client error displayed when trying to update logo settings for a non-existing group.
$this->clientError(_('No such group.'), 404);
}
$cur = common_current_user();
if (!$cur->isAdmin($this->group)) {
// TRANS: Client error displayed when trying to change group logo settings while not being a group admin.
$this->clientError(_('You must be an admin to edit the group.'), 403);
}
return true;
} }
/** /**
@ -302,18 +348,14 @@ class GrouplogoAction extends GroupAction
* We mux on the button name to figure out what the user actually wanted. * We mux on the button name to figure out what the user actually wanted.
* *
* @return void * @return void
* @throws ClientException
* @throws NoResultException
* @throws UnsupportedMediaException
* @throws UseFileAsThumbnailException
*/ */
function handlePost() protected function handlePost()
{ {
// CSRF protection parent::handlePost();
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
// TRANS: Form validation error message.
$this->show_form(_('There was a problem with your session token. '.
'Try again, please.'));
return;
}
if ($this->arg('upload')) { if ($this->arg('upload')) {
$this->uploadLogo(); $this->uploadLogo();
@ -323,7 +365,7 @@ class GrouplogoAction extends GroupAction
$this->deleteLogo(); $this->deleteLogo();
} else { } else {
// TRANS: Form validation error message when an unsupported argument is used. // TRANS: Form validation error message when an unsupported argument is used.
$this->showForm(_('Unexpected form submission.')); $this->setMessage(_('Unexpected form submission.'), true);
} }
} }
@ -335,20 +377,22 @@ class GrouplogoAction extends GroupAction
* *
* @return void * @return void
*/ */
function uploadLogo() public function uploadLogo()
{ {
try { try {
$imagefile = ImageFile::fromUpload('avatarfile'); $imagefile = ImageFile::fromUpload('avatarfile');
} catch (Exception $e) { } catch (Exception $e) {
$this->showForm($e->getMessage()); $this->setMessage($e->getMessage(), true);
return; return;
} }
$type = $imagefile->preferredType(); $type = $imagefile->preferredType();
$filename = Avatar::filename($this->group->id, $filename = Avatar::filename(
$this->group->id,
image_type_to_extension($type), image_type_to_extension($type),
null, null,
'group-temp-'.common_timestamp()); 'group-temp-' . common_timestamp()
);
$filepath = Avatar::path($filename); $filepath = Avatar::path($filename);
@ -367,16 +411,24 @@ class GrouplogoAction extends GroupAction
$this->mode = 'crop'; $this->mode = 'crop';
// TRANS: Form instructions on the group logo page. // TRANS: Form instructions on the group logo page.
$this->showForm(_('Pick a square area of the image to be the logo.'), $this->setMessage(_('Pick a square area of the image to be the logo.'));
true); }
public function setMessage($msg, $error = false)
{
$this->message = $msg;
$this->success = !$error;
} }
/** /**
* Handle the results of jcrop. * Handle the results of jcrop.
* *
* @return void * @return void
* @throws NoResultException
* @throws UnsupportedMediaException
* @throws UseFileAsThumbnailException
*/ */
function cropLogo() public function cropLogo()
{ {
$filedata = $_SESSION['FILEDATA']; $filedata = $_SESSION['FILEDATA'];
@ -398,8 +450,12 @@ class GrouplogoAction extends GroupAction
$profile = $this->group->getProfile(); $profile = $this->group->getProfile();
$imagefile = new ImageFile(null, $filedata['filepath']); $imagefile = new ImageFile(null, $filedata['filepath']);
$filename = Avatar::filename($profile->getID(), image_type_to_extension($imagefile->preferredType()), $filename = Avatar::filename(
$size, common_timestamp()); $profile->getID(),
image_type_to_extension($imagefile->preferredType()),
$size,
common_timestamp()
);
$imagefile->resizeTo(Avatar::path($filename), $box); $imagefile->resizeTo(Avatar::path($filename), $box);
@ -408,10 +464,10 @@ class GrouplogoAction extends GroupAction
unset($_SESSION['FILEDATA']); unset($_SESSION['FILEDATA']);
$this->mode = 'upload'; $this->mode = 'upload';
// TRANS: Form success message after updating a group logo. // TRANS: Form success message after updating a group logo.
$this->showForm(_('Logo updated.'), true); $this->setMessage(_('Logo updated.'));
} else { } else {
// TRANS: Form failure message after failing to update a group logo. // TRANS: Form failure message after failing to update a group logo.
$this->showForm(_('Failed updating logo.')); $this->setMessage(_('Failed updating logo.'), true);
} }
} }
@ -420,7 +476,7 @@ class GrouplogoAction extends GroupAction
* *
* @return void * @return void
*/ */
function deleteLogo() public function deleteLogo()
{ {
$orig = clone($this->group); $orig = clone($this->group);
Avatar::deleteFromProfile($this->group->getProfile()); Avatar::deleteFromProfile($this->group->getProfile());
@ -435,49 +491,6 @@ class GrouplogoAction extends GroupAction
$this->group->update($orig); $this->group->update($orig);
// TRANS: Success message for deleting the group logo. // TRANS: Success message for deleting the group logo.
$this->showForm(_('Logo deleted.')); $this->setMessage(_('Logo deleted.'));
}
function showPageNotice()
{
if ($this->msg) {
$this->element('div', ($this->success) ? 'success' : 'error',
$this->msg);
} else {
$inst = $this->getInstructions();
$output = common_markup_to_html($inst);
$this->elementStart('div', 'instructions');
$this->raw($output);
$this->elementEnd('div');
}
}
/**
* Add the jCrop stylesheet
*
* @return void
*/
function showStylesheets()
{
parent::showStylesheets();
$this->cssLink('js/extlib/jquery-jcrop/css/jcrop.css','base','screen, projection, tv');
}
/**
* Add the jCrop scripts
*
* @return void
*/
function showScripts()
{
parent::showScripts();
if ($this->mode == 'crop') {
$this->script('extlib/jquery-jcrop/jcrop.js');
$this->script('jcrop.go.js');
}
$this->autofocus('avatarfile');
} }
} }