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 . "
" . $sas_lang['email'] . " : " . $student_email; $msg = nl2br($msg); $msg = str_replace("%title%", $title, $msg); $msg = str_replace("%link%", $link, $msg); $msg .= ""; $mail = new PHPMailer(); $mail->From = $sas_config['email']; //site email address $mail->FromName = $sitename; $mail->Subject = $sas_lang['student_pages'] . ": " . $student_name . " " . $sas_lang['title'] . ": " . $title; $mail->Body = $msg; $mail->IsHTML(true); $mail->AddAddress($teacher_email); //add email address teacher. $mail->Send(); } //update the last change date in pages table if ($project == 1) //we have a project here { mysql_query("UPDATE $table_pages SET lastupdate='$d' WHERE module = 'sn_studentpages/viewproject.php' AND name = '$class_name'"); } else { mysql_query("UPDATE $table_pages SET lastupdate='$d' WHERE module = 'sn_studentpages/viewpage.php'"); mysql_query("UPDATE $table_pages SET lastupdate='$d' WHERE module = 'sn_studentpages/viewpage2.php' AND name = '" . $class_name . "'"); } } print ""; } $server_path = $sas_config['serverpath']; $user_path = $sas_config['user_path']; $media = $sas_config['media_dir']; $query = "SELECT dir_number FROM $table_studentpages WHERE studentid ='" . $edit_page . "'"; $result = mysql_query($query) or die_script($query, mysql_error()); //get the project id! $student_id = mysql_result($result, 0); $query = "SELECT id FROM $table_users WHERE id = '" . $student_id . "' AND type = '0'"; $result = mysql_query($query) or die_script($query, mysql_error()); //check if student has a project assigned! if (mysql_num_rows($result) > 0) { $project_id = mysql_result($result, 0); } else { $project_id = ""; } $query = "SELECT studentid, approved FROM $table_studentpages WHERE studentid='$edit_page' AND (dir_number='$_SESSION[userid]' OR dir_number = '" . $project_id . "')"; //approved field is used to hold the userid owning the pupil page. $result = mysql_query($query) or die_script($query, mysql_error()); //check if student is owner of this page! if (mysql_num_rows($result) > 0) { $userid_in_use = mysql_result($result, 0, 1); $ses_table = $dbprefix . "sessions"; $str_len = strlen($userid_in_use); $ses_value = "%userid|s:$str_len:\"" . $userid_in_use . "\";%"; $result1 = mysql_query("SELECT ses_id FROM $ses_table WHERE ses_value like '" . $ses_value . "'"); //check to see if userid holding the page still has a session if (mysql_num_rows($result1) == 0) { mysql_query("UPDATE $table_studentpages SET approved = '' WHERE studentid='" . $edit_page . "'"); $userid_in_use = ''; //no session , reset approved field. } if (($userid_in_use == '') OR ($userid_in_use == $_SESSION['userid'])) //nobody is holding the page { $query = "SELECT title, newcontent, invisible, sort, pcheck FROM $table_studentpages WHERE studentid='" . $edit_page . "'"; $result = mysql_query($query) or die_script($query, mysql_error()); // getting the title, newcontent $title = mysql_result($result, 0, 0); $content = mysql_result($result, 0, 1); $invisible = mysql_result($result, 0, 2); $order = mysql_result($result, 0, 3); $pcheck = mysql_result($result, 0, 4); unset ($query); unset ($result); if ($content == "") { $query = "SELECT content FROM $table_studentpages WHERE studentid='" . $edit_page . "'"; // getting the content $result = mysql_query($query) or die_script($query, mysql_error()); $content = mysql_result($result, 0); unset ($query); unset ($result); } mysql_query("UPDATE $table_studentpages SET approved = '$_SESSION[userid]' WHERE studentid='" . $edit_page . "'"); } else { $query = "SELECT name FROM $table_users WHERE id = '" . $userid_in_use . "'"; $result = mysql_query($query); $pupil_name = mysql_result($result, 0); $msg = str_replace("%user_name%", $pupil_name, $sas_lang['page_in_use']); print $msg; print "

<< " . $sas_lang['goback'] . "
"; exit; } } $template_path = $server_path . $user_path . "/" . $media . "/templates"; if (IsSet ($_GET['template'])) { $filename = $template_path . "/" . $_GET['template']; if (file_exists($filename)) { $handle = fopen($filename, "r"); $content = fread($handle, filesize($filename)); fclose($handle); } } print ""; $_SESSION['editpage'] = $edit_page; //used for image browser plugin to go to the right (project) directory include ("fckeditor.php"); print "
"; print " " . $sas_lang['title'] . ":   " . $sas_lang['order'] . ":  "; if (is_dir($template_path)) { print "  " . $sas_lang['template'] . ":  "; } if ($invisible == 1) { print "  " . $sas_lang['invisible']; } else { print "  " . $sas_lang['invisible']; } print "
"; $height = $sas_config['htmlarea_editor_rows'] * 18 + 75; $fck_lang = strtolower($sas_config[language]); $oFCKeditor = new FCKeditor('newcontent'); $oFCKeditor->BasePath = ''; $oFCKeditor->Config['DefaultLanguage'] = "$fck_lang"; $oFCKeditor->Width = '100%'; $oFCKeditor->Height = $height; $oFCKeditor->Value = $content; $oFCKeditor->Create(); print "
"; print ""; if ($_SESSION['usertype'] == "teacher") { print ""; if ($pcheck == "1") { print ""; print ""; print ""; print ""; print ""; } elseif ($pcheck == "0") { print ""; print ""; print ""; print ""; print ""; } else { print ""; print ""; print ""; print ""; print ""; } print ""; } print ""; print "
" . $sas_lang['page_on'] . "    " . $sas_lang['teacher_pages'] . "   " . $sas_lang['student_pages'] . "   " . $sas_lang['both'] . "   " . $sas_lang['student_pages'] . "   " . $sas_lang['both'] . "   " . $sas_lang['student_pages'] . "   " . $sas_lang['both'] . "
"; print "   
"; } ?>