本文整理汇总了PHP中CCrmPerms类的典型用法代码示例。如果您正苦于以下问题:PHP CCrmPerms类的具体用法?PHP CCrmPerms怎么用?PHP CCrmPerms使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCrmPerms类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CheckAuth
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;
}
示例2: checkPermissions
/**
* 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;
}
示例3: GetUserPermissions
public static function GetUserPermissions()
{
if (self::$USER_PERMISSIONS === null) {
self::$USER_PERMISSIONS = CCrmPerms::GetCurrentUserPermissions();
}
return self::$USER_PERMISSIONS;
}
示例4: getUserPermissions
/**
* @return \CCrmPerms
*/
protected function getUserPermissions()
{
if ($this->userPermissions === null) {
$this->userPermissions = \CCrmPerms::GetCurrentUserPermissions();
}
return $this->userPermissions;
}
示例5: checkRights
public function checkRights()
{
$permissions = CCrmPerms::GetCurrentUserPermissions();
if (!(CCrmPerms::IsAccessEnabled($permissions) && $permissions->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'READ'))) {
return false;
}
return true;
}
示例6: preparePermissionSql
/**
* @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;
}
示例7: checkAccessPermissions
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;
}
示例8: createDuplicate
/**
* @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;
}
示例9: preparePermissionSql
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;
}
示例10: canRead
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;
}
示例11: array
$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';
示例12: __CrmMobileDealEditEndResonse
//$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) {
示例13: Prepare
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);
//.........这里部分代码省略.........
示例14: CCrmPerms
<?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';
}
示例15: __CrmLeadListEndResonse
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'];