diff --git a/CHANGELOG.md b/CHANGELOG.md
index d189cf9..b40801f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased]
+### Added
+- Reverse active column option
## [4.2.0] - 2018-12-16
### Added
diff --git a/README.md b/README.md
index 87061c4..65cfb89 100644
--- a/README.md
+++ b/README.md
@@ -50,6 +50,7 @@ Name | Description | Details
**Allow display name change** | With this option enabled user can change its display name. The display name change is propagated to the database. | Optional.
Default: false.
Requires: user *Display name* column.
**Allow password change** | Can user change its password. The password change is propagated to the database. See [Hash algorithms](#hash-algorithms). | Optional.
Default: false.
**Case-insensitive username** | Whether user query should be case-sensitive or case-insensitive. | Optional.
Default: false.
+**Reverse active column** | Reverse value of active column in user table. | Optional.
Default: false.
**Use cache** | Use database query results cache. The cache can be cleared any time with the *Clear cache* button click. | Optional.
Default: false.
**Hash algorithm** | How users passwords are stored in the database. See [Hash algorithms](#hash-algorithms). | Mandatory.
**Email sync** | Sync e-mail address with the Nextcloud.
- *None* - Disables this feature. This is the default option.
- *Synchronise only once* - Copy the e-mail address to the Nextcloud preferences if its not set.
- *Nextcloud always wins* - Always copy the e-mail address to the database. This updates the user table.
- *SQL always wins* - Always copy the e-mail address to the Nextcloud preferences. | Optional.
Default: *None*.
Requires: user *Email* column.
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 01f2a2a..ecb2963 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -22,7 +22,7 @@
auth
-
+
\OCA\UserSQL\Settings\Admin
diff --git a/lib/Constant/Opt.php b/lib/Constant/Opt.php
index 5093210..6cdc6c2 100644
--- a/lib/Constant/Opt.php
+++ b/lib/Constant/Opt.php
@@ -38,5 +38,6 @@ final class Opt
const PASSWORD_CHANGE = "opt.password_change";
const PREPEND_SALT = "opt.prepend_salt";
const QUOTA_SYNC = "opt.quota_sync";
+ const REVERSE_ACTIVE = "opt.reverse_active";
const USE_CACHE = "opt.use_cache";
}
diff --git a/lib/Query/QueryProvider.php b/lib/Query/QueryProvider.php
index cd027d0..03b1f5b 100644
--- a/lib/Query/QueryProvider.php
+++ b/lib/Query/QueryProvider.php
@@ -22,6 +22,7 @@
namespace OCA\UserSQL\Query;
use OCA\UserSQL\Constant\DB;
+use OCA\UserSQL\Constant\Opt;
use OCA\UserSQL\Constant\Query;
use OCA\UserSQL\Properties;
@@ -86,6 +87,8 @@ class QueryProvider implements \ArrayAccess
$searchParam = Query::SEARCH_PARAM;
$uidParam = Query::UID_PARAM;
+ $reverseActiveOpt = $this->properties[Opt::REVERSE_ACTIVE];
+
$groupColumns
= "$gGID AS gid, " .
(empty($gName) ? $gGID : $gName) . " AS name, " .
@@ -96,7 +99,7 @@ class QueryProvider implements \ArrayAccess
(empty($uEmail) ? "null" : $uEmail) . " AS email, " .
(empty($uQuota) ? "null" : $uQuota) . " AS quota, " .
(empty($uHome) ? "null" : $uHome) . " AS home, " .
- (empty($uActive) ? "true" : $uActive) . " AS active, " .
+ (empty($uActive) ? "true" : (empty($reverseActiveOpt) ? "" : "NOT ") . $uActive) . " AS active, " .
(empty($uAvatar) ? "false" : $uAvatar) . " AS avatar, " .
(empty($uSalt) ? "null" : $uSalt) . " AS salt";
diff --git a/templates/admin.php b/templates/admin.php
index c00b06e..0a5f042 100644
--- a/templates/admin.php
+++ b/templates/admin.php
@@ -110,7 +110,8 @@ function print_select_options(