[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Settings/Leads/models/ -> Module.php (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  class Settings_Leads_Module_Model extends Vtiger_Module_Model {
  12  
  13      /**

  14       * Function to get fields of this model

  15       * @return <Array> list of field models <Settings_Leads_Field_Model>

  16       */
  17  	public function getFields() {
  18          if (!$this->fields) {
  19              $fieldModelsList = array();
  20              $fieldIds = $this->getMappingSupportedFieldIdsList();
  21  
  22              foreach ($fieldIds as $fieldId) {
  23                  $fieldModel = Settings_Leads_Field_Model::getInstance($fieldId, $this);
  24                  $fieldModelsList[$fieldModel->getFieldDataType()][$fieldId] = $fieldModel;
  25              }
  26              $this->fields = $fieldModelsList;
  27          }
  28          return $this->fields;
  29      }
  30  
  31      /**

  32       * Function to get mapping supported field ids list

  33       * @return <Array> list of field ids

  34       */
  35  	public function getMappingSupportedFieldIdsList() {
  36          if (!$this->supportedFieldIdsList) {
  37              $selectedTabidsList[] = getTabid($this->getName());
  38              $presense = array(0, 2);
  39              $restrictedFieldNames = array('campaignrelstatus');
  40              $restrictedUitypes = array(4, 10, 51, 52, 53, 57, 58, 69, 70);
  41              $selectedGeneratedTypes = array(1, 2);
  42  
  43              $db = PearDatabase::getInstance();
  44              $query = 'SELECT fieldid FROM vtiger_field
  45                          WHERE presence IN ('. generateQuestionMarks($presense) .')
  46                          AND tabid IN ('. generateQuestionMarks($selectedTabidsList) .')
  47                          AND uitype NOT IN ('. generateQuestionMarks($restrictedUitypes) .')
  48                          AND fieldname NOT IN ('. generateQuestionMarks($restrictedFieldNames) .')
  49                          AND generatedtype IN ('.generateQuestionMarks($selectedGeneratedTypes).')';
  50  
  51              $params = array_merge($presense, $selectedTabidsList, $restrictedUitypes,$restrictedFieldNames, $selectedGeneratedTypes);
  52  
  53              $result = $db->pquery($query, $params);
  54              $numOfRows = $db->num_rows($result);
  55  
  56              $fieldIdsList = array();
  57              for ($i=0; $i<$numOfRows; $i++) {
  58                  $fieldIdsList[] = $db->query_result($result, $i, 'fieldid');
  59              }
  60              $this->supportedFieldIdsList = $fieldIdsList;
  61          }
  62          return $this->supportedFieldIdsList;
  63      }
  64  
  65      /**

  66       * Function to get instance of module

  67       * @param <String> $moduleName

  68       * @return <Settings_Leads_Module_Model>

  69       */
  70  	public static function getInstance($moduleName) {
  71          $moduleModel = parent::getInstance($moduleName);
  72          $objectProperties = get_object_vars($moduleModel);
  73  
  74          $moduleModel = new self();
  75          foreach    ($objectProperties as $properName => $propertyValue) {
  76              $moduleModel->$properName = $propertyValue;
  77          }
  78          return $moduleModel;
  79      }
  80  }


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