当前位置: 首页>>代码示例>>PHP>>正文


PHP CCrmPerms::GetUserPermissions方法代码示例

本文整理汇总了PHP中CCrmPerms::GetUserPermissions方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmPerms::GetUserPermissions方法的具体用法?PHP CCrmPerms::GetUserPermissions怎么用?PHP CCrmPerms::GetUserPermissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCrmPerms的用法示例。


在下文中一共展示了CCrmPerms::GetUserPermissions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:15,代码来源:dealdatasource.php

示例2: 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;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:55,代码来源:duplicatecriterion.php

示例3: 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;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:13,代码来源:dedupedatasource.php

示例4: Add

 public function Add(array &$arFields, $bUpdateSearch = true, $arOptions = array())
 {
     global $DB;
     $this->LAST_ERROR = '';
     if (!is_array($arOptions)) {
         $arOptions = array();
     }
     if (isset($arOptions['CURRENT_USER'])) {
         $iUserId = intval($arOptions['CURRENT_USER']);
     } else {
         $iUserId = CCrmPerms::GetCurrentUserID();
     }
     if (isset($arFields['DATE_CREATE'])) {
         unset($arFields['DATE_CREATE']);
     }
     $arFields['~DATE_CREATE'] = $DB->CurrentTimeFunction();
     $arFields['~DATE_MODIFY'] = $DB->CurrentTimeFunction();
     if (!isset($arFields['CREATED_BY_ID']) || (int) $arFields['CREATED_BY_ID'] <= 0) {
         $arFields['CREATED_BY_ID'] = $iUserId;
     }
     if (!isset($arFields['MODIFY_BY_ID']) || (int) $arFields['MODIFY_BY_ID'] <= 0) {
         $arFields['MODIFY_BY_ID'] = $iUserId;
     }
     if (!isset($arFields['ASSIGNED_BY_ID']) || (int) $arFields['ASSIGNED_BY_ID'] <= 0) {
         $arFields['ASSIGNED_BY_ID'] = $iUserId;
     }
     if (!isset($arFields['OPPORTUNITY'])) {
         $arFields['OPPORTUNITY'] = 0.0;
     }
     if (!$this->CheckFields($arFields, false, $arOptions)) {
         $arFields['RESULT_MESSAGE'] =& $this->LAST_ERROR;
         return false;
     }
     if (isset($arFields['BIRTHDATE'])) {
         if ($arFields['BIRTHDATE'] !== '') {
             $birthDate = $arFields['BIRTHDATE'];
             $arFields['~BIRTHDATE'] = $DB->CharToDateFunction($birthDate, 'SHORT', false);
             $arFields['BIRTHDAY_SORT'] = \Bitrix\Crm\BirthdayReminder::prepareSorting($birthDate);
         } else {
             $arFields['BIRTHDAY_SORT'] = \Bitrix\Crm\BirthdayReminder::prepareSorting('');
         }
         unset($arFields['BIRTHDATE']);
     } else {
         $arFields['BIRTHDAY_SORT'] = \Bitrix\Crm\BirthdayReminder::prepareSorting('');
     }
     if (!isset($arFields['STATUS_ID']) || $arFields['STATUS_ID'] === '') {
         $arFields['STATUS_ID'] = 'NEW';
     }
     if (isset($arFields['DATE_CLOSED'])) {
         unset($arFields['DATE_CLOSED']);
     }
     self::EnsureStatusesLoaded();
     if (in_array($arFields['STATUS_ID'], self::$LEAD_STATUSES_BY_GROUP['FINISHED'])) {
         $arFields['~DATE_CLOSED'] = $DB->CurrentTimeFunction();
     }
     $arAttr = array();
     $arAttr['STATUS_ID'] = $arFields['STATUS_ID'];
     if (!empty($arFields['OPENED'])) {
         $arAttr['OPENED'] = $arFields['OPENED'];
     }
     $sPermission = 'ADD';
     if (isset($arFields['PERMISSION'])) {
         if ($arFields['PERMISSION'] == 'IMPORT') {
             $sPermission = 'IMPORT';
         }
         unset($arFields['PERMISSION']);
     }
     if ($this->bCheckPermission) {
         $arEntityAttr = self::BuildEntityAttr($iUserId, $arAttr);
         $userPerms = $iUserId == CCrmPerms::GetCurrentUserID() ? $this->cPerms : CCrmPerms::GetUserPermissions($iUserId);
         $sEntityPerm = $userPerms->GetPermType('LEAD', $sPermission, $arEntityAttr);
         if ($sEntityPerm == BX_CRM_PERM_NONE) {
             $this->LAST_ERROR = GetMessage('CRM_PERMISSION_DENIED');
             $arFields['RESULT_MESSAGE'] =& $this->LAST_ERROR;
             return false;
         }
         $assignedByID = intval($arFields['ASSIGNED_BY_ID']);
         if ($sEntityPerm == BX_CRM_PERM_SELF && $assignedByID != $iUserId) {
             $arFields['ASSIGNED_BY_ID'] = $iUserId;
         }
         if ($sEntityPerm == BX_CRM_PERM_OPEN && $iUserId == $assignedByID) {
             $arFields['OPENED'] = 'Y';
         }
     }
     $assignedByID = intval($arFields['ASSIGNED_BY_ID']);
     $arEntityAttr = self::BuildEntityAttr($assignedByID, $arAttr);
     $userPerms = $assignedByID == CCrmPerms::GetCurrentUserID() ? $this->cPerms : CCrmPerms::GetUserPermissions($assignedByID);
     $sEntityPerm = $userPerms->GetPermType('LEAD', $sPermission, $arEntityAttr);
     $this->PrepareEntityAttrs($arEntityAttr, $sEntityPerm);
     // Calculation of Account Data
     $accData = CCrmAccountingHelper::PrepareAccountingData(array('CURRENCY_ID' => isset($arFields['CURRENCY_ID']) ? $arFields['CURRENCY_ID'] : null, 'SUM' => isset($arFields['OPPORTUNITY']) ? $arFields['OPPORTUNITY'] : null, 'EXCH_RATE' => isset($arFields['EXCH_RATE']) ? $arFields['EXCH_RATE'] : null));
     if (is_array($accData)) {
         $arFields['ACCOUNT_CURRENCY_ID'] = $accData['ACCOUNT_CURRENCY_ID'];
         $arFields['OPPORTUNITY_ACCOUNT'] = $accData['ACCOUNT_SUM'];
     }
     if (isset($arFields['NAME']) || isset($arFields['LAST_NAME'])) {
         $arFields['FULL_NAME'] = trim((isset($arFields['NAME']) ? $arFields['NAME'] : '') . ' ' . (isset($arFields['LAST_NAME']) ? $arFields['LAST_NAME'] : ''));
     }
     $beforeEvents = GetModuleEvents('crm', 'OnBeforeCrmLeadAdd');
     while ($arEvent = $beforeEvents->Fetch()) {
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:crm_lead.php

示例5: isDeletable

 public function isDeletable($userID = 0, $userPermissions = null)
 {
     if (!is_int($userID)) {
         throw new Main\ArgumentTypeException('userID', 'integer');
     }
     if ($userPermissions === null) {
         $userPermissions = \CCrmPerms::GetUserPermissions($userID);
     }
     return \CCrmAuthorizationHelper::CheckDeletePermission(\CCrmOwnerType::ResolveName($this->entityTypeID), $this->entityID, $userPermissions);
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:10,代码来源:duplicateentity.php

示例6: onAfterDuplicateCreated

 protected function onAfterDuplicateCreated(Duplicate $dup, $entityTypeID, $userID, $enablePermissionCheck, $enableRanking, array &$rankings)
 {
     $name = $this->name;
     $lastName = $this->lastName;
     $secondName = $this->secondName;
     $rootEntityID = $dup->getRootEntityID();
     if ($secondName === '' && $name === '') {
         return;
     }
     $permissionSql = '';
     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;
         }
     }
     if ($secondName !== '') {
         $query = new Main\Entity\Query(DuplicatePersonMatchCodeTable::getEntity());
         $query->addSelect('ENTITY_ID');
         $query->addFilter('=ENTITY_TYPE_ID', $entityTypeID);
         $query->addFilter('=LAST_NAME', $lastName);
         $query->addFilter('=NAME', $name);
         $query->addFilter('=SECOND_NAME', '');
         if ($rootEntityID) {
             $query->addFilter('!ENTITY_ID', $rootEntityID);
             $query->addFilter('!@ENTITY_ID', DuplicateIndexMismatch::prepareQueryField(self::createFromMatches(array('LAST_NAME' => $lastName, 'NAME' => $name)), $entityTypeID, $rootEntityID, $userID));
         }
         if ($enablePermissionCheck && $permissionSql !== '') {
             $query->addFilter('@ENTITY_ID', new Main\DB\SqlExpression($permissionSql));
         }
         $dbResult = $query->exec();
         while ($fields = $dbResult->fetch()) {
             $entityID = isset($fields['ENTITY_ID']) ? intval($fields['ENTITY_ID']) : 0;
             if ($entityID <= 0) {
                 continue;
             }
             $entity = new DuplicateEntity($entityTypeID, $entityID);
             $entity->setCriterion(self::createFromMatches(array('LAST_NAME' => $lastName, 'NAME' => $name)));
             if ($enableRanking) {
                 $rankings[] = $entity->getRanking();
             }
             $dup->addEntity($entity);
         }
     }
     if ($name !== '') {
         $query = new Main\Entity\Query(DuplicatePersonMatchCodeTable::getEntity());
         $query->addSelect('ENTITY_ID');
         $query->addFilter('=ENTITY_TYPE_ID', $entityTypeID);
         $query->addFilter('=LAST_NAME', $lastName);
         $query->addFilter('=NAME', '');
         $query->addFilter('=SECOND_NAME', '');
         if ($rootEntityID) {
             $query->addFilter('!ENTITY_ID', $rootEntityID);
             $query->addFilter('!@ENTITY_ID', DuplicateIndexMismatch::prepareQueryField(self::createFromMatches(array('LAST_NAME' => $lastName)), $entityTypeID, $rootEntityID, $userID));
         }
         if ($enablePermissionCheck && $permissionSql !== '') {
             $query->addFilter('@ENTITY_ID', new Main\DB\SqlExpression($permissionSql));
         }
         $dbResult = $query->exec();
         while ($fields = $dbResult->fetch()) {
             $entityID = isset($fields['ENTITY_ID']) ? intval($fields['ENTITY_ID']) : 0;
             if ($entityID <= 0) {
                 continue;
             }
             $entity = new DuplicateEntity($entityTypeID, $entityID);
             $entity->setCriterion(self::createFromMatches(array('LAST_NAME' => $lastName)));
             if ($enableRanking) {
                 $rankings[] = $entity->getRanking();
             }
             $dup->addEntity($entity);
         }
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:78,代码来源:duplicatepersoncriterion.php

示例7: isAuthorizedUser

 protected function isAuthorizedUser()
 {
     if ($this->isAuthorizedUser === null) {
         /**@var \CCrmPerms $userPermissions @**/
         $userPermissions = CCrmPerms::GetUserPermissions($this->user->GetID());
         $this->isAuthorizedUser = $userPermissions->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'WRITE');
     }
     return $this->isAuthorizedUser;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:9,代码来源:restservice.php

示例8: loadBulk

 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);
                         }
                     }
                 }
             }
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:duplicateentityranking.php

示例9: ProcessLogEventEditPOST


//.........这里部分代码省略.........
     }
     if ($message === '') {
         $errors[] = GetMessage('CRM_SL_EVENT_EDIT_EMPTY_MESSAGE');
     }
     if (empty($errors)) {
         $fields = array('ENTITY_TYPE_ID' => $entityTypeID, 'ENTITY_ID' => $entityID, 'USER_ID' => $arResult['USER_ID'], 'TITLE' => $title, 'MESSAGE' => $message, 'RIGHTS' => $arSocnetRights);
         $parents = array();
         CCrmOwnerType::TryGetOwnerInfos($entityTypeID, $entityID, $parents, array('ENABLE_MAPPING' => true));
         foreach ($arEntityData as $entityData) {
             $curEntityTypeID = CCrmLiveFeedEntity::ResolveEntityTypeID($entityData['ENTITY_TYPE']);
             $curEntityID = $entityData['ENTITY_ID'];
             $entityKey = "{$curEntityTypeID}_{$curEntityID}";
             if (!isset($parents[$entityKey]) && !($curEntityTypeID === $entityTypeID && $curEntityID === $entityID)) {
                 $parents[$entityKey] = array('ENTITY_TYPE_ID' => $curEntityTypeID, 'ENTITY_ID' => $curEntityID);
             }
         }
         if (!empty($parents)) {
             $fields['PARENTS'] = array_values($parents);
         }
         if (!empty($attachedFiles)) {
             $fields['WEB_DAV_FILES'] = array($webDavFileFieldName => $attachedFiles);
         }
         $messageID = CCrmLiveFeed::CreateLogMessage($fields);
         if (!(is_int($messageID) && $messageID > 0)) {
             $errors[] = isset($fields['ERROR']) ? $fields['ERROR'] : 'UNKNOWN ERROR';
         } else {
             preg_match_all("/\\[user\\s*=\\s*([^\\]]*)\\](.+?)\\[\\/user\\]/is" . BX_UTF_PCRE_MODIFIER, $message, $arMention);
             if (!empty($arMention) && !empty($arMention[1]) && CModule::IncludeModule("im")) {
                 $arMention = $arMention[1];
                 $arMention = array_unique($arMention);
                 $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => "", "FROM_USER_ID" => $arResult['USER_ID'], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "crm", "NOTIFY_EVENT" => "mention");
                 $genderSuffix = "";
                 $dbUser = CUser::GetByID($arResult['USER_ID']);
                 if ($arUser = $dbUser->Fetch()) {
                     switch ($arUser["PERSONAL_GENDER"]) {
                         case "M":
                             $genderSuffix = "_M";
                             break;
                         case "F":
                             $genderSuffix = "_F";
                             break;
                         default:
                             $genderSuffix = "";
                     }
                 }
                 $strIMMessageTitle = str_replace(array("\r\n", "\n"), " ", strlen($title) > 0 ? $title : $message);
                 if (CModule::IncludeModule("blog")) {
                     $strIMMessageTitle = trim(blogTextParser::killAllTags($strIMMessageTitle));
                 }
                 $strIMMessageTitle = TruncateText($strIMMessageTitle, 100);
                 $strIMMessageTitleOut = TruncateText($strIMMessageTitle, 255);
                 $strLogEntryURL = COption::GetOptionString("socialnetwork", "log_entry_page", SITE_DIR . "company/personal/log/#log_id#/", SITE_ID);
                 $strLogEntryURL = CComponentEngine::MakePathFromTemplate($strLogEntryURL, array("log_id" => $messageID));
                 $strLogEntryCrmURL = CComponentEngine::MakePathFromTemplate(SITE_DIR . "crm/stream/?log_id=#log_id#", array("log_id" => $messageID));
                 $serverName = (CMain::IsHTTPS() ? "https" : "http") . "://" . (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0 ? SITE_SERVER_NAME : COption::GetOptionString("main", "server_name", ""));
                 foreach ($arMention as $val) {
                     $val = IntVal($val);
                     if ($val > 0 && $val != $arResult['USER_ID']) {
                         $bHasAccess = false;
                         if (in_array('U' . $val, $arSocnetRights)) {
                             $url = $strLogEntryURL;
                             $bHasAccess = true;
                         }
                         if (!$bHasAccess) {
                             $arAccessCodes = array();
                             $dbAccess = CAccess::GetUserCodes($val);
                             while ($arAccess = $dbAccess->Fetch()) {
                                 $arAccessCodes[] = $arAccess["ACCESS_CODE"];
                             }
                             $arTmp = array_intersect($arAccess, $arSocnetRights);
                             if (!empty($arTmp)) {
                                 $url = $strLogEntryURL;
                                 $bHasAccess = true;
                             }
                         }
                         if (!$bHasAccess) {
                             $userPermissions = CCrmPerms::GetUserPermissions($val);
                             foreach ($arEntityData as $arEntity) {
                                 if (CCrmAuthorizationHelper::CheckReadPermission(CCrmOwnerType::ResolveName(CCrmLiveFeedEntity::ResolveEntityTypeID($arEntity['ENTITY_TYPE'])), $arEntity['ENTITY_ID'], $userPermissions)) {
                                     $url = $strLogEntryCrmURL;
                                     $bHasAccess = true;
                                     break;
                                 }
                             }
                         }
                         if ($bHasAccess) {
                             $arMessageFields["TO_USER_ID"] = $val;
                             $arMessageFields["NOTIFY_TAG"] = "CRM|MESSAGE_MENTION|" . $messageID;
                             $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("CRM_SL_EVENT_IM_MENTION_POST" . $genderSuffix, array("#title#" => "<a href=\"" . $url . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($strIMMessageTitle) . "</a>"));
                             $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("CRM_SL_EVENT_IM_MENTION_POST" . $genderSuffix, array("#title#" => htmlspecialcharsbx($strIMMessageTitleOut))) . " (" . $serverName . $url . ")";
                             CIMNotify::Add($arMessageFields);
                         }
                     }
                 }
             }
             return $messageID;
         }
     }
     return $errors;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:livefeed.php

示例10: Add

 public function Add(&$arFields, $bUpdateSearch = true, $options = array())
 {
     global $DB;
     if (!is_array($options)) {
         $options = array();
     }
     $this->LAST_ERROR = '';
     $iUserId = CCrmSecurityHelper::GetCurrentUserID();
     if (isset($arFields['ID'])) {
         unset($arFields['ID']);
     }
     if (isset($arFields['DATE_CREATE'])) {
         unset($arFields['DATE_CREATE']);
     }
     $arFields['~DATE_CREATE'] = $DB->CurrentTimeFunction();
     $arFields['~DATE_MODIFY'] = $DB->CurrentTimeFunction();
     if (!isset($arFields['CREATED_BY_ID']) || (int) $arFields['CREATED_BY_ID'] <= 0) {
         $arFields['CREATED_BY_ID'] = $iUserId;
     }
     if (!isset($arFields['MODIFY_BY_ID']) || (int) $arFields['MODIFY_BY_ID'] <= 0) {
         $arFields['MODIFY_BY_ID'] = $iUserId;
     }
     if (isset($arFields['ASSIGNED_BY_ID']) && is_array($arFields['ASSIGNED_BY_ID'])) {
         $arFields['ASSIGNED_BY_ID'] = count($arFields['ASSIGNED_BY_ID']) > 0 ? intval($arFields['ASSIGNED_BY_ID'][0]) : $iUserId;
     }
     if (!isset($arFields['ASSIGNED_BY_ID']) || (int) $arFields['ASSIGNED_BY_ID'] <= 0) {
         $arFields['ASSIGNED_BY_ID'] = $iUserId;
     }
     // person type
     if (!isset($arFields['PERSON_TYPE_ID']) || intval($arFields['PERSON_TYPE_ID']) <= 0) {
         $arFields['PERSON_TYPE_ID'] = 0;
         $arPersonTypes = CCrmPaySystem::getPersonTypeIDs();
         if (isset($arPersonTypes['CONTACT']) && (!isset($arFields['COMPANY_ID']) || intval($arFields['COMPANY_ID']) <= 0)) {
             $arFields['PERSON_TYPE_ID'] = intval($arPersonTypes['CONTACT']);
         } else {
             if (isset($arPersonTypes['COMPANY']) && isset($arFields['COMPANY_ID']) && intval($arFields['COMPANY_ID']) > 0) {
                 $arFields['PERSON_TYPE_ID'] = intval($arPersonTypes['COMPANY']);
             }
         }
     }
     // storage type
     $storageTypeID = isset($arFields['STORAGE_TYPE_ID']) ? intval($arFields['STORAGE_TYPE_ID']) : CCrmQuoteStorageType::Undefined;
     if ($storageTypeID === CCrmQuoteStorageType::Undefined || !CCrmQuoteStorageType::IsDefined($storageTypeID)) {
         $storageTypeID = self::GetDefaultStorageTypeID();
     }
     $arFields['STORAGE_TYPE_ID'] = $storageTypeID;
     // storage elements
     $storageElementIDs = isset($arFields['STORAGE_ELEMENT_IDS']) && is_array($arFields['STORAGE_ELEMENT_IDS']) ? $arFields['STORAGE_ELEMENT_IDS'] : null;
     $arFields['STORAGE_ELEMENT_IDS'] = null;
     if ($storageElementIDs !== null) {
         $storageElementIDs = self::NormalizeStorageElementIDs($storageElementIDs);
         $arFields['STORAGE_ELEMENT_IDS'] = serialize($storageElementIDs);
     }
     if (!$this->CheckFields($arFields, false, $options)) {
         $result = false;
         $arFields['RESULT_MESSAGE'] =& $this->LAST_ERROR;
     } else {
         if (!isset($arFields['STATUS_ID'])) {
             $arFields['STATUS_ID'] = 'DRAFT';
         }
         $arAttr = array();
         if (!empty($arFields['STATUS_ID'])) {
             $arAttr['STATUS_ID'] = $arFields['STATUS_ID'];
         }
         if (!empty($arFields['OPENED'])) {
             $arAttr['OPENED'] = $arFields['OPENED'];
         }
         $sPermission = 'ADD';
         if (isset($arFields['PERMISSION'])) {
             if ($arFields['PERMISSION'] == 'IMPORT') {
                 $sPermission = 'IMPORT';
             }
             unset($arFields['PERMISSION']);
         }
         if ($this->bCheckPermission) {
             $arEntityAttr = self::BuildEntityAttr($iUserId, $arAttr);
             $userPerms = $iUserId == CCrmPerms::GetCurrentUserID() ? $this->cPerms : CCrmPerms::GetUserPermissions($iUserId);
             $sEntityPerm = $userPerms->GetPermType('QUOTE', $sPermission, $arEntityAttr);
             if ($sEntityPerm == BX_CRM_PERM_NONE) {
                 $this->LAST_ERROR = GetMessage('CRM_PERMISSION_DENIED');
                 $arFields['RESULT_MESSAGE'] =& $this->LAST_ERROR;
                 return false;
             }
             $assignedByID = intval($arFields['ASSIGNED_BY_ID']);
             if ($sEntityPerm == BX_CRM_PERM_SELF && $assignedByID != $iUserId) {
                 $arFields['ASSIGNED_BY_ID'] = $iUserId;
             }
             if ($sEntityPerm == BX_CRM_PERM_OPEN && $iUserId == $assignedByID) {
                 $arFields['OPENED'] = 'Y';
             }
         }
         $assignedByID = intval($arFields['ASSIGNED_BY_ID']);
         $arEntityAttr = self::BuildEntityAttr($assignedByID, $arAttr);
         $userPerms = $assignedByID == CCrmPerms::GetCurrentUserID() ? $this->cPerms : CCrmPerms::GetUserPermissions($assignedByID);
         $sEntityPerm = $userPerms->GetPermType('QUOTE', $sPermission, $arEntityAttr);
         $this->PrepareEntityAttrs($arEntityAttr, $sEntityPerm);
         // Calculation of Account Data
         $accData = CCrmAccountingHelper::PrepareAccountingData(array('CURRENCY_ID' => isset($arFields['CURRENCY_ID']) ? $arFields['CURRENCY_ID'] : null, 'SUM' => isset($arFields['OPPORTUNITY']) ? $arFields['OPPORTUNITY'] : null, 'EXCH_RATE' => isset($arFields['EXCH_RATE']) ? $arFields['EXCH_RATE'] : null));
         if (is_array($accData)) {
             $arFields['ACCOUNT_CURRENCY_ID'] = $accData['ACCOUNT_CURRENCY_ID'];
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:crm_quote.php

示例11: GetDataForPopup


//.........这里部分代码省略.........
                 $entityData = $crm[$entity][0];
                 $arResult['CONTACT'] = array('ID' => 0, 'NAME' => !empty($entityData['FORMATTED_NAME']) ? $entityData['FORMATTED_NAME'] : $entityData['TITLE'], 'POST' => $entityData['POST'], 'PHOTO' => '');
                 $arResult['COMPANY'] = $entityData['COMPANY_TITLE'];
                 $arResult['LEAD_DATA'] = array('ID' => $entityData['ID'], 'ASSIGNED_BY_ID' => $entityData['ASSIGNED_BY_ID']);
             } else {
                 if (isset($crm['COMPANY'])) {
                     $entity = 'COMPANY';
                     $entityData = $crm[$entity][0];
                     $arResult['COMPANY'] = $entityData['TITLE'];
                     $arResult['COMPANY_DATA'] = array('ID' => $entityData['ID']);
                 }
             }
         }
         if ($entityData['ASSIGNED_BY_ID'] > 0) {
             $ar = Bitrix\Main\UserTable::getById($entityData['ASSIGNED_BY_ID']);
             if ($user = $ar->fetch()) {
                 $arPhoto = CFile::ResizeImageGet($user['PERSONAL_PHOTO'], array('width' => 37, 'height' => 37), BX_RESIZE_IMAGE_EXACT, false, false, true);
                 $arResult['RESPONSIBILITY'] = array('ID' => $user['ID'], 'NAME' => CUser::FormatName(CSite::GetNameFormat(false), $user, true, false), 'PHOTO' => $arPhoto ? $arPhoto['src'] : '', 'POST' => $user['WORK_POSITION']);
             }
         }
         if (isset($entityData['SHOW_URL'])) {
             $arResult['SHOW_URL'] = $entityData['SHOW_URL'];
         }
         if (isset($entityData['ACTIVITY_LIST_URL'])) {
             $arResult['ACTIVITY_URL'] = $entityData['ACTIVITY_LIST_URL'];
         }
         if (isset($entityData['INVOICE_LIST_URL'])) {
             $arResult['INVOICE_URL'] = $entityData['INVOICE_LIST_URL'];
         }
         if (isset($entityData['DEAL_LIST_URL'])) {
             $arResult['DEAL_URL'] = $entityData['DEAL_LIST_URL'];
         }
         $activityId = CCrmActivity::GetIDByOrigin('VI_' . $callId);
         if ($activityId) {
             $arResult['CURRENT_CALL_URL'] = CCrmOwnerType::GetEditUrl(CCrmOwnerType::Activity, $activityId);
             if ($arResult['CURRENT_CALL_URL'] !== '') {
                 $arResult['CURRENT_CALL_URL'] = CCrmUrlUtil::AddUrlParams($arResult['CURRENT_CALL_URL'], array("disable_storage_edit" => 'Y'));
             }
         }
         if (isset($crm['CONTACT']) && isset($crm['COMPANY'])) {
             $entities = array('CONTACT', 'COMPANY', 'LEAD');
         } else {
             if (isset($crm['CONTACT']) && isset($crm['LEAD']) && !isset($crm['COMPANY'])) {
                 $entities = array('CONTACT', 'LEAD');
             } else {
                 if (isset($crm['LEAD']) && isset($crm['COMPANY']) && !isset($crm['CONTACT'])) {
                     $entities = array('LEAD', 'COMPANY');
                 } else {
                     $entities = array($entity);
                 }
             }
         }
         foreach ($entities as $entity) {
             if (isset($crm[$entity][0]['ACTIVITIES'])) {
                 foreach ($crm[$entity][0]['ACTIVITIES'] as $activity) {
                     if ($activity['ID'] == $activityId) {
                         continue;
                     }
                     $overdue = 'N';
                     if (strlen($activity['DEADLINE']) > 0 && MakeTimeStamp($activity['DEADLINE']) < time()) {
                         $overdue = 'Y';
                     }
                     $arResult['ACTIVITIES'][$activity['ID']] = array('TITLE' => $activity['SUBJECT'], 'DATE' => strlen($activity['DEADLINE']) > 0 ? $activity['DEADLINE'] : $activity['END_TIME'], 'OVERDUE' => $overdue, 'URL' => $activity['SHOW_URL']);
                 }
                 if (!empty($arResult['ACTIVITIES'])) {
                     $arResult['ACTIVITIES'] = array_values($arResult['ACTIVITIES']);
                 }
             }
             if (isset($crm[$entity][0]['DEALS'])) {
                 foreach ($crm[$entity][0]['DEALS'] as $deal) {
                     $opportunity = CCrmCurrency::MoneyToString($deal['OPPORTUNITY'], $deal['CURRENCY_ID']);
                     if (strpos('&', $opportunity)) {
                         $opportunity = CCrmCurrency::MoneyToString($deal['OPPORTUNITY'], $deal['CURRENCY_ID'], '#') . ' ' . $deal['CURRENCY_ID'];
                     }
                     $opportunity = str_replace('.00', '', $opportunity);
                     $arResult['DEALS'][$deal['ID']] = array('ID' => $deal['ID'], 'TITLE' => $deal['TITLE'], 'STAGE' => $dealStatuses[$deal['STAGE_ID']]['NAME'], 'STAGE_COLOR' => $dealStatuses[$deal['STAGE_ID']]['COLOR'] ? $dealStatuses[$deal['STAGE_ID']]['COLOR'] : "#5fa0ce", 'OPPORTUNITY' => $opportunity, 'URL' => $deal['SHOW_URL']);
                 }
                 if (!empty($arResult['DEALS'])) {
                     $arResult['DEALS'] = array_values($arResult['DEALS']);
                 }
             }
         }
     } else {
         $arResult = array('FOUND' => 'N');
         $userPermissions = CCrmPerms::GetUserPermissions($userId);
         if (CCrmLead::CheckCreatePermission($userPermissions)) {
             $arResult['LEAD_URL'] = CCrmOwnerType::GetEditUrl(CCrmOwnerType::Lead, 0);
             if ($arResult['LEAD_URL'] !== '') {
                 $arResult['LEAD_URL'] = CCrmUrlUtil::AddUrlParams($arResult['LEAD_URL'], array("phone" => (string) $phone, 'origin_id' => 'VI_' . $callId));
             }
         }
         if (CCrmContact::CheckCreatePermission($userPermissions)) {
             $arResult['CONTACT_URL'] = CCrmOwnerType::GetEditUrl(CCrmOwnerType::Contact, 0);
             if ($arResult['CONTACT_URL'] !== '') {
                 $arResult['CONTACT_URL'] = CCrmUrlUtil::AddUrlParams($arResult['CONTACT_URL'], array("phone" => (string) $phone, 'origin_id' => 'VI_' . $callId));
             }
         }
     }
     return $arResult;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:vi_crm_helper.php

示例12: findByPhoneNumber

 public static function findByPhoneNumber($number, $params = array())
 {
     if (!is_string($number)) {
         throw new \Bitrix\Main\ArgumentTypeException('number', 'string');
     }
     if ($number === '') {
         throw new \Bitrix\Main\ArgumentException('Is empty', 'number');
     }
     if (!is_array($params)) {
         $params = array();
     }
     $userID = isset($params['USER_ID']) ? intval($params['USER_ID']) : 0;
     if ($userID <= 0) {
         $userID = CCrmPerms::GetCurrentUserID();
     }
     $isAdmin = CCrmPerms::IsAdmin($userID);
     $userPermissions = CCrmPerms::GetUserPermissions($userID);
     $enableExtendedMode = isset($params['ENABLE_EXTENDED_MODE']) ? (bool) $params['ENABLE_EXTENDED_MODE'] : true;
     $contactFormID = isset($params['CONTACT_FORM_ID']) ? intval($params['CONTACT_FORM_ID']) : '';
     if ($contactFormID === '') {
         $contactFormID = CCrmContact::DEFAULT_FORM_ID;
     }
     $dups = array();
     $criterion = new \Bitrix\Crm\Integrity\DuplicateCommunicationCriterion('PHONE', $number);
     $entityTypes = array(CCrmOwnerType::Contact, CCrmOwnerType::Company, CCrmOwnerType::Lead);
     foreach ($entityTypes as $entityType) {
         $duplicate = $criterion->find($entityType, 1);
         if ($duplicate !== null) {
             $dups[] = $duplicate;
         }
     }
     $entityByType = array();
     foreach ($dups as &$dup) {
         /** @var \Bitrix\Crm\Integrity\Duplicate $dup */
         $entities = $dup->getEntities();
         if (!(is_array($entities) && !empty($entities))) {
             continue;
         }
         //Each entity type limited by 50 items
         foreach ($entities as &$entity) {
             /** @var \Bitrix\Crm\Integrity\DuplicateEntity $entity */
             $entityTypeID = $entity->getEntityTypeID();
             $entityID = $entity->getEntityID();
             $fields = null;
             if ($entityTypeID === CCrmOwnerType::Contact) {
                 $dbEntity = CCrmContact::GetListEx(array(), array('=ID' => $entityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'PHOTO', 'POST', 'COMPANY_ID', 'COMPANY_TITLE', 'ASSIGNED_BY_ID'));
                 $entityFields = is_object($dbEntity) ? $dbEntity->Fetch() : null;
                 if (is_array($entityFields)) {
                     $formattedName = CCrmContact::PrepareFormattedName(array('HONORIFIC' => isset($entityFields['HONORIFIC']) ? $entityFields['HONORIFIC'] : '', 'NAME' => isset($entityFields['NAME']) ? $entityFields['NAME'] : '', 'SECOND_NAME' => isset($entityFields['SECOND_NAME']) ? $entityFields['SECOND_NAME'] : '', 'LAST_NAME' => isset($entityFields['LAST_NAME']) ? $entityFields['LAST_NAME'] : ''));
                     $fields = array('ID' => intval($entityFields['ID']), 'FORMATTED_NAME' => $formattedName, 'PHOTO' => isset($entityFields['PHOTO']) ? intval($entityFields['PHOTO']) : 0, 'COMPANY_ID' => isset($entityFields['COMPANY_ID']) ? intval($entityFields['COMPANY_ID']) : 0, 'COMPANY_TITLE' => isset($entityFields['COMPANY_TITLE']) ? $entityFields['COMPANY_TITLE'] : '', 'POST' => isset($entityFields['POST']) ? $entityFields['POST'] : '', 'ASSIGNED_BY_ID' => isset($entityFields['ASSIGNED_BY_ID']) ? intval($entityFields['ASSIGNED_BY_ID']) : 0, 'CAN_READ' => CCrmContact::CheckReadPermission($entityID, $userPermissions));
                     if ($fields['CAN_READ'] && $enableExtendedMode) {
                         $deals = array();
                         $dbDeal = CCrmDeal::GetListEx(array('BEGINDATE' => 'ASC'), array('=CONTACT_ID' => $entityID, 'CLOSED' => 'N', 'CHECK_PERMISSIONS' => $isAdmin ? 'N' : 'Y'), false, array('nTopCount' => 2), array('ID', 'TITLE', 'STAGE_ID'), array('PERMS' => $userPermissions));
                         if (is_object($dbDeal)) {
                             while ($dealFields = $dbDeal->Fetch()) {
                                 $dealID = intval($dealFields['ID']);
                                 //$dealFields['CAN_READ'] = CCrmDeal::CheckReadPermission($dealID, $userPermissions);
                                 $dealFields['SHOW_URL'] = CCrmOwnerType::GetShowUrl(CCrmOwnerType::Deal, $dealID);
                                 $deals[] = $dealFields;
                             }
                         }
                         $fields['DEALS'] =& $deals;
                         unset($deals);
                     }
                 }
             } elseif ($entityTypeID === CCrmOwnerType::Company) {
                 $dbEntity = CCrmCompany::GetListEx(array(), array('=ID' => $entityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID', 'TITLE', 'LOGO', 'ASSIGNED_BY_ID'));
                 $entityFields = is_object($dbEntity) ? $dbEntity->Fetch() : null;
                 if (is_array($entityFields)) {
                     $fields = array('ID' => intval($entityFields['ID']), 'TITLE' => isset($entityFields['TITLE']) ? $entityFields['TITLE'] : '', 'LOGO' => isset($entityFields['LOGO']) ? intval($entityFields['LOGO']) : 0, 'ASSIGNED_BY_ID' => isset($entityFields['ASSIGNED_BY_ID']) ? intval($entityFields['ASSIGNED_BY_ID']) : 0, 'CAN_READ' => CCrmCompany::CheckReadPermission($entityID, $userPermissions));
                     if ($fields['CAN_READ'] && $enableExtendedMode) {
                         $deals = array();
                         $dbDeal = CCrmDeal::GetListEx(array('BEGINDATE' => 'ASC'), array('=COMPANY_ID' => $entityID, 'CLOSED' => 'N', 'CHECK_PERMISSIONS' => $isAdmin ? 'N' : 'Y'), false, array('nTopCount' => 2), array('ID', 'TITLE', 'STAGE_ID'), array('PERMS' => $userPermissions));
                         if (is_object($dbDeal)) {
                             while ($dealFields = $dbDeal->Fetch()) {
                                 $dealID = intval($dealFields['ID']);
                                 //$dealFields['CAN_READ'] = CCrmDeal::CheckReadPermission($dealID, $userPermissions);
                                 $dealFields['SHOW_URL'] = CCrmOwnerType::GetShowUrl(CCrmOwnerType::Deal, $dealID);
                                 $deals[] = $dealFields;
                             }
                         }
                         $fields['DEALS'] =& $deals;
                         unset($deals);
                     }
                 }
             } elseif ($entityTypeID === CCrmOwnerType::Lead) {
                 $dbEntity = CCrmLead::GetListEx(array(), array('=ID' => $entityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID', 'TITLE', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'POST', 'COMPANY_TITLE', 'ASSIGNED_BY_ID'));
                 $entityFields = is_object($dbEntity) ? $dbEntity->Fetch() : null;
                 if (is_array($entityFields)) {
                     $formattedName = '';
                     if (!empty($entityFields['NAME']) || !empty($entityFields['SECOND_NAME']) || !empty($entityFields['LAST_NAME'])) {
                         $formattedName = CCrmLead::PrepareFormattedName(array('HONORIFIC' => isset($entityFields['HONORIFIC']) ? $entityFields['HONORIFIC'] : '', 'NAME' => isset($entityFields['NAME']) ? $entityFields['NAME'] : '', 'SECOND_NAME' => isset($entityFields['SECOND_NAME']) ? $entityFields['SECOND_NAME'] : '', 'LAST_NAME' => isset($entityFields['LAST_NAME']) ? $entityFields['LAST_NAME'] : ''));
                     }
                     $fields = array('ID' => intval($entityFields['ID']), 'TITLE' => isset($entityFields['TITLE']) ? $entityFields['TITLE'] : '', 'FORMATTED_NAME' => $formattedName, 'COMPANY_TITLE' => isset($entityFields['COMPANY_TITLE']) ? $entityFields['COMPANY_TITLE'] : '', 'POST' => isset($entityFields['POST']) ? $entityFields['POST'] : '', 'ASSIGNED_BY_ID' => isset($entityFields['ASSIGNED_BY_ID']) ? intval($entityFields['ASSIGNED_BY_ID']) : 0, 'CAN_READ' => CCrmLead::CheckReadPermission($entityID, $userPermissions));
                 }
             }
             if (!is_array($fields)) {
                 continue;
             }
             if ($fields['CAN_READ'] && $enableExtendedMode) {
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:sip_helper.php

示例13: Add

 public function Add($arFields, &$arRecalculated = false, $siteId = SITE_ID, $options = array())
 {
     /** @global \CDatabase $DB */
     global $DB;
     if (!CModule::IncludeModule('sale')) {
         return false;
     }
     if (!is_array($options)) {
         $options = array();
     }
     $bRecalculate = is_array($arRecalculated);
     $orderID = false;
     $tmpOrderId = intval($arFields['ID']) <= 0 ? 0 : $arFields['ID'];
     if (isset($arFields['ID'])) {
         unset($arFields['ID']);
     }
     $arPrevOrder = $tmpOrderId !== 0 ? CCrmInvoice::GetByID($tmpOrderId) : null;
     $userId = CCrmSecurityHelper::GetCurrentUserID();
     if (!isset($arFields['RESPONSIBLE_ID']) || (int) $arFields['RESPONSIBLE_ID'] <= 0) {
         if (is_array($arPrevOrder) && isset($arPrevOrder['RESPONSIBLE_ID']) && intval($arPrevOrder['RESPONSIBLE_ID']) > 0) {
             $arFields['RESPONSIBLE_ID'] = $arPrevOrder['RESPONSIBLE_ID'];
         } else {
             $arFields['RESPONSIBLE_ID'] = $userId;
         }
     }
     $orderStatus = '';
     if (isset($arFields['STATUS_ID'])) {
         $orderStatus = $arFields['STATUS_ID'];
         unset($arFields['STATUS_ID']);
     }
     // prepare entity permissions
     $arAttr = array();
     if (!empty($arFields['OPENED'])) {
         $arAttr['OPENED'] = $arFields['OPENED'];
     }
     $sPermission = $tmpOrderId > 0 ? 'WRITE' : 'ADD';
     if ($this->bCheckPermission) {
         $arEntityAttr = self::BuildEntityAttr($userId, $arAttr);
         $userPerms = $userId == CCrmPerms::GetCurrentUserID() ? $this->cPerms : CCrmPerms::GetUserPermissions($userId);
         $sEntityPerm = $userPerms->GetPermType('INVOICE', $sPermission, $arEntityAttr);
         if ($sEntityPerm == BX_CRM_PERM_NONE) {
             $this->LAST_ERROR = GetMessage('CRM_PERMISSION_DENIED');
             $GLOBALS['APPLICATION']->ThrowException($this->LAST_ERROR);
             return false;
         }
         $responsibleID = intval($arFields['RESPONSIBLE_ID']);
         if ($sEntityPerm == BX_CRM_PERM_SELF && $responsibleID != $userId) {
             $arFields['RESPONSIBLE_ID'] = $userId;
         }
         if ($sEntityPerm == BX_CRM_PERM_OPEN && $userId == $responsibleID) {
             $arFields['OPENED'] = 'Y';
         }
     }
     $responsibleID = intval($arFields['RESPONSIBLE_ID']);
     $arEntityAttr = self::BuildEntityAttr($responsibleID, $arAttr);
     $userPerms = $responsibleID == CCrmPerms::GetCurrentUserID() ? $this->cPerms : CCrmPerms::GetUserPermissions($responsibleID);
     $sEntityPerm = $userPerms->GetPermType('INVOICE', $sPermission, $arEntityAttr);
     $this->PrepareEntityAttrs($arEntityAttr, $sEntityPerm);
     // date fields
     if ($tmpOrderId === 0) {
         $arFields['~DATE_BILL'] = $DB->CharToDateFunction(isset($arFields['DATE_BILL']) && $arFields['DATE_BILL'] !== '' ? $arFields['DATE_BILL'] : ConvertTimeStamp(time(), 'SHORT', SITE_ID), 'SHORT', false);
     } else {
         if (isset($arFields['DATE_BILL']) && $arFields['DATE_BILL'] !== '') {
             $arFields['~DATE_BILL'] = $DB->CharToDateFunction($arFields['DATE_BILL'], 'SHORT', false);
         }
     }
     unset($arFields['DATE_BILL']);
     if (isset($arFields['DATE_PAY_BEFORE']) && $arFields['DATE_PAY_BEFORE'] !== '') {
         $arFields['~DATE_PAY_BEFORE'] = $DB->CharToDateFunction($arFields['DATE_PAY_BEFORE'], 'SHORT', false);
     }
     unset($arFields['DATE_PAY_BEFORE']);
     if ($tmpOrderId !== 0 && !isset($arFields['PRODUCT_ROWS']) && !isset($arFields['INVOICE_PROPERTIES'])) {
         if (!is_array($arPrevOrder)) {
             return false;
         }
         $prevResponsibleID = isset($arPrevOrder['RESPONSIBLE_ID']) ? intval($arPrevOrder['RESPONSIBLE_ID']) : 0;
         $responsibleID = isset($arFields['RESPONSIBLE_ID']) ? intval($arFields['RESPONSIBLE_ID']) : 0;
         $prevStatusID = isset($arPrevOrder['STATUS_ID']) ? $arPrevOrder['STATUS_ID'] : '';
         // simple update order fields
         $CSaleOrder = new CSaleOrder();
         $orderID = $CSaleOrder->Update($tmpOrderId, $arFields);
         CCrmEntityHelper::NormalizeUserFields($arFields, self::$sUFEntityID, $GLOBALS['USER_FIELD_MANAGER'], array('IS_NEW' => false));
         $GLOBALS['USER_FIELD_MANAGER']->Update(self::$sUFEntityID, $tmpOrderId, $arFields);
         $registerSonetEvent = isset($options['REGISTER_SONET_EVENT']) && $options['REGISTER_SONET_EVENT'] === true;
         if (is_int($orderID) && $orderID > 0) {
             if ($registerSonetEvent) {
                 $newDealID = isset($arFields['UF_DEAL_ID']) ? intval($arFields['UF_DEAL_ID']) : 0;
                 $oldDealID = isset($arPrevOrder['UF_DEAL_ID']) ? intval($arPrevOrder['UF_DEAL_ID']) : 0;
                 $newCompanyID = isset($arFields['UF_COMPANY_ID']) ? intval($arFields['UF_COMPANY_ID']) : 0;
                 $oldCompanyID = isset($arPrevOrder['UF_COMPANY_ID']) ? intval($arPrevOrder['UF_COMPANY_ID']) : 0;
                 $newContactID = isset($arFields['UF_CONTACT_ID']) ? intval($arFields['UF_CONTACT_ID']) : 0;
                 $oldContactID = isset($arPrevOrder['UF_CONTACT_ID']) ? intval($arPrevOrder['UF_CONTACT_ID']) : 0;
                 $parents = array();
                 $parentsChanged = $newDealID !== $oldDealID || $newCompanyID !== $oldCompanyID || $newContactID !== $oldContactID;
                 if ($parentsChanged) {
                     if ($newDealID > 0) {
                         $parents[] = array('ENTITY_TYPE_ID' => CCrmOwnerType::Deal, 'ENTITY_ID' => $newDealID);
                     }
                     if ($newCompanyID > 0) {
                         $parents[] = array('ENTITY_TYPE_ID' => CCrmOwnerType::Company, 'ENTITY_ID' => $newCompanyID);
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:crm_invoice.php

示例14: getRegisteredCodes

 public static function getRegisteredCodes($entityTypeID, $entityID, $enablePermissionCheck = false, $userID = 0, $limit = 50)
 {
     if (!is_int($entityTypeID)) {
         throw new Main\ArgumentTypeException('entityTypeID', 'integer');
     }
     if (!is_int($entityID)) {
         throw new Main\ArgumentTypeException('entityID', 'integer');
     }
     if (!is_int($userID)) {
         throw new Main\ArgumentTypeException('userID', 'integer');
     }
     if (!is_bool($enablePermissionCheck)) {
         throw new Main\ArgumentTypeException('enablePermissionCheck', 'boolean');
     }
     if (!is_int($limit)) {
         throw new Main\ArgumentTypeException('limit', 'integer');
     }
     $query = new Main\Entity\Query(DuplicateCommunicationMatchCodeTable::getEntity());
     $query->addSelect('TYPE');
     $query->addSelect('VALUE');
     $query->addFilter('=ENTITY_TYPE_ID', $entityTypeID);
     $query->addFilter('=ENTITY_ID', $entityID);
     if ($enablePermissionCheck && $userID > 0) {
         $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 array();
         } elseif ($permissionSql !== '') {
             $query->addFilter('@ENTITY_ID', new Main\DB\SqlExpression($permissionSql));
         }
     }
     if ($limit > 0) {
         $query->setLimit($limit);
     }
     $dbResult = $query->exec();
     $results = array();
     while ($fields = $dbResult->fetch()) {
         $type = isset($fields['TYPE']) ? $fields['TYPE'] : '';
         $value = isset($fields['VALUE']) ? $fields['VALUE'] : '';
         if (!isset($results[$type])) {
             $results[$type] = array();
         }
         $results[$type][] = $value;
     }
     return $results;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:50,代码来源:duplicatecommunicationcriterion.php

示例15: getUserPermissions

 protected function getUserPermissions()
 {
     if ($this->userPermissions === null) {
         $this->userPermissions = \CCrmPerms::GetUserPermissions($this->userID);
     }
     return $this->userPermissions;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:7,代码来源:entitymerger.php


注:本文中的CCrmPerms::GetUserPermissions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。