public function getComponent() { $component = null; if (is_int($this->component)) { $component = ComponentDAL::findById($this->component); } else { if (is_a($this->component, "Component")) { $component = $this->component; } } return $component; }
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/ComponentDAL.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/UserDAL.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/UserHasModuleDAL.php'; $idUser = filter_input(INPUT_POST, 'idUser'); $idExam = filter_input(INPUT_POST, 'idExam'); $mark = floatval(filter_input(INPUT_POST, 'mark')); $component = ComponentDAL::findById($idExam); $component->setMark($mark); if (ComponentDAL::flush($component)) { $module = $component->getModule(); $user = UserDAL::findById($idUser); $hasFailed = $user->hasFailed($module); $mustResit = $user->mustResit($module); $finalMark = $user->getFinalMark($module); $userHasModule = UserHasModuleDAL::findByStudentAndModule($idUser, $module->getId()); $userHasModule->setHasFailed($hasFailed); $userHasModule->setMustPay($mustResit); $userHasModule->setFinalMark($finalMark); if ($hasFailed && $mustResit) { UserHasModuleDAL::flush($userHasModule); // Send mail -> Explain which component to resit and how to pay // (Always worst component to resit) } else { if ($hasFailed && !$mustResit) { UserHasModuleDAL::flush($userHasModule); // Send mail -> Tell he has failed the module and that there is no resit } else { if (!$hasFailed && $finalMark > 0) { UserHasModuleDAL::flush($userHasModule);
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/ComponentDAL.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/UserDAL.php'; $id = filter_input(INPUT_GET, 'id'); $component = ComponentDAL::findById($id); // Recipient $to = $component->getUser()->getMail(); // Subject $subject = 'New Mark'; // Message $message = ' <html> <head> <title>New Mark</title> </head> <body> ' . $component->getUser()->getFirstName() . ' ' . $component->getUser()->getLastName() . 'Here your results of the following exercise:\\n' . $component->getModule()->getTitle() . ' ' . $component->getModule()->getNumber() . ' ' . $component->getType()->getTypeName() . ' ' . $component->getDate() . '\\n Mark : ' . $component->getMark() . '/100.\\n --------------- It is an automated email. Please do not respond.</body></html>'; // HTML Email $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional Headers $headers = 'From: "Yann"<*****@*****.**>' . "\n"; $headers .= 'Reply-To: yannbutscher@gmail.com' . "\n"; // Sending mail($to, $subject, $message, $headers); /*error_reporting(E_ALL); if(mail($to, $subject, $message, $headers))