本文整理汇总了PHP中instance_is_visible函数的典型用法代码示例。如果您正苦于以下问题:PHP instance_is_visible函数的具体用法?PHP instance_is_visible怎么用?PHP instance_is_visible使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了instance_is_visible函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: glossary_rss_feeds
function glossary_rss_feeds()
{
global $CFG;
$status = true;
//Check CFG->enablerssfeeds
if (empty($CFG->enablerssfeeds)) {
debugging("DISABLED (admin variables)");
//Check CFG->glossary_enablerssfeeds
} else {
if (empty($CFG->glossary_enablerssfeeds)) {
debugging("DISABLED (module configuration)");
//It's working so we start...
} else {
//Iterate over all glossaries
if ($glossaries = get_records("glossary")) {
foreach ($glossaries as $glossary) {
if (!empty($glossary->rsstype) && !empty($glossary->rssarticles) && $status) {
$filename = rss_file_name('glossary', $glossary);
// RSS file
//First let's make sure there is work to do by checking existing files
if (file_exists($filename)) {
if ($lastmodified = filemtime($filename)) {
if (!glossary_rss_newstuff($glossary, $lastmodified)) {
continue;
}
}
}
//Ignore hidden forums
if (!instance_is_visible('glossary', $glossary)) {
if (file_exists($filename)) {
@unlink($filename);
}
continue;
}
mtrace("Updating RSS feed for " . format_string($glossary->name, true) . ", ID: {$glossary->id}");
//Get the XML contents
$result = glossary_rss_feed($glossary);
//Save the XML contents to file
if (!empty($result)) {
$status = rss_save_file("glossary", $glossary, $result);
}
//Some debug...
if (debugging()) {
if (empty($result)) {
echo "ID: {$glossary->id}-> (empty) ";
} else {
if (!empty($status)) {
echo "ID: {$glossary->id}-> OK ";
} else {
echo "ID: {$glossary->id}-> FAIL ";
}
}
}
}
}
}
}
}
return $status;
}
示例2: lightboxgallery_rss_feeds
function lightboxgallery_rss_feeds()
{
global $CFG;
$status = true;
if (!$CFG->enablerssfeeds) {
debugging('DISABLED (admin variables)');
} else {
if (!get_config('lightboxgallery', 'enablerssfeeds')) {
debugging('DISABLED (module configuration)');
} else {
if ($galleries = get_records('lightboxgallery')) {
foreach ($galleries as $gallery) {
if ($gallery->rss && $status) {
$filename = rss_file_name('lightboxgallery', $gallery);
if (file_exists($filename)) {
if ($lastmodified = filemtime($filename)) {
if ($lastmodified > time() - HOURSECS) {
continue;
}
}
}
if (!instance_is_visible('lightboxgallery', $gallery)) {
if (file_exists($filename)) {
@unlink($filename);
}
continue;
}
mtrace('Updating RSS feed for ' . format_string($gallery->name, true) . ', ID: ' . $gallery->id);
$result = lightboxgallery_rss_feed($gallery);
if (!empty($result)) {
$status = rss_save_file('lightboxgallery', $gallery, $result);
}
if (debugging()) {
if (empty($result)) {
echo 'ID: ' . $gallery->id . '-> (empty) ';
} else {
if (!empty($status)) {
echo 'ID: ' . $gallery->id . '-> OK ';
} else {
echo 'ID: ' . $gallery->id . '-> FAIL ';
}
}
}
}
}
}
}
}
return $status;
}
示例3: wiki_print_recent_activity
function wiki_print_recent_activity($course, $isteacher, $timestart)
{
/// Given a course and a time, this module should find recent activity
/// that has occurred in wiki activities and print it out.
/// Return true if there was output, or false is there was none.
global $CFG;
$sql = "SELECT l.*, cm.instance FROM {$CFG->prefix}log l \n INNER JOIN {$CFG->prefix}course_modules cm ON l.cmid = cm.id \n WHERE l.time > '{$timestart}' AND l.course = {$course->id} \n AND l.module = 'wiki' AND action LIKE 'edit%'\n ORDER BY l.time ASC";
if (!($logs = get_records_sql($sql))) {
return false;
}
foreach ($logs as $log) {
//Create a temp valid module structure (course,id)
$tempmod = new Object();
$tempmod->course = $log->course;
$tempmod->id = $log->instance;
//Obtain the visible property from the instance
$modvisible = instance_is_visible($log->module, $tempmod);
//Only if the mod is visible
if ($modvisible) {
$wikis[$log->info] = wiki_log_info($log);
$wikis[$log->info]->pagename = $log->info;
$wikis[$log->info]->time = $log->time;
$wikis[$log->info]->url = str_replace('&', '&', $log->url);
}
}
if (isset($wikis)) {
$content = true;
print_headline(get_string('updatedwikipages', 'wiki') . ':', 3);
foreach ($wikis as $wiki) {
print_recent_activity_note($wiki->time, $wiki, $wiki->pagename, $CFG->wwwroot . '/mod/wiki/' . $wiki->url);
}
}
return true;
// True if anything was printed, otherwise false
}
示例4: assignment_print_recent_activity
/**
* Print recent activity from all assignments in a given course
*
* This is used by the recent activity block
*/
function assignment_print_recent_activity($course, $isteacher, $timestart)
{
global $CFG;
$content = false;
$assignments = array();
if (!($logs = get_records_select('log', 'time > \'' . $timestart . '\' AND ' . 'course = \'' . $course->id . '\' AND ' . 'module = \'assignment\' AND ' . 'action = \'upload\' ', 'time ASC'))) {
return false;
}
foreach ($logs as $log) {
//Create a temp valid module structure (course,id)
$tempmod = new object();
$tempmod->course = $log->course;
$tempmod->id = $log->info;
//Obtain the visible property from the instance
$modvisible = instance_is_visible($log->module, $tempmod);
//Only if the mod is visible
if ($modvisible) {
if ($info = assignment_log_info($log)) {
$assignments[$log->info] = $info;
$assignments[$log->info]->time = $log->time;
$assignments[$log->info]->url = str_replace('&', '&', $log->url);
}
}
}
if (!empty($assignments)) {
print_headline(get_string('newsubmissions', 'assignment') . ':');
foreach ($assignments as $assignment) {
print_recent_activity_note($assignment->time, $assignment, $assignment->name, $CFG->wwwroot . '/mod/assignment/' . $assignment->url);
}
$content = true;
}
return $content;
}
示例5: array_unshift
$learningtable->align[] = 'center';
}
/// Now let's process the learning forums
if ($course->id != SITEID) {
// Only real courses have learning forums
// Add extra field for section number, at the front
if ($course->format == 'weeks' or $course->format == 'weekscss') {
array_unshift($learningtable->head, $strweek);
} else {
array_unshift($learningtable->head, $strsection);
}
array_unshift($learningtable->align, "center");
if ($learningforums) {
$currentsection = "";
foreach ($learningforums as $key => $forum) {
$forum->visible = instance_is_visible("forum", $forum) || has_capability('moodle/course:view', $coursecontext);
$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!groups_course_module_visible($cm)) {
continue;
}
$currentgroup = groups_get_activity_group($cm);
$groupmode = groups_get_activity_groupmode($cm);
$cantaccessagroup = $groupmode and !has_capability('moodle/site:accessallgroups', $context) and !mygroupid($course->id);
if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
$count = count_records("forum_discussions", "forum", "{$forum->id}", "groupid", $currentgroup);
} else {
$count = count_records("forum_discussions", "forum", "{$forum->id}");
}
if ($usetracking) {
if ($forum->trackingtype == FORUM_TRACKING_ON || !isset($untracked[$forum->id])) {
示例6: 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();
}
}
示例7: chat_print_recent_activity
function chat_print_recent_activity($course, $isteacher, $timestart)
{
/// Given a course and a date, prints a summary of all chat rooms
/// that currently have people in them.
/// This function is called from course/lib.php: print_recent_activity()
global $CFG;
$timeold = time() - $CFG->chat_old_ping;
$lastpingsearch = $CFG->chat_method == 'sockets' ? '' : 'AND cu.lastping > \'' . $timeold . '\'';
if (!($chatusers = get_records_sql("SELECT u.id, cu.chatid, u.firstname, u.lastname\n FROM {$CFG->prefix}chat_users cu,\n {$CFG->prefix}chat ch,\n {$CFG->prefix}user u\n WHERE cu.userid = u.id\n AND cu.chatid = ch.id {$lastpingsearch}\n AND ch.course = '{$course->id}'\n ORDER BY cu.chatid ASC"))) {
return false;
}
$outputstarted = false;
$current = 0;
foreach ($chatusers as $chatuser) {
if ($current != $chatuser->chatid) {
if ($current) {
echo '</ul></div>';
// room
$current = 0;
}
if ($chat = get_record('chat', 'id', $chatuser->chatid)) {
// we find the course module id
$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
// needs to be fixed
if (!(has_capability('mod/chat:readlog', $context) or instance_is_visible('chat', $chat))) {
// Chat hidden to students
continue;
}
if (!$outputstarted) {
print_headline(get_string('currentchats', 'chat') . ':');
$outputstarted = true;
}
echo '<div class="room"><p class="head"><a href="' . $CFG->wwwroot . '/mod/chat/view.php?c=' . $chat->id . '">' . format_string($chat->name, true) . '</a></p><ul>';
}
$current = $chatuser->chatid;
}
$fullname = fullname($chatuser, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id)));
echo '<li class="info name">' . $fullname . '</li>';
}
if ($current) {
echo '</ul></div>';
// room
}
return true;
}
示例8: vpl_cron
/**
* Run periodically to check for vpl visibility update
*
* @uses $CFG
* @return boolean
**/
function vpl_cron()
{
global $DB;
$rebuilds = array();
$now = time();
$sql = 'SELECT id, startdate, duedate, course, name
FROM {vpl}
WHERE startdate > ?
and startdate <= ?
and (duedate > ? or duedate = 0)';
$parms = array($now - 2 * 3600, $now, $now);
$vpls = $DB->get_records_sql($sql, $parms);
foreach ($vpls as $instance) {
if (!instance_is_visible(VPL, $instance)) {
$vpl = new mod_vpl(null, $instance->id);
echo 'Setting visible "' . s($vpl->get_printable_name()) . '"';
$cm = $vpl->get_course_module();
$rebuilds[$cm->id] = $cm;
}
}
foreach ($rebuilds as $cmid => $cm) {
set_coursemodule_visible($cm->id, true);
rebuild_course_cache($cm->course);
}
return true;
}
示例9: lesson_update_events
/**
* This function updates the events associated to the lesson.
* If $override is non-zero, then it updates only the events
* associated with the specified override.
*
* @uses LESSON_MAX_EVENT_LENGTH
* @param object $lesson the lesson object.
* @param object $override (optional) limit to a specific override
*/
function lesson_update_events($lesson, $override = null)
{
global $CFG, $DB;
require_once $CFG->dirroot . '/calendar/lib.php';
// Load the old events relating to this lesson.
$conds = array('modulename' => 'lesson', 'instance' => $lesson->id);
if (!empty($override)) {
// Only load events for this override.
if (isset($override->userid)) {
$conds['userid'] = $override->userid;
} else {
$conds['groupid'] = $override->groupid;
}
}
$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 lesson, so we
// need to add all the overrides.
$overrides = $DB->get_records('lesson_overrides', array('lessonid' => $lesson->id));
// As well as the original lesson (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;
$available = isset($current->available) ? $current->available : $lesson->available;
$deadline = isset($current->deadline) ? $current->deadline : $lesson->deadline;
// Only add open/close events for an override if they differ from the lesson default.
$addopen = empty($current->id) || !empty($current->available);
$addclose = empty($current->id) || !empty($current->deadline);
if (!empty($lesson->coursemodule)) {
$cmid = $lesson->coursemodule;
} else {
$cmid = get_coursemodule_from_instance('lesson', $lesson->id, $lesson->course)->id;
}
$event = new stdClass();
$event->description = format_module_intro('lesson', $lesson, $cmid);
// Events module won't show user events when the courseid is nonzero.
$event->courseid = $userid ? 0 : $lesson->course;
$event->groupid = $groupid;
$event->userid = $userid;
$event->modulename = 'lesson';
$event->instance = $lesson->id;
$event->timestart = $available;
$event->timeduration = max($deadline - $available, 0);
$event->visible = instance_is_visible('lesson', $lesson);
$event->eventtype = 'open';
// Determine the event name.
if ($groupid) {
$params = new stdClass();
$params->lesson = $lesson->name;
$params->group = groups_get_group_name($groupid);
if ($params->group === false) {
// Group doesn't exist, just skip it.
continue;
}
$eventname = get_string('overridegroupeventname', 'lesson', $params);
} else {
if ($userid) {
$params = new stdClass();
$params->lesson = $lesson->name;
$eventname = get_string('overrideusereventname', 'lesson', $params);
} else {
$eventname = $lesson->name;
}
}
if ($addopen or $addclose) {
if ($deadline and $available and $event->timeduration <= LESSON_MAX_EVENT_LENGTH) {
// Single event for the whole lesson.
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 ($available && $addopen) {
if ($oldevent = array_shift($oldevents)) {
$event->id = $oldevent->id;
} else {
unset($event->id);
}
$event->name = $eventname . ' (' . get_string('lessonopens', 'lesson') . ')';
//.........这里部分代码省略.........
示例10: qcreate_after_add_or_update
/**
* This function is called at the end of qcreate_add_instance
* and qcreate_update_instance, to do the common processing.
*
* @param object $qcreate the qcreate object.
*/
function qcreate_after_add_or_update($qcreate)
{
global $COURSE;
// Update the events relating to this qcreate.
// 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 = 'qcreate' and instance = '{$qcreate->id}'")) {
foreach ($events as $event) {
delete_event($event->id);
}
}
$event = new stdClass();
$event->description = $qcreate->intro;
$event->courseid = $qcreate->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'qcreate';
$event->instance = $qcreate->id;
$event->timestart = $qcreate->timeopen;
$event->timeduration = $qcreate->timeclose - $qcreate->timeopen;
$event->visible = instance_is_visible('qcreate', $qcreate);
$event->eventtype = 'open';
if ($qcreate->timeclose and $qcreate->timeopen and $event->timeduration <= QCREATE_MAX_EVENT_LENGTH) {
// Single event for the whole qcreate.
$event->name = $qcreate->name;
add_event($event);
} else {
// Separate start and end events.
$event->timeduration = 0;
if ($qcreate->timeopen) {
$event->name = $qcreate->name . ' (' . get_string('qcreateopens', 'qcreate') . ')';
add_event($event);
unset($event->id);
// So we can use the same object for the close event.
}
if ($qcreate->timeclose) {
$event->name = $qcreate->name . ' (' . get_string('qcreatecloses', 'qcreate') . ')';
$event->timestart = $qcreate->timeclose;
$event->eventtype = 'close';
add_event($event);
}
}
//update related grade item
qcreate_grade_item_update(stripslashes_recursive($qcreate));
}
示例11: lesson_update_instance
function lesson_update_instance($lesson)
{
/// Given an object containing all the necessary data,
/// (defined by the form in mod.html) this function
/// will update an existing instance with new data.
$lesson->timemodified = time();
$lesson->id = $lesson->instance;
if (empty($lesson->timespent) or !is_numeric($lesson->timespent) or $lesson->timespent < 0) {
$lesson->timespent = 0;
}
if (!isset($lesson->completed)) {
$lesson->completed = 0;
}
if (empty($lesson->gradebetterthan) or !is_numeric($lesson->gradebetterthan) or $lesson->gradebetterthan < 0) {
$lesson->gradebetterthan = 0;
} else {
if ($lesson->gradebetterthan > 100) {
$lesson->gradebetterthan = 100;
}
}
// conditions for dependency
$conditions = new stdClass();
$conditions->timespent = $lesson->timespent;
$conditions->completed = $lesson->completed;
$conditions->gradebetterthan = $lesson->gradebetterthan;
$lesson->conditions = addslashes(serialize($conditions));
unset($lesson->timespent);
unset($lesson->completed);
unset($lesson->gradebetterthan);
if (!empty($lesson->password)) {
$lesson->password = md5($lesson->password);
} else {
unset($lesson->password);
}
if ($lesson->lessondefault) {
$default = new stdClass();
$default = clone $lesson;
unset($default->lessondefault);
unset($default->name);
unset($default->timemodified);
unset($default->available);
unset($default->deadline);
if ($default->id = get_field("lesson_default", "id", "course", $default->course)) {
update_record("lesson_default", $default);
} else {
insert_record("lesson_default", $default);
}
} else {
unset($lesson->lessondefault);
}
// update the calendar events (credit goes to quiz module)
if ($events = get_records_select('event', "modulename = 'lesson' and instance = '{$lesson->id}'")) {
foreach ($events as $event) {
delete_event($event->id);
}
}
$event = new stdClass();
$event->name = $lesson->name;
$event->description = $lesson->name;
$event->courseid = $lesson->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'lesson';
$event->instance = $lesson->id;
$event->eventtype = 'open';
$event->timestart = $lesson->available;
$event->visible = instance_is_visible('lesson', $lesson);
$event->timeduration = $lesson->deadline - $lesson->available;
if ($event->timeduration > LESSON_MAX_EVENT_LENGTH) {
/// Long durations create two events
$event2 = clone $event;
$event->name .= ' (' . get_string('lessonopens', 'lesson') . ')';
$event->timeduration = 0;
$event2->timestart = $lesson->deadline;
$event2->eventtype = 'close';
$event2->timeduration = 0;
$event2->name .= ' (' . get_string('lessoncloses', 'lesson') . ')';
add_event($event2);
}
add_event($event);
return update_record("lesson", $lesson);
}
示例12: 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 {
//.........这里部分代码省略.........
示例13: forum_menu_list
/**
* @todo Document this function
*/
function forum_menu_list($course)
{
$menu = array();
$currentgroup = get_and_set_current_group($course, groupmode($course));
if ($forums = get_all_instances_in_course("forum", $course)) {
if ($course->format == 'weeks') {
$strsection = get_string('week');
} else {
$strsection = get_string('topic');
}
foreach ($forums as $forum) {
if ($cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!isset($forum->visible)) {
if (!instance_is_visible("forum", $forum) && !has_capability('moodle/course:viewhiddenactivities', $context)) {
continue;
}
}
$groupmode = groupmode($course, $cm);
// Groups are being used
if ($groupmode == SEPARATEGROUPS && $currentgroup === false && !has_capability('moodle/site:accessallgroups', $context)) {
continue;
}
}
$menu[$forum->id] = format_string($forum->name, true);
}
}
return $menu;
}
示例14: data_set_events
/**
* This creates new calendar events given as timeavailablefrom and timeclose by $data.
*
* @param stdClass $data
* @return void
*/
function data_set_events($data)
{
global $DB, $CFG;
require_once $CFG->dirroot . '/calendar/lib.php';
// Get CMID if not sent as part of $data.
if (!isset($data->coursemodule)) {
$cm = get_coursemodule_from_instance('data', $data->id, $data->course);
$data->coursemodule = $cm->id;
}
// Data start calendar events.
$event = new stdClass();
if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'data', 'instance' => $data->id, 'eventtype' => 'open'))) {
if ($data->timeavailablefrom > 0) {
// Calendar event exists so update it.
$event->name = get_string('calendarstart', 'data', $data->name);
$event->description = format_module_intro('data', $data, $data->coursemodule);
$event->timestart = $data->timeavailablefrom;
$event->visible = instance_is_visible('data', $data);
$event->timeduration = 0;
$calendarevent = calendar_event::load($event->id);
$calendarevent->update($event);
} else {
// Calendar event is on longer needed.
$calendarevent = calendar_event::load($event->id);
$calendarevent->delete();
}
} else {
// Event doesn't exist so create one.
if (isset($data->timeavailablefrom) && $data->timeavailablefrom > 0) {
$event->name = get_string('calendarstart', 'data', $data->name);
$event->description = format_module_intro('data', $data, $data->coursemodule);
$event->courseid = $data->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'data';
$event->instance = $data->id;
$event->eventtype = 'open';
$event->timestart = $data->timeavailablefrom;
$event->visible = instance_is_visible('data', $data);
$event->timeduration = 0;
calendar_event::create($event);
}
}
// Data end calendar events.
$event = new stdClass();
if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'data', 'instance' => $data->id, 'eventtype' => 'close'))) {
if ($data->timeavailableto > 0) {
// Calendar event exists so update it.
$event->name = get_string('calendarend', 'data', $data->name);
$event->description = format_module_intro('data', $data, $data->coursemodule);
$event->timestart = $data->timeavailableto;
$event->visible = instance_is_visible('data', $data);
$event->timeduration = 0;
$calendarevent = calendar_event::load($event->id);
$calendarevent->update($event);
} else {
// Calendar event is on longer needed.
$calendarevent = calendar_event::load($event->id);
$calendarevent->delete();
}
} else {
// Event doesn't exist so create one.
if (isset($data->timeavailableto) && $data->timeavailableto > 0) {
$event = new stdClass();
$event->name = get_string('calendarend', 'data', $data->name);
$event->description = format_module_intro('data', $data, $data->coursemodule);
$event->courseid = $data->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'data';
$event->instance = $data->id;
$event->eventtype = 'close';
$event->timestart = $data->timeavailableto;
$event->visible = instance_is_visible('data', $data);
$event->timeduration = 0;
calendar_event::create($event);
}
}
}
示例15: booking_update_options
function booking_update_options($optionvalues)
{
global $DB, $CFG;
require_once "{$CFG->dirroot}/mod/booking/locallib.php";
$bokingUtils = new booking_utils();
$booking = $DB->get_record('booking', array('id' => $optionvalues->bookingid));
$option = new stdClass();
$option->bookingid = $optionvalues->bookingid;
$option->text = trim($optionvalues->text);
$option->conectedoption = $optionvalues->conectedoption;
$option->howmanyusers = $optionvalues->howmanyusers;
$option->removeafterminutes = $optionvalues->removeafterminutes;
$option->notificationtext = $optionvalues->notificationtext;
$option->disablebookingusers = $optionvalues->disablebookingusers;
$option->sent = 0;
$option->location = trim($optionvalues->location);
$option->institution = trim($optionvalues->institution);
$option->address = trim($optionvalues->address);
$option->daystonotify = $optionvalues->daystonotify;
$option->pollurl = $optionvalues->pollurl;
$option->pollurlteachers = $optionvalues->pollurlteachers;
if ($optionvalues->limitanswers == 0) {
$option->limitanswers = 0;
$option->maxanswers = 0;
$option->maxoverbooking = 0;
} else {
$option->maxanswers = $optionvalues->maxanswers;
$option->maxoverbooking = $optionvalues->maxoverbooking;
$option->limitanswers = 1;
}
if (isset($optionvalues->restrictanswerperiod)) {
$option->bookingclosingtime = $optionvalues->bookingclosingtime;
} else {
$option->bookingclosingtime = 0;
}
$option->courseid = $optionvalues->courseid;
if (isset($optionvalues->startendtimeknown)) {
$option->coursestarttime = $optionvalues->coursestarttime;
$option->courseendtime = $optionvalues->courseendtime;
} else {
$option->coursestarttime = 0;
$option->courseendtime = 0;
}
$option->description = $optionvalues->description;
$option->limitanswers = $optionvalues->limitanswers;
$option->timemodified = time();
if (isset($optionvalues->optionid) && !empty($optionvalues->optionid) && $optionvalues->id != "add") {
//existing booking record
$option->id = $optionvalues->optionid;
if (isset($optionvalues->text) && $optionvalues->text != '') {
$event = new stdClass();
$event->id = $DB->get_field('booking_options', 'calendarid', array('id' => $option->id));
$groupid = $DB->get_field('booking_options', 'groupid', array('id' => $option->id));
$coursestarttime = $DB->get_field('booking_options', 'coursestarttime', array('id' => $option->id));
if ($coursestarttime != $optionvalues->coursestarttime) {
$option->sent = 0;
} else {
$option->sent = $DB->get_field('booking_options', 'sent', array('id' => $option->id));
}
$option->groupid = $bokingUtils->group($booking, $option);
$whereis = '';
if (strlen($option->location) > 0) {
$whereis = '<p>' . get_string('location', 'booking') . ': ' . $option->location . '</p>';
}
if ($event->id > 0) {
// event exist
if (isset($optionvalues->addtocalendar)) {
$event->name = $option->text;
$event->description = $option->description . $whereis;
$event->courseid = $option->courseid;
if ($option->courseid == 0) {
$event->courseid = $booking->course;
}
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'booking';
$event->instance = $option->bookingid;
$event->eventtype = 'booking';
$event->timestart = $option->coursestarttime;
$event->visible = instance_is_visible('booking', $booking);
$event->timeduration = $option->courseendtime - $option->coursestarttime;
if ($DB->record_exists("event", array('id' => $event->id))) {
$calendarevent = calendar_event::load($event->id);
$calendarevent->update($event);
$option->calendarid = $event->id;
$option->addtocalendar = $optionvalues->addtocalendar;
} else {
unset($event->id);
$tmpEvent = calendar_event::create($event);
$option->calendarid = $tmpEvent->id;
}
} else {
// Delete event if exist
$event = calendar_event::load($event->id);
$event->delete(true);
$option->addtocalendar = 0;
$option->calendarid = 0;
}
} else {
$option->addtocalendar = 0;
//.........这里部分代码省略.........