fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8504] property: tuning


From: Sigurd Nes
Subject: [Fmsystem-commits] [8504] property: tuning
Date: Fri, 06 Jan 2012 08:19:02 +0000

Revision: 8504
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8504
Author:   sigurdne
Date:     2012-01-06 08:19:01 +0000 (Fri, 06 Jan 2012)
Log Message:
-----------
property: tuning

Modified Paths:
--------------
    trunk/property/inc/class.bocommon.inc.php
    trunk/property/inc/class.custom_fields.inc.php

Modified: trunk/property/inc/class.bocommon.inc.php
===================================================================
--- trunk/property/inc/class.bocommon.inc.php   2012-01-06 08:13:27 UTC (rev 
8503)
+++ trunk/property/inc/class.bocommon.inc.php   2012-01-06 08:19:01 UTC (rev 
8504)
@@ -1176,11 +1176,17 @@
                                $type_id        = 0;//count($location_types);
                                $no_address     = true;
                        }
+
+                       $GLOBALS['phpgw']->config->read();
+                       $list_location_level = 
isset($GLOBALS['phpgw']->config->config_data['list_location_level'])     && 
$GLOBALS['phpgw']->config->config_data['list_location_level'] ? 
$GLOBALS['phpgw']->config->config_data['list_location_level'] : array();
+
+
                        $this->type_id  = $type_id;
                        $_level = 1;
                        for ($i=0; $i<$type_id; $i++)
                        {
-                               if($_level > 1)
+               //              if($_level > 1) // very expensive 
+                               if($_level == 2 && in_array(2, 
$list_location_level))
                                {
                                        $joinmethod .= " {$this->join} 
fm_location{$_level}";
                                        $paranthesis .='(';
@@ -1216,9 +1222,6 @@
                                $cols_return[] = 'loc' . 
$location_types[$i]['id'];
                        }
 
-                       $GLOBALS['phpgw']->config->read();
-                       $list_location_level = 
isset($GLOBALS['phpgw']->config->config_data['list_location_level'])     && 
$GLOBALS['phpgw']->config->config_data['list_location_level'] ? 
$GLOBALS['phpgw']->config->config_data['list_location_level'] : array();
-
                        for ($i=1;$i<($type_id+1);$i++)
                        {
                                $cols_return[]                          = 
"loc{$i}_name";

Modified: trunk/property/inc/class.custom_fields.inc.php
===================================================================
--- trunk/property/inc/class.custom_fields.inc.php      2012-01-06 08:13:27 UTC 
(rev 8503)
+++ trunk/property/inc/class.custom_fields.inc.php      2012-01-06 08:19:01 UTC 
(rev 8504)
@@ -447,73 +447,71 @@
                                                $location = 
explode('-',$data['value']);
                                        }
 
-                                       if(($data['datatype']=='R' || 
$data['datatype']=='LB') && $data['value'] && $data['attrib_id'])
+                                       $ret[$j][$field] = '';
+                                       if($data['value'])
                                        {
-                                               $sql="SELECT value FROM 
$choice_table WHERE $attribute_filter AND attrib_id=" .$data['attrib_id']. "  
AND id=" . $data['value'];
-                                               $this->_db->query($sql);
-                                               $this->_db->next_record();
-                                               $ret[$j][$field] =  
$this->_db->f('value');
-                                       }
-                                       else if($data['datatype']=='AB' && 
$data['value'])
-                                       {
-                                               $contact_data   = 
$contacts->read_single_entry($data['value'],array('fn'));
-                                               $ret[$j][$field] =  
$contact_data[0]['fn'];
-                                       }
-                                       else if($data['datatype']=='ABO' && 
$data['value'])
-                                       {
-                                               $contact_data   = 
$contacts->get_principal_organizations_data($data['value']);
-                                               $ret[$j][$field] = 
$contact_data[0]['org_name'];
-                                       }
-                                       else if($data['datatype']=='VENDOR' && 
$data['value'])
-                                       {
-                                               $sql="SELECT org_name FROM 
fm_vendor where id={$data['value']}";
-                                               $this->_db->query($sql);
-                                               $this->_db->next_record();
-                                               $ret[$j][$field] =  
$this->_db->f('org_name',true);
-                                       }
-                                       else if($data['datatype']=='CH' && 
$data['value'])
-                                       {
-                                       //      $ch= 
unserialize($data['value']);
-                                               $ch = explode(',', 
trim($data['value'], ','));
-                                               if (isset($ch) AND 
is_array($ch))
+                                               switch($data['datatype'])
                                                {
-                                                       for 
($k=0;$k<count($ch);$k++)
-                                                       {
-                                                               $sql="SELECT 
value FROM $choice_table WHERE $attribute_filter AND attrib_id= 
{$data['attrib_id']} AND id=" . $ch[$k];
+                                                       case 'R':
+                                                       case 'LB':
+                                                               
if($data['attrib_id'])
+                                                               {
+                                                                       
$sql="SELECT value FROM $choice_table WHERE $attribute_filter AND attrib_id=" 
.(int)$data['attrib_id']. "  AND id=" . (int)$data['value'];
+                                                                       
$this->_db->query($sql);
+                                                                       
$this->_db->next_record();
+                                                                       
$ret[$j][$field] =  $this->_db->f('value');
+                                                               }
+                                                               break;
+                                                       case 'AB':
+                                                               $contact_data   
= $contacts->read_single_entry($data['value'],array('fn'));
+                                                               
$ret[$j][$field] =  $contact_data[0]['fn'];
+                                                               break;
+                                                       case 'ABO':
+                                                               $contact_data   
= $contacts->get_principal_organizations_data($data['value']);
+                                                               
$ret[$j][$field] = $contact_data[0]['org_name'];
+                                                               break;
+                                                       case 'VENDOR':
+                                                               $sql="SELECT 
org_name FROM fm_vendor where id=" . (int)$data['value'];
                                                                
$this->_db->query($sql);
-                                                               while 
($this->_db->next_record())
+                                                               
$this->_db->next_record();
+                                                               
$ret[$j][$field] =  $this->_db->f('org_name',true);
+                                                               break;
+                                                       case 'CH':
+                                                               $ch = 
explode(',', trim($data['value'], ','));
+                                                               if (isset($ch) 
AND is_array($ch))
                                                                {
-                                                                       
$ch_value[]=$this->_db->f('value');
+                                                                       for 
($k=0;$k<count($ch);$k++)
+                                                                       {
+                                                                               
$sql="SELECT value FROM $choice_table WHERE $attribute_filter AND attrib_id= " 
. (int)$data['attrib_id'] . ' AND id = ' . (int)$ch[$k];
+                                                                               
$this->_db->query($sql);
+                                                                               
while ($this->_db->next_record())
+                                                                               
{
+                                                                               
        $ch_value[]=$this->_db->f('value');
+                                                                               
}
+                                                                       }
+                                                                       
$ret[$j][$field] =  @implode(",", $ch_value);
+                                                                       
unset($ch_value);
                                                                }
-                                                       }
-                                                       $ret[$j][$field] =  
@implode(",", $ch_value);
-                                                       unset($ch_value);
+                                                               break;
+                                                       case 'D':
+                                                               
$ret[$j][$field] =  
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($data['value']));
+                                                               break;
+                                                       case 'timestamp':
+                                                               
$ret[$j][$field] =  
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],$data['value']);
+                                                               break;
+                                                       case 'link':
+                                                               
$ret[$j][$field] =  phpgw::safe_redirect($data['value']);
+                                                               break;
+                                                       case 'user':
+                                                               
$ret[$j][$field] =   
$GLOBALS['phpgw']->accounts->get($data['value'])->__toString();
+                                                               break;
+                                                       case 'pwd':
+                                                               
$ret[$j][$field] =   lang('yes');
+                                                               break;
+                                                       default:
+                                                               
$ret[$j][$field] =  stripslashes($data['value']);
                                                }
                                        }
-                                       else if($data['datatype']=='D' && 
$data['value'])
-                                       {
-                                               $ret[$j][$field] =  
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($data['value']));
-                                       }
-                                       else if($data['datatype']=='timestamp' 
&& $data['value'])
-                                       {
-                                               $ret[$j][$field] =  
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],$data['value']);
-                                       }
-                                       else if($data['datatype']=='link' && 
$data['value'])
-                                       {
-                                               $ret[$j][$field] =  
phpgw::safe_redirect($data['value']);
-                                       }
-                                       else if($data['datatype']=='user' && 
$data['value'])
-                                       {
-                                               $ret[$j][$field] =   
$GLOBALS['phpgw']->accounts->get($data['value'])->__toString();
-                                       }
-                                       else if($data['datatype']=='pwd' && 
$data['value'])
-                                       {
-                                               $ret[$j][$field] =   
lang('yes');
-                                       }
-                                       else
-                                       {
-                                               $ret[$j][$field] =  
stripslashes($data['value']);
-                                       }
 
                                        if($location)
                                        {




reply via email to

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