Example #1
0
 /**
  * Function to get the detail view links (links and widgets)
  * @param <array> $linkParams - parameters which will be used to calicaulate the params
  * @return <array> - array of link models in the format as below
  *                   array('linktype'=>list of link models);
  */
 public function getDetailViewLinks($linkParams)
 {
     $linkModelList = Vtiger_DetailView_Model::getDetailViewLinks($linkParams);
     $recordModel = $this->getRecord();
     $moduleModel = $this->getModule();
     $moduleName = $moduleModel->getName();
     $recordId = $recordModel->getId();
     //TODO: update the database so that these separate handlings are not required
     $index = 0;
     foreach ($linkModelList['DETAILVIEW'] as $link) {
         if ($link->linklabel == 'View History' || $link->linklabel == 'Send SMS') {
             unset($linkModelList['DETAILVIEW'][$index]);
         } else {
             if ($link->linklabel == 'LBL_SHOW_ACCOUNT_HIERARCHY') {
                 $link->linklabel = 'LBL_SHOW_ACCOUNT_HIERARCHY';
                 $linkURL = 'index.php?module=Accounts&view=AccountHierarchy&record=' . $recordId;
                 $link->linkurl = 'javascript:Accounts_Detail_Js.triggerAccountHierarchy("' . $linkURL . '");';
                 unset($linkModelList['DETAILVIEW'][$index]);
                 $linkModelList['DETAILVIEW'][$index] = $link;
             }
         }
         $index++;
     }
     if (Users_Privileges_Model::isPermitted($moduleModel->getName(), 'ConvertLead', $recordModel->getId()) && Users_Privileges_Model::isPermitted($moduleModel->getName(), 'EditView', $recordModel->getId())) {
         $convert = !Leads_Module_Model::checkIfAllowedToConvert($recordModel->get('leadstatus')) ? 'hide' : '';
         $basicActionLink = array('linktype' => 'DETAILVIEWBASIC', 'linklabel' => '', 'linkclass' => 'btn-info btn-convertLead ' . $convert, 'linkhint' => vtranslate('LBL_CONVERT_LEAD', $moduleName), 'linkurl' => 'javascript:Leads_Detail_Js.convertLead("' . $recordModel->getConvertLeadUrl() . '",this);', 'linkicon' => 'glyphicon glyphicon-transfer');
         $linkModelList['DETAILVIEWBASIC'][] = Vtiger_Link_Model::getInstanceFromValues($basicActionLink);
     }
     return $linkModelList;
 }
Example #2
0
 /**
  * Function to get the detail view links (links and widgets)
  * @param <array> $linkParams - parameters which will be used to calicaulate the params
  * @return <array> - array of link models in the format as below
  *                   array('linktype'=>list of link models);
  */
 public function getDetailViewLinks($linkParams)
 {
     $currentUserModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
     $linkModelList = Vtiger_DetailView_Model::getDetailViewLinks($linkParams);
     $recordModel = $this->getRecord();
     $moduleModel = $this->getModule();
     $moduleName = $moduleModel->getName();
     $recordId = $recordModel->getId();
     $emailModuleModel = Vtiger_Module_Model::getInstance('OSSMail');
     if ($currentUserModel->hasModulePermission($emailModuleModel->getId())) {
         $config = $emailModuleModel->getComposeParameters();
         $basicActionLink = array('linktype' => 'DETAILVIEWBASIC', 'linklabel' => '', 'linkurl' => $emailModuleModel->getComposeUrl($moduleName, $recordId, 'Detail', $config['popup']), 'linkicon' => 'glyphicon glyphicon-envelope', 'linktarget' => $config['target'], 'linkPopup' => $config['popup'], 'linkhint' => 'LBL_SEND_EMAIL');
         $linkModelList['DETAILVIEWBASIC'][] = Vtiger_Link_Model::getInstanceFromValues($basicActionLink);
     }
     //TODO: update the database so that these separate handlings are not required
     $index = 0;
     foreach ($linkModelList['DETAILVIEW'] as $link) {
         if ($link->linklabel == 'View History' || $link->linklabel == 'Send SMS') {
             unset($linkModelList['DETAILVIEW'][$index]);
         } else {
             if ($link->linklabel == 'LBL_SHOW_ACCOUNT_HIERARCHY') {
                 $link->linklabel = 'LBL_SHOW_ACCOUNT_HIERARCHY';
                 $linkURL = 'index.php?module=Accounts&view=AccountHierarchy&record=' . $recordId;
                 $link->linkurl = 'javascript:Accounts_Detail_Js.triggerAccountHierarchy("' . $linkURL . '");';
                 unset($linkModelList['DETAILVIEW'][$index]);
                 $linkModelList['DETAILVIEW'][$index] = $link;
             }
         }
         $index++;
     }
     $CalendarActionLinks[] = array();
     $CalendarModuleModel = Vtiger_Module_Model::getInstance('Calendar');
     if ($currentUserModel->hasModuleActionPermission($CalendarModuleModel->getId(), 'EditView')) {
         $CalendarActionLinks[] = array('linktype' => 'DETAILVIEW', 'linklabel' => 'LBL_ADD_EVENT', 'linkurl' => $recordModel->getCreateEventUrl(), 'linkicon' => 'glyphicon glyphicon-time');
         $CalendarActionLinks[] = array('linktype' => 'DETAILVIEW', 'linklabel' => 'LBL_ADD_TASK', 'linkurl' => $recordModel->getCreateTaskUrl(), 'linkicon' => 'glyphicon glyphicon-calendar');
     }
     $SMSNotifierModuleModel = Vtiger_Module_Model::getInstance('SMSNotifier');
     if (!empty($SMSNotifierModuleModel) && $currentUserModel->hasModulePermission($SMSNotifierModuleModel->getId())) {
         $basicActionLink = array('linktype' => 'DETAILVIEWBASIC', 'linklabel' => 'LBL_SEND_SMS', 'linkurl' => 'javascript:Vtiger_Detail_Js.triggerSendSms("index.php?module=' . $this->getModule()->getName() . '&view=MassActionAjax&mode=showSendSMSForm","SMSNotifier");', 'linkicon' => 'glyphicon glyphicon-comment', 'title' => vtranslate('LBL_SEND_SMS'));
         $linkModelList['DETAILVIEW'][] = Vtiger_Link_Model::getInstanceFromValues($basicActionLink);
     }
     foreach ($CalendarActionLinks as $basicLink) {
         $linkModelList['DETAILVIEW'][] = Vtiger_Link_Model::getInstanceFromValues($basicLink);
     }
     if (Users_Privileges_Model::isPermitted($moduleModel->getName(), 'ConvertLead', $recordModel->getId()) && Users_Privileges_Model::isPermitted($moduleModel->getName(), 'EditView', $recordModel->getId())) {
         $basicActionLink = array('linktype' => 'DETAILVIEWBASIC', 'linklabel' => '', 'linkclass' => 'btn-info btn-convertLead', 'linkhint' => vtranslate('LBL_CONVERT_LEAD', $moduleName), 'linkurl' => 'javascript:Leads_Detail_Js.convertLead("' . $recordModel->getConvertLeadUrl() . '",this);', 'linkicon' => 'glyphicon glyphicon-transfer', 'linkgrupclass' => !Leads_Module_Model::checkIfAllowedToConvert($recordModel->get('leadstatus')) ? 'hide' : '');
         $linkModelList['DETAILVIEWBASIC'][] = Vtiger_Link_Model::getInstanceFromValues($basicActionLink);
     }
     return $linkModelList;
 }
Example #3
0
 function checkPermission(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $currentUserPriviligesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
     if (!$currentUserPriviligesModel->hasModuleActionPermission($moduleModel->getId(), 'ConvertLead')) {
         throw new AppException(vtranslate('LBL_PERMISSION_DENIED', $moduleName));
     }
     $recordId = $request->get('record');
     $recordModel = Vtiger_Record_Model::getInstanceById($recordId);
     if (!Leads_Module_Model::checkIfAllowedToConvert($recordModel->get('leadstatus'))) {
         throw new AppException(vtranslate('LBL_PERMISSION_DENIED', $moduleName));
     }
 }
Example #4
0
 function checkPermission(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $currentUserPriviligesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
     if (!$currentUserPriviligesModel->hasModuleActionPermission($moduleModel->getId(), 'ConvertLead')) {
         throw new NoPermittedException('LBL_PERMISSION_DENIED');
     }
     $recordPermission = Users_Privileges_Model::isPermitted($moduleName, 'Save', $recordId);
     if (!$recordPermission) {
         throw new NoPermittedToRecordException('LBL_NO_PERMISSIONS_FOR_THE_RECORD');
     }
     $recordId = $request->get('record');
     $recordModel = Vtiger_Record_Model::getInstanceById($recordId);
     if (!Leads_Module_Model::checkIfAllowedToConvert($recordModel->get('leadstatus'))) {
         throw new NoPermittedException('LBL_PERMISSION_DENIED');
     }
 }