[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Documents/models/ -> EditRecordStructure.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 Documents_EditRecordStructure_Model extends Vtiger_EditRecordStructure_Model {
  12  
  13      /**
  14       * Function to get the values in stuctured format
  15       * @return <array> - values in structure array('block'=>array(fieldinfo));
  16       */
  17  	public function getStructure() {
  18          if(!empty($this->structuredValues)) {
  19              return $this->structuredValues;
  20          }
  21  
  22          $values = array();
  23          $recordModel = $this->getRecord();
  24          $recordExists = !empty($recordModel);
  25          $recordId = $recordModel->getId();
  26          $moduleModel = $this->getModule();
  27          $blockModelList = $moduleModel->getBlocks();
  28          foreach($blockModelList as $blockLabel=>$blockModel) {
  29              $fieldModelList = $blockModel->getFields();
  30              if (!empty ($fieldModelList)) {
  31                  $values[$blockLabel] = array();
  32                  foreach($fieldModelList as $fieldName=>$fieldModel) {
  33                      if($fieldModel->isEditable()) {
  34                          $fieldValue = $recordModel->get($fieldName);
  35  
  36                          if (!$fieldValue && !$recordId) {
  37                              $fieldValue = $fieldModel->getDefaultFieldValue();
  38                          }
  39  
  40                          //By default the file status should be active while creating a Document record
  41                          if ($fieldName === 'filestatus' && !$recordId) {
  42                              $fieldValue = true;
  43                          }
  44  
  45                          if ($fieldValue) {
  46                              $fieldModel->set('fieldvalue', $fieldValue);
  47                          }
  48                          $values[$blockLabel][$fieldName] = $fieldModel;
  49                      }
  50                  }
  51              }
  52          }
  53          $this->structuredValues = $values;
  54          return $values;
  55      }
  56  }


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