Whoops! There was an error.
core \ exception \ moodle_exception
No guests here! core\exception\moodle_exception thrown with message "No guests here!" Stacktrace: #4 core\exception\moodle_exception in /var/www/html/lib/filelib.php:377 #3 file_get_unused_draft_itemid in /var/www/html/lib/filelib.php:424 #2 file_prepare_draft_area in /var/www/html/local/ipemcpd/classes/form/evidence_form.php:210 #1 local_ipemcpd\form\evidence_form:definition_after_data in /var/www/html/lib/formslib.php:1045 #0 moodleform:display in /var/www/html/local/ipemcpd/addevidence.php:260
Stack frames (5)
4
core\exception\moodle_exception
/lib/filelib.php377
3
file_get_unused_draft_itemid
/lib/filelib.php424
2
file_prepare_draft_area
/local/ipemcpd/classes/form/evidence_form.php210
1
local_ipemcpd\form\evidence_form definition_after_data
/lib/formslib.php1045
0
moodleform display
/local/ipemcpd/addevidence.php260
/var/www/html/lib/filelib.php
    }
 
    return $data;
}
 
/**
 * Generate a draft itemid
 *
 * @category files
 * @global moodle_database $DB
 * @global stdClass $USER
 * @return int a random but available draft itemid that can be used to create a new draft
 * file area.
 */
function file_get_unused_draft_itemid() {
    global $DB, $USER;
 
    if (isguestuser() or !isloggedin()) {
        // guests and not-logged-in users can not be allowed to upload anything!!!!!!
        throw new \moodle_exception('noguest');
    }
 
    $contextid = context_user::instance($USER->id)->id;
 
    $fs = get_file_storage();
    $draftitemid = rand(1, 999999999);
    while ($files = $fs->get_area_files($contextid, 'user', 'draft', $draftitemid)) {
        $draftitemid = rand(1, 999999999);
    }
 
    return $draftitemid;
}
 
/**
 * Initialise a draft file area from a real one by copying the files. A draft
 * area will be created if one does not already exist. Normally you should
 * get $draftitemid by calling file_get_submitted_draft_itemid('elementname');
 *
 * @category files
 * @global stdClass $CFG
/var/www/html/lib/filelib.php
 * @param string $text some html content that needs to have embedded links rewritten to point to the draft area.
 * @return string|null returns string if $text was passed in, the rewritten $text is returned. Otherwise NULL.
 */
function file_prepare_draft_area(&$draftitemid, $contextid, $component, $filearea, $itemid, ?array $options=null, $text=null) {
    global $CFG, $USER;
 
    $options = (array)$options;
    if (!isset($options['subdirs'])) {
        $options['subdirs'] = false;
    }
    if (!isset($options['forcehttps'])) {
        $options['forcehttps'] = false;
    }
 
    $usercontext = context_user::instance($USER->id);
    $fs = get_file_storage();
 
    if (empty($draftitemid)) {
        // create a new area and copy existing files into
        $draftitemid = file_get_unused_draft_itemid();
        $file_record = array('contextid'=>$usercontext->id, 'component'=>'user', 'filearea'=>'draft', 'itemid'=>$draftitemid);
        if (!is_null($itemid) and $files = $fs->get_area_files($contextid, $component, $filearea, $itemid)) {
            foreach ($files as $file) {
                if ($file->is_directory() and $file->get_filepath() === '/') {
                    // we need a way to mark the age of each draft area,
                    // by not copying the root dir we force it to be created automatically with current timestamp
                    continue;
                }
                if (!$options['subdirs'] and ($file->is_directory() or $file->get_filepath() !== '/')) {
                    continue;
                }
                $draftfile = $fs->create_file_from_storedfile($file_record, $file);
                // XXX: This is a hack for file manager (MDL-28666)
                // File manager needs to know the original file information before copying
                // to draft area, so we append these information in mdl_files.source field
                // {@link file_storage::search_references()}
                // {@link file_storage::search_references_count()}
                $sourcefield = $file->get_source();
                $newsourcefield = new stdClass;
                $newsourcefield->source = $sourcefield;
/var/www/html/local/ipemcpd/classes/form/evidence_form.php
 
        $this->set_data($cpddetails);
    }
 
    /**
     * Prepares the form before data are set
     *
     * Additional wysiwyg and filemanager editor initialization
     */
    public function definition_after_data() {
        global $USER;
        $mform = $this->_form;
        $id = $this->_customdata['id'];
        $usercontext = \context_user::instance($USER->id);
 
        // Prepare draft area for attachments.
        if (!$id) {
            // For new evidence, prepare empty draft area.
            $draftitemid = file_get_submitted_draft_itemid('evidenceid');
            file_prepare_draft_area($draftitemid, $usercontext->id, 'local_ipemcpd', 'evidenceid', null);
            $mform->setDefault('evidenceid', $draftitemid);
 
            // Prepare draft area for cover image.
            $coverimagedraftid = file_get_submitted_draft_itemid('coverimage');
            file_prepare_draft_area($coverimagedraftid, $usercontext->id, 'local_ipemcpd', 'coverimage', null);
            $mform->setDefault('coverimage', $coverimagedraftid);
        }
    }
 
    /**
     * Define the validation
     */
    public function validation($data, $files) {
        global $DB;
        $errors = [];
        if ($data['type'] == 'manual') {
            $formdate = $data['date'];
            if (empty(($formdate))) {
                $errors['date'] = get_string('required');
            }
/var/www/html/lib/formslib.php
            }
            $file = reset($files);
 
            return $file->get_content();
 
        } else if (isset($_FILES[$elname])) {
            return file_get_contents($_FILES[$elname]['tmp_name']);
        }
 
        return false;
    }
 
    /**
     * Print html form.
     */
    function display() {
        //finalize the form definition if not yet done
        if (!$this->_definition_finalized) {
            $this->_definition_finalized = true;
            $this->definition_after_data();
        }
 
        $this->_form->display();
    }
 
    /**
     * Renders the html form (same as display, but returns the result).
     *
     * Note that you can only output this rendered result once per page, as
     * it contains IDs which must be unique.
     *
     * @return string HTML code for the form
     */
    public function render() {
        ob_start();
        $this->display();
        $out = ob_get_contents();
        ob_end_clean();
        return $out;
    }
/var/www/html/local/ipemcpd/addevidence.php
@media (max-width: 768px) {
    .cpd-form-card {
        padding: 20px;
    }
 
    .cpd-form-header h2 {
        font-size: 24px;
    }
}
</style>';
 
echo '<div class="cpd-form-container">';
echo '<div class="cpd-form-card">';
echo '<div class="cpd-form-header">';
echo '<h2><i class="fa fa-edit"></i>' .
    ($id ? get_string('editcpd', 'local_ipemcpd') : get_string('addcpd', 'local_ipemcpd')) . '</h2>';
echo '<p>' . get_string('addevidencedescription', 'local_ipemcpd') . '</p>';
echo '</div>';
 
$cpdform->display();
 
echo '</div>'; // End cpd-form-card.
echo '</div>'; // End cpd-form-container.
 
echo $OUTPUT->footer();
 

Environment & details:

empty
empty
empty
empty
Key Value
USER stdClass Object ( [id] => 1 [auth] => manual [confirmed] => 1 [policyagreed] => 0 [deleted] => 0 [suspended] => 0 [mnethostid] => 1 [username] => guest [idnumber] => [firstname] => Guest user [lastname] => [email] => root@localhost [emailstop] => 0 [phone1] => [phone2] => [institution] => [department] => [address] => [city] => [country] => [lang] => en [calendartype] => gregorian [theme] => [timezone] => 99 [firstaccess] => 0 [lastaccess] => 0 [lastlogin] => 0 [currentlogin] => 0 [lastip] => [secret] => [picture] => 0 [descriptionformat] => 1 [mailformat] => 1 [maildigest] => 0 [maildisplay] => 2 [autosubscribe] => 1 [trackforums] => 0 [timecreated] => 0 [timemodified] => 1731422767 [trustbitmask] => 0 [imagealt] => [lastnamephonetic] => [firstnamephonetic] => [middlename] => [alternatename] => [moodlenetprofile] => [lastcourseaccess] => Array ( ) [currentcourseaccess] => Array ( ) [profile] => Array ( ) [sesskey] => pSH1A556xj [preference] => Array ( ) [autologinguest] => 1 [access] => Array ( [ra] => Array ( [/1] => Array ( [6] => 6 ) ) [time] => 1778827950 [rsw] => Array ( ) ) [enrol] => Array ( [enrolled] => Array ( ) [tempguest] => Array ( ) ) )
SESSION stdClass Object ( [isnewsessioncookie] => 1 [lang] => en [cachestore_session] => Array ( [default_session-core/navigation_cache] => Array ( [__lastaccess__u1_4oobmk475gkkl4pdbululn9las] => Array ( [0] => 1778827950 [1] => 1778827950 ) ) [default_session-core/calendar_categories] => Array ( [__lastaccess__u1_4oobmk475gkkl4pdbululn9las] => Array ( [0] => 1778827950 [1] => 1778827950 ) [u1_4oobmk475gkkl4pdbululn9las_lastinvalidation-54d720d11ece57b555859017bb76dfb4] => Array ( [0] => 1778827950.5191-6a06c2ae7eb990.24166737 [1] => 1778827950 ) [u1_4oobmk475gkkl4pdbululn9las_site-54d720d11ece57b555859017bb76dfb4] => Array ( [0] => Array ( ) [1] => 1778827950 ) ) [default_session-core/coursecat] => Array ( [__lastaccess__u1_4oobmk475gkkl4pdbululn9las] => Array ( [0] => 1778827950 [1] => 1778827950 ) [u1_4oobmk475gkkl4pdbululn9las_fd62dd52135191ed900a38df44e7b347c6219dbc] => Array ( [0] => 1778827950.5191-6a06c2ae7eb990.24166737 [1] => 1778827950 ) [u1_4oobmk475gkkl4pdbululn9las_8f4f29333501a57b81fcd293acb1153dbfd4c22d] => Array ( [0] => Array ( ) [1] => 1778827950 ) [u1_4oobmk475gkkl4pdbululn9las_4bbd71334e8f7d0af868c7243d676be7b5ef9a71] => Array ( [0] => Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 10 [9] => 12 [10] => 13 [11] => 14 [12] => 15 [13] => 24 [14] => 25 [15] => 26 [16] => 27 [17] => 28 [18] => 29 [19] => 30 [20] => 31 [21] => 32 ) [1] => 1778827950 ) ) ) [calendarshoweventtype] => 15 )
Key Value
HTTPS on
SSL_TLS_SNI lewsdevbox.adaptivle.co.uk
HTTP_ACCEPT */*
HTTP_USER_AGENT Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
HTTP_ACCEPT_ENCODING gzip, br, zstd, deflate
HTTP_HOST lewsdevbox.adaptivle.co.uk
PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
SERVER_SIGNATURE <address>Apache/2.4.52 (Ubuntu) Server at lewsdevbox.adaptivle.co.uk Port 443</address>
SERVER_SOFTWARE Apache/2.4.52 (Ubuntu)
SERVER_NAME lewsdevbox.adaptivle.co.uk
SERVER_ADDR 139.59.168.8
SERVER_PORT 443
REMOTE_ADDR 216.73.217.0
DOCUMENT_ROOT /var/www/html
REQUEST_SCHEME https
CONTEXT_PREFIX
CONTEXT_DOCUMENT_ROOT /var/www/html
SERVER_ADMIN webmaster@localhost
SCRIPT_FILENAME /var/www/html/local/ipemcpd/addevidence.php
REMOTE_PORT 1590
GATEWAY_INTERFACE CGI/1.1
SERVER_PROTOCOL HTTP/1.1
REQUEST_METHOD GET
QUERY_STRING
REQUEST_URI /local/ipemcpd/addevidence.php
SCRIPT_NAME /local/ipemcpd/addevidence.php
PHP_SELF /local/ipemcpd/addevidence.php
REQUEST_TIME_FLOAT 1778827949.506
REQUEST_TIME 1778827949
empty
0. Whoops\Handler\PrettyPageHandler
1. Whoops\Handler\CallbackHandler