当前位置: 首页>>代码示例>>PHP>>正文


PHP calendar_add_event_allowed函数代码示例

本文整理汇总了PHP中calendar_add_event_allowed函数的典型用法代码示例。如果您正苦于以下问题:PHP calendar_add_event_allowed函数的具体用法?PHP calendar_add_event_allowed怎么用?PHP calendar_add_event_allowed使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了calendar_add_event_allowed函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create_calendar_events

 /**
  * Delete Calendar events.
  *
  * @param array $events A list of events to create.
  * @return array array of events created.
  * @since Moodle 2.5
  * @throws moodle_exception if user doesnt have the permission to create events.
  */
 public static function create_calendar_events($events)
 {
     global $CFG, $DB, $USER;
     require_once $CFG->dirroot . "/calendar/lib.php";
     // Parameter validation.
     $params = self::validate_parameters(self::create_calendar_events_parameters(), array('events' => $events));
     $transaction = $DB->start_delegated_transaction();
     $return = array();
     $warnings = array();
     foreach ($params['events'] as $event) {
         // Let us set some defaults.
         $event['userid'] = $USER->id;
         $event['modulename'] = '';
         $event['instance'] = 0;
         $event['subscriptionid'] = null;
         $event['uuid'] = '';
         $event['format'] = external_validate_format($event['format']);
         if ($event['repeats'] > 0) {
             $event['repeat'] = 1;
         } else {
             $event['repeat'] = 0;
         }
         $eventobj = new calendar_event($event);
         // Let's check if the user is allowed to delete an event.
         if (!calendar_add_event_allowed($eventobj)) {
             $warnings[] = array('item' => $event['name'], 'warningcode' => 'nopermissions', 'message' => 'you do not have permissions to create this event');
             continue;
         }
         // Let's create the event.
         $var = $eventobj->create($event);
         $var = (array) $var->properties();
         if ($event['repeat']) {
             $children = $DB->get_records('event', array('repeatid' => $var['id']));
             foreach ($children as $child) {
                 $return[] = (array) $child;
             }
         } else {
             $return[] = $var;
         }
     }
     // Everything done smoothly, let's commit.
     $transaction->allow_commit();
     return array('events' => $return, 'warnings' => $warnings);
 }
开发者ID:nikitskynikita,项目名称:moodle,代码行数:52,代码来源:externallib.php

示例2: clean_text

 if (!empty($form) && !empty($form->name) && confirm_sesskey()) {
     $form->name = clean_text(strip_tags($form->name, '<lang><span>'));
     $form->timestart = make_timestamp($form->startyr, $form->startmon, $form->startday, $form->starthr, $form->startmin);
     if ($form->duration == 1) {
         $form->timeduration = make_timestamp($form->endyr, $form->endmon, $form->endday, $form->endhr, $form->endmin) - $form->timestart;
         if ($form->timeduration < 0) {
             $form->timeduration = 0;
         }
     } else {
         if ($form->duration == 2) {
             $form->timeduration = $form->minutes * MINSECS;
         } else {
             $form->timeduration = 0;
         }
     }
     if (!calendar_add_event_allowed($form)) {
         error('You are not authorized to do this');
     }
     validate_form($form, $err);
     if (count($err) == 0) {
         $form->timemodified = time();
         /// Get the event id for the log record.
         $eventid = insert_record('event', $form, true);
         /// Use the event id as the repeatid to link repeat entries together
         if ($form->repeat) {
             $form->repeatid = $form->id = $eventid;
             update_record('event', $form);
             // update the row, to set its repeatid
         }
         /// Log the event entry.
         add_to_log($form->courseid, 'calendar', 'add', 'event.php?action=edit&amp;id=' . $eventid, stripslashes($form->name));
开发者ID:NextEinstein,项目名称:riverhills,代码行数:31,代码来源:event.php

示例3: update

 /**
  * Update or create an event within the database
  *
  * Pass in a object containing the event properties and this function will
  * insert it into the database and deal with any associated files
  *
  * @see add_event()
  * @see update_event()
  *
  * @param stdClass $data object of event
  * @param bool $checkcapability if moodle should check calendar managing capability or not
  * @return bool event updated
  */
 public function update($data, $checkcapability = true)
 {
     global $CFG, $DB, $USER;
     foreach ($data as $key => $value) {
         $this->properties->{$key} = $value;
     }
     $this->properties->timemodified = time();
     $usingeditor = !empty($this->properties->description) && is_array($this->properties->description);
     if (empty($this->properties->id) || $this->properties->id < 1) {
         if ($checkcapability) {
             if (!calendar_add_event_allowed($this->properties)) {
                 print_error('nopermissiontoupdatecalendar');
             }
         }
         if ($usingeditor) {
             switch ($this->properties->eventtype) {
                 case 'user':
                     $this->properties->courseid = 0;
                     $this->properties->course = 0;
                     $this->properties->groupid = 0;
                     $this->properties->userid = $USER->id;
                     break;
                 case 'site':
                     $this->properties->courseid = SITEID;
                     $this->properties->course = SITEID;
                     $this->properties->groupid = 0;
                     $this->properties->userid = $USER->id;
                     break;
                 case 'course':
                     $this->properties->groupid = 0;
                     $this->properties->userid = $USER->id;
                     break;
                 case 'group':
                     $this->properties->userid = $USER->id;
                     break;
                 default:
                     // Ewww we should NEVER get here, but just incase we do lets
                     // fail gracefully
                     $usingeditor = false;
                     break;
             }
             // If we are actually using the editor, we recalculate the context because some default values
             // were set when calculate_context() was called from the constructor.
             if ($usingeditor) {
                 $this->properties->context = $this->calculate_context($this->properties);
                 $this->editorcontext = $this->properties->context;
             }
             $editor = $this->properties->description;
             $this->properties->format = $this->properties->description['format'];
             $this->properties->description = $this->properties->description['text'];
         }
         // Insert the event into the database
         $this->properties->id = $DB->insert_record('event', $this->properties);
         if ($usingeditor) {
             $this->properties->description = file_save_draft_area_files($editor['itemid'], $this->editorcontext->id, 'calendar', 'event_description', $this->properties->id, $this->editoroptions, $editor['text'], $this->editoroptions['forcehttps']);
             $DB->set_field('event', 'description', $this->properties->description, array('id' => $this->properties->id));
         }
         // Log the event entry.
         add_to_log($this->properties->courseid, 'calendar', 'add', 'event.php?action=edit&amp;id=' . $this->properties->id, $this->properties->name);
         $repeatedids = array();
         if (!empty($this->properties->repeat)) {
             $this->properties->repeatid = $this->properties->id;
             $DB->set_field('event', 'repeatid', $this->properties->repeatid, array('id' => $this->properties->id));
             $eventcopy = clone $this->properties;
             unset($eventcopy->id);
             for ($i = 1; $i < $eventcopy->repeats; $i++) {
                 $eventcopy->timestart = $eventcopy->timestart + WEEKSECS + dst_offset_on($eventcopy->timestart) - dst_offset_on($eventcopy->timestart + WEEKSECS);
                 // Get the event id for the log record.
                 $eventcopyid = $DB->insert_record('event', $eventcopy);
                 // If the context has been set delete all associated files
                 if ($usingeditor) {
                     $fs = get_file_storage();
                     $files = $fs->get_area_files($this->editorcontext->id, 'calendar', 'event_description', $this->properties->id);
                     foreach ($files as $file) {
                         $fs->create_file_from_storedfile(array('itemid' => $eventcopyid), $file);
                     }
                 }
                 $repeatedids[] = $eventcopyid;
                 // Log the event entry.
                 add_to_log($eventcopy->courseid, 'calendar', 'add', 'event.php?action=edit&amp;id=' . $eventcopyid, $eventcopy->name);
             }
         }
         // Hook for tracking added events
         self::calendar_event_hook('add_event', array($this->properties, $repeatedids));
         return true;
     } else {
         if ($checkcapability) {
//.........这里部分代码省略.........
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:101,代码来源:lib.php

示例4: unset

            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);
    } else {
        if ($cal_y && $cal_m && checkdate($cal_m, 1, $cal_y)) {
            if ($cal_y == $now['year'] && $cal_m == $now['mon']) {
                $event->timestart = make_timestamp($cal_y, $cal_m, $now['mday'], 0, 0, 0);
            } else {
                $event->timestart = make_timestamp($cal_y, $cal_m, 1, 0, 0, 0);
            }
        }
    }
    $event = new calendar_event($event);
    if (!calendar_add_event_allowed($event)) {
        print_error('nopermissions');
    }
}
$properties = $event->properties(true);
$formoptions->event = $event;
$formoptions->hasduration = $event->timeduration > 0;
$mform = new event_form(null, $formoptions);
$mform->set_data($properties);
$data = $mform->get_data();
if ($data) {
    if ($data->duration == 1) {
        $data->timeduration = $data->timedurationuntil - $data->timestart;
    } else {
        if ($data->duration == 2) {
            $data->timeduration = $data->timedurationminutes * MINSECS;
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:31,代码来源:event.php


注:本文中的calendar_add_event_allowed函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。