<?php require_once('includes/requirecompere.inc.php'); $cs_id=0+TGET('cs_id'); $expiredonly=TGET('expired'); $mb_id_owner=current_mb_id(); $timezone_bias_seconds=get_user_time_zone()*60; list($offset,$pagesize,$pageno)=decide_page_range(0+TGET('p'),0+TGET('ps')); $DBConn->connect(true); $course=array(); $course=db_load_course_by_id($DBConn,$cs_id); if ($mb_id_owner!=$course['mb_id_owner']) { redirect("./"); return; } $lectures=db_load_lectures_of_course($DBConn,$cs_id,!$expiredonly,$expiredonly,!$expiredonly,$pagesize+1,$offset); $dataset+=prepare_paging_dataset($pageno,$pagesize,$lectures); $l_count=db_count_lectures_of_compere($DBConn,$mb_id_owner); $lctr_ids=array_projection($lectures,'lctr_id'); $stafflist=db_load_staff_of_lectures($DBConn,$lctr_ids); $lecture_staff=array(); foreach ($stafflist as $s) { if (!isset($lecture_staff[$s['lctr_id']])) $lecture_staff[$s['lctr_id']]=array(); array_push($lecture_staff[$s['lctr_id']],$s); } $lctr_income=db_load_lecture_income($DBConn,$lctr_ids); $lctr2income=rowset2map($lctr_income,'lctr_id'); $dataset+=$course; $dataset['LECTURE']=$lectures; $dataset['NO-LECTURE']=$lectures?array():array(0); $dataset['local_currency_unit']=mapCurrencyLocalName(loadLocalCurrencyNameMap(),$course['cs_currency']); foreach ($dataset['LECTURE'] as &$lec) { if (!$lec['cs_name']) $lec['cs_name']=$course['cs_name']; $lec+=array_key_prepend(split_datetime($lec['lctr_since'],$timezone_bias_seconds),'since_'); $lec+=array_key_prepend(split_datetime($lec['lctr_expire'],$timezone_bias_seconds),'expire_'); if ($lec['since_year']!=$lec['expire_year'] || $lec['since_month']!=$lec['expire_month'] || $lec['since_day']!=$lec['expire_day']) $lec['DAY-DIFFERRED']=array(0); $lec['STAFF']=$lecture_staff[$lec['lctr_id']]; $lec['NOSTAFF']=$lec['STAFF']?array():array(0); $lec['STATUS-OPEN']=$lec['lctr_status']=='OPEN'?array(0):array(); $lec['STATUS-HIDDEN']=$lec['lctr_status']=='HIDDEN'?array(0):array(); $lec['STATUS-CLOSED']=$lec['lctr_status']=='CLOSED'?array(0):array(); $lec+=(array)$lctr2income[$lec['lctr_id']]; $lec['li_revenue_withtax']=$lec['li_revenue']+$lec['li_tax']; } $dataset['PRESENT']=!$expiredonly?array(0):array(); $dataset['EXPIRED']=$expiredonly?array(0):array(); $dataset['expired']=$expiredonly?'1':'0'; $dataset['count.addable']=get_compere_limit($DBConn,$mb_id_owner,'lecture.count')-$l_count; $dataset['ADD-LECTURE']=$dataset['count.addable']>0?array(0):array(); ?>