/** * Delete the photo, the original and the actual resized photos and thumbnails */ public function delete($pk = null) { $storage = CStorage::getStorage($this->storage); $storage->delete($this->image); $storage->delete($this->thumbnail); /* We did store original than now time to remove it */ if (!empty($this->original)) { /* Original do not sync with 3rd storage than we don't need to use $storage->delete; even it would be same */ if (JFile::exists(JPATH_ROOT . '/' . $this->original)) { JFile::delete(JPATH_ROOT . '/' . $this->original); } $originalDir = dirname(JPATH_ROOT . '/' . $this->original); $files = JFolder::files($originalDir); /* If the original path is empty, we can delete it too */ if (empty($files)) { JFolder::delete($originalDir); } } // if the photo is the album cover, set the album cover as default 0 $album = JTable::getInstance('Album', 'CTable'); $album->load($this->albumid); $album->set('photoid', 0); $album->store(); // delete the tags CFactory::load('libraries', 'phototagging'); $phototagging = new CPhotoTagging(); $phototagging->removeTagByPhoto($this->id); // delete the activities CActivities::remove('photos', $this->id); //Remove photo from activity stream CActivityStream::remove('photo.like', $this->id); // delete the comments $wall = CFactory::getModel('wall'); $wall->deleteAllChildPosts($this->id, 'photos'); /* And now finally we do delete this photo in database */ /* return parent::delete(); */ /** * @since 3.2 * We do not delete database record for now. Leave it for cron ! * @todo Considering local files should be deleted this time or not ? */ $this->published = 0; $this->status = 'delete'; $this->store(); }
/** * Delete the photo, the original and the actual resized photos and thumbnails */ public function delete() { CFactory::load('libraries', 'storage'); $storage = CStorage::getStorage($this->storage); $storage->delete($this->image); $storage->delete($this->thumbnail); JFile::delete(JPATH_ROOT . DS . $this->original); // If the original path is empty, we can delete it too $files = JFolder::files(dirname(JPATH_ROOT . DS . $this->original)); if (empty($files)) { JFolder::delete(dirname(JPATH_ROOT . DS . $this->original)); } // if the photo is the album cover, set the album cover as default 0 $album =& JTable::getInstance('Album', 'CTable'); $album->load($this->albumid); $album->set('photoid', 0); $album->store(); // delete the tags CFactory::load('libraries', 'phototagging'); CPhotoTagging::removeTagByPhoto($this->id); // delete the activities CFactory::load('libraries', 'activities'); CActivities::remove('photos', $this->id); // delete the comments $wall = CFactory::getModel('wall'); $wall->deleteAllChildPosts($this->id, 'photos'); return parent::delete(); }