/** * Deletes photo * * @param int $id * @return int */ public function deletePhoto($id) { /** @var $photo PHOTO_BOL_Photo */ if (!$id || !($photo = $this->photoDao->findById($id))) { return false; } $event = new OW_Event(PHOTO_CLASS_EventHandler::EVENT_BEFORE_PHOTO_DELETE, array('id' => $id)); OW::getEventManager()->trigger($event); if ($this->photoDao->deleteById($id)) { BOL_CommentService::getInstance()->deleteEntityComments('photo_comments', $id); BOL_RateService::getInstance()->deleteEntityRates($id, 'photo_rates'); BOL_TagService::getInstance()->deleteEntityTags($id, 'photo'); // remove files $this->photoDao->removePhotoFile($id, $photo->hash, 'main'); $this->photoDao->removePhotoFile($id, $photo->hash, 'preview'); $this->photoDao->removePhotoFile($id, $photo->hash, 'original'); $this->photoFeaturedDao->markUnfeatured($id); BOL_FlagService::getInstance()->deleteByTypeAndEntityId('photo', $id); OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'photo_comments', 'entityId' => $id))); $this->cleanListCache(); $event = new OW_Event(PHOTO_CLASS_EventHandler::EVENT_ON_PHOTO_DELETE, array('id' => $id)); OW::getEventManager()->trigger($event); return true; } return false; }
/** * Deletes photo * * @param int $id * @return int */ public function deletePhoto($id, $totalAlbum = FALSE) { if (!$id || !($photo = $this->photoDao->findById($id))) { return false; } if ($totalAlbum === FALSE) { $event = new OW_Event(PHOTO_CLASS_EventHandler::EVENT_BEFORE_PHOTO_DELETE, array('id' => $id)); OW::getEventManager()->trigger($event); } if ($this->photoDao->deleteById($id)) { BOL_CommentService::getInstance()->deleteEntityComments('photo_comments', $id); BOL_RateService::getInstance()->deleteEntityRates($id, 'photo_rates'); BOL_TagService::getInstance()->deleteEntityTags($id, 'photo'); $this->photoDao->removePhotoFile($id, $photo->hash, self::TYPE_SMALL); $this->photoDao->removePhotoFile($id, $photo->hash, self::TYPE_PREVIEW); $this->photoDao->removePhotoFile($id, $photo->hash, self::TYPE_MAIN); $this->photoDao->removePhotoFile($id, $photo->hash, self::TYPE_FULLSCREEN); $this->photoDao->removePhotoFile($id, $photo->hash, self::TYPE_ORIGINAL); $this->photoFeaturedDao->markUnfeatured($id); BOL_FlagService::getInstance()->deleteByTypeAndEntityId(PHOTO_CLASS_ContentProvider::ENTITY_TYPE, $id); BOL_TagService::getInstance()->deleteEntityTags($id, PHOTO_BOL_PhotoDao::PHOTO_ENTITY_TYPE); $this->cleanListCache(); OW::getEventManager()->trigger(new OW_Event(PHOTO_CLASS_EventHandler::EVENT_ON_PHOTO_DELETE, array('id' => $id))); return TRUE; } return FALSE; }