From d2ec0c08cc69d28e1a86aefa700abb99d9eb5feb Mon Sep 17 00:00:00 2001 From: Laurent Giovannoni <laurent.giovannoni@maarch.org> Date: Wed, 21 Dec 2011 17:36:51 +0000 Subject: [PATCH] MVC Actions --- core/trunk/core/class/ActionControler.php | 25 ++++++++++------- core/trunk/core/class/StatusControler.php | 33 ++++++++++++++++++++++- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/core/trunk/core/class/ActionControler.php b/core/trunk/core/class/ActionControler.php index dbd3098fd3b..05a5ec992cf 100644 --- a/core/trunk/core/class/ActionControler.php +++ b/core/trunk/core/class/ActionControler.php @@ -62,7 +62,7 @@ class ActionControler * Actions table */ public static $actions_table ; - + /** * Actions_groupbaskets_table table */ @@ -76,6 +76,7 @@ class ActionControler $db = new dbquery(); $db->connect(); self::$actions_table = $_SESSION['tablename']['actions']; + self::$actions_groupbaskets_table = $_SESSION['tablename']['bask_actions_groupbaskets']; self::$db=$db; } @@ -96,8 +97,10 @@ class ActionControler */ public function get($action_id) { - if(empty($action_id)) + + if(empty($action_id)) { return null; + } self::connect(); $query = "select * from ".self::$actions_table." where id = ".$action_id; @@ -136,14 +139,18 @@ class ActionControler */ public function save($action, $mode) { - if(!isset($action) ) + if(!isset($action)) { return false; - - if($mode == "up") - return self::update($action); - elseif($mode =="add") + } + if($mode == "up") { + //return self::update($action); + self::update($action); + return 'WTF !!!'; + + } + elseif($mode =="add"){ return self::insert($action); - + } return false; } @@ -260,7 +267,7 @@ class ActionControler $ok = false; } - self::disconnect(); + //self::disconnect(); return $ok; } diff --git a/core/trunk/core/class/StatusControler.php b/core/trunk/core/class/StatusControler.php index 9227d2b2d57..f1f23f321a7 100644 --- a/core/trunk/core/class/StatusControler.php +++ b/core/trunk/core/class/StatusControler.php @@ -386,4 +386,35 @@ class Maarch_Core_Class_StatusControler self::$db->disconnect(); return false; } -} \ No newline at end of file + + /** + * Return all status infos + * @return array of stauts + */ + public function getAllInfos() { + $db = new dbquery(); + $db->connect(); + $query = "select * from " . STATUS_TABLE . " "; + try { + if ($_ENV['DEBUG']) + echo $query . ' // '; + $db->query($query); + } catch (Exception $e) { + echo _NO_STATUS . ' // '; + } + if ($db->nb_result() > 0) { + $result = array (); + $cptId = 0; + while ($queryResult = $db->fetch_object()) { + $result[$cptId]['id'] = $queryResult->id; + $result[$cptId]['label'] = $queryResult->label_status; + $cptId++; + } + $db->disconnect(); + return $result; + } else { + $db->disconnect(); + return null; + } + } +} -- GitLab