当前位置: 首页>>代码示例>>PHP>>正文


PHP calendar_event::create方法代码示例

本文整理汇总了PHP中calendar_event::create方法的典型用法代码示例。如果您正苦于以下问题:PHP calendar_event::create方法的具体用法?PHP calendar_event::create怎么用?PHP calendar_event::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在calendar_event的用法示例。


在下文中一共展示了calendar_event::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 /**
  * Set up method.
  */
 protected function setUp()
 {
     global $DB, $CFG;
     $this->resetAfterTest();
     $this->setTimezone('Australia/Perth');
     $user = $this->getDataGenerator()->create_user();
     $sub = new stdClass();
     $sub->url = '';
     $sub->courseid = 0;
     $sub->groupid = 0;
     $sub->userid = $user->id;
     $sub->pollinterval = 0;
     $subid = $DB->insert_record('event_subscriptions', $sub, true);
     $event = new stdClass();
     $event->name = 'Event name';
     $event->description = '';
     $event->timestart = 1385913700;
     // A 2013-12-2 Monday event.
     $event->timeduration = 3600;
     $event->uuid = 'uuid';
     $event->subscriptionid = $subid;
     $event->userid = $user->id;
     $event->groupid = 0;
     $event->courseid = 0;
     $event->eventtype = 'user';
     $eventobj = calendar_event::create($event, false);
     $DB->set_field('event', 'repeatid', $eventobj->id, array('id' => $eventobj->id));
     $eventobj->repeatid = $eventobj->id;
     $this->event = $eventobj;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:33,代码来源:rrule_manager_tests.php

示例2: update_event_timedue

 /**
  *
  */
 public static function update_event_timedue($data)
 {
     global $DB;
     if (!empty($data->timedue)) {
         $event = new \stdClass();
         $event->name = $data->name;
         $event->description = format_module_intro('dataform', $data, $data->coursemodule);
         $event->timestart = $data->timedue;
         if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'dataform', 'instance' => $data->id))) {
             $calendarevent = \calendar_event::load($event->id);
             $calendarevent->update($event);
         } else {
             $event->courseid = $data->course;
             $event->groupid = 0;
             $event->userid = 0;
             $event->modulename = 'dataform';
             $event->instance = $data->id;
             $event->eventtype = 'due';
             $event->timeduration = 0;
             $event->visible = $DB->get_field('course_modules', 'visible', array('module' => $data->module, 'instance' => $data->id));
             \calendar_event::create($event);
         }
     } else {
         $DB->delete_records('event', array('modulename' => 'dataform', 'instance' => $data->id, 'eventtype' => 'due'));
     }
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:29,代码来源:calendar_event.php

示例3: execute

 /**
  * Do the job.
  */
 public function execute()
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . '/calendar/lib.php';
     // Get calendars set to sync in.
     $starttime = time();
     \local_o365\feature\calsync\observers::set_event_import(true);
     // Using a direct query here so we don't run into static cache issues.
     $laststarttime = $DB->get_record('config_plugins', ['plugin' => 'local_o365', 'name' => 'calsyncinlastrun']);
     $laststarttime = !empty($laststarttime) && !empty($laststarttime->value) ? $laststarttime->value : 0;
     $httpclient = new \local_o365\httpclient();
     $clientdata = \local_o365\oauth2\clientdata::instance_from_oidc();
     $calsubs = $DB->get_recordset_select('local_o365_calsub', 'syncbehav = ? OR syncbehav = ?', ['in', 'both']);
     $calsync = new \local_o365\feature\calsync\main($clientdata, $httpclient);
     foreach ($calsubs as $i => $calsub) {
         try {
             $events = $calsync->get_events($calsub->user_id, $calsub->o365calid, $laststarttime);
             if (!empty($events) && is_array($events) && isset($events['value']) && is_array($events['value'])) {
                 if (!empty($events['value'])) {
                     foreach ($events['value'] as $i => $event) {
                         if (!isset($event['Id'])) {
                             mtrace('Skipped an event because of malformed data.');
                             continue;
                         }
                         $idmapexists = $DB->record_exists('local_o365_calidmap', ['outlookeventid' => $event['Id']]);
                         if ($idmapexists === false) {
                             // Create Moodle event.
                             $eventparams = ['name' => $event['Subject'], 'description' => $event['Body']['Content'], 'eventtype' => $calsub->caltype, 'repeatid' => 0, 'modulename' => 0, 'instance' => 0, 'timestart' => strtotime($event['Start']), 'visible' => 1, 'uuid' => '', 'sequence' => 1];
                             $end = strtotime($event['End']);
                             $eventparams['timeduration'] = $end - $eventparams['timestart'];
                             if ($calsub->caltype === 'user') {
                                 $eventparams['userid'] = $calsub->caltypeid;
                             }
                             if ($calsub->caltype === 'course') {
                                 $eventparams['courseid'] = $calsub->caltypeid;
                             }
                             $moodleevent = \calendar_event::create($eventparams, false);
                             if (!empty($moodleevent) && !empty($moodleevent->id)) {
                                 $idmaprec = ['eventid' => $moodleevent->id, 'outlookeventid' => $event['Id'], 'origin' => 'o365', 'userid' => $calsub->user_id];
                                 $DB->insert_record('local_o365_calidmap', (object) $idmaprec);
                                 mtrace('Successfully imported event #' . $moodleevent->id);
                             }
                         }
                     }
                 } else {
                     mtrace('No new events to sync in.');
                 }
             } else {
                 mtrace('Bad response received when fetching events.');
             }
         } catch (\Exception $e) {
             mtrace('Error: ' . $e->getMessage());
         }
     }
     $calsubs->close();
     \local_o365\feature\calsync\observers::set_event_import(false);
     set_config('calsyncinlastrun', $starttime, 'local_o365');
     return true;
 }
开发者ID:jamesmcq,项目名称:o365-moodle,代码行数:62,代码来源:importfromoutlook.php

示例4: appear_add_instance

function appear_add_instance($data)
{
    global $DB, $CFG, $USER;
    $appear = new stdClass();
    $appear->course = $data->course;
    $appear->name = $data->name;
    $appear->intro = $data->intro;
    $appear->revision = $data->revision;
    $appear->timemodified = time();
    $appear->timecreated = time();
    $appear->timestart = $data->starttime;
    $appear->id = $DB->insert_record('appear', $appear);
    //creating group
    $group = new stdClass();
    $group->name = $data->name . '_group_' . $appear->id;
    $group->courseid = $data->course;
    $group->hidepicture = 0;
    $group->id = groups_create_group($group);
    // creating event subscription
    $sub = new stdClass();
    $sub->url = $CFG->wwwroot . '/mod/appear/view.php?id=' . $data->coursemodule;
    $sub->courseid = $data->course;
    $sub->groupid = $group->id;
    $sub->userid = $USER->id;
    $sub->pollinterval = 0;
    $subid = $DB->insert_record('event_subscriptions', $sub, true);
    // creating calender event
    $event = new stdClass();
    $event->name = $data->name;
    $event->description = '';
    $event->timestart = $data->starttime;
    $event->modulename = 'appear';
    $event->timeduration = 3600;
    $event->uuid = 'uuid';
    $event->subscriptionid = $subid;
    $event->userid = $USER->id;
    $event->groupid = $group->id;
    $event->courseid = $data->course;
    $event->eventtype = 'feedbackcloses';
    $eventobj = calendar_event::create($event, false);
    return $appear->id;
}
开发者ID:alokr912,项目名称:moodle-appear,代码行数:42,代码来源:lib.php

示例5: geogebra_after_add_or_update

function geogebra_after_add_or_update($geogebra, $mform)
{
    global $DB;
    if ($mform->get_data()->filetype === GEOGEBRA_FILE_TYPE_LOCAL) {
        $filename = geogebra_set_mainfile($geogebra);
        $geogebra->url = $filename;
        $result = $DB->update_record('geogebra', $geogebra);
    }
    if ($geogebra->timedue) {
        $event = new stdClass();
        if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'geogebra', 'instance' => $geogebra->id))) {
            $event->name = $geogebra->name;
            $event->description = format_module_intro('geogebra', $geogebra, $geogebra->coursemodule);
            $event->timestart = $geogebra->timedue;
            $calendarevent = calendar_event::load($event->id);
            $calendarevent->update($event);
        } else {
            $event = new stdClass();
            $event->name = $geogebra->name;
            $event->description = format_module_intro('geogebra', $geogebra, $geogebra->coursemodule);
            $event->courseid = $geogebra->course;
            $event->groupid = 0;
            $event->userid = 0;
            $event->modulename = 'geogebra';
            $event->instance = $geogebra->id;
            $event->eventtype = 'due';
            $event->timestart = $geogebra->timedue;
            $event->timeduration = 0;
            calendar_event::create($event);
        }
    } else {
        $DB->delete_records('event', array('modulename' => 'geogebra', 'instance' => $geogebra->id));
    }
    // get existing grade item
    geogebra_grade_item_update($geogebra);
    return true;
}
开发者ID:ninelanterns,项目名称:moodle-mod_geogebra,代码行数:37,代码来源:locallib.php

示例6: create_calendar_event

 /** Create calendar events or update them
  * Set $prop->id, if you want to do an update instead of creating an new event
  *
  * @param string $name        Event title
  * @param int    $userid      User id
  * @param string $type        Event type
  * @param int    $repeats     Number of repeated events to create
  * @param int    $timestart   Time stamp of the event start
  * @param mixed  $prop        List of event properties as array or object
  * @return mixed              Event object or false;
  * @since Moodle 2.5
  */
 public static function create_calendar_event($name, $userid = 0, $type = 'user', $repeats = 0, $timestart = null, $prop = null)
 {
     global $CFG, $DB, $USER, $SITE;
     require_once "{$CFG->dirroot}/calendar/lib.php";
     if (!empty($prop)) {
         if (is_array($prop)) {
             $prop = (object) $prop;
         }
     } else {
         $prop = new stdClass();
     }
     $prop->name = $name;
     if (empty($prop->eventtype)) {
         $prop->eventtype = $type;
     }
     if (empty($prop->repeats)) {
         $prop->repeats = $repeats;
     }
     if (empty($prop->timestart)) {
         $prop->timestart = time();
     }
     if (empty($prop->timeduration)) {
         $prop->timeduration = 0;
     }
     if (empty($prop->repeats)) {
         $prop->repeat = 0;
     } else {
         $prop->repeat = 1;
     }
     if (empty($prop->userid)) {
         if (!empty($userid)) {
             $prop->userid = $userid;
         } else {
             return false;
         }
     }
     if (!isset($prop->courseid)) {
         $prop->courseid = $SITE->id;
     }
     $event = new calendar_event($prop);
     return $event->create($prop);
 }
开发者ID:jeffthestampede,项目名称:excelsior,代码行数:54,代码来源:externallib_test.php

示例7: quiz_update_events

/**
 * This function updates the events associated to the quiz.
 * If $override is non-zero, then it updates only the events
 * associated with the specified override.
 *
 * @uses QUIZ_MAX_EVENT_LENGTH
 * @param object $quiz the quiz object.
 * @param object optional $override limit to a specific override
 */
function quiz_update_events($quiz, $override = null) {
    global $DB;

    // Load the old events relating to this quiz.
    $conds = array('modulename'=>'quiz',
                   'instance'=>$quiz->id);
    if (!empty($override)) {
        // Only load events for this override.
        $conds['groupid'] = isset($override->groupid)?  $override->groupid : 0;
        $conds['userid'] = isset($override->userid)?  $override->userid : 0;
    }
    $oldevents = $DB->get_records('event', $conds);

    // Now make a todo list of all that needs to be updated.
    if (empty($override)) {
        // We are updating the primary settings for the quiz, so we
        // need to add all the overrides.
        $overrides = $DB->get_records('quiz_overrides', array('quiz' => $quiz->id));
        // As well as the original quiz (empty override).
        $overrides[] = new stdClass();
    } else {
        // Just do the one override.
        $overrides = array($override);
    }

    foreach ($overrides as $current) {
        $groupid   = isset($current->groupid)?  $current->groupid : 0;
        $userid    = isset($current->userid)? $current->userid : 0;
        $timeopen  = isset($current->timeopen)?  $current->timeopen : $quiz->timeopen;
        $timeclose = isset($current->timeclose)? $current->timeclose : $quiz->timeclose;

        // Only add open/close events for an override if they differ from the quiz default.
        $addopen  = empty($current->id) || !empty($current->timeopen);
        $addclose = empty($current->id) || !empty($current->timeclose);

        if (!empty($quiz->coursemodule)) {
            $cmid = $quiz->coursemodule;
        } else {
            $cmid = get_coursemodule_from_instance('quiz', $quiz->id, $quiz->course)->id;
        }

        $event = new stdClass();
        $event->description = format_module_intro('quiz', $quiz, $cmid);
        // Events module won't show user events when the courseid is nonzero.
        $event->courseid    = ($userid) ? 0 : $quiz->course;
        $event->groupid     = $groupid;
        $event->userid      = $userid;
        $event->modulename  = 'quiz';
        $event->instance    = $quiz->id;
        $event->timestart   = $timeopen;
        $event->timeduration = max($timeclose - $timeopen, 0);
        $event->visible     = instance_is_visible('quiz', $quiz);
        $event->eventtype   = 'open';

        // Determine the event name.
        if ($groupid) {
            $params = new stdClass();
            $params->quiz = $quiz->name;
            $params->group = groups_get_group_name($groupid);
            if ($params->group === false) {
                // Group doesn't exist, just skip it.
                continue;
            }
            $eventname = get_string('overridegroupeventname', 'quiz', $params);
        } else if ($userid) {
            $params = new stdClass();
            $params->quiz = $quiz->name;
            $eventname = get_string('overrideusereventname', 'quiz', $params);
        } else {
            $eventname = $quiz->name;
        }
        if ($addopen or $addclose) {
            if ($timeclose and $timeopen and $event->timeduration <= QUIZ_MAX_EVENT_LENGTH) {
                // Single event for the whole quiz.
                if ($oldevent = array_shift($oldevents)) {
                    $event->id = $oldevent->id;
                } else {
                    unset($event->id);
                }
                $event->name = $eventname;
                // The method calendar_event::create will reuse a db record if the id field is set.
                calendar_event::create($event);
            } else {
                // Separate start and end events.
                $event->timeduration  = 0;
                if ($timeopen && $addopen) {
                    if ($oldevent = array_shift($oldevents)) {
                        $event->id = $oldevent->id;
                    } else {
                        unset($event->id);
                    }
//.........这里部分代码省略.........
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:101,代码来源:lib.php

示例8: grouptool_update_instance

/**
 * Updates an instance of the grouptool in the database
 *
 * Given an object containing all the necessary data,
 * (defined by the form in mod_form.php) this function
 * will update an existing instance with new data.
 *
 * @param stdClass $grouptool An object from the form in mod_form.php
 * @param mod_grouptool_mod_form $mform
 * @return boolean Success/Fail
 */
function grouptool_update_instance(stdClass $grouptool, mod_grouptool_mod_form $mform = null)
{
    global $DB, $CFG;
    $grouptool->timemodified = time();
    $grouptool->id = $grouptool->instance;
    $cmid = $grouptool->coursemodule;
    if (!isset($grouptool->use_size)) {
        $grouptool->use_size = 0;
    }
    if (!isset($grouptool->use_individual)) {
        $grouptool->use_individual = 0;
    }
    if (!isset($grouptool->use_queue)) {
        $queues = $DB->count_records_sql("SELECT COUNT(DISTINCT queues.id)\n                                            FROM {grouptool_agrps} agrps\n                                       LEFT JOIN {grouptool_queued} queues ON queues.agrpid = agrps.id\n                                           WHERE agrps.grouptoolid = ?", array($grouptool->instance));
        if (!empty($queues)) {
            $grouptool->use_queue = 1;
        } else {
            $grouptool->use_queue = 0;
        }
    }
    if (!isset($grouptool->allow_multiple)) {
        $grouptool->allow_multiple = 0;
    }
    $grouptool->grpsize = clean_param($grouptool->grpsize, PARAM_INT);
    $grouptool->choose_min = clean_param($grouptool->choose_min, PARAM_INT);
    $grouptool->choose_max = clean_param($grouptool->choose_max, PARAM_INT);
    // Register students if immediate registration has been turned on!
    if ($grouptool->immediate_reg) {
        require_once $CFG->dirroot . '/mod/grouptool/locallib.php';
        $instance = new mod_grouptool($grouptool->coursemodule, $grouptool);
        $instance->push_registrations();
    }
    require_once $CFG->dirroot . '/calendar/lib.php';
    $event = new stdClass();
    if ($grouptool->allow_reg) {
        $event->name = get_string('registration_period_start', 'grouptool') . ' ' . $grouptool->name;
    } else {
        $event->name = $grouptool->name . ' ' . get_string('availabledate', 'grouptool');
    }
    $event->description = format_module_intro('grouptool', $grouptool, $grouptool->coursemodule);
    if (!empty($grouptool->timeavailable)) {
        $event->timestart = $grouptool->timeavailable;
    } else {
        $grouptool->timecreated = $DB->get_field('grouptool', 'timecreated', array('id' => $grouptool->id));
        $event->timestart = $grouptool->timecreated;
    }
    $event->visible = instance_is_visible('grouptool', $grouptool);
    $event->timeduration = 0;
    if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'grouptool', 'instance' => $grouptool->id, 'eventtype' => 'availablefrom'))) {
        $calendarevent = calendar_event::load($event->id);
        $calendarevent->update($event, false);
    } else {
        $event->courseid = $grouptool->course;
        $event->groupid = 0;
        $event->userid = 0;
        $event->modulename = 'grouptool';
        $event->instance = $grouptool->id;
        /*
         *  For activity module's events, this can be used to set the alternative text of the
         *  event icon. Set it to 'pluginname' unless you have a better string.
         */
        $event->eventtype = 'availablefrom';
        calendar_event::create($event);
    }
    if ($grouptool->timedue != 0) {
        unset($event->id);
        unset($calendarevent);
        if ($grouptool->allow_reg) {
            $event->name = get_string('registration_period_end', 'grouptool') . ' ' . $grouptool->name;
        } else {
            $event->name = $grouptool->name . ' ' . get_string('duedate', 'grouptool');
        }
        $event->timestart = $grouptool->timedue;
        $event->eventtype = 'deadline';
        /*
         *  For activity module's events, this can be used to set the alternative text of the
         *  event icon. Set it to 'pluginname' unless you have a better string.
         */
        if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'grouptool', 'instance' => $grouptool->id, 'eventtype' => 'due'))) {
            $calendarevent = calendar_event::load($event->id);
            $calendarevent->update($event, false);
        } else {
            unset($event->id);
            $event->courseid = $grouptool->course;
            // We've got some permission issues with calendar_event::create() so we work around that!
            $calev = new calendar_event($event);
            $calev->update($event, false);
        }
    } else {
//.........这里部分代码省略.........
开发者ID:rimacher,项目名称:moodle-mod_grouptool,代码行数:101,代码来源:lib.php

示例9: vpl_update_instance

/**
 * Update a vpl instance
 *
 * @param object from the form in mod.html
 * @return boolean OK
 *
 **/
function vpl_update_instance($instance)
{
    global $CFG, $DB;
    require_once $CFG->dirroot . '/calendar/lib.php';
    vpl_truncate_VPL($instance);
    $instance->id = $instance->instance;
    //Update event
    $event = vpl_create_event($instance, $instance->id);
    if ($eventid = $DB->get_field('event', 'id', array('modulename' => VPL, 'instance' => $instance->id))) {
        $event->id = $eventid;
        $calendarevent = calendar_event::load($eventid);
        if ($instance->duedate) {
            $calendarevent->update($event);
        } else {
            $calendarevent->delete();
        }
    } else {
        if ($instance->duedate) {
            calendar_event::create($event);
        }
    }
    $cm = get_coursemodule_from_instance(VPL, $instance->id, $instance->course);
    vpl_update_grade_item($instance, $cm);
    return $DB->update_record(VPL, $instance);
}
开发者ID:go38,项目名称:moodle-mod_vpl,代码行数:32,代码来源:lib.php

示例10: bigbluebuttonbn_process_post_save

/**
 * Runs any processes that must be run
 * after a bigbluebuttonbn insert/update
 *
 * @global object
 * @param object $bigbluebuttonbn BigBlueButtonBN form data
 * @return void
 **/
function bigbluebuttonbn_process_post_save(&$bigbluebuttonbn)
{
    global $DB, $CFG, $USER;
    // Now that an id was assigned, generate and set the meetingid property based on
    // [Moodle Instance + Activity ID + BBB Secret] (but only for new activities)
    if (isset($bigbluebuttonbn->add) && !empty($bigbluebuttonbn->add)) {
        $bigbluebuttonbn_meetingid = sha1($CFG->wwwroot . $bigbluebuttonbn->id . bigbluebuttonbn_get_cfg_shared_secret());
        $DB->set_field('bigbluebuttonbn', 'meetingid', $bigbluebuttonbn_meetingid, array('id' => $bigbluebuttonbn->id));
        $action = get_string('mod_form_field_notification_msg_created', 'bigbluebuttonbn');
    } else {
        $action = get_string('mod_form_field_notification_msg_modified', 'bigbluebuttonbn');
    }
    // Add evento to the calendar when if openingtime is set
    if (isset($bigbluebuttonbn->openingtime) && $bigbluebuttonbn->openingtime) {
        $event = new stdClass();
        $event->name = $bigbluebuttonbn->name;
        $event->courseid = $bigbluebuttonbn->course;
        $event->groupid = 0;
        $event->userid = 0;
        $event->modulename = 'bigbluebuttonbn';
        $event->instance = $bigbluebuttonbn->id;
        $event->timestart = $bigbluebuttonbn->openingtime;
        if ($bigbluebuttonbn->closingtime) {
            $event->durationtime = $bigbluebuttonbn->closingtime - $bigbluebuttonbn->openingtime;
        } else {
            $event->durationtime = 0;
        }
        if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'bigbluebuttonbn', 'instance' => $bigbluebuttonbn->id))) {
            $calendarevent = calendar_event::load($event->id);
            $calendarevent->update($event);
        } else {
            calendar_event::create($event);
        }
    } else {
        $DB->delete_records('event', array('modulename' => 'bigbluebuttonbn', 'instance' => $bigbluebuttonbn->id));
    }
    if (isset($bigbluebuttonbn->notification) && $bigbluebuttonbn->notification) {
        // Prepare message
        $msg = new stdClass();
        /// Build the message_body
        $msg->action = $action;
        $msg->activity_type = "";
        $msg->activity_title = $bigbluebuttonbn->name;
        /// Add the meeting details to the message_body
        $msg->action = ucfirst($action);
        $msg->activity_description = "";
        if (!empty($bigbluebuttonbn->intro)) {
            $msg->activity_description = trim($bigbluebuttonbn->intro);
        }
        $msg->activity_openingtime = "";
        if ($bigbluebuttonbn->openingtime) {
            $date = new stdClass();
            $date->day = calendar_day_representation($bigbluebuttonbn->openingtime);
            $date->time = calendar_time_representation($bigbluebuttonbn->openingtime);
            $msg->activity_openingtime = get_string('email_date', 'bigbluebuttonbn', $date);
        }
        $msg->activity_closingtime = "";
        if ($bigbluebuttonbn->closingtime) {
            $date = new stdClass();
            $date->day = calendar_day_representation($bigbluebuttonbn->closingtime);
            $date->time = calendar_time_representation($bigbluebuttonbn->closingtime);
            $msg->activity_closingtime = get_string('email_date', 'bigbluebuttonbn', $date);
        }
        $msg->activity_owner = fullname($USER);
        $message_text = get_string('email_body_notification', 'bigbluebuttonbn', $msg);
        // Send notification to all users enrolled
        bigbluebuttonbn_send_notification($USER, $bigbluebuttonbn, $message_text);
    }
}
开发者ID:blindsidenetworks,项目名称:moodle-mod_bigbluebuttonbn,代码行数:77,代码来源:lib.php

示例11: update_calendar

 /**
  * Update the calendar entries for this assignment.
  *
  * @param int $coursemoduleid - Required to pass this in because it might
  *                              not exist in the database yet.
  * @return bool
  */
 public function update_calendar($coursemoduleid)
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . '/calendar/lib.php';
     // Special case for add_instance as the coursemodule has not been set yet.
     $instance = $this->get_instance();
     if ($instance->duedate) {
         $event = new stdClass();
         $params = array('modulename' => 'assign', 'instance' => $instance->id);
         $event->id = $DB->get_field('event', 'id', $params);
         if ($event->id) {
             $event->name = $instance->name;
             $event->description = format_module_intro('assign', $instance, $coursemoduleid);
             $event->timestart = $instance->duedate;
             $calendarevent = calendar_event::load($event->id);
             $calendarevent->update($event);
         } else {
             $event = new stdClass();
             $event->name = $instance->name;
             $event->description = format_module_intro('assign', $instance, $coursemoduleid);
             $event->courseid = $instance->course;
             $event->groupid = 0;
             $event->userid = 0;
             $event->modulename = 'assign';
             $event->instance = $instance->id;
             $event->eventtype = 'due';
             $event->timestart = $instance->duedate;
             $event->timeduration = 0;
             calendar_event::create($event);
         }
     } else {
         $DB->delete_records('event', array('modulename' => 'assign', 'instance' => $instance->id));
     }
 }
开发者ID:covex-nn,项目名称:moodle,代码行数:41,代码来源:locallib.php

示例12: add_event

/**
 * Call this function to add an event to the calendar table and to call any calendar plugins
 *
 * @param object $event An object representing an event from the calendar table.
 * The event will be identified by the id field. The object event should include the following:
 *  <ul>
 *    <li><b>$event->name</b> - Name for the event
 *    <li><b>$event->description</b> - Description of the event (defaults to '')
 *    <li><b>$event->format</b> - Format for the description (using formatting types defined at the top of weblib.php)
 *    <li><b>$event->courseid</b> - The id of the course this event belongs to (0 = all courses)
 *    <li><b>$event->groupid</b> - The id of the group this event belongs to (0 = no group)
 *    <li><b>$event->userid</b> - The id of the user this event belongs to (0 = no user)
 *    <li><b>$event->modulename</b> - Name of the module that creates this event
 *    <li><b>$event->instance</b> - Instance of the module that owns this event
 *    <li><b>$event->eventtype</b> - The type info together with the module info could
 *             be used by calendar plugins to decide how to display event
 *    <li><b>$event->timestart</b>- Timestamp for start of event
 *    <li><b>$event->timeduration</b> - Duration (defaults to zero)
 *    <li><b>$event->visible</b> - 0 if the event should be hidden (e.g. because the activity that created it is hidden)
 *  </ul>
 * @return int|false The id number of the resulting record or false if failed
 * @deprecated please use calendar_event::create() instead.
 * @todo final deprecation of this function in MDL-40607
 */
function add_event($event)
{
    global $CFG;
    require_once $CFG->dirroot . '/calendar/lib.php';
    debugging('add_event() is deprecated, please use calendar_event::create() instead.', DEBUG_DEVELOPER);
    $event = calendar_event::create($event);
    if ($event !== false) {
        return $event->id;
    }
    return false;
}
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:35,代码来源:deprecatedlib.php

示例13: add_event

/**
 * Call this function to add an event to the calendar table and to call any calendar plugins
 *
 * @param object $event An object representing an event from the calendar table.
 * The event will be identified by the id field. The object event should include the following:
 *  <ul>
 *    <li><b>$event->name</b> - Name for the event
 *    <li><b>$event->description</b> - Description of the event (defaults to '')
 *    <li><b>$event->format</b> - Format for the description (using formatting types defined at the top of weblib.php)
 *    <li><b>$event->courseid</b> - The id of the course this event belongs to (0 = all courses)
 *    <li><b>$event->groupid</b> - The id of the group this event belongs to (0 = no group)
 *    <li><b>$event->userid</b> - The id of the user this event belongs to (0 = no user)
 *    <li><b>$event->modulename</b> - Name of the module that creates this event
 *    <li><b>$event->instance</b> - Instance of the module that owns this event
 *    <li><b>$event->eventtype</b> - The type info together with the module info could
 *             be used by calendar plugins to decide how to display event
 *    <li><b>$event->timestart</b>- Timestamp for start of event
 *    <li><b>$event->timeduration</b> - Duration (defaults to zero)
 *    <li><b>$event->visible</b> - 0 if the event should be hidden (e.g. because the activity that created it is hidden)
 *  </ul>
 * @return int|false The id number of the resulting record or false if failed
 */
 function add_event($event) {
    global $CFG;
    require_once($CFG->dirroot.'/calendar/lib.php');
    $event = calendar_event::create($event);
    if ($event !== false) {
        return $event->id;
    }
    return false;
}
开发者ID:nuckey,项目名称:moodle,代码行数:31,代码来源:deprecatedlib.php

示例14: simplecertificate_send_event

/**
 * Update the event if it exists, else create
 */
function simplecertificate_send_event($certificate)
{
    global $DB, $CFG;
    require_once $CFG->dirroot . '/calendar/lib.php';
    if ($event = $DB->get_record('event', array('modulename' => 'simplecertificate', 'instance' => $certificate->id))) {
        $calendarevent = calendar_event::load($event->id);
        $calendarevent->name = $certificate->name;
        $calendarevent->update($calendarevent);
    } else {
        $event = new stdClass();
        $event->name = $certificate->name;
        $event->description = '';
        $event->courseid = $certificate->course;
        $event->groupid = 0;
        $event->userid = 0;
        $event->modulename = 'simplecertificate';
        $event->instance = $certificate->id;
        calendar_event::create($event);
    }
}
开发者ID:v--k,项目名称:moodle-mod_simplecertificate,代码行数:23,代码来源:lib.php

示例15: elluminate_update_events

function elluminate_update_events($elluminate)
{
    global $DB;
    if ($elluminate->sessiontype == 0 || $elluminate->sessiontype == 1) {
        $oldevents = $DB->get_records('event', array('modulename' => 'elluminate', 'instance' => $elluminate->id));
    } else {
        if ($elluminate->sessiontype == 2) {
            $oldevents = $DB->get_records('event', array('modulename' => 'elluminate', 'instance' => $elluminate->groupparentid, 'groupid' => $elluminate->groupid));
        } else {
            if ($elluminate->sessiontype == 3) {
                if ($elluminate->groupmode != 0) {
                    $oldevents = $DB->get_records('event', array('modulename' => 'elluminate', 'instance' => $elluminate->groupparentid, 'groupid' => $elluminate->groupid));
                } else {
                    $oldevents = $DB->get_records('event', array('modulename' => 'elluminate', 'instance' => $elluminate->id));
                }
            }
        }
    }
    $event = new stdClass();
    foreach ($oldevents as $oldevent) {
        $event = $oldevent;
    }
    $event->description = $elluminate->description;
    $event->courseid = $elluminate->course;
    // Events module won't show user events when the courseid is nonzero
    if ($elluminate->sessiontype == 0 || $elluminate->sessiontype == 1) {
        //course private
        $event->groupid = 0;
        $event->eventtype = 'open';
        $event->name = $elluminate->name;
        $event->instance = $elluminate->id;
    } else {
        if ($elluminate->sessiontype == 3) {
            //grouping
            if ($elluminate->groupmode != 0) {
                //Seperate or Visible groups
                $event->groupid = $elluminate->groupid;
                $event->eventtype = 'group';
                $event->name = $elluminate->sessionname;
                $event->instance = $elluminate->groupparentid;
            } else {
                //No groups
                $event->groupid = 0;
                $event->eventtype = 'open';
                $event->name = $elluminate->sessionname;
                $event->instance = $elluminate->id;
            }
        } else {
            //group
            $event->groupid = $elluminate->groupid;
            $event->eventtype = 'group';
            $event->name = $elluminate->sessionname;
            $event->instance = $elluminate->groupparentid;
        }
    }
    $event->modulename = 'elluminate';
    $event->timestart = $elluminate->timestart;
    $event->timeduration = max($elluminate->timeend - $elluminate->timestart, 0);
    $event->visible = instance_is_visible('elluminate', $elluminate);
    calendar_event::create($event);
}
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:61,代码来源:lib.php


注:本文中的calendar_event::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。