本文整理汇总了PHP中CCrmOwnerType::GetResponsibleID方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmOwnerType::GetResponsibleID方法的具体用法?PHP CCrmOwnerType::GetResponsibleID怎么用?PHP CCrmOwnerType::GetResponsibleID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCrmOwnerType
的用法示例。
在下文中一共展示了CCrmOwnerType::GetResponsibleID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetSubSelect
private static function GetSubSelect($arLogFields, $bDecrement = false)
{
global $DB;
$author_id = CCrmSecurityHelper::GetCurrentUserID();
if ($author_id <= 0 && isset($arLogFields["USER_ID"])) {
$author_id = intval($arLogFields["USER_ID"]);
}
if ($author_id <= 0) {
return "";
}
$entityTypeID = CCrmLiveFeedEntity::ResolveEntityTypeID($arLogFields["ENTITY_TYPE"]);
$entityID = $arLogFields["ENTITY_ID"];
$arEntities = array();
if ($entityTypeID == CCrmOwnerType::Activity) {
if ($arActivity = CCrmActivity::GetByID($entityID)) {
$entityTypeID = $arActivity["OWNER_TYPE_ID"];
$entityID = $arActivity["OWNER_ID"];
$entityName = CCrmOwnerType::ResolveName($entityTypeID);
$bOpened = CCrmOwnerType::isOpened($entityTypeID, $entityID, false);
$responsible_id = CCrmOwnerType::GetResponsibleID($entityTypeID, $entityID, false);
if (intval($entityID) > 0 && $entityName && intval($responsible_id) > 0) {
if (!array_key_exists($entityName, $arEntities)) {
$arEntities[$entityName] = array();
}
$arEntities[$entityName][$entityTypeID . "_" . $entityID] = array("ENTITY_TYPE_ID" => $entityTypeID, "ENTITY_ID" => $entityID, "ENTITY_NAME" => $entityName, "IS_OPENED" => $bOpened, "RESPONSIBLE_ID" => $responsible_id);
}
$arCommunications = CCrmActivity::GetCommunications($arActivity["ID"]);
foreach ($arCommunications as $arActivityCommunication) {
$entityTypeID = $arActivityCommunication["ENTITY_TYPE_ID"];
$entityID = $arActivityCommunication["ENTITY_ID"];
$entityName = CCrmOwnerType::ResolveName($entityTypeID);
$bOpened = CCrmOwnerType::isOpened($entityTypeID, $entityID, false);
$responsible_id = CCrmOwnerType::GetResponsibleID($entityTypeID, $entityID, false);
if (intval($entityID) > 0 && $entityName && intval($responsible_id) > 0) {
if (!array_key_exists($entityName, $arEntities)) {
$arEntities[$entityName] = array();
}
$arEntities[$entityName][$entityTypeID . "_" . $entityID] = array("ENTITY_TYPE_ID" => $entityTypeID, "ENTITY_ID" => $entityID, "ENTITY_NAME" => $entityName, "IS_OPENED" => $bOpened, "RESPONSIBLE_ID" => $responsible_id);
}
}
}
} elseif ($entityTypeID == CCrmOwnerType::Invoice) {
if ($arInvoice = CCrmInvoice::GetByID($entityID)) {
$arBindings = array(CCrmOwnerType::Contact => $arInvoice["UF_CONTACT_ID"], CCrmOwnerType::Company => $arInvoice["UF_COMPANY_ID"], CCrmOwnerType::Deal => $arInvoice["UF_DEAL_ID"]);
foreach ($arBindings as $entityTypeID => $entityID) {
if (intval($entityID) > 0) {
$entityName = CCrmOwnerType::ResolveName($entityTypeID);
$bOpened = CCrmOwnerType::isOpened($entityTypeID, $entityID, false);
$responsible_id = CCrmOwnerType::GetResponsibleID($entityTypeID, $entityID, false);
if ($entityName && intval($responsible_id) > 0) {
if (!array_key_exists($entityName, $arEntities)) {
$arEntities[$entityName] = array();
}
$arEntities[$entityName][$entityTypeID . "_" . $entityID] = array("ENTITY_TYPE_ID" => $entityTypeID, "ENTITY_ID" => $entityID, "ENTITY_NAME" => $entityName, "IS_OPENED" => $bOpened, "RESPONSIBLE_ID" => $responsible_id);
}
}
}
}
} else {
$entityName = CCrmOwnerType::ResolveName($entityTypeID);
$bOpened = CCrmOwnerType::isOpened($entityTypeID, $entityID, false);
$responsible_id = CCrmOwnerType::GetResponsibleID($entityTypeID, $entityID, false);
if (intval($entityID) > 0 && $entityName && intval($responsible_id) > 0) {
if (!array_key_exists($entityName, $arEntities)) {
$arEntities[$entityName] = array();
}
$arEntities[$entityName][$entityTypeID . "_" . $entityID] = array("ENTITY_TYPE_ID" => $entityTypeID, "ENTITY_ID" => $entityID, "ENTITY_NAME" => $entityName, "IS_OPENED" => $bOpened, "RESPONSIBLE_ID" => $responsible_id);
}
}
if (intval($arLogFields["LOG_ID"]) > 0 && in_array($arLogFields["EVENT_ID"], array("crm_lead_message", "crm_deal_message", "crm_contact_message", "crm_company_message"))) {
$dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arLogFields["LOG_ID"]));
while ($arRight = $dbRight->Fetch()) {
if (preg_match('/^(' . CCrmLiveFeedEntity::Contact . '|' . CCrmLiveFeedEntity::Lead . '|' . CCrmLiveFeedEntity::Company . '|' . CCrmLiveFeedEntity::Deal . ')(\\d+)$/', $arRight["GROUP_CODE"], $matches)) {
$entityTypeID = CCrmLiveFeedEntity::ResolveEntityTypeID($matches[1]);
$entityID = $matches[2];
$entityName = CCrmOwnerType::ResolveName($entityTypeID);
$responsible_id = CCrmOwnerType::GetResponsibleID($entityTypeID, $entityID, false);
if (!array_key_exists($entityName, $arEntities)) {
$arEntities[$entityName] = array();
}
if (intval($entityID) > 0 && $entityName && intval($responsible_id) > 0 && !array_key_exists($entityTypeID . "_" . $entityID, $arEntities[$entityName])) {
$arEntities[$entityName][$entityTypeID . "_" . $entityID] = array("ENTITY_TYPE_ID" => $entityTypeID, "ENTITY_ID" => $entityID, "ENTITY_NAME" => $entityName, "IS_OPENED" => CCrmOwnerType::isOpened($entityTypeID, $entityID, false), "RESPONSIBLE_ID" => $responsible_id);
}
}
}
}
$arUserID = array();
foreach ($arEntities as $entityName => $arTmp) {
$sSql = "SELECT RL.RELATION, RP.ATTR \n\t\t\t\tFROM b_crm_role_relation RL \n\t\t\t\tINNER JOIN b_crm_role_perms RP ON RL.ROLE_ID = RP.ROLE_ID AND RP.ENTITY = '" . $entityName . "' AND RP.PERM_TYPE = 'READ'\n\t\t\t";
$res = $DB->Query($sSql, false, 'FILE: ' . __FILE__ . '<br /> LINE: ' . __LINE__);
while ($row = $res->Fetch()) {
$user_id = false;
switch ($row["ATTR"]) {
case BX_CRM_PERM_SELF:
foreach ($arTmp as $arEntity) {
$strSQL = "SELECT UA.USER_ID \n\t\t\t\t\t\t\tFROM b_user_access UA \n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tUA.USER_ID = " . intval($arEntity["RESPONSIBLE_ID"]) . "\n\t\t\t\t\t\t\t\tAND UA.ACCESS_CODE = '" . $DB->ForSQL($row["RELATION"]) . "'";
$rsUser = $DB->Query($strSQL, false, 'FILE: ' . __FILE__ . '<br /> LINE: ' . __LINE__);
if (($arUser = $rsUser->Fetch()) && !in_array($arUser["USER_ID"], $arUserID) && $arUser["USER_ID"] != $author_id) {
$arUserID[] = $arUser["USER_ID"];
}
//.........这里部分代码省略.........
示例2: GetMessage
$errorMsg = GetMessage('CRM_CONTACT_UPDATE_PERMISSION_DENIED', array('#TITLE#' => $entityTitle));
} elseif ($ownerTypeID === CCrmOwnerType::Company) {
$errorMsg = GetMessage('CRM_COMPANY_UPDATE_PERMISSION_DENIED', array('#TITLE#' => $entityTitle));
} elseif ($ownerTypeID === CCrmOwnerType::Lead) {
$errorMsg = GetMessage('CRM_LEAD_UPDATE_PERMISSION_DENIED', array('#TITLE#' => $entityTitle));
} elseif ($ownerTypeID === CCrmOwnerType::Deal) {
$errorMsg = GetMessage('CRM_DEAL_UPDATE_PERMISSION_DENIED', array('#TITLE#' => $entityTitle));
} else {
$errorMsg = GetMessage('CRM_PERMISSION_DENIED');
}
echo CUtil::PhpToJSObject(array('ERROR' => $errorMsg));
die;
}
$userID = $curUser->GetID();
if ($userID <= 0) {
$userID = CCrmOwnerType::GetResponsibleID($ownerTypeID, $ownerID, false);
if ($userID <= 0) {
echo CUtil::PhpToJSObject(array('ERROR' => GetMessage('CRM_ACTIVITY_RESPONSIBLE_NOT_FOUND')));
die;
}
}
$arErrors = array();
$crmEmail = CCrmMailHelper::ExtractEmail(COption::GetOptionString('crm', 'mail', ''));
$from = isset($data['from']) ? trim(strval($data['from'])) : '';
if ($from === '') {
if ($crmEmail !== '') {
$from = $crmEmail;
} else {
$arErrors[] = GetMessage('CRM_ACTIVITY_EMAIL_EMPTY_FROM_FIELD');
}
} else {
示例3: GetDocumentAuthorID
public static function GetDocumentAuthorID($documentId)
{
if (!is_array($documentId) || count($documentId) < 3) {
return 0;
}
$documentInfo = self::GetDocumentInfo($documentId[2]);
$entityTypeName = isset($documentInfo['TYPE']) ? $documentInfo['TYPE'] : '';
$entityId = isset($documentInfo['ID']) ? intval($documentInfo['ID']) : 0;
return CCrmOwnerType::GetResponsibleID(CCrmOwnerType::ResolveID($entityTypeName), $entityId, false);
}
示例4: innerAdd
protected function innerAdd(&$fields, &$errors, array $params = null)
{
$ownerTypeID = isset($fields['OWNER_TYPE_ID']) ? intval($fields['OWNER_TYPE_ID']) : 0;
$ownerID = isset($fields['OWNER_ID']) ? intval($fields['OWNER_ID']) : 0;
$bindings = array();
if ($ownerTypeID > 0 && $ownerID > 0) {
$bindings["{$ownerTypeID}_{$ownerID}"] = array('OWNER_TYPE_ID' => $ownerTypeID, 'OWNER_ID' => $ownerID);
}
$responsibleID = isset($fields['RESPONSIBLE_ID']) ? intval($fields['RESPONSIBLE_ID']) : 0;
if ($responsibleID <= 0 && $ownerTypeID > 0 && $ownerID > 0) {
$fields['RESPONSIBLE_ID'] = $responsibleID = CCrmOwnerType::GetResponsibleID($ownerTypeID, $ownerID);
}
if ($responsibleID <= 0) {
$responsibleID = CCrmSecurityHelper::GetCurrentUserID();
}
if ($responsibleID <= 0) {
$errors[] = 'The field RESPONSIBLE_ID is not defined or invalid.';
return false;
}
$typeID = isset($fields['TYPE_ID']) ? intval($fields['TYPE_ID']) : CCrmActivityType::Undefined;
if (!CCrmActivityType::IsDefined($typeID)) {
$errors[] = 'The field TYPE_ID is not defined or invalid.';
return false;
}
if (!in_array($typeID, array(CCrmActivityType::Call, CCrmActivityType::Meeting, CCrmActivityType::Email), true)) {
$errors[] = 'The activity type "' . CCrmActivityType::ResolveDescription($typeID) . ' is not supported in current context".';
return false;
}
$description = isset($fields['DESCRIPTION']) ? $fields['DESCRIPTION'] : '';
$descriptionType = isset($fields['DESCRIPTION_TYPE']) ? intval($fields['DESCRIPTION_TYPE']) : CCrmContentType::PlainText;
if ($description !== '' && CCrmActivity::AddEmailSignature($description, $descriptionType)) {
$fields['DESCRIPTION'] = $description;
}
$direction = isset($fields['DIRECTION']) ? intval($fields['DIRECTION']) : CCrmActivityDirection::Undefined;
$completed = isset($fields['COMPLETED']) && strtoupper($fields['COMPLETED']) === 'Y';
$communications = isset($fields['COMMUNICATIONS']) && is_array($fields['COMMUNICATIONS']) ? $fields['COMMUNICATIONS'] : array();
$this->prepareCommunications($ownerTypeID, $ownerID, $typeID, $communications, $bindings);
if (empty($communications)) {
$errors[] = 'The field COMMUNICATIONS is not defined or invalid.';
return false;
}
if (($typeID === CCrmActivityType::Call || $typeID === CCrmActivityType::Meeting) && count($communications) > 1) {
$errors[] = 'The only one communication is allowed for activity of specified type.';
return false;
}
if (empty($bindings)) {
$errors[] = 'Could not build binding. Please ensure that owner info and communications are defined correctly.';
return false;
}
foreach ($bindings as &$binding) {
if (!CCrmActivity::CheckUpdatePermission($binding['OWNER_TYPE_ID'], $binding['OWNER_ID'])) {
$errors[] = 'Access denied.';
return false;
}
}
unset($binding);
$fields['BINDINGS'] = array_values($bindings);
$fields['COMMUNICATIONS'] = $communications;
$storageTypeID = $fields['STORAGE_TYPE_ID'] = CCrmActivity::GetDefaultStorageTypeID();
$fields['STORAGE_ELEMENT_IDS'] = array();
if ($storageTypeID === StorageType::WebDav) {
$webdavElements = isset($fields['WEBDAV_ELEMENTS']) && is_array($fields['WEBDAV_ELEMENTS']) ? $fields['WEBDAV_ELEMENTS'] : array();
foreach ($webdavElements as &$element) {
$elementID = isset($element['ELEMENT_ID']) ? intval($element['ELEMENT_ID']) : 0;
if ($elementID > 0) {
$fields['STORAGE_ELEMENT_IDS'][] = $elementID;
}
}
unset($element);
} elseif ($storageTypeID === StorageType::Disk) {
$diskFiles = isset($fields['FILES']) && is_array($fields['FILES']) ? $fields['FILES'] : array();
if (empty($diskFiles)) {
//For backward compatibility only
$diskFiles = isset($fields['WEBDAV_ELEMENTS']) && is_array($fields['WEBDAV_ELEMENTS']) ? $fields['WEBDAV_ELEMENTS'] : array();
}
foreach ($diskFiles as &$fileInfo) {
$fileID = isset($fileInfo['FILE_ID']) ? (int) $fileInfo['FILE_ID'] : 0;
if ($fileID > 0) {
$fields['STORAGE_ELEMENT_IDS'][] = $fileID;
}
}
unset($fileInfo);
}
if (!($ID = CCrmActivity::Add($fields))) {
$errors[] = CCrmActivity::GetLastErrorMessage();
return false;
}
CCrmActivity::SaveCommunications($ID, $communications, $fields, false, false);
if ($completed && $typeID === CCrmActivityType::Email && $direction === CCrmActivityDirection::Outgoing) {
$sendErrors = array();
if (!CCrmActivityEmailSender::TrySendEmail($ID, $fields, $sendErrors)) {
foreach ($sendErrors as &$error) {
$code = $error['CODE'];
if ($code === CCrmActivityEmailSender::ERR_CANT_LOAD_SUBSCRIBE) {
$errors[] = 'Email send error. Failed to load module "subscribe".';
} elseif ($code === CCrmActivityEmailSender::ERR_INVALID_DATA) {
$errors[] = 'Email send error. Invalid data.';
} elseif ($code === CCrmActivityEmailSender::ERR_INVALID_EMAIL) {
$errors[] = 'Email send error. Invalid email is specified.';
} elseif ($code === CCrmActivityEmailSender::ERR_CANT_FIND_EMAIL_FROM) {
//.........这里部分代码省略.........