<?php require_once('includes/requirecompere.inc.php'); require_once('includes/requirepost.inc.php'); $action=TPOST('action'); $mb_id_owner=current_mb_id(); $cg_id=TPOST('cg_id'); if ($action=='modify' && !$cg_id) { redirect("qx-cmd-coursegroup.manage.html"); return; } $DBConn->connect(); $DBConn->begin(true); if ($action=='addnew') { $cg_name=TPOST('cg_name'); $cg_brief=TPOST('cg_brief'); $cg_count=db_count_course_group($DBConn,current_mb_id()); $errorareas=iif_array4(array( array(!$cg_name,'ERROR-INVALID-NAME',array(0)), array(!$cg_brief,'ERROR-INVALID-BRIEF',array(0)), array($cg_count>=get_compere_limit($DBConn,$mb_id_owner,'coursegroup.count'),'ERROR-COUNT-LIMIT',array(0)) )); if ($errorareas) { $_SESSION['reserv.inputcache.domain']='coursegroup.addnew'; $_SESSION['reserv.inputcache.errorareas']=$errorareas; $_SESSION['reserv.inputcache.data']=array('cg_name'=>$cg_name,'cg_brief'=>$cg_brief); $_SESSION['reserv.inputcache.okas']=false; redirect("qx-cmd-coursegroup.addnew-op-revise.html"); } else { $cg_id=db_insert_course_group($DBConn,$mb_id_owner,$cg_name,$cg_brief); purge_array_by_key_prefix($_SESSION,'reserv.inputcache.'); redirect("qx-cmd-coursegroup.manage-op-addnew--ok.html"); } } else if ($action=='modify') { $cg_name=TPOST('cg_name'); $cg_brief=TPOST('cg_brief'); $errorareas=iif_array4(array( array(!$cg_name,'ERROR-INVALID-NAME',array(0)), array(!$cg_brief,'ERROR-INVALID-BRIEF',array(0)) )); if ($errorareas) { $_SESSION['reserv.inputcache.domain']='coursegroup.modify'; $_SESSION['reserv.inputcache.errorareas']=$errorareas; $_SESSION['reserv.inputcache.data']=array('cg_id'=>$cg_id,'cg_name'=>$cg_name,'cg_brief'=>$cg_brief); $_SESSION['reserv.inputcache.okas']=false; redirect("qx-cmd-coursegroup.modify-op-revise.html"); } else { db_update_course_group($DBConn,$cg_id,$mb_id_owner,$cg_name,$cg_brief); purge_array_by_key_prefix($_SESSION,'reserv.inputcache.'); redirect("qx-cmd-coursegroup.modify-cg_id-".$cg_id."-op-modified.html"); } } $DBConn->commit(); ?>