From 2287f29c57e5af767fbc7407c5bfe8c7e32eee9f Mon Sep 17 00:00:00 2001 From: Samantha Doherty Date: Thu, 22 Sep 2011 09:27:36 -0400 Subject: [PATCH 01/11] Update RTL stylesheet for neo. --- theme/neo/css/rtl.css | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/theme/neo/css/rtl.css b/theme/neo/css/rtl.css index e677e7f6e6..f1187c64d1 100644 --- a/theme/neo/css/rtl.css +++ b/theme/neo/css/rtl.css @@ -85,6 +85,10 @@ address{ margin-left: 0; } +.notice p.entry-content { + float: left; +} + .threaded-replies .form_notice #notice_action-submit { right: 10px; } @@ -264,6 +268,29 @@ select { float: left; } +.profile .entity_profile .fn, .profile .entity_profile .label { + margin-right: 11px; + margin-left: 0; +} + +#core .vcard .photo { + float: right; +} + +.profile_list .label { + margin-right: 59px !important; +} + +.profile .entity_profile .note, .profile .entity_profile .url, .profile .entity_profile .entity_tags, .profile .entity_profile .form_subscription_edit { + margin-right: 59px; + margin-left: 0; +} + +.profile_list .entity_actions ul { + left: 20px; + right: auto; +} + /*#site_nav_local_views { float: right; } @@ -273,3 +300,4 @@ select { }*/ + From 4c91dc45469b1f60bacd015e3e4e4cb36cd90abe Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 22 Sep 2011 12:49:04 -0700 Subject: [PATCH 02/11] Use array_merge instead of array_replace (same effect, and array_merge works with PHP versions < 5.3) fixes http://status.net/open-source/issues/3393 --- lib/siteprofile.php | 8 ++++---- lib/statusnet.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/siteprofile.php b/lib/siteprofile.php index 51ce907b19..b5c6fc304c 100644 --- a/lib/siteprofile.php +++ b/lib/siteprofile.php @@ -90,7 +90,7 @@ class PublicSite extends SiteProfileSettings global $config; return array( // We only want to change these values, not replace entire 'site' array - 'site' => array_replace( + 'site' => array_merge( $config['site'], array( 'inviteonly' => false, 'private' => false, @@ -137,7 +137,7 @@ class PrivateSite extends SiteProfileSettings global $config; return array( // We only want to change these values, not replace entire 'site' array - 'site' => array_replace( + 'site' => array_merge( $config['site'], array( 'inviteonly' => true, 'private' => true, @@ -200,7 +200,7 @@ class CommunitySite extends SiteProfileSettings global $config; return array( // We only want to change these values, not replace entire 'site' array - 'site' => array_replace( + 'site' => array_merge( $config['site'], array( 'private' => false, 'closed' => false @@ -245,7 +245,7 @@ class SingleuserSite extends SiteProfileSettings return array( 'singleuser' => array('enabled' => true), // We only want to change these values, not replace entire 'site' array - 'site' => array_replace( + 'site' => array_merge( $config['site'], array( 'private' => false, 'closed' => true, diff --git a/lib/statusnet.php b/lib/statusnet.php index e4fb60ec7c..bffa625773 100644 --- a/lib/statusnet.php +++ b/lib/statusnet.php @@ -310,7 +310,7 @@ class StatusNet { global $config; $settings = SiteProfile::getSettings($name); - $config = array_replace($config, $settings); + $config = array_merge($config, $settings); } protected function _sn_to_path($sn) From 8fa816c32450c9bbe1a9c306835ad97e3eca5be6 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 22 Sep 2011 16:29:31 -0400 Subject: [PATCH 03/11] don't use potentially bad Profile values --- classes/Profile.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/Profile.php b/classes/Profile.php index f61803dcd0..7f45031f66 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -1420,14 +1420,18 @@ class Profile extends Managed_DataObject { $ids = array(); foreach ($profiles as $profile) { - $ids[] = $profile->id; + if (!empty($profile)) { + $ids[] = $profile->id; + } } $avatars = Avatar::pivotGet('profile_id', $ids, array('width' => $width, 'height' => $width)); foreach ($profiles as $profile) { - $profile->_fillAvatar($width, $avatars[$profile->id]); + if (!empty($profile)) { // ??? + $profile->_fillAvatar($width, $avatars[$profile->id]); + } } } From dba9d71abda39baafc0804afa8e4445eaa587c50 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 23 Sep 2011 17:18:21 -0400 Subject: [PATCH 04/11] Support mode in all --- actions/all.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/actions/all.php b/actions/all.php index a987ebbadb..bab59a7d03 100644 --- a/actions/all.php +++ b/actions/all.php @@ -1,7 +1,7 @@ user, Profile::current()); + $this->mode = $this->trimmed('mode', 'conversation'); + + if ($this->mode == 'stream') { + $stream = new InboxNoticeStream($this->user, Profile::current()); + } else { + $stream = new ThreadingInboxNoticeStream($this->user, Profile::current()); + } $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); @@ -176,7 +183,11 @@ class AllAction extends ProfileAction $profile = $current_user->getProfile(); } - $nl = new ThreadedNoticeList($this->notice, $this, $profile); + if ($this->mode == 'stream') { + $nl = new NoticeList($this->notice, $this); + } else { + $nl = new ThreadedNoticeList($this->notice, $this, $profile); + } $cnt = $nl->show(); From 66c97a1a1ee782b364ab68eed27193f3caf34965 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 23 Sep 2011 17:28:54 -0400 Subject: [PATCH 05/11] switch between conversation and stream for public and group --- actions/public.php | 15 +++++++++++++-- actions/showgroup.php | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/actions/public.php b/actions/public.php index 75217cb229..847aba666e 100644 --- a/actions/public.php +++ b/actions/public.php @@ -60,6 +60,7 @@ class PublicAction extends Action var $page = null; var $notice; var $userProfile = null; + var $mode = 'conversation'; function isReadOnly($args) { @@ -88,7 +89,13 @@ class PublicAction extends Action $this->userProfile = Profile::current(); - $stream = new ThreadingPublicNoticeStream($this->userProfile); + $this->mode = $this->trimmed('mode', 'conversation'); + + if ($this->mode == 'stream') { + $stream = new PublicNoticeStream($this->userProfile); + } else { + $stream = new ThreadingPublicNoticeStream($this->userProfile); + } $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); @@ -213,7 +220,11 @@ class PublicAction extends Action */ function showContent() { - $nl = new ThreadedNoticeList($this->notice, $this, $this->userProfile); + if ($this->mode == 'stream') { + $nl = new NoticeList($this->notice, $this); + } else { + $nl = new ThreadedNoticeList($this->notice, $this, $this->userProfile); + } $cnt = $nl->show(); diff --git a/actions/showgroup.php b/actions/showgroup.php index 9d4051bd89..5e1012e9d8 100644 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@ -50,6 +50,7 @@ class ShowgroupAction extends GroupAction var $page = null; var $userProfile = null; var $notice = null; + var $mode = 'conversation'; /** * Is this page read-only? @@ -97,10 +98,15 @@ class ShowgroupAction extends GroupAction $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + $this->mode = $this->trimmed('mode', 'conversation'); $this->userProfile = Profile::current(); - $stream = new ThreadingGroupNoticeStream($this->group, $this->userProfile); + if ($this->mode == 'stream') { + $stream = new GroupNoticeStream($this->group, $this->userProfile); + } else { + $stream = new ThreadingGroupNoticeStream($this->group, $this->userProfile); + } $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); @@ -140,7 +146,12 @@ class ShowgroupAction extends GroupAction */ function showGroupNotices() { - $nl = new ThreadedNoticeList($this->notice, $this, $this->userProfile); + if ($this->mode == 'stream') { + $nl = new NoticeList($this->notice, $this); + } else { + $nl = new ThreadedNoticeList($this->notice, $this, $this->userProfile); + } + $cnt = $nl->show(); $this->pagination($this->page > 1, From 02a30cf47cfe8054d6a93a35096c534d4cdb053d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 23 Sep 2011 17:50:38 -0400 Subject: [PATCH 06/11] start using stream mode prefs instead of separate parameter --- actions/all.php | 7 ++-- actions/public.php | 9 ++--- actions/showgroup.php | 11 ++++--- classes/Stream_mode_prefs.php | 62 +++++++++++++++++++++++++++++++++++ classes/User.php | 10 ++++++ 5 files changed, 86 insertions(+), 13 deletions(-) create mode 100644 classes/Stream_mode_prefs.php diff --git a/actions/all.php b/actions/all.php index bab59a7d03..e82f221b93 100644 --- a/actions/all.php +++ b/actions/all.php @@ -46,7 +46,6 @@ require_once INSTALLDIR.'/lib/feedlist.php'; class AllAction extends ProfileAction { var $notice; - var $mode = 'conversation'; function isReadOnly($args) { @@ -57,9 +56,9 @@ class AllAction extends ProfileAction { parent::prepare($args); - $this->mode = $this->trimmed('mode', 'conversation'); + $user = common_current_user(); - if ($this->mode == 'stream') { + if (!empty($user) && $user->useStreamMode()) { $stream = new InboxNoticeStream($this->user, Profile::current()); } else { $stream = new ThreadingInboxNoticeStream($this->user, Profile::current()); @@ -183,7 +182,7 @@ class AllAction extends ProfileAction $profile = $current_user->getProfile(); } - if ($this->mode == 'stream') { + if (!empty($current_user) && $current_user->showStreamMode()) { $nl = new NoticeList($this->notice, $this); } else { $nl = new ThreadedNoticeList($this->notice, $this, $profile); diff --git a/actions/public.php b/actions/public.php index 847aba666e..03f67e2e00 100644 --- a/actions/public.php +++ b/actions/public.php @@ -60,7 +60,6 @@ class PublicAction extends Action var $page = null; var $notice; var $userProfile = null; - var $mode = 'conversation'; function isReadOnly($args) { @@ -89,9 +88,9 @@ class PublicAction extends Action $this->userProfile = Profile::current(); - $this->mode = $this->trimmed('mode', 'conversation'); + $user = common_current_user(); - if ($this->mode == 'stream') { + if (!empty($user) && $user->useStreamMode()) { $stream = new PublicNoticeStream($this->userProfile); } else { $stream = new ThreadingPublicNoticeStream($this->userProfile); @@ -220,7 +219,9 @@ class PublicAction extends Action */ function showContent() { - if ($this->mode == 'stream') { + $user = common_current_user(); + + if (!empty($user) && $user->useStreamMode()) { $nl = new NoticeList($this->notice, $this); } else { $nl = new ThreadedNoticeList($this->notice, $this, $this->userProfile); diff --git a/actions/showgroup.php b/actions/showgroup.php index 5e1012e9d8..423551907e 100644 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@ -50,7 +50,6 @@ class ShowgroupAction extends GroupAction var $page = null; var $userProfile = null; var $notice = null; - var $mode = 'conversation'; /** * Is this page read-only? @@ -98,11 +97,11 @@ class ShowgroupAction extends GroupAction $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; - $this->mode = $this->trimmed('mode', 'conversation'); - $this->userProfile = Profile::current(); - if ($this->mode == 'stream') { + $user = common_current_user(); + + if (!empty($user) && $user->useStreamMode()) { $stream = new GroupNoticeStream($this->group, $this->userProfile); } else { $stream = new ThreadingGroupNoticeStream($this->group, $this->userProfile); @@ -146,7 +145,9 @@ class ShowgroupAction extends GroupAction */ function showGroupNotices() { - if ($this->mode == 'stream') { + $user = common_current_user(); + + if (!empty($user) && $user->useStreamMode()) { $nl = new NoticeList($this->notice, $this); } else { $nl = new ThreadedNoticeList($this->notice, $this, $this->userProfile); diff --git a/classes/Stream_mode_prefs.php b/classes/Stream_mode_prefs.php new file mode 100644 index 0000000000..ca15a9cb61 --- /dev/null +++ b/classes/Stream_mode_prefs.php @@ -0,0 +1,62 @@ +. + * + * @category UI + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Separate table for storing stream mode preferences + * + * @category UI + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class Stream_mode_prefs extends Managed_ +{ + /** + * Function comment + * + * @param + * + * @return + */ + + function Method() + { + } + +} diff --git a/classes/User.php b/classes/User.php index 7289a17b69..90e2277246 100644 --- a/classes/User.php +++ b/classes/User.php @@ -1145,4 +1145,14 @@ class User extends Managed_DataObject // TRANS: Subject for password recovery e-mail. mail_to_user($user, _('Password recovery requested'), $body, $headers, $confirm->address); } + + function showStreamMode() + { + $smp = Stream_mode_prefs::staticGet('user_id', $this->id); + if (!empty($smp)) { + return $smp->show_stream_mode; + } else { + return false; + } + } } From ddc121c085fd2b8aef5d724c15b0d3f5573a443b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 24 Sep 2011 07:12:34 -0400 Subject: [PATCH 07/11] New table for all old-school UI prefs --- actions/all.php | 4 +- actions/public.php | 4 +- actions/showgroup.php | 4 +- classes/Old_school_prefs.php | 88 +++++++++++++++++++++++++++++++++++ classes/Stream_mode_prefs.php | 62 ------------------------ classes/User.php | 28 +++++++++-- db/core.php | 1 + 7 files changed, 119 insertions(+), 72 deletions(-) create mode 100644 classes/Old_school_prefs.php delete mode 100644 classes/Stream_mode_prefs.php diff --git a/actions/all.php b/actions/all.php index e82f221b93..6e6dae5d16 100644 --- a/actions/all.php +++ b/actions/all.php @@ -58,7 +58,7 @@ class AllAction extends ProfileAction $user = common_current_user(); - if (!empty($user) && $user->useStreamMode()) { + if (!empty($user) && $user->streamModeOnly()) { $stream = new InboxNoticeStream($this->user, Profile::current()); } else { $stream = new ThreadingInboxNoticeStream($this->user, Profile::current()); @@ -182,7 +182,7 @@ class AllAction extends ProfileAction $profile = $current_user->getProfile(); } - if (!empty($current_user) && $current_user->showStreamMode()) { + if (!empty($current_user) && $current_user->streamModeOnly()) { $nl = new NoticeList($this->notice, $this); } else { $nl = new ThreadedNoticeList($this->notice, $this, $profile); diff --git a/actions/public.php b/actions/public.php index 03f67e2e00..cf732fe464 100644 --- a/actions/public.php +++ b/actions/public.php @@ -90,7 +90,7 @@ class PublicAction extends Action $user = common_current_user(); - if (!empty($user) && $user->useStreamMode()) { + if (!empty($user) && $user->streamModeOnly()) { $stream = new PublicNoticeStream($this->userProfile); } else { $stream = new ThreadingPublicNoticeStream($this->userProfile); @@ -221,7 +221,7 @@ class PublicAction extends Action { $user = common_current_user(); - if (!empty($user) && $user->useStreamMode()) { + if (!empty($user) && $user->streamModeOnly()) { $nl = new NoticeList($this->notice, $this); } else { $nl = new ThreadedNoticeList($this->notice, $this, $this->userProfile); diff --git a/actions/showgroup.php b/actions/showgroup.php index 423551907e..2449ea1db7 100644 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@ -101,7 +101,7 @@ class ShowgroupAction extends GroupAction $user = common_current_user(); - if (!empty($user) && $user->useStreamMode()) { + if (!empty($user) && $user->streamModeOnly()) { $stream = new GroupNoticeStream($this->group, $this->userProfile); } else { $stream = new ThreadingGroupNoticeStream($this->group, $this->userProfile); @@ -147,7 +147,7 @@ class ShowgroupAction extends GroupAction { $user = common_current_user(); - if (!empty($user) && $user->useStreamMode()) { + if (!empty($user) && $user->streamModeOnly()) { $nl = new NoticeList($this->notice, $this); } else { $nl = new ThreadedNoticeList($this->notice, $this, $this->userProfile); diff --git a/classes/Old_school_prefs.php b/classes/Old_school_prefs.php new file mode 100644 index 0000000000..29e13ddc74 --- /dev/null +++ b/classes/Old_school_prefs.php @@ -0,0 +1,88 @@ +. + * + * @category UI + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Separate table for storing UI preferences + * + * @category UI + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class Old_school_prefs extends Managed_DataObject +{ + public $__table = 'old_school_prefs'; // table name + public $user_id; + public $stream_mode_only; + public $conversation_tree; + public $stream_nicknames; + public $created; + public $modified; + + public static function schemaDef() + { + return array( + 'fields' => array( + 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user who has the preference'), + 'stream_mode_only' => array('type' => 'int', + 'size' => 'tiny', + 'default' => 1, + 'description' => 'No conversation streams'), + 'conversation_tree' => array('type' => 'int', + 'size' => 'tiny', + 'default' => 1, + 'description' => 'Hierarchical tree view for conversations'), + 'stream_nicknames' => array('type' => 'int', + 'size' => 'tiny', + 'default' => 1, + 'description' => 'Show nicknames for authors and addressees in streams'), + 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), + ), + 'primary key' => array('user_id'), + 'foreign keys' => array( + 'old_school_prefs_user_id_fkey' => array('user', array('user_id' => 'id')), + ), + ); + } + + function staticGet($k,$v=NULL) { + return Memcached_DataObject::staticGet('Old_school_prefs',$k,$v); + } +} diff --git a/classes/Stream_mode_prefs.php b/classes/Stream_mode_prefs.php deleted file mode 100644 index ca15a9cb61..0000000000 --- a/classes/Stream_mode_prefs.php +++ /dev/null @@ -1,62 +0,0 @@ -. - * - * @category UI - * @package StatusNet - * @author Evan Prodromou - * @copyright 2011 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 - * @link http://status.net/ - */ - -if (!defined('STATUSNET')) { - // This check helps protect against security problems; - // your code file can't be executed directly from the web. - exit(1); -} - -/** - * Separate table for storing stream mode preferences - * - * @category UI - * @package StatusNet - * @author Evan Prodromou - * @copyright 2011 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 - * @link http://status.net/ - */ - -class Stream_mode_prefs extends Managed_ -{ - /** - * Function comment - * - * @param - * - * @return - */ - - function Method() - { - } - -} diff --git a/classes/User.php b/classes/User.php index 90e2277246..2c84ac1995 100644 --- a/classes/User.php +++ b/classes/User.php @@ -1146,11 +1146,31 @@ class User extends Managed_DataObject mail_to_user($user, _('Password recovery requested'), $body, $headers, $confirm->address); } - function showStreamMode() + function streamModeOnly() { - $smp = Stream_mode_prefs::staticGet('user_id', $this->id); - if (!empty($smp)) { - return $smp->show_stream_mode; + $osp = Old_school_prefs::staticGet('user_id', $this->id); + if (!empty($osp)) { + return $osp->stream_mode_only; + } else { + return false; + } + } + + function conversationTree() + { + $osp = Old_school_prefs::staticGet('user_id', $this->id); + if (!empty($osp)) { + return $osp->conversation_tree; + } else { + return false; + } + } + + function streamNicknames() + { + $osp = Old_school_prefs::staticGet('user_id', $this->id); + if (!empty($osp)) { + return $osp->stream_nicknames; } else { return false; } diff --git a/db/core.php b/db/core.php index c484c8c785..b7881a7dc0 100644 --- a/db/core.php +++ b/db/core.php @@ -86,6 +86,7 @@ $classes = array('Profile', 'Local_group', 'User_urlshortener_prefs', 'Schema_version', + 'Old_school_prefs', ); foreach ($classes as $cls) { From 61a3ccf2bf83a05eab9e4877bd747de735a95c76 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 24 Sep 2011 07:19:52 -0400 Subject: [PATCH 08/11] users can choose to just see nicknames in streams --- lib/noticelistitem.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/noticelistitem.php b/lib/noticelistitem.php index 0231f3a57f..a8506aa46e 100644 --- a/lib/noticelistitem.php +++ b/lib/noticelistitem.php @@ -219,8 +219,14 @@ class NoticeListItem extends Widget $this->out->elementStart('a', $attrs); $this->showAvatar(); $this->out->text(' '); - $this->out->element('span',array('class' => 'fn'), - $this->profile->getBestName()); + $user = common_current_user(); + if (!empty($user) && $user->streamNicknames()) { + $this->out->element('span',array('class' => 'fn'), + $this->profile->nickname); + } else { + $this->out->element('span',array('class' => 'fn'), + $this->profile->getBestName()); + } $this->out->elementEnd('a'); $this->out->elementEnd('span'); @@ -262,11 +268,15 @@ class NoticeListItem extends Widget $groups = $this->getGroups(); + $user = common_current_user(); + + $streamNicknames = !empty($user) && $user->streamNicknames(); + foreach ($groups as $group) { $ga[] = array('href' => $group->homeUrl(), 'title' => $group->nickname, 'class' => 'addressee group', - 'text' => $group->getBestName()); + 'text' => ($streamNicknames) ? $group->nickname : $group->getBestName()); } return $ga; @@ -283,11 +293,15 @@ class NoticeListItem extends Widget $replies = $this->getReplyProfiles(); + $user = common_current_user(); + + $streamNicknames = !empty($user) && $user->streamNicknames(); + foreach ($replies as $reply) { $pa[] = array('href' => $reply->profileurl, 'title' => $reply->nickname, 'class' => 'addressee account', - 'text' => $reply->getBestName()); + 'text' => ($streamNicknames) ? $reply->nickname : $reply->getBestName()); } return $pa; From ae0b4d49c7931e51c480f17aaaa9b5f15fa8088d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 24 Sep 2011 09:29:12 -0400 Subject: [PATCH 09/11] optional conversation tree view --- actions/conversation.php | 11 +- lib/conversationtree.php | 215 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 224 insertions(+), 2 deletions(-) create mode 100644 lib/conversationtree.php diff --git a/actions/conversation.php b/actions/conversation.php index 637e86e4b2..aa2539d213 100644 --- a/actions/conversation.php +++ b/actions/conversation.php @@ -123,9 +123,15 @@ class ConversationAction extends Action */ function showContent() { - $tnl = new FullThreadedNoticeList($this->notices, $this, $this->userProfile); + $user = common_current_user(); - $cnt = $tnl->show(); + if (!empty($user) && $user->conversationTree()) { + $nl = new ConversationTree($this->notices, $this); + } else { + $nl = new FullThreadedNoticeList($this->notices, $this, $this->userProfile); + } + + $cnt = $nl->show(); } function isReadOnly() @@ -162,3 +168,4 @@ class ConversationAction extends Action _('Conversation feed (Activity Streams JSON)'))); } } + diff --git a/lib/conversationtree.php b/lib/conversationtree.php new file mode 100644 index 0000000000..49ed48af20 --- /dev/null +++ b/lib/conversationtree.php @@ -0,0 +1,215 @@ +. + * + * @category Widget + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Conversation tree + * + * The widget class for displaying a hierarchical list of notices. + * + * @category Widget + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + */ +class ConversationTree extends NoticeList +{ + var $tree = null; + var $table = null; + + /** + * Show the tree of notices + * + * @return void + */ + function show() + { + $cnt = $this->_buildTree(); + + $this->out->elementStart('div', array('id' =>'notices_primary')); + // TRANS: Header on conversation page. Hidden by default (h2). + $this->out->element('h2', null, _('Notices')); + $this->out->elementStart('ol', array('class' => 'notices xoxo')); + + if (array_key_exists('root', $this->tree)) { + $rootid = $this->tree['root'][0]; + $this->showNoticePlus($rootid); + } + + $this->out->elementEnd('ol'); + $this->out->elementEnd('div'); + + return $cnt; + } + + function _buildTree() + { + $cnt = 0; + + $this->tree = array(); + $this->table = array(); + + while ($this->notice->fetch()) { + + $cnt++; + + $id = $this->notice->id; + $notice = clone($this->notice); + + $this->table[$id] = $notice; + + if (is_null($notice->reply_to)) { + $this->tree['root'] = array($notice->id); + } else if (array_key_exists($notice->reply_to, $this->tree)) { + $this->tree[$notice->reply_to][] = $notice->id; + } else { + $this->tree[$notice->reply_to] = array($notice->id); + } + } + + return $cnt; + } + + /** + * Shows a notice plus its list of children. + * + * @param integer $id ID of the notice to show + * + * @return void + */ + function showNoticePlus($id) + { + $notice = $this->table[$id]; + + $this->out->elementStart('li', array('class' => 'hentry notice', + 'id' => 'notice-' . $id)); + + $item = $this->newListItem($notice); + $item->show(); + + if (array_key_exists($id, $this->tree)) { + $children = $this->tree[$id]; + + $this->out->elementStart('ol', array('class' => 'notices')); + + sort($children); + + foreach ($children as $child) { + $this->showNoticePlus($child); + } + + $this->out->elementEnd('ol'); + } + + $this->out->elementEnd('li'); + } + + /** + * Override parent class to return our preferred item. + * + * @param Notice $notice Notice to display + * + * @return NoticeListItem a list item to show + */ + function newListItem($notice) + { + return new ConversationTreeItem($notice, $this->out); + } +} + +/** + * Conversation tree list item + * + * Special class of NoticeListItem for use inside conversation trees. + * + * @category Widget + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + */ +class ConversationTreeItem extends NoticeListItem +{ + /** + * start a single notice. + * + * The default creates the
  • ; we skip, since the ConversationTree + * takes care of that. + * + * @return void + */ + function showStart() + { + return; + } + + /** + * finish the notice + * + * The default closes the
  • ; we skip, since the ConversationTree + * takes care of that. + * + * @return void + */ + function showEnd() + { + return; + } + + /** + * show link to notice conversation page + * + * Since we're only used on the conversation page, we skip this + * + * @return void + */ + function showContext() + { + return; + } + + /** + * show people this notice is in reply to + * + * Tree context shows this, so we skip it. + * + * @return void + */ + function showAddressees() + { + return; + } +} From ea1a11a0878fcd260e566d11fc4aa5aead96ed05 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 24 Sep 2011 09:46:13 -0400 Subject: [PATCH 10/11] site-wide option to enable old-school settings --- CONFIGURE | 9 +++++++++ classes/User.php | 35 ++++++++++++++++++++--------------- lib/default.php | 3 ++- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/CONFIGURE b/CONFIGURE index 285ccd11b3..c5fac78730 100644 --- a/CONFIGURE +++ b/CONFIGURE @@ -859,3 +859,12 @@ performance high: if you need high performance, or if you're seeing bad performance, set this to true. It will turn off some high-intensity code from the site. + +oldschool +--------- + +enabled: enable certain old-style user settings options, like stream-only mode, + conversation trees, and nicknames in streams. Off by default, and + may not be well supported in future versions. + + diff --git a/classes/User.php b/classes/User.php index 2c84ac1995..65bc0485bf 100644 --- a/classes/User.php +++ b/classes/User.php @@ -1148,31 +1148,36 @@ class User extends Managed_DataObject function streamModeOnly() { - $osp = Old_school_prefs::staticGet('user_id', $this->id); - if (!empty($osp)) { - return $osp->stream_mode_only; - } else { - return false; + if (common_config('oldschool', 'enabled')) { + $osp = Old_school_prefs::staticGet('user_id', $this->id); + if (!empty($osp)) { + return $osp->stream_mode_only; + } } + + return false; } function conversationTree() { - $osp = Old_school_prefs::staticGet('user_id', $this->id); - if (!empty($osp)) { - return $osp->conversation_tree; - } else { - return false; + if (common_config('oldschool', 'enabled')) { + $osp = Old_school_prefs::staticGet('user_id', $this->id); + if (!empty($osp)) { + return $osp->conversation_tree; + } } + + return false; } function streamNicknames() { - $osp = Old_school_prefs::staticGet('user_id', $this->id); - if (!empty($osp)) { - return $osp->stream_nicknames; - } else { - return false; + if (common_config('oldschool', 'enabled')) { + $osp = Old_school_prefs::staticGet('user_id', $this->id); + if (!empty($osp)) { + return $osp->stream_nicknames; + } } + return false; } } diff --git a/lib/default.php b/lib/default.php index 8748b64580..673c94769a 100644 --- a/lib/default.php +++ b/lib/default.php @@ -352,5 +352,6 @@ $default = array('cache' => true), // whether to cache the router object. Defaults to true, turn off for devel 'discovery' => array('cors' => false), // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.) - 'performance' => array('high' => false) // disable some features for higher performance; default false + 'performance' => array('high' => false), // disable some features for higher performance; default false + 'oldschool' => array('enabled' => false) // enable users to use old-style UI ); From 8e04dce94778d0a8df43802b3813481c58307897 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 24 Sep 2011 10:14:45 -0400 Subject: [PATCH 11/11] Old-school settings page A page to set or remove old-school settings. --- actions/oldschoolsettings.php | 228 ++++++++++++++++++++++++++++++++++ lib/router.php | 4 + lib/settingsnav.php | 9 ++ 3 files changed, 241 insertions(+) create mode 100644 actions/oldschoolsettings.php diff --git a/actions/oldschoolsettings.php b/actions/oldschoolsettings.php new file mode 100644 index 0000000000..74c6c05cda --- /dev/null +++ b/actions/oldschoolsettings.php @@ -0,0 +1,228 @@ +. + * + * @category Oldschool + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Old-school settings + * + * @category Oldschool + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class OldschoolsettingsAction extends SettingsAction +{ + /** + * Title of the page + * + * @return string Title of the page + */ + function title() + { + // TRANS: Page title for profile settings. + return _('Old school UI settings'); + } + + /** + * Instructions for use + * + * @return instructions for use + */ + function getInstructions() + { + // TRANS: Usage instructions for profile settings. + return _('If you like it "the old way", you can set that here.'); + } + + /** + * For initializing members of the class. + * + * @param array $argarray misc. arguments + * + * @return boolean true + */ + + function prepare($argarray) + { + if (!common_config('oldschool', 'enabled')) { + throw new ClientException("Old-school settings not enabled."); + } + parent::prepare($argarray); + return true; + } + + /** + * Handler method + * + * @param array $argarray is ignored since it's now passed in in prepare() + * + * @return void + */ + + function handlePost() + { + $user = common_current_user(); + + $osp = Old_school_prefs::staticGet('user_id', $user->id); + $orig = null; + + if (!empty($osp)) { + $orig = clone($osp); + } else { + $osp = new Old_school_prefs(); + $osp->user_id = $user->id; + $osp->created = common_sql_now(); + } + + $osp->stream_mode_only = $this->boolean('stream_mode_only'); + $osp->conversation_tree = $this->boolean('conversation_tree'); + $osp->stream_nicknames = $this->boolean('stream_nicknames'); + $osp->modified = common_sql_now(); + + if (!empty($orig)) { + $osp->update($orig); + } else { + $osp->insert(); + } + + // TRANS: Confirmation shown when user profile settings are saved. + $this->showForm(_('Settings saved.'), true); + + return; + } + + function showContent() + { + $user = common_current_user(); + $form = new OldSchoolForm($this, $user); + $form->show(); + } +} + +class OldSchoolForm extends Form +{ + var $user; + + function __construct($out, $user) + { + parent::__construct($out); + $this->user = $user; + } + + /** + * Visible or invisible data elements + * + * Display the form fields that make up the data of the form. + * Sub-classes should overload this to show their data. + * + * @return void + */ + + function formData() + { + $this->elementStart('fieldset'); + $this->elementStart('ul', 'form_data'); + $this->elementStart('li'); + $this->checkbox('stream_mode_only', _('Only stream mode (no conversations) in timelines'), + $this->user->streamModeOnly()); + $this->elementEnd('li'); + $this->elementStart('li'); + $this->checkbox('conversation_tree', _('Show conversation page as hierarchical trees'), + $this->user->conversationTree()); + $this->elementEnd('li'); + $this->elementStart('li'); + $this->checkbox('stream_nicknames', _('Show nicknames (not full names) in timelines'), + $this->user->streamNicknames()); + $this->elementEnd('li'); + $this->elementEnd('fieldset'); + $this->elementEnd('ul'); + } + + /** + * Buttons for form actions + * + * Submit and cancel buttons (or whatever) + * Sub-classes should overload this to show their own buttons. + * + * @return void + */ + + function formActions() + { + $this->submit('submit', _('Save')); + } + + /** + * ID of the form + * + * Should be unique on the page. Sub-classes should overload this + * to show their own IDs. + * + * @return int ID of the form + */ + + function id() + { + return 'form_oldschool'; + } + + /** + * Action of the form. + * + * URL to post to. Should be overloaded by subclasses to give + * somewhere to post to. + * + * @return string URL to post to + */ + + function action() + { + return common_local_url('oldschoolsettings'); + } + + /** + * Class of the form. May include space-separated list of multiple classes. + * + * @return string the form's class + */ + + function formClass() + { + return 'form_settings'; + } +} diff --git a/lib/router.php b/lib/router.php index 1fb5165621..b0124375de 100644 --- a/lib/router.php +++ b/lib/router.php @@ -184,6 +184,10 @@ class Router $m->connect('settings/'.$s, array('action' => $s.'settings')); } + if (common_config('oldschool', 'enabled')) { + $m->connect('settings/oldschool', array('action' => 'oldschoolsettings')); + } + $m->connect('settings/oauthapps/show/:id', array('action' => 'showapplication'), array('id' => '[0-9]+') diff --git a/lib/settingsnav.php b/lib/settingsnav.php index 67d5c35314..8b664fbae6 100644 --- a/lib/settingsnav.php +++ b/lib/settingsnav.php @@ -150,6 +150,15 @@ class SettingsNav extends Menu _('Authorized connected applications'), $actionName == 'oauthconnectionsettings'); + if (common_config('oldschool', 'enabled')) { + $this->action->menuItem(common_local_url('oldschoolsettings'), + // TRANS: Menu item in settings navigation panel. + _m('MENU','Old school'), + // TRANS: Menu item title in settings navigation panel. + _('UI tweaks for old-school users'), + $actionName == 'oldschoolsettings'); + } + Event::handle('EndConnectSettingsNav', array(&$this->action)); }