<td><?php echo GetMessage("RATING_RULE_EDIT_FRM_TYPE_ID"); ?> </td> <td><?php echo SelectBoxFromArray("ENTITY_TYPE_ID", array('reference_id' => $arObjects, 'reference' => $arObjects), $str_ENTITY_TYPE_ID, "", "onChange=\"jsTypeChanged('rating_rule_form')\""); ?> </td> </tr> <? $tabControl->EndCustomField("ENTITY_TYPE_ID"); $tabControl->AddSection("CAT_HOW_ACTIVATE", GetMessage("RATING_RULE_EDIT_CAT_HOW_ACTIVATE")); $tabControl->BeginCustomField("CONDITION_NAME", GetMessage('RATING_RULE_EDIT_FRM_CONDITION_NAME'), true); $arRatingRuleConfigs = CRatingRule::GetRatingRuleConfigs($str_ENTITY_TYPE_ID); $arConditionName = array(); foreach ($arRatingRuleConfigs["CONDITION_CONFIG"] as $configId => $arConfig) { $arConditionName['reference'][] = $arConfig["NAME"]; $arConditionName['reference_id'][] = $arConfig["ID"]; } $arCurrentCondition = $arRatingRuleConfigs["CONDITION_CONFIG"][$str_CONDITION_NAME]; $conditionCount = count($arCurrentCondition['FIELDS']); ?> <tr> <td colspan="2"> <table cellpadding="2" cellspacing="0" border="0" width="100%" class="edit-table"> <tr valign="top" style="" class="adm-detail-required-field"> <td class="field-name" style="vertical-align:middle;" width="40%"> <?php
public static function Update($ID, $arFields) { global $DB; $ID = intval($ID); $err_mess = CRatingRule::err_mess() . "<br>Function: Update<br>Line: "; // check only general field if (!CRatingRule::__CheckFields($arFields)) { return false; } if (isset($arFields["ENTITY_TYPE_ID"]) && strlen($arFields['ENTITY_TYPE_ID']) > 0) { $arRatingRuleConfigs = CRatingRule::GetRatingRuleConfigs($arFields["ENTITY_TYPE_ID"]); $bHideAction = isset($arRatingRuleConfigs['CONDITION_CONFIG'][$arFields["CONDITION_NAME"]]['HIDE_ACTION']) && $arRatingRuleConfigs['CONDITION_CONFIG'][$arFields["CONDITION_NAME"]]['HIDE_ACTION'] == true ? true : false; $conditionModuleId = $arRatingRuleConfigs['CONDITION_CONFIG'][$arFields["CONDITION_NAME"]]['MODULE']; $arFields_u = array("ACTIVE" => $arFields["ACTIVE"] == 'Y' ? 'Y' : 'N', "NAME" => $arFields["NAME"], "ENTITY_TYPE_ID" => $arFields["ENTITY_TYPE_ID"], "CONDITION_NAME" => $arFields["CONDITION_NAME"], "CONDITION_MODULE" => strlen($conditionModuleId) > 0 ? $conditionModuleId : 'main', "CONDITION_CLASS" => $arRatingRuleConfigs['CONDITION_CONFIG'][$arFields["CONDITION_NAME"]]['CLASS'], "CONDITION_METHOD" => $arRatingRuleConfigs['CONDITION_CONFIG'][$arFields["CONDITION_NAME"]]['METHOD'], "ACTION_NAME" => $bHideAction ? 'empty' : $arFields["ACTION_NAME"], "ACTIVATE_CLASS" => $bHideAction ? 'empty' : $arRatingRuleConfigs['ACTION_CONFIG'][$arFields["ACTION_NAME"]]['CLASS'], "ACTIVATE_METHOD" => $bHideAction ? 'empty' : $arRatingRuleConfigs['ACTION_CONFIG'][$arFields["ACTION_NAME"]]['METHOD'], "DEACTIVATE_CLASS" => $bHideAction ? 'empty' : $arRatingRuleConfigs['ACTION_CONFIG'][$arFields["ACTION_NAME"]]['CLASS'], "DEACTIVATE_METHOD" => $bHideAction ? 'empty' : $arRatingRuleConfigs['ACTION_CONFIG'][$arFields["ACTION_NAME"]]['METHOD'], "~LAST_MODIFIED" => $DB->GetNowFunction()); } else { $arFields_u = array("ACTIVE" => $arFields['ACTIVE'] == 'Y' ? 'Y' : 'N', "NAME" => $arFields["NAME"], "~LAST_MODIFIED" => $DB->GetNowFunction()); unset($arFields["CONDITION_CONFIG"]); unset($arFields["ACTION_CONFIG"]); } $strUpdate = $DB->PrepareUpdate("b_rating_rule", $arFields_u); if ($strUpdate != "") { $strSql = "UPDATE b_rating_rule SET " . $strUpdate . " WHERE ID=" . $ID; if (!$DB->Query($strSql, false, $err_mess . __LINE__)) { return false; } } if (isset($arFields["CONDITION_CONFIG"])) { // queries modules and give them to inspect the field settings $db_events = GetModuleEvents("main", "OnAfterUpdateRatingRule"); while ($arEvent = $db_events->Fetch()) { $arFields = ExecuteModuleEventEx($arEvent, array($ID, $arFields)); } $arFields_u = array("CONDITION_CONFIG" => "'" . $DB->ForSQL(serialize($arFields["CONDITION_CONFIG"])) . "'", "ACTION_CONFIG" => $bHideAction ? "'a:0:{}'" : "'" . $DB->ForSQL(serialize($arFields["ACTION_CONFIG"])) . "'"); $DB->Update("b_rating_rule", $arFields_u, "WHERE ID = " . $ID); } CAgent::RemoveAgent("CRatingRule::Apply({$ID});", "main"); CAgent::AddAgent("CRatingRule::Apply({$ID});", "main", "N", $arRatingRuleConfigs['CONDITION_CONFIG'][$arFields["CONDITION_NAME"]]['REFRESH_TIME'], "", "Y", ""); return true; }