alert (\"" . $sas_lang['student_page_save'] . "\"); window.close(); "; } elseif ((IsSet ($save_page)) and ($_SESSION[usertype] == "student")) { require ("../../core/class.phpmailer.php"); //use the phpmailer class if ($newcontent != "") { $query = "SELECT dir_number, pcheck, send_email, change_date FROM $table_studentpages WHERE studentid='" . $save_page . "'"; $result = mysql_query($query) or die_script($query, mysql_error()); //get check bit, email bit and change date $project_id = mysql_result($result, 0, 0); $check = mysql_result($result, 0, 1); $send_email = mysql_result($result, 0, 2); $change_date = mysql_result($result, 0, 3); unset ($query); unset ($result); $d = date("Y-m-d"); mysql_query("UPDATE $table_studentpages SET change_date='$d', sort='$order' WHERE studentid='" . $save_page . "'"); $query = "SELECT class, email FROM $table_users WHERE id='$_SESSION[userid]'"; //get the student class and email $result = mysql_query($query) or die_script($query, mysql_error()); $class = mysql_result($result, 0, 0); $student_email = mysql_result($result, 0, 1); $query = "SELECT class FROM $table_users WHERE id = '" . $project_id . "'"; //get the student project $result = mysql_query($query) or die_script($query, mysql_error()); $project = mysql_result($result, 0, 0); unset ($query); unset ($result); $query = "SELECT project, name FROM $table_classes WHERE id = '" . $project . "'"; //are we a project or pupil $result = mysql_query($query) or die_script($query, mysql_error()); $project = mysql_result($result, 0, 0); $class_name = mysql_result($result, 0, 1); //get the student class/project name unset ($query); unset ($result); $query = "SELECT email FROM $table_users WHERE (class LIKE '%,$class,%' OR class like '$class,%' OR class like '%,$class' OR class like '$class' OR project LIKE '%,$project,%' OR project like '$project,%' OR project like '%,$project' OR project like '$project') AND (type = 2 OR type = 22) AND email != ''"; //get the teachers email $result = mysql_query($query) or die_script($query, mysql_error()); if (mysql_num_rows($result) > 0) { while ($teacher_email_list = mysql_fetch_array($result)) { $teacher_email .= $teacher_email_list[0] . ","; } $teacher_email = substr($teacher_email, 0, -1); //strip last comma } unset ($query); unset ($result); if ($title != "") { mysql_query("UPDATE $table_studentpages SET title='$title', change_date='$d', approved = '' WHERE studentid='" . $save_page . "'"); } if ($check == "0") { mysql_query("UPDATE $table_studentpages SET content='$newcontent' WHERE studentid='" . $save_page . "'"); } else { if (($teacher_email != "") and ($change_date < $d)) { $msg = "
"; $msg .= nl2br($sas_lang['student_email_message1'] . "\n" . $student_name . "\n" . $sas_lang['email'] . " : " . $student_email); $msg = str_replace("%title%", $title, $msg); if ($project == 1) //we have a project here { $type = $sas_lang['student_project']; } else { $type = $sas_lang['student']; } $msg = str_replace("%type%", $type, $msg); $msg .= ""; $mail = new PHPMailer(); $mail->From = $sas_config['email']; //site email address $mail->FromName = $sitename; $mail->Subject = $sas_lang[student_page_check] . " " . $student_name; $mail->Body = $msg; $mail->IsHTML(true); $mail->AddAddress($teacher_email); //add email address teacher. $mail->Send(); } mysql_query("UPDATE $table_studentpages SET newcontent='$newcontent' WHERE studentid='$save_page'"); } if (($teacher_email != "") and ($send_email == "1") and ($change_date < $d)) { //get the page and section number for the pupilpages $result = mysql_query("SELECT id, section FROM $table_pages WHERE name='" . $class_name . "' AND module='sn_studentpages/viewpage2.php'"); if (mysql_num_rows($result) > 0) { $student_pages = mysql_result($result, 0, 0); $student_section = mysql_result($result, 0, 1); } else { $result = mysql_query("SELECT id, section FROM $table_pages WHERE module='sn_studentpages/viewpage.php'"); $student_pages = mysql_result($result, 0, 0); $student_section = mysql_result($result, 0, 1); } if (mysql_num_rows($result) > 0) { $link = "" . $sas_config['url'] . "index.php?section=$student_section&page=$student_pages&student=$save_page&name=$student_name"; } $msg = "" . $sas_lang['student_email_message2'] . "\n" . $student_name . "