<?php
/**
- * Laconica, the distributed open-source microblogging tool
+ * StatusNet, the distributed open-source microblogging tool
*
- * Change user password
+ * Saves a design for a given group.
*
* PHP version 5
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Settings
- * @package Laconica
- * @author Sarven Capadisli <csarven@controlyourself.ca>
- * @author Zach Copley <zach@controlyourself.ca>
- * @copyright 2008-2009 Control Yourself, Inc.
+ * @package StatusNet
+ * @author Sarven Capadisli <csarven@status.net>
+ * @author Zach Copley <zach@status.net>
+ * @copyright 2008-2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://laconi.ca/
+ * @link http://status.net/
*/
-if (!defined('LACONICA')) {
+if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
* Saves a design for a given group
*
* @category Settings
- * @package Laconica
- * @author Zach Copley <zach@controlyourself.ca>
- * @author Sarven Capadisli <csarven@controlyourself.ca>
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @author Sarven Capadisli <csarven@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://laconi.ca/
+ * @link http://status.net/
*/
-
class GroupDesignSettingsAction extends DesignSettingsAction
{
var $group = null;
*
* @return boolean true
*/
-
function prepare($args)
{
parent::prepare($args);
- if (!common_config('inboxes', 'enabled')) {
- $this->serverError(_('Inboxes must be enabled for groups to work'));
- return false;
- }
-
if (!common_logged_in()) {
+ // TRANS: Client error displayed trying to change group design settings while not logged in.
$this->clientError(_('You must be logged in to edit a group.'));
return false;
}
}
if (!$nickname) {
- $this->clientError(_('No nickname'), 404);
+ // TRANS: Client error displayed trying to change group design settings without providing a group nickname.
+ $this->clientError(_('No nickname.'), 404);
return false;
}
if ($groupid) {
$this->group = User_group::staticGet('id', $groupid);
} else {
- $this->group = User_group::staticGet('nickname', $nickname);
+ $local = Local_group::staticGet('nickname', $nickname);
+ if ($local) {
+ $this->group = User_group::staticGet('id', $local->group_id);
+ }
}
if (!$this->group) {
- $this->clientError(_('No such group'), 404);
+ // TRANS: Client error displayed trying to change group design settings while providing a nickname for a non-existing group.
+ $this->clientError(_('No such group.'), 404);
return false;
}
$cur = common_current_user();
if (!$cur->isAdmin($this->group)) {
- $this->clientError(_('You must be an admin to edit the group'), 403);
+ // TRANS: Client error displayed trying to change group design settings without being a (group) admin.
+ $this->clientError(_('You must be an admin to edit the group.'), 403);
return false;
}
*
* @return Design a design object to use
*/
-
function getDesign()
{
function title()
{
+ // TRANS: Title group design settings page.
return _('Group design');
}
*
* @return instructions for use
*/
-
function getInstructions()
{
+ // TRANS: Instructions for group design settings page.
return _('Customize the way your group looks ' .
'with a background image and a colour palette of your choice.');
}
*
* @return nothing
*/
-
- function showLocalNav()
+ function showObjectNav()
{
$nav = new GroupNav($this, $this->group);
$nav->show();
}
+ /**
+ * Override to show default nav stuff
+ *
+ * @return nothing
+ */
+ function showLocalNav()
+ {
+ Action::showLocalNav();
+ }
+
/**
* Get the design we want to edit
*
* @return Design
*/
-
function getWorkingDesign()
{
-
$design = null;
if (isset($this->group)) {
$design = $this->group->getDesign();
}
- if (empty($design)) {
- $design = $this->defaultDesign();
- }
-
return $design;
}
*
* @return void
*/
-
function showContent()
{
- $this->showDesignForm($this->getWorkingDesign());
+ $design = $this->getWorkingDesign();
+
+ if (empty($design)) {
+ $design = Design::siteDesign();
+ }
+
+ $this->showDesignForm($design);
}
/**
*
* @return void
*/
-
function saveDesign()
{
try {
-
$bgcolor = new WebColor($this->trimmed('design_background'));
$ccolor = new WebColor($this->trimmed('design_content'));
$sbcolor = new WebColor($this->trimmed('design_sidebar'));
$tcolor = new WebColor($this->trimmed('design_text'));
$lcolor = new WebColor($this->trimmed('design_links'));
-
} catch (WebColorException $e) {
$this->showForm($e->getMessage());
return;
$design = $this->group->getDesign();
if (!empty($design)) {
-
// update design
$original = clone($design);
if ($result === false) {
common_log_db_error($design, 'UPDATE', __FILE__);
- $this->showForm(_('Couldn\'t update your design.'));
+ // TRANS: Form validation error displayed when group design settings could not be updated because of an application issue.
+ $this->showForm(_('Unable to update your design settings.'));
return;
}
-
} else {
-
$this->group->query('BEGIN');
// save new design
if (empty($id)) {
common_log_db_error($id, 'INSERT', __FILE__);
- $this->showForm(_('Unable to save your design settings!'));
+ // TRANS: Form validation error displayed when group design settings could not be saved because of an application issue.
+ $this->showForm(_('Unable to save your design settings.'));
return;
}
if (empty($result)) {
common_log_db_error($original, 'UPDATE', __FILE__);
- $this->showForm(_('Unable to save your design settings!'));
+ // TRANS: Form validation error displayed when group design settings could not be saved because of an application issue.
+ $this->showForm(_('Unable to save your design settings.'));
$this->group->query('ROLLBACK');
return;
}
$this->group->query('COMMIT');
-
}
$this->saveBackgroundImage($design);
+ // TRANS: Form text to confirm saved group design settings.
$this->showForm(_('Design preferences saved.'), true);
}
-
- /**
- * Handle input and output a page (overrided)
- *
- * @param array $args $_REQUEST arguments
- *
- * @return void
- */
-
- function handle($args)
- {
- parent::handle($args);
- if (!common_logged_in()) {
- $this->clientError(_('Not logged in.'));
- return;
- } else if (!common_is_real_login()) {
- // Cookie theft means that automatic logins can't
- // change important settings or see private info, and
- // _all_ our settings are important
- common_set_returnto($this->selfUrl());
- $user = common_current_user();
- if ($user->hasOpenID()) {
- common_redirect(common_local_url('openidlogin'), 303);
- } else {
- common_redirect(common_local_url('login'), 303);
- }
- } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- $this->handlePost();
- } else {
- $this->showForm();
- }
- }
-
}