<?php require_once('includes/requirecompere.inc.php'); require_once('includes/requirepost.inc.php'); $action=TPOST('action'); $o_id=TPOST('o_id'); $o_name=TPOST('o_name'); $o_desc=TPOST('o_desc'); $o_num_min=TPOST('o_num_min'); $o_num_max=TPOST('o_num_max'); $o_price_base=TPOST('o_price_base'); $o_price_step=TPOST('o_price_step'); $o_thumbnail_url=TPOST('o_thumbnail_url'); $_co_desc_replacement=TPOST('_co_desc_replacement'); if ($_co_desc_replacement && !$o_desc) $o_desc=$_co_desc_replacement; $mb_id=current_mb_id(); $DBConn->connect(); $DBConn->begin(true); $errorareas=iif_array4(array( array(!$o_name,'ERROR-NAME',array(0)), array(strlen($o_desc)<10,'ERROR-DESC',array(0)), array(!is_decimal_in_range($o_price_base,0,2000000000),'ERROR-PRICE-BASE',array(0)), array(!is_decimal_in_range($o_price_step,0,2000000000),'ERROR-PRICE-STEP',array(0)), array(!is_integer_in_range($o_num_min,0,min(999,$o_num_max)),'ERROR-NUM-MIN',array(0)), array(!is_integer_in_range($o_num_max,0,999),'ERROR-NUM-MAX',array(0)), array($action=='addnew' && db_count_compere_option($DBConn,$mb_id)>=get_compere_limit($DBConn,$mb_id,'option.count'),'ERROR-COUNT-LIMIT',array(0)) )); if (count_true_entries($errorareas)>0) { $_SESSION['reserv.inputcache.domain']='course.option.'.$action; $_SESSION['reserv.inputcache.errorareas']=$errorareas; $_SESSION['reserv.inputcache.inputcache']=array( 'o_id'=>$o_id, 'o_name'=>$o_name, 'o_desc'=>$o_desc, 'o_price_base'=>$o_price_base, 'o_price_step'=>$o_price_step, 'o_num_min'=>$o_num_min, 'o_num_max'=>$o_num_max, 'o_thumbnail_url'=>$o_thumbnail_url, ); if ($action=='addnew') redirect("qx-cmd-option.addnew-cs_id-".$cs_id."-op-revise.html"); else if ($action=='modify') redirect("qx-cmd-option.modify-o_id-".$o_id."-op-revise.html"); return; } if ($action=="addnew") { $max_ordinal=db_load_option_ordinal_max($DBConn,$mb_id); $o_id=db_insert_option($DBConn,$mb_id,$max_ordinal+1,$o_price_base,$o_price_step,$o_num_min,$o_num_max,$o_thumbnail_url); db_set_option_desc($DBConn,$o_id,$o_name,$o_desc); redirect("qx-cmd-option.save.done-op-addnew-o_id-".$o_id.".html"); member_refresh_login($DBConn); } else if ($action=="modify") { db_update_option($DBConn,$mb_id,$o_id,$o_price_base,$o_price_step,$o_num_min,$o_num_max,$o_thumbnail_url); db_set_option_desc($DBConn,$o_id,$o_name,$o_desc); redirect("qx-cmd-option.save.done-op-modify-o_id-".$o_id.".html"); } purge_array_by_key_prefix($_SESSION,'reserv.inputcache.'); $DBConn->commit(); ?>