From cf2a4a79eb8344ab1c3303d4bdbb80c91d94925b Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Tue, 27 Dec 2011 01:36:09 +0100 Subject: Section's Styles are nowonlyavailable by a getter. Also fixed many MySQL Queries. These SELECT ... WHERE foo = (SELECT...) have not worked as expected, so now there are many ugly joins... --- ratatoeskr/backend.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'ratatoeskr/backend.php') diff --git a/ratatoeskr/backend.php b/ratatoeskr/backend.php index c5ae9c9..57d87f9 100644 --- a/ratatoeskr/backend.php +++ b/ratatoeskr/backend.php @@ -1095,8 +1095,8 @@ $backend_subactions = url_action_subactions(array( try { $section = Section::by_name($_GET["rmfrom"]); - $style = $_GET["rmstyle"]; - $section->styles = array_filter($section->styles, function($s) use ($style) { return $s->name != $style; }); + $style = Style::by_name($_GET["rmstyle"]); + $section->remove_style($style); $section->save(); $ste->vars["success"] = $translation["style_removed"]; } @@ -1175,11 +1175,7 @@ $backend_subactions = url_action_subactions(array( { $section = Section::by_name($_POST["section_select"]); $style = Style::by_name($_POST["style_to_add"]); - if(!in_array($style, $section->styles)) - { - $section->styles[] = $style; - $section->save(); - } + $section->add_style($style); $ste->vars["success"] = $translation["successfully_added_style"]; } catch(DoesNotExistError $e) @@ -1236,7 +1232,7 @@ $backend_subactions = url_action_subactions(array( "name" => $section->name, "title" => $titles, "template" => $section->template, - "styles" => array_map(function($style) { return $style->name; }, $section->styles), + "styles" => array_map(function($style) { return $style->name; }, $section->get_styles()), "default" => ($section->get_id() == $ratatoeskr_settings["default_section"]) ); }, $sections); -- cgit v1.2.3-54-g00ecf