Exemple #1
0
 /**
  * Delete a file in the wiki
  *
  * @return     void
  */
 public function deletefileTask()
 {
     // Check if they're logged in
     if (User::isGuest()) {
         $this->displayTask();
         return;
     }
     // Incoming
     $listdir = Request::getInt('listdir', 0, 'get');
     if (!$listdir) {
         $this->setError(Lang::txt('COM_WIKI_NO_ID'));
         $this->displayTask();
         return;
     }
     // Incoming file
     $file = trim(Request::getVar('file', '', 'get'));
     if (!$file) {
         $this->setError(Lang::txt('COM_WIKI_NO_FILE'));
         $this->displayTask();
         return;
     }
     $attachment = new Tables\Attachment($this->database);
     // Build the file path
     $path = $attachment->filespace() . DS . $listdir;
     // Delete the file
     if (!file_exists($path . DS . $file) or !$file) {
         $this->setError(Lang::txt('COM_WIKI_ERROR_NO_FILE'));
         $this->displayTask();
     } else {
         // Attempt to delete the file
         if (!Filesystem::delete($path . DS . $file)) {
             $this->setError(Lang::txt('COM_WIKI_ERROR_UNABLE_TO_DELETE_FILE', $file));
         } else {
             // Delete the database entry for the file
             $attachment->deleteFile($file, $listdir);
         }
     }
     // Push through to the media view
     if (Request::getVar('no_html', 0)) {
         return $this->listTask();
     }
     $this->displayTask();
 }