<commit_before><?php // $Id$

/////////////////////////////////////////////////////////////////////////////
//                                                                         //
// NOTICE OF COPYRIGHT                                                     //
//                                                                         //
// Moodle - Calendar extension                                             //
//                                                                         //
// Copyright (C) 2003-2004  Greek School Network            www.sch.gr     //
//                                                                         //
// Designed by:                                                            //
//     <NAME> (<EMAIL>)                         //
//     <NAME> (<EMAIL>)                                     //
//                                                                         //
// Programming and development:                                            //
//     <NAME> (<EMAIL>)                                     //
//                                                                         //
// For bugs, suggestions, etc contact:                                     //
//     <NAME> (<EMAIL>)                                     //
//                                                                         //
// The current module was developed at the University of Macedonia         //
// (www.uom.gr) under the funding of the Greek School Network (www.sch.gr) //
// The aim of this project is to provide additional and improved           //
// functionality to the Asynchronous Distance Education service that the   //
// Greek School Network deploys.                                           //
//                                                                         //
// This program is free software; you can redistribute it and/or modify    //
// it under the terms of the GNU General Public License as published by    //
// the Free Software Foundation; either version 2 of the License, or       //
// (at your option) any later version.                                     //
//                                                                         //
// This program is distributed in the hope that it will be useful,         //
// but WITHOUT ANY WARRANTY; without even the implied warranty of          //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
// GNU General Public License for more details:                            //
//                                                                         //
//          http://www.gnu.org/copyleft/gpl.html                           //
//                                                                         //
/////////////////////////////////////////////////////////////////////////////

    require_once('../config.php');
    require_once($CFG->dirroot.'/calendar/lib.php');
    require_once($CFG->dirroot.'/course/lib.php');
    require_once($CFG->dirroot.'/mod/forum/lib.php');

    require_login();

    $action = required_param('action', PARAM_ALPHA);
    $eventid = optional_param('id', 0, PARAM_INT);
    $eventtype = optional_param('type', 'select', PARAM_ALPHA);
    $urlcourse = optional_param('course', 0, PARAM_INT);
    $cal_y = optional_param('cal_y');
    $cal_m = optional_param('cal_m');
    $cal_d = optional_param('cal_d');

    if(isguest()) {
        // Guests cannot do anything with events
        redirect(CALENDAR_URL.'view.php?view=upcoming&amp;course='.$urlcourse);
    }

    $focus = '';

    if(!$site = get_site()) {
        redirect($CFG->wwwroot.'/'.$CFG->admin.'/index.php');
    }

    $strcalendar = get_string('calendar', 'calendar');

    // Initialize the session variables
    calendar_session_vars();

    $now = usergetdate(time());
    $navlinks = array();
    $calendar_navlink = array('name' => $strcalendar,
                          'link' =>calendar_get_link_href(CALENDAR_URL.'view.php?view=upcoming&amp;course='.$urlcourse.'&amp;',
                                                          $now['mday'], $now['mon'], $now['year']),
                          'type' => 'misc');

    $day = intval($now['mday']);
    $mon = intval($now['mon']);
    $yr = intval($now['year']);

    if ($usehtmleditor = can_use_html_editor()) {
        $defaultformat = FORMAT_HTML;
    } else {
        $defaultformat = FORMAT_MOODLE;
    }

    // If a course has been supplied in the URL, change the filters to show that one
    if($urlcourse > 0 && $DB->record_exists('course', array('id'=>$urlcourse))) {
        require_login($urlcourse, false);

        if($urlcourse == SITEID) {
            // If coming from the site page, show all courses
            $SESSION->cal_courses_shown = calendar_get_default_courses(true);
            calendar_set_referring_course(0);
        }
        else {
            // Otherwise show just this one
            $SESSION->cal_courses_shown = $urlcourse;
            calendar_set_referring_course($SESSION->cal_courses_shown);
        }
    }

    switch($action) {
        case 'delete':
            $title = get_string('deleteevent', 'calendar');
            $event = $DB->get_record('event', array('id'=>$eventid));
            if($event === false) {
                print_error('invalidevent');
            }
            if(!calendar_edit_event_allowed($event)) {
                print_error('nopermissions');
            }
        break;

        case 'edit':
            $title = get_string('editevent', 'calendar');
            $event = $DB->get_record('event', array('id'=>$eventid));
            $repeats = optional_param('repeats', 0, PARAM_INT);

            if ($event === false) {
                print_error('invalidevent');
            }
            if (!calendar_edit_event_allowed($event)) {
                print_error('nopermissions');
            }

            if($form = data_submitted()) {

                $form->name = clean_param(strip_tags($form->name,'<lang><span>'), PARAM_CLEAN);

                $form->timestart = make_timestamp($form->startyr, $form->startmon, $form->startday, $form->starthr, $form->startmin);
                if($form->duration == 1) {
                    $form->timeduration = make_timestamp($form->endyr, $form->endmon, $form->endday, $form->endhr, $form->endmin) - $form->timestart;
                    if($form->timeduration < 0) {
                        $form->timeduration = 0;<commit_msg>"MDL-10633, fix dobule quote in calendar, merged from MOODLE_19_STABLE"<commit_after><?php // $Id$

/////////////////////////////////////////////////////////////////////////////
//                                                                         //
// NOTICE OF COPYRIGHT                                                     //
//                                                                         //
// Moodle - Calendar extension                                             //
//                                                                         //
// Copyright (C) 2003-2004  Greek School Network            www.sch.gr     //
//                                                                         //
// Designed by:                                                            //
//     <NAME> (<EMAIL>)                         //
//     <NAME> (<EMAIL>)                                     //
//                                                                         //
// Programming and development:                                            //
//     <NAME> (<EMAIL>)                                     //
//                                                                         //
// For bugs, suggestions, etc contact:                                     //
//     <NAME> (<EMAIL>)                                     //
//                                                                         //
// The current module was developed at the University of Macedonia         //
// (www.uom.gr) under the funding of the Greek School Network (www.sch.gr) //
// The aim of this project is to provide additional and improved           //
// functionality to the Asynchronous Distance Education service that the   //
// Greek School Network deploys.                                           //
//                                                                         //
// This program is free software; you can redistribute it and/or modify    //
// it under the terms of the GNU General Public License as published by    //
// the Free Software Foundation; either version 2 of the License, or       //
// (at your option) any later version.                                     //
//                                                                         //
// This program is distributed in the hope that it will be useful,         //
// but WITHOUT ANY WARRANTY; without even the implied warranty of          //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
// GNU General Public License for more details:                            //
//                                                                         //
//          http://www.gnu.org/copyleft/gpl.html                           //
//                                                                         //
/////////////////////////////////////////////////////////////////////////////

    require_once('../config.php');
    require_once($CFG->dirroot.'/calendar/lib.php');
    require_once($CFG->dirroot.'/course/lib.php');
    require_once($CFG->dirroot.'/mod/forum/lib.php');

    require_login();

    $action = required_param('action', PARAM_ALPHA);
    $eventid = optional_param('id', 0, PARAM_INT);
    $eventtype = optional_param('type', 'select', PARAM_ALPHA);
    $urlcourse = optional_param('course', 0, PARAM_INT);
    $cal_y = optional_param('cal_y');
    $cal_m = optional_param('cal_m');
    $cal_d = optional_param('cal_d');

    if(isguest()) {
        // Guests cannot do anything with events
        redirect(CALENDAR_URL.'view.php?view=upcoming&amp;course='.$urlcourse);
    }

    $focus = '';

    if(!$site = get_site()) {
        redirect($CFG->wwwroot.'/'.$CFG->admin.'/index.php');
    }

    $strcalendar = get_string('calendar', 'calendar');

    // Initialize the session variables
    calendar_session_vars();

    $now = usergetdate(time());
    $navlinks = array();
    $calendar_navlink = array('name' => $strcalendar,
                          'link' =>calendar_get_link_href(CALENDAR_URL.'view.php?view=upcoming&amp;course='.$urlcourse.'&amp;',
                                                          $now['mday'], $now['mon'], $now['year']),
                          'type' => 'misc');

    $day = intval($now['mday']);
    $mon = intval($now['mon']);
    $yr = intval($now['year']);

    if ($usehtmleditor = can_use_html_editor()) {
        $defaultformat = FORMAT_HTML;
    } else {
        $defaultformat = FORMAT_MOODLE;
    }

    // If a course has been supplied in the URL, change the filters to show that one
    if($urlcourse > 0 && $DB->record_exists('course', array('id'=>$urlcourse))) {
        require_login($urlcourse, false);

        if($urlcourse == SITEID) {
            // If coming from the site page, show all courses
            $SESSION->cal_courses_shown = calendar_get_default_courses(true);
            calendar_set_referring_course(0);
        }
        else {
            // Otherwise show just this one
            $SESSION->cal_courses_shown = $urlcourse;
            calendar_set_referring_course($SESSION->cal_courses_shown);
        }
    }

    switch($action) {
        case 'delete':
            $title = get_string('deleteevent', 'calendar');
            $event = $DB->get_record('event', array('id'=>$eventid));
            if($event === false) {
                print_error('invalidevent');
            }
            if(!calendar_edit_event_allowed($event)) {
                print_error('nopermissions');
            }
        break;

        case 'edit':
            $title = get_string('editevent', 'calendar');
            $event = $DB->get_record('event', array('id'=>$eventid));
            $repeats = optional_param('repeats', 0, PARAM_INT);

            if ($event === false) {
                print_error('invalidevent');
            }
            if (!calendar_edit_event_allowed($event)) {
                print_error('nopermissions');
            }

            if($form = data_submitted()) {

                $form->name = clean_param(strip_tags($form->name,'<lang><span>'), PARAM_CLEAN);

                // To avoid double slashes
                $form->name = stripslashes($form->name);
                $form->description = stripslashes($form->description);

                $form->timestart = make_timestamp($form->startyr, $form->startmon, $form->startday, $form->starthr, $form->startmin);
                if($form->duration == 1) {
                    $form->timeduration = make_timestamp($form->endyr, $form->endmon, $form->endday, $form->endhr, $form->endmin) - $form->timestart;
                    if($form->timeduration < 0) {
                        $form->timeduration = 0;
{'fraction_non_alphanumeric': 0.14720157743060822, 'fraction_numerical': 0.0031093584104353103, 'mean_word_length': 1.1442276422764228, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 99, 'https://': 0, 'lorem ipsum': 0, 'www.': 10, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 100, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1731216', 'n_tokens_mistral': 3149, 'n_tokens_neox': 2999, 'n_words': 685}