Skip to content

Commit

Permalink
let's extend a function a bit, we love reusability.
Browse files Browse the repository at this point in the history
Signed-off-by:Thorsten Eurich <thorsten@eurich.de>
  • Loading branch information
eurich committed Jun 30, 2013
1 parent 7499882 commit 62b855f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
12 changes: 1 addition & 11 deletions sources/admin/Themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,17 +361,7 @@ public function action_options()
elseif ($_POST['default_options_master'][$opt] == 1)
{
// Delete then insert for ease of database compatibility!
$db->query('substring', '
DELETE FROM {db_prefix}themes
WHERE id_theme = {int:default_theme}
AND id_member != {int:no_member}
AND variable = SUBSTRING({string:option}, 1, 255)',
array(
'default_theme' => 1,
'no_member' => 0,
'option' => $opt,
)
);
removeThemeOptions(true, false, $opt);
addThemeOptions(1, $opt, $val);

$old_settings[] = $opt;
Expand Down
11 changes: 8 additions & 3 deletions sources/subs/Themes.subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@ function countConfiguredMemberOptions()
/**
* Deletes all outdated options from the themes table
*
* @param bol $default_theme -> true is default, false for all custom themes
* @param bol $membergroups -> true is for members, false for guests
* @param bool $default_theme -> true is default, false for all custom themes
* @param bool $membergroups -> true is for members, false for guests
* @param array $old_settings
*/
function removeThemeOptions($default_theme, $membergroups, $old_settings)
Expand All @@ -449,12 +449,17 @@ function removeThemeOptions($default_theme, $membergroups, $old_settings)
$mem_param = array('operator' => '=', 'id' => -1);
else
$mem_param = array('operator' => '>', 'id' => 0);

if (is_array($old_settings))
$var = 'variable IN ({array_string:old_settings})';
else
$var = 'variable = {string:old_settings}';

$db->query('', '
DELETE FROM {db_prefix}themes
WHERE id_theme '. $default . ' {int:default_theme}
AND id_member ' . $mem_param['operator'] . ' {int:guest_member}
AND variable IN ({array_string:old_settings})',
AND ' . $var,
array(
'default_theme' => 1,
'guest_member' => $mem_param['id'],
Expand Down

0 comments on commit 62b855f

Please sign in to comment.