Beispiel #1
0
// default value
$str_NAME 			= isset($_REQUEST["NAME"]) ? htmlspecialcharsbx($_REQUEST["NAME"]) : GetMessage("RATING_RULE_DEF_NAME");
$str_ENTITY_TYPE_ID = isset($_REQUEST["ENTITY_TYPE_ID"]) ? htmlspecialcharsbx($_REQUEST["ENTITY_TYPE_ID"]) : 'USER';
$str_ACTIVE 		= isset($_REQUEST["ACTIVE"]) && $_REQUEST["ACTIVE"] == 'Y' ? 'Y' : 'N';
$str_CONDITION_NAME = isset($_REQUEST["CONDITION_NAME"]) ? htmlspecialcharsbx($_REQUEST["CONDITION_NAME"]) : 'RATING';
$str_ACTION_NAME	= isset($_REQUEST["ACTION_NAME"]) ? htmlspecialcharsbx($_REQUEST["ACTION_NAME"]) : 'ADD_TO_GROUP';
$bTypeChange 		= isset($_POST["action"]) && $_POST["action"] == 'type_changed' ? true : false;

//when creating a new rule, default check on
if ($ID == 0 && empty($_POST))
	$str_ACTIVE = 'Y';

if($ID>0 && !$bTypeChange)
{
	$ratingRule = CRatingRule::GetByID($ID);
	if(!($arRatingRule = $ratingRule->ExtractFields("str_")))
		$ID=0;
	$str_CONDITION_CONFIG = unserialize(htmlspecialcharsback($str_CONDITION_CONFIG));
	$str_ACTION_CONFIG = unserialize(htmlspecialcharsback($str_ACTION_CONFIG));
}

$sDocTitle = ($ID>0? GetMessage("MAIN_RATING_RULE_EDIT_RECORD", array("#ID#"=>$ID)) : GetMessage("MAIN_RATING_RULE_NEW_RECORD"));
$APPLICATION->SetTitle($sDocTitle);

require($_SERVER["DOCUMENT_ROOT"].FX_ROOT."/modules/main/include/prolog_admin_after.php");

$aMenu = array(
	array(
		"TEXT"=>GetMessage("RATING_RULE_LIST"),
		"TITLE"=>GetMessage("RATING_RULE_LIST_TITLE"),
Beispiel #2
0
 public static function Apply($ID)
 {
     global $DB;
     $ID = intval($ID);
     $err_mess = CRatingRule::err_mess() . "<br>Function: Apply<br>Line: ";
     $ratingRule = CRatingRule::GetByID($ID);
     $arConfigs = $ratingRule->Fetch();
     if ($arConfigs['ACTIVE'] == 'Y') {
         $arConfigs['CONDITION_CONFIG'] = unserialize(htmlspecialcharsback($arConfigs['CONDITION_CONFIG']));
         $arConfigs['ACTION_CONFIG'] = unserialize(htmlspecialcharsback($arConfigs['ACTION_CONFIG']));
         $arConfigs['CONDITION_MODULE'] = isset($arConfigs['CONDITION_MODULE']) && strlen($arConfigs['CONDITION_MODULE']) > 0 ? $arConfigs['CONDITION_MODULE'] : 'main';
         if (CModule::IncludeModule(strtolower($arConfigs['CONDITION_MODULE']))) {
             if (method_exists($arConfigs['CONDITION_CLASS'], $arConfigs['CONDITION_METHOD'])) {
                 call_user_func(array($arConfigs['CONDITION_CLASS'], $arConfigs['CONDITION_METHOD']), $arConfigs);
             }
             $DB->Query("DELETE FROM b_rating_rule_vetting WHERE RULE_ID = {$ID} AND APPLIED = 'Y'", false, $err_mess . __LINE__);
         }
         if (method_exists($arConfigs['ACTIVATE_CLASS'], $arConfigs['ACTIVATE_METHOD'])) {
             call_user_func(array($arConfigs['ACTIVATE_CLASS'], $arConfigs['ACTIVATE_METHOD']), $arConfigs);
         }
         $DB->Query("UPDATE b_rating_rule SET LAST_APPLIED = " . $DB->GetNowFunction() . " WHERE ID = {$ID}", false, $err_mess . __LINE__);
     }
     return "CRatingRule::Apply({$ID});";
 }