本文整理汇总了PHP中calendar_get_allowed_types函数的典型用法代码示例。如果您正苦于以下问题:PHP calendar_get_allowed_types函数的具体用法?PHP calendar_get_allowed_types怎么用?PHP calendar_get_allowed_types使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了calendar_get_allowed_types函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calendar_can_edit_subscription
/**
* Checks to see if the user can edit a given subscription feed.
*
* @param mixed $subscriptionorid Subscription object or id
* @return bool true if current user can edit the subscription else false
*/
function calendar_can_edit_subscription($subscriptionorid)
{
global $DB;
if (is_array($subscriptionorid)) {
$subscription = (object) $subscriptionorid;
} else {
if (is_object($subscriptionorid)) {
$subscription = $subscriptionorid;
} else {
$subscription = calendar_get_subscription($subscriptionorid);
}
}
$allowed = new stdClass();
$courseid = $subscription->courseid;
$groupid = $subscription->groupid;
calendar_get_allowed_types($allowed, $courseid);
switch ($subscription->eventtype) {
case 'user':
return $allowed->user;
case 'course':
if (isset($allowed->courses[$courseid])) {
return $allowed->courses[$courseid];
} else {
return false;
}
case 'site':
return $allowed->site;
case 'group':
if (isset($allowed->groups[$groupid])) {
return $allowed->groups[$groupid];
} else {
return false;
}
default:
return false;
}
}
示例2: calendar_user_can_add_event
/**
* see if user can add calendar entries at all
* used to print the "New Event" button
* @return bool
*/
function calendar_user_can_add_event()
{
calendar_get_allowed_types($allowed);
return (bool) ($allowed->user || $allowed->groups || $allowed->courses || $allowed->site);
}
示例3: get_string
$form->modulename = '';
$form->eventtype = '';
$form->instance = 0;
$form->timeduration = 0;
$form->duration = 0;
$form->repeat = 0;
$form->repeats = '';
$form->minutes = '';
$form->type = 'group';
$header = get_string('typegroup', 'calendar');
}
break;
case 'course':
$courseid = optional_param('courseid', 0, PARAM_INT);
if (!record_exists('course', 'id', $courseid)) {
calendar_get_allowed_types($allowed);
$eventtype = 'select';
} else {
$form->name = '';
$form->description = '';
$form->courseid = $courseid;
$form->groupid = 0;
$form->userid = $USER->id;
$form->modulename = '';
$form->eventtype = '';
$form->instance = 0;
$form->timeduration = 0;
$form->duration = 0;
$form->repeat = 0;
$form->repeats = '';
$form->minutes = '';
示例4: calendar_user_can_add_event
/**
* See if user can add calendar entries at all
* used to print the "New Event" button
*
* @param stdClass $course object of a course or course id
* @return bool has the capability to add at least one event type
*/
function calendar_user_can_add_event($course)
{
if (!isloggedin() || isguestuser()) {
return false;
}
calendar_get_allowed_types($allowed, $course);
return (bool) ($allowed->user || $allowed->groups || $allowed->courses || $allowed->site);
}
示例5: calendar_get_eventtype_choices
/**
* Returns option list of available options for the calendar event type, given the current user and course.
*
* @param int $courseid The id of the course
* @return array An array containing the event types the user can create.
*/
function calendar_get_eventtype_choices($courseid)
{
$choices = array();
$allowed = new stdClass();
calendar_get_allowed_types($allowed, $courseid);
if ($allowed->user) {
$choices['user'] = get_string('userevents', 'calendar');
}
if ($allowed->site) {
$choices['site'] = get_string('siteevents', 'calendar');
}
if (!empty($allowed->courses)) {
$choices['course'] = get_string('courseevents', 'calendar');
}
if (!empty($allowed->groups) and is_array($allowed->groups)) {
$choices['group'] = get_string('group');
}
return array($choices, $allowed->groups);
}
示例6: get_string
if ($eventid !== 0) {
$title = get_string('editevent', 'calendar');
$event = calendar_event::load($eventid);
if (!calendar_edit_event_allowed($event)) {
print_error('nopermissions');
}
$event->action = $action;
$event->course = $courseid;
$event->timedurationuntil = $event->timestart + $event->timeduration;
$event->count_repeats();
if (!calendar_add_event_allowed($event)) {
print_error('nopermissions');
}
} else {
$title = get_string('newevent', 'calendar');
calendar_get_allowed_types($formoptions->eventtypes, $USER->id);
$event = new stdClass();
$event->action = $action;
$event->course = $courseid;
$event->timeduration = 0;
if ($formoptions->eventtypes->courses) {
if ($courseexists) {
$event->courseid = $courseid;
$event->eventtype = 'course';
} else {
unset($formoptions->eventtypes->courses);
unset($formoptions->eventtypes->groups);
}
}
if ($cal_y && $cal_m && $cal_d && checkdate($cal_m, $cal_d, $cal_y)) {
$event->timestart = make_timestamp($cal_y, $cal_m, $cal_d, 0, 0, 0);
示例7: get_string
if ($eventid !== 0) {
$title = get_string('editevent', 'calendar');
$event = calendar_event::load($eventid);
if (!calendar_edit_event_allowed($event)) {
print_error('nopermissions');
}
$event->action = $action;
$event->course = $courseid;
$event->timedurationuntil = $event->timestart + $event->timeduration;
$event->count_repeats();
if (!calendar_add_event_allowed($event)) {
print_error('nopermissions');
}
} else {
$title = get_string('newevent', 'calendar');
calendar_get_allowed_types($formoptions->eventtypes, $course);
$event = new stdClass();
$event->action = $action;
$event->course = $courseid;
$event->courseid = $courseid;
$event->timeduration = 0;
if ($formoptions->eventtypes->courses) {
if (!$issite) {
$event->eventtype = 'course';
} else {
unset($formoptions->eventtypes->courses);
unset($formoptions->eventtypes->groups);
}
}
if ($cal_y && $cal_m && $cal_d && checkdate($cal_m, $cal_d, $cal_y)) {
$event->timestart = make_timestamp($cal_y, $cal_m, $cal_d, 0, 0, 0);