<?php require_once('includes/requirecompere.inc.php'); $mb_id=current_mb_id(); $timezone_bias=get_user_time_zone()*60; $DBConn->connect(true); $courses=db_load_course_by_owner($DBConn,$mb_id); $cs_ids=array_projection($courses,'cs_id'); $staff_counts=db_count_course_staff($DBConn,$cs_ids); $classroom_counts=db_count_course_classroom($DBConn,$cs_ids); $timeavails=db_count_timeavail_by_course($DBConn,$mb_id); $sc_map=rowset2map($staff_counts,'cs_id','count'); $cc_map=rowset2map($classroom_counts,'cs_id','count'); $cate_map=rowset2map($categories,'cs_id','bc_id'); $ta_map=rowset2map($timeavails,'cs_id','count'); foreach ($courses as &$course) { $course+=array_key_prepend(split_datetime($course['cs_since'],$timezone_bias),'since_'); $course+=array_key_prepend(split_datetime($course['cs_expire'],$timezone_bias),'expire_'); $course['UI-CLSR']=!$cc_map[$course['cs_id']]?array(0):array(); $course['UI-STAFF']=!$sc_map[$course['cs_id']]?array(0):array(); $course['UI-TIMEAVAIL']=$course['cs_initby']=='PARTICIPANT' && !$ta_map[$course['cs_id']]?array(0):array(); $course['UI-LIST']=$course['UI-CLSR'] || $course['UI-STAFF'] || $course['UI-TIMEAVAIL']?array(0):array(); if (datetime_datepart($course['cs_since'],$timezone_bias)==datetime_datepart($course['cs_expire'],$timezone_bias)) $course['DAY-SAME']=array(0); else $course['DAY-DIFF']=array(0); } $dataset['COURSE']=$courses; $dataset['NO-COURSE']=$courses?array():array(0); $dataset['count.addable']=get_compere_limit($DBConn,$mb_id,'course.count')-sizeof($courses); $dataset['ADD-COURSE']=$dataset['count.addable']>0?array(0):array(); ?>