public function get_actions_tree_links() { $lang = LangLoader::get('common', 'gallery'); $tree = new ModuleTreeLinks(); $manage_categories_link = new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), GalleryUrlBuilder::manage_categories()); $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), GalleryUrlBuilder::manage_categories())); $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('category.add', 'categories-common'), GalleryUrlBuilder::add_category())); $tree->add_link($manage_categories_link); $manage_gallery_link = new AdminModuleLink($lang['gallery.manage'], GalleryUrlBuilder::manage()); $manage_gallery_link->add_sub_link(new AdminModuleLink($lang['gallery.manage'], GalleryUrlBuilder::manage())); $manage_gallery_link->add_sub_link(new AdminModuleLink($lang['gallery.actions.add'], GalleryUrlBuilder::admin_add(AppContext::get_request()->get_getstring('id_category', 0)))); $tree->add_link($manage_gallery_link); $tree->add_link(new AdminModuleLink(LangLoader::get_message('configuration', 'admin-common'), GalleryUrlBuilder::configuration())); if (!AppContext::get_current_user()->check_level(User::ADMIN_LEVEL)) { $tree->add_link(new ModuleLink($lang['gallery.actions.add'], GalleryUrlBuilder::add(AppContext::get_request()->get_getstring('id_category', 0)), GalleryAuthorizationsService::check_authorizations()->write())); } return $tree; }
private function check_authorizations() { $id_cat = $this->get_category()->get_id(); if (!GalleryAuthorizationsService::check_authorizations($id_cat)->read()) { $error_controller = PHPBoostErrors::user_not_authorized(); DispatchManager::redirect($error_controller); } }
* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ require_once '../kernel/begin.php'; require_once '../gallery/gallery_begin.php'; require_once '../kernel/header_no_display.php'; $g_idpics = retrieve(GET, 'id', 0); if (!empty($g_idpics)) { //Niveau d'autorisation de la catégorie if (!GalleryAuthorizationsService::check_authorizations($id_category)->read()) { $error_controller = PHPBoostErrors::user_not_authorized(); DispatchManager::redirect($error_controller); } //Mise à jour du nombre de vues. PersistenceContext::get_querier()->inject("UPDATE " . GallerySetup::$gallery_table . " SET views = views + 1 WHERE idcat = :idcat AND id = :id", array('idcat' => $id_category, 'id' => $g_idpics)); $path = PersistenceContext::get_querier()->get_column_value(GallerySetup::$gallery_table, 'path', 'WHERE idcat = :idcat AND id = :id' . (AppContext::get_current_user()->check_level(User::ADMIN_LEVEL) ? '' : ' AND aprob = 1'), array('idcat' => $id_category, 'id' => $g_idpics)); if (empty($path)) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } $Gallery = new Gallery(); list($width_s, $height_s, $weight_s, $ext) = $Gallery->Arg_pics('pics/' . $path); $Gallery->Send_header($ext); //Header image. if ($Gallery->get_error() != '') {
} else { AppContext::get_session()->csrf_get_protect(); //Protection csrf if (!empty($rename_pics)) { $id_cat = PersistenceContext::get_querier()->get_column_value(GallerySetup::$gallery_table, 'idcat', 'WHERE id = :id', array('id' => $id_file)); if (GalleryAuthorizationsService::check_authorizations($id_cat)->moderation()) { //Initialisation de la class de gestion des fichiers. include_once PATH_TO_ROOT . '/gallery/Gallery.class.php'; $Gallery = new Gallery(); $name = TextHelper::strprotect(utf8_decode($request->get_postvalue('name', ''))); $previous_name = TextHelper::strprotect(utf8_decode($request->get_postvalue('previous_name', ''))); if (!empty($id_file)) { echo $Gallery->Rename_pics($id_file, $name, $previous_name); } else { echo -1; } } } elseif (!empty($aprob_pics)) { $id_cat = PersistenceContext::get_querier()->get_column_value(GallerySetup::$gallery_table, 'idcat', 'WHERE id = :id', array('id' => $id_file)); if (GalleryAuthorizationsService::check_authorizations($id_cat)->moderation()) { $Gallery = new Gallery(); if (!empty($id_file)) { echo $Gallery->Aprob_pics($id_file); //Régénération du cache des photos aléatoires. GalleryMiniMenuCache::invalidate(); } else { echo 0; } } } }
public function get_menu_content() { global $LANG; $tpl = new FileTemplate('gallery/gallery_mini.tpl'); //Chargement de la langue du module. load_module_lang('gallery'); $config = GalleryConfig::load(); $array_random_pics = GalleryMiniMenuCache::load()->get_pictures(); $i = 0; //Affichage des miniatures disponibles $array_pics_mini = 'var array_pics_mini = new Array();' . "\n"; list($nbr_pics, $sum_height, $sum_width, $scoll_mode, $height_max, $width_max) = array(0, 0, 0, 0, 142, 142); if (isset($array_random_pics) && $array_random_pics !== array()) { $gallery_mini = array(); shuffle($array_random_pics); //On mélange les éléments du tableau. //Vérification des autorisations. $break = 0; foreach ($array_random_pics as $array_pics_info) { if (GalleryAuthorizationsService::check_authorizations($array_pics_info['idcat'])->read()) { $gallery_mini[] = $array_pics_info; $break++; } if ($break == $config->get_pics_number_in_mini()) { break; } } //Aucune photo ne correspond, on fait une requête pour vérifier. if (count($gallery_mini) == 0) { $array_random_pics = array(); $result = PersistenceContext::get_querier()->select("SELECT g.id, g.name, g.path, g.width, g.height, g.idcat, gc.auth\n\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\tLEFT JOIN " . GallerySetup::$gallery_cats_table . " gc on gc.id = g.idcat\n\t\t\t\tWHERE g.aprob = 1 AND gc.aprob = 1\n\t\t\t\tORDER BY RAND()\n\t\t\t\tLIMIT " . $config->get_pics_number_in_mini()); while ($row = $result->fetch()) { $array_random_pics[] = $row; } //Vérification des autorisations. $break = 0; foreach ($array_random_pics as $key => $array_pics_info) { if (GalleryAuthorizationsService::check_authorizations($array_pics_info['idcat'])->read()) { $gallery_mini[] = $array_pics_info; $break++; } if ($break == $config->get_pics_number_in_mini()) { break; } } } $tpl->put_all(array('C_FADE' => false, 'C_VERTICAL_SCROLL' => false, 'C_HORIZONTAL_SCROLL' => false, 'C_STATIC' => false)); switch ($config->get_scroll_type()) { case GalleryConfig::STATIC_SCROLL: $tpl->put('C_FADE', true); break; case GalleryConfig::VERTICAL_DYNAMIC_SCROLL: $tpl->put('C_VERTICAL_SCROLL', true); break; case GalleryConfig::HORIZONTAL_DYNAMIC_SCROLL: $tpl->put('C_HORIZONTAL_SCROLL', true); break; case GalleryConfig::NO_SCROLL: $tpl->put('C_STATIC', true); break; } $Gallery = new Gallery(); foreach ($gallery_mini as $key => $row) { //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle. if (!is_file(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) { $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']); } //Redimensionnement + création miniature // On recupère la hauteur et la largeur de l'image. if ($row['width'] == 0 || $row['height'] == 0) { list($row['width'], $row['height']) = @getimagesize(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path']); } if ($row['width'] == 0 || $row['height'] == 0) { list($row['width'], $row['height']) = array(142, 142); } $tpl->assign_block_vars('pics_mini', array('ID' => $row['id'], 'PICS' => TPL_PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'], 'NAME' => TextHelper::strprotect($row['name'], TextHelper::HTML_PROTECT, TextHelper::ADDSLASHES_FORCE), 'HEIGHT' => $row['height'], 'WIDTH' => $row['width'], 'U_PICS' => TPL_PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&id=' . $row['id'], '-' . $row['idcat'] . '-' . $row['id'] . '.php'))); $sum_height += $row['height'] + 5; $sum_width += $row['width'] + 5; if ($config->get_scroll_type() == GalleryConfig::NO_SCROLL) { break; } $i++; } } $tpl->put_all(array('ARRAY_PICS' => $array_pics_mini, 'HEIGHT_DIV' => $config->get_mini_max_height(), 'SUM_HEIGHT' => $sum_height + 10, 'HIDDEN_HEIGHT' => $config->get_mini_max_height() + 10, 'WIDTH_DIV' => $config->get_mini_max_width(), 'SUM_WIDTH' => $sum_width + 30, 'HIDDEN_WIDTH' => $config->get_mini_max_width() * 3 + 30, 'SCROLL_DELAY' => $config->get_mini_pics_speed() * 1000, 'L_NO_RANDOM_PICS' => $i == 0 ? '<br /><span class="smaller"><em>' . $LANG['no_random_img'] . '</em></span><br />' : '', 'L_GALLERY' => $LANG['gallery'])); return $tpl->render(); }
public function get_authorizations() { $authorizations = new CommentsAuthorizations(); $authorizations->set_authorized_access_module(GalleryAuthorizationsService::check_authorizations($this->get_id_category())->read()); return $authorizations; }