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


PHP calendar_event::delete方法代码示例

本文整理汇总了PHP中calendar_event::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP calendar_event::delete方法的具体用法?PHP calendar_event::delete怎么用?PHP calendar_event::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在calendar_event的用法示例。


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

示例1: delete

 /**
  * Deletes an event and if selected an repeated events in the same series
  *
  * This function deletes an event, any associated events if $deleterepeated=true,
  * and cleans up any files associated with the events.
  *
  * @see delete_event()
  *
  * @param bool $deleterepeated
  * @return bool
  */
 public function delete($deleterepeated = false)
 {
     global $DB;
     // If $this->properties->id is not set then something is wrong
     if (empty($this->properties->id)) {
         debugging('Attempting to delete an event before it has been loaded', DEBUG_DEVELOPER);
         return false;
     }
     // Delete the event
     $DB->delete_records('event', array('id' => $this->properties->id));
     // If the editor context hasn't already been set then set it now
     if ($this->editorcontext === null) {
         $this->editorcontext = $this->properties->context;
     }
     // If the context has been set delete all associated files
     if ($this->editorcontext !== null) {
         $fs = get_file_storage();
         $files = $fs->get_area_files($this->editorcontext->id, 'calendar', 'event_description', $this->properties->id);
         foreach ($files as $file) {
             $file->delete();
         }
     }
     // Fire the event deleted hook
     self::calendar_event_hook('delete_event', array($this->properties->id, $deleterepeated));
     // If we need to delete repeated events then we will fetch them all and delete one by one
     if ($deleterepeated && !empty($this->properties->repeatid) && $this->properties->repeatid > 0) {
         // Get all records where the repeatid is the same as the event being removed
         $events = $DB->get_records('event', array('repeatid' => $this->properties->repeatid));
         // For each of the returned events populate a calendar_event object and call delete
         // make sure the arg passed is false as we are already deleting all repeats
         foreach ($events as $event) {
             $event = new calendar_event($event);
             $event->delete(false);
         }
     }
     return true;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:48,代码来源:lib.php

示例2: delete

 /**
  * Deletes an event and if selected an repeated events in the same series
  *
  * This function deletes an event, any associated events if $deleterepeated=true,
  * and cleans up any files associated with the events.
  *
  * @see delete_event()
  *
  * @param bool $deleterepeated  delete event repeatedly
  * @return bool succession of deleting event
  */
 public function delete($deleterepeated = false)
 {
     global $DB;
     // If $this->properties->id is not set then something is wrong
     if (empty($this->properties->id)) {
         debugging('Attempting to delete an event before it has been loaded', DEBUG_DEVELOPER);
         return false;
     }
     // Delete the event
     $DB->delete_records('event', array('id' => $this->properties->id));
     // If we are deleting parent of a repeated event series, promote the next event in the series as parent
     if ($this->properties->id == $this->properties->repeatid && !$deleterepeated) {
         $newparent = $DB->get_field_sql("SELECT id from {event} where repeatid = ? order by id ASC", array($this->properties->id), IGNORE_MULTIPLE);
         if (!empty($newparent)) {
             $DB->execute("UPDATE {event} SET repeatid = ? WHERE repeatid = ?", array($newparent, $this->properties->id));
             // Get all records where the repeatid is the same as the event being removed
             $events = $DB->get_records('event', array('repeatid' => $newparent));
             // For each of the returned events trigger the event_update hook.
             foreach ($events as $event) {
                 self::calendar_event_hook('update_event', array($event, false));
             }
         }
     }
     // If the editor context hasn't already been set then set it now
     if ($this->editorcontext === null) {
         $this->editorcontext = $this->properties->context;
     }
     // If the context has been set delete all associated files
     if ($this->editorcontext !== null) {
         $fs = get_file_storage();
         $files = $fs->get_area_files($this->editorcontext->id, 'calendar', 'event_description', $this->properties->id);
         foreach ($files as $file) {
             $file->delete();
         }
     }
     // Fire the event deleted hook
     self::calendar_event_hook('delete_event', array($this->properties->id, $deleterepeated));
     // If we need to delete repeated events then we will fetch them all and delete one by one
     if ($deleterepeated && !empty($this->properties->repeatid) && $this->properties->repeatid > 0) {
         // Get all records where the repeatid is the same as the event being removed
         $events = $DB->get_records('event', array('repeatid' => $this->properties->repeatid));
         // For each of the returned events populate a calendar_event object and call delete
         // make sure the arg passed is false as we are already deleting all repeats
         foreach ($events as $event) {
             $event = new calendar_event($event);
             $event->delete(false);
         }
     }
     return true;
 }
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:61,代码来源:lib.php

示例3: delete

 /**
  * Deletes an event and if selected an repeated events in the same series
  *
  * This function deletes an event, any associated events if $deleterepeated=true,
  * and cleans up any files associated with the events.
  *
  * @see delete_event()
  *
  * @param bool $deleterepeated
  * @return bool
  */
 public function delete($deleterepeated = false)
 {
     global $DB, $USER, $CFG;
     // If $this->properties->id is not set then something is wrong
     if (empty($this->properties->id)) {
         debugging('Attempting to delete an event before it has been loaded', DEBUG_DEVELOPER);
         return false;
     }
     // Delete the event
     $DB->delete_records('event', array('id' => $this->properties->id));
     // If the editor context hasn't already been set then set it now
     if ($this->editorcontext === null) {
         switch ($this->properties->eventtype) {
             case 'course':
             case 'group':
                 $this->editorcontext = get_context_instance(CONTEXT_COURSE, $this->properties->courseid);
                 break;
             case 'user':
                 $this->editorcontext = get_context_instance(CONTEXT_USER, $USER->id);
                 break;
             case 'site':
                 $this->editorcontext = get_context_instance(CONTEXT_SYSTEM);
                 break;
             default:
                 // There is a chance we can get here as some modules use there own
                 // eventtype strings. In this case the event has been added by code
                 // and we don't need to worry about it anyway
                 break;
         }
     }
     // If the context has been set delete all associated files
     if ($this->editorcontext !== null) {
         $fs = get_file_storage();
         $files = $fs->get_area_files($this->editorcontext->id, 'calendar', 'event_description', $this->properties->id);
         foreach ($files as $file) {
             $file->delete();
         }
     }
     // Fire the event deleted hook
     self::calendar_event_hook('delete_event', array($this->properties->id, $deleterepeated));
     // If we need to delete repeated events then we will fetch them all and delete one by one
     if ($deleterepeated && !empty($this->properties->repeatid) && $this->properties->repeatid > 0) {
         // Get all records where the repeatid is the same as the event being removed
         $events = $DB->get_records('event', array('repeatid' => $this->properties->repeatid));
         // For each of the returned events populate a calendar_event object and call delete
         // make sure the arg passed is false as we are already deleting all repeats
         foreach ($events as $event) {
             $event = new calendar_event($event);
             $event->delete(false);
         }
     }
     return true;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:64,代码来源:lib.php


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