[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Potentials/models/ -> DetailView.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 Potentials_DetailView_Model extends Vtiger_DetailView_Model {
  12      /**
  13       * Function to get the detail view links (links and widgets)
  14       * @param <array> $linkParams - parameters which will be used to calicaulate the params
  15       * @return <array> - array of link models in the format as below
  16       *                   array('linktype'=>list of link models);
  17       */
  18  	public function getDetailViewLinks($linkParams) {
  19          $currentUserModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
  20  
  21          $linkModelList = parent::getDetailViewLinks($linkParams);
  22          $recordModel = $this->getRecord();
  23          $invoiceModuleModel = Vtiger_Module_Model::getInstance('Invoice');
  24          $quoteModuleModel = Vtiger_Module_Model::getInstance('Quotes');
  25  
  26          if($currentUserModel->hasModuleActionPermission($invoiceModuleModel->getId(), 'EditView')) {
  27              $basicActionLink = array(
  28                  'linktype' => 'DETAILVIEW',
  29                  'linklabel' => vtranslate('LBL_CREATE').' '.vtranslate($invoiceModuleModel->getSingularLabelKey(), 'Invoice'),
  30                  'linkurl' => $recordModel->getCreateInvoiceUrl(),
  31                  'linkicon' => ''
  32              );
  33              $linkModelList['DETAILVIEW'][] = Vtiger_Link_Model::getInstanceFromValues($basicActionLink);
  34          }
  35          
  36          if($currentUserModel->hasModuleActionPermission($quoteModuleModel->getId(), 'EditView')) {
  37              $basicActionLink = array(
  38                  'linktype' => 'DETAILVIEW',
  39                  'linklabel' => vtranslate('LBL_CREATE').' '.vtranslate($quoteModuleModel->getSingularLabelKey(), 'Quotes'),
  40                  'linkurl' => $recordModel->getCreateQuoteUrl(),
  41                  'linkicon' => ''
  42              );
  43              $linkModelList['DETAILVIEW'][] = Vtiger_Link_Model::getInstanceFromValues($basicActionLink);
  44          }
  45  
  46          $CalendarActionLinks[] = array();
  47          $CalendarModuleModel = Vtiger_Module_Model::getInstance('Calendar');
  48          if($currentUserModel->hasModuleActionPermission($CalendarModuleModel->getId(), 'EditView')) {
  49              $CalendarActionLinks[] = array(
  50                      'linktype' => 'DETAILVIEW',
  51                      'linklabel' => 'LBL_ADD_EVENT',
  52                      'linkurl' => $recordModel->getCreateEventUrl(),
  53                      'linkicon' => ''
  54              );
  55  
  56              $CalendarActionLinks[] = array(
  57                      'linktype' => 'DETAILVIEW',
  58                      'linklabel' => 'LBL_ADD_TASK',
  59                      'linkurl' => $recordModel->getCreateTaskUrl(),
  60                      'linkicon' => ''
  61              );
  62          }
  63          
  64          foreach($CalendarActionLinks as $basicLink) {
  65              $linkModelList['DETAILVIEW'][] = Vtiger_Link_Model::getInstanceFromValues($basicLink);
  66          }
  67  
  68          return $linkModelList;
  69      }
  70      
  71      /**
  72       * Function to get the detail view widgets
  73       * @return <Array> - List of widgets , where each widget is an Vtiger_Link_Model
  74       */
  75  	public function getWidgets() {
  76          $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
  77          $widgetLinks = parent::getWidgets();
  78          $widgets = array();
  79  
  80          $documentsInstance = Vtiger_Module_Model::getInstance('Documents');
  81          if($userPrivilegesModel->hasModuleActionPermission($documentsInstance->getId(), 'DetailView')) {
  82              $createPermission = $userPrivilegesModel->hasModuleActionPermission($documentsInstance->getId(), 'EditView');
  83              $widgets[] = array(
  84                      'linktype' => 'DETAILVIEWWIDGET',
  85                      'linklabel' => 'Documents',
  86                      'linkName'    => $documentsInstance->getName(),
  87                      'linkurl' => 'module='.$this->getModuleName().'&view=Detail&record='.$this->getRecord()->getId().
  88                              '&relatedModule=Documents&mode=showRelatedRecords&page=1&limit=5',
  89                      'action'    =>    ($createPermission == true) ? array('Add') : array(),
  90                      'actionURL' =>    $documentsInstance->getQuickCreateUrl()
  91              );
  92          }
  93  
  94          $contactsInstance = Vtiger_Module_Model::getInstance('Contacts');
  95          if($userPrivilegesModel->hasModuleActionPermission($contactsInstance->getId(), 'DetailView')) {
  96              $createPermission = $userPrivilegesModel->hasModuleActionPermission($contactsInstance->getId(), 'EditView');
  97              $widgets[] = array(
  98                      'linktype' => 'DETAILVIEWWIDGET',
  99                      'linklabel' => 'LBL_RELATED_CONTACTS',
 100                      'linkName'    => $contactsInstance->getName(),
 101                      'linkurl' => 'module='.$this->getModuleName().'&view=Detail&record='.$this->getRecord()->getId().
 102                              '&relatedModule=Contacts&mode=showRelatedRecords&page=1&limit=5',
 103                      'action'    =>    ($createPermission == true) ? array('Add') : array(),
 104                      'actionURL' =>    $contactsInstance->getQuickCreateUrl()
 105              );
 106          }
 107  
 108          $productsInstance = Vtiger_Module_Model::getInstance('Products');
 109          if($userPrivilegesModel->hasModuleActionPermission($productsInstance->getId(), 'DetailView')) {
 110              $createPermission = $userPrivilegesModel->hasModuleActionPermission($productsInstance->getId(), 'EditView');
 111              $widgets[] = array(
 112                      'linktype' => 'DETAILVIEWWIDGET',
 113                      'linklabel' => 'LBL_RELATED_PRODUCTS',
 114                      'linkName'    => $productsInstance->getName(),
 115                      'linkurl' => 'module='.$this->getModuleName().'&view=Detail&record='.$this->getRecord()->getId().
 116                              '&relatedModule=Products&mode=showRelatedRecords&page=1&limit=5',
 117                      'action'    =>    ($createPermission == true) ? array('Add') : array(),
 118                      'actionURL' =>    $productsInstance->getQuickCreateUrl()
 119              );
 120          }
 121  
 122          foreach ($widgets as $widgetDetails) {
 123              $widgetLinks[] = Vtiger_Link_Model::getInstanceFromValues($widgetDetails);
 124          }
 125  
 126          return $widgetLinks;
 127      }
 128  }


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