1
0
mirror of https://github.com/moparisthebest/user_sql synced 2024-11-21 08:45:02 -05:00

Add possibility to invert value of active column

This commit is contained in:
Andreas Boehler 2015-05-27 22:01:51 +02:00
parent ef259e36bb
commit 4cd5cf7f7e
5 changed files with 22 additions and 10 deletions

View File

@ -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

View File

@ -1 +1 @@
1.3
1.4

View File

@ -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);

View File

@ -63,6 +63,7 @@ $cfgClass = $ocVersion >= 7 ? 'section' : 'personalblock';
</select></td>
</tr>
<tr><td><label for="sql_column_active"><?php echo $l -> t('User Active Column'); ?></label></td><td><input type="text" id="sql_column_active" name="sql_column_active" value="<?php echo $_['sql_column_active']; ?>" /></td></tr>
<tr><td><label for="sql_column_active_invert"><?php echo $l -> t('Invert Active Value'); ?></label></td><td><input type="text" id="sql_column_active_invert" name="sql_column_active_invert" value="<?php echo $_['sql_column_active_invert']; ?>" /></td></tr>
</table>
</fieldset>
<fieldset id="sql-3">

View File

@ -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);