private static function loadBulk($entityTypeID, array &$entityIDs, array &$itemMap, array $options = null) { /** @var DuplicateEntityRanking[] $itemMap */ if ($entityTypeID !== \CCrmOwnerType::Contact && $entityTypeID !== \CCrmOwnerType::Company && $entityTypeID !== \CCrmOwnerType::Lead) { return; } if (!is_array($options)) { $options = array(); } $checkPermissions = isset($options['CHECK_PERMISSIONS']) ? (bool) $options['CHECK_PERMISSIONS'] : false; $userID = isset($options['USER_ID']) ? (int) $options['USER_ID'] : 0; $permissions = $checkPermissions ? \CCrmPerms::GetUserPermissions($userID) : null; $limit = isset($options['LIMIT']) ? (int) $options['LIMIT'] : 3000; if ($limit <= 0) { $limit = 3000; } $length = count($entityIDs); if ($length === 0) { return; } while ($length > 0) { if ($length <= $limit) { $ids = $entityIDs; unset($entityIDs); $entityIDs = array(); } else { $ids = array_splice($entityIDs, 0, $limit); } $length = count($entityIDs); if (empty($ids)) { continue; } if ($entityTypeID === \CCrmOwnerType::Lead) { $dbResult = Entity\DuplicateEntityStatisticsTable::getList(array('select' => array('ENTITY_ID', 'RANKING_DATA'), 'filter' => array('ENTITY_TYPE_ID' => \CCrmOwnerType::Lead, 'ENTITY_ID' => $ids))); while ($fields = $dbResult->fetch()) { $entityID = intval($fields['ENTITY_ID']); $key = "{$entityTypeID}_{$entityID}"; if (!isset($itemMap[$key])) { continue; } if (isset($fields['RANKING_DATA']) && $fields['RANKING_DATA'] !== '') { $data = unserialize($fields['RANKING_DATA']); /** @var DuplicateEntityRanking $ranking */ $ranking = $itemMap[$key]; $ranking->lastChanged = isset($data['LAST_CHANGED']) ? $data['LAST_CHANGED'] : 0; $ranking->completeness = isset($data['COMPLETENESS']) ? $data['COMPLETENESS'] : 0; if ($checkPermissions) { $ranking->editable = \CCrmLead::CheckUpdatePermission($entityID, $permissions); $ranking->deleteable = \CCrmLead::CheckDeletePermission($entityID, $permissions); } } } } else { $query = new Main\Entity\Query(Entity\DuplicateEntityStatisticsTable::getEntity()); $query->addSelect('ENTITY_ID'); $query->addSelect('RANKING_DATA'); $query->addFilter('ENTITY_ID', $ids); $query->addFilter('ENTITY_TYPE_ID', $entityTypeID); if ($entityTypeID === \CCrmOwnerType::Contact) { $subQuery = new Main\Entity\Query(DealTable::getEntity()); $subQuery->addSelect('CONTACT_ID'); $subQuery->addFilter('CONTACT_ID', $ids); $subQuery->addSelect('QTY'); $subQuery->registerRuntimeField('', new Main\Entity\ExpressionField('QTY', 'COUNT(*)')); $referenceField = new Main\Entity\ReferenceField('D', Main\Entity\Base::getInstanceByQuery($subQuery), array('=this.ENTITY_ID' => 'ref.CONTACT_ID'), array('join_type' => 'LEFT')); } else { $subQuery = new Main\Entity\Query(DealTable::getEntity()); $subQuery->addSelect('COMPANY_ID'); $subQuery->addFilter('COMPANY_ID', $ids); $subQuery->addSelect('QTY'); $subQuery->registerRuntimeField('', new Main\Entity\ExpressionField('QTY', 'COUNT(*)')); $referenceField = new Main\Entity\ReferenceField('D', Main\Entity\Base::getInstanceByQuery($subQuery), array('=this.ENTITY_ID' => 'ref.COMPANY_ID'), array('join_type' => 'LEFT')); } $query->registerRuntimeField('', $referenceField); $query->addSelect('D.QTY', 'QTY'); $dbResult = $query->exec(); while ($fields = $dbResult->fetch()) { $entityID = intval($fields['ENTITY_ID']); $key = "{$entityTypeID}_{$entityID}"; if (!isset($itemMap[$key])) { continue; } $itemMap[$key]->referenceCount = isset($fields['QTY']) ? intval($fields['QTY']) : 0; if (isset($fields['RANKING_DATA']) && $fields['RANKING_DATA'] !== '') { $data = unserialize($fields['RANKING_DATA']); /** @var DuplicateEntityRanking $ranking */ $ranking = $itemMap[$key]; $ranking->lastChanged = isset($data['LAST_CHANGED']) ? $data['LAST_CHANGED'] : 0; $ranking->completeness = isset($data['COMPLETENESS']) ? $data['COMPLETENESS'] : 0; if ($checkPermissions) { if ($entityTypeID === \CCrmOwnerType::Contact) { $ranking->editable = \CCrmContact::CheckUpdatePermission($entityID, $permissions); $ranking->deleteable = \CCrmContact::CheckDeletePermission($entityID, $permissions); } else { $ranking->editable = \CCrmCompany::CheckUpdatePermission($entityID, $permissions); $ranking->deleteable = \CCrmCompany::CheckDeletePermission($entityID, $permissions); } } } } } } }
public static function CheckAuth() { $CCrmPerms = new CCrmPerms($GLOBALS['USER']->GetID()); if ($CCrmPerms->HavePerm('LEAD', BX_CRM_PERM_NONE)) { return new CSOAPFault('Server Error', 'Unable to authorize user.'); } return false; }
/** * Function checks if user have basic permissions to launch the component * @throws Exception * @return void */ protected function checkPermissions() { $result = true; $CrmPerms = new CCrmPerms($GLOBALS['USER']->GetID()); if (!$CrmPerms->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'WRITE')) { $this->errors['FATAL'][] = Loc::getMessage('CRM_CLE2_PERMISSION_DENIED'); $result = false; } return $result; }
public static function GetUserPermissions() { if (self::$USER_PERMISSIONS === null) { self::$USER_PERMISSIONS = CCrmPerms::GetCurrentUserPermissions(); } return self::$USER_PERMISSIONS; }
/** * @return \CCrmPerms */ protected function getUserPermissions() { if ($this->userPermissions === null) { $this->userPermissions = \CCrmPerms::GetCurrentUserPermissions(); } return $this->userPermissions; }
public function checkRights() { $permissions = CCrmPerms::GetCurrentUserPermissions(); if (!(CCrmPerms::IsAccessEnabled($permissions) && $permissions->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'READ'))) { return false; } return true; }
/** * @return string|boolean */ protected function preparePermissionSql() { if ($this->permissionSql !== null) { return $this->permissionSql; } if (\CCrmPerms::IsAdmin($this->userID)) { $this->permissionSql = ''; } else { $this->permissionSql = \CCrmPerms::BuildSql(\CCrmOwnerType::DealName, '', 'READ', array('RAW_QUERY' => true, 'PERMS' => \CCrmPerms::GetUserPermissions($this->userID))); } return $this->permissionSql; }
protected static function checkAccessPermissions($parameters = array()) { if (!is_array($parameters)) { $parameters = array(); } $errors = array(); $CCrmPerms = new CCrmPerms($GLOBALS['USER']->GetID()); if ($CCrmPerms->HavePerm('CONFIG', BX_CRM_PERM_NONE, 'WRITE')) { $errors[] = Loc::getMessage("SALE_CCLI2_CRM_MODULE_WRITE_ACCESS_DENIED"); } if (!LocationHelper::checkLocationEnabled()) { $errors[] = 'Locations were disabled or data has not been converted'; } if ($parameters['CHECK_CSRF']) { $post = \Bitrix\Main\Context::getCurrent()->getRequest()->getPostList(); if (!strlen($post['csrf']) || bitrix_sessid() != $post['csrf']) { $errors[] = 'CSRF token is not valid'; } } return $errors; }
/** * @return Duplicate */ public function createDuplicate($entityTypeID, $rootEntityID, $userID, $enablePermissionCheck, $enableRanking, $limit = 0) { if ($entityTypeID !== \CCrmOwnerType::Lead && $entityTypeID !== \CCrmOwnerType::Contact && $entityTypeID !== \CCrmOwnerType::Company) { throw new Main\NotSupportedException("Entity type: '" . \CCrmOwnerType::ResolveName($entityTypeID) . "' is not supported in current context"); } /** @var Duplicate $dup **/ $dup = new Duplicate($this, array()); $query = static::createQuery(); $query->addSelect('ENTITY_ID'); $query->addFilter('=ENTITY_TYPE_ID', $entityTypeID); static::setQueryFilter($query, $this->getMatches()); if ($enablePermissionCheck) { $permissions = isset($params['PERMISSIONS']) ? $params['PERMISSIONS'] : null; if ($permissions === null) { $permissions = \CCrmPerms::GetUserPermissions($userID); } $permissionSql = \CCrmPerms::BuildSql(\CCrmOwnerType::ResolveName($entityTypeID), '', 'READ', array('RAW_QUERY' => true, 'PERMS' => $permissions)); if ($permissionSql === false) { //Access denied; return null; } if ($permissionSql !== '') { $query->addFilter('@ENTITY_ID', new Main\DB\SqlExpression($permissionSql)); } } if ($limit > 0) { $query->setLimit($limit); } if ($rootEntityID > 0) { $dup->setRootEntityID($rootEntityID); $query->addFilter('!ENTITY_ID', $rootEntityID); $query->addFilter('!@ENTITY_ID', DuplicateIndexMismatch::prepareQueryField($this, $entityTypeID, $rootEntityID, $userID)); } $dbResult = $query->exec(); $rankings = array(); while ($fields = $dbResult->fetch()) { $entityID = isset($fields['ENTITY_ID']) ? intval($fields['ENTITY_ID']) : 0; if ($entityID <= 0) { continue; } $entity = new DuplicateEntity($entityTypeID, $entityID); if ($enableRanking) { $rankings[] = $entity->getRanking(); } $dup->addEntity($entity); } $this->onAfterDuplicateCreated($dup, $entityTypeID, $userID, $enablePermissionCheck, $enableRanking, $rankings); if ($enableRanking) { DuplicateEntityRanking::initializeBulk($rankings, array('CHECK_PERMISSIONS' => $enablePermissionCheck, 'USER_ID' => $userID)); } return $dup; }
protected function preparePermissionSql() { if ($this->permissionSql !== null) { return $this->permissionSql; } $userID = $this->getUserID(); if (\CCrmPerms::IsAdmin($userID)) { $this->permissionSql = ''; } else { $this->permissionSql = \CCrmPerms::BuildSql(\CCrmOwnerType::ResolveName($this->getEntityTypeID()), '', 'READ', array('RAW_QUERY' => true, 'PERMS' => \CCrmPerms::GetUserPermissions($userID))); } return $this->permissionSql; }
public function canRead($userId) { if ($this->canRead !== null) { return $this->canRead; } /** @noinspection PhpDynamicAsStaticMethodCallInspection */ if (\CSocNetUser::isCurrentUserModuleAdmin()) { $this->canRead = true; return $this->canRead; } if ($comment = $this->loadLogCommentData()) { if (strpos($comment["EVENT_ID"], "crm_") === 0) { $queryLog = \CSocNetLog::getList(array(), array("ID" => intval($comment["LOG_ID"])), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID")); if (($log = $queryLog->fetch()) && Loader::includeModule("crm")) { $userPermissions = \CCrmPerms::getUserPermissions($userId); if ($log["ENTITY_TYPE"] == "CRMACTIVITY") { $bindings = \CCRMActivity::getBindings($log["ENTITY_ID"]); foreach ($bindings as $binding) { if (\CCrmAuthorizationHelper::checkReadPermission(\CCrmOwnerType::resolveName($binding["OWNER_TYPE_ID"]), $binding["OWNER_ID"], $userPermissions)) { $this->canRead = true; return $this->canRead; } } } else { if (\CCrmAuthorizationHelper::checkReadPermission(\CCrmLiveFeedEntity::resolveEntityTypeID($log["ENTITY_TYPE"]), $log["ENTITY_ID"], $userPermissions)) { $this->canRead = true; return $this->canRead; } elseif (intval($comment["LOG_ID"]) > 0 && \CSocNetLogRights::checkForUser($comment["LOG_ID"], $userId)) { $this->canRead = true; return $this->canRead; } } } } elseif (intval($comment["LOG_ID"]) > 0 && \CSocNetLogRights::checkForUser($comment["LOG_ID"], $userId)) { $this->canRead = true; return $this->canRead; } } $this->canRead = false; return $this->canRead; }
<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die; } if (!CModule::IncludeModule('crm')) { return; } $CrmPerms = new CCrmPerms($USER->GetID()); if ($CrmPerms->HavePerm('INVOICE', BX_CRM_PERM_NONE)) { return; } $arParams['PATH_TO_INVOICE_LIST'] = CrmCheckPath('PATH_TO_INVOICE_LIST', $arParams['PATH_TO_INVOICE_LIST'], $APPLICATION->GetCurPage()); $arParams['PATH_TO_INVOICE_SHOW'] = CrmCheckPath('PATH_TO_INVOICE_SHOW', $arParams['PATH_TO_INVOICE_SHOW'], $APPLICATION->GetCurPage() . '?invoice_id=#invoice_id#&show'); $arParams['PATH_TO_INVOICE_PAYMENT'] = CrmCheckPath('PATH_TO_INVOICE_PAYMENT', $arParams['PATH_TO_INVOICE_PAYMENT'], $APPLICATION->GetCurPage() . '?invoice_id=#invoice_id#&payment'); $arParams['PATH_TO_INVOICE_EDIT'] = CrmCheckPath('PATH_TO_INVOICE_EDIT', $arParams['PATH_TO_INVOICE_EDIT'], $APPLICATION->GetCurPage() . '?invoice_id=#invoice_id#&edit'); if (!isset($arParams['TYPE'])) { $arParams['TYPE'] = 'list'; } if (isset($_REQUEST['copy'])) { $arParams['TYPE'] = 'copy'; } $arResult['TYPE'] = $arParams['TYPE']; $arResult['BUTTONS'] = array(); $arFields = array(); $arParams['ELEMENT_ID'] = intval($arParams['ELEMENT_ID']); if ($arParams['TYPE'] == 'list') { $bRead = !$CrmPerms->HavePerm('INVOICE', BX_CRM_PERM_NONE, 'READ'); $bExport = !$CrmPerms->HavePerm('INVOICE', BX_CRM_PERM_NONE, 'EXPORT'); $bImport = !$CrmPerms->HavePerm('INVOICE', BX_CRM_PERM_NONE, 'IMPORT'); $bAdd = !$CrmPerms->HavePerm('INVOICE', BX_CRM_PERM_NONE, 'ADD');
} $arResult['ENTITY_ID'] = $entityID; if ($entityTypeID <= CCrmOwnerType::Undefined) { ShowError(GetMessage('CRM_PRODUCT_LIST_OWNER_TYPE_NOT_DEFINED')); return; } if ($entityTypeID !== CCrmOwnerType::Deal && $entityTypeID !== CCrmOwnerType::Lead && $entityTypeID !== CCrmOwnerType::Invoice) { ShowError(GetMessage('CRM_PRODUCT_LIST_OWNER_TYPE_NOT_SUPPORTED')); return; } if ($entityID <= 0) { ShowError(GetMessage('CRM_PRODUCT_LIST_OWNER_ID_NOT_DEFINED')); return; } $entityTypeName = CCrmOwnerType::ResolveName($entityTypeID); $userPerms = CCrmPerms::GetCurrentUserPermissions(); if (!CCrmAuthorizationHelper::CheckReadPermission($entityTypeName, $entityID, $userPerms)) { ShowError(GetMessage('CRM_PERMISSION_DENIED')); return; } $arParams['UID'] = isset($arParams['UID']) ? $arParams['UID'] : ''; if (!isset($arParams['UID']) || $arParams['UID'] === '') { $arParams['UID'] = 'mobile_crm_product_row_list'; } $arResult['UID'] = $arParams['UID']; $arResult['ITEMS'] = array(); $arResult['TAX_MODE'] = 'NONE'; if ($entityTypeID === CCrmOwnerType::Deal) { $dbRes = CCrmDeal::GetListEx(array(), array('ID' => $entityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('TITLE', 'CURRENCY_ID', 'OPPORTUNITY')); $arOwner = $dbRes ? $dbRes->Fetch() : null; if ($arOwner) {
$arResult['CONTACT'][$iContactId]['EDIT'] = $CCrmPerms->CheckEnityAccess('CONTACT', 'WRITE', $arContactAttr[$iContactId]); $arResult['CONTACT'][$iContactId]['DELETE'] = $CCrmPerms->CheckEnityAccess('CONTACT', 'DELETE', $arContactAttr[$iContactId]); $arResult['CONTACT'][$iContactId]['BIZPROC_LIST'] = array(); foreach ($arBPData as $arBP) { if (!CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::StartWorkflow, $userID, array('crm', 'CCrmDocumentContact', 'CONTACT_' . $arResult['CONTACT'][$iContactId]['ID']), array('UserGroups' => $CCrmBizProc->arCurrentUserGroups, 'DocumentStates' => $arDocumentStates, 'WorkflowTemplateId' => $arBP['ID'], 'CreatedBy' => $arResult['CONTACT'][$iContactId]['ASSIGNED_BY'], 'UserIsAdmin' => $isAdmin, 'CRMEntityAttr' => $arContactAttr[$iContactId]))) { continue; } $arBP['PATH_TO_BIZPROC_START'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_SHOW'], array('contact_id' => $arResult['CONTACT'][$iContactId]['ID'])), array('workflow_template_id' => $arBP['ID'], 'bizproc_start' => 1, 'sessid' => $arResult['SESSION_ID'], 'CRM_CONTACT_SHOW_V12_active_tab' => 'tab_bizproc', 'back_url' => $arParams['PATH_TO_CONTACT_LIST'])); $arResult['CONTACT'][$iContactId]['BIZPROC_LIST'][] = $arBP; } } } if (!$isInExportMode) { $arResult['NEED_FOR_REBUILD_DUP_INDEX'] = false; $arResult['NEED_FOR_REBUILD_CONTACT_ATTRS'] = false; if (!$bInternal && CCrmPerms::IsAdmin()) { if (COption::GetOptionString('crm', '~CRM_REBUILD_CONTACT_DUP_INDEX', 'N') === 'Y') { $arResult['NEED_FOR_REBUILD_DUP_INDEX'] = true; } if (COption::GetOptionString('crm', '~CRM_REBUILD_CONTACT_ATTR', 'N') === 'Y') { $arResult['PATH_TO_PRM_LIST'] = CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_perm_list')); $arResult['NEED_FOR_REBUILD_CONTACT_ATTRS'] = true; } } $this->IncludeComponentTemplate(); include_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/components/bitrix/crm.contact/include/nav.php'; return $arResult['ROWS_COUNT']; } else { $APPLICATION->RestartBuffer(); // hack. any '.default' customized template should contain 'excel' page $this->__templateName = '.default';
//$langID = isset($_REQUEST['lang_id'])? $_REQUEST['lang_id']: LANGUAGE_ID; //__IncludeLang(dirname(__FILE__).'/lang/'.$langID.'/'.basename(__FILE__)); CUtil::JSPostUnescape(); if (!function_exists('__CrmMobileDealEditEndResonse')) { function __CrmMobileDealEditEndResonse($result) { $GLOBALS['APPLICATION']->RestartBuffer(); Header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); if (!empty($result)) { echo CUtil::PhpToJSObject($result); } require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_after.php'; die; } } $curUserPrems = CCrmPerms::GetCurrentUserPermissions(); $action = isset($_REQUEST['ACTION']) ? $_REQUEST['ACTION'] : ''; if ($action === 'SAVE_ENTITY') { __IncludeLang(dirname(__FILE__) . '/lang/' . LANGUAGE_ID . '/' . basename(__FILE__)); $typeName = isset($_REQUEST['ENTITY_TYPE_NAME']) ? $_REQUEST['ENTITY_TYPE_NAME'] : ''; if ($typeName !== CCrmOwnerType::DealName) { __CrmMobileDealEditEndResonse(array('ERROR' => GetMessage('CRM_ENTITY_TYPE_NOT_SUPPORTED', array('#ENTITY_TYPE#' => $typeName)))); } $data = isset($_REQUEST['ENTITY_DATA']) && is_array($_REQUEST['ENTITY_DATA']) ? $_REQUEST['ENTITY_DATA'] : array(); if (count($data) == 0) { __CrmMobileDealEditEndResonse(array('ERROR' => GetMessage('CRM_ENTITY_DATA_NOT_FOUND'))); } $ID = isset($data['ID']) ? intval($data['ID']) : 0; $isNew = $ID <= 0; $hasPermission = $isNew ? CCrmDeal::CheckCreatePermission() : CCrmDeal::CheckUpdatePermission($ID); if (!$hasPermission) {
public function Prepare($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array(), $arOptions = array()) { global $DB; if (!is_array($arOrder)) { $arOrder = array(); } if (!is_array($arFilter)) { $arFilter = array(); } // ID must present in select (If select is empty it will be filled by CSqlUtil::PrepareSql) if (!is_array($arSelectFields)) { $arSelectFields = array(); } if (count($arSelectFields) > 0 && !in_array('*', $arSelectFields, true) && !in_array('ID', $arSelectFields, true)) { $arSelectFields[] = 'ID'; } if (!is_array($arOptions)) { $arOptions = array(); } $arOptions['DB_TYPE'] = $this->dbType; $isExternalContext = isset($arOptions['IS_EXTERNAL_CONTEXT']) && ($arOptions['IS_EXTERNAL_CONTEXT'] === true || $arOptions['IS_EXTERNAL_CONTEXT'] === 'Y'); if ($isExternalContext) { // Sanitizing of filter data if (isset($arFilter['__JOINS'])) { unset($arFilter['__JOINS']); } if (isset($arFilter['CHECK_PERMISSIONS'])) { unset($arFilter['CHECK_PERMISSIONS']); } } // Processing of special fields if ($this->fmEntityID !== '' && isset($arFilter['FM'])) { CCrmFieldMulti::PrepareExternalFilter($arFilter, array('ENTITY_ID' => $this->fmEntityID, 'MASTER_ALIAS' => $this->tableAlias, 'MASTER_IDENTITY' => 'ID')); } // Processing user fields $ufSelectSql = null; $ufFilterSql = null; if ($this->ufEntityID !== '') { $ufSelectSql = new CUserTypeSQL(); $ufSelectSql->SetEntity($this->ufEntityID, $this->tableAlias . '.ID'); $ufSelectSql->SetSelect($arSelectFields); $ufSelectSql->SetOrder($arOrder); $ufFilterSql = new CUserTypeSQL(); $ufFilterSql->SetEntity($this->ufEntityID, $this->tableAlias . '.ID'); $ufFilterSql->SetFilter($arFilter); $userType = new CCrmUserType($GLOBALS['USER_FIELD_MANAGER'], $this->ufEntityID); $userType->ListPrepareFilter($arFilter); } $this->sqlData = CSqlUtil::PrepareSql($this->fields, $arOrder, $arFilter, $arGroupBy, $arSelectFields, $arOptions); $this->sqlData['SELECT'] = str_replace('%%_DISTINCT_%% ', '', $this->sqlData['SELECT']); // 'Joins' implement custom filter logic $joins = array(); if (isset($arFilter['__JOINS'])) { if (is_array($arFilter['__JOINS'])) { $joins = $arFilter['__JOINS']; } unset($arFilter['__JOINS']); } if (count($joins) > 0) { foreach ($joins as &$join) { // INNER JOINs will be added tostart $this->Add2SqlData($join['SQL'], 'FROM', !isset($join['TYPE']) || $join['TYPE'] === 'INNER', isset($join['REPLACE']) ? $join['REPLACE'] : ''); } unset($join); } // Apply user permission logic if (count($this->permissionCallback) > 0) { if ((!array_key_exists('CHECK_PERMISSIONS', $arFilter) || $arFilter['CHECK_PERMISSIONS'] !== 'N') && !CCrmPerms::IsAdmin()) { $arPermType = !isset($arFilter['PERMISSION']) ? 'READ' : (is_array($arFilter['PERMISSION']) ? $arFilter['PERMISSION'] : array($arFilter['PERMISSION'])); $permissionSql = call_user_func_array($this->permissionCallback, array($this->tableAlias, $arPermType, $arOptions)); if (is_bool($permissionSql) && !$permissionSql) { $CDBResult = new CDBResult(); $CDBResult->InitFromArray(array()); return $CDBResult; } if ($permissionSql !== '') { $sqlType = isset($arOptions['PERMISSION_SQL_TYPE']) && $arOptions['PERMISSION_SQL_TYPE'] === 'FROM' ? 'FROM' : 'WHERE'; $this->Add2SqlData($permissionSql, $sqlType, $sqlType === 'FROM'); } } } // Apply custom SQL logic if (count($this->afterPrepareSqlCallback) > 0) { $arUserSql = call_user_func_array($this->afterPrepareSqlCallback, array($this, $arOrder, $arFilter, $arGroupBy, $arSelectFields)); if (is_array($arUserSql)) { if (isset($arUserSql['FROM'])) { $this->Add2SqlData($arUserSql['FROM'], 'FROM'); } if (isset($arUserSql['WHERE'])) { $this->Add2SqlData($arUserSql['WHERE'], 'WHERE'); } } } if ($ufSelectSql) { // Adding user fields to SELECT $this->Add2SqlData($ufSelectSql->GetSelect(), 'SELECT'); // Adding user fields to ORDER BY if (is_array($arOrder)) { foreach ($arOrder as $orderKey => $order) { $orderSql = $ufSelectSql->GetOrder($orderKey); if (!is_string($orderSql) || $orderSql === '') { continue; } $order = strtoupper($order); if ($order !== 'ASC' && $order !== 'DESC') { $order = 'ASC'; } $this->Add2SqlData("{$orderSql} {$order}", 'ORDERBY'); } } // Adding user fields to joins $this->Add2SqlData($ufSelectSql->GetJoin($this->tableAlias . '.ID'), 'FROM'); } if ($ufFilterSql) { // Adding user fields to WHERE $ufWhere = $ufFilterSql->GetFilter(); if ($ufWhere !== '') { $ufSql = $this->tableAlias . '.ID IN (SELECT ' . $this->tableAlias . '.ID FROM ' . $this->tableName . ' ' . $this->tableAlias . ' ' . $ufFilterSql->GetJoin($this->tableAlias . '.ID') . ' WHERE ' . $ufWhere . ')'; // Adding user fields to joins $this->Add2SqlData($ufSql, 'WHERE'); } } //Get count only if (is_array($arGroupBy) && count($arGroupBy) == 0) { return $this->GetRowCount(RestrictionManager::getSqlRestriction()->getRowCountThreshold()); } $sql = 'SELECT ' . $this->sqlData['SELECT'] . ' FROM ' . $this->tableName . ' ' . $this->tableAlias; if (isset($this->sqlData['FROM'][0])) { $sql .= ' ' . $this->sqlData['FROM']; } if (isset($this->sqlData['WHERE'][0])) { $sql .= ' WHERE ' . $this->sqlData['WHERE']; } if (isset($this->sqlData['GROUPBY'][0])) { $sql .= ' GROUP BY ' . $this->sqlData['GROUPBY']; } if (isset($this->sqlData['ORDERBY'][0])) { $sql .= ' ORDER BY ' . $this->sqlData['ORDERBY']; } $enableNavigation = is_array($arNavStartParams); $top = $enableNavigation && isset($arNavStartParams['nTopCount']) ? intval($arNavStartParams['nTopCount']) : 0; if ($enableNavigation && $top <= 0) { $dbRes = new CDBResult(); if ($this->ufEntityID !== '') { $dbRes->SetUserFields($GLOBALS['USER_FIELD_MANAGER']->GetUserFields($this->ufEntityID)); } elseif (!empty($this->userFields)) { $dbRes->SetUserFields($this->userFields); } //Trace('CCrmEntityListBuilder::Prepare, SQL', $sql, 1); $cnt = $this->GetRowCount(RestrictionManager::getSqlRestriction()->getRowCountThreshold()); $dbRes->NavQuery($sql, $cnt, $arNavStartParams); } else { $limit = $top; $offset = 0; if (isset($arOptions['QUERY_OPTIONS']) && is_array($arOptions['QUERY_OPTIONS'])) { $queryOptions = $arOptions['QUERY_OPTIONS']; $limit = isset($queryOptions['LIMIT']) ? (int) $queryOptions['LIMIT'] : 0; $offset = isset($queryOptions['OFFSET']) ? (int) $queryOptions['OFFSET'] : 0; } $threshold = RestrictionManager::getSqlRestriction()->getRowCountThreshold(); if ($threshold > 0 && $threshold < $limit + $offset) { $delta = $threshold - $offset; if ($delta <= 0) { $obRes = new CDBResult(); $obRes->InitFromArray(array()); return $obRes; } $limit = $delta; } if ($limit > 0) { $sql = Main\Application::getConnection()->getSqlHelper()->getTopSql($sql, $limit, $offset); } //Trace('CCrmEntityListBuilder::Prepare, SQL', $sql, 1); $dbRes = $DB->Query($sql, false, 'File: ' . __FILE__ . '<br/>Line: ' . __LINE__); if ($this->ufEntityID !== '') { $dbRes->SetUserFields($GLOBALS['USER_FIELD_MANAGER']->GetUserFields($this->ufEntityID)); } elseif (!empty($this->userFields)) { $dbRes->SetUserFields($this->userFields); } } return $dbRes; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if (!CModule::IncludeModule("crm")) { return; } global $USER; $CCrmPerms = new CCrmPerms($USER->GetID()); $arSupportedTypes = array(); // all entity types are defined in settings $arSettings = $arParams['arUserField']['SETTINGS']; if (isset($arSettings['LEAD']) && $arSettings['LEAD'] === 'Y') { $arSupportedTypes[] = 'LEAD'; } if (isset($arSettings['CONTACT']) && $arSettings['CONTACT'] === 'Y') { $arSupportedTypes[] = 'CONTACT'; } if (isset($arSettings['COMPANY']) && $arSettings['COMPANY'] === 'Y') { $arSupportedTypes[] = 'COMPANY'; } if (isset($arSettings['DEAL']) && $arSettings['DEAL'] === 'Y') { $arSupportedTypes[] = 'DEAL'; } if (isset($arSettings['QUOTE']) && $arSettings['QUOTE'] === 'Y') { $arSupportedTypes[] = 'QUOTE'; } if (isset($arSettings['PRODUCT']) && $arSettings['PRODUCT'] === 'Y') { $arSupportedTypes[] = 'PRODUCT'; }
function __CrmLeadListEndResonse($result) { $GLOBALS['APPLICATION']->RestartBuffer(); Header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); if (!empty($result)) { echo CUtil::PhpToJSObject($result); } require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_after.php'; die; } } if (!CModule::IncludeModule('crm')) { __CrmLeadListEndResonse(array('ERROR' => 'Could not include crm module.')); } $userPerms = CCrmPerms::GetCurrentUserPermissions(); if (!CCrmPerms::IsAuthorized()) { __CrmLeadListEndResonse(array('ERROR' => 'Access denied.')); } $action = isset($_REQUEST['ACTION']) ? $_REQUEST['ACTION'] : ''; if (isset($_REQUEST['MODE']) && $_REQUEST['MODE'] === 'SEARCH') { if ($userPerms->HavePerm('LEAD', BX_CRM_PERM_NONE, 'READ')) { return; } __IncludeLang(dirname(__FILE__) . '/lang/' . LANGUAGE_ID . '/' . basename(__FILE__)); CUtil::JSPostUnescape(); $APPLICATION->RestartBuffer(); // Limit count of items to be found $nPageTop = 50; // 50 items by default if (isset($_REQUEST['LIMIT_COUNT']) && $_REQUEST['LIMIT_COUNT'] >= 0) { $rawNPageTop = (int) $_REQUEST['LIMIT_COUNT'];
<?php require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/header.php"; IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/intranet/public/crm/index.php"); $APPLICATION->SetTitle(GetMessage("CRM_TITLE")); $APPLICATION->SetPageProperty("BodyClass", " page-one-column"); if (CModule::IncludeModule('crm') && CCrmPerms::IsAccessEnabled()) { $APPLICATION->IncludeComponent('bitrix:crm.control_panel', '', array('ID' => 'COMPANY_LIST', 'ACTIVE_ITEM_ID' => '', 'PATH_TO_COMPANY_LIST' => '#SITE_DIR#crm/company/', 'PATH_TO_COMPANY_EDIT' => '#SITE_DIR#crm/company/edit/#company_id#/', 'PATH_TO_CONTACT_LIST' => '#SITE_DIR#crm/contact/', 'PATH_TO_CONTACT_EDIT' => '#SITE_DIR#crm/contact/edit/#contact_id#/', 'PATH_TO_DEAL_LIST' => '#SITE_DIR#crm/deal/', 'PATH_TO_DEAL_EDIT' => '#SITE_DIR#crm/deal/edit/#deal_id#/', 'PATH_TO_QUOTE_LIST' => '#SITE_DIR#crm/quote/', 'PATH_TO_QUOTE_EDIT' => '#SITE_DIR#crm/quote/edit/#quote_id#/', 'PATH_TO_INVOICE_LIST' => '#SITE_DIR#crm/invoice/', 'PATH_TO_INVOICE_EDIT' => '#SITE_DIR#crm/invoice/edit/#invoice_id#/', 'PATH_TO_LEAD_LIST' => '#SITE_DIR#crm/lead/', 'PATH_TO_LEAD_EDIT' => '#SITE_DIR#crm/lead/edit/#lead_id#/', 'PATH_TO_REPORT_LIST' => '#SITE_DIR#crm/reports/report/', 'PATH_TO_DEAL_FUNNEL' => '#SITE_DIR#crm/reports/', 'PATH_TO_EVENT_LIST' => '#SITE_DIR#crm/events/', 'PATH_TO_PRODUCT_LIST' => '#SITE_DIR#crm/product/', 'PATH_TO_SETTINGS' => '#SITE_DIR#crm/configs/', 'PATH_TO_SEARCH_PAGE' => '#SITE_DIR#search/index.php?where=crm')); $APPLICATION->IncludeComponent("bitrix:desktop", "", array("GADGETS_FIXED" => array(), "ID" => "crm", "CAN_EDIT" => "Y", "COLUMNS" => "3", "PM_URL" => "/company/personal/messages/chat/#USER_ID#/", "PATH_TO_CONPANY_DEPARTMENT" => "/company/structure.php?set_filter_structure=Y&structure_UF_DEPARTMENT=#ID#", "PATH_TO_VIDEO_CALL" => "/company/personal/video/#USER_ID#/", "NAME_TEMPLATE" => "", "SHOW_LOGIN" => "Y", "DATE_TIME_FORMAT" => LANGUAGE_ID == "en" ? "m/d/Y H:i:s" : (LANGUAGE_ID == "de" ? "d.m.Y H:i:s" : "d.m.Y H:i:s"), "DATE_FORMAT" => LANGUAGE_ID == "en" ? "m/d/Y" : (LANGUAGE_ID == "de" ? "d.m.Y" : "d.m.Y"), "DATE_FORMAT_NO_YEAR" => LANGUAGE_ID == "en" ? "m/d" : (LANGUAGE_ID == "de" ? "d.m" : "d.m"), "SHOW_YEAR" => "M", "COLUMN_WIDTH_0" => "50%", "COLUMN_WIDTH_1" => "50%", "COLUMN_WIDTH_2" => "260px", "GADGETS" => array("ALL"), "G_RSSREADER_CACHE_TIME" => "3600", "G_RSSREADER_SHOW_URL" => "N", "G_RSSREADER_PREDEFINED_RSS" => "", "GU_RSSREADER_TITLE_STD" => "", "GU_RSSREADER_CNT" => "10", "GU_RSSREADER_RSS_URL" => "", "G_VIDEO_IBLOCK_TYPE" => "", "G_VIDEO_IBLOCK_ID" => "", "G_VIDEO_LIST_URL" => "/about/media.php", "G_VIDEO_CACHE_TYPE" => "A", "G_VIDEO_CACHE_TIME" => "3600", "GU_VIDEO_TITLE_STD" => "", "G_VOTE_CHANNEL_SID" => "-", "G_VOTE_CACHE_TYPE" => "A", "G_VOTE_CACHE_TIME" => "3600", "G_VOTE_LIST_URL" => "/services/votes.php", "GU_VOTE_TITLE_STD" => "", "GU_GOOGLE_GADGETS_TITLE_STD" => "", "G_BIRTHDAY_STRUCTURE_PAGE" => "structure.php", "G_BIRTHDAY_PM_URL" => "/company/personal/messages/chat/#USER_ID#/", "G_BIRTHDAY_SHOW_YEAR" => "Y", "G_BIRTHDAY_USER_PROPERTY" => array("WORK_POSITION"), "G_BIRTHDAY_LIST_URL" => "/company/birthdays.php", "GU_BIRTHDAY_TITLE_STD" => "", "GU_BIRTHDAY_NUM_USERS" => "5", "GU_BIRTHDAY_DEPARTMENT" => "-", "G_HONOUR_LIST_URL" => "/company/leaders.php", "GU_HONOUR_TITLE_STD" => "", "GU_HONOUR_NUM_USERS" => "5", "GU_HTML_AREA_TITLE_STD" => "", "GU_FAVORITES_TITLE_STD" => "", "G_ADV_TYPE" => "-", "GU_ADV_TITLE_STD" => "", "G_TASKS_IBLOCK_ID" => "15", "G_TASKS_PAGE_VAR" => "page", "G_TASKS_GROUP_VAR" => "group_id", "G_TASKS_VIEW_VAR" => "user_id", "G_TASKS_TASK_VAR" => "task_id", "G_TASKS_ACTION_VAR" => "action", "G_TASKS_PATH_TO_GROUP_TASKS" => "/workgroups/group/#group_id#/tasks/", "G_TASKS_PATH_TO_GROUP_TASKS_TASK" => "/workgroups/group/#group_id#/tasks/task/#action#/#task_id#/", "G_TASKS_PATH_TO_USER_TASKS" => "/company/personal/user/#user_id#/tasks/", "G_TASKS_PATH_TO_USER_TASKS_TASK" => "/company/personal/user/#user_id#/tasks/task/#action#/#task_id#/", "G_TASKS_PATH_TO_TASK" => "/company/personal/user/#user_id#/tasks/", "G_TASKS_PATH_TO_TASK_NEW" => "/company/personal/user/#user_id#/tasks/task/edit/0/", "GU_TASKS_TITLE_STD" => "", "GU_TASKS_ITEMS_COUNT" => "20", "GU_TASKS_ORDER_BY" => "E", "GU_TASKS_TYPE" => "Z", "G_TICKETS_PATH_TO_TICKET_EDIT" => "/extranet/services/support.php?ID=#ID#", "G_TICKETS_PATH_TO_TICKET_NEW" => "/extranet/services/support.php?show_wizard=Y", "GU_TICKETS_TITLE_STD" => "", "GU_TICKETS_ITEMS_COUNT" => "5", "GU_TICKETS_LAMP" => array(), "G_MESSAGES_PATH_TO_USER" => "/company/personal/user/#user_id#/", "G_MESSAGES_PATH_TO_GROUP" => "/company/personal/group/#group_id#/", "G_MESSAGES_PATH_TO_MESSAGE_FORM" => "/company/personal/messages/form/#user_id#/", "G_MESSAGES_PATH_TO_MESSAGE_FORM_MESS" => "/company/personal/messages/form/#user_id#/#message_id#/", "G_MESSAGES_PATH_TO_MESSAGES_CHAT" => "/company/personal/messages/chat/#user_id#/", "G_MESSAGES_PATH_TO_SMILE" => "/bitrix/images/socialnetwork/smile/", "G_MESSAGES_AJAX_LONG_TIMEOUT" => "60", "G_MESSAGES_MESSAGE_VAR" => "message_id", "G_MESSAGES_PAGE_VAR" => "page", "G_MESSAGES_USER_VAR" => "user_id", "G_MESSAGES_INBOX_URL" => "/company/personal/messages/input/", "G_MESSAGES_SENT_URL" => "/company/personal/messages/output/", "GU_MESSAGES_TITLE_STD" => "", "G_CALENDAR_IBLOCK_TYPE" => "news", "G_CALENDAR_IBLOCK_ID" => "15", "G_CALENDAR_DETAIL_URL" => "/company/personal/user/#user_id#/calendar/", "G_CALENDAR_CACHE_TYPE" => "A", "G_CALENDAR_CACHE_TIME" => "3600", "G_CALENDAR_CALENDAR_URL" => "/company/personal/user/#user_id#/calendar/", "GU_CALENDAR_TITLE_STD" => "", "GU_CALENDAR_EVENTS_COUNT" => "5", "G_PROFILE_PATH_TO_GENERAL" => "/company/personal/", "G_PROFILE_PATH_TO_PROFILE_EDIT" => "/company/personal/user/#user_id#/edit/", "G_PROFILE_PATH_TO_LOG" => "/company/personal/log/", "G_PROFILE_PATH_TO_SUBSCR" => "/company/personal/subscribe/", "G_PROFILE_PATH_TO_MSG" => "/company/personal/messages/", "G_PROFILE_PATH_TO_GROUPS" => "/company/personal/user/#user_id#/groups/", "G_PROFILE_PATH_TO_GROUP_NEW" => "/company/personal/user/#user_id#/groups/create/", "G_PROFILE_PATH_TO_PHOTO" => "/company/personal/user/#user_id#/photo/", "G_PROFILE_PATH_TO_PHOTO_NEW" => "/company/personal/user/#user_id#/photo/photo/user_#user_id#/0/action/upload/", "G_PROFILE_PATH_TO_FORUM" => "/company/personal/user/#user_id#/forum/", "G_PROFILE_PATH_TO_BLOG" => "/company/personal/user/#user_id#/blog/", "G_PROFILE_PATH_TO_BLOG_NEW" => "/company/personal/user/#user_id#/blog/edit/new/", "G_PROFILE_PATH_TO_CAL" => "/company/personal/user/#user_id#/calendar/", "G_PROFILE_PATH_TO_TASK" => "/company/personal/user/#user_id#/tasks/", "G_PROFILE_PATH_TO_TASK_NEW" => "/company/personal/user/#user_id#/tasks/task/edit/0/", "G_PROFILE_PATH_TO_LIB" => "/company/personal/user/#user_id#/files/lib/", "GU_PROFILE_TITLE_STD" => "", "GU_PROFILE_SHOW_GENERAL" => "Y", "GU_PROFILE_SHOW_GROUPS" => "Y", "GU_PROFILE_SHOW_PHOTO" => "Y", "GU_PROFILE_SHOW_CAL" => "Y", "GU_PROFILE_SHOW_BLOG" => "Y", "GU_PROFILE_SHOW_TASK" => "Y", "GU_PROFILE_SHOW_LIB" => "Y", "G_SEARCH_EMPLOYEE_LIST_URL" => "/company/", "GU_SEARCH_EMPLOYEE_TITLE_STD" => "", "G_LIFE_IBLOCK_TYPE" => "news", "G_LIFE_IBLOCK_ID" => $_REQUEST["ID"], "G_LIFE_ACTIVE_DATE_FORMAT" => LANGUAGE_ID == "en" ? "F j, Y" : (LANGUAGE_ID == "de" ? "d.m.Y" : "d.m.Y"), "G_LIFE_LIST_URL" => "/about/life.php", "G_LIFE_DETAIL_URL" => "/about/life.php?ID=#ELEMENT_ID#", "G_LIFE_CACHE_TYPE" => "A", "G_LIFE_CACHE_TIME" => "36000000", "GU_LIFE_TITLE_STD" => "", "GU_LIFE_NEWS_COUNT" => "5", "GU_LIFE_DISPLAY_DATE" => "Y", "GU_LIFE_DISPLAY_PICTURE" => "Y", "GU_LIFE_DISPLAY_PREVIEW_TEXT" => "Y", "G_BLOG_PATH_TO_BLOG" => "/company/personal/user/#user_id#/blog/", "G_BLOG_PATH_TO_POST" => "/company/personal/user/#user_id#/blog/#post_id#/", "G_BLOG_PATH_TO_GROUP_BLOG_POST" => "/workgroups/group/#group_id#/blog/#post_id#/", "G_BLOG_PATH_TO_USER" => "/company/personal/user/#user_id#/", "G_BLOG_CACHE_TYPE" => "A", "G_BLOG_CACHE_TIME" => "180", "GU_BLOG_TITLE_STD" => "", "GU_BLOG_MESSAGE_COUNT" => "6", "GU_BLOG_MESSAGE_LENGTH" => "100", "GU_BLOG_DATE_TIME_FORMAT" => "#DATE_TIME_FORMAT#", "G_NEW_EMPLOYEES_LIST_URL" => "/company/events.php", "GU_NEW_EMPLOYEES_TITLE_STD" => "", "GU_NEW_EMPLOYEES_NUM_USERS" => "5", "GU_NEW_EMPLOYEES_DEPARTMENT" => "-", "G_UPDATES_USER_VAR" => "user_id", "G_UPDATES_GROUP_VAR" => "group_id", "G_UPDATES_PAGE_VAR" => "page", "G_UPDATES_PATH_TO_USER" => "/company/personal/user/#user_id#/", "G_UPDATES_PATH_TO_GROUP" => "/workgroups/group/#group_id#/", "G_UPDATES_LIST_URL" => "/company/personal/log/", "GU_UPDATES_TITLE_STD" => "", "GU_UPDATES_ENTITY_TYPE" => "", "GU_UPDATES_EVENT_ID" => "", "G_SHARED_DOCS_IBLOCK_TYPE" => "library", "G_SHARED_DOCS_IBLOCK_ID" => $_REQUEST["ID"], "G_SHARED_DOCS_LIST_URL" => "/docs/", "G_SHARED_DOCS_DETAIL_URL" => "/docs/shared/element/view/#ELEMENT_ID#/", "G_SHARED_DOCS_CACHE_TYPE" => "A", "G_SHARED_DOCS_CACHE_TIME" => "3600", "GU_SHARED_DOCS_TITLE_STD" => "", "GU_SHARED_DOCS_DOCS_COUNT" => "5", "GU_SHARED_DOCS_DISPLAY_DATE" => "Y", "GU_SHARED_DOCS_DISPLAY_PICTURE" => "Y", "GU_SHARED_DOCS_DISPLAY_PREVIEW_TEXT" => "Y", "G_ABSENT_LIST_URL" => "/company/absence.php", "GU_ABSENT_TITLE_STD" => "", "GU_ABSENT_NUM_USERS" => "5", "GU_ABSENT_DEPARTMENT" => "-", "G_REPORT1C_CACHE_TYPE" => "A", "G_REPORT1C_CACHE_TIME" => "0", "GU_REPORT1C_TITLE_STD" => "", "GU_REPORT1C_INITIALREPORT" => "shortreport", "GU_REPORT1C_URL" => "localhost", "GU_REPORT1C_PORT" => "8080", "GU_REPORT1C_PATH" => "/ws/report.1cws", "GU_REPORT1C_LOGIN" => "", "GU_REPORT1C_PASSWORD" => "", "G_OFFICIAL_IBLOCK_TYPE" => "news", "G_OFFICIAL_IBLOCK_ID" => $_REQUEST["ID"], "G_OFFICIAL_LIST_URL" => "/about/index.php", "G_OFFICIAL_DETAIL_URL" => "/about/official.php?ID=#ELEMENT_ID#", "G_OFFICIAL_ACTIVE_DATE_FORMAT" => LANGUAGE_ID == "en" ? "F j, Y" : (LANGUAGE_ID == "de" ? "d.m.Y" : "d.m.Y"), "G_OFFICIAL_CACHE_TYPE" => "A", "G_OFFICIAL_CACHE_TIME" => "36000000", "GU_OFFICIAL_TITLE_STD" => "", "GU_OFFICIAL_NEWS_COUNT" => "5", "GU_OFFICIAL_DISPLAY_PREVIEW_TEXT" => "Y", "G_PROBKI_CACHE_TIME" => "3600", "G_PROBKI_SHOW_URL" => "N", "GU_PROBKI_TITLE_STD" => "", "GU_PROBKI_CITY" => "c213", "G_WEATHER_CACHE_TIME" => "3600", "G_WEATHER_SHOW_URL" => "N", "GU_WEATHER_TITLE_STD" => "", "GU_WEATHER_CITY" => "c213", "G_WORKGROUPS_GROUP_VAR" => "group_id", "G_WORKGROUPS_PATH_TO_GROUP" => "/workgroups/group/#group_id#/", "G_WORKGROUPS_PATH_TO_GROUP_SEARCH" => "/workgroups/", "G_WORKGROUPS_CACHE_TIME" => "3600", "GU_WORKGROUPS_TITLE_STD" => "", "GU_WORKGROUPS_DATE_TIME_FORMAT" => LANGUAGE_ID == "en" ? "F j, Y H:i:s" : (LANGUAGE_ID == "de" ? "d.m.Y H:i:s" : "d.m.Y H:i:s"), "GU_WORKGROUPS_DISPLAY_PICTURE" => "Y", "GU_WORKGROUPS_DISPLAY_DESCRIPTION" => "Y", "GU_WORKGROUPS_DISPLAY_NUMBER_OF_MEMBERS" => "Y", "GU_WORKGROUPS_FILTER_MY" => "N", "G_COMPANY_CALENDAR_IBLOCK_TYPE" => "news", "G_COMPANY_CALENDAR_IBLOCK_ID" => "15", "G_COMPANY_CALENDAR_DETAIL_URL" => "/about/calendar.php", "G_COMPANY_CALENDAR_CACHE_TYPE" => "A", "G_COMPANY_CALENDAR_CACHE_TIME" => "3600", "GU_COMPANY_CALENDAR_TITLE_STD" => "", "GU_COMPANY_CALENDAR_EVENTS_COUNT" => "5", "G_CRM_COMPANY_LIST_PATH_TO_COMPANY_SHOW" => "#SITE_DIR#crm/company/show/#company_id#/", "GU_CRM_COMPANY_LIST_TITLE_STD" => "", "GU_CRM_COMPANY_LIST_TYPE_ID" => "", "GU_CRM_COMPANY_LIST_ONLY_MY" => "N", "GU_CRM_COMPANY_LIST_SORT" => "DATE_CREATE", "GU_CRM_COMPANY_LIST_SORT_BY" => "DESC", "GU_CRM_COMPANY_LIST_COMPANY_COUNT" => "5", "G_CRM_CONTACT_LIST_PATH_TO_CONTACT_SHOW" => "#SITE_DIR#crm/contact/show/#contact_id#/", "GU_CRM_CONTACT_LIST_TITLE_STD" => "", "GU_CRM_CONTACT_LIST_TYPE_ID" => "", "GU_CRM_CONTACT_LIST_ONLY_MY" => "N", "GU_CRM_CONTACT_LIST_SORT" => "DATE_CREATE", "GU_CRM_CONTACT_LIST_SORT_BY" => "DESC", "GU_CRM_CONTACT_LIST_CONTACT_COUNT" => "5", "G_CRM_LEAD_LIST_PATH_TO_LEAD_SHOW" => "#SITE_DIR#crm/lead/show/#lead_id#/", "GU_CRM_LEAD_LIST_TITLE_STD" => "", "GU_CRM_LEAD_LIST_STATUS_ID" => "", "GU_CRM_LEAD_LIST_ONLY_MY" => "N", "GU_CRM_LEAD_LIST_SORT" => "DATE_CREATE", "GU_CRM_LEAD_LIST_SORT_BY" => "DESC", "GU_CRM_LEAD_LIST_LEAD_COUNT" => "5", "G_CRM_DEAL_LIST_PATH_TO_DEAL_SHOW" => "#SITE_DIR#crm/deal/show/#deal_id#/", "GU_CRM_DEAL_LIST_TITLE_STD" => "", "GU_CRM_DEAL_LIST_STAGE_ID" => "", "GU_CRM_DEAL_LIST_ONLY_MY" => "N", "GU_CRM_DEAL_LIST_SORT" => "DATE_CREATE", "GU_CRM_DEAL_LIST_SORT_BY" => "DESC", "GU_CRM_DEAL_LIST_DEAL_COUNT" => "5", "G_CRM_EVENT_LIST_PATH_TO_LEAD_SHOW" => "#SITE_DIR#crm/lead/show/#lead_id#/", "G_CRM_EVENT_LIST_PATH_TO_CONTACT_SHOW" => "#SITE_DIR#crm/contact/show/#contact_id#/", "G_CRM_EVENT_LIST_PATH_TO_COMPANY_SHOW" => "#SITE_DIR#crm/company/show/#company_id#/", "G_CRM_EVENT_LIST_PATH_TO_DEAL_SHOW" => "#SITE_DIR#crm/deal/show/#deal_id#/", "GU_CRM_EVENT_LIST_TITLE_STD" => "", "GU_CRM_EVENT_LIST_EVENT_TYPE_LIST" => "", "GU_CRM_EVENT_LIST_EVENT_COUNT" => "5", "G_PHOTOS_IBLOCK_TYPE" => "news", "G_PHOTOS_IBLOCK_ID" => "", "G_PHOTOS_LIST_URL" => "/about/gallery/", "G_PHOTOS_DETAIL_URL" => "/about/gallery/#SECTION_ID#/#ELEMENT_ID#/", "G_PHOTOS_DETAIL_SLIDE_SHOW_URL" => "/about/gallery/#SECTION_ID#/#ELEMENT_ID#/slide_show/", "G_PHOTOS_CACHE_TYPE" => "A", "G_PHOTOS_CACHE_TIME" => "3600", "GU_PHOTOS_TITLE_STD" => "", "GU_PHOTOS_PAGE_ELEMENTS" => "6")); } require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php";
@unlink($_SESSION['CRM_IMPORT_FILE']); foreach ($_SESSION as $key => $value) { if (strpos($key, 'CRM_IMPORT_FILE') !== false) { unset($_SESSION[$key]); } } LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LEAD_LIST'], array())); } } } } $arResult['FORM_ID'] = 'CRM_LEAD_IMPORT'; $arResult['FIELDS']['tab_1'] = array(); $arResult['FIELDS']['tab_1'][] = array('id' => 'IMPORT_FILE', 'name' => GetMessage('CRM_FIELD_IMPORT_FILE'), 'params' => array(), 'type' => 'file', 'required' => true); $encodings = array('_' => GetMessage('CRM_FIELD_IMPORT_DEFAULT_FILE_ENCODING'), 'ascii' => 'ASCII', 'UTF-8' => 'UTF-8', 'UTF-16' => 'UTF-16', 'windows-1251' => 'Windows-1251', 'Windows-1252' => 'Windows-1252', 'iso-8859-1' => 'ISO-8859-1', 'iso-8859-2' => 'ISO-8859-2', 'iso-8859-3' => 'ISO-8859-3', 'iso-8859-4' => 'ISO-8859-4', 'iso-8859-5' => 'ISO-8859-5', 'iso-8859-6' => 'ISO-8859-6', 'iso-8859-7' => 'ISO-8859-7', 'iso-8859-8' => 'ISO-8859-8', 'iso-8859-9' => 'ISO-8859-9', 'iso-8859-10' => 'ISO-8859-10', 'iso-8859-13' => 'ISO-8859-13', 'iso-8859-14' => 'ISO-8859-14', 'iso-8859-15' => 'ISO-8859-15', 'koi8-r' => 'KOI8-R'); $siteEncoding = strtolower(SITE_CHARSET); $arResult['FIELDS']['tab_1'][] = array('id' => 'IMPORT_FILE_ENCODING', 'name' => GetMessage('CRM_FIELD_IMPORT_FILE_ENCODING'), 'items' => $encodings, 'type' => 'list', 'value' => isset($encodings[$siteEncoding]) ? $siteEncoding : '_'); $arResult['FIELDS']['tab_1'][] = array('id' => 'IMPORT_DEFAULT_RESPONSIBLE', 'name' => GetMessage('CRM_FIELD_IMPORT_DEFAULT_RESPONSIBLE'), 'type' => 'intranet_user_search', 'componentParams' => array('NAME' => 'crm_lead_import_responsible', 'INPUT_NAME' => 'IMPORT_DEFAULT_RESPONSIBLE_ID', 'SEARCH_INPUT_NAME' => 'IMPORT_DEFAULT_RESPONSIBLE_NAME'), 'value' => CCrmPerms::GetCurrentUserID()); $arResult['FIELDS']['tab_1'][] = array('id' => 'IMPORT_NAME_FORMAT', 'name' => GetMessage('CRM_FIELD_NAME_FORMAT'), 'items' => $userNameFormats, 'type' => 'list', 'value' => \Bitrix\Crm\Format\PersonNameFormatter::FirstLast); $arResult['FIELDS']['tab_1'][] = array('id' => 'IMPORT_FILE_EXAMPLE', 'name' => GetMessage('CRM_FIELD_IMPORT_FILE_EXAMPLE'), 'params' => array(), 'type' => 'label', 'value' => '<a href="?getSample=csv&ncc=1">' . GetMessage('CRM_DOWNLOAD') . '</a>'); $arResult['FIELDS']['tab_1'][] = array('id' => 'IMPORT_FILE_FORMAT', 'name' => GetMessage('CRM_SECTION_IMPORT_FILE_FORMAT'), 'type' => 'section'); $arResult['FIELDS']['tab_1'][] = array('id' => 'IMPORT_FILE_SEPORATOR', 'name' => GetMessage('CRM_FIELD_IMPORT_FILE_SEPORATOR'), 'items' => array('semicolon' => GetMessage('CRM_FIELD_IMPORT_FILE_SEPORATOR_SEMICOLON'), 'comma' => GetMessage('CRM_FIELD_IMPORT_FILE_SEPORATOR_COMMA'), 'tab' => GetMessage('CRM_FIELD_IMPORT_FILE_SEPORATOR_TAB'), 'space' => GetMessage('CRM_FIELD_IMPORT_FILE_SEPORATOR_SPACE')), 'type' => 'list', 'value' => isset($_POST['IMPORT_FILE_SEPORATOR']) ? $_POST['IMPORT_FILE_SEPORATOR'] : 'semicolon'); $arResult['FIELDS']['tab_1'][] = array('id' => 'IMPORT_FILE_FIRST_HEADER', 'name' => GetMessage('CRM_FIELD_IMPORT_FILE_FIRST_HEADER'), 'type' => 'checkbox', 'value' => isset($_POST['IMPORT_FILE_FIRST_HEADER']) && $_POST['IMPORT_FILE_FIRST_HEADER'] == 'N' ? 'N' : 'Y'); $arResult['FIELDS']['tab_1'][] = array('id' => 'IMPORT_FILE_SKIP_EMPTY', 'name' => GetMessage('CRM_FIELD_IMPORT_FILE_SKIP_EMPTY'), 'type' => 'checkbox', 'value' => isset($_POST['IMPORT_FILE_SKIP_EMPTY']) && $_POST['IMPORT_FILE_SKIP_EMPTY'] == 'N' ? 'N' : 'Y'); for ($i = 1; $i <= 4; $i++) { if ($arResult['STEP'] != $i) { $arResult['FIELDS']['tab_' . $i] = array(); } } $this->IncludeComponentTemplate(); include_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/components/bitrix/crm.lead/include/nav.php';
public function Delete($ID, $arEntityAttr) { if (!CModule::IncludeModule('bizproc')) { return true; } $userID = CCrmSecurityHelper::GetCurrentUserID(); $bDeleteError = !CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::WriteDocument, $userID, array('crm', $this->sDocument, $this->sEntityType . '_' . $ID), array('UserGroups' => $this->arCurrentUserGroups, 'UserIsAdmin' => CCrmPerms::IsAdmin($userID), 'CRMEntityAttr' => $arEntityAttr)); if (!$bDeleteError) { return $this->ProcessDeletion($ID); } return true; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/intranet/public/crm/contact/.left.menu_ext.php"); if (CModule::IncludeModule('crm')) { $CrmPerms = new CCrmPerms($GLOBALS['USER']->GetID()); $aMenuLinksExt = array(); if (!$CrmPerms->HavePerm('CONTACT', BX_CRM_PERM_NONE, 'ADD')) { $aMenuLinksExt[] = array(GetMessage("MENU_CRM_ADD_CONTACT"), '#SITE_DIR#crm/contact/edit/0/', array(), array(), ''); } if (!$CrmPerms->HavePerm('CONTACT', BX_CRM_PERM_NONE, 'READ')) { $aMenuLinksExt[] = array(GetMessage("MENU_CRM_CONTACT_LIST"), '#SITE_DIR#crm/contact/list/', array(), array(), ''); } if (!$CrmPerms->HavePerm('CONTACT', BX_CRM_PERM_NONE, 'ADD')) { $aMenuLinksExt[] = array(GetMessage("MENU_CRM_CONTACT_IMPORT"), '#SITE_DIR#crm/contact/import/', array(), array(), ''); } $aMenuLinks = array_merge($aMenuLinks, $aMenuLinksExt); }
return; } if (!CModule::IncludeModule('currency')) { ShowError(GetMessage('CRM_MODULE_NOT_INSTALLED_CURRENCY')); return; } if (!CModule::IncludeModule('sale')) { ShowError(GetMessage('CRM_MODULE_NOT_INSTALLED_SALE')); return; } if (!CModule::IncludeModule('catalog')) { ShowError(GetMessage('CRM_MODULE_NOT_INSTALLED_CATALOG')); return; } global $APPLICATION, $USER; $CrmPerms = new CCrmPerms($USER->GetID()); if (!$CrmPerms->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'WRITE')) { ShowError(GetMessage('CRM_PERMISSION_DENIED')); return; } $arResult['PATH_TO_CONFIGS_INDEX'] = isset($arParams['PATH_TO_CONFIGS_INDEX']) ? $arParams['PATH_TO_CONFIGS_INDEX'] : '/crm/configs/'; $componentPage = ''; $arDefaultUrlTemplates404 = array('index' => '', 'catalog' => 'catalog/', 'invoice' => 'invoice/'); if ($arParams['SEF_MODE'] === 'Y') { $arDefaultVariableAliases404 = array(); $arComponentVariables = array(); $arVariables = array(); $arUrlTemplates = CComponentEngine::MakeComponentUrlTemplates($arDefaultUrlTemplates404, $arParams['SEF_URL_TEMPLATES']); $arVariableAliases = CComponentEngine::MakeComponentVariableAliases($arDefaultVariableAliases404, $arParams['VARIABLE_ALIASES']); $componentPage = CComponentEngine::ParseComponentPath($arParams['SEF_FOLDER'], $arUrlTemplates, $arVariables); if (!(is_string($componentPage) && isset($componentPage[0]) && isset($arDefaultUrlTemplates404[$componentPage])) || $this->__templateName === 'free') {
$filterFieldInfo = array('typeName' => 'USER', 'id' => $filterID, 'params' => array('data' => array('paramName' => "{$filterID}", 'elementId' => "{$prefix}_{$filterID}"), 'search' => array('paramName' => "{$filterID}_name", 'elementId' => "{$prefix}_{$filterID}_NAME"))); $gridManagerCfg['filterFields'][] = $filterFieldInfo; } } $arResult['GRID_DATA'] = array(); foreach ($arResult['EVENT'] as $arEvent) { $arEvent['FILE_HTML'] = ""; if (!empty($arEvent['FILES'])) { $arEvent['FILE_HTML'] = '<div class="event-detail-files"><label class="event-detail-files-title">' . GetMessage('CRM_EVENT_TABLE_FILES') . ':</label><div class="event-detail-files-list">'; foreach ($arEvent['FILES'] as $key => $value) { $arEvent['FILE_HTML'] .= '<div class="event-detail-file"><span class="event-detail-file-number">' . $key . '.</span><span class="event-detail-file-info"><a href="' . htmlspecialcharsbx($value['PATH']) . '" target="_blank" class="event-detail-file-link">' . htmlspecialcharsbx($value['NAME']) . '</a><span class="event-detail-file-size">(' . htmlspecialcharsbx($value['SIZE']) . ')</span></span></div>'; } $arEvent['FILE_HTML'] .= '</div></div>'; } $arActions = array(); if (CCrmPerms::IsAdmin() || $arEvent['USER_ID'] == CCrmPerms::GetCurrentUserID()) { $arActions[] = array('ICONCLASS' => 'delete', 'TITLE' => GetMessage('CRM_EVENT_DELETE_TITLE'), 'TEXT' => GetMessage('CRM_EVENT_DELETE'), 'ONCLICK' => "crm_event_delete_grid('" . GetMessage('CRM_EVENT_DELETE_TITLE') . "', '" . GetMessage('CRM_EVENT_DELETE_CONFIRM') . "', '" . GetMessage('CRM_EVENT_DELETE') . "', '" . $arEvent['PATH_TO_EVENT_DELETE'] . "')"); } $eventColor = ''; if ($arEvent['TYPE'] == '0') { $eventColor = 'color: #208c0b'; } elseif ($arEvent['TYPE'] == '2') { $eventColor = 'color: #9c8000'; } $arColumns = array('CREATED_BY_FULL_NAME' => $arEvent['CREATED_BY_FULL_NAME'] == '' ? '' : '<a href="' . $arEvent['CREATED_BY_LINK'] . '" id="balloon_' . $arResult['GRID_ID'] . '_' . $arEvent['ID'] . '">' . $arEvent['CREATED_BY_FULL_NAME'] . '</a>' . '<script type="text/javascript">BX.tooltip(' . $arEvent['USER_ID'] . ', "balloon_' . $arResult['GRID_ID'] . '_' . $arEvent['ID'] . '", "");</script>', 'EVENT_NAME' => '<span style="' . $eventColor . '">' . $arEvent['EVENT_NAME'] . '</span>', 'EVENT_DESC' => $arEvent['EVENT_DESC'] . $arEvent['FILE_HTML'], 'DATE_CREATE' => FormatDate('x', MakeTimeStamp($arEvent['DATE_CREATE']), time() + CTimeZone::GetOffset())); // if ($arResult['EVENT_ENTITY_LINK'] == 'Y') // { // $arColumns['ENTITY_TYPE'] = !empty($arEvent['ENTITY_TYPE'])? GetMessage('CRM_EVENT_ENTITY_TYPE_'.$arEvent['ENTITY_TYPE']): ''; // $arColumns['ENTITY_TITLE'] = !empty($arEvent['ENTITY_TITLE'])? // '<a href="'.$arEvent['ENTITY_LINK'].'" id="balloon_'.$arResult['GRID_ID'].'_I_'.$arEvent['ID'].'">'.$arEvent['ENTITY_TITLE'].'</a>'. // '<script type="text/javascript">BX.tooltip("'.$arEvent['ENTITY_TYPE'].'_'.$arEvent['ENTITY_ID'].'", "balloon_'.$arResult['GRID_ID'].'_I_'.$arEvent['ID'].'", "/bitrix/components/bitrix/crm.'.strtolower($arEvent['ENTITY_TYPE']).'.show/card.ajax.php", "crm_balloon'.($arEvent['ENTITY_TYPE'] == 'LEAD' || $arEvent['ENTITY_TYPE'] == 'DEAL' || $arEvent['ENTITY_TYPE'] == 'QUOTE' ? '_no_photo': '_'.strtolower($arEvent['ENTITY_TYPE'])).'", true);</script>'
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/intranet/public/crm/.left.menu_ext.php"); if (CModule::IncludeModule('crm')) { $CrmPerms = new CCrmPerms($GLOBALS["USER"]->GetID()); $arMenuCrm = array(); if (SITE_TEMPLATE_ID === "bitrix24") { $arMenuCrm[] = array(GetMessage("MENU_CRM_DESKTOP"), "#SITE_DIR#crm/", array(), array(), ""); } $arMenuCrm[] = array(GetMessage("MENU_CRM_STREAM"), "#SITE_DIR#crm/stream/", array(), array(), ""); $arMenuCrm[] = array(GetMessage("MENU_CRM_ACTIVITY"), "#SITE_DIR#crm/activity/", array(), array(), ""); if (!$CrmPerms->HavePerm('CONTACT', BX_CRM_PERM_NONE)) { $arMenuCrm[] = array(GetMessage("MENU_CRM_CONTACT"), "#SITE_DIR#crm/contact/", array(), array(), ""); } if (!$CrmPerms->HavePerm('COMPANY', BX_CRM_PERM_NONE)) { $arMenuCrm[] = array(GetMessage("MENU_CRM_COMPANY"), "#SITE_DIR#crm/company/", array(), array(), ""); } if (!$CrmPerms->HavePerm('DEAL', BX_CRM_PERM_NONE)) { $arMenuCrm[] = array(GetMessage("MENU_CRM_DEAL"), "#SITE_DIR#crm/deal/", array(), array(), ""); } if (!$CrmPerms->HavePerm('INVOICE', BX_CRM_PERM_NONE)) { $arMenuCrm[] = array(GetMessage("MENU_CRM_INVOICE"), "#SITE_DIR#crm/invoice/", array(), array(), ""); } if (!$CrmPerms->HavePerm('QUOTE', BX_CRM_PERM_NONE)) { $arMenuCrm[] = array(GetMessage("MENU_CRM_QUOTE"), "#SITE_DIR#crm/quote/", array(), array(), ""); } if (!$CrmPerms->HavePerm('LEAD', BX_CRM_PERM_NONE)) { $arMenuCrm[] = array(GetMessage("MENU_CRM_LEAD"), "#SITE_DIR#crm/lead/", array(), array(), "");
} if (!CModule::IncludeModule('sale')) { ShowError(GetMessage('CRM_SALE_MODULE_NOT_INSTALLED')); return; } global $USER, $APPLICATION; $arParams['PATH_TO_LOCATIONS_LIST'] = CrmCheckPath('PATH_TO_LOCATIONS_LIST', $arParams['PATH_TO_LOCATIONS_LIST'], ''); $arParams['PATH_TO_LOCATIONS_ADD'] = CrmCheckPath('PATH_TO_LOCATIONS_ADD', $arParams['PATH_TO_LOCATIONS_ADD'], '?add'); $arParams['PATH_TO_LOCATIONS_EDIT'] = CrmCheckPath('PATH_TO_LOCATIONS_EDIT', $arParams['PATH_TO_LOCATIONS_EDIT'], '?loc_id=#loc_id#&edit'); $arParams['PATH_TO_LOCATIONS_IMPORT'] = CrmCheckPath('PATH_TO_LOCATIONS_IMPORT', $arParams['PATH_TO_LOCATIONS_IMPORT'], '?import'); if (!isset($arParams['TYPE'])) { $arParams['TYPE'] = 'list'; } $arResult['BUTTONS'] = array(); $locID = isset($arParams['LOC_ID']) ? strval($arParams['LOC_ID']) : ''; $CrmPerms = new CCrmPerms($USER->GetID()); $locAdd = $locEdit = $locDelete = $locImport = $CrmPerms->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'WRITE'); if (CSaleLocation::isLocationProMigrated()) { $exists = intval($locID > 0) && CCrmLocations::CheckLocationExists($locID); } else { $exists = intval($locID > 0) && is_array(CCrmLocations::GetByID($locID)); } ######################## ######################## ######################## // LIST if ($arParams['TYPE'] == 'list') { $parentId = false; // STEP UP IN LIST if (CSaleLocation::isLocationProEnabled()) { $filterParentId = false;
<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die; } if (!CModule::IncludeModule('crm')) { ShowError(GetMessage('CRM_MODULE_NOT_INSTALLED')); return; } global $USER, $APPLICATION; $CrmPerms = new CCrmPerms($USER->GetID()); if (!$CrmPerms->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'READ')) { ShowError(GetMessage('CRM_PERMISSION_DENIED')); return; } $taxID = isset($arParams['TAX_ID']) ? strval($arParams['TAX_ID']) : ''; if ($taxID[0] <= 0) { $taxIDParName = isset($arParams['TAX_ID_PAR_NAME']) ? strval($arParams['TAX_ID_PAR_NAME']) : ''; if (strlen($taxIDParName) == 0) { $taxIDParName = 'tax_id'; } $taxID = isset($_REQUEST[$taxIDParName]) ? intval($_REQUEST[$taxIDParName]) : 0; } $arResult['SHOW_RATES'] = isset($_REQUEST['show_rates']) && $_REQUEST['show_rates'] == 'Y' ? true : false; $tax = array(); if ($taxID <= 0 || !($tax = CCrmTax::GetByID($taxID))) { ShowError(GetMessage('CRM_TAX_NOT_FOUND')); @define('ERROR_404', 'Y'); if ($arParams['SET_STATUS_404'] === 'Y') { CHTTP::SetStatus("404 Not Found"); }
private static function SynchronizeLiveFeedEvent($activityID, $params) { if (!is_array($params)) { $params = array(); } $processBindings = isset($params['PROCESS_BINDINGS']) ? (bool) $params['PROCESS_BINDINGS'] : false; $bindings = isset($params['BINDINGS']) && is_array($params['BINDINGS']) ? $params['BINDINGS'] : array(); $hasBindings = !empty($bindings); if ($processBindings) { CCrmSonetRelation::UnRegisterRelationsByEntity(CCrmOwnerType::Activity, $activityID, array('QUICK' => $hasBindings)); } $arOwners = $hasBindings ? $bindings : self::GetBindings($activityID); $slEntities = CCrmLiveFeed::GetLogEvents(array(), array('ENTITY_TYPE_ID' => CCrmOwnerType::Activity, 'ENTITY_ID' => $activityID), array('ID', 'EVENT_ID')); if (empty($slEntities)) { return false; } global $DB; foreach ($slEntities as &$slEntity) { $slID = intval($slEntity['ID']); $slEventType = $slEntity['EVENT_ID']; if (isset($params['REFRESH_DATE']) ? (bool) $params['REFRESH_DATE'] : false) { //Update LOG_UPDATE for force event to rise in global feed //Update LOG_DATE for force event to rise in entity feed CCrmLiveFeed::UpdateLogEvent($slID, array('=LOG_UPDATE' => $DB->CurrentTimeFunction(), '=LOG_DATE' => $DB->CurrentTimeFunction())); } else { //HACK: FAKE UPDATE FOR INVALIDATE CACHE CCrmLiveFeed::UpdateLogEvent($slID, array('ENTITY_TYPE_ID' => CCrmOwnerType::Activity, 'ENTITY_ID' => $activityID)); } /* 'START_RESPONSIBLE_ID' => $arPrevEntity['RESPONSIBLE_ID'], 'FINAL_RESPONSIBLE_ID' => $responsibleID */ $userID = intval($params['EDITOR_ID']) > 0 ? $params['EDITOR_ID'] : CCrmSecurityHelper::GetCurrentUserID(); if (intval($params['START_RESPONSIBLE_ID']) != intval($params['FINAL_RESPONSIBLE_ID']) && CModule::IncludeModule("im")) { switch ($params['TYPE_ID']) { case CCrmActivityType::Call: $type = 'CALL'; break; case CCrmActivityType::Meeting: $type = 'MEETING'; break; default: $type = false; } if ($type) { $url = "/crm/stream/?log_id=#log_id#"; $url = str_replace(array("#log_id#"), array($slID), $url); $serverName = (CMain::IsHTTPS() ? "https" : "http") . "://" . (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0 ? SITE_SERVER_NAME : COption::GetOptionString("main", "server_name", "")); $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "FROM_USER_ID" => $userID, "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "crm", "LOG_ID" => $slID, "NOTIFY_EVENT" => "activity_add", "NOTIFY_TAG" => "CRM|ACTIVITY|" . $activityID); if (intval($params['START_RESPONSIBLE_ID']) != $userID) { $bHasPermissions = false; $perms = CCrmPerms::GetUserPermissions($params['START_RESPONSIBLE_ID']); foreach ($arOwners as $arOwner) { if (CCrmActivity::CheckReadPermission($arOwner["OWNER_TYPE_ID"], $arOwner["OWNER_ID"], $perms)) { $bHasPermissions = true; break; } } if ($bHasPermissions) { $arMessageFields["TO_USER_ID"] = $params['START_RESPONSIBLE_ID']; $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("CRM_ACTIVITY_" . $type . "_NOT_RESPONSIBLE_IM_NOTIFY", array("#title#" => '<a href="' . $url . '">' . htmlspecialcharsbx($params['SUBJECT']) . '</a>')); $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("CRM_ACTIVITY_" . $type . "_NOT_RESPONSIBLE_IM_NOTIFY", array("#title#" => htmlspecialcharsbx($params['SUBJECT']))) . " (" . $serverName . $url . ")"; CIMNotify::Add($arMessageFields); } } if (intval($params['FINAL_RESPONSIBLE_ID']) != $userID) { $bHasPermissions = false; $perms = CCrmPerms::GetUserPermissions($params['FINAL_RESPONSIBLE_ID']); foreach ($arOwners as $arOwner) { if (CCrmActivity::CheckReadPermission($arOwner["OWNER_TYPE_ID"], $arOwner["OWNER_ID"], $perms)) { $bHasPermissions = true; break; } } if ($bHasPermissions) { $arMessageFields["TO_USER_ID"] = $params['FINAL_RESPONSIBLE_ID']; $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("CRM_ACTIVITY_" . $type . "_RESPONSIBLE_IM_NOTIFY", array("#title#" => '<a href="' . $url . '">' . htmlspecialcharsbx($params['SUBJECT']) . '</a>')); $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("CRM_ACTIVITY_" . $type . "_RESPONSIBLE_IM_NOTIFY", array("#title#" => htmlspecialcharsbx($params['SUBJECT']))) . " (" . $serverName . $url . ")"; CIMNotify::Add($arMessageFields); } } } } if ($processBindings && $hasBindings) { CCrmSonetRelation::RegisterRelationBundle($slID, $slEventType, CCrmOwnerType::Activity, $activityID, $bindings, array('ENTITY_TYPE_ID_KEY' => 'OWNER_TYPE_ID', 'ENTITY_ID_KEY' => 'OWNER_ID', 'TYPE_ID' => CCrmSonetRelationType::Ownership)); } } unset($slEntity); return true; }
<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die; } if (CModule::IncludeModule('crm')) { $CrmPerms = new CCrmPerms($GLOBALS["USER"]->GetID()); $arMenuCrm = array(); if (!$CrmPerms->HavePerm('CONTACT', BX_CRM_PERM_NONE)) { $arMenuCrm[] = array(GetMessage("CRM_CONTACT"), "#SITE_DIR#crm/contact/", array(), array(), ""); } if (!$CrmPerms->HavePerm('COMPANY', BX_CRM_PERM_NONE)) { $arMenuCrm[] = array(GetMessage("CRM_COMPANY"), "#SITE_DIR#crm/company/", array(), array(), ""); } if (!$CrmPerms->HavePerm('DEAL', BX_CRM_PERM_NONE)) { $arMenuCrm[] = array(GetMessage("CRM_DEAL"), "#SITE_DIR#crm/deal/", array(), array(), ""); } if (!$CrmPerms->HavePerm('LEAD', BX_CRM_PERM_NONE)) { $arMenuCrm[] = array(GetMessage("CRM_LEAD"), "#SITE_DIR#crm/lead/", array(), array(), ""); } if (!$CrmPerms->HavePerm('CONFIG', BX_CRM_PERM_NONE)) { $arMenuCrm[] = array(GetMessage("CRM_PRODUCTS"), "#SITE_DIR#crm/product/", array(), array(), ""); } if (!$CrmPerms->HavePerm('LEAD', BX_CRM_PERM_NONE) || !$CrmPerms->HavePerm('CONTACT', BX_CRM_PERM_NONE) || !$CrmPerms->HavePerm('COMPANY', BX_CRM_PERM_NONE) || !$CrmPerms->HavePerm('DEAL', BX_CRM_PERM_NONE)) { $arMenuCrm[] = array(GetMessage("CRM_EVENT"), "#SITE_DIR#crm/events/", array(), array(), ""); } if (!$CrmPerms->HavePerm('LEAD', BX_CRM_PERM_NONE) || !$CrmPerms->HavePerm('CONTACT', BX_CRM_PERM_NONE) || !$CrmPerms->HavePerm('COMPANY', BX_CRM_PERM_NONE) || !$CrmPerms->HavePerm('DEAL', BX_CRM_PERM_NONE)) { $arMenuCrm[] = array(GetMessage("CRM_REPORTS"), CModule::IncludeModule('report') ? "#SITE_DIR#crm/reports/report/" : "#SITE_DIR#crm/reports/", array(), array(), ""); $arMenuCrm[] = array(GetMessage("CRM_HELP"), "#SITE_DIR#crm/info/", array(), array(), ""); } if (!$CrmPerms->HavePerm('CONFIG', BX_CRM_PERM_NONE)) {
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/intranet/public/crm/company/.left.menu_ext.php"); if (CModule::IncludeModule('crm')) { $CrmPerms = new CCrmPerms($GLOBALS['USER']->GetID()); $aMenuLinksExt = array(); if (!$CrmPerms->HavePerm('COMPANY', BX_CRM_PERM_NONE, 'ADD')) { $aMenuLinksExt[] = array(GetMessage("MENU_CRM_COMPANY_ADD"), '/crm/company/edit/0/', array(), array(), ''); } if (!$CrmPerms->HavePerm('COMPANY', BX_CRM_PERM_NONE, 'READ')) { $aMenuLinksExt[] = array(GetMessage("MENU_CRM_COMPANY_LIST"), '/crm/company/list/', array(), array(), ''); } if (!$CrmPerms->HavePerm('COMPANY', BX_CRM_PERM_NONE, 'ADD')) { $aMenuLinksExt[] = array(GetMessage("MENU_CRM_COMPANY_IMPORT"), '/crm/company/import/', array(), array(), ''); } $aMenuLinks = array_merge($aMenuLinks, $aMenuLinksExt); }