Esempio n. 1
0
 /**
  * Method is responsible to rename an item from the media manager.
  *
  * @access	public
  * @param	null
  */
 public function move()
 {
     $ajax = EasyBlogHelper::getHelper('Ajax');
     // This is the original location
     $sourceRelative = JRequest::getVar('fromPath');
     // This is where it should be renamed to
     $destinationRelative = JRequest::getVar('toPath');
     // This let's us know the type of folder we should lookup to
     $place = JRequest::getString('place');
     // Rename types
     // 1. Renaming Image
     //	  - Renaming image should also rename image variations
     //	  - Renaming image should also return variations.
     // 2. Moving from user folder to shared folder
     // 3. Really just rename folder.
     // @task: Let's find the exact path first as there could be 3 possibilities here.
     // 1. Shared folder
     // 2. Article folder
     // 3. User folder
     $source = EasyBlogMediaManager::getAbsolutePath($sourceRelative, $place);
     $destination = EasyBlogMediaManager::getAbsolutePath($destinationRelative, $place);
     // @task: Create the media object.
     $media = new EasyBlogMediaManager();
     // @task: Let's test if the source folder really exist.
     if (!$media->exists($source)) {
         return $ajax->fail(JText::_('COM_EASYBLOG_FILE_OR_FOLDER_DOES_NOT_EXIST'));
     }
     // @task: Try to rename the source to destination
     $state = $media->rename($source, $destination);
     // @task: If failed, let's just return a failed status
     if ($state !== true) {
         return $ajax->fail($state);
     }
     // @task: Get the absolute URI to the destination item.
     $uri = EasyBlogMediaManager::getAbsoluteURI($destinationRelative, $place);
     $obj = $media->getItem($destination, $uri)->toArray();
     $ajax->success($obj);
 }