mirror of
https://github.com/xevidos/codiad.git
synced 2024-11-10 21:26:35 +01:00
Updated update option function to support non user options.
This commit is contained in:
parent
4298962b14
commit
2307466e7b
@ -208,26 +208,48 @@ class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
public function update_option( $option, $value, $user_setting = null ) {
|
||||
public function update_option( $option, $value, $user_setting = true ) {
|
||||
|
||||
global $sql;
|
||||
$query = "INSERT INTO user_options ( name, username, value ) VALUES ( ?, ?, ? );";
|
||||
$bind_variables = array(
|
||||
$option,
|
||||
$this->username,
|
||||
$value,
|
||||
);
|
||||
$result = $sql->query( $query, $bind_variables, 0, "rowCount" );
|
||||
|
||||
if( $result == 0 ) {
|
||||
if( $user_setting == null ) {
|
||||
|
||||
$query = "UPDATE user_options SET value=? WHERE name=? AND username=?;";
|
||||
$query = "INSERT INTO options ( name, username, value ) VALUES ( ?, ? );";
|
||||
$bind_variables = array(
|
||||
$value,
|
||||
$option,
|
||||
$this->username,
|
||||
$value,
|
||||
);
|
||||
$result = $sql->query( $query, $bind_variables, 0, "rowCount" );
|
||||
|
||||
if( $result == 0 ) {
|
||||
|
||||
$query = "UPDATE options SET value=? WHERE name=?;";
|
||||
$bind_variables = array(
|
||||
$value,
|
||||
$option,
|
||||
);
|
||||
$result = $sql->query( $query, $bind_variables, 0, "rowCount" );
|
||||
}
|
||||
} else {
|
||||
|
||||
$query = "INSERT INTO user_options ( name, username, value ) VALUES ( ?, ?, ? );";
|
||||
$bind_variables = array(
|
||||
$option,
|
||||
$this->username,
|
||||
$value,
|
||||
);
|
||||
$result = $sql->query( $query, $bind_variables, 0, "rowCount" );
|
||||
|
||||
if( $result == 0 ) {
|
||||
|
||||
$query = "UPDATE user_options SET value=? WHERE name=? AND username=?;";
|
||||
$bind_variables = array(
|
||||
$value,
|
||||
$option,
|
||||
$this->username,
|
||||
);
|
||||
$result = $sql->query( $query, $bind_variables, 0, "rowCount" );
|
||||
}
|
||||
}
|
||||
|
||||
if( $result > 0 ) {
|
||||
|
Loading…
Reference in New Issue
Block a user