[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Vtiger/uitypes/ -> Multiowner.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 Vtiger_Multiowner_UIType extends Vtiger_Base_UIType {
  12  
  13      /**
  14       * Function to get the Template name for the current UI Type object
  15       * @return <String> - Template Name
  16       */
  17  	public function getTemplateName() {
  18          return 'uitypes/MultiOwner.tpl';
  19      }
  20  
  21      /**
  22       * Function to get the Display Value, for the current field type with given DB Insert Value
  23       * @param <Object> $value
  24       * @return <Object>
  25       */
  26  	public function getDisplayValue($values) {
  27          if($values == NULL && !is_array($values)) return;
  28          foreach($values as $value){
  29              if (self::getOwnerType($value) === 'User') {
  30                  $userModel = Users_Record_Model::getCleanInstance('Users');
  31                  $userModel->set('id', $value);
  32                  $detailViewUrl = $userModel->getDetailViewUrl();
  33                  $currentUser = Users_Record_Model::getCurrentUserModel();
  34                  if(!$currentUser->isAdminUser()){
  35                      return getOwnerName($value);
  36                  }
  37              } else {
  38                  $currentUser = Users_Record_Model::getCurrentUserModel();
  39                  if(!$currentUser->isAdminUser()){
  40                      return getOwnerName($value);
  41                  }
  42                  $recordModel = new Settings_Groups_Record_Model();
  43                  $recordModel->set('groupid',$value);
  44                  $detailViewUrl = $recordModel->getDetailViewUrl();
  45              }
  46              $displayvalue[] = "<a href=" .$detailViewUrl. ">" .getOwnerName($value). "</a>&nbsp";
  47          }
  48          $displayvalue = implode(',',$displayvalue);
  49          return $displayvalue;
  50      }
  51      
  52      /**
  53       * Function to know owner is either User or Group
  54       * @param <Integer> userId/GroupId
  55       * @return <String> User/Group
  56       */
  57  	public static function getOwnerType($id) {
  58          $db = PearDatabase::getInstance();
  59  
  60          $result = $db->pquery('SELECT 1 FROM vtiger_users WHERE id = ?', array($id));
  61          if ($db->num_rows($result) > 0) {
  62              return 'User';
  63          }
  64          return 'Group';
  65      }
  66  }


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