From: Evan Prodromou Date: Fri, 23 Sep 2011 21:50:38 +0000 (-0400) Subject: start using stream mode prefs instead of separate parameter X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=02a30cf47cfe8054d6a93a35096c534d4cdb053d;p=quix0rs-gnu-social.git start using stream mode prefs instead of separate parameter --- 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; + } + } }