moving rerouting check from initialize() to onRouterInitialized()

This commit is contained in:
Hannes Mannerheim 2015-07-11 15:09:39 +02:00
parent 4d67a4534a
commit 37a30cbe5c
2 changed files with 24 additions and 1103 deletions

View File

@ -119,29 +119,6 @@ class QvitterPlugin extends Plugin {
public function initialize()
{
// check if we should reroute UI to qvitter, and which home-stream the user wants (hide-replies or normal)
$scoped = Profile::current();
$qvitter_enabled_by_user = 0;
$qvitter_disabled_by_user = 0;
if ($scoped instanceof Profile) {
$qvitter_enabled_by_user = (int)$scoped->getPref('qvitter', 'enable_qvitter', false);
$qvitter_disabled_by_user = (int)$scoped->getPref('qvitter', 'disable_qvitter', false);
$this->qvitter_hide_replies = $scoped->getPref('qvitter', 'hide_replies', false);
}
// reroute to qvitter if we're logged out and qvitter is enabled by default
if(static::settings('enabledbydefault') === true && is_null($scoped)) {
$this->hijack_ui = true;
}
// if we're logged in and qvitter is enabled by default, reroute if the user has not disabled qvitter
elseif(static::settings('enabledbydefault') === true && $qvitter_disabled_by_user == 0){
$this->hijack_ui = true;
}
// if we're logged in, and qvitter is _not_ enabled by default, reroute if the user enabled qvitter
elseif(static::settings('enabledbydefault') === false && $qvitter_enabled_by_user == 1) {
$this->hijack_ui = true;
}
// show qvitter link in the admin panel
common_config_append('admin', 'panels', 'qvitteradm');
}
@ -198,6 +175,30 @@ class QvitterPlugin extends Plugin {
array('action' => 'qvitterlogin'));
// check if we should reroute UI to qvitter, and which home-stream the user wants (hide-replies or normal)
$scoped = Profile::current();
$qvitter_enabled_by_user = 0;
$qvitter_disabled_by_user = 0;
if ($scoped instanceof Profile) {
$qvitter_enabled_by_user = (int)$scoped->getPref('qvitter', 'enable_qvitter', false);
$qvitter_disabled_by_user = (int)$scoped->getPref('qvitter', 'disable_qvitter', false);
$this->qvitter_hide_replies = $scoped->getPref('qvitter', 'hide_replies', false);
}
// reroute to qvitter if we're logged out and qvitter is enabled by default
if(static::settings('enabledbydefault') === true && is_null($scoped)) {
$this->hijack_ui = true;
}
// if we're logged in and qvitter is enabled by default, reroute if the user has not disabled qvitter
elseif(static::settings('enabledbydefault') === true && $qvitter_disabled_by_user == 0){
$this->hijack_ui = true;
}
// if we're logged in, and qvitter is _not_ enabled by default, reroute if the user enabled qvitter
elseif(static::settings('enabledbydefault') === false && $qvitter_enabled_by_user == 1) {
$this->hijack_ui = true;
}
if ($this->hijack_ui === true) {
$m->connect('', array('action' => 'qvitter'));
$m->connect('main/all', array('action' => 'qvitter'));

File diff suppressed because it is too large Load Diff