Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/cesanet/
Upload File :
Current File : /var/www/cesa.co.za/cesanet/modcontact.php

<?php
include("inc_functions.php");

//ini_set('display_errors', 1);
//error_reporting(E_ALL);

if (!isset($_SESSION["StudentID"]) || empty($_SESSION["StudentID"]) || $_SESSION["StudentID"] == null)
    header("Location: /cesanet/login.php");

include_once($_SERVER['DOCUMENT_ROOT'] . "/cesanet/includes/html_begin.php");
?>
<h1> Send a Message</h1>
<?php
include_once($_SERVER['DOCUMENT_ROOT'] . "/cesanet/includes/message_menu.php");

if (!CurrentStudent()) {
    echo "<p><b>Only available to current students.</b></p>";
} else {
    include_once($_SERVER['DOCUMENT_ROOT'] . '/php/includes/Utils.php');

    $sError = "";
    $sMessageSent = false;
    $cceMessageSendResult = array();

    if (isset($_POST["go"]) && ($_POST["go"] == 1)) {
        $arrSendTo = isset($_POST["sendto"]) ? $_POST["sendto"] : array();
        if (!is_array($arrSendTo) || count($arrSendTo) == 0) {
            $sError = '<div class="alert alert-danger" role="alert">Please select at least one recipient.</div>';
        } elseif (empty($_POST["message"])) {
            $sError = '<div class="alert alert-danger" role="alert">Please enter a message to be sent.</div>';
        } else {
            $sFrom = "";
            $sql = "SELECT FirstName, KnownAs, Surname FROM CCEStudents WHERE CCEStudentID=" . intval($_SESSION["StudentID"]);
            $rec = mysql_query($sql);
            if ($row = mysql_fetch_assoc($rec)) {
                $sFrom = $row["KnownAs"] . " " . $row["Surname"];
            }
            mysql_free_result($rec);
            $SentByStudentID = intval($_SESSION["StudentID"]);
            include($_SERVER['DOCUMENT_ROOT'] . "/cceadmin/inc_sendmessage.php");
            if (!empty($cceMessageSendResult['ok'])) {
                $sMessageSent = true;
            } else {
                $sError = renderCceMessageSendFeedback($cceMessageSendResult, true);
            }
        }
    }

    if ($sMessageSent) {
        echo renderCceMessageSendFeedback($cceMessageSendResult, true);
        ?>
        <p>
            <a href="modcontact.php" class="btn btn-primary">Compose another message</a>
            <a href="sentmessages.php" class="btn btn-default">Sent items</a>
        </p>
        <?php
    } elseif (!empty($sError) || !isset($_POST["go"])) {
        echo $sError;
?>
        <form id="form1" name="form1" method="post" action="modcontact.php" enctype="multipart/form-data">
            <input type="hidden" name="go" value="1" />
            <table border="0" cellspacing="0" cellpadding="5" class="table">
                <tr>
                    <td>Module:</td>
                    <td>
                        <select name="modid" id="modid" class="select2-field">
                            <option value="" <?php if (!isset($_POST["modid"])) echo " selected"; ?>>General</option>
                            <?php
                            $sql = "SELECT * FROM CCEModules, CCEStudentCourses
                                WHERE CCEModules.CCECourseID=CCEStudentCourses.CCECourseID
                                    AND CCEStudentCourses.CCEStudentID=" . $_SESSION["StudentID"] . "
                                ORDER BY CCEModules.ModuleNum";
                            $recMod = mysql_query($sql);
                            while ($rowMod = mysql_fetch_assoc($recMod)) {
                            ?>
                                <option value="<?php echo $rowMod["CCEModuleID"]; ?>" <?php
                                                                                        if (isset($_POST["modid"]) && ($_POST["modid"] == $rowMod["CCEModuleID"]))
                                                                                            echo " selected";
                                                                                        ?>><?php echo $rowMod["ModuleName"]; ?></option>
                            <?php
                            }
                            ?>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td valign="top" colspan="2">Send To:<br>
                        <div style="font-size:11px">
                            <?php
                            $iSelectFacilitatorID = 0;
                            $iSelectStudentID = 0;
                            $iSelectExpertID = 0;
                            $sReplyHtml = "";
                            $sForwardHtml = "";
                            $sReplySubject = "";
                            $arrReplyAll = array();
                            if (isset($_GET["replyto"])) {
                                $sql = "SELECT * FROM CCEMessages WHERE CCEMessageID='" . $_GET["replyto"] . "'";
                                $rec = mysql_query($sql);
                                if ($row = mysql_fetch_assoc($rec)) {
                                    $iSelectFacilitatorID = $row["SentByFacilitatorID"];
                                    $iSelectStudentID = $row["SentByStudentID"];
                                    $iSelectExpertID = $row["SentByExpertID"];
                                    if (isset($_GET["all"]) && ($_GET["all"] == 1))
                                        $arrReplyAll = explode(",", $row["SentTo"]);
                                    $sReplyHtml = quoteCceMessageHtmlForEditor(
                                        $row["MessageText"],
                                        $row["SentDateTime"],
                                        $row["SentByName"]
                                    );
                                    $sReplySubject = "RE: " . $row["MessageSubject"];
                                }
                                mysql_free_result($rec);
                            }
                            if (isset($_GET["fwd"])) {
                                $sql = "SELECT * FROM CCEMessages WHERE CCEMessageID='" . $_GET["fwd"] . "'";
                                $rec = mysql_query($sql);
                                if ($row = mysql_fetch_assoc($rec)) {
                                    $sForwardHtml = quoteCceMessageHtmlForEditor(
                                        $row["MessageText"],
                                        $row["SentDateTime"],
                                        $row["SentByName"]
                                    );
                                    $sReplySubject = "FWD: " . $row["MessageSubject"];
                                }
                                mysql_free_result($rec);
                            }
                            if (!isset($_POST["sendto"]) || !is_array($_POST["sendto"]) || count($_POST["sendto"]) == 0) {
                                $_POST["sendto"] = [];
                            }
                            ?>
                            <table border="0" cellpadding="4" cellspacing="0" width="100%" class="table">
                                <tr>
                                    <td valign="top">
                                        <!-- <input type="checkbox" name="sendto[]" value="CESA"
                                            <?php
                                            if (
                                                in_array("CESA Programme Coordinator", $arrReplyAll) ||
                                                (isset($_POST["sendto"]) && in_array("CESA", $_POST["sendto"]))
                                            )
                                                echo " checked"; ?>>BCE Programme Coordinators<br> -->
                                        <input type="checkbox" name="sendto[]" value="blessings"
                                            <?php if (in_array("blessings", $_POST["sendto"])) echo " checked"; ?>>Blessings Banda<br>
                                        <input type="checkbox" name="sendto[]" value="brenda"
                                            <?php if (in_array("brenda", $_POST["sendto"])) echo " checked"; ?>>Brenda Lacey-Smith<br>
                                        
                                        <!-- <input type="checkbox" name="sendto[]" value="melissa"
                                            <?php if (in_array("melissa", $_POST["sendto"])) echo " checked"; ?>>Melissa Jardine<br> -->
                                        <br />
                                        <!-- <input type="checkbox" name="sendto[]" value="FAll"<?php if (isset($_POST["sendto"]) && in_array("FAll", $_POST["sendto"])) echo " checked"; ?><?php if (in_array("All Convenors", $arrReplyAll)) echo " checked"; ?>>All Convenors<br> -->
                                        <?php
                                        $sql = "SELECT * "
                                            . "FROM CCEFacilitators "
                                            . "WHERE Archived=0 AND ProgrammeCoordinator = 0 "
                                            . "ORDER BY FacilitatorName";
                                        $rec = mysql_query($sql);
                                        while ($row = mysql_fetch_assoc($rec)) {
                                        ?>
                                            <input type="checkbox" name="sendto[]" value="F<?php echo $row["FacilitatorID"]; ?>" <?php if (isset($_REQUEST["sendto"]) && in_array("F" . $row["FacilitatorID"], $_REQUEST["sendto"])) echo " checked"; ?><?php if (($iSelectFacilitatorID == $row["FacilitatorID"]) || in_array($row["FacilitatorName"], $arrReplyAll)) echo " checked"; ?>>Convenor: <?php echo $row["FacilitatorName"]; ?><br>
                                        <?php
                                        } //while Convenors
                                        /*
                                          ?>
                                          <input type="checkbox" name="sendto[]" value="EAll"<?php if (isset($_POST["sendto"]) && in_array("EAll", $_POST["sendto"])) echo " checked"; ?><?php if (in_array("All Facilitators", $arrReplyAll)) echo " checked"; ?>>All Facilitators<br>
                                          <?php
                                          $sql = "SELECT * FROM CCESubjectExperts WHERE Archived=0 ORDER BY ExpertName";
                                          $rec = mysql_query($sql);
                                          while ($row = mysql_fetch_assoc($rec)) {
                                          ?>
                                          <input type="checkbox" name="sendto[]" value="E<?php echo $row["ExpertID"]; ?>"<?php if (isset($_REQUEST["sendto"]) && in_array("E" . $row["ExpertID"], $_REQUEST["sendto"])) echo " checked"; ?><?php if (($iSelectExpertID == $row["ExpertID"]) || in_array($row["ExpertName"], $arrReplyAll)) echo " checked"; ?>>Facilitator: <?php echo $row["ExpertName"]; ?><br>
                                          <?php
                                          }
                                         *
                                         */
                                        ?>
                                    </td>
                                    <td valign="top">
                                        <input type="checkbox" name="sendto[]" value="SAll" <?php if (isset($_POST["sendto"]) && in_array("SAll", $_POST["sendto"])) echo " checked"; ?><?php if (in_array("All Students", $arrReplyAll)) echo " checked"; ?>>All Students<br>
                                        <?php
                                        $sql = "SELECT * FROM CCEStudents WHERE Archived=0 AND Cancelled=0 AND CCEStudentID<>54 ORDER BY KnownAs, Surname LIMIT 0,15";
                                        $rec = mysql_query($sql);
                                        while ($row = mysql_fetch_assoc($rec)) {
                                        ?>
                                            <input type="checkbox" name="sendto[]" value="S<?php echo $row["CCEStudentID"]; ?>" <?php if (isset($_REQUEST["sendto"]) && in_array("S" . $row["CCEStudentID"], $_REQUEST["sendto"])) echo " checked"; ?><?php if (($iSelectStudentID == $row["CCEStudentID"]) || in_array($row["KnownAs"] . " " . $row["Surname"], $arrReplyAll)) echo " checked"; ?>>Student: <?php echo $row["KnownAs"] . " " . $row["Surname"]; ?><br>
                                        <?php
                                        }
                                        ?>
                                        <p><i>Note: Convenors / facilitators will be <br>
                                                CCed on inter-student communications.</i></p>
                                    </td>
                                    <td valign="top">
                                        <br>
                                        <?php
                                        $sql = "SELECT * FROM CCEStudents WHERE Archived=0 AND Cancelled=0 AND CCEStudentID<>54 ORDER BY KnownAs, Surname LIMIT 15,100";
                                        $rec = mysql_query($sql);
                                        while ($row = mysql_fetch_assoc($rec)) {
                                        ?>
                                            <input type="checkbox" name="sendto[]" value="S<?php echo $row["CCEStudentID"]; ?>" <?php if (isset($_REQUEST["sendto"]) && in_array("S" . $row["CCEStudentID"], $_REQUEST["sendto"])) echo " checked"; ?><?php if (($iSelectStudentID == $row["CCEStudentID"]) || in_array($row["KnownAs"] . " " . $row["Surname"], $arrReplyAll)) echo " checked"; ?>>Student: <?php echo $row["KnownAs"] . " " . $row["Surname"]; ?><br>
                                        <?php
                                        }
                                        ?>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>Subject:</td>
                    <td>
                        <input name="subject" type="text" id="subject" class="form-control" value="<?php
                                                                                                    if (isset($_POST["subject"])) {
                                                                                                        echo $_POST["subject"];
                                                                                                    } else {
                                                                                                        echo $sReplySubject;
                                                                                                    }
                                                                                                    ?>" required />
                    </td>
                </tr>
                <tr>
                    <td>Message:</td>
                    <td style="height: 400px;">
                        <textarea name="message" id="message" rows="20" style="height: 400px;"><?php
                                                                                                if (isset($_POST["message"])) {
                                                                                                    echo $_POST["message"];
                                                                                                } elseif (!empty($sReplyHtml) || !empty($sForwardHtml)) {
                                                                                                    echo $sReplyHtml . $sForwardHtml;
                                                                                                }
                                                                                                ?></textarea>
                    </td>
                </tr>
                <tr>
                    <td valign="top">
                        Attachments:
                    </td>
                    <td>
                        <?php
                        $cceMessageAttachmentUseBootstrap = true;
                        include $_SERVER['DOCUMENT_ROOT'] . '/php/includes/cceMessageAttachmentUpload.inc.php';
                        ?>
                    </td>
                </tr>
            </table>

            <div class="row p-3">
                <div class="d-grid gap-2 d-md-block text-center">
                    <input type="submit" name="button" id="button" class="btn btn-primary" value="Send Now" />
                </div>
            </div>
        </form>
        <script>
            var allowSubmit = true;

            $(document).ready(function() {

                $('#form1').on('submit', function() {
                    if (allowSubmit) {
                        allowSubmit = false;
                        $('#button').attr('value', 'Sending now ...');
                        $('#button').attr('disabled', 'disabled');
                        return true;
                    } else {
                        return false;
                    }
                });
            });

            // This sample still does not showcase all CKEditor&nbsp;5 features (!)
            // Visit https://ckeditor.com/docs/ckeditor5/latest/features/index.html to browse all the features.
            $(document).ready(function() {
                var messageElement = document.getElementById("message");
                if (messageElement) {
                    CKEDITOR.ClassicEditor.create(messageElement, {
                // https://ckeditor.com/docs/ckeditor5/latest/features/toolbar/toolbar.html#extended-toolbar-configuration-format
                toolbar: {
                    items: [
                        'exportPDF', 'exportWord', '|',
                        'findAndReplace', 'selectAll', '|',
                        'heading', '|',
                        'bold', 'italic', 'strikethrough', 'underline', 'code', 'subscript', 'superscript', 'removeFormat', '|',
                        'bulletedList', 'numberedList', 'todoList', '|',
                        'outdent', 'indent', '|',
                        'undo', 'redo',
                        '-',
                        'fontSize', 'fontFamily', 'fontColor', 'fontBackgroundColor', 'highlight', '|',
                        'alignment', '|',
                        'link', 'uploadImage', 'blockQuote', 'insertTable', 'mediaEmbed', 'codeBlock', 'htmlEmbed', '|',
                        'specialCharacters', 'horizontalLine', 'pageBreak', '|',
                        'textPartLanguage', '|',
                        'sourceEditing'
                    ],
                    shouldNotGroupWhenFull: true
                },
                // Changing the language of the interface requires loading the language file using the <script> tag.
                // language: 'es',
                list: {
                    properties: {
                        styles: false,
                        startIndex: true,
                        reversed: true
                    }
                },
                // https://ckeditor.com/docs/ckeditor5/latest/features/headings.html#configuration
                heading: {
                    options: [{
                            model: 'paragraph',
                            title: 'Paragraph',
                            class: 'ck-heading_paragraph'
                        },
                        {
                            model: 'heading1',
                            view: 'h1',
                            title: 'Heading 1',
                            class: 'ck-heading_heading1'
                        },
                        {
                            model: 'heading2',
                            view: 'h2',
                            title: 'Heading 2',
                            class: 'ck-heading_heading2'
                        },
                        {
                            model: 'heading3',
                            view: 'h3',
                            title: 'Heading 3',
                            class: 'ck-heading_heading3'
                        },
                        {
                            model: 'heading4',
                            view: 'h4',
                            title: 'Heading 4',
                            class: 'ck-heading_heading4'
                        },
                        {
                            model: 'heading5',
                            view: 'h5',
                            title: 'Heading 5',
                            class: 'ck-heading_heading5'
                        },
                        {
                            model: 'heading6',
                            view: 'h6',
                            title: 'Heading 6',
                            class: 'ck-heading_heading6'
                        }
                    ]
                },
                // https://ckeditor.com/docs/ckeditor5/latest/features/editor-placeholder.html#using-the-editor-configuration
                placeholder: 'Welcome to CKEditor 5!',
                // https://ckeditor.com/docs/ckeditor5/latest/features/font.html#configuring-the-font-family-feature
                fontFamily: {
                    options: [
                        'default',
                        'Arial, Helvetica, sans-serif',
                        'Courier New, Courier, monospace',
                        'Georgia, serif',
                        'Lucida Sans Unicode, Lucida Grande, sans-serif',
                        'Tahoma, Geneva, sans-serif',
                        'Times New Roman, Times, serif',
                        'Trebuchet MS, Helvetica, sans-serif',
                        'Verdana, Geneva, sans-serif'
                    ],
                    supportAllValues: true
                },
                // https://ckeditor.com/docs/ckeditor5/latest/features/font.html#configuring-the-font-size-feature
                fontSize: {
                    options: [10, 12, 14, 'default', 18, 20, 22],
                    supportAllValues: true
                },
                // Be careful with the setting below. It instructs CKEditor to accept ALL HTML markup.
                // https://ckeditor.com/docs/ckeditor5/latest/features/general-html-support.html#enabling-all-html-features
                htmlSupport: {
                    allow: [{
                        name: /.*/,
                        attributes: true,
                        classes: true,
                        styles: true
                    }],
                    disallow: [
                        { name: 'style' },
                        { name: 'script' },
                        { name: 'head' }
                    ]
                },
                // Be careful with enabling previews
                // https://ckeditor.com/docs/ckeditor5/latest/features/html-embed.html#content-previews
                htmlEmbed: {
                    showPreviews: true
                },
                // https://ckeditor.com/docs/ckeditor5/latest/features/link.html#custom-link-attributes-decorators
                link: {
                    decorators: {
                        addTargetToExternalLinks: true,
                        defaultProtocol: 'https://',
                        toggleDownloadable: {
                            mode: 'manual',
                            label: 'Downloadable',
                            attributes: {
                                download: 'file'
                            }
                        }
                    }
                },
                // https://ckeditor.com/docs/ckeditor5/latest/features/mentions.html#configuration
                mention: {
                    feeds: [{
                        marker: '@',
                        feed: [
                            '@apple', '@bears', '@brownie', '@cake', '@cake', '@candy', '@canes', '@chocolate', '@cookie', '@cotton', '@cream',
                            '@cupcake', '@danish', '@donut', '@dragée', '@fruitcake', '@gingerbread', '@gummi', '@ice', '@jelly-o',
                            '@liquorice', '@macaroon', '@marzipan', '@oat', '@pie', '@plum', '@pudding', '@sesame', '@snaps', '@soufflé',
                            '@sugar', '@sweet', '@topping', '@wafer'
                        ],
                        minimumCharacters: 1
                    }]
                },
                // The "superbuild" contains more premium features that require additional configuration, disable them below.
                // Do not turn them on unless you read the documentation and know how to configure them and setup the editor.
                removePlugins: [
                    // These two are commercial, but you can try them out without registering to a trial.
                    // 'ExportPdf',
                    // 'ExportWord',
                    'AIAssistant',
                    'CKBox',
                    'CKFinder',
                    'EasyImage',
                    // This sample uses the Base64UploadAdapter to handle image uploads as it requires no configuration.
                    // https://ckeditor.com/docs/ckeditor5/latest/features/images/image-upload/base64-upload-adapter.html
                    // Storing images as Base64 is usually a very bad idea.
                    // Replace it on production website with other solutions:
                    // https://ckeditor.com/docs/ckeditor5/latest/features/images/image-upload/image-upload.html
                    // 'Base64UploadAdapter',
                    'RealTimeCollaborativeComments',
                    'RealTimeCollaborativeTrackChanges',
                    'RealTimeCollaborativeRevisionHistory',
                    'PresenceList',
                    'Comments',
                    'TrackChanges',
                    'TrackChangesData',
                    'RevisionHistory',
                    'Pagination',
                    'WProofreader',
                    // Careful, with the Mathtype plugin CKEditor will not load when loading this sample
                    // from a local file system (file://) - load this site via HTTP server if you enable MathType.
                    'MathType',
                    // The following features are part of the Productivity Pack and require additional license.
                    'SlashCommand',
                    'Template',
                    'DocumentOutline',
                    'FormatPainter',
                    'TableOfContents',
                    'PasteFromOfficeEnhanced',
                'CaseChange'
            ]
                    }).catch(error => {
                        console.error('CKEditor initialization failed:', error);
                    });
                } else {
                    console.error('CKEditor: Element with id "message" not found');
                }
            });
        </script>
<?php
    }
}

include_once($_SERVER['DOCUMENT_ROOT'] . "/cesanet/includes/html_end.php");