Merge branch 'groupdesign' into 0.8.x

* groupdesign:
  Group theming.
  Add design_id to User_group
This commit is contained in:
Zach Copley 2009-06-18 02:02:43 -07:00
commit 2f36604ddf
13 changed files with 41 additions and 143 deletions

View File

@ -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;

View File

@ -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')) {
* @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()
{ {

View File

@ -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
$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');
} }

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -19,6 +19,7 @@ class User_group extends Memcached_DataObject
public $homepage_logo; // varchar(255) public $homepage_logo; // varchar(255)
public $stream_logo; // varchar(255) public $stream_logo; // varchar(255)
public $mini_logo; // varchar(255) public $mini_logo; // varchar(255)
public $design_id; // int(4)
public $created; // datetime() not_null public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
@ -239,4 +240,10 @@ class User_group extends Memcached_DataObject
} }
return null; return null;
} }
function getDesign()
{
return Design::staticGet('id', $this->design_id);
}
} }

View File

@ -468,6 +468,7 @@ original_logo = 2
homepage_logo = 2 homepage_logo = 2
stream_logo = 2 stream_logo = 2
mini_logo = 2 mini_logo = 2
design_id = 1
created = 142 created = 142
modified = 384 modified = 384

View File

@ -387,6 +387,7 @@ create table user_group (
homepage_logo varchar(255) comment 'homepage (profile) size logo', homepage_logo varchar(255) comment 'homepage (profile) size logo',
stream_logo varchar(255) comment 'stream-sized logo', stream_logo varchar(255) comment 'stream-sized logo',
mini_logo varchar(255) comment 'mini logo', mini_logo varchar(255) comment 'mini logo',
design_id integer comment 'id of a design' references design(id),
created datetime not null comment 'date this record was created', created datetime not null comment 'date this record was created',
modified timestamp comment 'date this record was modified', modified timestamp comment 'date this record was modified',

View File

@ -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' =>

View File

@ -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
'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
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
return; return;
} }
} }
$this->showForm(_('Design preferences saved.'), true);
} }
} }

View File

@ -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');
} }

View File

@ -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
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]+'));