/** * Update album * * @param PluginLsgallery_ModuleAlbum_EntityAlbum $oAlbum * @return boolean */ public function UpdateAlbum($oAlbum) { $oAlbum->setDateEdit(); if ($this->oMapper->UpdateAlbum($oAlbum)) { //чистим зависимые кеши $this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('album_update', "album_update_{$oAlbum->getId()}", "image_update")); $this->Cache_Delete("album_{$oAlbum->getId()}"); return true; } return false; }
/** * Update album * * @param PluginLsgallery_ModuleAlbum_EntityAlbum $oAlbum * @return boolean */ public function UpdateAlbum($oAlbum) { $sql = "UPDATE\n " . Config::Get('db.table.lsgallery.album') . "\n SET\n album_title = ?,\n album_description = ?,\n album_type = ?,\n album_date_edit = ?,\n album_cover_image_id= ?d,\n image_count = ?d\n WHERE\n album_id = ?d\n "; if ($this->oDb->query($sql, $oAlbum->getTitle(), $oAlbum->getDescription(), $oAlbum->getType(), $oAlbum->getDateEdit(), $oAlbum->getCoverId(), $oAlbum->getImageCount(), $oAlbum->getId())) { return true; } return false; }
/** * Is allow view images from album * * @param ModuleUser_EntityUser $oUser * @param PluginLsgallery_ModuleAlbum_EntityAlbum $oAlbum */ public function AllowViewAlbumImages($oUser, $oAlbum) { if ($oAlbum->getType() == PluginLsgallery_ModuleAlbum_EntityAlbum::TYPE_OPEN) { return true; } if (!$oUser) { return false; } if ($oUser->isAdministrator()) { return true; } if ($oUser->getId() == $oAlbum->getUserId()) { return true; } if ($oAlbum->getTitle() == PluginLsgallery_ModuleAlbum_EntityAlbum::TYPE_PERSONAL) { return false; } if ($oAlbum->getType() == PluginLsgallery_ModuleAlbum_EntityAlbum::TYPE_FRIEND) { if ($oFriend = $this->User_GetFriend($oUser->getId(), $oAlbum->getUserId())) { if ($oFriend->getFriendStatus() == ModuleUser::USER_FRIEND_ACCEPT + ModuleUser::USER_FRIEND_ACCEPT || $oFriend->getFriendStatus() == ModuleUser::USER_FRIEND_ACCEPT + ModuleUser::USER_FRIEND_OFFER) { return true; } } } return false; }
/** * Validate album fields * * @param PluginLsgallery_ModuleAlbum_EntityAlbum $oAlbum * @return boolean */ protected function _checkAlbumFields($oAlbum = null) { $this->Security_ValidateSendForm(); $bOk = true; if (!is_null($oAlbum)) { if ($oAlbum->getId() != getRequest('album_id')) { $this->Message_AddError($this->Lang_Get('plugin.lsgallery.lsgallery_album_id_error'), $this->Lang_Get('error')); $bOk = false; } } if (!func_check(getRequest('album_title'), 'text', 2, 64)) { $this->Message_AddError($this->Lang_Get('plugin.lsgallery.lsgallery_album_title_error'), $this->Lang_Get('error')); $bOk = false; } $sDescription = getRequest('album_description'); if ($sDescription && !func_check($sDescription, 'text', 10, 512)) { $this->Message_AddError($this->Lang_Get('plugin.lsgallery.lsgallery_album_description_error'), $this->Lang_Get('error')); $bOk = false; } $aTypes = PluginLsgallery_ModuleAlbum_EntityAlbum::getLocalizedTypes($this); if (!in_array(getRequest('album_type'), array_keys($aTypes))) { $this->Message_AddError($this->Lang_Get('plugin.lsgallery.lsgallery_album_type_error'), $this->Lang_Get('error')); $bOk = false; } return $bOk; }
/** * Move image from one album to other * * @param PluginLsgallery_ModuleImage_EntityImage $oImage * @param PluginLsgallery_ModuleAlbum_EntityAlbum $oAlbumFrom * @param PluginLsgallery_ModuleAlbum_EntityAlbum $oAlbumTo * * @return boolean */ public function MoveImage($oImage, $oAlbumFrom, $oAlbumTo) { $oImage->setAlbumId($oAlbumTo->getId()); $this->UpdateImage($oImage); $this->Comment_MoveTargetParent($oAlbumFrom->getId(), 'image', $oAlbumTo->getId()); if ($oAlbumFrom->getCoverId() == $oImage->getId()) { $oAlbumFrom->setCoverId(null); } $oAlbumFrom->setImageCount($oAlbumFrom->getImageCount() - 1); $this->PluginLsgallery_Album_UpdateAlbum($oAlbumFrom); $oAlbumTo->setImageCount($oAlbumTo->getImageCount() + 1); $this->PluginLsgallery_Album_UpdateAlbum($oAlbumTo); }