コード例 #1
0
ファイル: ajax.php プロジェクト: mrdeadmouse/u136006
} elseif ($action == 'GET_ENTITY_COMMUNICATIONS') {
    $entityType = isset($_POST['ENTITY_TYPE']) ? strtoupper(strval($_POST['ENTITY_TYPE'])) : '';
    $entityID = isset($_POST['ENTITY_ID']) ? intval($_POST['ENTITY_ID']) : 0;
    $communicationType = isset($_POST['COMMUNICATION_TYPE']) ? strval($_POST['COMMUNICATION_TYPE']) : '';
    if ($entityType === '' || $entityID <= 0) {
        echo CUtil::PhpToJSObject(array('ERROR' => 'Invalid data'));
        die;
    }
    $result = GetCrmEntityCommunications($entityType, $entityID, $communicationType);
    echo CUtil::PhpToJSObject($result);
} elseif ($action == 'SEARCH_COMMUNICATIONS') {
    $entityType = isset($_POST['ENTITY_TYPE']) ? strtoupper(strval($_POST['ENTITY_TYPE'])) : '';
    $entityID = isset($_POST['ENTITY_ID']) ? intval($_POST['ENTITY_ID']) : 0;
    $communicationType = isset($_POST['COMMUNICATION_TYPE']) ? strval($_POST['COMMUNICATION_TYPE']) : '';
    $needle = isset($_POST['NEEDLE']) ? strval($_POST['NEEDLE']) : '';
    $results = CCrmActivity::FindContactCommunications($needle, $communicationType, 10);
    if ($communicationType !== '') {
        //If communication type defined add companies communications
        $results = array_merge($results, CCrmActivity::FindCompanyCommunications($needle, $communicationType, 10));
    }
    $results = array_merge($results, CCrmActivity::FindLeadCommunications($needle, $communicationType, 10));
    $data = array();
    foreach ($results as &$result) {
        $key = "{$result['ENTITY_TYPE_ID']}_{$result['ENTITY_ID']}";
        if (!isset($data[$key])) {
            $data[$key] = array('ownerEntityType' => $entityType !== '' ? $entityType : CCrmOwnerType::ResolveName($result['ENTITY_TYPE_ID']), 'ownerEntityId' => $entityID > 0 ? $entityID : intval($result['ENTITY_ID']), 'entityType' => CCrmOwnerType::ResolveName($result['ENTITY_TYPE_ID']), 'entityId' => $result['ENTITY_ID'], 'entityTitle' => $result['TITLE'], 'entityDescription' => $result['DESCRIPTION'], 'tabId' => 'search', 'communications' => array());
        }
        if ($result['TYPE'] !== '' && $result['VALUE'] !== '') {
            $comm = array('type' => $result['TYPE'], 'value' => $result['VALUE']);
            $data[$key]['communications'][] = $comm;
        }
コード例 #2
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
                    $item['COMMUNICATIONS'][] = array('TYPE' => $commType, 'VALUE' => $multiField['VALUE']);
                }
                if (!empty($item['COMMUNICATIONS'])) {
                    $items["CONTACT_{$ownerID}"] =& $item;
                }
                unset($item);
            }
        }
    }
} elseif ($ownerTypeID === CCrmOwnerType::Invoice) {
    if (!CCrmActivity::CheckReadPermission(CCrmOwnerType::Invoice, $ownerID)) {
        ShowError(GetMessage('CRM_PERMISSION_DENIED'));
        return;
    }
    if ($enableSearch && $needle !== '') {
        $results = CCrmActivity::FindContactCommunications($needle, $commType !== 'PERSON' ? $commType : '', 10);
        if ($commType !== '') {
            //If communication type defined add companies communications
            $results = array_merge($results, CCrmActivity::FindCompanyCommunications($needle, $commType !== 'PERSON' ? $commType : '', 10));
        }
        $results = array_merge($results, CCrmActivity::FindLeadCommunications($needle, $commType !== 'PERSON' ? $commType : '', 10));
        foreach ($results as &$result) {
            $entityID = intval($result['ENTITY_ID']);
            $entityTypeID = intval($result['ENTITY_TYPE_ID']);
            $entityTypeName = CCrmOwnerType::ResolveName($entityTypeID);
            if (!CCrmAuthorizationHelper::CheckReadPermission($entityTypeName, $entityID, $userPerms)) {
                continue;
            }
            $item = array('OWNER_ID' => $entityID, 'OWNER_TYPE_ID' => $entityTypeID, 'OWNER_TYPE_NAME' => $entityTypeName, 'TITLE' => $result['TITLE'], 'DESCRIPTION' => $result['DESCRIPTION'], 'IMAGE_URL' => '', 'COMMUNICATIONS' => array());
            if ($result['TYPE'] !== '' && $result['VALUE'] !== '') {
                $item['COMMUNICATIONS'][] = array('TYPE' => $result['TYPE'], 'VALUE' => $result['VALUE']);