[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Users/models/ -> Field.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  /**
  12   * User Field Model Class
  13   */
  14  class Users_Field_Model extends Vtiger_Field_Model {
  15  
  16      /**
  17       * Function to check whether the current field is read-only
  18       * @return <Boolean> - true/false
  19       */
  20  	public function isReadOnly() {
  21          $currentUserModel = Users_Record_Model::getCurrentUserModel();
  22          if(($currentUserModel->isAdminUser() == false && $this->get('uitype') == 98) || $this->get('uitype') == 156 || $this->get('uitype') == 115) {
  23              return true;
  24          }
  25      }
  26  
  27  
  28      /**
  29       * Function to check if the field is shown in detail view
  30       * @return <Boolean> - true/false
  31       */
  32  	public function isViewEnabled() {
  33          if($this->getDisplayType() == '4' || in_array($this->get('presence'), array(1,3))) {
  34              return false;
  35          }
  36          return true;
  37      }
  38  
  39  
  40      /**
  41       * Function to get the Webservice Field data type
  42       * @return <String> Data type of the field
  43       */
  44  	public function getFieldDataType() {
  45          if($this->get('uitype') == 99){
  46              return 'password';
  47          }else if(in_array($this->get('uitype'), array(32, 115))) {
  48              return 'picklist';
  49          } else if($this->get('uitype') == 101) {
  50              return 'userReference';
  51          } else if($this->get('uitype') == 98) {
  52              return 'userRole';
  53          } elseif($this->get('uitype') == 105) {
  54              return 'image';
  55          } else if($this->get('uitype') == 31) {
  56              return 'theme';
  57          }
  58          return parent::getFieldDataType();
  59      }
  60  
  61      /**
  62       * Function to check whether field is ajax editable'
  63       * @return <Boolean>
  64       */
  65  	public function isAjaxEditable() {
  66          if(!$this->isEditable() || $this->get('uitype') == 105 || $this->get('uitype') == 106 || $this->get('uitype') == 98 || $this->get('uitype') == 101) {
  67              return false;
  68          }
  69          return true;
  70      }
  71  
  72      /**
  73       * Function to get all the available picklist values for the current field
  74       * @return <Array> List of picklist values if the field is of type picklist or multipicklist, null otherwise.
  75       */
  76  	public function getPicklistValues() {
  77          if($this->get('uitype') == 32) {
  78              return Vtiger_Language_Handler::getAllLanguages();
  79          }
  80          else if ($this->get('uitype') == '115') {
  81              $db = PearDatabase::getInstance();
  82              
  83              $query = 'SELECT '.$this->getFieldName().' FROM vtiger_'.$this->getFieldName();
  84              $result = $db->pquery($query, array());
  85              $num_rows = $db->num_rows($result);
  86              $fieldPickListValues = array();
  87              for($i=0; $i<$num_rows; $i++) {
  88                  $picklistValue = $db->query_result($result,$i,$this->getFieldName());
  89                  $fieldPickListValues[$picklistValue] = vtranslate($picklistValue,$this->getModuleName());
  90              }
  91              return $fieldPickListValues;
  92          }
  93          return parent::getPicklistValues();
  94      }
  95  
  96      /**
  97       * Function to returns all skins(themes)
  98       * @return <Array>
  99       */
 100      public function getAllSkins(){
 101          return Vtiger_Theme::getAllSkins();
 102      }
 103  
 104      /**
 105       * Function to retieve display value for a value
 106       * @param <String> $value - value which need to be converted to display value
 107       * @return <String> - converted display value
 108       */
 109      public function getDisplayValue($value, $recordId = false) {
 110          
 111           if($this->get('uitype') == 32){
 112              return Vtiger_Language_Handler::getLanguageLabel($value);
 113           }
 114          return parent::getDisplayValue($value, $recordId);
 115      }
 116  
 117      /**
 118       * Function returns all the User Roles
 119       * @return
 120       */
 121       public function getAllRoles(){
 122          $roleModels = Settings_Roles_Record_Model::getAll();
 123          $roles = array();
 124          foreach ($roleModels as $roleId=>$roleModel) {
 125              $roleName = $roleModel->getName();
 126              $roles[$roleName] = $roleId;
 127          }
 128          return $roles;
 129      }
 130  
 131      /**
 132       * Function to check whether this field editable or not
 133       * return <boolen> true/false
 134       */
 135  	public function isEditable() {
 136          $isEditable = $this->get('editable');
 137          if (!$isEditable) {
 138              $this->set('editable', parent::isEditable());
 139          }
 140          return $this->get('editable');
 141      }
 142      
 143      /**
 144       * Function which will check if empty piclist option should be given
 145       */
 146      public function isEmptyPicklistOptionAllowed() {
 147          if($this->getFieldName() == 'reminder_interval') {
 148              return true;
 149          }
 150          return false;
 151      }
 152  }


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