Abgebrochene Arbeit am IsValid flag
authorlseed <mail@joachim-breitner.de>
Thu, 25 Jun 2009 20:02:13 +0000 (22:02 +0200)
committerJoachim Breitner <mail@joachim-breitner.de>
Fri, 26 Jun 2009 08:44:05 +0000 (10:44 +0200)
web/js/communication.js
web/php/Controller.php
web/php/Database.php
web/php/Plant.php
web/setup/script00.sql

index 2e18914..9e6831d 100644 (file)
@@ -518,7 +518,7 @@ Lseed.Editor = function() {
        };
        
        this.Save = function(plant) {
-               
+               alert('Save');  
                communication.sendMessage(Lseed.MessageCommands.RPC, { 
                        func: 'SavePlant'
                        ,plant: plant.data.Name
index 7638696..36738c3 100644 (file)
@@ -79,6 +79,7 @@
                        }
                        
                        $res = "";
+                       error_log($func);
 
                        switch ($func) {
                                case "IsLoggedIn":
@@ -98,6 +99,7 @@
                                        break;
 
                                case "SavePlant":
+                                       error_log("Blubb");
                                        if ($plant != null) {
                                                $res = $plant->Save($code);
                                        } else {
index 19e5abe..7a23fb1 100644 (file)
                }
                public function InsertNewPlant($userid, $name, $code) {
                        $result = false;
+
+                       $plant = new Plant(0,$userid,$plantname,$code,this);
+                       $valid = $plant->IsValid();
                        
-                       $stmt = $this->m_Connection->prepare("INSERT INTO plant (UserID, Name, Code) VALUES (?, ?, ?)");
+                       $stmt = $this->m_Connection->prepare("INSERT INTO plant (UserID, Name, Code, Valid) VALUES (?, ?, ?, ?)");
                        
                        if ($stmt) {
-                               $stmt->bind_param("dss", $userid, $name, $code);
+                               $stmt->bind_param("dssi", $userid, $name, $code, $valid);
                                $stmt->execute();
                                
                                if ($stmt->affected_rows == 1) {
                public function UpdatePlant($plant) {
                        $result = false;
                        
-                       $stmt = $this->m_Connection->prepare("UPDATE plant SET Code=? WHERE ID=?");
-                       
+                       die($plant);
+
+                       $stmt = $this->m_Connection->prepare("UPDATE plant SET Code=?, Valid=? WHERE ID=?");
+
                        if ($stmt) {
-                               $stmt->bind_param("sd", $plant->Code, $plant->ID);
+                               $stmt->bind_param("sid", $plant->Code, $plant->IsValid(), $plant->ID);
                                $stmt->execute();
 
                                if ($stmt->affected_rows == 1) {
index 2fd5b28..ed5d8db 100644 (file)
                }
                
                public function Validate() {
-                       return $this->ValidateCode();
+                       $arr =  $this->ValidateCode();
+                       return $arr[1];
+               }
+
+               public function IsValid() {
+                       $arr =  $this->ValidateCode();
+                       return $arr[0];
                }
                
                public function ValidateCode() {
                        $result = "{valid: false, line: 0, column: 0, msg: 'Interner Server Fehler'}";
+                       $result_ok = 0;
                        
                        $descriptorspec = array(
                           0 => array("pipe", "r"),  // STDIN ist eine Pipe, von der das Child liest
                                //echo $return_value;
                                if ($return_value == 0) {
                                        $result = $output;
+                                       $result_ok = 1;
                                }
                        }
 
-                       return $result;
+                       return array($result_ok, $result);
                }
                
                public function Activate() {
index cfd1519..aee2584 100644 (file)
@@ -24,6 +24,7 @@ CREATE TABLE `plant` (
        `UserID` INT NOT NULL ,\r
        `Name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,\r
        `Code` VARCHAR( 2048 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,\r
+       `Valid` BOOL NOT NULL,\r
        INDEX ( `UserID` )\r
 ) ENGINE = MYISAM ;\r
 \r