mirror of
https://github.com/moparisthebest/user_sql
synced 2024-11-21 16:55:02 -05:00
Add possibility to invert value of active column
This commit is contained in:
parent
ef259e36bb
commit
4cd5cf7f7e
@ -14,7 +14,8 @@ $l = new OC_L10N('user_sql');
|
|||||||
$params = array('sql_host', 'sql_user', 'sql_database', 'sql_password',
|
$params = array('sql_host', 'sql_user', 'sql_database', 'sql_password',
|
||||||
'sql_table', 'sql_column_username', 'sql_column_password', 'sql_type',
|
'sql_table', 'sql_column_username', 'sql_column_password', 'sql_type',
|
||||||
'sql_column_active', 'strip_domain', 'default_domain', 'crypt_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")
|
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);
|
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);
|
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
|
else
|
||||||
{
|
{
|
||||||
OCP\Config::setAppValue('user_sql', $param, $_POST[$param]);
|
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);
|
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
|
} else
|
||||||
|
@ -1 +1 @@
|
|||||||
1.3
|
1.4
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
$params = array('sql_host', 'sql_user', 'sql_database', 'sql_password', 'sql_table',
|
$params = array('sql_host', 'sql_user', 'sql_database', 'sql_password', 'sql_table',
|
||||||
'sql_column_username', 'sql_column_password', 'sql_type', 'sql_column_active',
|
'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::addStyle('user_sql', 'settings');
|
||||||
OCP\Util::addScript('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_array', OCP\Config::getAppValue('user_sql', 'domain_array', ''));
|
||||||
$tmpl -> assign('domain_settings', OCP\Config::getAppValue('user_sql', 'domain_settings', ''));
|
$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('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
|
// workaround to detect OC version
|
||||||
$ocVersion = @reset(OCP\Util::getVersion());
|
$ocVersion = @reset(OCP\Util::getVersion());
|
||||||
$tmpl -> assign('ocVersion', $ocVersion);
|
$tmpl -> assign('ocVersion', $ocVersion);
|
||||||
|
@ -63,6 +63,7 @@ $cfgClass = $ocVersion >= 7 ? 'section' : 'personalblock';
|
|||||||
</select></td>
|
</select></td>
|
||||||
</tr>
|
</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"><?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>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset id="sql-3">
|
<fieldset id="sql-3">
|
||||||
|
12
user_sql.php
12
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_username;
|
||||||
protected $sql_column_password;
|
protected $sql_column_password;
|
||||||
protected $sql_column_active;
|
protected $sql_column_active;
|
||||||
|
protected $sql_column_active_invert;
|
||||||
protected $sql_column_displayname;
|
protected $sql_column_displayname;
|
||||||
protected $sql_type;
|
protected $sql_type;
|
||||||
protected $db_conn;
|
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_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_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 = 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 -> sql_type = OCP\Config::getAppValue('user_sql', 'sql_type', '');
|
||||||
$this -> default_domain = OCP\Config::getAppValue('user_sql', 'default_domain', '');
|
$this -> default_domain = OCP\Config::getAppValue('user_sql', 'default_domain', '');
|
||||||
$this -> strip_domain = OCP\Config::getAppValue('user_sql', 'strip_domain', 0);
|
$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";
|
$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 != '')
|
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);
|
OC_Log::write('OC_USER_SQL', "Preparing query: $query", OC_Log::DEBUG);
|
||||||
$result = $this -> db -> prepare($query);
|
$result = $this -> db -> prepare($query);
|
||||||
$result -> bindParam(":uid", $uid);
|
$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 = "SELECT $this->sql_column_username FROM $this->sql_table";
|
||||||
$query .= " WHERE $this->sql_column_username LIKE :search";
|
$query .= " WHERE $this->sql_column_username LIKE :search";
|
||||||
if($this -> sql_column_active != '')
|
if($this -> sql_column_active != '')
|
||||||
{
|
$query .= " AND " .($this->sql_column_active_invert ? "NOT " : "" ).$this->sql_column_active;
|
||||||
$query .= " AND $this->sql_column_active";
|
|
||||||
}
|
|
||||||
$query .= " ORDER BY $this->sql_column_username";
|
$query .= " ORDER BY $this->sql_column_username";
|
||||||
if($limit != null)
|
if($limit != null)
|
||||||
{
|
{
|
||||||
@ -387,7 +387,7 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface
|
|||||||
$uid = $this -> doUserDomainMapping($uid);
|
$uid = $this -> doUserDomainMapping($uid);
|
||||||
$query = "SELECT $this->sql_column_username FROM $this->sql_table WHERE $this->sql_column_username = :uid";
|
$query = "SELECT $this->sql_column_username FROM $this->sql_table WHERE $this->sql_column_username = :uid";
|
||||||
if($this -> sql_column_active != '')
|
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);
|
OC_Log::write('OC_USER_SQL', "Preparing query: $query", OC_Log::DEBUG);
|
||||||
$result = $this -> db -> prepare($query);
|
$result = $this -> db -> prepare($query);
|
||||||
$result -> bindParam(":uid", $uid);
|
$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";
|
$query = "SELECT $this->sql_column_displayname FROM $this->sql_table WHERE $this->sql_column_username = :uid";
|
||||||
if($this -> sql_column_active != '')
|
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);
|
OC_Log::write('OC_USER_SQL', "Preparing query: $query", OC_Log::DEBUG);
|
||||||
$result = $this -> db -> prepare($query);
|
$result = $this -> db -> prepare($query);
|
||||||
$result -> bindParam(":uid", $uid);
|
$result -> bindParam(":uid", $uid);
|
||||||
|
Loading…
Reference in New Issue
Block a user