[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [9869] controller: code formatting
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [9869] controller: code formatting |
Date: |
Thu, 16 Aug 2012 10:54:47 +0000 |
Revision: 9869
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9869
Author: sigurdne
Date: 2012-08-16 10:54:47 +0000 (Thu, 16 Aug 2012)
Log Message:
-----------
controller: code formatting
Modified Paths:
--------------
trunk/controller/inc/class.socase.inc.php
trunk/controller/inc/class.socheck_item.inc.php
trunk/controller/inc/class.socheck_list.inc.php
trunk/controller/inc/class.socommon.inc.php
trunk/controller/inc/class.socontrol.inc.php
trunk/controller/inc/class.socontrol_group.inc.php
trunk/controller/inc/class.socontrol_group_list.inc.php
trunk/controller/inc/class.socontrol_item.inc.php
trunk/controller/inc/class.socontrol_item_list.inc.php
trunk/controller/inc/class.socontrol_item_option.inc.php
trunk/controller/inc/class.sodocument.inc.php
trunk/controller/inc/class.soprocedure.inc.php
Modified: trunk/controller/inc/class.socase.inc.php
===================================================================
--- trunk/controller/inc/class.socase.inc.php 2012-08-16 08:57:41 UTC (rev
9868)
+++ trunk/controller/inc/class.socase.inc.php 2012-08-16 10:54:47 UTC (rev
9869)
@@ -43,7 +43,8 @@
*/
public static function get_instance()
{
- if (self::$so == null) {
+ if (self::$so == null)
+ {
self::$so = CreateObject('controller.socase');
}
return self::$so;
@@ -69,7 +70,8 @@
$this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
- if($this->db->next_record()) {
+ if($this->db->next_record())
+ {
$case = new
controller_check_item_case($this->unmarshal($this->db->f('id'), 'int'));
$case->set_check_item_id($this->unmarshal($this->db->f('check_item_id'),
'int'));
$case->set_status($this->unmarshal($this->db->f('status'), 'int'));
@@ -108,7 +110,8 @@
$this->db->query($sql);
- while ($this->db->next_record()) {
+ while ($this->db->next_record())
+ {
$case = new
controller_check_item_case($this->unmarshal($this->db->f('id'), 'int'));
$case->set_check_item_id($this->unmarshal($this->db->f('check_item_id'),
'int'));
$case->set_status($this->unmarshal($this->db->f('status'), 'int'));
@@ -122,9 +125,13 @@
$case->set_measurement($this->unmarshal($this->db->f('measurement'), 'string'));
if($return_type == "return_object")
+ {
$cases_array[] = $case;
+ }
else
+ {
$cases_array[] = $case->toArray();
+ }
}
return $cases_array;
@@ -166,7 +173,7 @@
$result = $this->db->query('INSERT INTO
controller_check_item_case (' . join(',', $cols) . ') VALUES (' . join(',',
$values) . ')', __LINE__,__FILE__);
- return isset($result) ?
$this->db->get_last_insert_id('controller_check_item_case', 'id') : 0;
+ return $result ?
$this->db->get_last_insert_id('controller_check_item_case', 'id') : 0;
}
/**
@@ -177,7 +184,7 @@
*/
function update($case)
{
- $id = $case->get_id();
+ $id = (int) $case->get_id();
$values = array(
'check_item_id = ' .
$this->marshal($case->get_check_item_id(), 'int'),
@@ -194,7 +201,7 @@
$result = $this->db->query('UPDATE
controller_check_item_case SET ' . join(',', $values) . " WHERE id=$id",
__LINE__,__FILE__);
- if( isset($result) )
+ if( $result )
{
return $id;
}
@@ -215,7 +222,7 @@
$case_id = (int) $case_id;
$status = $this->db->query("DELETE FROM
controller_check_item_case WHERE id = $case_id");
- if( isset($status) )
+ if( $status )
{
return true;
}
Modified: trunk/controller/inc/class.socheck_item.inc.php
===================================================================
--- trunk/controller/inc/class.socheck_item.inc.php 2012-08-16 08:57:41 UTC
(rev 9868)
+++ trunk/controller/inc/class.socheck_item.inc.php 2012-08-16 10:54:47 UTC
(rev 9869)
@@ -44,7 +44,8 @@
*/
public static function get_instance()
{
- if (self::$so == null) {
+ if (self::$so == null)
+ {
self::$so =
CreateObject('controller.socheck_item');
}
return self::$so;
@@ -70,7 +71,7 @@
$result = $this->db->query('INSERT INTO
controller_check_item (' . join(',', $cols) . ') VALUES (' . join(',', $values)
. ')', __LINE__,__FILE__);
- return isset($result) ?
$this->db->get_last_insert_id('controller_check_item', 'id') : 0;
+ return $result ?
$this->db->get_last_insert_id('controller_check_item', 'id') : 0;
}
/**
@@ -90,7 +91,7 @@
$result = $this->db->query('UPDATE
controller_check_item SET ' . join(',', $values) . " WHERE id=$id",
__LINE__,__FILE__);
- if( isset($result) )
+ if( $result )
{
return $id;
}
@@ -117,7 +118,8 @@
$this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
- if($this->db->next_record()) {
+ if($this->db->next_record())
+ {
$check_item = new
controller_check_item($this->unmarshal($this->db->f('c_id'), 'int'));
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id'),
'int'));
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id'),
'int'));
@@ -161,10 +163,10 @@
$counter = 0;
$check_item = null;
- while ($this->db->next_record()) {
-
- if( $counter == 0 ){
-
+ while ($this->db->next_record())
+ {
+ if( $counter == 0 )
+ {
$check_item = new
controller_check_item($this->unmarshal($this->db->f('ci_id'), 'int'));
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id'),
'int'));
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id'),
'int'));
@@ -178,14 +180,19 @@
$control_item->set_type($this->db->f('type', true), 'string');
if($return_type == "return_array")
+ {
$check_item->set_control_item($control_item->toArray());
+ }
else
+ {
$check_item->set_control_item($control_item);
+ }
$cases_array = array();
}
- if($this->db->f('cic_id') != ''){
+ if($this->db->f('cic_id'))
+ {
$case = new
controller_check_item_case($this->unmarshal($this->db->f('cic_id'), 'int'));
$case->set_check_item_id($this->unmarshal($this->db->f('check_item_id'),
'int'));
$case->set_status($this->unmarshal($this->db->f('cic_status'), 'int'));
@@ -199,23 +206,34 @@
if($return_type == "return_array")
+ {
$cases_array[] =
$case->toArray();
+ }
else
+ {
$cases_array[] = $case;
+ }
}
$check_item_id = $check_item->get_id();
$counter++;
}
- if($check_item != null){
+ if($check_item != null)
+ {
$check_item->set_cases_array($cases_array);
if($return_type == "return_array")
+ {
return $check_item->toArray();
+ }
else
+ {
return $check_item;
- }else{
+ }
+ }
+ else
+ {
return null;
}
}
@@ -240,7 +258,8 @@
$this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
- if($this->db->next_record()) {
+ if($this->db->next_record())
+ {
$check_item = new
controller_check_item($this->unmarshal($this->db->f('c_id'), 'int'));
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id'),
'int'));
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id'),
'int'));
@@ -329,22 +348,35 @@
$sql .= "WHERE ci.check_list_id = {$check_list_id} ";
if($status == 'open')
+ {
$sql .= "AND cic.status = 0 ";
+ }
else if($status == 'closed')
+ {
$sql .= "AND cic.status = 1 ";
+ }
else if($status == 'waiting')
+ {
$sql .= "AND cic.status = 2 ";
+ }
else if($status == 'open_or_waiting')
+ {
$sql .= "AND (cic.status = 0 OR cic.status = 2)
";
+ }
- if($type != null){
+ if($type != null)
+ {
$sql .= "AND coi.type = '$type' ";
}
if($messageStatus != null & $messageStatus ==
'no_message_registered')
+ {
$sql .= "AND cic.location_item_id IS NULL ";
+ }
else if($messageStatus != null & $messageStatus ==
'message_registered')
+ {
$sql .= "AND cic.location_item_id > 0 ";
+ }
$sql .= "ORDER BY ci.id";
@@ -352,17 +384,22 @@
$check_item_id = 0;
$check_item = null;
- while ($this->db->next_record()) {
-
- if( $this->db->f('ci_id', true) !=
$check_item_id ){
-
- if($check_item_id != 0){
+ while ($this->db->next_record())
+ {
+ if( $this->db->f('ci_id') != $check_item_id )
+ {
+ if($check_item_id)
+ {
$check_item->set_cases_array($cases_array);
if($return_type ==
"return_array")
+ {
$check_items_array[] =
$check_item->toArray();
+ }
else
+ {
$check_items_array[] =
$check_item;
+ }
}
$check_item = new
controller_check_item($this->unmarshal($this->db->f('ci_id'), 'int'));
@@ -378,14 +415,19 @@
$control_item->set_type($this->db->f('type', true), 'string');
if($return_type == "return_array")
+ {
$check_item->set_control_item($control_item->toArray());
+ }
else
+ {
$check_item->set_control_item($control_item);
+ }
$cases_array = array();
}
- if($this->db->f('cic_id', true) != ''){
+ if( $this->db->f('cic_id') )
+ {
$case = new
controller_check_item_case($this->unmarshal($this->db->f('cic_id'), 'int'));
$case->set_check_item_id($this->unmarshal($this->db->f('check_item_id'),
'int'));
$case->set_status($this->unmarshal($this->db->f('cic_status'), 'int'));
@@ -399,24 +441,34 @@
$case->set_measurement($this->unmarshal($this->db->f('measurement', true),
'string'));
if($return_type == "return_array")
+ {
$cases_array[] =
$case->toArray();
+ }
else
+ {
$cases_array[] = $case;
+ }
}
$check_item_id = $check_item->get_id();
}
- if($check_item != null){
+ if($check_item != null)
+ {
$check_item->set_cases_array($cases_array);
if($return_type == "return_array")
+ {
$check_items_array[] =
$check_item->toArray();
+ }
else
+ {
$check_items_array[] = $check_item;
-
+ }
return $check_items_array;
- }else {
+ }
+ else
+ {
return null;
}
}
@@ -444,17 +496,22 @@
$check_item_id = 0;
$check_item = null;
- while ($this->db->next_record()) {
-
- if( $this->db->f('ci_id', true) !=
$check_item_id ){
-
- if($check_item_id != 0){
+ while ($this->db->next_record())
+ {
+ if( $this->db->f('ci_id') != $check_item_id )
+ {
+ if($check_item_id)
+ {
$check_item->set_cases_array($cases_array);
if($return_type ==
"return_array")
+ {
$check_items_array[] =
$check_item->toArray();
+ }
else
+ {
$check_items_array[] =
$check_item;
+ }
}
$check_item = new
controller_check_item($this->unmarshal($this->db->f('ci_id'), 'int'));
@@ -470,14 +527,19 @@
$control_item->set_type($this->db->f('type', true), 'string');
if($return_type == "return_array")
+ {
$check_item->set_control_item($control_item->toArray());
+ }
else
+ {
$check_item->set_control_item($control_item);
+ }
$cases_array = array();
}
- if($this->db->f('cic_id') != ''){
+ if($this->db->f('cic_id'))
+ {
$case = new
controller_check_item_case($this->unmarshal($this->db->f('cic_id'), 'int'));
$case->set_status($this->unmarshal($this->db->f('cic_status'), 'int'));
$case->set_check_item_id($this->unmarshal($this->db->f('check_item_id'),
'int'));
@@ -491,24 +553,35 @@
if($return_type == "return_array")
+ {
$cases_array[] =
$case->toArray();
+ }
else
+ {
$cases_array[] = $case;
+ }
}
$check_item_id = $check_item->get_id();
}
- if($check_item != null){
+ if($check_item != null)
+ {
$check_item->set_cases_array($cases_array);
if($return_type == "return_array")
+ {
$check_items_array[] =
$check_item->toArray();
+ }
else
+ {
$check_items_array[] = $check_item;
+ }
return $check_items_array;
- }else {
+ }
+ else
+ {
return null;
}
}
Modified: trunk/controller/inc/class.socheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.socheck_list.inc.php 2012-08-16 08:57:41 UTC
(rev 9868)
+++ trunk/controller/inc/class.socheck_list.inc.php 2012-08-16 10:54:47 UTC
(rev 9869)
@@ -45,7 +45,8 @@
*/
public static function get_instance()
{
- if (self::$so == null) {
+ if (self::$so == null)
+ {
self::$so = CreateObject('controller.socheck_list');
}
return self::$so;
@@ -82,9 +83,12 @@
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases'),
'int'));
$check_list->set_num_pending_cases($this->unmarshal($this->db->f('num_pending_cases'),
'int'));
- if($check_list != null){
+ if($check_list != null)
+ {
return $check_list;
- }else {
+ }
+ else
+ {
return null;
}
}
@@ -110,19 +114,27 @@
$sql .= "WHERE cl.id = {$check_list_id} ";
if($status == 'open')
+ {
$sql .= "AND ci.status = 0 ";
+ }
else if($status == 'handled')
+ {
$sql .= "AND ci.status = 1 ";
+ }
if($type != null)
+ {
$sql .= "AND coi.type = '$type'";
-
+ }
+
$this->db->query($sql);
$counter = 0;
$check_list = null;
- while ($this->db->next_record()) {
- if($counter == 0){
+ while ($this->db->next_record())
+ {
+ if($counter == 0)
+ {
$check_list = new
controller_check_list($this->unmarshal($this->db->f('cl_id'), 'int'));
$check_list->set_status($this->unmarshal($this->db->f('cl_status'), 'bool'));
$check_list->set_control_id($this->unmarshal($this->db->f('control_id'),
'int'));
@@ -135,7 +147,8 @@
$check_list->set_num_pending_cases($this->unmarshal($this->db->f('num_pending_cases'),
'int'));
}
- if($this->db->f('ci_id') != ''){
+ if($this->db->f('ci_id'))
+ {
$check_item = new
controller_check_item($this->unmarshal($this->db->f('ci_id'), 'int'));
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id'),
'int'));
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id'),
'int'));
@@ -155,10 +168,13 @@
$counter++;
}
- if($check_list != null){
+ if($check_list != null)
+ {
$check_list->set_check_item_array($check_items_array);
return $check_list->toArray();
- }else {
+ }
+ else
+ {
return null;
}
}
@@ -185,9 +201,12 @@
$check_list_id = 0;
$check_list = null;
- while ($this->db->next_record()) {
- if( $this->db->f('cl_id') != $check_list_id ){
- if($check_list_id != 0){
+ while ($this->db->next_record())
+ {
+ if( $this->db->f('cl_id') != $check_list_id )
+ {
+ if( $check_list_id )
+ {
$check_list->set_check_item_array($check_items_array);
$check_list_array[] =
$check_list->toArray();
}
@@ -214,12 +233,15 @@
$check_list_id = $check_list->get_id();
}
- if($check_list != null){
+ if($check_list != null)
+ {
$check_list->set_check_item_array($check_items_array);
$check_list_array[] = $check_list->toArray();
return $check_list_array;
- }else {
+ }
+ else
+ {
return null;
}
}
@@ -259,11 +281,14 @@
$check_list_id = 0;
$check_list = null;
- while ($this->db->next_record()) {
+ while ($this->db->next_record())
+ {
- if( $this->db->f('cl_id') != $check_list_id ){
+ if( $this->db->f('cl_id') != $check_list_id )
+ {
- if($check_list_id != 0){
+ if($check_list_id)
+ {
$check_list_array[] = $check_list;
}
@@ -281,10 +306,13 @@
$check_list_id = $check_list->get_id();
}
- if($check_list != null){
+ if($check_list != null)
+ {
$check_list_array[] = $check_list;
return $check_list_array;
- }else {
+ }
+ else
+ {
return null;
}
}
@@ -314,9 +342,12 @@
$check_list_id = 0;
$check_list = null;
- while ($this->db->next_record()) {
- if( $this->db->f('cl_id') != $check_list_id ){
- if($check_list_id != 0){
+ while ($this->db->next_record())
+ {
+ if( $this->db->f('cl_id') != $check_list_id )
+ {
+ if($check_list_id)
+ {
$check_list_array[] = $check_list;
}
@@ -334,10 +365,13 @@
$check_list_id = $check_list->get_id();
}
- if($check_list != null){
+ if($check_list != null)
+ {
$check_list_array[] = $check_list;
return $check_list_array;
- }else {
+ }
+ else
+ {
return null;
}
}
@@ -367,10 +401,13 @@
$check_list_id = 0;
$check_list = null;
- while ($this->db->next_record()) {
+ while ($this->db->next_record())
+ {
- if( $this->db->f('cl_id') != $check_list_id ){
- if($check_list_id != 0){
+ if( $this->db->f('cl_id') != $check_list_id )
+ {
+ if($check_list_id)
+ {
$check_list_array[] = $check_list;
}
@@ -388,10 +425,13 @@
$check_list_id = $check_list->get_id();
}
- if($check_list != null){
+ if($check_list != null)
+ {
$check_list_array[] = $check_list;
return $check_list_array;
- }else {
+ }
+ else
+ {
return null;
}
}
@@ -404,15 +444,19 @@
* @param $to_date end time period
* @return array with check list objects
*/
- function get_num_open_cases_for_control( $cl_criteria, $from_date_ts,
$to_date_ts ){
+ function get_num_open_cases_for_control( $cl_criteria, $from_date_ts,
$to_date_ts )
+ {
$sql = "SELECT c.id as c_id, sum(cl.num_open_cases) as count ";
$sql .= "FROM controller_check_list cl, controller_control c ";
- if($cl_criteria->get_component_id() > 0 &&
$cl_criteria->get_location_id() > 0){
+ if($cl_criteria->get_component_id() > 0 &&
$cl_criteria->get_location_id() > 0)
+ {
$sql .= "WHERE cl.component_id =
{$cl_criteria->get_component_id()} ";
$sql .= "AND cl.location_id =
{$cl_criteria->get_location_id()} ";
- }else{
+ }
+ else
+ {
$sql .= "WHERE cl.location_code =
'{$cl_criteria->get_location_code()}' ";
}
@@ -423,11 +467,13 @@
$this->db->query($sql);
- if ($this->db->next_record() & $this->db->f('count') > 0) {
- $control_array = array(
- "id" =>
$this->unmarshal($this->db->f('c_id'), 'int'),
-
"count" => $this->db->f('count')
- );
+ if ($this->db->next_record() & $this->db->f('count') > 0)
+ {
+ $control_array = array
+ (
+ "id" =>
$this->unmarshal($this->db->f('c_id'), 'int'),
+ "count" => $this->db->f('count')
+ );
}
return $control_array;
@@ -442,7 +488,8 @@
* @param $repeat_type_expr repeat type expression
* @return array with check list objects
*/
- function get_check_lists_for_location( $location_code, $from_date_ts,
$to_date_ts, $repeat_type_expr = null ){
+ function get_check_lists_for_location( $location_code, $from_date_ts,
$to_date_ts, $repeat_type_expr = null )
+ {
$sql = "SELECT c.id as c_id, ";
$sql .= "cl.id as cl_id, cl.status as cl_status, cl.comment as
cl_comment, deadline, planned_date, completed_date, ";
$sql .= "cl.component_id as cl_component_id, cl.location_code
as cl_location_code, num_open_cases, num_pending_cases ";
@@ -451,7 +498,9 @@
$sql .= "WHERE cl.location_code = '{$location_code}' ";
if( $repeat_type != null )
+ {
$sql .= "AND c.repeat_type $repeat_type_expr ";
+ }
$sql .= "AND deadline BETWEEN $from_date_ts AND $to_date_ts ";
$sql .= "ORDER BY c.id;";
@@ -461,11 +510,12 @@
$control_id = 0;
$control = null;
$controls_array = array();
- while ($this->db->next_record()) {
-
- if( $this->db->f('c_id') != $control_id ){
-
- if($control_id != 0){
+ while ($this->db->next_record())
+ {
+ if( $this->db->f('c_id') != $control_id )
+ {
+ if($control_id)
+ {
$control->set_check_lists_array($check_lists_array);
$controls_array[] = $control;
}
@@ -491,7 +541,8 @@
$control_id = $control->get_id();
}
- if($control != null){
+ if($control != null)
+ {
$control->set_check_lists_array($check_lists_array);
$controls_array[] = $control;
}
@@ -522,7 +573,9 @@
$sql .= "AND cl.component_id = {$component_id} ";
if( $repeat_type != null )
+ {
$sql .= "AND c.repeat_type $repeat_type_expr ";
+ }
$sql .= "AND deadline BETWEEN $from_date_ts AND $to_date_ts ";
$sql .= "ORDER BY c.id;";
@@ -532,15 +585,16 @@
$control_id = 0;
$control = null;
$controls_array = array();
- while ($this->db->next_record()) {
-
- if( $this->db->f('c_id') != $control_id ){
-
- if($control_id != 0){
+ while ($this->db->next_record())
+ {
+ if( $this->db->f('c_id') != $control_id )
+ {
+ if($control_id != 0)
+ {
$control->set_check_lists_array($check_lists_array);
$controls_array[] = $control;
}
-
+
$control = new
controller_control($this->unmarshal($this->db->f('c_id'), 'int'));
$check_lists_array = array();
@@ -563,7 +617,8 @@
$control_id = $control->get_id();
}
- if($control != null){
+ if($control != null)
+ {
$control->set_check_lists_array($check_lists_array);
$controls_array[] = $control;
}
@@ -593,13 +648,16 @@
$sql .= "AND cl.location_code = '{$location_code}' ";
if( $repeat_type != null )
+ {
$sql .= "AND c.repeat_type = $repeat_type ";
+ }
$sql .= "AND deadline BETWEEN $from_date_ts AND $to_date_ts ";
$this->db->query($sql);
- while ($this->db->next_record()) {
+ while ($this->db->next_record())
+ {
$check_list = new
controller_check_list($this->unmarshal($this->db->f('cl_id'), 'int'));
$check_list->set_status($this->unmarshal($this->db->f('cl_status'), 'int'));
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true),
'string'));
@@ -642,13 +700,16 @@
$sql .= "AND cl.location_id = {$location_id} ";
if( $repeat_type != null )
+ {
$sql .= "AND c.repeat_type = $repeat_type ";
+ }
$sql .= "AND deadline BETWEEN $from_date_ts AND $to_date_ts ";
$this->db->query($sql);
- while ($this->db->next_record()) {
+ while ($this->db->next_record())
+ {
$check_list = new
controller_check_list($this->unmarshal($this->db->f('cl_id'), 'int'));
$check_list->set_status($this->unmarshal($this->db->f('cl_status'), 'int'));
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true),
'string'));
@@ -717,7 +778,8 @@
$search_for = $this->marshal($search_for,'field');
$like_pattern = "'%".$search_for."%'";
$like_clauses = array();
- switch($search_type){
+ switch($search_type)
+ {
default:
$like_clauses[] = "p.title $this->like
$like_pattern";
break;
@@ -764,7 +826,8 @@
function populate(int $control_id, &$control)
{
- if($control == null) {
+ if($control == null)
+ {
$start_date = date("d.m.Y",
$this->db->f('start_date'));
$end_date = date("d.m.Y", $this->db->f('end_date'));
$control = new controller_control((int) $control_id);
@@ -846,7 +909,7 @@
$result = $this->db->query('UPDATE controller_check_list SET '
. join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
- if(isset($result))
+ if($result)
{
return $id;
}
Modified: trunk/controller/inc/class.socommon.inc.php
===================================================================
--- trunk/controller/inc/class.socommon.inc.php 2012-08-16 08:57:41 UTC (rev
9868)
+++ trunk/controller/inc/class.socommon.inc.php 2012-08-16 10:54:47 UTC (rev
9869)
@@ -160,7 +160,8 @@
/**
* Method for retrieving the db-object (security "forgotten")
*/
- public function get_db(){
+ public function get_db()
+ {
return $this->db;
}
@@ -347,8 +348,10 @@
public function store(&$object)
{
- if ($object->validates()) {
- if ($object->get_id() > 0) {
+ if ($object->validates())
+ {
+ if ($object->get_id() > 0)
+ {
// We can assume this composite came
from the database since it has an ID. Update the existing row
return $this->update($object);
}
@@ -362,5 +365,4 @@
// The object did not validate
return false;
}
-
}
Modified: trunk/controller/inc/class.socontrol.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol.inc.php 2012-08-16 08:57:41 UTC
(rev 9868)
+++ trunk/controller/inc/class.socontrol.inc.php 2012-08-16 10:54:47 UTC
(rev 9869)
@@ -36,7 +36,7 @@
class controller_socontrol extends controller_socommon
{
- protected static $so;
+ protected static $so;
/**
* Get a static reference to the storage object associated with
this model object
@@ -45,7 +45,8 @@
*/
public static function get_instance()
{
- if (self::$so == null) {
+ if (self::$so == null)
+ {
self::$so =
CreateObject('controller.socontrol');
}
return self::$so;
@@ -63,7 +64,8 @@
$sql = "INSERT INTO controller_control (title) VALUES
('$title')";
$result = $this->db->query($sql, __LINE__,__FILE__);
- if(isset($result)) {
+ if($result)
+ {
// Set the new control ID
$control->set_id($this->db->get_last_insert_id('controller_control', 'id'));
@@ -85,7 +87,6 @@
*/
function update($control)
{
-
$id = intval($control->get_id());
$values = array(
@@ -102,9 +103,12 @@
$result = $this->db->query('UPDATE controller_control
SET ' . join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
- if( isset($result) ){
+ if( $result )
+ {
return $id;
- }else{
+ }
+ else
+ {
return 0;
}
}
@@ -133,16 +137,22 @@
$sql .= "WHERE cll.location_code = '$location_code' ";
if( is_numeric($repeat_type) )
+ {
$sql .= "AND c.repeat_type = $repeat_type ";
+ }
+
if( is_numeric($role_id))
+ {
$sql .= "AND c.responsibility_id = $role_id ";
+ }
$sql .= "AND (c.start_date <= $from_date AND c.end_date
IS NULL ";
$sql .= "OR c.start_date > $from_date AND c.start_date
< $to_date)";
$this->db->query($sql);
- while($this->db->next_record()) {
+ while($this->db->next_record())
+ {
$control = new
controller_control($this->unmarshal($this->db->f('id'), 'int'));
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
$control->set_description($this->unmarshal($this->db->f('description', true),
'string'));
@@ -159,15 +169,21 @@
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval'),
'int'));
if($return_type == "return_object")
+ {
$controls_array[] = $control;
+ }
else
+ {
$controls_array[] = $control->toArray();
+ }
}
- if( count( $controls_array ) > 0 ){
+ if( count( $controls_array ) > 0 )
+ {
return $controls_array;
}
- else {
+ else
+ {
return null;
}
}
@@ -197,16 +213,21 @@
$sql .= "WHERE fm_bim_item.loc1 = '$location_code' ";
if( is_numeric($repeat_type) )
+ {
$sql .= "AND c.repeat_type = $repeat_type ";
+ }
if( is_numeric($role_id))
+ {
$sql .= "AND c.responsibility_id = $role_id ";
+ }
$sql .= "AND (c.start_date <= $from_date AND c.end_date
IS NULL ";
$sql .= "OR c.end_date > $from_date AND c.start_date <
$to_date)";
$this->db->query($sql);
- while($this->db->next_record()) {
+ while($this->db->next_record())
+ {
$control = new
controller_control($this->unmarshal($this->db->f('id'), 'int'));
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
$control->set_description($this->unmarshal($this->db->f('description', true),
'string'));
@@ -226,14 +247,21 @@
$control->set_component_id($this->unmarshal($this->db->f('component_id'),
'int'));
//
if($return_type == "return_object")
+ {
$controls_array[] = $control;
+ }
else
+ {
$controls_array[] = $control->toArray();
+ }
}
- if( count( $controls_array ) > 0 ){
+ if( count( $controls_array ) > 0 )
+ {
return $controls_array;
- }else {
+ }
+ else
+ {
return null;
}
}
@@ -431,24 +459,29 @@
$this->db->query($sql);
- while($this->db->next_record()) {
+ while($this->db->next_record())
+ {
$control_id =
$this->unmarshal($this->db->f('id'), 'int');
$title = $this->unmarshal($this->db->f('title',
true), 'string');
$location_code =
$this->unmarshal($this->db->f('location_code', true), 'string');
$location_array =
execMethod('property.bolocation.read_single', array('location_code' =>
$location_code));
- $controls_array[] = array(
-
"id" =>
$control_id,
-
"title" =>
$title,
-
"location_code"
=> $location_code,
-
"loc1_name" =>
$location_array["loc1_name"]
-
);
+ $controls_array[] = array
+ (
+ "id" => $control_id,
+ "title" => $title,
+ "location_code" => $location_code,
+ "loc1_name" =>
$location_array["loc1_name"]
+ );
}
- if( count( $controls_array ) > 0 ){
+ if( count( $controls_array ) > 0 )
+ {
return $controls_array;
- }else {
+ }
+ else
+ {
return null;
}
}
@@ -474,7 +507,8 @@
$this->db->query($sql);
- while($this->db->next_record()) {
+ while($this->db->next_record())
+ {
$component = new controller_component();
$component->set_type($this->unmarshal($this->db->f('type'), 'int'));
$component->set_id($this->unmarshal($this->db->f('component_id'), 'int'));
@@ -489,7 +523,8 @@
$components_array[] = $component;
}
- if( count( $components_array ) > 0 ){
+ if( count( $components_array ) > 0 )
+ {
return $components_array;
}
else
@@ -515,7 +550,8 @@
$this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
- if($this->db->next_record()){
+ if($this->db->next_record())
+ {
$control_location = new
controller_control_location($this->unmarshal($this->db->f('id'), 'int'));
$control_location->set_location_code($this->unmarshal($this->db->f('location_code',
true), 'string'));
@@ -715,7 +751,8 @@
$search_for =
$this->marshal($search_for,'field');
$like_pattern = "'%".$search_for."%'";
$like_clauses = array();
- switch($search_type){
+ switch($search_type)
+ {
default:
$like_clauses[] =
"controller_control.title $this->like $like_pattern";
$like_clauses[] =
"controller_control.description $this->like $like_pattern";
@@ -779,7 +816,8 @@
function populate(int $control_id, &$control)
{
- if($control == null) {
+ if($control == null)
+ {
$control = new controller_control((int)
$control_id);
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
@@ -867,9 +905,13 @@
if($ifc != null)
{
if($ifc == 1)
+ {
$where_clause = "WHERE is_ifc";
+ }
else
+ {
$where_clause = "WHERE NOT is_ifc";
+ }
}
$sql = "select * from fm_bim_type {$where_clause} ORDER
BY name";
$this->db->query($sql, __LINE__, __FILE__);
Modified: trunk/controller/inc/class.socontrol_group.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol_group.inc.php 2012-08-16 08:57:41 UTC
(rev 9868)
+++ trunk/controller/inc/class.socontrol_group.inc.php 2012-08-16 10:54:47 UTC
(rev 9869)
@@ -43,7 +43,8 @@
*/
public static function get_instance()
{
- if (self::$so == null) {
+ if (self::$so == null)
+ {
self::$so =
CreateObject('controller.socontrol_group');
}
return self::$so;
@@ -73,7 +74,7 @@
$result = $this->db->query('INSERT INTO
controller_control_group (' . join(',', $cols) . ') VALUES (' . join(',',
$values) . ')', __LINE__,__FILE__);
- if(isset($result))
+ if($result)
{
// Get the new control group ID and return it
return
$this->db->get_last_insert_id('controller_control_group', 'id');
@@ -104,7 +105,7 @@
$result = $this->db->query('UPDATE
controller_control_group SET ' . join(',', $values) . " WHERE id=$id",
__LINE__,__FILE__);
- return isset($result);
+ return $result ? $id : 0;
}
/**
@@ -218,7 +219,8 @@
$sql = "SELECT * FROM controller_control_group WHERE
control_area_id=$control_area_id";
$this->db->query($sql);
- while ($this->db->next_record()) {
+ while ($this->db->next_record())
+ {
$control_group = new
controller_control_group($this->unmarshal($this->db->f('id'), 'int'));
$control_group->set_group_name($this->unmarshal($this->db->f('group_name',
true), 'string'));
$control_group->set_procedure_id($this->unmarshal($this->db->f('procedure_id'),
'int'));
@@ -257,7 +259,8 @@
{
$like_pattern = "'%" .
$this->db->db_addslashes($search_for) . "%'";
$like_clauses = array();
- switch($search_type){
+ switch($search_type)
+ {
default:
$like_clauses[] =
"controller_control_group.group_name $this->like $like_pattern";
break;
@@ -338,7 +341,8 @@
$sql = "SELECT * FROM controller_control_group WHERE
control_area_id=$control_area_id";
$this->db->query($sql);
- while($this->db->next_record()) {
+ while($this->db->next_record())
+ {
$control_group = new
controller_control_group((int) $this->db->f('id'));
$control_group->set_group_name($this->unmarshal($this->db->f('group_name',
true), 'string'));
@@ -353,7 +357,8 @@
$control_groups_array[] =
$control_group->toArray();
}
- if( count( $control_groups_array ) > 0 ){
+ if( count( $control_groups_array ) > 0 )
+ {
return $control_groups_array;
}
else
@@ -374,14 +379,16 @@
$sql = "SELECT control_area_id FROM
controller_control_group WHERE control_group_id={$control_group_id}";
$this->db->query($sql);
- while($this->db->next_record()) {
+ while($this->db->next_record())
+ {
$control_area =
$this->unmarshal($this->db->f('control_area_id'), 'int');
$category =
execMethod('phpgwapi.categories.return_single',
$this->unmarshal($this->db->f('control_area_id', 'int')));
$control_area_array[] = array($control_area =>
$category[0]['name']);
}
- if( count( $control_area_array ) > 0 ){
+ if( count( $control_area_array ) > 0 )
+ {
return $control_area_array;
}
else
Modified: trunk/controller/inc/class.socontrol_group_list.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol_group_list.inc.php 2012-08-16
08:57:41 UTC (rev 9868)
+++ trunk/controller/inc/class.socontrol_group_list.inc.php 2012-08-16
10:54:47 UTC (rev 9869)
@@ -44,7 +44,8 @@
*/
public static function get_instance()
{
- if (self::$so == null) {
+ if (self::$so == null)
+ {
self::$so =
CreateObject('controller.socontrol_group_list');
}
return self::$so;
@@ -72,7 +73,8 @@
$result = $this->db->query('INSERT INTO
controller_control_group_list (' . join(',', $cols) . ') VALUES (' . join(',',
$values) . ')', __LINE__,__FILE__);
- if(isset($result)) {
+ if($result)
+ {
// Get the new control group ID and return it
return
$this->db->get_last_insert_id('controller_control_group_list', 'id');
}
@@ -80,7 +82,6 @@
{
return 0;
}
-
}
/**
@@ -103,7 +104,7 @@
//var_dump('UPDATE activity_activity SET ' . join(',',
$values) . " WHERE id=$id");
$result = $this->db->query('UPDATE
controller_control_group_list SET ' . join(',', $values) . " WHERE id=$id",
__LINE__,__FILE__);
- return isset($result);
+ return $result;
}
/**
@@ -119,7 +120,8 @@
$sql = "SELECT p.* FROM controller_control_group_list p
WHERE p.id = " . $id;
$this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
- if($this->db->next_record()){
+ if($this->db->next_record())
+ {
$control_group_list = new
controller_control_group_list($this->unmarshal($this->db->f('id'), 'int'));
$control_group_list->set_control_id($this->unmarshal($this->db->f('control_id'),
'int'));
$control_group_list->set_control_group_id($this->unmarshal($this->db->f('control_group_id'),
'int'));
@@ -148,7 +150,8 @@
$sql = "SELECT p.* FROM controller_control_group_list p
WHERE p.control_id={$control_id} AND p.control_group_id={$control_group_id}";
$this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
- if($this->db->next_record()){
+ if($this->db->next_record())
+ {
$control_group_list = new
controller_control_group_list($this->unmarshal($this->db->f('id'), 'int'));
$control_group_list->set_control_id($this->unmarshal($this->db->f('control_id'),
'int'));
$control_group_list->set_control_group_id($this->unmarshal($this->db->f('control_group_id'),
'int'));
@@ -176,7 +179,7 @@
$result = $this->db->query("DELETE FROM
controller_control_group_list WHERE control_id = $control_id AND
control_group_id = $control_group_id");
- return isset($result);
+ return $result;
}
/**
@@ -190,7 +193,7 @@
$control_id = (int) $control_id;
$result = $this->db->query("DELETE FROM
controller_control_group_list WHERE control_id = $control_id");
- return isset($result);
+ return $result;
}
/**
@@ -222,9 +225,13 @@
$control_group->set_building_part_id($this->unmarshal($this->db->f('building_part_id'),
'int'));
if($returnType == "array")
+ {
$control_group_list[] =
$control_group->toArray();
- else
+ }
+ else
+ {
$control_group_list[] = $control_group;
+ }
}
return $control_group_list;
Modified: trunk/controller/inc/class.socontrol_item.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol_item.inc.php 2012-08-16 08:57:41 UTC
(rev 9868)
+++ trunk/controller/inc/class.socontrol_item.inc.php 2012-08-16 10:54:47 UTC
(rev 9869)
@@ -43,7 +43,8 @@
*/
public static function get_instance()
{
- if (self::$so == null) {
+ if (self::$so == null)
+ {
self::$so =
CreateObject('controller.socontrol_item');
}
return self::$so;
@@ -79,7 +80,8 @@
$result = $this->db->query('INSERT INTO
controller_control_item (' . join(',', $cols) . ') VALUES (' . join(',',
$values) . ')', __LINE__,__FILE__);
- if(isset($result)) {
+ if($result)
+ {
// return the new control item ID
return
$this->db->get_last_insert_id('controller_control_item', 'id');
}
@@ -113,7 +115,8 @@
//var_dump('UPDATE controller_control_item SET ' .
join(',', $values) . " WHERE id=$id");
$result = $this->db->query('UPDATE
controller_control_item SET ' . join(',', $values) . " WHERE id=$id",
__LINE__,__FILE__);
- if(isset($result)) {
+ if($result)
+ {
// return the new control item ID
return $id;
}
@@ -174,7 +177,7 @@
$control_item = null;
while ($this->db->next_record())
{
- if( $counter == 0 )
+ if( !$counter )
{
$control_item = new
controller_control_item($this->unmarshal($this->db->f('ci_id'), 'int'));
$control_item->set_title($this->unmarshal($this->db->f('title', true),
'string'));
@@ -189,7 +192,7 @@
$control_item->set_control_area_name($category[0]['name']);
}
- if($this->db->f('cio_id') != '')
+ if($this->db->f('cio_id'))
{
$control_item_option = new
controller_control_item_option();
$control_item_option->set_id($this->unmarshal($this->db->f('cio_id'), 'int'));
@@ -246,7 +249,8 @@
//var_dump($sql);
$this->db->limit_query($sql, $start, __LINE__,
__FILE__, $limit);
- while ($this->db->next_record()) {
+ while ($this->db->next_record())
+ {
$control_item = new
controller_control_item($this->unmarshal($this->db->f('id'), 'int'));
$control_item->set_title($this->unmarshal($this->db->f('title', true),
'string'));
$control_item->set_required($this->unmarshal($this->db->f('required', true),
'boolean'));
@@ -294,7 +298,8 @@
$search_for =
$this->marshal($search_for,'field');
$like_pattern = "'%".$search_for."%'";
$like_clauses = array();
- switch($search_type){
+ switch($search_type)
+ {
default:
$like_clauses[] =
"controller_control_item.title $this->like $like_pattern";
$like_clauses[] =
"controller_control_item.what_to_do $this->like $like_pattern";
@@ -363,7 +368,8 @@
function populate(int $control_item_id, &$control_item)
{
- if($control_item == null) {
+ if($control_item == null)
+ {
$control_item = new
controller_control_item((int) $control_item_id);
$control_item->set_title($this->unmarshal($this->db->f('title', true),
'string'));
@@ -389,12 +395,12 @@
//var_dump($sql1);
$this->db->query($sql1, __LINE__, __FILE__);
- while ($this->db->next_record()) {
+ while ($this->db->next_record())
+ {
$results[] = array('control_group' =>
$this->db->f('id'));
}
return $results;
-
}
function location_has_component($comp, $location_code)
@@ -436,5 +442,4 @@
}
return $results;
}
-
}
Modified: trunk/controller/inc/class.socontrol_item_list.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol_item_list.inc.php 2012-08-16
08:57:41 UTC (rev 9868)
+++ trunk/controller/inc/class.socontrol_item_list.inc.php 2012-08-16
10:54:47 UTC (rev 9869)
@@ -44,7 +44,8 @@
*/
public static function get_instance()
{
- if (self::$so == null) {
+ if (self::$so == null)
+ {
self::$so =
CreateObject('controller.socontrol_item_list');
}
return self::$so;
@@ -70,7 +71,8 @@
$result = $this->db->query( 'INSERT INTO
controller_control_item_list (' . join(',', $cols) . ') VALUES (' . join(',',
$values) . ')', __LINE__,__FILE__);
- if(isset($result)) {
+ if($result)
+ {
// return the new control item ID
return
$this->db->get_last_insert_id('controller_control_item_list', 'id');
}
@@ -98,7 +100,7 @@
$result = $this->db->query('UPDATE
controller_control_item_list SET ' . join(',', $values) . " WHERE id=$id",
__LINE__,__FILE__);
- return isset($result);
+ return $result;
}
/**
@@ -166,7 +168,8 @@
$this->db->query($sql);
- while ($this->db->next_record()) {
+ while ($this->db->next_record())
+ {
$control_item = new
controller_control_item($this->unmarshal($this->db->f('id'), 'int'));
$control_item->set_title($this->unmarshal($this->db->f('title', true),
'string'));
$control_item->set_required($this->unmarshal($this->db->f('required'),
'boolean'));
@@ -175,9 +178,13 @@
$control_item->set_control_group_id($this->unmarshal($this->db->f('control_group_id'),
'int'));
if($return_type == "return_object")
+ {
$results[] = $control_item;
+ }
else
+ {
$results[] = $control_item->toArray();
+ }
}
return $results;
@@ -203,7 +210,8 @@
$this->db->query($sql);
- while ($this->db->next_record()) {
+ while ($this->db->next_record())
+ {
$control_item = new
controller_control_item($this->unmarshal($this->db->f('id'), 'int'));
$control_item->set_title($this->unmarshal($this->db->f('title', true),
'string'));
$control_item->set_required($this->unmarshal($this->db->f('required'),
'boolean'));
@@ -213,9 +221,13 @@
$control_item->set_type($this->unmarshal($this->db->f('type', true), 'string'));
if($returnType == "return_array")
+ {
$results[] = $control_item->toArray();
+ }
else
+ {
$results[] = $control_item;
+ }
}
return $results;
@@ -246,7 +258,8 @@
$this->db->limit_query($sql, $start, __LINE__,
__FILE__, $limit);
- while ($this->db->next_record()) {
+ while ($this->db->next_record())
+ {
$control_item = new
controller_control_item($this->unmarshal($this->db->f('id'), 'int'));
$control_item->set_title($this->unmarshal($this->db->f('title', true),
'string'));
$control_item->set_required($this->unmarshal($this->db->f('required'),
'boolean'));
@@ -256,9 +269,13 @@
$control_item->set_type($this->unmarshal($this->db->f('type', true), 'string'));
if($returnType == "return_array")
+ {
$results[] = $control_item->toArray();
+ }
else
+ {
$results[] = $control_item;
+ }
}
return $results;
@@ -293,15 +310,22 @@
$control_item_id = 0;
$control_item = null;
$control_item_array = array();
- while ($this->db->next_record()) {
- if( $this->db->f('ci_id') != $control_item_id ){
- if($control_item_id != 0){
+ while ($this->db->next_record())
+ {
+ if( $this->db->f('ci_id') != $control_item_id )
+ {
+ if($control_item_id)
+ {
$control_item->set_options_array($options_array);
if($return_type ==
"return_array")
+ {
$control_item_array[] =
$control_item->toArray();
+ }
else
+ {
$control_item_array[] =
$control_item;
+ }
}
$control_item = new
controller_control_item($this->unmarshal($this->db->f('ci_id'), 'int'));
@@ -319,25 +343,34 @@
$control_item_option->set_id($this->db->f('cio_id'));
if($return_type == "return_array")
+ {
$options_array[] =
$control_item_option->toArray();
+ }
else
+ {
$options_array[] = $control_item_option;
-
-
+ }
+
$control_item_id = $control_item->get_id();
}
- if($control_item != null){
+ if($control_item != null)
+ {
$control_item->set_options_array($options_array);
- if($return_type == "return_array"){
+ if($return_type == "return_array")
+ {
$control_item_array[] =
$control_item->toArray();
- }else{
+ }
+ else
+ {
$control_item_array[] = $control_item;
}
return $control_item_array;
- }else {
+ }
+ else
+ {
return null;
}
}
@@ -356,7 +389,7 @@
$result = $this->db->query("DELETE FROM
controller_control_item_list WHERE control_id = $control_id AND control_item_id
= $control_item_id", __LINE__,__FILE__);
- return isset($result);
+ return $result;
}
/**
@@ -370,7 +403,7 @@
$control_id = (int) $control_id;
$result = $this->db->query("DELETE FROM
controller_control_item_list WHERE control_id = $control_id");
- return isset($result);
+ return $result;
}
/**
@@ -393,7 +426,7 @@
$result = $this->db->query($sql);
- return isset($result);
+ return $result;
}
function get_id_field_name($extended_info = false){}
Modified: trunk/controller/inc/class.socontrol_item_option.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol_item_option.inc.php 2012-08-16
08:57:41 UTC (rev 9868)
+++ trunk/controller/inc/class.socontrol_item_option.inc.php 2012-08-16
10:54:47 UTC (rev 9869)
@@ -38,7 +38,8 @@
public static function get_instance()
{
- if (self::$so == null) {
+ if (self::$so == null)
+ {
self::$so =
CreateObject('controller.socontrol_item_option');
}
return self::$so;
@@ -64,7 +65,8 @@
$result = $this->db->query('INSERT INTO
controller_control_item_option (' . join(',', $cols) . ') VALUES (' . join(',',
$values) . ')', __LINE__,__FILE__);
- if(isset($result)) {
+ if($result)
+ {
// return the new control item ID
return
$this->db->get_last_insert_id('controller_control_item_option', 'id');
}
@@ -91,7 +93,7 @@
$result = $this->db->query('UPDATE
controller_control_item_option SET ' . join(',', $values) . " WHERE id=$id",
__LINE__,__FILE__);
- return isset($result);
+ return $result;
}
/**
Modified: trunk/controller/inc/class.sodocument.inc.php
===================================================================
--- trunk/controller/inc/class.sodocument.inc.php 2012-08-16 08:57:41 UTC
(rev 9868)
+++ trunk/controller/inc/class.sodocument.inc.php 2012-08-16 10:54:47 UTC
(rev 9869)
@@ -45,7 +45,8 @@
*/
public static function get_instance()
{
- if (self::$so == null) {
+ if (self::$so == null)
+ {
self::$so = CreateObject('controller.sodocument');
}
return self::$so;
@@ -82,7 +83,8 @@
$search_for = $this->marshal($search_for,'field');
$like_pattern = "'%".$search_for."%'";
$like_clauses = array();
- switch($search_type){
+ switch($search_type)
+ {
case "title":
$like_clauses[] =
"controller_document.title $this->like $like_pattern";
break;
@@ -221,7 +223,8 @@
$sql = "SELECT id, title FROM
controller_document_types";
$this->db->query($sql, __LINE__, __FILE__);
$results = array();
- while($this->db->next_record()){
+ while($this->db->next_record())
+ {
$location_id = $this->db->f('id');
$results[$location_id] = $this->db->f('title',
true);
}
@@ -236,7 +239,8 @@
$sql = "SELECT id, title FROM controller_document_types";
$this->db->query($sql, __LINE__, __FILE__);
$results = array();
- while($this->db->next_record()){
+ while($this->db->next_record())
+ {
$result[] = $this->db->f('id');
$result[] = $this->db->f('title', true);
$results[] = $result;
Modified: trunk/controller/inc/class.soprocedure.inc.php
===================================================================
--- trunk/controller/inc/class.soprocedure.inc.php 2012-08-16 08:57:41 UTC
(rev 9868)
+++ trunk/controller/inc/class.soprocedure.inc.php 2012-08-16 10:54:47 UTC
(rev 9869)
@@ -45,7 +45,8 @@
*/
public static function get_instance()
{
- if (self::$so == null) {
+ if (self::$so == null)
+ {
self::$so =
CreateObject('controller.soprocedure');
}
return self::$so;
@@ -91,7 +92,8 @@
$result = $this->db->query('INSERT INTO
controller_procedure (' . join(',', $cols) . ') VALUES (' . join(',', $values)
. ')', __LINE__,__FILE__);
- if(isset($result)) {
+ if($result)
+ {
// Get the new procedure ID and return it
return
$this->db->get_last_insert_id('controller_procedure', 'id');
}
@@ -130,7 +132,7 @@
$result = $this->db->query('UPDATE controller_procedure
SET ' . join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
- return isset($result);
+ return $result;
}
/**
@@ -145,13 +147,13 @@
$counter = 0;
$documents = null;
-
$joins .= " {$this->left_join} controller_document ON
(p.id = controller_document.procedure_id)";
$sql = "SELECT p.*, controller_document.id AS
document_id, controller_document.title AS document_title,
controller_document.description as document_description FROM
controller_procedure p {$joins} WHERE p.id = " . $id;
//var_dump($sql);
$this->db->query($sql, __LINE__, __FILE__);
- while ($this->db->next_record()) {
+ while ($this->db->next_record())
+ {
if($counter == 0){
$procedure = new
controller_procedure($this->unmarshal($this->db->f('id'), 'int'));
$procedure->set_title($this->unmarshal($this->db->f('title', true), 'string'));
@@ -173,7 +175,8 @@
//$procedure->set_control_area_name($this->unmarshal($this->db->f('control_area_name',
'string')));
}
- if($this->db->f('document_id') != ''){
+ if($this->db->f('document_id') != '')
+ {
$document = new
controller_document($this->unmarshal($this->db->f('document_id'), 'int'));
$document->set_procedure_id($procedure->get_id());
$document->set_title($this->unmarshal($this->db->f('document_title', true),
'string'));
@@ -199,8 +202,10 @@
$sql = "SELECT p.*, controller_document.id AS
document_id, controller_document.title AS document_title,
controller_document.description as document_description FROM
controller_procedure p {$joins} WHERE p.id = " . $id;
//var_dump($sql);
$this->db->query($sql, __LINE__, __FILE__);
- while ($this->db->next_record()) {
- if($counter == 0){
+ while ($this->db->next_record())
+ {
+ if(!$counter)
+ {
$procedure = new
controller_procedure($this->unmarshal($this->db->f('id'), 'int'));
$procedure->set_title($this->unmarshal($this->db->f('title', true), 'string'));
$procedure->set_purpose($this->unmarshal($this->db->f('purpose', true),
'string'));
@@ -218,7 +223,8 @@
$procedure->set_control_area_name($category[0]['name']);
}
- if($this->db->f('document_id') != ''){
+ if($this->db->f('document_id'))
+ {
$document = new
controller_document($this->unmarshal($this->db->f('document_id'), 'int'));
$document->set_procedure_id($procedure->get_id());
$document->set_title($this->unmarshal($this->db->f('document_title', true),
'string'));
@@ -232,20 +238,29 @@
$documents_array[] =
$doc_as_array;
}
else
+ {
$documents_array[] = $document;
+ }
}
$counter++;
}
- if($procedure != null){
+ if($procedure != null)
+ {
$procedure->set_documents($documents_array);
if($return_type == "return_array")
+ {
return $procedure->toArray();
+ }
else
+ {
return $procedure;
- }else {
+ }
+ }
+ else
+ {
return null;
}
}
@@ -258,7 +273,8 @@
$sql = "SELECT * FROM controller_procedure WHERE
control_area_id={$control_area_id} AND end_date IS NULL ORDER BY title ASC";
$this->db->query($sql);
- while($this->db->next_record()) {
+ while($this->db->next_record())
+ {
$procedure = new
controller_procedure($this->unmarshal($this->db->f('id'), 'int'));
$procedure->set_title($this->unmarshal($this->db->f('title', true), 'string'));
$procedure->set_purpose($this->unmarshal($this->db->f('purpose', true),
'string'));
@@ -275,7 +291,8 @@
$procedures_array[] = $procedure->toArray();
}
- if( count( $procedures_array ) > 0 ){
+ if( count( $procedures_array ) > 0 )
+ {
return $procedures_array;
}
else
@@ -297,7 +314,8 @@
$sql = "SELECT * FROM controller_procedure $condition
$order";
$this->db->limit_query($sql, $start, __LINE__,
__FILE__, $limit);
- while ($this->db->next_record()) {
+ while ($this->db->next_record())
+ {
$procedure = new
controller_procedure($this->unmarshal($this->db->f('id'), 'int'));
$procedure->set_title($this->unmarshal($this->db->f('title', true), 'string'));
$procedure->set_purpose($this->unmarshal($this->db->f('purpose', true),
'string'));
@@ -330,7 +348,8 @@
$sql = "SELECT * FROM controller_procedure $condition
$order";
$this->db->limit_query($sql, $start, __LINE__,
__FILE__, $limit);
- while ($this->db->next_record()) {
+ while ($this->db->next_record())
+ {
$procedure = new
controller_procedure($this->unmarshal($this->db->f('id'), 'int'));
$procedure->set_title($this->unmarshal($this->db->f('title', true), 'string'));
$procedure->set_purpose($this->unmarshal($this->db->f('purpose', true),
'string'));
@@ -358,7 +377,8 @@
$sql = "SELECT p.* FROM controller_procedure p WHERE
procedure_id = {$id} ORDER BY end_date DESC";
$this->db->limit_query($sql, $start, __LINE__,
__FILE__, $limit);
- while ($this->db->next_record()) {
+ while ($this->db->next_record())
+ {
$procedure = new
controller_procedure($this->unmarshal($this->db->f('id'), 'int'));
$procedure->set_title($this->unmarshal($this->db->f('title', true), 'string'));
$procedure->set_purpose($this->unmarshal($this->db->f('purpose', true),
'string'));
@@ -408,7 +428,8 @@
{
$like_pattern = "'%" .
$this->db->db_addslashes($search_for) . "%'";
$like_clauses = array();
- switch($search_type){
+ switch($search_type)
+ {
default:
$like_clauses[] =
"procedure.title $this->like $like_pattern";
break;
@@ -472,7 +493,8 @@
function populate(int $procedure_id, &$procedure)
{
- if($procedure == null) {
+ if($procedure == null)
+ {
$procedure = new controller_procedure((int)
$procedure_id);
$procedure->set_title($this->unmarshal($this->db->f('title'), 'string'));
@@ -494,5 +516,4 @@
return $procedure;
}
-
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [9869] controller: code formatting,
Sigurd Nes <=