[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
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_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 $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 ($fieldModelList) { 31 $values[$blockLabel] = array(); 32 foreach($fieldModelList as $fieldName => $fieldModel) { 33 if($fieldModel->get('uitype') == 115) { 34 $fieldModel->set('editable', false); 35 } 36 if(empty($recordId) && ($fieldModel->get('uitype') == 99 || $fieldModel->get('uitype') == 106)) { 37 $fieldModel->set('editable', true); 38 } 39 //Is Admin field is editable when the record user != current user 40 if (in_array($fieldModel->get('uitype'), array(156)) && $currentUserModel->getId() !== $recordId) { 41 $fieldModel->set('editable', true); 42 if ($fieldModel->get('uitype') == 156) { 43 $fieldValue = false; 44 $defaultValue = $fieldModel->getDefaultFieldValue(); 45 if ($recordModel->get($fieldName) === 'on') { 46 $fieldValue = true; 47 } 48 $recordModel->set($fieldName, $fieldValue); 49 } 50 } 51 if($fieldModel->isEditable()) { 52 if($recordModel->get($fieldName) != '') { 53 $fieldModel->set('fieldvalue', $recordModel->get($fieldName)); 54 } else { 55 $defaultValue = $fieldModel->getDefaultFieldValue(); 56 if(!empty($defaultValue) && !$recordId) 57 $fieldModel->set('fieldvalue', $defaultValue); 58 } 59 60 if(!$recordId && $fieldModel->get('uitype') == 99) { 61 $fieldModel->set('editable', true); 62 $values[$blockLabel][$fieldName] = $fieldModel; 63 } else if($fieldModel->get('uitype') != 99){ 64 $values[$blockLabel][$fieldName] = $fieldModel; 65 } 66 } 67 } 68 } 69 } 70 $this->structuredValues = $values; 71 return $values; 72 } 73 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |