Esempio n. 1
0
     }
 } else {
     $arUpdateValues["IBLOCK_ID"] = $arParams["IBLOCK_ID"];
     // set activity start date for new element to current date. Change it, if ya want ;-)
     if (strlen($arUpdateValues["DATE_ACTIVE_FROM"]) <= 0) {
         $arUpdateValues["DATE_ACTIVE_FROM"] = ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL");
     }
     if ($arParams['SECTION_CODE']) {
         $arUpdateValues['IBLOCK_SECTION_ID'] = getSectionId($arParams['SECTION_CODE']);
     }
     $sAction = "ADD";
     if (!($arParams["ID"] = $oElement->Add($arUpdateValues, $bWorkflowIncluded, true, $arParams["RESIZE_IMAGES"]))) {
         $arResult["ERRORS"][] = $oElement->LAST_ERROR;
     } else {
         foreach ($arUpdateValues['PROPERTY_VALUES'] as $key => $val) {
             $temp = findCode($key, $val);
             if ($temp['VALUE']) {
                 $arProps[$temp['CODE']] = $temp['VALUE'];
             } else {
                 $arProps[$temp['CODE']] = $val;
             }
             unset($temp);
         }
         $arFields = array("NAME" => $arUpdateValues['NAME'], "PREVIEW_TEXT" => $arUpdateValues['PREVIEW_TEXT']);
     }
     CEvent::Send($arParams['POST_TEMPLATE'], SITE_ID, array_merge($arFields, $arProps));
     if (!empty($_REQUEST["iblock_apply"]) && strlen($SEF_URL) > 0) {
         if (strpos($SEF_URL, "?") === false) {
             $SEF_URL .= "?edit=Y";
         } elseif (strpos($SEF_URL, "edit=") === false) {
             $SEF_URL .= "&edit=Y";
 /* customer keywords research */
 foreach ($customer as $key => $value) {
     $subject = str_replace('{' . $key . '}', $value, $subject);
     $content = str_replace('{' . $key . '}', $value, $content);
 }
 $tags_search = array('{shop_name}', '{shop_url}', '{shop_logo}');
 $tags_replace = array($shop_name, $shop_url, $shop_logo);
 $content = str_replace($tags_search, $tags_replace, $content);
 $content = utf8Outtags($content);
 $temp = str_replace('{content}', $content, $seltemplate);
 /* vouchers */
 if ($sel == 5 || $sel == 6) {
     $code = '';
     $alphanum = '0123456789AZERTYUIOPMLKJHGFDSQWXCVBN';
     $code_length = Tools::strlen($code);
     while ($code_length < 8 || (int) findCode($code)) {
         $code = '';
         for ($i = 0; $i < 8; $i++) {
             $code .= Tools::substr($alphanum, mt_rand(1, Tools::strlen($alphanum)) - 1, 1);
         }
     }
     $name = array();
     $name[5] = 'Birthday voucher !';
     $name[6] = 'Extra voucher !';
     if (version_compare(_PS_VERSION_, '1.5', '>=')) {
         $voucher = new CartRule();
         foreach (Language::getLanguages() as $lang) {
             $voucher->name[$lang['id_lang']] = $name[$sel];
         }
         $voucher->code = $code;
         if ($trigger[$sel]['discountType'] == 'amount') {