diff --git a/ajax/settings.php b/ajax/settings.php index 1d8ea2e..763f48f 100644 --- a/ajax/settings.php +++ b/ajax/settings.php @@ -14,7 +14,8 @@ $l = new OC_L10N('user_sql'); $params = array('sql_host', 'sql_user', 'sql_database', 'sql_password', 'sql_table', 'sql_column_username', 'sql_column_password', 'sql_type', 'sql_column_active', 'strip_domain', 'default_domain', 'crypt_type', - 'sql_column_displayname', 'domain_settings', 'map_array', 'domain_array', 'allow_password_change'); + 'sql_column_displayname', 'domain_settings', 'map_array', 'domain_array', + 'allow_password_change', 'sql_column_active_invert'); if(isset($_POST['appname']) && $_POST['appname'] == "user_sql") { @@ -26,10 +27,14 @@ if(isset($_POST['appname']) && $_POST['appname'] == "user_sql") { OCP\Config::setAppValue('user_sql', 'strip_domain', true); } - elseif($param ==='allow_password_change') + elseif($param === 'allow_password_change') { OCP\Config::setAppValue('user_sql', 'allow_password_change', true); } + elseif($param === 'sql_column_active_invert') + { + OCP\Config::setAppValue('user_sql', 'sql_column_active_invert', true); + } else { OCP\Config::setAppValue('user_sql', $param, $_POST[$param]); @@ -44,6 +49,10 @@ if(isset($_POST['appname']) && $_POST['appname'] == "user_sql") { OCP\Config::setAppValue('user_sql', 'allow_password_change', false); } + elseif($param === 'sql_column_active_invert') + { + OCP\Config::setAppValue('user_sql', 'sql_column_active_invert', false); + } } } } else diff --git a/appinfo/version b/appinfo/version index 7e32cd5..c068b24 100644 --- a/appinfo/version +++ b/appinfo/version @@ -1 +1 @@ -1.3 +1.4 diff --git a/settings.php b/settings.php index ce46d72..55de344 100644 --- a/settings.php +++ b/settings.php @@ -22,7 +22,8 @@ */ $params = array('sql_host', 'sql_user', 'sql_database', 'sql_password', 'sql_table', 'sql_column_username', 'sql_column_password', 'sql_type', 'sql_column_active', - 'strip_domain', 'default_domain', 'crypt_type', 'sql_column_displayname', 'domain_map', 'domain_settings'); + 'strip_domain', 'default_domain', 'crypt_type', 'sql_column_displayname', + 'domain_map', 'domain_settings', 'sql_column_active_invert'); OCP\Util::addStyle('user_sql', 'settings'); OCP\Util::addScript('user_sql', 'settings'); @@ -54,6 +55,7 @@ $tmpl -> assign('map_array', OCP\Config::getAppValue('user_sql', 'map_array', '' $tmpl -> assign('domain_array', OCP\Config::getAppValue('user_sql', 'domain_array', '')); $tmpl -> assign('domain_settings', OCP\Config::getAppValue('user_sql', 'domain_settings', '')); $tmpl -> assign('allow_password_change', OCP\Config::getAppValue('user_sql', 'allow_password_change', 0)); +$tmpl -> assign('sql_column_active_invert', OCP\Config::getAppValue('user_sql', 'sql_column_active_invert', 0)); // workaround to detect OC version $ocVersion = @reset(OCP\Util::getVersion()); $tmpl -> assign('ocVersion', $ocVersion); diff --git a/templates/settings.php b/templates/settings.php index 2dee363..c37b072 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -63,6 +63,7 @@ $cfgClass = $ocVersion >= 7 ? 'section' : 'personalblock'; +
diff --git a/user_sql.php b/user_sql.php index c9ea7f8..a282fcd 100644 --- a/user_sql.php +++ b/user_sql.php @@ -38,6 +38,7 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface protected $sql_column_username; protected $sql_column_password; protected $sql_column_active; + protected $sql_column_active_invert; protected $sql_column_displayname; protected $sql_type; protected $db_conn; @@ -63,6 +64,7 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface $this -> sql_column_password = OCP\Config::getAppValue('user_sql', 'sql_column_password', ''); $this -> sql_column_displayname = OCP\Config::getAppValue('user_sql', 'sql_column_displayname', $this->sql_column_username); $this -> sql_column_active = OCP\Config::getAppValue('user_sql', 'sql_column_active', ''); + $this -> sql_column_active_invert = OCP\Config::getAppValue('user_sql', 'sql_column_active_invert', 0); $this -> sql_type = OCP\Config::getAppValue('user_sql', 'sql_type', ''); $this -> default_domain = OCP\Config::getAppValue('user_sql', 'default_domain', ''); $this -> strip_domain = OCP\Config::getAppValue('user_sql', 'strip_domain', 0); @@ -238,7 +240,7 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface $query = "SELECT $this->sql_column_username, $this->sql_column_password FROM $this->sql_table WHERE $this->sql_column_username = :uid"; if($this -> sql_column_active != '') - $query .= " AND $this->sql_column_active"; + $query .= " AND " .($this->sql_column_active_invert ? "NOT " : "" ).$this->sql_column_active; OC_Log::write('OC_USER_SQL', "Preparing query: $query", OC_Log::DEBUG); $result = $this -> db -> prepare($query); $result -> bindParam(":uid", $uid); @@ -317,9 +319,7 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface $query = "SELECT $this->sql_column_username FROM $this->sql_table"; $query .= " WHERE $this->sql_column_username LIKE :search"; if($this -> sql_column_active != '') - { - $query .= " AND $this->sql_column_active"; - } + $query .= " AND " .($this->sql_column_active_invert ? "NOT " : "" ).$this->sql_column_active; $query .= " ORDER BY $this->sql_column_username"; if($limit != null) { @@ -387,7 +387,7 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface $uid = $this -> doUserDomainMapping($uid); $query = "SELECT $this->sql_column_username FROM $this->sql_table WHERE $this->sql_column_username = :uid"; if($this -> sql_column_active != '') - $query .= " AND $this->sql_column_active"; + $query .= " AND " .($this->sql_column_active_invert ? "NOT " : "" ).$this->sql_column_active; OC_Log::write('OC_USER_SQL', "Preparing query: $query", OC_Log::DEBUG); $result = $this -> db -> prepare($query); $result -> bindParam(":uid", $uid); @@ -431,7 +431,7 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface $query = "SELECT $this->sql_column_displayname FROM $this->sql_table WHERE $this->sql_column_username = :uid"; if($this -> sql_column_active != '') - $query .= " AND $this->sql_column_active"; + $query .= " AND " .($this->sql_column_active_invert ? "NOT " : "" ).$this->sql_column_active; OC_Log::write('OC_USER_SQL', "Preparing query: $query", OC_Log::DEBUG); $result = $this -> db -> prepare($query); $result -> bindParam(":uid", $uid);