mirror of
https://github.com/xevidos/codiad.git
synced 2024-11-11 05:36:34 +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;
|
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(
|
$bind_variables = array(
|
||||||
$value,
|
|
||||||
$option,
|
$option,
|
||||||
$this->username,
|
$value,
|
||||||
);
|
);
|
||||||
$result = $sql->query( $query, $bind_variables, 0, "rowCount" );
|
$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 ) {
|
if( $result > 0 ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user