Exemplo n.º 1
0
 /**
  * Deletes a file or folder from the media manager.
  *
  * @access	public
  * @param	null
  *
  */
 public function delete()
 {
     $ajax = EasyBlogHelper::getHelper('Ajax');
     // This is the relative path to the items that needs to be deleted.
     $relativePath = JRequest::getVar('path');
     // This let's us know the type of folder we should lookup to
     $place = JRequest::getString('place');
     // @task: Create the media object.
     $media = new EasyBlogMediaManager();
     // @task: Let's find the exact path first as there could be 3 possibilities here.
     // 1. Shared folder
     // 2. User folder
     $absolutePath = EasyBlogMediaManager::getAbsolutePath($relativePath, $place);
     // @task: Let's test if the source folder really exist.
     if (!$media->exists($absolutePath)) {
         return $ajax->fail(JText::_('COM_EASYBLOG_FILE_OR_FOLDER_DOES_NOT_EXIST'));
     }
     // @task: Try to rename the source to destination
     $state = $media->delete($absolutePath);
     // @task: If failed, let's just return a failed status
     if ($state !== true) {
         return $ajax->fail($state);
     }
     // @task: Return the deleted path's relative path
     return $ajax->success($relativePath);
 }