コード例 #1
0
ファイル: point-of-contact.php プロジェクト: hughnguy/php
//============================================================================================
$profile = new Profile($dbo);
$poc = new PointOfContact($dbo);
$emp_profile = new \Ventus\Profile\MyProfile($dbo);
if (isset($_GET['student_num']) && ctype_digit($_GET['student_num'])) {
    $studentProfile = $profile->getProfile($_GET['student_num']);
}
//============================================================================================
// Load the content
//============================================================================================
if (!isset($_GET['page'])) {
    $render = true;
    if (!empty($studentProfile)) {
        $thisPage = 'poc';
        $emp_signature = nl2br($emp_profile->getEmpSignature($SESSION->user_name));
        $point_of_contact = $poc->listPointOfContact($_GET['student_num']);
        foreach ($point_of_contact as &$p) {
            $p["files"] = $poc->fetchAllPointOfContactFiles($p["point_of_contact_id"]);
        }
        unset($p);
        $l10n->addResource(__DIR__ . '/l10n/point-of-contact.json');
        $viewFile = 'views/point-of-contact.php';
    }
} elseif ($_GET['page'] === "create") {
    $allowedFileTypes = unserialize(FILE_TYPES_ALLOWED_FOR_NOTES_DISABILITIES);
    $last_inserted = $poc->createPointOfContact($_POST);
    $loggers['audit']->info("Counselling point of contact {$last_inserted} created");
    for ($i = 0, $numFiles = sizeof($_FILES["point_of_contact_attachment"]["name"]) - 1; $i < $numFiles; $i++) {
        if (in_array($_FILES["point_of_contact_attachment"]["type"][$i], $allowedFileTypes, true)) {
            $fp = fopen($_FILES["point_of_contact_attachment"]["tmp_name"][$i], "rb");
            $content = fread($fp, $_FILES["point_of_contact_attachment"]["size"][$i]);