예제 #1
0
	public function Update($ID, $arFields)
	{
		global $DB;

		$ID = intval($ID);
		if ($ID <= 0)
			return false;

		foreach (GetModuleEvents("catalog", "OnBeforeCouponUpdate", true) as $arEvent)
		{
			if (false === ExecuteModuleEventEx($arEvent, array($ID, &$arFields)))
				return false;
		}

		if (!CCatalogDiscountCoupon::CheckFields("UPDATE", $arFields, $ID))
			return false;

		$strUpdate = $DB->PrepareUpdate("b_catalog_discount_coupon", $arFields);
		if (!empty($strUpdate))
		{
			$strSql = "UPDATE b_catalog_discount_coupon SET ".$strUpdate." WHERE ID = ".$ID;
			$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		}

		foreach (GetModuleEvents("catalog", "OnCouponUpdate", true) as $arEvent)
		{
			ExecuteModuleEventEx($arEvent, array($ID, $arFields));
		}

		return $ID;
	}
예제 #2
0
 public function Update($ID, $arFields)
 {
     global $DB;
     global $USER;
     $ID = intval($ID);
     if ($ID <= 0) {
         return false;
     }
     foreach (GetModuleEvents("catalog", "OnBeforeCouponUpdate", true) as $arEvent) {
         if (false === ExecuteModuleEventEx($arEvent, array($ID, &$arFields))) {
             return false;
         }
     }
     $arFields1 = array();
     if (array_key_exists('CREATED_BY', $arFields)) {
         unset($arFields['CREATED_BY']);
     }
     if (array_key_exists('DATE_CREATE', $arFields)) {
         unset($arFields['DATE_CREATE']);
     }
     if (array_key_exists('TIMESTAMP_X', $arFields)) {
         unset($arFields['TIMESTAMP_X']);
     }
     if (!CCatalogDiscountCoupon::CheckFields("UPDATE", $arFields, $ID)) {
         return false;
     }
     if (isset($USER) && $USER instanceof CUser && 'CUser' == get_class($USER)) {
         if (!array_key_exists('MODIFIED_BY', $arFields) || intval($arFields["MODIFIED_BY"]) <= 0) {
             $arFields["MODIFIED_BY"] = intval($USER->GetID());
         }
     }
     $arFields1['TIMESTAMP_X'] = $DB->GetNowFunction();
     $strUpdate = $DB->PrepareUpdate("b_catalog_discount_coupon", $arFields);
     if (!empty($strUpdate)) {
         foreach ($arFields1 as $key => $value) {
             if (strlen($strUpdate) > 0) {
                 $strUpdate .= ", ";
             }
             $strUpdate .= $key . "=" . $value . " ";
         }
         $strSql = "UPDATE b_catalog_discount_coupon SET " . $strUpdate . " WHERE ID = " . $ID;
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     foreach (GetModuleEvents("catalog", "OnCouponUpdate", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID, $arFields));
     }
     return $ID;
 }
예제 #3
0
 public function Update($ID, $arFields)
 {
     static $eventOnBeforeUpdateExists = null;
     static $eventOnUpdateExists = null;
     global $DB;
     $ID = (int) $ID;
     if ($ID <= 0) {
         return false;
     }
     if ($eventOnBeforeUpdateExists === true || $eventOnBeforeUpdateExists === null) {
         foreach (GetModuleEvents('catalog', 'OnBeforeCouponUpdate', true) as $arEvent) {
             $eventOnBeforeUpdateExists = true;
             if (ExecuteModuleEventEx($arEvent, array($ID, &$arFields)) === false) {
                 return false;
             }
         }
         if ($eventOnBeforeUpdateExists === null) {
             $eventOnBeforeUpdateExists = false;
         }
     }
     if (!CCatalogDiscountCoupon::CheckFields("UPDATE", $arFields, $ID)) {
         return false;
     }
     $strUpdate = $DB->PrepareUpdate("b_catalog_discount_coupon", $arFields);
     if (!empty($strUpdate)) {
         $strSql = "UPDATE b_catalog_discount_coupon SET " . $strUpdate . " WHERE ID = " . $ID;
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     if ($eventOnUpdateExists === true || $eventOnUpdateExists === null) {
         foreach (GetModuleEvents('catalog', 'OnCouponUpdate', true) as $arEvent) {
             $eventOnUpdateExists = true;
             ExecuteModuleEventEx($arEvent, array($ID, $arFields));
         }
         if ($eventOnUpdateExists === null) {
             $eventOnUpdateExists = false;
         }
     }
     return $ID;
 }