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


PHP CCrmContact::Add方法代码示例

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


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

示例1: foreach

     if (is_array($arProductRows)) {
         foreach ($arProductRows as &$arProductRow) {
             $originID = $arProductRow['ORIGIN_ID'];
             $arProduct = CCrmProduct::GetByOriginID($originID, $catalogID);
             if (!is_array($arProduct)) {
                 continue;
             }
             CCrmLead::SaveProductRows($leadID, array(array('PRODUCT_ID' => intval($arProduct['ID']), 'PRICE' => doubleval($arProduct['PRICE']), 'QUANTITY' => 1)));
         }
     }
 }
 // Add Contact
 require_once "contact.demo.php";
 $CCrmContact = new CCrmContact();
 foreach ($arContacts as $ID => $arParams) {
     $arContacts[$ID]['ID'] = $CCrmContact->Add($arParams);
 }
 // Add Company
 require_once "company.demo.php";
 $CCrmCompany = new CCrmCompany();
 foreach ($arCompany as $ID => $arParams) {
     $arCompany[$ID]['ID'] = $CCrmCompany->Add($arParams);
 }
 // Add Deal
 require_once "deal.demo.php";
 $CCrmDeal = new CCrmDeal();
 foreach ($arDeals as $ID => &$arParams) {
     $arProductRows = null;
     if (isset($arParams['PRODUCT_ROWS'])) {
         $arProductRows = $arParams['PRODUCT_ROWS'];
         unset($arParams['PRODUCT_ROWS']);
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:index.php

示例2: Add

 public function Add($data)
 {
     if (($r = self::CheckAuth()) !== false) {
         return $r;
     }
     $arFieldsInfo = CCrmContact::GetFields();
     $arFields = array();
     $arEl = $data->elementsByName('Field');
     foreach ($arEl as $el) {
         $children = $el->children();
         $sFieldName = $el->getAttribute('id');
         // Fix for issue #40193
         if (!isset($arFieldsInfo[$sFieldName])) {
             continue;
         }
         if (!is_null($children)) {
             $arFields[$sFieldName] = array();
             foreach ($children as $child) {
                 $arFields[$sFieldName][] = $child->content;
             }
         } else {
             $arFields[$sFieldName] = $el->content;
         }
     }
     CCrmFieldMulti::PrepareFields($arFields);
     if (isset($arFields['PHOTO'])) {
         $arFile = null;
         if (CCrmUrlUtil::HasScheme($arFields['PHOTO']) && CCrmUrlUtil::IsSecureUrl($arFields['PHOTO'])) {
             $arFile = CFile::MakeFileArray($arFields['PHOTO']);
             if (is_array($arFile)) {
                 $arFile += array('MODULE_ID' => 'crm');
             }
         }
         if (is_array($arFile)) {
             $arFields['PHOTO'] = $arFile;
         } else {
             unset($arFields['PHOTO']);
         }
     }
     $arUserFields = $GLOBALS['USER_FIELD_MANAGER']->GetUserFields(CCrmContact::$sUFEntityID);
     foreach ($arUserFields as $FIELD_NAME => $arUserField) {
         if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'file') {
             if (!isset($arFields[$FIELD_NAME])) {
                 continue;
             }
             if (is_array($arFields[$FIELD_NAME])) {
                 $arFiles = array();
                 foreach ($arFields[$FIELD_NAME] as $sFilePath) {
                     if (!(CCrmUrlUtil::HasScheme($sFilePath) && CCrmUrlUtil::IsSecureUrl($sFilePath))) {
                         continue;
                     }
                     $arFile = CFile::MakeFileArray($sFilePath);
                     if (is_array($arFile)) {
                         $arFile += array('MODULE_ID' => 'crm');
                         $arFiles[] = $arFile;
                     }
                 }
                 $arFields[$FIELD_NAME] = $arFiles;
             } else {
                 $arFile = null;
                 $sFilePath = $arFields[$FIELD_NAME];
                 if (CCrmUrlUtil::HasScheme($sFilePath) && CCrmUrlUtil::IsSecureUrl($sFilePath)) {
                     $arFile = CFile::MakeFileArray($sFilePath);
                     if (is_array($arFile)) {
                         $arFile += array('MODULE_ID' => 'crm');
                     }
                 }
                 if (is_array($arFile)) {
                     $arFields[$FIELD_NAME] = $arFile;
                 } else {
                     unset($arFields[$FIELD_NAME]);
                 }
             }
         }
     }
     $CCrmContact = new CCrmContact();
     return $CCrmContact->Add($arFields) ? 'ok' : new CSoapFault('CCrmLead::Add', htmlspecialcharsbx(strip_tags(nl2br($arFields['RESULT_MESSAGE']))));
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:78,代码来源:ws_contact.php

示例3: SaveOrderDataContact

 private function SaveOrderDataContact($arOrder)
 {
     if (!isset($arOrder["CONTRACTOR"]) || !is_array($arOrder["CONTRACTOR"])) {
         return false;
     }
     $contactId = 0;
     $contactXmlId = $arOrder["CONTRACTOR"]["ID"];
     if (isset($arOrder["CONTRACTOR"]["FIRST_NAME"]) && $arOrder["CONTRACTOR"]["FIRST_NAME"] != "") {
         $contactXmlId .= "|" . $arOrder["CONTRACTOR"]["FIRST_NAME"];
     }
     if (isset($arOrder["CONTRACTOR"]["LAST_NAME"]) && $arOrder["CONTRACTOR"]["LAST_NAME"] != "") {
         $contactXmlId .= "|" . $arOrder["CONTRACTOR"]["LAST_NAME"];
     }
     $dbContact = CCrmContact::GetList(array(), array("ORIGINATOR_ID" => $this->externalSaleId, "ORIGIN_ID" => $contactXmlId, "CHECK_PERMISSIONS" => "N"));
     if ($arContact = $dbContact->Fetch()) {
         $contactId = $arContact["ID"];
     }
     $arFields = array('ORIGINATOR_ID' => $this->externalSaleId, 'ORIGIN_ID' => $contactXmlId, 'TYPE_ID' => 'CLIENT', 'OPENED' => 'Y');
     $sources = CCrmStatus::GetStatusList('SOURCE');
     if (isset($sources['WEB'])) {
         $arFields['SOURCE_ID'] = 'WEB';
     }
     if (isset($arOrder["CONTRACTOR"]["FIRST_NAME"]) && $arOrder["CONTRACTOR"]["FIRST_NAME"] != "") {
         $arFields['NAME'] = $arOrder["CONTRACTOR"]["FIRST_NAME"];
     }
     if (isset($arOrder["CONTRACTOR"]["LAST_NAME"]) && $arOrder["CONTRACTOR"]["LAST_NAME"] != "") {
         $arFields['LAST_NAME'] = $arOrder["CONTRACTOR"]["LAST_NAME"];
     }
     if (isset($arOrder["CONTRACTOR"]["SECOND_NAME"]) && $arOrder["CONTRACTOR"]["SECOND_NAME"] != "") {
         $arFields['SECOND_NAME'] = $arOrder["CONTRACTOR"]["SECOND_NAME"];
     }
     if (isset($arOrder["CONTRACTOR"]["BIRTHDAY"]) && $arOrder["CONTRACTOR"]["BIRTHDAY"] != "") {
         $arFields['BIRTHDATE'] = $arOrder["CONTRACTOR"]["BIRTHDAY"];
     }
     if (isset($arOrder["CONTRACTOR"]["FULL_NAME"]) && $arOrder["CONTRACTOR"]["FULL_NAME"] != "") {
         $arFields['FULL_NAME'] = $arOrder["CONTRACTOR"]["FULL_NAME"];
     } elseif (isset($arOrder["CONTRACTOR"]["NAME"]) && $arOrder["CONTRACTOR"]["NAME"] != "") {
         $arFields['FULL_NAME'] = $arOrder["CONTRACTOR"]["NAME"];
     }
     if (is_array($arOrder["CONTRACTOR"]["ADDRESS"])) {
         foreach ($arOrder["CONTRACTOR"]["ADDRESS"] as $key => $val) {
             if ($key == "VIEW") {
                 continue;
             }
             if (!empty($arFields["ADDRESS"])) {
                 $arFields["ADDRESS"] .= ", ";
             }
             $arFields["ADDRESS"] .= $val;
         }
         if (isset($arOrder["CONTRACTOR"]["ADDRESS"]["VIEW"])) {
             if (!empty($arFields["ADDRESS"])) {
                 $arFields["ADDRESS"] .= "\n";
             }
             $arFields["ADDRESS"] .= $arOrder["CONTRACTOR"]["ADDRESS"]["VIEW"];
         }
     }
     if (is_array($arOrder["CONTRACTOR"]["CONTACTS"])) {
         $arFields["FM"] = array();
         if ($contactId > 0) {
             $dbCrmFieldMulti = CCrmFieldMulti::GetList(array(), array('ENTITY_ID' => 'CONTACT', 'ELEMENT_ID' => $contactId, "CHECK_PERMISSIONS" => "N"));
             while ($arCrmFieldMulti = $dbCrmFieldMulti->Fetch()) {
                 $arFields["FM"][$arCrmFieldMulti["TYPE_ID"]][$arCrmFieldMulti["ID"]] = array("VALUE_TYPE" => $arCrmFieldMulti["VALUE_TYPE"], "VALUE" => $arCrmFieldMulti["VALUE"]);
             }
         }
         $arMapTmp = array("MAIL" => "EMAIL", "E-MAIL" => "EMAIL", "WORKPHONE" => "PHONE");
         $arInc = array();
         foreach ($arOrder["CONTRACTOR"]["CONTACTS"] as $val) {
             $t = strtoupper(preg_replace("/\\s/", "", $val["TYPE"]));
             if (!isset($arMapTmp[$t])) {
                 continue;
             }
             $bFound = false;
             $tNew = $arMapTmp[$t];
             if (isset($arFields["FM"][$tNew]) && is_array($arFields["FM"][$tNew])) {
                 if (count($arFields["FM"][$tNew]) >= 50) {
                     //Disable adding new communication after threshold is exceeded
                     $bFound = true;
                 } else {
                     foreach ($arFields["FM"][$tNew] as $k => $v) {
                         if ($v["VALUE"] == $val["VALUE"]) {
                             $bFound = true;
                             break;
                         }
                     }
                 }
             }
             if (!$bFound) {
                 $arInc[$tNew]++;
                 $arFields["FM"][$tNew]["n" . $arInc[$tNew]] = array("VALUE_TYPE" => "WORK", "VALUE" => $val["VALUE"]);
             }
         }
     }
     $newContact = $contactId == 0;
     $obj = new CCrmContact(false);
     if ($contactId == 0) {
         if ((!isset($arFields['NAME']) || strlen($arFields['NAME']) <= 0) && (!isset($arFields['LAST_NAME']) || strlen($arFields['LAST_NAME']) <= 0)) {
             $arFields['LAST_NAME'] = $contactXmlId;
         }
         $res = $obj->Add($arFields, true, array('DISABLE_USER_FIELD_CHECK' => true));
         if ($res > 0) {
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:crm_external_sale_import.php

示例4: CCrmContact

     }
 }
 if ($photoID > 0) {
     $fields['PHOTO'] = $photoID;
 }
 if (isset($data['FM']) && is_array($data['FM']) && !empty($data['FM'])) {
     $fields['FM'] = $data['FM'];
 }
 $entity = new CCrmContact(false);
 if (!$entity->CheckFields($fields, !$isNew ? $ID : false, array('DISABLE_USER_FIELD_CHECK' => true))) {
     __CrmMobileContactEditEndResonse(array('ERROR' => strip_tags(preg_replace("/<br[^>]*>/", "\n", $entity->LAST_ERROR))));
 } else {
     //$DB->StartTransaction();
     $successed = false;
     if ($isNew) {
         $ID = $entity->Add($fields, true, array('DISABLE_USER_FIELD_CHECK' => true, 'REGISTER_SONET_EVENT' => true));
         $successed = $ID !== false;
     } else {
         $successed = $entity->Update($ID, $fields, true, true, array('DISABLE_USER_FIELD_CHECK' => true, 'REGISTER_SONET_EVENT' => true));
     }
     if ($successed) {
         //$DB->Commit();
         $errors = array();
         CCrmBizProcHelper::AutoStartWorkflows(CCrmOwnerType::Contact, $ID, $isNew ? CCrmBizProcEventType::Create : CCrmBizProcEventType::Edit, $errors);
         $dbRes = CCrmContact::GetListEx(array(), array('=ID' => $ID, 'CHECK_PERMISSIONS' => 'N'));
         $currentItem = $dbRes->GetNext();
         $formatParams = isset($_REQUEST['FORMAT_PARAMS']) ? $_REQUEST['FORMAT_PARAMS'] : array();
         CCrmMobileHelper::PrepareContactItem($currentItem, $formatParams);
         __CrmMobileContactEditEndResonse(array('SAVED_ENTITY_ID' => $ID, 'SAVED_ENTITY_DATA' => CCrmMobileHelper::PrepareContactData($currentItem)));
     } else {
         //$DB->Rollback();
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:ajax.php

示例5: GetMessage

     if (!empty($CCrmContact->LAST_ERROR)) {
         $arResult['ERROR_MESSAGE'] .= $CCrmContact->LAST_ERROR;
     } else {
         $arResult['ERROR_MESSAGE'] .= GetMessage('UNKNOWN_ERROR');
     }
 }
 if ($arBizProcParametersValues = $CCrmBizProc->CheckFields($isEditMode ? $arResult['ELEMENT']['ID'] : false, false, $arResult['ELEMENT']['ASSIGNED_BY'], $isEditMode ? array($arResult['ELEMENT']['ID'] => $arEntityAttr[$arResult['ELEMENT']['ID']]) : null) === false) {
     $arResult['ERROR_MESSAGE'] .= $CCrmBizProc->LAST_ERROR;
 }
 if (empty($arResult['ERROR_MESSAGE'])) {
     $DB->StartTransaction();
     $success = false;
     if ($isEditMode) {
         $success = $CCrmContact->Update($arResult['ELEMENT']['ID'], $arFields, true, true, array('REGISTER_SONET_EVENT' => true));
     } else {
         $ID = $CCrmContact->Add($arFields, true, array('REGISTER_SONET_EVENT' => true));
         $success = $ID !== false;
         if ($success) {
             $arResult['ELEMENT']['ID'] = $ID;
         }
     }
     if ($success) {
         $DB->Commit();
     } else {
         $DB->Rollback();
         $arResult['ERROR_MESSAGE'] = !empty($arFields['RESULT_MESSAGE']) ? $arFields['RESULT_MESSAGE'] : GetMessage('UNKNOWN_ERROR');
     }
 }
 if (empty($arResult['ERROR_MESSAGE']) && !$CCrmBizProc->StartWorkflow($arResult['ELEMENT']['ID'], $arBizProcParametersValues)) {
     $arResult['ERROR_MESSAGE'] = $CCrmBizProc->LAST_ERROR;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php

示例6: executePhase

 public function executePhase()
 {
     if ($this->currentPhase === LeadConversionPhase::COMPANY_CREATION || $this->currentPhase === LeadConversionPhase::CONTACT_CREATION || $this->currentPhase === LeadConversionPhase::DEAL_CREATION) {
         if ($this->currentPhase === LeadConversionPhase::COMPANY_CREATION) {
             $entityTypeID = \CCrmOwnerType::Company;
         } elseif ($this->currentPhase === LeadConversionPhase::CONTACT_CREATION) {
             $entityTypeID = \CCrmOwnerType::Contact;
         } else {
             $entityTypeID = \CCrmOwnerType::Deal;
         }
         $entityTypeName = \CCrmOwnerType::ResolveName($entityTypeID);
         $config = $this->config->getItem($entityTypeID);
         if (!$config->isActive()) {
             return false;
         }
         /** @var \CCrmPerms $permissions */
         $permissions = $this->getUserPermissions();
         $entityID = isset($this->contextData[$entityTypeName]) ? $this->contextData[$entityTypeName] : 0;
         if ($entityID > 0) {
             if ($entityTypeID === \CCrmOwnerType::Company) {
                 if (!\CCrmCompany::Exists($entityID)) {
                     throw new EntityConversionException(\CCrmOwnerType::Lead, \CCrmOwnerType::Company, EntityConversionException::TARG_DST, EntityConversionException::NOT_FOUND);
                 }
                 $entity = new \CCrmCompany(false);
             } elseif ($entityTypeID === \CCrmOwnerType::Contact) {
                 if (!\CCrmContact::Exists($entityID)) {
                     throw new EntityConversionException(\CCrmOwnerType::Lead, \CCrmOwnerType::Contact, EntityConversionException::TARG_DST, EntityConversionException::NOT_FOUND);
                 }
                 $entity = new \CCrmContact(false);
             } else {
                 if (!\CCrmDeal::Exists($entityID)) {
                     throw new EntityConversionException(\CCrmOwnerType::Lead, \CCrmOwnerType::Deal, EntityConversionException::TARG_DST, EntityConversionException::NOT_FOUND);
                 }
                 $entity = new \CCrmDeal(false);
             }
             if (!\CCrmAuthorizationHelper::CheckUpdatePermission($entityTypeName, $entityID, $permissions)) {
                 throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::UPDATE_DENIED);
             }
             $fields = array('LEAD_ID' => $this->entityID);
             $entity->Update($entityID, $fields);
             $this->resultData[$entityTypeName] = $entityID;
             return true;
         }
         if (!\CCrmAuthorizationHelper::CheckCreatePermission($entityTypeName, $permissions)) {
             throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::CREATE_DENIED);
         }
         if (UserFieldSynchronizer::needForSynchronization(\CCrmOwnerType::Lead, $entityTypeID)) {
             throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::NOT_SYNCHRONIZED);
         }
         if (!ConversionSettings::getCurrent()->isAutocreationEnabled()) {
             throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::AUTOCREATION_DISABLED);
         }
         if (\CCrmBizProcHelper::HasAutoWorkflows($entityTypeID, \CCrmBizProcEventType::Create)) {
             throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::HAS_WORKFLOWS);
         }
         /** @var LeadConversionMapper $mapper */
         $mapper = $this->getMapper();
         $map = self::prepareMap($entityTypeID);
         $fields = $mapper->map($map);
         if (empty($fields)) {
             throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::EMPTY_FIELDS);
         }
         if ($entityTypeID === \CCrmOwnerType::Company) {
             $entity = new \CCrmCompany(false);
             $entityID = $entity->Add($fields);
             if ($entityID <= 0) {
                 throw new EntityConversionException(\CCrmOwnerType::Lead, \CCrmOwnerType::Company, EntityConversionException::TARG_DST, EntityConversionException::CREATE_FAILED, $entity->LAST_ERROR);
             }
             //region BizProcess
             $arErrors = array();
             \CCrmBizProcHelper::AutoStartWorkflows(\CCrmOwnerType::Company, $entityID, \CCrmBizProcEventType::Create, $arErrors);
             //endregion
             $this->resultData[\CCrmOwnerType::CompanyName] = $entityID;
         } elseif ($entityTypeID === \CCrmOwnerType::Contact) {
             if (isset($this->resultData[\CCrmOwnerType::CompanyName])) {
                 $fields['COMPANY_ID'] = $this->resultData[\CCrmOwnerType::CompanyName];
             }
             $entity = new \CCrmContact(false);
             if (!$entity->CheckFields($fields)) {
                 throw new EntityConversionException(\CCrmOwnerType::Lead, $entityTypeID, EntityConversionException::TARG_DST, EntityConversionException::INVALID_FIELDS, $entity->LAST_ERROR);
             }
             $entityID = $entity->Add($fields);
             if ($entityID <= 0) {
                 throw new EntityConversionException(\CCrmOwnerType::Lead, \CCrmOwnerType::Contact, EntityConversionException::TARG_DST, EntityConversionException::CREATE_FAILED, $entity->LAST_ERROR);
             }
             //region BizProcess
             $arErrors = array();
             \CCrmBizProcHelper::AutoStartWorkflows(\CCrmOwnerType::Contact, $entityID, \CCrmBizProcEventType::Create, $arErrors);
             //endregion
             $this->resultData[\CCrmOwnerType::ContactName] = $entityID;
         } else {
             if (isset($this->resultData[\CCrmOwnerType::ContactName])) {
                 $fields['CONTACT_ID'] = $this->resultData[\CCrmOwnerType::ContactName];
             }
             if (isset($this->resultData[\CCrmOwnerType::CompanyName])) {
                 $fields['COMPANY_ID'] = $this->resultData[\CCrmOwnerType::CompanyName];
             }
             $productRows = isset($fields['PRODUCT_ROWS']) && is_array($fields['PRODUCT_ROWS']) ? $fields['PRODUCT_ROWS'] : array();
             if (!empty($productRows)) {
                 $result = \CCrmProductRow::CalculateTotalInfo('D', 0, false, $fields, $productRows);
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:leadconverter.php

示例7: TryImportVCard

 private static function TryImportVCard(&$fileData)
 {
     $CCrmVCard = new CCrmVCard();
     $arContact = $CCrmVCard->ReadCard(false, $fileData);
     if (empty($arContact['NAME']) && empty($arContact['LAST_NAME'])) {
         return false;
     }
     $arFilter = array();
     if (!empty($arContact['NAME'])) {
         $arFilter['NAME'] = $arContact['NAME'];
     }
     if (!empty($arContact['LAST_NAME'])) {
         $arFilter['LAST_NAME'] = $arContact['LAST_NAME'];
     }
     if (!empty($arContact['SECOND_NAME'])) {
         $arFilter['SECOND_NAME'] = $arContact['SECOND_NAME'];
     }
     $arFilter['CHECK_PERMISSIONS'] = 'N';
     $dbContact = CCrmContact::GetListEx(array(), $arFilter, false, false, array('ID'));
     if ($dbContact->Fetch()) {
         return false;
     }
     $arContact['SOURCE_ID'] = 'EMAIL';
     $arContact['TYPE_ID'] = 'SHARE';
     if (!empty($arContact['COMPANY_TITLE'])) {
         $dbCompany = CCrmCompany::GetListEx(array(), array('TITLE' => $arContact['COMPANY_TITLE'], 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID'));
         if (($arCompany = $dbCompany->Fetch()) !== false) {
             $arContact['COMPANY_ID'] = $arCompany['ID'];
         } else {
             if (!empty($arContact['COMMENTS'])) {
                 $arContact['COMMENTS'] .= PHP_EOL;
             }
             $arContact['COMMENTS'] .= GetMessage('CRM_MAIL_COMPANY_NAME', array('%TITLE%' => $arContact['COMPANY_TITLE']));
         }
     }
     $CCrmContact = new CCrmContact(false);
     $CCrmContact->Add($arContact, true, array('DISABLE_USER_FIELD_CHECK' => true));
     return true;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:39,代码来源:crm_email.php

示例8: CreateDocument

 public static function CreateDocument($parentDocumentId, $arFields)
 {
     global $DB;
     $arDocumentID = self::GetDocumentInfo($parentDocumentId);
     if ($arDocumentID == false) {
         $arDocumentID['TYPE'] = $parentDocumentId;
     }
     $arDocumentFields = self::GetDocumentFields($arDocumentID['TYPE']);
     $arKeys = array_keys($arFields);
     foreach ($arKeys as $key) {
         if (!array_key_exists($key, $arDocumentFields)) {
             //Fix for issue #40374
             unset($arFields[$key]);
             continue;
         }
         $fieldType = $arDocumentFields[$key]["Type"];
         if (in_array($fieldType, array("phone", "email", "im", "web"), true)) {
             CCrmDocument::PrepareEntityMultiFields($arFields, strtoupper($fieldType));
             continue;
         }
         $arFields[$key] = is_array($arFields[$key]) && !CBPHelper::IsAssociativeArray($arFields[$key]) ? $arFields[$key] : array($arFields[$key]);
         if ($arDocumentFields[$key]["Type"] == "user") {
             $ar = array();
             foreach ($arFields[$key] as $v1) {
                 if (substr($v1, 0, strlen("user_")) == "user_") {
                     $ar[] = substr($v1, strlen("user_"));
                 } else {
                     $a1 = self::GetUsersFromUserGroup($v1, "CONTACT_0");
                     foreach ($a1 as $a11) {
                         $ar[] = $a11;
                     }
                 }
             }
             $arFields[$key] = $ar;
         } elseif ($fieldType == "select" && substr($key, 0, 3) == "UF_") {
             self::InternalizeEnumerationField('CRM_CONTACT', $arFields, $key);
         } elseif ($fieldType == "file") {
             $arFileOptions = array('ENABLE_ID' => true);
             foreach ($arFields[$key] as &$value) {
                 //Issue #40380. Secure URLs and file IDs are allowed.
                 $file = false;
                 CCrmFileProxy::TryResolveFile($value, $file, $arFileOptions);
                 $value = $file;
             }
             unset($value);
         } elseif ($fieldType == "S:HTML") {
             foreach ($arFields[$key] as &$value) {
                 $value = array("VALUE" => $value);
             }
             unset($value);
         }
         if (!$arDocumentFields[$key]["Multiple"] && is_array($arFields[$key])) {
             if (count($arFields[$key]) > 0) {
                 $a = array_values($arFields[$key]);
                 $arFields[$key] = $a[0];
             } else {
                 $arFields[$key] = null;
             }
         }
     }
     if (isset($arFields['COMMENTS'])) {
         if (preg_match('/<[^>]+[\\/]?>/i', $arFields['COMMENTS']) === 1) {
             $arFields['COMMENTS'] = htmlspecialcharsbx($arFields['COMMENTS']);
         }
         $arFields['COMMENTS'] = str_replace(array("\r\n", "\r", "\n"), "<br>", $arFields['COMMENTS']);
     }
     $DB->StartTransaction();
     $CCrmEntity = new CCrmContact(false);
     $id = $CCrmEntity->Add($arFields);
     if (!$id || $id <= 0) {
         $DB->Rollback();
         throw new Exception($CCrmEntity->LAST_ERROR);
     }
     if (COption::GetOptionString("crm", "start_bp_within_bp", "N") == "Y") {
         $CCrmBizProc = new CCrmBizProc('CONTACT');
         if (false === $CCrmBizProc->CheckFields(false, true)) {
             throw new Exception($CCrmBizProc->LAST_ERROR);
         }
         if ($id && $id > 0 && !$CCrmBizProc->StartWorkflow($id)) {
             $DB->Rollback();
             throw new Exception($CCrmBizProc->LAST_ERROR);
             $id = false;
         }
     }
     if ($id && $id > 0) {
         $DB->Commit();
     }
     return $id;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:89,代码来源:crm_document_contact.php

示例9: array

 */
 if (empty($arResult['ERROR_MESSAGE'])) {
     if ($bConvertCompany) {
         $iCompanyId = $CCrmCompany->Add($arFields['COMPANY'], true, array('REGISTER_SONET_EVENT' => true));
         if ($iCompanyId > 0) {
             $CCrmCompanyBizProc = new CCrmBizProc('COMPANY');
             $arCompanyBizProcParams = $CCrmCompanyBizProc->CheckFields(false, false, $arFields['COMPANY']['ASSIGNED_BY_ID'], null);
             if ($arCompanyBizProcParams !== false) {
                 $CCrmCompanyBizProc->StartWorkflow($iCompanyId, $arCompanyBizProcParams);
             }
         }
     }
     $arFields['CONTACT']['COMPANY_ID'] = $iCompanyId;
     $arFields['DEAL']['COMPANY_ID'] = $iCompanyId;
     if ($bConvertContact) {
         $iContactId = $CCrmContact->Add($arFields['CONTACT'], true, array('REGISTER_SONET_EVENT' => true));
         if ($iContactId > 0) {
             $CCrmEvent = new CCrmEvent();
             $CCrmEvent->Share(array('ENTITY_TYPE' => 'LEAD', 'ENTITY_ID' => $arParams['ELEMENT_ID']), array(array('ENTITY_TYPE' => 'CONTACT', 'ENTITY_ID' => $iContactId)), 'MESSAGE');
             $CCrmContactBizProc = new CCrmBizProc('CONTACT');
             $arContactBizProcParams = $CCrmContactBizProc->CheckFields(false, false, $arFields['CONTACT']['ASSIGNED_BY_ID'], null);
             if ($arContactBizProcParams !== false) {
                 $CCrmContactBizProc->StartWorkflow($iContactId, $arContactBizProcParams);
             }
         }
     }
     $arFields['DEAL']['CONTACT_ID'] = $iContactId;
     if (!$CrmPerms->HavePerm('DEAL', BX_CRM_PERM_NONE, 'ADD')) {
         if ($bConvertDeal) {
             $arDealFields = $arFields['DEAL'];
             $iDealId = $CCrmDeal->Add($arDealFields, true, array('REGISTER_SONET_EVENT' => true));
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php

示例10: isset

    }
    $phone = isset($data['phone']) ? $data['phone'] : '';
    if ($phone !== '') {
        if (!isset($arFields['FM'])) {
            $arFields['FM'] = array();
        }
        $arFields['FM']['PHONE'] = array('n0' => array('VALUE_TYPE' => 'WORK', 'VALUE' => $phone));
    }
    $CrmContact = new CCrmContact();
    if ($ID > 0) {
        if ($CrmContact->Update($ID, $arFields, true, array('DISABLE_USER_FIELD_CHECK' => true, 'REGISTER_SONET_EVENT' => true))) {
            $info = CCrmEntitySelectorHelper::PrepareEntityInfo('CONTACT', $ID);
            echo CUtil::PhpToJSObject(array('DATA' => $data, 'INFO' => array('title' => $info['TITLE'], 'url' => $info['URL'])));
        }
    } else {
        $ID = $CrmContact->Add($arFields, true, array('DISABLE_USER_FIELD_CHECK' => true, 'REGISTER_SONET_EVENT' => true));
        if (is_int($ID) && $ID > 0) {
            $data['id'] = $ID;
            $info = CCrmEntitySelectorHelper::PrepareEntityInfo('CONTACT', $ID, array('NAME_TEMPLATE' => isset($_POST['NAME_TEMPLATE']) ? $_POST['NAME_TEMPLATE'] : ''));
            echo CUtil::PhpToJSObject(array('DATA' => $data, 'INFO' => array('title' => $info['TITLE'], 'url' => $info['URL'])));
        } else {
            echo CUtil::PhpToJSObject(array('ERROR' => $CrmContact->LAST_ERROR));
        }
    }
} elseif ($action === 'ENABLE_SONET_SUBSCRIPTION') {
    $userID = CCrmSecurityHelper::GetCurrentUserID();
    $entityTypeName = isset($_POST['ENTITY_TYPE']) ? strtoupper($_POST['ENTITY_TYPE']) : '';
    $entityID = isset($_POST['ENTITY_ID']) ? intval($_POST['ENTITY_ID']) : 0;
    if ($userID > 0 && $entityTypeName === CCrmOwnerType::ContactName && $entityID > 0 && CCrmContact::CheckReadPermission($entityID)) {
        $isEnabled = CCrmSonetSubscription::IsRelationRegistered(CCrmOwnerType::Contact, $entityID, CCrmSonetSubscriptionType::Observation, $userID);
        $enable = isset($_POST['ENABLE']) && strtoupper($_POST['ENABLE']) === 'Y';
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:ajax.php


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