<?php function course_lecture_info_prepare_dataset($dbconn,$course,$lecture_data,$timezone_bias_seconds,$confirming,$takegrant=false) { $dataset=$course; $dataset+=$lecture_data; $dataset['LENGTH']=array(); for ($mn=$course['cs_minutes_min'];$mn<=$course['cs_minutes_max'];$mn+=$course['cs_minutes_step']) { array_push($dataset['LENGTH'],array('no_of_minutes'=>$mn)); if (!$course['cs_minutes_step']) break; } if ($lecture_data['lctr_since']) { $since=array_key_prepend(split_datetime($lecture_data['lctr_since'],$timezone_bias_seconds),'since_'); array_unset_keys($dataset,array_keys($since)); $dataset+=$since; } if ($lecture_data['lctr_since'] && $lecture_data['lctr_expire']) { $dataset['INPUT-CLASSROOM']=array(0); if (!$lecture_data['no_of_minutes']) { $expire_seconds=datetime_to_seconds($lecture_data['lctr_expire']); $since_seconds=datetime_to_seconds($lecture_data['lctr_since']); $lecture_data['no_of_minutes']=floor(($expire_seconds-$since_seconds)/60); } $dataset+=array_key_prepend(split_datetime($lecture_data['lctr_expire'],$timezone_bias_seconds),'expire_'); $classrooms=db_load_classroom_of_compere( $dbconn, $course['mb_id_owner'], $course['cs_id'] ); $clsr_ids=array_projection($classrooms,'clsr_id'); if ($takegrant && $lecture_data['lctr_id']) { $avail_clsr_ids=array($lecture_data['clsr_id']); } else { $avail_clsr_ids=db_filter_for_available_classroom( $dbconn, $clsr_ids, $lecture_data['lctr_since'], $lecture_data['lctr_expire'] ); } $dataset['CLASSROOM']=array(); $clsr_plc=array(); foreach ($classrooms as $avail_room) { if (!in_array($avail_room['clsr_id'],$avail_clsr_ids)) continue; if (!isset($clsr_plc[$avail_room['clsr_id']])) { array_push($dataset['CLASSROOM'], array( 'clsr_id'=>$avail_room['clsr_id'], 'clsr_name'=>$avail_room['clsr_name'], 'SELECTED'=>$lecture_data['clsr_id']==$avail_room['clsr_id']?array(0):array(), 'UNSELECTED'=>$lecture_data['clsr_id']==$avail_room['clsr_id']?array():array(0), 'PLACE'=>array() ) ); $clsr_plc[$avail_room['clsr_id']]=&$dataset['CLASSROOM'][sizeof($dataset['CLASSROOM'])-1]['PLACE']; } array_push($clsr_plc[$avail_room['clsr_id']], array( 'plc_id'=>$avail_room['plc_id'], 'plc_name'=>$avail_room['plc_name'] ) ); } $dataset['CLASSROOM-NONE']=$dataset['CLASSROOM']?array():array(0); } array_assoc_set_iif( $dataset['LENGTH'], 'no_of_minutes', $lecture_data['no_of_minutes'], 'SELECTED', array(0), 'UNSELECTED', array(0)); if (!$lecture_data['lctr_status']) $lecture_data['lctr_status']='OPEN'; $dataset['STATUS-OPEN']=$lecture_data['lctr_status']=='OPEN'?array(0):array(); $dataset['STATUS-HIDDEN']=$lecture_data['lctr_status']=='HIDDEN'?array(0):array(); $dataset['STATUS-CLOSED']=$lecture_data['lctr_status']=='CLOSED'?array(0):array(); if ($lecture_data['clsr_id']) $dataset+=db_load_classroom($dbconn,$lecture_data['clsr_id']); if ($confirming) $dataset['SAVABLE']=array(0); else $dataset['NEXT']=array(0); return $dataset; } ?>