We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 57274d21 authored by Zach Copley's avatar Zach Copley

Group theming.

parent dff43c03
...@@ -41,7 +41,7 @@ if (!defined('LACONICA')) { ...@@ -41,7 +41,7 @@ if (!defined('LACONICA')) {
* @link http://laconi.ca/ * @link http://laconi.ca/
*/ */
class BlockedfromgroupAction extends Action class BlockedfromgroupAction extends GroupDesignAction
{ {
var $page = null; var $page = null;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
* @package Laconica * @package Laconica
* @author Evan Prodromou <evan@controlyourself.ca> * @author Evan Prodromou <evan@controlyourself.ca>
* @author Sarven Capadisli <csarven@controlyourself.ca> * @author Sarven Capadisli <csarven@controlyourself.ca>
* @author Zach Copley <zach@controlyourself.ca>
* @copyright 2008-2009 Control Yourself, Inc. * @copyright 2008-2009 Control Yourself, Inc.
* @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://laconi.ca/ * @link http://laconi.ca/
...@@ -40,14 +41,15 @@ if (!defined('LACONICA')) { ...@@ -40,14 +41,15 @@ if (!defined('LACONICA')) {
* @category Group * @category Group
* @package Laconica * @package Laconica
* @author Evan Prodromou <evan@controlyourself.ca> * @author Evan Prodromou <evan@controlyourself.ca>
* @author Zach Copley <zach@controlyourself.ca>
* @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://laconi.ca/ * @link http://laconi.ca/
*/ */
class EditgroupAction extends Action class EditgroupAction extends GroupDesignAction
{ {
var $msg; var $msg;
var $group = null;
function title() function title()
{ {
......
...@@ -151,19 +151,17 @@ class GroupblockAction extends Action ...@@ -151,19 +151,17 @@ class GroupblockAction extends Action
function areYouSureForm() function areYouSureForm()
{ {
$id = $this->profile->id; $id = $this->profile->id;
$this->elementStart('form', array('id' => 'block-' . $id,
'method' => 'post',
'class' => 'form_settings form_entity_block',
'action' => common_local_url('groupblock')));
$this->elementStart('fieldset');
$this->hidden('token', common_session_token());
$this->element('legend', null, _('Block user'));
$this->element('p', null, $this->element('p', null,
sprintf(_('Are you sure you want to block user "%s" from the group "%s"? '. sprintf(_('Are you sure you want to block user "%s" from the group "%s"? '.
'They will be removed from the group, unable to post, and '. 'They will be removed from the group, unable to post, and '.
'unable to subscribe to the group in the future.'), 'unable to subscribe to the group in the future.'),
$this->profile->getBestName(), $this->profile->getBestName(),
$this->group->getBestName())); $this->group->getBestName()));
$this->elementStart('form', array('id' => 'block-' . $id,
'method' => 'post',
'class' => 'block',
'action' => common_local_url('groupblock')));
$this->hidden('token', common_session_token());
$this->hidden('blockto-' . $this->profile->id, $this->hidden('blockto-' . $this->profile->id,
$this->profile->id, $this->profile->id,
'blockto'); 'blockto');
...@@ -175,9 +173,8 @@ class GroupblockAction extends Action ...@@ -175,9 +173,8 @@ class GroupblockAction extends Action
$this->hidden($k, $v); $this->hidden($k, $v);
} }
} }
$this->submit('form_action-no', _('No'), 'submit form_action-primary', 'no', _("Do not block this user from this group")); $this->submit('no', _('No'));
$this->submit('form_action-yes', _('Yes'), 'submit form_action-secondary', 'yes', _('Block this user from this group')); $this->submit('yes', _('Yes'));
$this->elementEnd('fieldset');
$this->elementEnd('form'); $this->elementEnd('form');
} }
......
...@@ -50,7 +50,7 @@ define('MAX_ORIGINAL', 480); ...@@ -50,7 +50,7 @@ define('MAX_ORIGINAL', 480);
* @link http://laconi.ca/ * @link http://laconi.ca/
*/ */
class GrouplogoAction extends Action class GrouplogoAction extends GroupDesignAction
{ {
var $mode = null; var $mode = null;
var $imagefile = null; var $imagefile = null;
......
...@@ -44,7 +44,7 @@ require_once INSTALLDIR.'/lib/publicgroupnav.php'; ...@@ -44,7 +44,7 @@ require_once INSTALLDIR.'/lib/publicgroupnav.php';
* @link http://laconi.ca/ * @link http://laconi.ca/
*/ */
class GroupmembersAction extends Action class GroupmembersAction extends GroupDesignAction
{ {
var $page = null; var $page = null;
......
...@@ -47,10 +47,9 @@ define('MEMBERS_PER_SECTION', 27); ...@@ -47,10 +47,9 @@ define('MEMBERS_PER_SECTION', 27);
* @link http://laconi.ca/ * @link http://laconi.ca/
*/ */
class ShowgroupAction extends Action class ShowgroupAction extends GroupDesignAction
{ {
/** group we're viewing. */
var $group = null;
/** page we're viewing. */ /** page we're viewing. */
var $page = null; var $page = null;
......
...@@ -115,7 +115,7 @@ class AccountSettingsNav extends Widget ...@@ -115,7 +115,7 @@ class AccountSettingsNav extends Widget
'openidsettings' => 'openidsettings' =>
array(_('OpenID'), array(_('OpenID'),
_('Add or remove OpenIDs')), _('Add or remove OpenIDs')),
'designsettings' => 'userdesignsettings' =>
array(_('Design'), array(_('Design'),
_('Design your profile')), _('Design your profile')),
'othersettings' => 'othersettings' =>
......
...@@ -35,8 +35,11 @@ if (!defined('LACONICA')) { ...@@ -35,8 +35,11 @@ if (!defined('LACONICA')) {
require_once INSTALLDIR . '/lib/accountsettingsaction.php'; require_once INSTALLDIR . '/lib/accountsettingsaction.php';
require_once INSTALLDIR . '/lib/webcolor.php'; require_once INSTALLDIR . '/lib/webcolor.php';
class DesignsettingsAction extends AccountSettingsAction class DesignSettingsAction extends AccountSettingsAction
{ {
var $submitaction = null;
/** /**
* Title of the page * Title of the page
* *
...@@ -60,29 +63,14 @@ class DesignsettingsAction extends AccountSettingsAction ...@@ -60,29 +63,14 @@ class DesignsettingsAction extends AccountSettingsAction
'with a background image and a colour palette of your choice.'); 'with a background image and a colour palette of your choice.');
} }
/** function showDesignForm($design)
* Content area of the page
*
* Shows a form for changing the password
*
* @return void
*/
function showContent()
{ {
$user = common_current_user();
$design = $user->getDesign();
if (empty($design)) {
$design = $this->defaultDesign();
}
$this->elementStart('form', array('method' => 'post', $this->elementStart('form', array('method' => 'post',
'enctype' => 'multipart/form-data', 'enctype' => 'multipart/form-data',
'id' => 'form_settings_design', 'id' => 'form_settings_design',
'class' => 'form_settings', 'class' => 'form_settings',
'action' => 'action' => $this->submitaction));
common_local_url('designsettings')));
$this->elementStart('fieldset'); $this->elementStart('fieldset');
$this->hidden('token', common_session_token()); $this->hidden('token', common_session_token());
...@@ -370,108 +358,7 @@ class DesignsettingsAction extends AccountSettingsAction ...@@ -370,108 +358,7 @@ class DesignsettingsAction extends AccountSettingsAction
return $design; return $design;
} }
/** function saveBackgroundImage($design) {
* Save or update the user's design settings
*
* @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;
}
$onoff = $this->arg('design_background-image_onoff');
$on = false;
$off = false;
$tile = false;
if ($onoff == 'on') {
$on = true;
} else {
$off = true;
}
$repeat = $this->boolean('design_background-image_repeat');
if ($repeat) {
$tile = true;
}
$user = common_current_user();
$design = $user->getDesign();
if (!empty($design)) {
$original = clone($design);
$design->backgroundcolor = $bgcolor->intValue();
$design->contentcolor = $ccolor->intValue();
$design->sidebarcolor = $sbcolor->intValue();
$design->textcolor = $tcolor->intValue();
$design->linkcolor = $lcolor->intValue();
$design->backgroundimage = $filepath;
$design->setDisposition($on, $off, $tile);
$result = $design->update($original);
if ($result === false) {
common_log_db_error($design, 'UPDATE', __FILE__);
$this->showForm(_('Couldn\'t update your design.'));
return;
}
// update design
} else {
$user->query('BEGIN');
// save new design
$design = new Design();
$design->backgroundcolor = $bgcolor->intValue();
$design->contentcolor = $ccolor->intValue();
$design->sidebarcolor = $sbcolor->intValue();
$design->textcolor = $tcolor->intValue();
$design->linkcolor = $lcolor->intValue();
$design->backgroundimage = $filepath;
$design->setDisposition($on, $off, $tile);
$id = $design->insert();
if (empty($id)) {
common_log_db_error($id, 'INSERT', __FILE__);
$this->showForm(_('Unable to save your design settings!'));
return;
}
$original = clone($user);
$user->design_id = $id;
$result = $user->update($original);
if (empty($result)) {
common_log_db_error($original, 'UPDATE', __FILE__);
$this->showForm(_('Unable to save your design settings!'));
$user->query('ROLLBACK');
return;
}
$user->query('COMMIT');
}
// Now that we have a Design ID we can add a file to the design. // Now that we have a Design ID we can add a file to the design.
// XXX: This is an additional DB hit, but figured having the image // XXX: This is an additional DB hit, but figured having the image
...@@ -510,8 +397,6 @@ class DesignsettingsAction extends AccountSettingsAction ...@@ -510,8 +397,6 @@ class DesignsettingsAction extends AccountSettingsAction
return; return;
} }
} }
$this->showForm(_('Design preferences saved.'), true);
} }
} }
...@@ -113,6 +113,12 @@ class GroupNav extends Widget ...@@ -113,6 +113,12 @@ class GroupNav extends Widget
sprintf(_('Add or edit %s logo'), $nickname), sprintf(_('Add or edit %s logo'), $nickname),
$action_name == 'grouplogo', $action_name == 'grouplogo',
'nav_group_logo'); 'nav_group_logo');
$this->out->menuItem(common_local_url('groupdesignsettings', array('nickname' =>
$nickname)),
_('Design'),
sprintf(_('Add or edit %s design'), $nickname),
$action_name == 'groupdesignsettings',
'nav_group_design');
} }
$this->out->elementEnd('ul'); $this->out->elementEnd('ul');
} }
......
...@@ -132,7 +132,7 @@ class Router ...@@ -132,7 +132,7 @@ class Router
// settings // settings
foreach (array('profile', 'avatar', 'password', 'openid', 'im', foreach (array('profile', 'avatar', 'password', 'openid', 'im',
'email', 'sms', 'twitter', 'design', 'other') as $s) { 'email', 'sms', 'twitter', 'userdesign', 'other') as $s) {
$m->connect('settings/'.$s, array('action' => $s.'settings')); $m->connect('settings/'.$s, array('action' => $s.'settings'));
} }
...@@ -223,7 +223,7 @@ class Router ...@@ -223,7 +223,7 @@ class Router
array('nickname' => '[a-zA-Z0-9]+')); array('nickname' => '[a-zA-Z0-9]+'));
} }
foreach (array('members', 'logo', 'rss') as $n) { foreach (array('members', 'logo', 'rss', 'designsettings') as $n) {
$m->connect('group/:nickname/'.$n, $m->connect('group/:nickname/'.$n,
array('action' => 'group'.$n), array('action' => 'group'.$n),
array('nickname' => '[a-zA-Z0-9]+')); array('nickname' => '[a-zA-Z0-9]+'));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment