本文整理汇总了PHP中calendar_event::toggle_visibility方法的典型用法代码示例。如果您正苦于以下问题:PHP calendar_event::toggle_visibility方法的具体用法?PHP calendar_event::toggle_visibility怎么用?PHP calendar_event::toggle_visibility使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calendar_event
的用法示例。
在下文中一共展示了calendar_event::toggle_visibility方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_coursemodule_visible
/**
* Set the visibility of a module and inherent properties.
*
* Note: Do not forget to trigger the event \core\event\course_module_updated as it needs
* to be triggered manually, refer to {@link \core\event\course_module_updated::create_from_cm()}.
*
* From 2.4 the parameter $prevstateoverrides has been removed, the logic it triggered
* has been moved to {@link set_section_visible()} which was the only place from which
* the parameter was used.
*
* @param int $id of the module
* @param int $visible state of the module
* @return bool false when the module was not found, true otherwise
*/
function set_coursemodule_visible($id, $visible)
{
global $DB, $CFG;
require_once $CFG->libdir . '/gradelib.php';
require_once $CFG->dirroot . '/calendar/lib.php';
// Trigger developer's attention when using the previously removed argument.
if (func_num_args() > 2) {
debugging('Wrong number of arguments passed to set_coursemodule_visible(), $prevstateoverrides
has been removed.', DEBUG_DEVELOPER);
}
if (!($cm = $DB->get_record('course_modules', array('id' => $id)))) {
return false;
}
// Create events and propagate visibility to associated grade items if the value has changed.
// Only do this if it's changed to avoid accidently overwriting manual showing/hiding of student grades.
if ($cm->visible == $visible) {
return true;
}
if (!($modulename = $DB->get_field('modules', 'name', array('id' => $cm->module)))) {
return false;
}
if ($events = $DB->get_records('event', array('instance' => $cm->instance, 'modulename' => $modulename))) {
foreach ($events as $event) {
if ($visible) {
$event = new calendar_event($event);
$event->toggle_visibility(true);
} else {
$event = new calendar_event($event);
$event->toggle_visibility(false);
}
}
}
// Updating visible and visibleold to keep them in sync. Only changing a section visibility will
// affect visibleold to allow for an original visibility restore. See set_section_visible().
$cminfo = new stdClass();
$cminfo->id = $id;
$cminfo->visible = $visible;
$cminfo->visibleold = $visible;
$DB->update_record('course_modules', $cminfo);
// Hide the associated grade items so the teacher doesn't also have to go to the gradebook and hide them there.
// Note that this must be done after updating the row in course_modules, in case
// the modules grade_item_update function needs to access $cm->visible.
if (plugin_supports('mod', $modulename, FEATURE_CONTROLS_GRADE_VISIBILITY) && component_callback_exists('mod_' . $modulename, 'grade_item_update')) {
$instance = $DB->get_record($modulename, array('id' => $cm->instance), '*', MUST_EXIST);
component_callback('mod_' . $modulename, 'grade_item_update', array($instance));
} else {
$grade_items = grade_item::fetch_all(array('itemtype' => 'mod', 'itemmodule' => $modulename, 'iteminstance' => $cm->instance, 'courseid' => $cm->course));
if ($grade_items) {
foreach ($grade_items as $grade_item) {
$grade_item->set_hidden(!$visible);
}
}
}
rebuild_course_cache($cm->course, true);
return true;
}
示例2: show_event
/**
* Call this function to unhide 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 true
*/
function show_event($event) {
global $CFG;
require_once($CFG->dirroot.'/calendar/lib.php');
$event = new calendar_event($event);
return $event->toggle_visibility(true);
}
示例3: show_event
/**
* Call this function to unhide 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 true
* @deprecated please use calendar_event->toggle_visibility(true) instead.
* @todo final deprecation of this function in MDL-40607
*/
function show_event($event)
{
global $CFG;
require_once $CFG->dirroot . '/calendar/lib.php';
debugging('show_event() is deprecated, please use calendar_event->toggle_visibility(true) instead.', DEBUG_DEVELOPER);
$event = new calendar_event($event);
return $event->toggle_visibility(true);
}