Esempio n. 1
0
     __CrmLeadListEndResonse(array('ERROR' => 'Undefined entity type is specified.'));
 }
 if ($entityTypeID !== CCrmOwnerType::Lead) {
     __CrmLeadListEndResonse(array('ERROR' => "The '{$entityTypeName}' type is not supported in current context."));
 }
 if (!CCrmLead::CheckUpdatePermission(0)) {
     __CrmLeadListEndResonse(array('ERROR' => 'Access denied.'));
 }
 if (COption::GetOptionString('crm', '~CRM_REBUILD_LEAD_DUP_INDEX', 'N') !== 'Y') {
     __CrmLeadListEndResonse(array('STATUS' => 'NOT_REQUIRED', 'SUMMARY' => GetMessage('CRM_LEAD_LIST_REBUILD_DUPLICATE_INDEX_NOT_REQUIRED_SUMMARY')));
 }
 $progressData = COption::GetOptionString('crm', '~CRM_REBUILD_LEAD_DUP_INDEX_PROGRESS', '');
 $progressData = $progressData !== '' ? unserialize($progressData) : array();
 if (empty($progressData) && intval(\Bitrix\Crm\BusinessTypeTable::getCount()) === 0) {
     //Try to fill BusinessTypeTable on first iteration
     \Bitrix\Crm\BusinessTypeTable::installDefault();
 }
 $lastItemID = isset($progressData['LAST_ITEM_ID']) ? intval($progressData['LAST_ITEM_ID']) : 0;
 $processedItemQty = isset($progressData['PROCESSED_ITEMS']) ? intval($progressData['PROCESSED_ITEMS']) : 0;
 $totalItemQty = isset($progressData['TOTAL_ITEMS']) ? intval($progressData['TOTAL_ITEMS']) : 0;
 if ($totalItemQty <= 0) {
     $totalItemQty = CCrmLead::GetListEx(array(), array('CHECK_PERMISSIONS' => 'N'), array(), false);
 }
 $filter = array('CHECK_PERMISSIONS' => 'N');
 if ($lastItemID > 0) {
     $filter['>ID'] = $lastItemID;
 }
 $dbResult = CCrmLead::GetListEx(array('ID' => 'ASC'), $filter, false, array('nTopCount' => 100), array('ID'));
 $itemIDs = array();
 $itemQty = 0;
 if (is_object($dbResult)) {
 public static function getTypeRegexPattern()
 {
     if (self::$typeRx !== null) {
         return self::$typeRx;
     }
     self::$typeRx = array();
     $dbBizType = Crm\BusinessTypeTable::getList(array('select' => array('NAME'), 'order' => array('CODE' => 'DESC')));
     $isUtf = defined('BX_UTF');
     $lBorder = $isUtf ? "(?<!\\pL)" : "\\b";
     $rBorder = $isUtf ? "(?!\\pL)" : "\\b";
     while ($bizType = $dbBizType->fetch()) {
         $name = isset($bizType['NAME']) ? $bizType['NAME'] : '';
         $parts = explode('.', $name);
         $qty = count($parts);
         if ($qty === 1) {
             $pattern = "{$lBorder}{$name}{$rBorder}";
         } else {
             $ary = array();
             for ($i = 0; $i < $qty; $i++) {
                 $part = $parts[$i];
                 if ($part !== '') {
                     $part = preg_replace('/\\s+/', '\\s+', $part);
                 }
                 if ($i === 0) {
                     $ary[] = "{$lBorder}{$part}";
                 } elseif ($i < $qty - 1) {
                     $ary[] = "(\\s*\\.{0,1}\\s*){$part}";
                 } else {
                     if ($part !== '') {
                         $ary[] = "(\\s*\\.{0,1}\\s*){$part}{$rBorder}";
                     } else {
                         $ary[] = "(\\.|{$rBorder})";
                     }
                 }
             }
             $pattern = implode('', $ary);
         }
         if ($pattern !== '') {
             self::$typeRx[] = "/{$pattern}/i" . BX_UTF_PCRE_MODIFIER;
         }
     }
     if ($isUtf) {
         //\u00AB « left-pointing double angle quotation mark
         //\u00BB » right-pointing double angle quotation mark
         //\u201E „ double low-9 quotation mark
         //\u201F ? double high-reversed-9 quotation mark
         //\u2018 ‘ left single quotation mark
         //\u2019 ’ right single quotation mark
         //\u201C “ left double quotation mark
         //\u201D ” right double quotation mark
         self::$typeRx[] = '/[\\x{00AB}\\x{00BB}\\x{2018}\\x{2019}\\x{201C}\\x{201D}\\x{201E}\\x{201F}]/u';
     } else {
         //AB « left-pointing double angle quotation mark
         //BB » right-pointing double angle quotation mark
         //84 „ double low-9 quotation mark
         //91 ‘ left single quotation mark
         //92 ’ right single quotation mark
         //93 “ left double quotation mark
         //94 ” right double quotation mark
         self::$typeRx[] = '/[\\xAB\\xBB\\x84\\x91\\x92\\x93\\x94]/';
     }
     self::$typeRx[] = '/[\\"\'\\-\\,\\.\\;\\:\\s]/i' . BX_UTF_PCRE_MODIFIER;
     return self::$typeRx;
 }