本文整理汇总了PHP中add_event函数的典型用法代码示例。如果您正苦于以下问题:PHP add_event函数的具体用法?PHP add_event怎么用?PHP add_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_event函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bigbluebutton_add_instance
function bigbluebutton_add_instance($bigbluebutton)
{
$bigbluebutton->timemodified = time();
if ($returnid = insert_record('bigbluebutton', $bigbluebutton)) {
$event = NULL;
$event->courseid = $bigbluebutton->course;
$event->name = $bigbluebutton->name;
$event->meetingname = $bigbluebutton->meetingname;
$event->meetingid = $bigbluebutton->meetingid;
$event->attendeepw = $bigbluebutton->attendeepw;
$event->moderatorpw = $bigbluebutton->moderatorpw;
$event->autologin = $bigbluebutton->autologin;
$event->newwindow = $bigbluebutton->newwindow;
$event->welcomemsg = $bigbluebutton->welcomemsg;
add_event($event);
}
return $returnid;
}
示例2: certificate_update_instance
function certificate_update_instance($certificate)
{
$certificate->timemodified = time();
$certificate->id = $certificate->instance;
if ($returnid = update_record('certificate', $certificate)) {
if ($event->id = get_field('event', 'id', 'modulename', 'certificate', 'instance', $certificate->id)) {
$event->name = $certificate->name;
update_event($event);
} else {
$event = NULL;
$event->name = $certificate->name;
$event->courseid = $certificate->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'certificate';
$event->instance = $certificate->id;
add_event($event);
}
} else {
delete_records('event', 'modulename', 'certificate', 'instance', $certificate->id);
}
return $returnid;
}
示例3: _wwassignment_create_events
/**
* @desc Creates the corresponding events for a wwassignment.
* @param $wwsetname string The name of the set.
* @param $wwassignmentid string The ID of the wwassignment record.
* @param $opendate integer The UNIX timestamp of the open date.
* @param $duedate integer The UNIX timestamp of the due date.
* @return integer 0 on success. -1 on error.
*/
function _wwassignment_create_events($wwsetname, $wwassignment, $opendate, $duedate)
{
global $COURSE;
unset($event);
$event->name = $wwsetname;
$event->description = 'WeBWorK Set Event';
$event->courseid = $wwassignment->course;
$event->groupid = 0;
$event->userid = 0;
$event->format = 1;
$event->modulename = 'wwassignment';
$event->instance = $wwassignment->id;
$event->visible = 1;
// FIXME -- this doesn't create a new object we'll just handle the due date for now
// what you want is $openevent = clone $event this makes a shallow copy of the object
//$openevent = $event;
// FIXME -- it's likely that only the due date needs to be posted. once that is sure, clean this up.
$dueevent = $event;
//$openevent->name .= ' is Open.';
//$openevent->eventtype = 'open';
//$openevent->timestart = $opendate;
//$openevent->timeduration = $duedate - $opendate;
$dueevent->name .= ' is Due.';
$dueevent->eventtype = 'due';
$dueevent->timestart = $duedate;
$dueevent->timeduration = 1;
// error_log("adding a due event");
$result = 0;
//if(!add_event($openevent)) {
// $result = -1;
//}
if (!add_event($dueevent)) {
$result = -1;
}
return $result;
}
示例4: certificate_update_instance
/**
* Update certificate instance.
*
* @param stdClass $certificate
* @return bool true
*/
function certificate_update_instance($certificate)
{
global $DB;
// Update the certificate
$certificate->timemodified = time();
$certificate->id = $certificate->instance;
$DB->update_record('certificate', $certificate);
// Update the event if it exists, else create
if ($event = $DB->get_record('event', array('modulename' => 'certificate', 'instance' => $certificate->id))) {
$event->name = $certificate->name;
update_event($event);
} else {
$event = new stdClass();
$event->name = $certificate->name;
$event->description = '';
$event->courseid = $certificate->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'certificate';
$event->instance = $certificate->id;
add_event($event);
}
return true;
}
示例5: quiz_after_add_or_update
/**
* This function is called at the end of quiz_add_instance
* and quiz_update_instance, to do the common processing.
*
* @param object $quiz the quiz object.
*/
function quiz_after_add_or_update($quiz)
{
// Save the feedback
delete_records('quiz_feedback', 'quizid', $quiz->id);
for ($i = 0; $i <= $quiz->feedbackboundarycount; $i += 1) {
$feedback = new stdClass();
$feedback->quizid = $quiz->id;
$feedback->feedbacktext = $quiz->feedbacktext[$i];
$feedback->mingrade = $quiz->feedbackboundaries[$i];
$feedback->maxgrade = $quiz->feedbackboundaries[$i - 1];
if (!insert_record('quiz_feedback', $feedback, false)) {
return "Could not save quiz feedback.";
}
}
// Update the events relating to this quiz.
// This is slightly inefficient, deleting the old events and creating new ones. However,
// there are at most two events, and this keeps the code simpler.
if ($events = get_records_select('event', "modulename = 'quiz' and instance = '{$quiz->id}'")) {
foreach ($events as $event) {
delete_event($event->id);
}
}
$event = new stdClass();
$event->description = $quiz->intro;
$event->courseid = $quiz->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'quiz';
$event->instance = $quiz->id;
$event->timestart = $quiz->timeopen;
$event->timeduration = $quiz->timeclose - $quiz->timeopen;
$event->visible = instance_is_visible('quiz', $quiz);
$event->eventtype = 'open';
if ($quiz->timeclose and $quiz->timeopen and $event->timeduration <= QUIZ_MAX_EVENT_LENGTH) {
// Single event for the whole quiz.
$event->name = $quiz->name;
add_event($event);
} else {
// Separate start and end events.
$event->timeduration = 0;
if ($quiz->timeopen) {
$event->name = $quiz->name . ' (' . get_string('quizopens', 'quiz') . ')';
add_event($event);
unset($event->id);
// So we can use the same object for the close event.
}
if ($quiz->timeclose) {
$event->name = $quiz->name . ' (' . get_string('quizcloses', 'quiz') . ')';
$event->timestart = $quiz->timeclose;
$event->eventtype = 'close';
add_event($event);
}
}
//update related grade item
quiz_grade_item_update(stripslashes_recursive($quiz));
}
示例6: chat_refresh_events
function chat_refresh_events($courseid = 0)
{
// This standard function will check all instances of this module
// and make sure there are up-to-date events created for each of them.
// If courseid = 0, then every chat event in the site is checked, else
// only chat events belonging to the course specified are checked.
// This function is used, in its new format, by restore_refresh_events()
if ($courseid) {
if (!($chats = get_records("chat", "course", $courseid))) {
return true;
}
} else {
if (!($chats = get_records("chat"))) {
return true;
}
}
$moduleid = get_field('modules', 'id', 'name', 'chat');
foreach ($chats as $chat) {
$event = NULL;
$event->name = addslashes($chat->name);
$event->description = addslashes($chat->intro);
$event->timestart = $chat->chattime;
if ($event->id = get_field('event', 'id', 'modulename', 'chat', 'instance', $chat->id)) {
update_event($event);
} else {
$event->courseid = $chat->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'chat';
$event->instance = $chat->id;
$event->eventtype = $chat->schedule;
$event->timeduration = 0;
$event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $chat->id);
add_event($event);
}
}
return true;
}
示例7: chat_refresh_events
/**
* This standard function will check all instances of this module
* and make sure there are up-to-date events created for each of them.
* If courseid = 0, then every chat event in the site is checked, else
* only chat events belonging to the course specified are checked.
* This function is used, in its new format, by restore_refresh_events()
*
* @global object
* @param int $courseid
* @return bool
*/
function chat_refresh_events($courseid = 0)
{
global $DB;
if ($courseid) {
if (!($chats = $DB->get_records("chat", array("course" => $courseid)))) {
return true;
}
} else {
if (!($chats = $DB->get_records("chat"))) {
return true;
}
}
$moduleid = $DB->get_field('modules', 'id', array('name' => 'chat'));
foreach ($chats as $chat) {
$cm = get_coursemodule_from_id('chat', $chat->id);
$event = new object();
$event->name = $chat->name;
$event->description = format_module_intro('chat', $chat, $cm->id);
$event->timestart = $chat->chattime;
if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'chat', 'instance' => $chat->id))) {
update_event($event);
} else {
$event->courseid = $chat->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'chat';
$event->instance = $chat->id;
$event->eventtype = $chat->schedule;
$event->timeduration = 0;
$event->visible = $DB->get_field('course_modules', 'visible', array('module' => $moduleid, 'instance' => $chat->id));
add_event($event);
}
}
return true;
}
示例8: questionnaire_set_events
function questionnaire_set_events($questionnaire)
{
// Adding the questionnaire to the eventtable.
global $DB;
if ($events = $DB->get_records('event', array('modulename' => 'questionnaire', 'instance' => $questionnaire->id))) {
foreach ($events as $event) {
delete_event($event->id);
}
}
// The open-event.
$event = new stdClass();
$event->description = $questionnaire->name;
$event->courseid = $questionnaire->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'questionnaire';
$event->instance = $questionnaire->id;
$event->eventtype = 'open';
$event->timestart = $questionnaire->opendate;
$event->visible = instance_is_visible('questionnaire', $questionnaire);
$event->timeduration = $questionnaire->closedate - $questionnaire->opendate;
if ($questionnaire->closedate and $questionnaire->opendate and $event->timeduration <= QUESTIONNAIRE_MAX_EVENT_LENGTH) {
// Single event for the whole questionnaire.
$event->name = $questionnaire->name;
add_event($event);
} else {
// Separate start and end events.
$event->timeduration = 0;
if ($questionnaire->opendate) {
$event->name = $questionnaire->name . ' (' . get_string('questionnaireopens', 'questionnaire') . ')';
add_event($event);
unset($event->id);
// So we can use the same object for the close event.
}
if ($questionnaire->closedate) {
$event->name = $questionnaire->name . ' (' . get_string('questionnairecloses', 'questionnaire') . ')';
$event->timestart = $questionnaire->closedate;
$event->eventtype = 'close';
add_event($event);
}
}
}
示例9: turnitintool_refresh_events
/**
* This is a standard Moodle module that checks to make sure there are events for each activity
*
* @param var $courseid The ID of the course this activity belongs to (default 0 for all courses)
* @return bool success
*/
function turnitintool_refresh_events($courseid = 0)
{
if ($courseid == 0) {
if (!($turnitintools = turnitintool_get_records("turnitintool"))) {
$result = true;
}
} else {
if (!($turnitintools = turnitintool_get_records("turnitintool", "course", $courseid))) {
$result = true;
}
}
$module = turnitintool_get_records_select('modules', "name='turnitintool'", NULL, 'id');
$moduleid = current(array_keys($module));
foreach ($turnitintools as $turnitintool) {
$event = new stdClass();
$event->description = $turnitintool->intro;
if (!($parts = turnitintool_get_records("turnitintool_parts", "turnitintoolid", $turnitintool->id))) {
$result = false;
}
foreach ($parts as $part) {
$event->timestart = $part->dtdue;
if ($events = turnitintool_get_record_select('event', "modulename='turnitintool' AND instance=" . $turnitintool->id . " AND name='" . $turnitintool->name . " - " . $part->partname . "'")) {
$event->id = $events->id;
if (method_exists('calendar_event', 'update')) {
$calendarevent = calendar_event::load($event->id);
$calendarevent->update($event);
} else {
update_event($event);
}
} else {
$event->courseid = $turnitintool->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'turnitintool';
$event->instance = $turnitintool->id;
$event->eventtype = 'due';
$event->timeduration = 0;
$event->name = $turnitintool->name . ' - ' . $part->partname;
$coursemodule = turnitintool_get_record('course_modules', 'module', $moduleid, 'instance', $turnitintool->id);
$event->visible = $coursemodule->visible;
if (method_exists('calendar_event', 'create')) {
calendar_event::create($event);
} else {
add_event($event);
}
}
}
$result = true;
}
return $result;
}
示例10: save_event
/**
*
* Adds an event to the calendar of a user
* @param object $event a object containing details of an event tot be saved into a users calendar
*/
function save_event($event)
{
//we can not user add_event in moodle 2.0 as it requires the user to have persmissions to add events to the
//calendar however this capability check can be bypassed if we use the calendar event class so we will use add_event in
//1.9 and calendar_event class in 2.0
global $CFG, $USER;
if (stripos($CFG->release, "2.") !== false) {
require_once $CFG->dirroot . '/calendar/lib.php';
$calevent = new calendar_event($event);
$calevent->update($event, false);
if ($calevent !== false) {
return $calevent->id;
}
} else {
return add_event($event);
}
}
示例11: feedback_restore_mods
function feedback_restore_mods($mod, $restore)
{
global $CFG;
// $allValues = array();
// $allTrackings = array();
$status = true;
$restore_userdata = restore_userdata_selected($restore, 'feedback', $mod->id);
//Get record from backup_ids
$data = backup_getid($restore->backup_unique_code, $mod->modtype, $mod->id);
if ($data) {
//Now get completed xmlized object
$info = $data->info;
//check of older backupversion of feedback
$version = intval(backup_todb($info['MOD']['#']['VERSION']['0']['#']));
//Now, build the feedback record structure
$feedback->course = $restore->course_id;
$feedback->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$feedback->summary = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']);
$feedback->anonymous = backup_todb($info['MOD']['#']['ANONYMOUS']['0']['#']);
$feedback->email_notification = backup_todb($info['MOD']['#']['EMAILNOTIFICATION']['0']['#']);
$feedback->multiple_submit = backup_todb($info['MOD']['#']['MULTIPLESUBMIT']['0']['#']);
$feedback->autonumbering = backup_todb($info['MOD']['#']['AUTONUMBERING']['0']['#']);
$feedback->page_after_submit = backup_todb($info['MOD']['#']['PAGEAFTERSUB']['0']['#']);
$feedback->site_after_submit = backup_todb($info['MOD']['#']['SITEAFTERSUB']['0']['#']);
$feedback->publish_stats = backup_todb($info['MOD']['#']['PUBLISHSTATS']['0']['#']);
$feedback->timeopen = backup_todb($info['MOD']['#']['TIMEOPEN']['0']['#']);
$feedback->timeclose = backup_todb($info['MOD']['#']['TIMECLOSE']['0']['#']);
$feedback->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//The structure is equal to the db, so insert the feedback
$newid = insert_record("feedback", $feedback);
//create events
// the open-event
if ($feedback->timeopen > 0) {
$event = NULL;
$event->name = get_string('start', 'feedback') . ' ' . $feedback->name;
$event->description = $feedback->summary;
$event->courseid = $feedback->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'feedback';
$event->instance = $newid;
$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;
}
add_event($event);
}
// the close-event
if ($feedback->timeclose > 0) {
$event = NULL;
$event->name = get_string('stop', 'feedback') . ' ' . $feedback->name;
$event->description = $feedback->summary;
$event->courseid = $feedback->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'feedback';
$event->instance = $newid;
$event->eventtype = 'close';
$event->timestart = $feedback->timeclose;
$event->visible = instance_is_visible('feedback', $feedback);
$event->timeduration = 0;
add_event($event);
}
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<ul><li>" . get_string("modulename", "feedback") . " \"" . $feedback->name . "\"<br />";
}
backup_flush(300);
if ($newid) {
//Now, build the feedback_item record structure
$items = $info['MOD']['#']['ITEMS']['0']['#']['ITEM'];
for ($i = 0; $i < sizeof($items); $i++) {
$item_info = $items[$i];
$item->feedback = $newid;
$item->template = 0;
$item->name = backup_todb($item_info['#']['NAME']['0']['#']);
$item->presentation = backup_todb($item_info['#']['PRESENTATION']['0']['#']);
$item->presentation = str_replace("\n", '', $item->presentation);
if ($version >= 1) {
$item->typ = backup_todb($item_info['#']['TYP']['0']['#']);
$item->hasvalue = backup_todb($item_info['#']['HASVALUE']['0']['#']);
switch ($item->typ) {
case 'radio':
$item->typ = 'multichoice';
$item->presentation = 'r' . FEEDBACK_MULTICHOICERESTORE_TYPE_SEP . $item->presentation;
break;
case 'check':
$item->typ = 'multichoice';
$item->presentation = 'c' . FEEDBACK_MULTICHOICERESTORE_TYPE_SEP . $item->presentation;
break;
case 'dropdown':
$item->typ = 'multichoice';
$item->presentation = 'd' . FEEDBACK_MULTICHOICERESTORE_TYPE_SEP . $item->presentation;
break;
case 'radiorated':
$item->typ = 'multichoicerated';
//.........这里部分代码省略.........
示例12: wwassignment_refresh_events
function wwassignment_refresh_events($courseid = 0)
{
error_log('wwassignment_refresh_events called');
if ($courseid == 0) {
if (!($wwassignment = get_records('wwassignment'))) {
return true;
}
} else {
if (!($wwassignment = get_records('wwassignment', 'course', $courseid))) {
return true;
}
}
$moduleid = get_field('modules', 'id', 'name', 'wwassignment');
foreach ($wwassignment as $wwassignment) {
$event = NULL;
$event->name = addslashes($wwassignment->name);
$event->description = addslashes($wwassignment->description);
$event->timestart = $wwassignment->timedue;
if ($event->id = get_field('event', 'id', 'modulename', 'wwassignment', 'instance', $wwassignment->id)) {
update_event($event);
} else {
$event->courseid = $wwassignment->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'wwassignment';
$event->instance = $wwassignment->id;
$event->eventtype = 'due';
$event->timeduration = 0;
$event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $wwassignment->id);
add_event($event);
}
}
return true;
}
示例13: mediaboard_refresh_events
/**
* Make sure up-to-date events are created for all mediaboard instances
*
* This standard function will check all instances of this module
* and make sure there are up-to-date events created for each of them.
* If courseid = 0, then every mediaboard event in the site is checked, else
* only mediaboard events belonging to the course specified are checked.
* This function is used, in its new format, by restore_refresh_events()
*
* @param $courseid int optional If zero then all mediaboards for all courses are covered
* @return boolean Always returns true
*/
function mediaboard_refresh_events($courseid = 0)
{
global $DB;
if ($courseid == 0) {
if (!($mediaboards = $DB->get_records("mediaboard"))) {
return true;
}
} else {
if (!($mediaboards = $DB->get_records("mediaboard", array("course" => $courseid)))) {
return true;
}
}
$moduleid = $DB->get_field('modules', 'id', array('name' => 'mediaboard'));
foreach ($mediaboards as $mediaboard) {
$cm = get_coursemodule_from_id('mediaboard', $mediaboard->id);
$event = new stdClass();
$event->name = $mediaboard->name;
$event->description = format_module_intro('mediaboard', $mediaboard, $cm->id);
$event->timestart = $mediaboard->timedue;
if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'mediaboard', 'instance' => $mediaboard->id))) {
update_event($event);
} else {
$event->courseid = $mediaboard->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'mediaboard';
$event->instance = $mediaboard->id;
$event->eventtype = 'due';
$event->timeduration = 0;
$event->visible = $DB->get_field('course_modules', 'visible', array('module' => $moduleid, 'instance' => $mediaboard->id));
add_event($event);
}
}
return true;
}
示例14: mysqli_real_escape_string
<?php
include 'config/db.php';
include 'libraries/events.php';
include 'libraries/general.php';
$device_id = mysqli_real_escape_string($conn, $_GET['device_id']);
if (ctype_digit($device_id) && !empty($device_id)) {
$sql = "DELETE FROM `devices` WHERE `device_id`='{$device_id}'";
if ($conn->query($sql) === TRUE) {
//set success message
$device_label = get_device_label_from_id($device_id);
$event_type = "Device Removed";
$event_message = "Device {$device_label} was removed";
$event_status = "Complete";
add_event($event_type, $event_message, $event_status);
$_SESSION['success'] = "Success, device removed.";
} else {
//set error message
$_SESSION['error'] = "Error, device not removed.";
}
//redirect back to where we came from
$referrer = $_SESSION['referrer'];
unset($_SESSION['referrer']);
//clear session var
header("Location: {$referrer}");
//redirect!
}
示例15: session_start
<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<?php
include 'header.php';
if (isset($_POST['addBook'])) {
add_book();
} elseif (isset($_POST['deleteBook'])) {
delete_book();
} elseif (isset($_POST['addEvent'])) {
add_event();
} elseif (isset($_POST['deleteEvent'])) {
delete_event();
} elseif (isset($_POST['uploadNewsletter'])) {
upload_newsletter();
} elseif (isset($_POST['deleteNewsletter'])) {
delete_newsletter();
} elseif (isset($_POST['uploadReport'])) {
upload_report();
} elseif (isset($_POST['deleteReport'])) {
delete_report();
} else {
echo "Error: Please submit changes to the site first.";
}
// TODO: If logged_user is the admin user, then this page will be available as a link
// TODO: Add following forms:
// ADD/DELETE Books/Events Form