/**
  * Delete image
  *
  * @param PluginLsgallery_ModuleImage_EntityImage $oImage
  * @return boolean
  */
 public function DeleteImage($oImage)
 {
     $oAlbum = $this->PluginLsgallery_Album_GetAlbumById($oImage->getAlbumId());
     if (!$this->oMapper->DeleteImage($oImage->getId())) {
         return false;
     }
     if ($oAlbum->getCoverId() == $oImage->getId()) {
         $oAlbum->setCoverId(null);
     }
     $oAlbum->setImageCount($oAlbum->getImageCount() - 1);
     $this->PluginLsgallery_Album_UpdateAlbum($oAlbum);
     $this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array("image_update"));
     $this->Cache_Delete("image_{$oImage->getId()}");
     $this->DeleteImageFiles($oImage);
     $this->Vote_DeleteVoteByTarget($oImage->getId(), 'image');
     $this->Favourite_DeleteFavouriteByTargetId($oImage->getId(), 'image');
     $this->Comment_DeleteCommentByTargetId($oImage->getId(), 'image');
     return true;
 }
 /**
  * Get next image id
  *
  * @param PluginLsgallery_ModuleImage_EntityImage $oImage
  * @return int|null
  */
 public function GetNextImageId($oImage)
 {
     $sql = "\n                SELECT\n                    image_id\n                FROM\n                    " . Config::Get('db.table.lsgallery.image') . "\n                WHERE\n                    image_id > ?d\n                AND\n                    album_id = ?d\n                ORDER BY\n                    image_id ASC\n                ";
     if ($aRow = $this->oDb->selectRow($sql, $oImage->getId(), $oImage->getAlbumId())) {
         return $aRow['image_id'];
     }
     return null;
 }