Пример #1
0
 public function delete()
 {
     if (empty($this->id)) {
         return;
     }
     $file = $this->get_path();
     // Detach this file from any view feedback
     set_field('view_feedback', 'attachment', null, 'attachment', $this->id);
     if (is_file($file)) {
         $size = filesize($file);
         // Only delete the file on disk if no other artefacts point to it
         if (count_records('artefact_file_files', 'fileid', $this->get('id')) == 1) {
             unlink($file);
         }
         global $USER;
         // Deleting other users' files won't lower their quotas yet...
         if (!$this->institution && $USER->id == $this->get('owner')) {
             $USER->quota_remove($size);
             $USER->commit();
         }
     }
     parent::delete();
 }
Пример #2
0
 public function delete()
 {
     // ArtefactType::delete() deletes all the child artefacts one by one.
     // If the folder contains a lot of artefacts, it's too slow to do this
     // but for very small directories it seems to be slightly faster.
     $descendants = artefact_get_descendants(array($this->id));
     if (count($descendants) < 10) {
         parent::delete();
     } else {
         ArtefactType::delete_by_artefacttype($descendants);
     }
 }