<?php require_once('includes/requirelogin.inc.php'); require_once('includes/requirepost.inc.php'); $cs_id=TPOST('cs_id'); $lctr_id=TPOST('lctr_id'); $mb_id_to=TPOST('mb_id_to'); $bb_id_head=TPOST('bb_id_head'); $bb_id_replyto=TPOST('bb_id_replyto'); $type=TPOST('type'); $fh_text=TPOST('fh_text'); $scope=TPOST('scope'); $action_save=TPOST('save'); $mb_id_current=current_mb_id(); $DBConn->connect(); $reader_scopes=array(); switch ($scope) { case "specific": array_push($reader_scopes,array('mb_id_reader'=>$mb_id_to,'lctr_id'=>$lctr_id)); break; case "staff": $mb_id_reader=array(); if ($lctr_id) { $lecture=db_load_lecture_by_id($DBConn,$lctr_id); $course=db_load_course_by_id($DBConn,$lecture['cs_id']); $mb_id_reader=array_merge($mb_id_reader,db_load_lecture_staff_ids($DBConn,$lctr_id)); array_push($mb_id_reader,$course['mb_id_owner']); } if ($mb_id_to) array_push($mb_id_reader,$mb_id_to); foreach ($mb_id_reader as $mb_id) array_push($reader_scopes,array('mb_id_reader'=>$mb_id,'lctr_id'=>$lctr_id)); break; case "csowner": if ($lctr_id) { $lecture=db_load_lecture_by_id($DBConn,$lctr_id); if ($lecture) { $course=db_load_course_by_id($DBConn,$lecture['cs_id']); array_push($reader_scopes,array('mb_id_reader'=>$course['mb_id_owner'],'lctr_id'=>$lctr_id,'cs_id'=>$cs_id)); } } if ($mb_id_to) array_push($reader_scopes,array('mb_id_reader'=>$mb_id_to,'lctr_id'=>$lctr_id,'cs_id'=>$cs_id)); break; case "lecture": array_push($reader_scopes,array('lctr_id'=>$lctr_id)); break; case "all": if ($cs_id) array_push($reader_scopes,array('cs_id'=>$cs_id)); else if ($lctr_id) { $lecture=db_load_lecture_by_id($DBConn,$lctr_id); if ($lecture) array_push($reader_scopes,array('cs_id'=>$lecture['cs_id'])); } break; } if ($action_save && $reader_scopes && $fh_text) { $file_id=db_insert_file($DBConn,$fh_text); $bb_id=db_insert_billboard($DBConn,$mb_id_current,$file_id,$bb_id_head,$bb_id_replyto); foreach ($reader_scopes as $reader_scope) db_add_billboard_reader_and($DBConn,$bb_id,$reader_scope); } redirect("./?".http_build_query( array( 'cmd'=>'comment', 'cs_id'=>$cs_id?$cs_id:null, 'lctr_id'=>$lctr_id?$lctr_id:null, 'mb_id_to'=>$mb_id_to?$mb_id_to:null, 'bb_id_head'=>$bb_id_head?$bb_id_head:null, 'bb_id_replyto'=>$bb_id_replyto?$bb_id_replyto:null, 'type'=>$type?$type:null ) )); ?>