fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [8745]


From: Torstein
Subject: [Fmsystem-commits] [8745]
Date: Tue, 31 Jan 2012 18:54:27 +0000

Revision: 8745
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8745
Author:   vator
Date:     2012-01-31 18:54:27 +0000 (Tue, 31 Jan 2012)
Log Message:
-----------


Modified Paths:
--------------
    trunk/controller/inc/class.socontrol.inc.php
    trunk/controller/inc/class.uicontrol_location.inc.php
    trunk/controller/inc/model/class.control_location.inc.php

Modified: trunk/controller/inc/class.socontrol.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol.inc.php        2012-01-31 18:38:02 UTC 
(rev 8744)
+++ trunk/controller/inc/class.socontrol.inc.php        2012-01-31 18:54:27 UTC 
(rev 8745)
@@ -231,17 +231,22 @@
 
                function get_control_location($control_id, $location_code)
                {
-                       $sql =  "SELECT * FROM controller_control_location_list 
WHERE control_id = $control_id AND location_code=$location_code";
+                       $sql =  "SELECT * FROM controller_control_location_list 
WHERE control_id = $control_id AND location_code = '$location_code'";
                        
                        $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
-                       $this->db->next_record();
-
-                       $control_location = new 
controller_control_location($this->unmarshal($this->db->f('id', true), 'int'));
-
-                       
$control_location->set_location_code($this->unmarshal($this->db->f('location_code',
 true), 'string'));
-                       
$control_location->set_control_id($this->unmarshal($this->db->f('control_id', 
true), 'int'));
-                                               
-                       return $control_location
+                       
+                       if($this->db->next_record()){
+                               $control_location = new 
controller_control_location($this->unmarshal($this->db->f('id', true), 'int'));
+       
+                               
$control_location->set_location_code($this->unmarshal($this->db->f('location_code',
 true), 'string'));
+                               
$control_location->set_control_id($this->unmarshal($this->db->f('control_id', 
true), 'int'));
+                                                       
+                               return $control_location;
+                       }
+                       else
+                       {
+                               return null;
+                       }
                }
                
                function register_control_to_location($control_id, 
$location_code)

Modified: trunk/controller/inc/class.uicontrol_location.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_location.inc.php       2012-01-31 
18:38:02 UTC (rev 8744)
+++ trunk/controller/inc/class.uicontrol_location.inc.php       2012-01-31 
18:54:27 UTC (rev 8745)
@@ -371,8 +371,16 @@
                        $control_id = phpgw::get_var('control_id');
                        $location_code = phpgw::get_var('location_code');
                        
-                       $control_location_id = 
$this->so_control->register_control_to_location($control_id, $location_code);
+                       $control_location  = null;
+                       $control_location_id = 0;
                        
+                       $control_location = 
$this->so_control->get_control_location($control_id, $location_code);
+                       
+                       if($control_location == null ){
+                               
+                               $control_location_id = 
$this->so_control->register_control_to_location($control_id, $location_code);
+                       }
+                       
                        if($control_location_id > 0)
                                return json_encode( array( "status" => "saved" 
) );
                        else

Modified: trunk/controller/inc/model/class.control_location.inc.php
===================================================================
--- trunk/controller/inc/model/class.control_location.inc.php   2012-01-31 
18:38:02 UTC (rev 8744)
+++ trunk/controller/inc/model/class.control_location.inc.php   2012-01-31 
18:54:27 UTC (rev 8745)
@@ -31,9 +31,7 @@
        include_class('controller', 'model', 'inc/model/');
 
        class controller_control_location extends controller_model
-       {
-               public static $so;
-               
+       {               
                protected $id;
                protected $location_code;
                protected $control_id;
@@ -54,13 +52,8 @@
                        $this->id = $id;
                }
                
-               public function get_id() { return $this->id; }
+               public function get_id() { return (int)$this->id; }
                
-               public function set_title($title)
-               {
-                       $this->title = $title;
-               }
-               
                public function get_location_code() { return 
$this->location_code; }
                
                public function set_location_code($location_code)
@@ -68,10 +61,10 @@
                        $this->location_code = $location_code;
                }
                
-               public function get_control_id() { return $this->control_id; }
+               public function get_control_id() { return 
(int)$this->control_id; }
                
                public function set_control_id($control_id)
                {
-                       $this->control_id = $control_id;
+                       $this->control_id = (int)$control_id;
                }
        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]