示例#1
0
                 }
             }
         }
         // Update record
         if (!$DB->update_record('block_email_list_folder', $updatefolder)) {
             return false;
         }
         add_to_log($courseid, 'email_list', "update subfolder", 'folder.php?id=' . $id, "{$data->name}", 0, $USER->id);
         echo $OUTPUT->notification(get_string('modifyfolderok', 'block_email_list'), '');
         email_print_administration_folders($options);
     } else {
         $mform->display();
     }
     break;
 case md5('remove'):
     email_removefolder($id, $options);
     email_print_administration_folders($options);
 default:
     // Can create subfolders?
     if (!has_capability('block/email_list:createfolder', $context)) {
         print_error('forbiddencreatefolder', 'block_email_list', $CFG->wwwroot . '/blocks/email_list/email/index.php?id=' . $course->id);
     }
     $mform = new folder_form('folder.php', array('id' => $id, 'course' => $courseid, 'action' => ''));
     // If the form is cancelled
     if ($mform->is_cancelled()) {
         redirect($CFG->wwwroot . '/blocks/email_list/email/index.php?id=' . $courseid, get_string('foldercancelled', 'block_email_list'));
         // Get form sended
     } else {
         if ($form = $mform->get_data()) {
             $foldernew = new stdClass();
             // Clean name
 /**
  * When instance course has deleted, deleting all email_list course content.
  */
 function instance_delete()
 {
     /* When delete instance. Drop:
      * 		- Folders associated at this course.
      * 		- Mails of this course and all attachments.
      * 		- Colaterals effects:
      * 			# Drop all mail-folder references. (email_foldermail)
      * 			# Drop all sendbox/inbox (email_send)
      * 			# Drop all subfolders associated at this course.
      * 			# Drop all filters.
      */
     global $CFG, $DB;
     // Get course id
     if (!empty($this->instance)) {
         $courseid = $this->instance->pageid;
     } else {
         return true;
         // Skip
     }
     // Do not process SITEID
     if ($courseid === SITEID) {
         return true;
         // Skip
     }
     // Get all email references.
     if ($mailids = $DB->get_records('block_email_list_mail', array('course' => $courseid))) {
         foreach ($mailids as $mailid) {
             $DB->delete_records('block_email_list_foldermail', array('mailid' => $mailid));
         }
     }
     // Drop all mails
     $DB->delete_records('block_email_list_mail', array('course' => $courseid));
     if ($folders = $DB->get_records('block_email_list_folder', array('course' => $courseid))) {
         foreach ($folders as $folder) {
             // If user have defined who has associated folders-course, then delete all folders to this course.
             if (email_have_asociated_folders($folder->userid)) {
                 if (!email_removefolder($folder->id)) {
                     print_error('faildroprecordsfolder', 'block_email_list');
                 }
             }
         }
     }
     return true;
 }