Beispiel #1
0
 /**
  * Добавляем инфоблок дополнительных свойств пользователя
  * @param $name
  */
 function addPropsBlock($name)
 {
     global $USER;
     $PROP['PROPERTY_USER'] = $this->getUserId();
     $arLoadProductArray = array("MODIFIED_BY" => $USER->GetID(), "IBLOCK_ID" => IB_USER_PROPS, "PROPERTY_VALUES" => $PROP, "NAME" => $name, "ACTIVE" => "Y");
     return CIBlockElement::Add($arLoadProductArray);
 }
 public function Execute()
 {
     if (!CModule::IncludeModule("intranet")) {
         return CBPActivityExecutionStatus::Closed;
     }
     $absenceIblockId = COption::GetOptionInt("intranet", 'iblock_absence', 0);
     if ($absenceIblockId <= 0) {
         return CBPActivityExecutionStatus::Closed;
     }
     $rootActivity = $this->GetRootActivity();
     $documentId = $rootActivity->GetDocumentId();
     $documentService = $this->workflow->GetService("DocumentService");
     $arAbsenceUserTmp = $this->AbsenceUser;
     $arAbsenceUser = CBPHelper::ExtractUsers($arAbsenceUserTmp, $documentId, false);
     $arAbsenceTypes = array();
     $dbTypeRes = CIBlockPropertyEnum::GetList(array("SORT" => "ASC", "VALUE" => "ASC"), array('IBLOCK_ID' => $absenceIblockId, 'PROPERTY_ID' => 'ABSENCE_TYPE'));
     while ($arTypeValue = $dbTypeRes->GetNext()) {
         $arAbsenceTypes[$arTypeValue['XML_ID']] = $arTypeValue['ID'];
     }
     foreach ($arAbsenceUser as $absenceUser) {
         $arFields = array("ACTIVE" => "Y", "IBLOCK_ID" => $absenceIblockId, 'ACTIVE_FROM' => $this->AbsenceFrom, 'ACTIVE_TO' => $this->AbsenceTo, "NAME" => $this->AbsenceName, "PREVIEW_TEXT" => $this->AbsenceDesrc, "PREVIEW_TEXT_TYPE" => "text", "PROPERTY_VALUES" => array("USER" => $absenceUser, "STATE" => $this->AbsenceState, "FINISH_STATE" => $this->AbsenceFinishState, "ABSENCE_TYPE" => $arAbsenceTypes[$this->AbsenceType]));
         $el = new CIBlockElement();
         $el->Add($arFields);
     }
     return CBPActivityExecutionStatus::Closed;
 }
 function AddProduct($NAME)
 {
     $iblock_permission = CIBlock::GetPermission(IBLOCK_ID);
     if ($iblock_permission < "W") {
         $GLOBALS["USER"]->RequiredHTTPAuthBasic();
         return new CSOAPFault('Server Error', 'Unable to authorize user.');
     }
     $code = self::translit($NAME);
     $i = 1;
     while (true) {
         $res = CIBlockElement::Getlist(array(), array("CODE" => $code), false, array("CODE"));
         if ($res->Fetch()) {
             $code = self::translit($NAME) . $i;
         } else {
             break;
         }
         $i++;
     }
     $arFields = array("IBLOCK_ID" => IBLOCK_ID, "NAME" => $NAME);
     $ib_element = new CIBlockElement();
     $result = $ib_element->Add($arFields);
     if ($result > 0) {
         return $result;
     }
     return new CSOAPFault('Server Error', 'Error: ' . $ib_element->LAST_ERROR);
 }
Beispiel #4
0
function trackStartedTask($stopStartedTask = true)
{
    CModule::IncludeModule('iblock');
    $res = CIBlockElement::GetList(array(), array("IBLOCK_ID" => TASKS_IBLOCK_ID, 'ACTIVE' => 'Y', "PROPERTY_PROGRAMMER" => CUser::GetID(), "PROPERTY_STATUS" => STATUS_LIST_WORK), false, false, array('ID', 'NAME', 'PROPERTY_PROJECT', 'PROPERTY_STATUS_DATE'));
    if ($taskArr = $res->Fetch()) {
        if ($stopStartedTask) {
            CIBlockElement::SetPropertyValuesEx($taskArr['ID'], TASKS_IBLOCK_ID, array('STATUS' => STATUS_LIST_PAUSE));
        }
        $link = TASKS_LIST_URL . $taskArr["PROPERTY_PROJECT_VALUE"] . '/' . $taskArr['ID'] . '/';
        $date = new DateTime($taskArr["PROPERTY_STATUS_DATE_VALUE"]);
        $curdate = new DateTime();
        $diff = $date->diff($curdate);
        $h = $diff->format('%h');
        $i = $diff->format('%i');
        if ($h || $i) {
            $timingText = '';
            if ($h) {
                $timingText = "{$h} ч, ";
            }
            if ($i) {
                $timingText = $timingText . "{$i} мин. ";
            }
            $decTime = $h + $i / 60;
            $decTime = round($decTime, 2);
            $el = new CIBlockElement();
            if ($el->Add(array("DATE_ACTIVE_FROM" => ConvertTimeStamp(time(), "SHORT"), "MODIFIED_BY" => CUser::GetID(), "IBLOCK_SECTION_ID" => false, "IBLOCK_ID" => TRACKING_IBLOCK_ID, "NAME" => 'Без названия' . ' (' . $decTime . 'ч.)', "ACTIVE" => "Y", "PROPERTY_VALUES" => array("HOURS" => $decTime, "TASK" => $taskArr['ID'])))) {
                crmEntitiesHelper::recalcTaskTracking($taskArr['ID']);
                ToolTip::Add("+ {$timingText} в трекер задачи \"<a target=\"_blank\" href=\"{$link}\">{$taskArr['ID']} {$taskArr['NAME']}</a>\"");
            } else {
                ToolTip::AddError($el->LAST_ERROR);
            }
        }
    }
}
Beispiel #5
0
 function add($data)
 {
     global $USER;
     $el = new CIBlockElement();
     $arLoadProductArray = array("MODIFIED_BY" => $USER->GetID(), "IBLOCK_ID" => IB_SUB_STOCK_ID, "PROPERTY_VALUES" => array('CLUB_ID' => $this->clubID), "ACTIVE_TO" => date("d.m.Y", strtotime($data['ACTIVE_TO'])), "ACTIVE_FROM" => date("d.m.Y", strtotime($data['ACTIVE_FROM'])), "NAME" => trim(strip_tags($data['NAME'])), "ACTIVE" => "Y", "DETAIL_TEXT" => trim($data['DETAIL_TEXT']));
     return $el->Add($arLoadProductArray);
 }
Beispiel #6
0
function addResult($STEP, $PARAMS){
	if (!CModule::IncludeModule("iblock")):
		return false;
	endif;
	global $USER;
	$actionStr = getActionStr($STEP);
	$el = new CIBlockElement;
	$PROP = array();
	$PROP = array(
		"TIME" => mktime(),
		"ACTION" => $actionStr,
		"STATUS" => "wait",
		"TYPE" => $STEP,
		"PARAMS" => $PARAMS,
		"MESSAGE" => "Ожидает"
		);
	$arLoadProductArray = Array(
	  "MODIFIED_BY"    => $USER->GetID(), // элемент изменен текущим пользователем
	  "IBLOCK_ID"      => 23,
	  "PROPERTY_VALUES"=> $PROP,
	  "NAME"           => $actionStr,
	  "ACTIVE"         => "Y",// активен
	  );
	if($ID = $el->Add($arLoadProductArray)):
		return $ID;
	endif;
}
function storeResult($arResult, $arParams) {
    $iblock = CIBlock::GetList(
        array(),
        array(
            'TYPE' => $arParams['IBLOCK_TYPE'],
            'CODE' => $arParams['IBLOCK_CODE'],
        )
    );
    $iblock = $iblock->Fetch();
    
    $el = new CIBlockElement;

    $props = array();
    foreach ($arResult['FIELDS_LIST'] as $arField) {
        if ($arField['FIELD_TYPE'] == 'TEXT' || $arField['FIELD_TYPE'] == 'NUMBER') {
            $props[$arField['CODE']] = array(
                'VALUE' => $arResult['POST_DATA']['~'.$arField['CODE']],
            );
        } elseif ($arField['FIELD_TYPE'] == 'TEXTAREA') {
            $props[$arField['CODE']] = array(
                'VALUE' => array(
                    'TYPE' => 'text',
                    'TEXT' => $arResult['POST_DATA']['~'.$arField['CODE']],
                ),
            );
        } elseif ($arField['FIELD_TYPE'] == 'LIST') {
            $propEnum = CIBlockPropertyEnum::GetList(
                array(),
                array(
                    'XML_ID' => $arResult['POST_DATA']['~'.$arField['CODE']],
                    'CODE' => $arField['CODE'],
                    'IBLOCK_ID' => $iblock['ID'],
                )
            );
            $propEnum = $propEnum->Fetch();
            if ( ! $propEnum) return false;

            $props[$arField['CODE']] = array(
                'VALUE' => $propEnum['ID'],
            );
        }
    }

    $res = $el->Add(array(
        'IBLOCK_TYPE' => $arParams['IBLOCK_TYPE'],
        'IBLOCK_ID' => $iblock['ID'],
        'ACTIVE' => 'Y',
        'PROPERTY_VALUES' => $props,
        'ACTIVE_FROM' => ConvertTimeStamp(time()+CTimeZone::GetOffset(), 'FULL'),
        'NAME' => 'Form result', # !!! NEED TO REPLACE TO DEFAULT VALUE
    ));

    if (!$res) {
        return array(
            'MESSAGE' => $el->LAST_ERROR,
        );
    }

    return true;
}
Beispiel #8
0
 /**
  * <p>Метод добавляет новую Wiki-страницу. Динамичный метод.</p>
  *
  *
  * @param array $arFields  <a href="http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblock/add.php">CIBlock::Add</a>
  *
  * @return int 
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?<br>
  * // Добавим Wiki-страницу в инфо.блок с идентификатором 2
  * 
  * $arFields = array(
  * 	'ACTIVE' =&gt; 'Y',
  * 	'IBLOCK_ID' =&gt; 2,
  * 	'DETAIL_TEXT_TYPE' =&gt; 'html',
  * 	'DETAIL_TEXT' =&gt; '&lt;br/&gt;&lt;h2&gt;Тестовая страница&lt;/h2&gt;&lt;br/&gt;',
  * 	'NAME' =&gt; 'Тестовая страница'
  * );
  * $CWiki = new CWiki();
  * if (!($ID = $CWiki-&gt;Add($arFields)))
  * 	echo 'Ошибка. Страница не создана.';
  * ?&gt;
  * </pre>
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/wiki/classes/cwiki/Update.php">CWiki::Update</a> </li> </ul><a
  * name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/wiki/classes/cwiki/Add.php
  * @author Bitrix
  */
 public function Add($arFields)
 {
     $arFields['XML_ID'] = $arFields['NAME'];
     $arCats = array();
     $CWikiParser = new CWikiParser();
     $arFields['DETAIL_TEXT'] = $CWikiParser->parseBeforeSave($arFields['DETAIL_TEXT'], $arCats, $arFields['NAME_TEMPLATE']);
     if (CWikiSocnet::IsSocNet()) {
         $arFields['IBLOCK_SECTION_ID'] = CWikiSocnet::$iCatId;
     }
     //add item
     $ID = $this->cIB_E->Add($arFields);
     $this->CleanCache($ID, $arFields['NAME'], $arFields['IBLOCK_ID']);
     //serve category / bindings
     $this->UpdateCategory($ID, $arFields['IBLOCK_ID'], $arCats);
     //$this->UpdateHistory($ID, $arFields['IBLOCK_ID']);
     return $ID;
 }
Beispiel #9
0
/**
 * Created by JetBrains PhpStorm.
 * User: oleg
 * Date: 01.10.12
 * Time: 21:06
 * To change this template use File | Settings | File Templates.
 */
function agent_kingcoupon_pars()
{
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
    CModule::IncludeModule("iblock");
    CModule::IncludeModule("mytb");
    $content = file_get_contents("http://kingcoupon.ru/offer/category/Food/");
    preg_match_all("#kingcoupon\\.ru/offer/([0-9]+)/#is", $content, $arr);
    $xml = file_get_contents("http://kingcoupon.ru/offer/export/?refId=100132540459877345");
    $svg = new SimpleXMLElement($xml);
    $clubListID = array();
    foreach ($arr[1] as $var) {
        $clubListID[$var] = $var;
    }
    foreach ($svg->offers->offer as $var) {
        $R = array();
        if (in_array($var->id, $arr[1])) {
            $R['clubName'] = (string) $var->supplier->name;
            foreach ((array) $var->supplier->addresses as $address) {
                if (is_array($address)) {
                    foreach ((array) $address as $var1) {
                        $R['clubAdress'][] = (string) $var1->name;
                    }
                } else {
                    $R['clubAdress'][] = $address->name;
                }
            }
            foreach ((array) $var->supplier->tel as $tel) {
                $R['clubPhone'][] = $tel;
            }
            $id = $var->id;
            $url = preg_replace("#http://#i", "", $var->supplier->url);
            $url = preg_replace("#^([^/]+)/.*#i", "\\1", $url);
            $url = str_replace("www.", "", $url);
            $R['url'] = $url;
            $arSelect = array("ID", "NAME");
            $arFilter = array("IBLOCK_ID" => IB_CLUB_ID, "PROPERTY_SITE" => "%" . $url . "%");
            $res = CIBlockElement::GetList(array("SORT" => "DESC"), $arFilter, FALSE, FALSE, $arSelect);
            if (!$res->Fetch()) {
                $PROP = array();
                //                $PROP["PHONE"]   = $R['clubPhone'];
                //                $PROP["ADDRESS"] = $R['clubAdress'];
                $PROP["SITE"] = $R['url'];
                $PROP["LIST"] = array(54);
                $el = new CIBlockElement();
                $arLoadProductArray = array("IBLOCK_ID" => IB_CLUB_ID, "PROPERTY_VALUES" => $PROP, "NAME" => $R['clubName'], "TAGS" => "kingcoupon", "ACTIVE" => "Y", "SORT" => "0");
                if ($PRODUCT_ID = $el->Add($arLoadProductArray)) {
                    foreach ($R['clubAdress'] as $addressItem) {
                        MyTbCore::Add(array("CLUB_ID" => $PRODUCT_ID, "SITY_ID" => 1, "ADDRESS" => $addressItem, "PHONE" => serialize($R['clubPhone'])), "address");
                        printAr($addressItem);
                    }
                } else {
                    echo "Error: " . $el->LAST_ERROR;
                }
            }
        }
    }
    return "agent_kingcoupon_pars();";
}
 function executeUp()
 {
     CModule::IncludeModule('iblock');
     $obj_ib_element = new CIBlockElement();
     $r = $obj_ib_element->Add(array('NAME' => 'sone new name here', 'IBLOCK_ID' => self::IBLOCK_ID, 'ACTIVE' => 'Y'));
     if (!$r) {
         throw new \Exception('Fail do add new element!!!');
     }
     return true;
 }
Beispiel #11
0
 private function addElement($arFields)
 {
     $el = new \CIBlockElement();
     if ($elID = $el->Add($arFields)) {
         $this->message .= \Helper::boldColorText("Елемент - <{$arFields['XML_ID']}> успешно добавлен", 'green');
     } else {
         $err = "Добавление элемента <{$arFields['XML_ID']}> не удалось((( - {$el->LAST_ERROR}";
         $this->errors .= \Helper::boldColorText($err, "red");
     }
 }
 /**
  * Добавляет элемент
  *
  * @param array $fields
  * @param array $properties
  *
  * @return int|null
  */
 public function add(array $fields, array $properties = array())
 {
     if ($id = $this->iBEGateway->Add($fields)) {
         if (!empty($properties)) {
             \CIBlockElement::SetPropertyValuesEx($id, $fields['IBLOCK_ID'], $properties);
         }
         return $id;
     }
     return null;
 }
Beispiel #13
0
 public static function connectToUser($userID, $providerName, $userProfile)
 {
     CModule::IncludeModule("iblock");
     $el = new \CIBlockElement();
     $PROP = array();
     $PROP["USER_ID"] = $userID;
     $PROP["SOCIAL_PROVIDER"] = $providerName;
     $PROP["SOCIAL_ID"] = $userProfile["identifier"];
     $arLoadProductArray = array("IBLOCK_SECTION_ID" => false, "IBLOCK_ID" => USER_SOCIAL_IB, "PROPERTY_VALUES" => $PROP, "NAME" => trim("Пользователь №" . $userID), "ACTIVE" => "Y");
     $el->Add($arLoadProductArray);
     \CUserEx::capacityAdd($userID, 1);
 }
 public function save()
 {
     \Bitrix\Main\Loader::includeModule("iblock");
     $errors =& $this->arResult["forms"][$this->request->getPost("id")]["errors"];
     $el = new CIBlockElement();
     $this->element_id = $el->Add(array("IBLOCK_ID" => 4, "NAME" => "({$this->arResult["forms"][$this->request->getPost("id")]["title"]})Обращение от {$this->request->getPost("first_name")} {$this->request->getPost("last_name")}", "PREVIEW_TEXT" => $this->request->getPost("comment"), "PROPERTY_VALUES" => array("TREATMENT_REASON" => $this->request->getPost("reason_for_treatment"), "PHONE" => $this->request->getPost("phone"), "EMAIL" => $this->request->getPost("email"), "FILE" => $this->request->getFile("file"))));
     if ($this->element_id !== false) {
         return true;
     }
     $errors[] = $res->LAST_ERROR;
     return false;
 }
Beispiel #15
0
function addElementReview($arResult, $ID_SECTION, $IBLOCK_ID)
{
    CModule::IncludeModule('iblock');
    $property_enums = CIBlockPropertyEnum::GetList(array("DEF" => "DESC", "SORT" => "ASC"), array("IBLOCK_ID" => $IBLOCK_ID, "CODE" => "RATING", "VALUE" => $arResult['RATING']));
    while ($rating = $property_enums->GetNext()) {
        $arRating = $rating["ID"];
    }
    $current_date = dateActiveFrom(date('d.m.Y'));
    $NAME = $current_date . ' ' . $arResult['NAME'];
    $arFields = array("ACTIVE" => "N", "IBLOCK_ID" => $IBLOCK_ID, "IBLOCK_SECTION_ID" => $ID_SECTION, "NAME" => $NAME, "DETAIL_TEXT" => "Описание элемента", "PROPERTY_VALUES" => array("NAME" => $arResult['NAME'], "EMAIL" => $arResult['EMAIL'], "RATING" => array('VALUE' => $arRating), "BENEFITS" => $arResult['BENEFITS'], "DISADVANTAGES" => $arResult['DISADVANTAGES'], "COMMENT" => $arResult['COMMENT']));
    $oElement = new CIBlockElement();
    $idElement = $oElement->Add($arFields, false, false, true);
    return $idElement;
}
Beispiel #16
0
function OnAfterUserAddHandler(&$arFields)
{
    if (intval($arFields["ID"]) > 0) {
        global $USER;
        $noticeDefault = array("day" => array(1, 2, 3, 4, 5, 6, 7), "metod" => array("sms", "email"));
        $PROP['USER'] = $arFields["ID"];
        $PROP["NOTICE"] = serialize($noticeDefault);
        $arLoadProductArray = array("MODIFIED_BY" => $USER->GetID(), "IBLOCK_ID" => IB_USER_PROPS, "PROPERTY_VALUES" => $PROP, "NAME" => $arFields["LOGIN"], "ACTIVE" => "Y");
        $el = new CIBlockElement();
        $el->Add($arLoadProductArray);
        return true;
    } else {
        return TRUE;
    }
}
 function addOrder($data)
 {
     if ($data['product'] > 0 and strlen(trim($data['name'])) > 0 and (strlen(trim($data['phone'])) > 0 or strlen(trim($data['email'])) > 0)) {
         /**
          * save form
          */
         $arFields = array('IBLOCK_ID' => (int) $GLOBALS['AQW_ORDER']['IBLOCK_ID'], 'NAME' => GetMessage("AQW_SHOP_NOVYY_ZAKAZ_OT") . date("d.m.Y H:i:s"), 'PROPERTY_VALUES' => array('PRODUCT' => $data['product'], 'COLOR' => $data['color'], 'SIZE' => $data['size'], 'NAME' => $data['name'], 'PHONE' => $data['phone'], 'EMAIL' => $data['email'], 'ORDER_URL' => getenv("REQUEST_URI")));
         $iBlock = new CIBlockElement();
         $ORDER_ID = $iBlock->Add($arFields);
         /**
          * send email
          */
         $arEventFields = array("IBLOCK_TYPE" => $GLOBALS['AQW_ORDER']['IBLOCK_TYPE'], "IBLOCK_ID" => (int) $GLOBALS['AQW_ORDER']['IBLOCK_ID'], "ORDER_ID" => $ORDER_ID, "PRODUCT" => $data['product'], "COLOR" => $data['color'], "SIZE" => $data['size'], "NAME" => $data['name'], "PHONE" => $data['phone'], "EMAIL" => $data['email'], "ORDER_URL" => getenv("REQUEST_URI"));
         CEvent::Send("NEW_ORDER", SITE_ID, $arEventFields);
     }
 }
 public function addElement($elementsProperties)
 {
     if (empty($this->elementName)) {
         $this->elementName = date('Y.m.d H:i');
     }
     $el = new \CIBlockElement();
     $id = $el->Add(array('IBLOCK_ID' => $this->iBlockId, 'PROPERTY_VALUES' => $elementsProperties, 'NAME' => $this->elementName, "DATE_ACTIVE_FROM" => ConvertTimeStamp(time(), "FULL")));
     if (!$id) {
         if ($this->isCritical) {
             throw new \Exception($el->LAST_ERROR);
         } else {
             $this->form->setErrors($this->getErrorMessage($el->LAST_ERROR));
         }
     }
     return $id;
 }
	public function ImportFromID($id = 0) {
		global $USER;
		if (!is_object($USER)) $USER = new CUser;

		$channel = CIChannelsRssRep::GetRssChannelById($id);
		if (!$channel) return;

		$arUrl = parse_url($channel['URL']);

		if (!array_key_exists('port', $arUrl)) $arUrl['port'] = 80;
		if (!array_key_exists('path', $arUrl)) $arUrl['path'] = '';
		if (!array_key_exists('query', $arUrl)) $arUrl['query'] = '';

		CModule::IncludeModule('iblock');

		$rChannel = CIBlockRSS::GetNewsEx(
			$arUrl['host'],
			$arUrl['port'],
			$arUrl['path'],
			$arUrl['query']
		);

		$arChannel = CIBlockRSS::FormatArray($rChannel);

		$mapper = CIChannels::getRssMapperByID($channel['MAPPER']);

		$ins = new $mapper['class'];

		foreach ($arChannel['item'] as $item) {
			$arFields = $ins->{$mapper['method']}($item, $channel);
			if (empty ($arFields)) continue;

			$arFields['ACTIVE'] = 'Y';
			$arFields['IBLOCK_TYPE_ID'] = $channel['IBLOCK_TYPE_ID'];
			$arFields['IBLOCK_ID'] = $channel['IBLOCK_ID'];

			if ($channel['IBLOCK_SECTION_ID'] != '0') {
				$arFields['IBLOCK_SECTION_ID'] = $channel['IBLOCK_SECTION_ID'];
			}

			$iblockElement = new CIBlockElement();
			$iNewElementID = $iblockElement->Add($arFields);
		}

		return sprintf('%s(%d);', __METHOD__, $id);
	}
Beispiel #20
0
function add_element($iblock_id, $section_id, $NAME, $PRICE_EUR, $P, $DETAIL_PICTURE)
{
    $el = new CIBlockElement();
    //test_dump($P);
    $arFields = array("IBLOCK_ID" => $iblock_id, "NAME" => $NAME, "CODE" => $P["ARTNUMBER"], "ACTIVE" => "Y", "IBLOCK_SECTION_ID" => $section_id, "DETAIL_TEXT" => $P["DESCRIPTION_TEXT"], "DETAIL_TEXT_TYPE" => "html", "PROPERTY_VALUES" => $P, "DETAIL_PICTURE" => $DETAIL_PICTURE);
    if ($last_el_id = $el->Add($arFields)) {
        echo "New ID: " . $last_el_id . "<br>";
        $arFields = array("ID" => $last_el_id, "VAT_INCLUDED" => "Y");
        if (CCatalogProduct::Add($arFields)) {
            echo "Добавили параметры товара к элементу каталога " . $last_el_id . "<br>";
            $arFields = array("PRODUCT_ID" => $last_el_id, "CATALOG_GROUP_ID" => 1, "PRICE" => $PRICE_EUR, "CURRENCY" => "EUR");
            CPrice::Add($arFields);
        } else {
            echo "Ошибка добавления параметров товаров";
        }
    } else {
        echo "Error: " . $el->LAST_ERROR . "<br>";
    }
}
Beispiel #21
0
 /**
  * Функция копирования
  * @param $From - откуда $To - куда, $ID
  * @return bool
  */
 static function Copy($From, $To, $ID)
 {
     $result = array();
     foreach ($ID as $key => $value) {
         $res = CIBlockElement::GetByID($value);
         while ($ob = $res->GetNextElement()) {
             $arFields = $ob->GetFields();
             $arProps = $ob->GetProperties();
         }
         foreach ($arProps as $key => $value) {
             $arProp[$key] = $value["VALUE"];
         }
         $el = new CIBlockElement();
         $arLoadProductArray = array("NAME" => str_replace("&nbsp;", " ", htmlspecialchars_decode($arFields["NAME"])), "IBLOCK_ID" => $To, "ACTIVE" => $arFields["ACTIVE"], "DATE_ACTIVE_FROM" => $arFields["DATE_ACTIVE_FROM"], "DATE_ACTIVE_TO" => $arFields["DATE_ACTIVE_TO"], "SORT" => $arFields["SORT"], "PREVIEW_PICTURE" => CFile::MakeFileArray($arFields["PREVIEW_PICTURE"]), "PREVIEW_TEXT" => str_replace("&nbsp;", " ", htmlspecialchars_decode($arFields["PREVIEW_TEXT"])), "PREVIEW_TEXT_TYPE" => $arFields["PREVIEW_TEXT_TYPE"], "DETAIL_PICTURE" => CFile::MakeFileArray($arFields["DETAIL_PICTURE"]), "DETAIL_TEXT" => str_replace("&nbsp;", " ", htmlspecialchars_decode($arFields["DETAIL_TEXT"])), "DETAIL_TEXT_TYPE" => $arFields["DETAIL_TEXT_TYPE"], "SEARCHABLE_CONTENT" => $arFields["SEARCHABLE_CONTENT"], "DATE_CREATE" => $arFields["DATE_CREATE"], "CREATED_BY" => $arFields["CREATED_BY"], "CREATED_USER_NAME" => $arFields["CREATED_USER_NAME"], "TIMESTAMP_X" => $arFields["TIMESTAMP_X"], "MODIFIED_BY" => $arFields["MODIFIED_BY"], "USER_NAME" => $arFields["USER_NAME"], "LANG_DIR" => $arFields["LANG_DIR"], "LIST_PAGE_URL" => $arFields["LIST_PAGE_URL"], "DETAIL_PAGE_URL" => $arFields["DETAIL_PAGE_URL"], "SHOW_COUNTER" => $arFields["SHOW_COUNTER"], "SHOW_COUNTER_START" => $arFields["SHOW_COUNTER_START"], "WF_COMMENTS" => $arFields["WF_COMMENTS"], "WF_STATUS_ID" => $arFields["WF_STATUS_ID"], "LOCK_STATUS" => $arFields["LOCK_STATUS"], "TAGS" => $arFields["TAGS"], "PROPERTY_VALUES" => $arProp);
         if ($PRODUCT_ID = $el->Add($arLoadProductArray)) {
             $result[] = "Yes";
         }
     }
     return $result;
 }
Beispiel #22
0
 /**
  * @inheritdoc
  */
 public function save(array $request, array $builderData)
 {
     $iblockElement = new \CIBlockElement();
     $fields['IBLOCK_ID'] = $builderData['DATA']['ID'];
     foreach ($builderData['DEFAULT_FIELDS'] as $fieldName => $field) {
         if (isset($request[$fieldName])) {
             $fields[$fieldName] = $request[$fieldName];
         }
     }
     foreach ($builderData['FIELDS'] as $fieldName => $field) {
         if (isset($request[$fieldName])) {
             $fields['PROPERTY_VALUES'][$fieldName] = $request[$fieldName];
         }
     }
     $result = $iblockElement->Add($fields);
     if (is_numeric($result)) {
         return $result;
     }
     $iblockErrorParser = new IBlockErrorParser($builderData['FIELDS'], $builderData['DEFAULT_FIELDS']);
     $this->errorList = $iblockErrorParser->parse($iblockElement->LAST_ERROR);
     return false;
 }
    public static function ConvertToUrlForm($propName, $propValue)
    {
        if (CModule::IncludeModule("iblock")) {
            // check if infoblock contains conversion
            $arSelect = Array("ID", "NAME","CODE", "PROPERTY_CATEGORY");
            $arFilter = Array("IBLOCK_ID"=>37, "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y", "PROPERTY_CATEGORY_VALUE"=>$propName, "NAME"=>$propValue);
            $res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);
            $ob = $res->GetNext();
            if ($ob)
                return $ob["CODE"];

            // if no, make convertion and add to infoblock
            $urlForm = CUtil::translit($propValue,"ru", array("replace_space"=>"-","replace_other"=>"-"));
            $el = new CIBlockElement;
            $res = $el->Add(array(
                "IBLOCK_ID"=>37,
                "NAME"=>$propValue,
                "CODE"=>$urlForm,
                "PROPERTY_VALUES"=>array("CATEGORY"=>$propName)
            ));
            return $urlForm;
        }
    }
 public function fetch()
 {
     $feed = new SimplePie();
     $feed->set_feed_url($this->_feedUrl);
     $feed->init();
     $feed->handle_content_type();
     CModule::IncludeModule("iblock");
     $arFilter = array("IBLOCK_ID" => $this->_iblockId, "FEED_URL" => $this->_feedUrl);
     $arSelectedFields = array("PROPERTY_GUID");
     $dbRecords = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelectedFields);
     $arGuids = array();
     while ($arRecord = $dbRecords->GetNext()) {
         $arGuids[] = $arRecord["PROPERTY_GUID_VALUE"];
     }
     foreach ($feed->get_items() as $item) {
         if (in_array($item->get_id(true), $arGuids)) {
             continue;
         }
         $arProperties = array("GUID" => $item->get_id(true), "PERMALINK" => $item->get_permalink(), "FEED_URL" => $this->_feedUrl);
         $arFields = array("IBLOCK_ID" => $this->_iblockId, "NAME" => $item->get_title(), "PREVIEW_TEXT" => $item->get_description(), "DETAIL_TEXT" => $item->get_description(), "DATE_CREATE" => $item->get_date('d.m.Y H:i:s'), "PROPERTY_VALUES" => $arProperties);
         $iblockElement = new CIBlockElement();
         $iblockElement->Add($arFields, false, false, false);
     }
 }
Beispiel #25
0
function AddAbsence($arFields)
{
    global $iblockID;
    if (CModule::IncludeModule('iblock')) {
        $PROP = array();
        $db_absence = CIBlockProperty::GetList(array(), array("CODE" => "ABSENCE_TYPE", "IBLOCK_ID" => $iblockID));
        if ($ar_absence = $db_absence->Fetch()) {
            $PROP[$ar_absence['ID']] = array($arFields["ABSENCE_TYPE"]);
        }
        $db_user = CIBlockProperty::GetList(array(), array("CODE" => "USER", "IBLOCK_ID" => $iblockID));
        if ($ar_user = $db_user->Fetch()) {
            $PROP[$ar_user['ID']] = array($arFields["USER_ID"]);
        }
        $arNewFields = array("NAME" => $arFields["NAME"], "PROPERTY_VALUES" => $PROP, "ACTIVE_FROM" => $arFields["ACTIVE_FROM"], "ACTIVE_TO" => $arFields["ACTIVE_TO"], "IBLOCK_ID" => $iblockID);
        $element = new CIBlockElement();
        $ID = $element->Add($arNewFields);
    }
    if (!$ID) {
        $arErrors = preg_split("/<br>/", $element->LAST_ERROR);
        return $arErrors;
    } else {
        return $ID;
    }
}
Beispiel #26
0
 protected function processActionCheckDataElementCreation()
 {
     if ($_POST["save"] != "Y" && $_POST["changePostFormTab"] != "lists" && !check_bitrix_sessid()) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_SEAC_CONNECTION_MODULE_IBLOCK'))));
     }
     if (!Loader::IncludeModule('bizproc')) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_SEAC_CONNECTION_MODULE_BIZPROC'))));
     }
     if (!Loader::includeModule('iblock')) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_SEAC_CONNECTION_MODULE_IBLOCK'))));
     }
     $this->iblockId = intval($this->request->getPost('IBLOCK_ID'));
     $this->iblockTypeId = COption::GetOptionString("lists", "livefeed_iblock_type_id");
     $this->checkPermissionElement();
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $templateId = intval($_POST['TEMPLATE_ID']);
     $documentType = BizprocDocument::generateDocumentComplexType(COption::GetOptionString("lists", "livefeed_iblock_type_id"), $this->iblockId);
     if (!empty($templateId)) {
         if (CModule::IncludeModule('bizproc')) {
             if (!CBPWorkflowTemplateLoader::isConstantsTuned($templateId)) {
                 $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_CONSTANTS_TUNED_NEW'))));
                 $this->sendJsonErrorResponse();
             }
         }
     } else {
         if (CModule::IncludeModule("bizproc")) {
             $templateObject = CBPWorkflowTemplateLoader::getTemplatesList(array('ID' => 'DESC'), array('DOCUMENT_TYPE' => $documentType, 'AUTO_EXECUTE' => CBPDocumentEventType::Create), false, false, array('ID'));
             $template = $templateObject->fetch();
             if (!empty($template)) {
                 if (!CBPWorkflowTemplateLoader::isConstantsTuned($template["ID"])) {
                     $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_CONSTANTS_TUNED_NEW'))));
                     $this->sendJsonErrorResponse();
                 }
             } else {
                 $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_NOT_BIZPROC_TEMPLATE'))));
                 $this->sendJsonErrorResponse();
             }
         }
     }
     $list = new CList($this->iblockId);
     $fields = $list->getFields();
     $elementData = array("IBLOCK_ID" => $this->iblockId, "NAME" => $_POST["NAME"]);
     $props = array();
     foreach ($fields as $fieldId => $field) {
         if ($fieldId == "PREVIEW_PICTURE" || $fieldId == "DETAIL_PICTURE") {
             $elementData[$fieldId] = $_FILES[$fieldId];
             if (isset($_POST[$fieldId . "_del"]) && $_POST[$fieldId . "_del"] == "Y") {
                 $elementData[$fieldId]["del"] = "Y";
             }
         } elseif ($fieldId == "PREVIEW_TEXT" || $fieldId == "DETAIL_TEXT") {
             if (isset($field["SETTINGS"]) && is_array($field["SETTINGS"]) && $field["SETTINGS"]["USE_EDITOR"] == "Y") {
                 $elementData[$fieldId . "_TYPE"] = "html";
             } else {
                 $elementData[$fieldId . "_TYPE"] = "text";
             }
             $elementData[$fieldId] = $_POST[$fieldId];
         } elseif ($fieldId == 'ACTIVE_FROM' || $fieldId == 'ACTIVE_TO') {
             $elementData[$fieldId] = array_shift($_POST[$fieldId]);
         } elseif ($list->is_field($fieldId)) {
             $elementData[$fieldId] = $_POST[$fieldId];
         } elseif ($field["PROPERTY_TYPE"] == "F") {
             if (isset($_POST[$fieldId . "_del"])) {
                 $deleteArray = $_POST[$fieldId . "_del"];
             } else {
                 $deleteArray = array();
             }
             $props[$field["ID"]] = array();
             $files = $this->unEscape($_FILES);
             CFile::ConvertFilesToPost($files[$fieldId], $props[$field["ID"]]);
             foreach ($props[$field["ID"]] as $fileId => $file) {
                 if (isset($deleteArray[$fileId]) && (!is_array($deleteArray[$fileId]) && $deleteArray[$fileId] == "Y" || is_array($deleteArray[$fileId]) && $deleteArray[$fileId]["VALUE"] == "Y")) {
                     if (isset($props[$field["ID"]][$fileId]["VALUE"])) {
                         $props[$field["ID"]][$fileId]["VALUE"]["del"] = "Y";
                     } else {
                         $props[$field["ID"]][$fileId]["del"] = "Y";
                     }
                 }
             }
         } elseif ($field["PROPERTY_TYPE"] == "N") {
             if (is_array($_POST[$fieldId]) && !array_key_exists("VALUE", $_POST[$fieldId])) {
                 $props[$field["ID"]] = array();
                 foreach ($_POST[$fieldId] as $key => $value) {
                     if (is_array($value)) {
                         if (strlen($value["VALUE"])) {
                             $value = str_replace(" ", "", str_replace(",", ".", $value["VALUE"]));
                             if (!is_numeric($value)) {
                                 $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_VALIDATE_FIELD_ERROR', array('#NAME#' => $field['NAME'])))));
                                 $this->sendJsonErrorResponse();
                             }
                             $props[$field["ID"]][$key] = doubleval($value);
                         }
                     } else {
                         if (strlen($value)) {
                             $value = str_replace(" ", "", str_replace(",", ".", $value));
                             if (!is_numeric($value)) {
                                 $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_VALIDATE_FIELD_ERROR', array('#NAME#' => $field['NAME'])))));
                                 $this->sendJsonErrorResponse();
                             }
                             $props[$field["ID"]][$key] = doubleval($value);
                         }
                     }
                 }
             } else {
                 if (is_array($_POST[$fieldId])) {
                     if (strlen($_POST[$fieldId]["VALUE"])) {
                         $value = str_replace(" ", "", str_replace(",", ".", $_POST[$fieldId]["VALUE"]));
                         if (!is_numeric($value)) {
                             $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_VALIDATE_FIELD_ERROR', array('#NAME#' => $field['NAME'])))));
                             $this->sendJsonErrorResponse();
                         }
                         $props[$field["ID"]] = doubleval($value);
                     }
                 } else {
                     if (strlen($_POST[$fieldId])) {
                         $value = str_replace(" ", "", str_replace(",", ".", $_POST[$fieldId]));
                         if (!is_numeric($value)) {
                             $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_VALIDATE_FIELD_ERROR', array('#NAME#' => $field['NAME'])))));
                             $this->sendJsonErrorResponse();
                         }
                         $props[$field["ID"]] = doubleval($value);
                     }
                 }
             }
         } else {
             $props[$field["ID"]] = $_POST[$fieldId];
         }
     }
     $elementData["MODIFIED_BY"] = $this->getUser()->getID();
     unset($elementData["TIMESTAMP_X"]);
     if (!empty($props)) {
         $elementData["PROPERTY_VALUES"] = $props;
     }
     $documentStates = CBPDocument::GetDocumentStates($documentType, null);
     $userId = $this->getUser()->getId();
     $write = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::WriteDocument, $userId, $documentType, array('AllUserGroups' => array(), 'DocumentStates' => $documentStates));
     if (!$write) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_ACCESS_DENIED_STATUS'))));
         $this->sendJsonErrorResponse();
     }
     $bizprocParametersValues = array();
     foreach ($documentStates as $documentState) {
         if (strlen($documentState["ID"]) <= 0) {
             $errors = array();
             $bizprocParametersValues[$documentState['TEMPLATE_ID']] = CBPDocument::StartWorkflowParametersValidate($documentState['TEMPLATE_ID'], $documentState['TEMPLATE_PARAMETERS'], $documentType, $errors);
             $stringError = '';
             foreach ($errors as $e) {
                 $stringError .= $e['message'] . '<br />';
             }
         }
     }
     if (!empty($stringError)) {
         $this->errorCollection->add(array(new Error($stringError)));
         $this->sendJsonErrorResponse();
     }
     $objectElement = new CIBlockElement();
     $idElement = $objectElement->Add($elementData, false, true, true);
     if ($idElement) {
         $bizProcWorkflowId = array();
         foreach ($documentStates as $documentState) {
             if (strlen($documentState["ID"]) <= 0) {
                 $errorsTmp = array();
                 $bizProcWorkflowId[$documentState['TEMPLATE_ID']] = CBPDocument::StartWorkflow($documentState['TEMPLATE_ID'], array('lists', 'BizprocDocument', $idElement), array_merge($bizprocParametersValues[$documentState['TEMPLATE_ID']], array('TargetUser' => 'user_' . intval($this->getUser()->getID()))), $errorsTmp);
             }
         }
         if (!empty($errorsTmp)) {
             $documentStates = null;
             CBPDocument::AddDocumentToHistory(array('lists', 'BizprocDocument', $idElement), $elementData['NAME'], $this->getUser()->getID());
         }
     } else {
         $this->errorCollection->add(array(new Error($objectElement->LAST_ERROR)));
         $this->sendJsonErrorResponse();
     }
     $this->sendJsonSuccessResponse(array());
 }
Beispiel #27
0
<?php

require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
CModule::IncludeModule("iblock");
$id = intval($_GET["event_id"]);
$like = intval($_GET["like"]);
$UID = $USER->GetID();
$ib_id = 6;
$resObj = CIBlockElement::GetByID($id);
$item = $resObj->GetNextElement(true, false);
/*$propItems = $item->GetProperty("USERS");*/
if ($like) {
    $el = new CIBlockElement();
    $PROP = array();
    $PROP['LIKE'] = array("n0" => array("VALUE" => $id, "DESCRIPTION" => ""));
    $PROP['USER'] = array("n0" => array("VALUE" => $UID, "DESCRIPTION" => ""));
    $arLoadProductArray = array("IBLOCK_SECTION" => false, "IBLOCK_ID" => $ib_id, "PROPERTY_VALUES" => $PROP, "NAME" => "like");
    $PRODUCT_ID = id_element;
    $res = $el->Add($arLoadProductArray);
} else {
    $res = CIBlockElement::GetList(array(), array("IBLOCK_ID" => 6, "PROPERTY_LIKE" => $id, "PROPERTY_USER" => $USER->GetID()));
    $ob = $res->GetNextElement();
    //echo "<xmp>";print_r($ob);echo "</xmp>";
    if ($ob) {
        $obs = $ob->GetFields();
        $ELEMENT_ID = $obs["ID"];
        CIBlockElement::Delete($ELEMENT_ID);
    }
}
Beispiel #28
0
 public function addElement($iblockId, $fields = array(), $props = array())
 {
     $default = array("NAME" => "element", "IBLOCK_SECTION_ID" => false, "ACTIVE" => "Y", "PREVIEW_TEXT" => "", "DETAIL_TEXT" => "");
     $fields = array_merge($default, $fields);
     $fields["IBLOCK_ID"] = $iblockId;
     if (!empty($props)) {
         $fields['PROPERTY_VALUES'] = $props;
     }
     $ib = new \CIBlockElement();
     $id = $ib->Add($fields);
     if ($id) {
         return $id;
     }
     $this->throwException(__METHOD__, $ib->LAST_ERROR);
 }
Beispiel #29
0
                 $arProductGroups[$PRODUCT_ID] = array();
             }
             if (!in_array($LAST_GROUP_CODE_tmp, $arProductGroups[$PRODUCT_ID])) {
                 $arProductGroups[$PRODUCT_ID][] = $LAST_GROUP_CODE_tmp;
             }
             $arLoadProductArray["IBLOCK_SECTION"] = $arProductGroups[$PRODUCT_ID];
         }
         $res = $el->Update($PRODUCT_ID, $arLoadProductArray, $bWorkflow, true, 'Y' === $IMAGE_RESIZE);
     } else {
         if ($bThereIsGroups) {
             $arLoadProductArray["IBLOCK_SECTION"] = $LAST_GROUP_CODE > 0 ? $LAST_GROUP_CODE : false;
         }
         if ($arLoadProductArray["ACTIVE"] != "N") {
             $arLoadProductArray["ACTIVE"] = "Y";
         }
         $PRODUCT_ID = $el->Add($arLoadProductArray, $bWorkflow, true, 'Y' === $IMAGE_RESIZE);
         if ($bThereIsGroups) {
             if (!isset($arProductGroups[$PRODUCT_ID])) {
                 $arProductGroups[$PRODUCT_ID] = array();
             }
             $arProductGroups[$PRODUCT_ID][] = $LAST_GROUP_CODE > 0 ? $LAST_GROUP_CODE : false;
         }
         $res = $PRODUCT_ID > 0;
     }
     if (!$res) {
         $strErrorR .= GetMessage("CATI_LINE_NO") . " " . $line_num . ". " . GetMessage("CATI_ERROR_LOADING") . " " . $el->LAST_ERROR . "<br>";
     }
 }
 if ('' === $strErrorR) {
     $PROP = array();
     for ($i = 0; $i < $NUM_FIELDS; $i++) {
Beispiel #30
0
 public function CloneElement($ID, $arFields = array())
 {
     global $DB;
     $ID = intval($ID);
     $db_element = CIBlockElement::GetList(array(), array("ID" => $ID, "SHOW_HISTORY" => "Y"), false, false, array("ID", "MODIFIED_BY", "DATE_CREATE", "CREATED_BY", "IBLOCK_ID", "ACTIVE", "ACTIVE_FROM", "ACTIVE_TO", "SORT", "NAME", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "DETAIL_PICTURE", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "WF_STATUS_ID", "WF_PARENT_ELEMENT_ID", "WF_COMMENTS", "IN_SECTIONS", "CODE", "TAGS", "XML_ID", "TMP_ID"));
     if ($ar_element = $db_element->Fetch()) {
         $IBLOCK_ID = $ar_element["IBLOCK_ID"];
         if ($ar_element["WF_PARENT_ELEMENT_ID"] > 0) {
             throw new Exception(GetMessage("IBD_ELEMENT_NOT_FOUND"));
         } else {
             if ($ar_element["PREVIEW_PICTURE"]) {
                 $ar_element["PREVIEW_PICTURE"] = CFile::MakeFileArray($ar_element["PREVIEW_PICTURE"]);
             }
             if ($ar_element["DETAIL_PICTURE"]) {
                 $ar_element["DETAIL_PICTURE"] = CFile::MakeFileArray($ar_element["DETAIL_PICTURE"]);
             }
             $ar_element["IBLOCK_SECTION"] = array();
             if ($ar_element["IN_SECTIONS"] == "Y") {
                 $rsSections = CIBlockElement::GetElementGroups($ar_element["ID"], true, array('ID', 'IBLOCK_ELEMENT_ID'));
                 while ($arSection = $rsSections->Fetch()) {
                     $ar_element["IBLOCK_SECTION"][] = $arSection["ID"];
                 }
             }
             $ar_element["PROPERTY_VALUES"] = array();
             foreach ($arFields as $field_id => $value) {
                 if (array_key_exists($field_id, $ar_element)) {
                     $ar_element[$field_id] = $value;
                 }
             }
             $ar_element["WF_PARENT_ELEMENT_ID"] = $ID;
             $ar_element["IBLOCK_ID"] = $IBLOCK_ID;
             $arProps =& $ar_element["PROPERTY_VALUES"];
             //Add new proiperty values
             $rsProps = CIBlockElement::GetProperty($ar_element["IBLOCK_ID"], $ar_element["ID"], array("value_id" => "asc"));
             $i = 0;
             while ($arProp = $rsProps->Fetch()) {
                 if (array_key_exists($arProp["CODE"], $ar_element["PROPERTY_VALUES"])) {
                     continue;
                 }
                 $i++;
                 if (!array_key_exists($arProp["ID"], $arProps)) {
                     $arProps[$arProp["ID"]] = array();
                 }
                 if ($arProp["PROPERTY_VALUE_ID"]) {
                     if ($arProp["PROPERTY_TYPE"] == "F") {
                         $arProps[$arProp["ID"]]["n" . $i] = array("VALUE" => CFile::MakeFileArray($arProp["VALUE"]), "DESCRIPTION" => $arProp["DESCRIPTION"]);
                     } else {
                         $arProps[$arProp["ID"]]["n" . $i] = array("VALUE" => $arProp["VALUE"], "DESCRIPTION" => $arProp["DESCRIPTION"]);
                     }
                 }
             }
             if (CIBlock::GetArrayByID($IBLOCK_ID, "RIGHTS_MODE") === "E") {
                 $ibRights = new CIBlockElementRights(intval($IBLOCK_ID), $ID);
                 $arRights = $ibRights->GetRights();
                 $arNewRights = array();
                 $rightIndex = 0;
                 foreach ($arRights as $rightID => $right) {
                     if ($right['IS_INHERITED'] !== 'Y') {
                         $arNewRights['n' . $rightIndex++] = $right;
                     }
                 }
                 $ar_element['RIGHTS'] = $arNewRights;
             }
             $obElement = new CIBlockElement();
             $NEW_ID = $obElement->Add($ar_element);
             if (!$NEW_ID) {
                 throw new Exception($obElement->LAST_ERROR);
             } else {
                 return $NEW_ID;
             }
         }
     } else {
         throw new Exception(GetMessage("IBD_ELEMENT_NOT_FOUND"));
     }
 }