<?php require_once('includes/requirecompere.inc.php'); $cs_id=TGET('cs_id'); $o_id=TGET('o_id'); if (!$cs_id && !$o_id || $cs_id && $o_id) return; $mb_id=current_mb_id(); $dataset['COURSE-BASED']=$cs_id?array(0):array(); $dataset['OPTION-BASED']=$o_id?array(0):array(); $DBConn->connect(true); if ($cs_id) { $courses=db_load_course($DBConn,$cs_id,false); if ($courses[0]['mb_id_owner']!=$mb_id) $courses=array(); } else $courses=db_load_course_by_owner($DBConn,$mb_id,false); $options=db_load_options($DBConn,null,$mb_id,$o_id); $cs_o_ids=db_load_course_option($DBConn,array_projection($courses,'cs_id'),array_projection($courses,'o_id')); $cs_id_selected=array_projection($cs_o_ids,'cs_id'); $o_id_selected=array_projection($cs_o_ids,'o_id'); $dataset['COURSE']=$courses; if (sizeof($courses)==1) $dataset['COURSE'][0]['SELECTED']=array(0); foreach ($dataset['COURSE'] as &$cs) $cs['SELECTED']=in_array($cs['cs_id'],$cs_id_selected)?array(0):array(); $dataset['OPTION']=$options; foreach ($dataset['OPTION'] as &$o) $o['SELECTED']=in_array($o['o_id'],$o_id_selected)?array(0):array(); ?>