[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/include/events/ -> VTEntityType.inc (source)

   1  <?php
   2  /*+***********************************************************************************
   3   * The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9   *************************************************************************************/
  10  
  11  require_once ('include/events/SqlResultIterator.inc');
  12  
  13  class VTEntityType{
  14  	function __construct($adb, $setype){
  15          $this->moduleName=$setype;
  16          require_once("modules/".$setype."/".$setype.".php"); 
  17          $result = $adb->pquery("select tabid from vtiger_tab where name=?", 
  18              array($setype));
  19          $tabId = $adb->query_result($result,0,"tabid");
  20          $this->tabId = $tabId;
  21          $this->adb = $adb;
  22      }
  23      
  24  	function getTabId(){
  25          return $this->tabId;
  26      }
  27      
  28  	function getModuleName(){
  29          return $this->moduleName;
  30      }
  31  
  32  	function getFieldNames(){
  33          $adb = $this->adb;
  34          $arr = array();
  35          $result = $adb->pquery("select fieldname from vtiger_field where tabid=? and vtiger_field.presence in (0,2)", 
  36              array($this->getTabId()));
  37          $it = new SQLResultIterator($adb, $result);
  38          foreach($it as $row){
  39              $arr[] = $row->fieldname;
  40          }
  41          return $arr;
  42      }
  43      
  44  	function getFieldType($fieldName){
  45          $adb = $this->adb;
  46          $result = $adb->pquery("select * from vtiger_field where fieldname=? and tabid=? and vtiger_field.presence in (0,2)", 
  47              array($fieldName, $this->tabId));
  48          $uitype = $adb->query_result($result,0,"uitype");
  49          $fieldType = new VTFieldType();
  50          if(in_array($uitype, array(50, 51, 73))){
  51              $fieldType->type = "Related";
  52              $fieldType->relatedTo = "Accounts";    
  53          }else if($uitype == 71){
  54              $fieldType->type = "Number";
  55          }else{
  56              $fieldType->type = "String";
  57          }
  58          return $fieldType;
  59      }
  60      
  61  	function getFieldTypes(){
  62          $adb = $this->adb;
  63          $fieldNames = $this->getFieldNames();
  64          $fieldTypes = array();
  65          foreach($fieldNames as $fieldName){
  66              $fieldTypes[$fieldName]=$this->getFieldType($fieldName);
  67          }
  68          return $fieldTypes;
  69      }
  70      
  71  
  72  }
  73  
  74  class VTFieldType{
  75  	function toArray(){
  76          $ro = new ReflectionObject($this);
  77          $props = $ro->getProperties();
  78          $arr = array();
  79          foreach($props as $prop){
  80              $arr[$prop->getName()]=$prop->getValue($this);
  81          }
  82          return $arr;
  83      }
  84      
  85  }
  86  
  87  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1