本文整理汇总了PHP中calendar_event类的典型用法代码示例。如果您正苦于以下问题:PHP calendar_event类的具体用法?PHP calendar_event怎么用?PHP calendar_event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了calendar_event类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: xmldb_workshop_upgrade
/**
* Performs upgrade of the database structure and data
*
* Workshop supports upgrades from version 1.9.0 and higher only. During 1.9 > 2.0 upgrade,
* there are significant database changes.
*
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_workshop_upgrade($oldversion)
{
global $CFG, $DB, $OUTPUT;
$dbman = $DB->get_manager();
// Moodle v2.2.0 release upgrade line
if ($oldversion < 2012033100) {
// add the field 'phaseswitchassessment' to the 'workshop' table
$table = new xmldb_table('workshop');
$field = new xmldb_field('phaseswitchassessment', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'assessmentend');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2012033100, 'workshop');
}
/**
* Remove all workshop calendar events
*/
if ($oldversion < 2012041700) {
require_once $CFG->dirroot . '/calendar/lib.php';
$events = $DB->get_records('event', array('modulename' => 'workshop'));
foreach ($events as $event) {
$event = calendar_event::load($event);
$event->delete();
}
upgrade_mod_savepoint(true, 2012041700, 'workshop');
}
/**
* Recreate all workshop calendar events
*/
if ($oldversion < 2012041701) {
require_once dirname(dirname(__FILE__)) . '/lib.php';
$sql = "SELECT w.id, w.course, w.name, w.intro, w.introformat, w.submissionstart,\n w.submissionend, w.assessmentstart, w.assessmentend,\n cm.id AS cmid\n FROM {workshop} w\n JOIN {modules} m ON m.name = 'workshop'\n JOIN {course_modules} cm ON (cm.module = m.id AND cm.course = w.course AND cm.instance = w.id)";
$rs = $DB->get_recordset_sql($sql);
foreach ($rs as $workshop) {
$cmid = $workshop->cmid;
unset($workshop->cmid);
workshop_calendar_update($workshop, $cmid);
}
$rs->close();
upgrade_mod_savepoint(true, 2012041701, 'workshop');
}
// Moodle v2.3.0 release upgrade line
// Put any upgrade step following this
return true;
}
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:54,代码来源:upgrade.php
示例5: 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
示例6: 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
示例7: create
/**
* Creates a new event and returns a calendar_event object
*
* @param object|array $properties An object containing event properties
* @return calendar_event|false The event object or false if it failed
*/
public static function create($properties)
{
if (is_array($properties)) {
$properties = (object) $properties;
}
if (!is_object($properties)) {
throw new coding_exception('When creating an event properties should be either an object or an assoc array');
}
$event = new calendar_event($properties);
if ($event->update($properties)) {
return $event;
} else {
return false;
}
}
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:21,代码来源:lib.php
示例8: turnitintool_update_partnames
//.........这里部分代码省略.........
} else {
$owner = turnitintool_get_owner($turnitintool->course);
}
if (!($course = turnitintool_get_record('course', 'id', $turnitintool->course))) {
turnitintool_print_error('coursegeterror', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
exit;
}
$loaderbar = new turnitintool_loaderbarclass(3);
$tii = new turnitintool_commclass(turnitintool_getUID($owner), $owner->firstname, $owner->lastname, $owner->email, 2, $loaderbar);
$tii->startSession();
turnitintool_usersetup($owner, get_string('userprocess', 'turnitintool'), $tii, $loaderbar);
turnitintool_classsetup($course, $owner, get_string('classprocess', 'turnitintool'), $tii, $loaderbar);
if ($tii->getRerror()) {
if ($tii->getAPIunavailable()) {
turnitintool_print_error('apiunavailable', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
} else {
turnitintool_print_error($tii->getRmessage(), NULL, NULL, NULL, __FILE__, __LINE__);
}
exit;
}
$tiipost->cid = turnitintool_getCID($turnitintool->course);
$tiipost->assignid = turnitintool_getAID($post['submitted']);
$tiipost->s_view_report = $turnitintool->studentreports;
$tiipost->max_points = $post['maxmarks'];
$tiipost->anon = $turnitintool->anon;
$tiipost->report_gen_speed = $turnitintool->reportgenspeed;
$tiipost->late_accept_flag = $turnitintool->allowlate;
$tiipost->submit_papers_to = $turnitintool->submitpapersto;
$tiipost->s_paper_check = $turnitintool->spapercheck;
$tiipost->internet_check = $turnitintool->internetcheck;
$tiipost->journal_check = $turnitintool->journalcheck;
// Add in Exclude small matches, biblio, quoted etc 20102009
$tiipost->exclude_biblio = $turnitintool->excludebiblio;
$tiipost->exclude_quoted = $turnitintool->excludequoted;
$tiipost->exclude_value = $turnitintool->excludevalue;
$tiipost->exclude_type = $turnitintool->excludetype;
// Add in the erater settings
$tiipost->erater = $turnitintool->erater;
$tiipost->erater_handbook = $turnitintool->erater_handbook;
$tiipost->erater_dictionary = $turnitintool->erater_dictionary;
$tiipost->erater_spelling = $turnitintool->erater_spelling;
$tiipost->erater_grammar = $turnitintool->erater_grammar;
$tiipost->erater_usage = $turnitintool->erater_usage;
$tiipost->erater_mechanics = $turnitintool->erater_mechanics;
$tiipost->erater_style = $turnitintool->erater_style;
$tiipost->transmatch = $turnitintool->transmatch;
$tiipost->name = $turnitintool->name . ' - ' . $post['partname'] . ' (Moodle ' . $tiipost->assignid . ')';
$tiipost->currentassign = $turnitintool->name . ' - ' . turnitintool_partnamefromnum($post['submitted']) . ' (Moodle ' . $tiipost->assignid . ')';
$tii->createAssignment($tiipost, 'UPDATE', get_string('assignmentupdate', 'turnitintool', ''));
if ($tii->getRerror()) {
if ($tii->getRcode() == TURNITINTOOL_DB_UNIQUEID_ERROR) {
$reason = get_string('assignmentdoesnotexist', 'turnitintool');
} else {
$reason = $tii->getAPIunavailable() ? get_string('apiunavailable', 'turnitintool') : $tii->getRmessage();
}
turnitintool_print_error('<strong>' . get_string('updateerror', 'turnitintool') . '</strong><br />' . $reason);
exit;
}
$part = new stdClass();
$part->id = $post['submitted'];
$part->dtstart = $dtstart;
$part->dtdue = $dtdue;
$part->dtpost = $dtpost;
$part->partname = $post['partname'];
$part->maxmarks = $post['maxmarks'];
$part->deleted = 0;
$event = new stdClass();
$event->timestart = $part->dtdue;
$event->name = $turnitintool->name . ' - ' . $part->partname;
$currentevent = $turnitintool->name . ' - ' . turnitintool_partnamefromnum($post['submitted']);
if (!($dbpart = turnitintool_update_record('turnitintool_parts', $part, false))) {
turnitintool_print_error('partdberror', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
}
if ($events = turnitintool_get_record_select('event', "modulename='turnitintool' AND instance = ? AND name = ?", array($turnitintool->id, $currentevent))) {
$event->id = $events->id;
if (method_exists('calendar_event', 'update')) {
$calendarevent = calendar_event::load($event->id);
$calendarevent->update($event);
} else {
update_event($event);
}
}
@(include_once $CFG->dirroot . "/lib/gradelib.php");
// Set the view time for Grade Book viewing
if (function_exists('grade_update')) {
$lastpart = turnitintool_get_record('turnitintool_parts', 'turnitintoolid', $turnitintool->id, '', '', '', '', 'max(dtpost)');
$lastpart = current($lastpart);
$params['hidden'] = $lastpart;
grade_update('mod/turnitintool', $turnitintool->course, 'mod', 'turnitintool', $turnitintool->id, 0, NULL, $params);
}
$tii->endSession();
turnitintool_redirect($CFG->wwwroot . '/mod/turnitintool/view.php' . '?id=' . $cm->id . '&do=intro');
exit;
} else {
return $notice;
}
} else {
turnitintool_print_error('permissiondeniederror', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
}
}
开发者ID:ccle,项目名称:moodle-mod_turnitintool,代码行数:101,代码来源:lib.php
示例9: booking_delete_booking_option
/**
* Deletes a booking option and the associated user answers
* @param $bookingid the booking instance
* @param $optionid the booking option
* @return false if not successful, true on success
*/
function booking_delete_booking_option($booking, $optionid)
{
global $DB;
$event = new stdClass();
if (!($option = $DB->get_record("booking_options", array("id" => $optionid)))) {
return false;
}
$result = true;
$params = array('bookingid' => $booking->id, 'optionid' => $optionid);
$userids = $DB->get_fieldset_select('booking_answers', 'userid', 'bookingid = :bookingid AND optionid = :optionid', $params);
foreach ($userids as $userid) {
booking_check_unenrol_user($option, $booking, $userid);
// Unenrol any users enroled via this option.
}
if (!$DB->delete_records("booking_answers", array("bookingid" => $booking->id, "optionid" => $optionid))) {
$result = false;
}
// Delete calendar entry, if any
$event->id = $DB->get_field('booking_options', 'calendarid', array('id' => $optionid));
if ($event->id > 0) {
// Delete event if exist
$event = calendar_event::load($event->id);
$event->delete(true);
}
if (!$DB->delete_records("booking_options", array("id" => $optionid))) {
$result = false;
}
return $result;
}
开发者ID:375michael40veit,项目名称:moodle-mod_booking,代码行数:35,代码来源:lib.php
示例10: feedback_set_events
/**
* This creates new events given as timeopen and closeopen by $feedback.
*
* @global object
* @param object $feedback
* @return void
*/
function feedback_set_events($feedback) {
global $DB;
// adding the feedback to the eventtable (I have seen this at quiz-module)
$DB->delete_records('event', array('modulename'=>'feedback', 'instance'=>$feedback->id));
if (!isset($feedback->coursemodule)) {
$cm = get_coursemodule_from_id('feedback', $feedback->id);
$feedback->coursemodule = $cm->id;
}
// the open-event
if ($feedback->timeopen > 0) {
$event = new stdClass();
$event->name = get_string('start', 'feedback').' '.$feedback->name;
$event->description = format_module_intro('feedback', $feedback, $feedback->coursemodule);
$event->courseid = $feedback->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'feedback';
$event->instance = $feedback->id;
$event->eventtype = 'open';
$event->timestart = $feedback->timeopen;
$event->visible = instance_is_visible('feedback', $feedback);
if ($feedback->timeclose > 0) {
$event->timeduration = ($feedback->timeclose - $feedback->timeopen);
} else {
$event->timeduration = 0;
}
calendar_event::create($event);
}
// the close-event
if ($feedback->timeclose > 0) {
$event = new stdClass();
$event->name = get_string('stop', 'feedback').' '.$feedback->name;
$event->description = format_module_intro('feedback', $feedback, $feedback->coursemodule);
$event->courseid = $feedback->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'feedback';
$event->instance = $feedback->id;
$event->eventtype = 'close';
$event->timestart = $feedback->timeclose;
$event->visible = instance_is_visible('feedback', $feedback);
$event->timeduration = 0;
calendar_event::create($event);
}
}
开发者ID:numbas,项目名称:moodle,代码行数:58,代码来源:lib.php
示例11: update_instance
/**
* Updates a new assignment activity
*
* Given an object containing all the necessary data,
* (defined by the form in mod_form.php) this function
* will update the assignment instance and return the id number
* The due date is updated in the calendar
* This is common to all assignment types.
*
* @global object
* @global object
* @param object $assignment The data from the form on mod_form.php
* @return bool success
*/
function update_instance($assignment) {
global $COURSE, $DB;
$assignment->timemodified = time();
$assignment->id = $assignment->instance;
$assignment->courseid = $assignment->course;
$DB->update_record('assignment', $assignment);
if ($assignment->timedue) {
$event = new stdClass();
if ($event->id = $DB->get_field('event', 'id', array('modulename'=>'assignment', 'instance'=>$assignment->id))) {
$event->name = $assignment->name;
$event->description = format_module_intro('assignment', $assignment, $assignment->coursemodule);
$event->timestart = $assignment->timedue;
$calendarevent = calendar_event::load($event->id);
$calendarevent->update($event);
} else {
$event = new stdClass();
$event->name = $assignment->name;
$event->description = format_module_intro('assignment', $assignment, $assignment->coursemodule);
$event->courseid = $assignment->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'assignment';
$event->instance = $assignment->id;
$event->eventtype = 'due';
$event->timestart = $assignment->timedue;
$event->timeduration = 0;
calendar_event::create($event);
}
} else {
$DB->delete_records('event', array('modulename'=>'assignment', 'instance'=>$assignment->id));
}
// get existing grade item
assignment_grade_item_update($assignment);
return true;
}
开发者ID:nuckey,项目名称:moodle,代码行数:59,代码来源:lib.php
示例12: delete
/**
* Deletes this lesson from the database
*/
public function delete()
{
global $CFG, $DB;
require_once $CFG->libdir . '/gradelib.php';
require_once $CFG->dirroot . '/calendar/lib.php';
$cm = get_coursemodule_from_instance('lesson', $this->properties->id, $this->properties->course);
$context = context_module::instance($cm->id);
$DB->delete_records("lesson", array("id" => $this->properties->id));
$DB->delete_records("lesson_pages", array("lessonid" => $this->properties->id));
$DB->delete_records("lesson_answers", array("lessonid" => $this->properties->id));
$DB->delete_records("lesson_attempts", array("lessonid" => $this->properties->id));
$DB->delete_records("lesson_grades", array("lessonid" => $this->properties->id));
$DB->delete_records("lesson_timer", array("lessonid" => $this->properties->id));
$DB->delete_records("lesson_branch", array("lessonid" => $this->properties->id));
$DB->delete_records("lesson_high_scores", array("lessonid" => $this->properties->id));
if ($events = $DB->get_records('event', array("modulename" => 'lesson', "instance" => $this->properties->id))) {
foreach ($events as $event) {
$event = calendar_event::load($event);
$event->delete();
}
}
// Delete files associated with this module.
$fs = get_file_storage();
$fs->delete_area_files($context->id);
grade_update('mod/lesson', $this->properties->course, 'mod', 'lesson', $this->properties->id, 0, null, array('deleted' => 1));
return true;
}
开发者ID:nikitskynikita,项目名称:moodle,代码行数:30,代码来源:locallib.php
示例13: get_calendar_events
/**
* Get Calendar events
*
* @param array $events A list of events
* @param array $options various options
* @return array Array of event details
* @since Moodle 2.5
*/
public static function get_calendar_events($events = array(), $options = array())
{
global $SITE, $DB, $USER, $CFG;
require_once $CFG->dirroot . "/calendar/lib.php";
// Parameter validation.
$params = self::validate_parameters(self::get_calendar_events_parameters(), array('events' => $events, 'options' => $options));
$funcparam = array('courses' => array(), 'groups' => array());
$hassystemcap = has_capability('moodle/calendar:manageentries', context_system::instance());
$warnings = array();
// Let us findout courses that we can return events from.
if (!$hassystemcap) {
$courses = enrol_get_my_courses();
$courses = array_keys($courses);
foreach ($params['events']['courseids'] as $id) {
if (in_array($id, $courses)) {
$funcparam['courses'][] = $id;
} else {
$warnings[] = array('item' => $id, 'warningcode' => 'nopermissions', 'message' => 'you do not have permissions to access this course');
}
}
} else {
$courses = $params['events']['courseids'];
$funcparam['courses'] = $courses;
}
// Let us findout groups that we can return events from.
if (!$hassystemcap) {
$groups = groups_get_my_groups();
$groups = array_keys($groups);
foreach ($params['events']['groupids'] as $id) {
if (in_array($id, $groups)) {
$funcparam['groups'][] = $id;
} else {
$warnings[] = array('item' => $id, 'warningcode' => 'nopermissions', 'message' => 'you do not have permissions to access this group');
}
}
} else {
$groups = $params['events']['groupids'];
$funcparam['groups'] = $groups;
}
// Do we need user events?
if (!empty($params['options']['userevents'])) {
$funcparam['users'] = array($USER->id);
} else {
$funcparam['users'] = false;
}
// Do we need site events?
if (!empty($params['options']['siteevents'])) {
$funcparam['courses'][] = $SITE->id;
}
// We treat 0 and null as no end.
if (empty($params['options']['timeend'])) {
$params['options']['timeend'] = PHP_INT_MAX;
}
$eventlist = calendar_get_events($params['options']['timestart'], $params['options']['timeend'], $funcparam['users'], $funcparam['groups'], $funcparam['courses'], true, $params['options']['ignorehidden']);
// WS expects arrays.
$events = array();
foreach ($eventlist as $id => $event) {
$events[$id] = (array) $event;
}
// We need to get events asked for eventids.
$eventsbyid = calendar_get_events_by_id($params['events']['eventids']);
foreach ($eventsbyid as $eventid => $eventobj) {
$event = (array) $eventobj;
if (isset($events[$eventid])) {
continue;
}
if ($hassystemcap) {
// User can see everything, no further check is needed.
$events[$eventid] = $event;
} else {
if (!empty($eventobj->modulename)) {
$cm = get_coursemodule_from_instance($eventobj->modulename, $eventobj->instance);
if (\core_availability\info_module::is_user_visible($cm, 0, false)) {
$events[$eventid] = $event;
}
} else {
// Can the user actually see this event?
$eventobj = calendar_event::load($eventobj);
if ($eventobj->courseid == $SITE->id || !empty($eventobj->groupid) && in_array($eventobj->groupid, $groups) || !empty($eventobj->courseid) && in_array($eventobj->courseid, $courses) || $USER->id == $eventobj->userid || calendar_edit_event_allowed($eventid)) {
$events[$eventid] = $event;
} else {
$warnings[] = array('item' => $eventid, 'warningcode' => 'nopermissions', 'message' => 'you do not have permissions to view this event');
}
}
}
}
return array('events' => $events, 'warnings' => $warnings);
}
开发者ID:nikitskynikita,项目名称:moodle,代码行数:96,代码来源:externallib.php
示例14: workshop_calendar_update
/**
* Updates the calendar events associated to the given workshop
*
* @param stdClass $workshop the workshop instance record
* @param int $cmid course module id
*/
function workshop_calendar_update(stdClass $workshop, $cmid) {
global $DB;
// get the currently registered events so that we can re-use their ids
$currentevents = $DB->get_records('event', array('modulename' => 'workshop', 'instance' => $workshop->id));
// the common properties for all events
$base = new stdClass();
$base->description = format_module_intro('workshop', $workshop, $cmid, false);
$base->courseid = $workshop->course;
$base->groupid = 0;
$base->userid = 0;
$base->modulename = 'workshop';
$base->eventtype = 'pluginname';
$base->instance = $workshop->id;
$base->visible = instance_is_visible('workshop', $workshop);
$base->timeduration = 0;
if ($workshop->submissionstart) {
$event = clone($base);
$event->name = get_string('submissionstartevent', 'mod_workshop', $workshop->name);
$event->timestart = $workshop->submissionstart;
if ($reusedevent = array_shift($currentevents)) {
$event->id = $reusedevent->id;
} else {
// should not be set but just in case
unset($event->id);
}
// update() will reuse a db record if the id field is set
$eventobj = new calendar_event($event);
$eventobj->update($event, false);
}
if ($workshop->submissionend) {
$event = clone($base);
$event->name = get_string('submissionendevent', 'mod_workshop', $workshop->name);
$event->timestart = $workshop->submissionend;
if ($reusedevent = array_shift($currentevents)) {
$event->id = $reusedevent->id;
} else {
// should not be set but just in case
unset($event->id);
}
// update() will reuse a db record if the id field is set
$eventobj = new calendar_event($event);
$eventobj->update($event, false);
}
if ($workshop->assessmentstart) {
$event = clone($base);
$event->name = get_string('assessmentstartevent', 'mod_workshop', $workshop->name);
$event->timestart = $workshop->assessmentstart;
if ($reusedevent = array_shift($currentevents)) {
$event->id = $reusedevent->id;
} else {
// should not be set but just in case
unset($event->id);
}
// update() will reuse a db record if the id field is set
$eventobj = new calendar_event($event);
$eventobj->update($event, false);
}
if ($workshop->assessmentend) {
$event = clone($base);
$event->name = get_string('assessmentendevent', 'mod_workshop', $workshop->name);
$event->timestart = $workshop->assessmentend;
if ($reusedevent = array_shift($currentevents)) {
$event->id = $reusedevent->id;
} else {
// should not be set but just in case
unset($event->id);
}
// update() will reuse a db record if the id field is set
$eventobj = new calendar_event($event);
$eventobj->update($event, false);
}
// delete any leftover events
foreach ($currentevents as $oldevent) {
$oldevent = calendar_event::load($oldevent);
$oldevent->delete();
}
}
开发者ID:ncsu-delta,项目名称:moodle,代码行数:90,代码来源:lib.php
示例15: update_event
/**
* Call this function to update an event in the calendar table
* the event will be identified by the id field of the $event object.
*
* @param object $event An object representing an event from the calendar table. The event will be identified by the id field.
* @return bool Success
* @deprecated please calendar_event->update() instead.
*/
function update_event($event)
{
global $CFG;
require_once $CFG->dirroot . '/calendar/lib.php';
debugging('update_event() is deprecated, please use calendar_event->update() instead.', DEBUG_DEVELOPER);
$event = (object) $event;
$calendarevent = calendar_event::load($event->id);
return $calendarevent->update($event);
}
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:17,代码来源:deprecatedlib.php
示例16: 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
示例17: 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;
|
请发表评论