logic that i understand..

This commit is contained in:
Hannes Mannerheim 2015-07-10 19:15:08 +02:00
parent 68e20d9ff1
commit 51cda6f1da

View File

@ -121,17 +121,30 @@ class QvitterPlugin extends Plugin {
{ {
// check if we should reroute UI to qvitter, and which home-stream the user wants (hide-replies or normal) // check if we should reroute UI to qvitter, and which home-stream the user wants (hide-replies or normal)
$scoped = Profile::current(); $scoped = Profile::current();
$qvitter_enabled_by_user = false; $qvitter_enabled_by_user = 0;
$qvitter_disabled_by_user = false; $qvitter_disabled_by_user = 0;
if ($scoped instanceof Profile) { if ($scoped instanceof Profile) {
$qvitter_enabled_by_user = (int)$scoped->getPref('qvitter', 'enable_qvitter', false); $qvitter_enabled_by_user = (int)$scoped->getPref('qvitter', 'enable_qvitter', false);
$qvitter_disabled_by_user = (int)$scoped->getPref('qvitter', 'disable_qvitter', false); $qvitter_disabled_by_user = (int)$scoped->getPref('qvitter', 'disable_qvitter', false);
$this->qvitter_hide_replies = $scoped->getPref('qvitter', 'hide_replies', false); $this->qvitter_hide_replies = $scoped->getPref('qvitter', 'hide_replies', false);
} }
$this->hijack_ui = (self::settings('enabledbydefault') && !$scoped) // reroute to qvitter if we're logged out and qvitter is enabled by default
|| (self::settings('enabledbydefault') && $qvitter_disabled_by_user == 0) if(self::settings('enabledbydefault') === true && !$scoped) {
|| (!self::settings('enabledbydefault') && $qvitter_enabled_by_user == 1); $this->hijack_ui = true;
}
// if we're logged in and qvitter is enabled by default, reroute if the user has not disabled qvitter
elseif(self::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(self::settings('enabledbydefault') === false && $qvitter_enabled_by_user == 1) {
$this->hijack_ui = true;
}
// otherwise we do not reroute
else {
$this->hijack_ui = false;
}
// show qvitter link in the admin panel // show qvitter link in the admin panel
common_config_append('admin', 'panels', 'qvitteradm'); common_config_append('admin', 'panels', 'qvitteradm');