[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Users/models/ -> DetailRecordStructure.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 Users_DetailRecordStructure_Model extends Vtiger_DetailRecordStructure_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          $currentUserModel = Users_Record_Model::getCurrentUserModel();
  24          $recordModel = $this->getRecord();
  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                      //Is Admin and Status fields are Ajax editable when the record user != current user
  34                      if (in_array($fieldModel->get('uitype'), array(156, 115)) && $currentUserModel->getId() !== $recordId) {
  35                          $fieldModel->set('editable', true);
  36                          if ($fieldModel->get('uitype') == 156) {
  37                              $fieldValue = false;
  38                              if ($recordModel->get($fieldName) === 'on') {
  39                                  $fieldValue = true;
  40                              }
  41                              $recordModel->set($fieldName, $fieldValue);
  42                          }
  43                      }
  44                      if($fieldModel->isViewableInDetailView()) {
  45                          if($recordId) {
  46                              $fieldModel->set('fieldvalue', $recordModel->get($fieldName));
  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