當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。