本文整理汇总了PHP中CCrmOwnerType::TryGetOwnerInfos方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmOwnerType::TryGetOwnerInfos方法的具体用法?PHP CCrmOwnerType::TryGetOwnerInfos怎么用?PHP CCrmOwnerType::TryGetOwnerInfos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCrmOwnerType
的用法示例。
在下文中一共展示了CCrmOwnerType::TryGetOwnerInfos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: RegisterLiveFeedEvent
private static function RegisterLiveFeedEvent(&$arFields)
{
$ID = isset($arFields['ID']) ? intval($arFields['ID']) : 0;
if ($ID <= 0) {
$arFields['ERROR'] = 'Could not find activity ID.';
return false;
}
$ownerTypeID = isset($arFields['OWNER_TYPE_ID']) ? intval($arFields['OWNER_TYPE_ID']) : CCrmOwnerType::Undefined;
if (!CCrmOwnerType::IsDefined($ownerTypeID)) {
$arFields['ERROR'] = 'Could not find owner type ID.';
return false;
}
$ownerID = isset($arFields['OWNER_ID']) ? intval($arFields['OWNER_ID']) : 0;
if ($ownerID <= 0) {
$arFields['ERROR'] = 'Could not find owner ID.';
return false;
}
$arOwners = array(array("OWNER_TYPE_ID" => $ownerTypeID, "OWNER_ID" => $ownerID));
$authorID = isset($arFields['AUTHOR_ID']) ? intval($arFields['AUTHOR_ID']) : 0;
$editorID = isset($arFields['EDITOR_ID']) ? intval($arFields['EDITOR_ID']) : 0;
$userID = $authorID > 0 ? $authorID : $editorID;
if ($userID <= 0) {
$userID = CCrmSecurityHelper::GetCurrentUserID();
}
// Params are not assigned - we will use current activity only.
$liveFeedFields = array('ENTITY_TYPE_ID' => CCrmOwnerType::Activity, 'ENTITY_ID' => $ID, 'USER_ID' => $userID, 'MESSAGE' => '', 'TITLE' => '');
$bindings = isset($arFields['BINDINGS']) && is_array($arFields['BINDINGS']) ? $arFields['BINDINGS'] : array();
if (!empty($bindings)) {
$liveFeedFields['PARENTS'] = $bindings;
$liveFeedFields['PARENT_OPTIONS'] = array('ENTITY_TYPE_ID_KEY' => 'OWNER_TYPE_ID', 'ENTITY_ID_KEY' => 'OWNER_ID');
$ownerInfoOptions = array('ENTITY_TYPE_ID_KEY' => 'OWNER_TYPE_ID', 'ENTITY_ID_KEY' => 'OWNER_ID', 'ADDITIONAL_DATA' => array('LEVEL' => 2));
$additionalParents = array();
foreach ($bindings as &$binding) {
$ownerTypeID = isset($binding['OWNER_TYPE_ID']) ? intval($binding['OWNER_TYPE_ID']) : CCrmOwnerType::Undefined;
$ownerID = isset($binding['OWNER_ID']) ? intval($binding['OWNER_ID']) : 0;
if ($ownerTypeID != CCrmOwnerType::Undefined && $ownerID > 0) {
$arOwners[] = array("OWNER_TYPE_ID" => $ownerTypeID, "OWNER_ID" => $ownerID);
}
if ($ownerTypeID === CCrmOwnerType::Contact && $ownerID > 0) {
$owners = array();
if (CCrmOwnerType::TryGetOwnerInfos(CCrmOwnerType::Contact, $ownerID, $owners, $ownerInfoOptions)) {
$additionalParents = array_merge($additionalParents, $owners);
}
}
}
unset($binding);
if (!empty($additionalParents)) {
$liveFeedFields['PARENTS'] = array_merge($bindings, $additionalParents);
}
$arOwners = array_unique($arOwners);
}
self::PrepareStorageElementIDs($arFields);
$arStorageElementID = $arFields["STORAGE_ELEMENT_IDS"];
if (!empty($arStorageElementID)) {
if ($arFields["STORAGE_TYPE_ID"] == StorageType::WebDav) {
$liveFeedFields["UF_SONET_LOG_DOC"] = $arStorageElementID;
} else {
if ($arFields["STORAGE_TYPE_ID"] == StorageType::Disk) {
$liveFeedFields["UF_SONET_LOG_DOC"] = array();
//We have to add prefix Bitrix\Disk\Uf\FileUserType::NEW_FILE_PREFIX to file ID
foreach ($arStorageElementID as $elementID) {
$liveFeedFields["UF_SONET_LOG_DOC"][] = "n{$elementID}";
}
} else {
$liveFeedFields["UF_SONET_LOG_FILE"] = $arStorageElementID;
}
}
}
if ($arFields['TYPE_ID'] == CCrmActivityType::Task && isset($arFields["ASSOCIATED_ENTITY_ID"]) && intval($arFields["ASSOCIATED_ENTITY_ID"]) > 0 && CModule::IncludeModule("tasks")) {
$dbTask = CTasks::GetByID($arFields["ASSOCIATED_ENTITY_ID"], false);
if ($arTask = $dbTask->Fetch()) {
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("TASKS_TASK", "UF_TASK_WEBDAV_FILES", $arTask["ID"], LANGUAGE_ID);
if ($ufDocID) {
$liveFeedFields["UF_SONET_LOG_DOC"] = $ufDocID;
}
}
}
$bConvert = false;
if ($arTask) {
$rsLog = CSocNetLog::GetList(array(), array("EVENT_ID" => "tasks", "SOURCE_ID" => $arTask["ID"]), array("ID"));
if ($arLog = $rsLog->Fetch()) {
$eventID = CCrmLiveFeed::ConvertTasksLogEvent(array("LOG_ID" => $arLog["ID"], "ACTIVITY_ID" => $ID));
$bConvert = true;
}
}
if (!$bConvert) {
$eventID = CCrmLiveFeed::CreateLogEvent($liveFeedFields, CCrmLiveFeedEvent::Add);
}
if (!(is_int($eventID) && $eventID > 0) && isset($liveFeedFields['ERROR'])) {
$arFields['ERROR'] = $liveFeedFields['ERROR'];
} else {
if ($arTask) {
$arTaskParticipant = CTaskNotifications::GetRecipientsIDs($arTask, false);
$arSocnetRights = CTaskNotifications::__UserIDs2Rights($arTaskParticipant);
if (isset($arTask['GROUP_ID']) && intval($arTask['GROUP_ID']) > 0) {
$perm = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $arTask['GROUP_ID'], "tasks", "view");
$arSocnetRights = array_merge($arSocnetRights, array('SG' . $arTask['GROUP_ID'], 'SG' . $arTask['GROUP_ID'] . '_' . $perm));
}
CSocNetLogRights::DeleteByLogID($eventID);
CSocNetLogRights::Add($eventID, $arSocnetRights);
//.........这里部分代码省略.........
示例2: ProcessLogEventEditPOST
public static function ProcessLogEventEditPOST($arPOST, $entityTypeID, $entityID, &$arResult)
{
$arEntityData = array();
$errors = array();
$enableTitle = isset($arPOST['ENABLE_POST_TITLE']) && strtoupper($arPOST['ENABLE_POST_TITLE']) === 'Y';
$title = $enableTitle && isset($arPOST['POST_TITLE']) ? $arPOST['POST_TITLE'] : '';
$message = isset($arPOST['MESSAGE']) ? htmlspecialcharsback($arPOST['MESSAGE']) : '';
$arResult['EVENT']['MESSAGE'] = $message;
$arResult['EVENT']['TITLE'] = $title;
$arResult['ENABLE_TITLE'] = $enableTitle;
$attachedFiles = array();
$webDavFileFieldName = $arResult['WEB_DAV_FILE_FIELD_NAME'];
if ($webDavFileFieldName !== '' && isset($GLOBALS[$webDavFileFieldName]) && is_array($GLOBALS[$webDavFileFieldName])) {
foreach ($GLOBALS[$webDavFileFieldName] as $fileID) {
if ($fileID === '') {
continue;
}
//fileID: "888|165|16"
$attachedFiles[] = $fileID;
}
if (!empty($attachedFiles) && is_array($arResult['WEB_DAV_FILE_FIELD'])) {
$arResult['WEB_DAV_FILE_FIELD']['VALUE'] = $attachedFiles;
}
}
$allowToAll = COption::GetOptionString('socialnetwork', 'allow_livefeed_toall', 'Y') === 'Y';
if ($allowToAll) {
$arToAllRights = unserialize(COption::GetOptionString("socialnetwork", "livefeed_toall_rights", 'a:1:{i:0;s:2:"AU";}'));
if (!$arToAllRights) {
$arToAllRights = array('AU');
}
$arUserGroupCode = array_merge(array('AU'), CAccess::GetUserCodesArray($arResult['USER_ID']));
if (count(array_intersect($arToAllRights, $arUserGroupCode)) <= 0) {
$allowToAll = false;
}
}
$arSocnetRights = array();
if (!empty($arPOST['SPERM'])) {
foreach ($arPOST['SPERM'] as $v => $k) {
if (strlen($v) > 0 && is_array($k) && !empty($k)) {
foreach ($k as $vv) {
if (strlen($vv) > 0) {
$arSocnetRights[] = $vv;
}
}
}
}
}
if (in_array('UA', $arSocnetRights) && !$allowToAll) {
foreach ($arSocnetRights as $key => $value) {
if ($value == 'UA') {
unset($arSocnetRights[$key]);
break;
}
}
}
foreach ($arSocnetRights as $key => $value) {
if ($value == 'UA') {
$arSocnetRights[] = 'AU';
unset($arSocnetRights[$key]);
break;
}
}
$arSocnetRights = array_unique($arSocnetRights);
$allFeedEtityTypes = CCrmLiveFeedEntity::GetAll();
$userPerms = CCrmPerms::GetCurrentUserPermissions();
foreach ($arSocnetRights as $key => $value) {
$groupCodeData = array();
if (CCrmLiveFeed::TryParseGroupCode($value, $groupCodeData) && in_array($groupCodeData['ENTITY_TYPE'], $allFeedEtityTypes, true)) {
$groupCodeEntityType = $groupCodeData['ENTITY_TYPE'];
$groupCodeEntityID = $groupCodeData['ENTITY_ID'];
if (!CCrmLiveFeed::CheckCreatePermission($groupCodeEntityType, $groupCodeEntityID, $userPerms)) {
$canonicalEntityTypeID = CCrmLiveFeedEntity::ResolveEntityTypeID($groupCodeEntityType);
$errors[] = GetMessage('CRM_SL_EVENT_EDIT_PERMISSION_DENIED', array('#TITLE#' => CCrmOwnerType::GetCaption($canonicalEntityTypeID, $groupCodeEntityID, false)));
} else {
$arEntityData[] = array('ENTITY_TYPE' => $groupCodeEntityType, 'ENTITY_ID' => $groupCodeEntityID);
}
}
}
if (!(CCrmOwnerType::IsDefined($entityTypeID) && $entityID > 0) && !empty($arEntityData)) {
$entityData = $arEntityData[0];
$entityTypeID = CCrmLiveFeedEntity::ResolveEntityTypeID($entityData['ENTITY_TYPE']);
$entityID = $entityData['ENTITY_ID'];
}
if (!empty($arEntityData)) {
$arResult['ENTITY_DATA'] = $arEntityData;
}
if (!(CCrmOwnerType::IsDefined($entityTypeID) && $entityID > 0)) {
$errors[] = GetMessage('CRM_SL_EVENT_EDIT_ENTITY_NOT_DEFINED');
}
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}";
//.........这里部分代码省略.........