Remove addition to the news forum when new session is added

Remove addition to the news forum when new session is added

by Julian Whitehead -
Number of replies: 0
First of all - I love this block...
I really don't want it to add to the News Forum each time I add a new session - the students know when the sessions are.
The relevent bit seems to be in updateSessionAction.php

//insert into forum discussion to show this one in Latest news in course home page
  //get max of firstpost
  
  $maxsql = get_record_sql("select count(*) as cnt from {$CFG->prefix}forum_discussions");
  
  $maxpost = $maxsql->cnt;
  
  //get forum id
  
  require_once($CFG->dirroot.'/mod/forum/lib.php');   // We'll need this
   
  if (!$forum = forum_get_course_forum($course->id, 'news')) {
   error("Error in getting forum");
  }
  
  $finstmt = "insert into {$CFG->prefix}forum_discussions(course,forum,name,firstpost,userid,groupid,assessed,timemodified,usermodified) ".
    "values(".$course->id.",".$forum->id.",'".get_string('editclasssession','block_attendance')."',".($maxpost+1).",".$USER->id.",-1,1,".time().",".$USER->id.")";
  //echo $finstmt;
  $result = $db->Execute($finstmt);
  if(!$result)
   error("Error in new discussion");
   
  //get the last insert id
  $lsql = get_record_sql("select max(id) as id from {$CFG->prefix}forum_discussions");
  $lid = $lsql->id;
  
  $message = get_string('message3','block_attendance').$sessdate.get_string('message4','block_attendance').$newdate.get_string('message5','block_attendance').$USER->firstname . ' ' . $USER->lastname;
  $message = addslashes($message);
  $poststmt = "insert into {$CFG->prefix}forum_posts(discussion, parent, userid, created, modified, mailed,subject,message,format,".
    "attachment,totalscore) values (".$lid.",0,".$USER->id.",".time().",".time().",0,'".get_string('newclasssession','block_attendance')."','".$message.
    "',0,' ',0)";
  $result = $db->Execute($poststmt);
  if(!$result)
   error("Error in posting"); 
  
  //now take the last insert id from {$CFG->prefix}forum_post table, update firstpost field value in {$CFG->prefix}forum_discussions with this one
  
  $lpsql = get_record_sql("select max(id) as id from {$CFG->prefix}forum_posts");
  $lpid = $lpsql->id;
  $result = $db->Execute("update {$CFG->prefix}forum_discussions set firstpost = " . $lpid ." where id = " . $lid);
  if(!$result)
   error("Error in posting data");
 
 }
What do I have to do to the code to stop the entry happening?
Ta
Average of ratings: -