[ 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 Accounts_Module_Model extends Vtiger_Module_Model { 12 13 /** 14 * Function to get the Quick Links for the module 15 * @param <Array> $linkParams 16 * @return <Array> List of Vtiger_Link_Model instances 17 */ 18 public function getSideBarLinks($linkParams) { 19 $parentQuickLinks = parent::getSideBarLinks($linkParams); 20 21 $quickLink = array( 22 'linktype' => 'SIDEBARLINK', 23 'linklabel' => 'LBL_DASHBOARD', 24 'linkurl' => $this->getDashBoardUrl(), 25 'linkicon' => '', 26 ); 27 28 //Check profile permissions for Dashboards 29 $moduleModel = Vtiger_Module_Model::getInstance('Dashboard'); 30 $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel(); 31 $permission = $userPrivilegesModel->hasModulePermission($moduleModel->getId()); 32 if($permission) { 33 $parentQuickLinks['SIDEBARLINK'][] = Vtiger_Link_Model::getInstanceFromValues($quickLink); 34 } 35 36 return $parentQuickLinks; 37 } 38 39 /** 40 * Function to get list view query for popup window 41 * @param <String> $sourceModule Parent module 42 * @param <String> $field parent fieldname 43 * @param <Integer> $record parent id 44 * @param <String> $listQuery 45 * @return <String> Listview Query 46 */ 47 public function getQueryByModuleField($sourceModule, $field, $record, $listQuery) { 48 if (($sourceModule == 'Accounts' && $field == 'account_id' && $record) 49 || in_array($sourceModule, array('Campaigns', 'Products', 'Services', 'Emails'))) { 50 51 if ($sourceModule === 'Campaigns') { 52 $condition = " vtiger_account.accountid NOT IN (SELECT accountid FROM vtiger_campaignaccountrel WHERE campaignid = '$record')"; 53 } elseif ($sourceModule === 'Products') { 54 $condition = " vtiger_account.accountid NOT IN (SELECT crmid FROM vtiger_seproductsrel WHERE productid = '$record')"; 55 } elseif ($sourceModule === 'Services') { 56 $condition = " vtiger_account.accountid NOT IN (SELECT relcrmid FROM vtiger_crmentityrel WHERE crmid = '$record' UNION SELECT crmid FROM vtiger_crmentityrel WHERE relcrmid = '$record') "; 57 } elseif ($sourceModule === 'Emails') { 58 $condition = ' vtiger_account.emailoptout = 0'; 59 } else { 60 $condition = " vtiger_account.accountid != '$record'"; 61 } 62 63 $position = stripos($listQuery, 'where'); 64 if($position) { 65 $split = spliti('where', $listQuery); 66 $overRideQuery = $split[0] . ' WHERE ' . $split[1] . ' AND ' . $condition; 67 } else { 68 $overRideQuery = $listQuery. ' WHERE ' . $condition; 69 } 70 return $overRideQuery; 71 } 72 } 73 74 /** 75 * Function to get relation query for particular module with function name 76 * @param <record> $recordId 77 * @param <String> $functionName 78 * @param Vtiger_Module_Model $relatedModule 79 * @return <String> 80 */ 81 public function getRelationQuery($recordId, $functionName, $relatedModule) { 82 if ($functionName === 'get_activities') { 83 $focus = CRMEntity::getInstance($this->getName()); 84 $focus->id = $recordId; 85 $entityIds = $focus->getRelatedContactsIds(); 86 $entityIds = implode(',', $entityIds); 87 88 $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users'); 89 90 $query = "SELECT CASE WHEN (vtiger_users.user_name not like '') THEN $userNameSql ELSE vtiger_groups.groupname END AS user_name, 91 vtiger_crmentity.*, vtiger_activity.activitytype, vtiger_activity.subject, vtiger_activity.date_start, vtiger_activity.time_start, 92 vtiger_activity.recurringtype, vtiger_activity.due_date, vtiger_activity.time_end, vtiger_activity.visibility, vtiger_seactivityrel.crmid AS parent_id, 93 CASE WHEN (vtiger_activity.activitytype = 'Task') THEN (vtiger_activity.status) ELSE (vtiger_activity.eventstatus) END AS status 94 FROM vtiger_activity 95 INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_activity.activityid 96 LEFT JOIN vtiger_seactivityrel ON vtiger_seactivityrel.activityid = vtiger_activity.activityid 97 LEFT JOIN vtiger_cntactivityrel ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid 98 LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid 99 LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid 100 WHERE vtiger_crmentity.deleted = 0 AND vtiger_activity.activitytype <> 'Emails' 101 AND (vtiger_seactivityrel.crmid = ".$recordId; 102 if($entityIds) { 103 $query .= " OR vtiger_cntactivityrel.contactid IN (".$entityIds."))"; 104 } else { 105 $query .= ")"; 106 } 107 108 $relatedModuleName = $relatedModule->getName(); 109 $query .= $this->getSpecificRelationQuery($relatedModuleName); 110 $nonAdminQuery = $this->getNonAdminAccessControlQueryForRelation($relatedModuleName); 111 if ($nonAdminQuery) { 112 $query = appendFromClauseToQuery($query, $nonAdminQuery); 113 } 114 115 // There could be more than one contact for an activity. 116 $query .= ' GROUP BY vtiger_activity.activityid'; 117 } else { 118 $query = parent::getRelationQuery($recordId, $functionName, $relatedModule); 119 } 120 121 return $query; 122 } 123 }
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 |