public function execute(HTTPRequestCustom $request) { $id = $request->get_getint('id', 0); if (!empty($id) && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) { try { $this->downloadfile = DownloadService::get_downloadfile('WHERE download.id = :id', array('id' => $id)); } catch (RowNotFoundException $e) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } } if ($this->downloadfile !== null && $this->downloadfile->is_visible()) { if (!PersistenceContext::get_querier()->row_exists(PREFIX . 'events', 'WHERE id_in_module=:id_in_module AND module=\'download\' AND current_status = 0', array('id_in_module' => $this->downloadfile->get_id()))) { $contribution = new Contribution(); $contribution->set_id_in_module($this->downloadfile->get_id()); $contribution->set_entitled(StringVars::replace_vars(LangLoader::get_message('contribution.deadlink', 'common'), array('link_name' => $this->downloadfile->get_name()))); $contribution->set_fixing_url(DownloadUrlBuilder::edit($this->downloadfile->get_id())->relative()); $contribution->set_description(LangLoader::get_message('contribution.deadlink_explain', 'common')); $contribution->set_poster_id(AppContext::get_current_user()->get_id()); $contribution->set_module('download'); $contribution->set_type('alert'); $contribution->set_auth(Authorizations::capture_and_shift_bit_auth(DownloadService::get_categories_manager()->get_heritated_authorizations($this->downloadfile->get_id_category(), Category::MODERATION_AUTHORIZATIONS, Authorizations::AUTH_CHILD_PRIORITY), Category::MODERATION_AUTHORIZATIONS, Contribution::CONTRIBUTION_AUTH_BIT)); ContributionService::save_contribution($contribution); } DispatchManager::redirect(new UserContributionSuccessController()); } else { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } }
private function build_table() { $table_model = new SQLHTMLTableModel(DownloadSetup::$download_table, 'table', array(new HTMLTableColumn(LangLoader::get_message('form.name', 'common'), 'name'), new HTMLTableColumn(LangLoader::get_message('category', 'categories-common'), 'id_category'), new HTMLTableColumn(LangLoader::get_message('author', 'common'), 'display_name'), new HTMLTableColumn(LangLoader::get_message('form.date.creation', 'common'), 'creation_date'), new HTMLTableColumn(LangLoader::get_message('status', 'common'), 'approbation_type'), new HTMLTableColumn('')), new HTMLTableSortingRule('creation_date', HTMLTableSortingRule::DESC)); $table = new HTMLTable($table_model); $table_model->set_caption($this->lang['download.management']); $results = array(); $result = $table_model->get_sql_results('download LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' com ON com.id_in_module = download.id AND com.module_id = \'download\' LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = download.id AND notes.module_name = \'download\' LEFT JOIN ' . DB_TABLE_NOTE . ' note ON note.id_in_module = download.id AND note.module_name = \'download\' AND note.user_id = ' . AppContext::get_current_user()->get_id() . ' LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = download.author_user_id', array('*', 'download.id')); foreach ($result as $row) { $downloadfile = new DownloadFile(); $downloadfile->set_properties($row); $category = $downloadfile->get_category(); $user = $downloadfile->get_author_user(); $edit_link = new LinkHTMLElement(DownloadUrlBuilder::edit($downloadfile->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit'); $delete_link = new LinkHTMLElement(DownloadUrlBuilder::delete($downloadfile->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete'); $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true); $author = $user->get_id() !== User::VISITOR_LEVEL ? new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level())) : $user->get_display_name(); $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(DownloadUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $downloadfile->get_id(), $downloadfile->get_rewrited_name()), $downloadfile->get_name()), 'left'), new HTMLTableRowCell(new LinkHTMLElement(DownloadUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()), $category->get_name())), new HTMLTableRowCell($author), new HTMLTableRowCell($downloadfile->get_creation_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($downloadfile->get_status()), new HTMLTableRowCell($edit_link->display() . $delete_link->display()))); } $table->set_rows($table_model->get_number_of_matching_rows(), $results); $this->view->put('table', $table->display()); }
public function __construct($view, $title_page) { parent::__construct($view); $lang = LangLoader::get('common', 'download'); $this->set_title($lang['module_title']); $this->add_link(LangLoader::get_message('categories.management', 'categories-common'), DownloadUrlBuilder::manage_categories()); $this->add_link(LangLoader::get_message('category.add', 'categories-common'), DownloadUrlBuilder::add_category()); $this->add_link($lang['download.management'], DownloadUrlBuilder::manage()); $this->add_link($lang['download.actions.add'], DownloadUrlBuilder::add()); $this->add_link(LangLoader::get_message('configuration', 'admin-common'), DownloadUrlBuilder::configuration()); $env = $this->get_graphical_environment(); $env->set_page_title($title_page, $lang['module_title']); }
public function execute(HTTPRequestCustom $request) { AppContext::get_session()->csrf_get_protect(); $this->get_downloadfile($request); $this->check_authorizations(); DownloadService::delete('WHERE id=:id', array('id' => $this->downloadfile->get_id())); DownloadService::get_keywords_manager()->delete_relations($this->downloadfile->get_id()); PersistenceContext::get_querier()->delete(DB_TABLE_EVENTS, 'WHERE module=:module AND id_in_module=:id', array('module' => 'download', 'id' => $this->downloadfile->get_id())); CommentsService::delete_comments_topic_module('download', $this->downloadfile->get_id()); NotationService::delete_notes_id_in_module('download', $this->downloadfile->get_id()); Feed::clear_cache('download'); DownloadCache::invalidate(); AppContext::get_response()->redirect($request->get_url_referrer() ? $request->get_url_referrer() : DownloadUrlBuilder::home(), StringVars::replace_vars(LangLoader::get_message('download.message.success.delete', 'common', 'download'), array('name' => $this->downloadfile->get_name()))); }
public function get_actions_tree_links() { $lang = LangLoader::get('common', 'download'); $tree = new ModuleTreeLinks(); $manage_categories_link = new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), DownloadUrlBuilder::manage_categories()); $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), DownloadUrlBuilder::manage_categories())); $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('category.add', 'categories-common'), DownloadUrlBuilder::add_category())); $tree->add_link($manage_categories_link); $manage_link = new AdminModuleLink($lang['download.manage'], DownloadUrlBuilder::manage()); $manage_link->add_sub_link(new AdminModuleLink($lang['download.manage'], DownloadUrlBuilder::manage())); $manage_link->add_sub_link(new AdminModuleLink($lang['download.actions.add'], DownloadUrlBuilder::add(AppContext::get_request()->get_getint('id_category', Category::ROOT_CATEGORY)))); $tree->add_link($manage_link); $tree->add_link(new AdminModuleLink(LangLoader::get_message('configuration', 'admin-common'), DownloadUrlBuilder::configuration())); if (!AppContext::get_current_user()->check_level(User::ADMIN_LEVEL)) { $tree->add_link(new ModuleLink($lang['download.actions.add'], DownloadUrlBuilder::add(AppContext::get_request()->get_getint('id_category', Category::ROOT_CATEGORY)), DownloadAuthorizationsService::check_authorizations()->write() || DownloadAuthorizationsService::check_authorizations()->contribution())); } $tree->add_link(new ModuleLink($lang['download.pending'], DownloadUrlBuilder::display_pending(), DownloadAuthorizationsService::check_authorizations()->write() || DownloadAuthorizationsService::check_authorizations()->contribution() || DownloadAuthorizationsService::check_authorizations()->moderation())); return $tree; }
public function get_feed_data_struct($idcat = 0, $name = '') { if (DownloadService::get_categories_manager()->get_categories_cache()->category_exists($idcat)) { $querier = PersistenceContext::get_querier(); $category = DownloadService::get_categories_manager()->get_categories_cache()->get_category($idcat); $site_name = GeneralConfig::load()->get_site_name(); $site_name = $idcat != Category::ROOT_CATEGORY ? $site_name . ' : ' . $category->get_name() : $site_name; $feed_module_name = LangLoader::get_message('module_title', 'common', 'download'); $data = new FeedData(); $data->set_title($feed_module_name . ' - ' . $site_name); $data->set_date(new Date()); $data->set_link(SyndicationUrlBuilder::rss('download', $idcat)); $data->set_host(HOST); $data->set_desc($feed_module_name . ' - ' . $site_name); $data->set_lang(LangLoader::get_message('xml_lang', 'main')); $data->set_auth_bit(Category::READ_AUTHORIZATIONS); $categories = DownloadService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true); $ids_categories = array_keys($categories); $now = new Date(); $results = $querier->select('SELECT download.id, download.id_category, download.name, download.rewrited_name, download.contents, download.short_contents, download.creation_date, download.picture_url, cat.rewrited_name AS rewrited_name_cat FROM ' . DownloadSetup::$download_table . ' download LEFT JOIN ' . DownloadSetup::$download_cats_table . ' cat ON cat.id = download.id_category WHERE download.id_category IN :ids_categories AND (approbation_type = 1 OR (approbation_type = 2 AND start_date < :timestamp_now AND (end_date > :timestamp_now OR end_date = 0))) ORDER BY download.creation_date DESC', array('ids_categories' => $ids_categories, 'timestamp_now' => $now->get_timestamp())); foreach ($results as $row) { $row['rewrited_name_cat'] = !empty($row['id_category']) ? $row['rewrited_name_cat'] : 'root'; $link = DownloadUrlBuilder::display($row['id_category'], $row['rewrited_name_cat'], $row['id'], $row['rewrited_name']); $item = new FeedItem(); $item->set_title($row['name']); $item->set_link($link); $item->set_guid($link); $item->set_desc(FormatingHelper::second_parse($row['contents'])); $item->set_date(new Date($row['creation_date'], Timezone::SERVER_TIMEZONE)); $item->set_image_url($row['picture_url']); $item->set_auth(DownloadService::get_categories_manager()->get_heritated_authorizations($row['id_category'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY)); $data->add_item($item); } $results->dispose(); return $data; } }
private function generate_response(View $tpl) { $downloadfile = $this->get_downloadfile(); $response = new SiteDisplayResponse($tpl); $graphical_environment = $response->get_graphical_environment(); $breadcrumb = $graphical_environment->get_breadcrumb(); $breadcrumb->add($this->lang['module_title'], DownloadUrlBuilder::home()); if ($downloadfile->get_id() === null) { $graphical_environment->set_page_title($this->lang['download.add'], $this->lang['module_title']); $breadcrumb->add($this->lang['download.add'], DownloadUrlBuilder::add($downloadfile->get_id_category())); $graphical_environment->get_seo_meta_data()->set_description($this->lang['download.add']); $graphical_environment->get_seo_meta_data()->set_canonical_url(DownloadUrlBuilder::add($downloadfile->get_id_category())); } else { $graphical_environment->set_page_title($this->lang['download.edit'], $this->lang['module_title']); $graphical_environment->get_seo_meta_data()->set_description($this->lang['download.edit']); $graphical_environment->get_seo_meta_data()->set_canonical_url(DownloadUrlBuilder::edit($downloadfile->get_id())); $categories = array_reverse(DownloadService::get_categories_manager()->get_parents($downloadfile->get_id_category(), true)); foreach ($categories as $id => $category) { if ($category->get_id() != Category::ROOT_CATEGORY) { $breadcrumb->add($category->get_name(), DownloadUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name())); } } $category = $downloadfile->get_category(); $breadcrumb->add($downloadfile->get_name(), DownloadUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $downloadfile->get_id(), $downloadfile->get_rewrited_name())); $breadcrumb->add($this->lang['download.edit'], DownloadUrlBuilder::edit($downloadfile->get_id())); } return $response; }
protected function get_categories_management_url() { return DownloadUrlBuilder::manage_categories(); }
public function get_array_tpl_vars() { $category = $this->get_category(); $contents = FormatingHelper::second_parse($this->contents); $description = $this->get_real_short_contents(); $user = $this->get_author_user(); $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true); $number_comments = CommentsService::get_number_comments('download', $this->id); return array('C_VISIBLE' => $this->is_visible(), 'C_EDIT' => $this->is_authorized_to_edit(), 'C_DELETE' => $this->is_authorized_to_delete(), 'C_READ_MORE' => !$this->is_short_contents_enabled() && $description != $contents && strlen($description) >= DownloadConfig::NUMBER_CARACTERS_BEFORE_CUT, 'C_SIZE' => !empty($this->size), 'C_PICTURE' => $this->has_picture(), 'C_CUSTOM_AUTHOR_DISPLAY_NAME' => $this->is_author_display_name_enabled(), 'C_USER_GROUP_COLOR' => !empty($user_group_color), 'C_UPDATED_DATE' => $this->has_updated_date(), 'ID' => $this->id, 'NAME' => $this->name, 'SIZE' => $this->formated_size, 'CONTENTS' => $contents, 'DESCRIPTION' => $description, 'DATE' => $this->creation_date->format(Date::FORMAT_DAY_MONTH_YEAR), 'DATE_DAY' => $this->creation_date->get_day(), 'DATE_MONTH' => $this->creation_date->get_month(), 'DATE_YEAR' => $this->creation_date->get_year(), 'DATE_DAY_MONTH' => $this->creation_date->format(Date::FORMAT_DAY_MONTH), 'DATE_ISO8601' => $this->creation_date->format(Date::FORMAT_ISO8601), 'UPDATED_DATE' => $this->updated_date !== null ? $this->updated_date->format(Date::FORMAT_DAY_MONTH_YEAR) : '', 'UPDATED_DATE_ISO8601' => $this->updated_date !== null ? $this->updated_date->format(Date::FORMAT_ISO8601) : '', 'STATUS' => $this->get_status(), 'CUSTOM_AUTHOR_DISPLAY_NAME' => $this->author_display_name, 'C_AUTHOR_EXIST' => $user->get_id() !== User::VISITOR_LEVEL, 'PSEUDO' => $user->get_display_name(), 'USER_LEVEL_CLASS' => UserService::get_level_class($user->get_level()), 'USER_GROUP_COLOR' => $user_group_color, 'NUMBER_DOWNLOADS' => $this->number_downloads, 'L_DOWNLOADED_TIMES' => StringVars::replace_vars(LangLoader::get_message('downloaded_times', 'common', 'download'), array('number_downloads' => $this->number_downloads)), 'STATIC_NOTATION' => NotationService::display_static_image($this->get_notation()), 'NOTATION' => NotationService::display_active_image($this->get_notation()), 'C_COMMENTS' => !empty($number_comments), 'L_COMMENTS' => CommentsService::get_lang_comments('download', $this->id), 'NUMBER_COMMENTS' => CommentsService::get_number_comments('download', $this->id), 'C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'CATEGORY_ID' => $category->get_id(), 'CATEGORY_NAME' => $category->get_name(), 'CATEGORY_DESCRIPTION' => $category->get_description(), 'CATEGORY_IMAGE' => $category->get_image()->rel(), 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? DownloadUrlBuilder::configuration()->rel() : DownloadUrlBuilder::edit_category($category->get_id())->rel(), 'U_SYNDICATION' => SyndicationUrlBuilder::rss('download', $this->id_category)->rel(), 'U_AUTHOR_PROFILE' => UserUrlBuilder::profile($this->get_author_user()->get_id())->rel(), 'U_LINK' => DownloadUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $this->id, $this->rewrited_name)->rel(), 'U_DOWNLOAD' => DownloadUrlBuilder::download($this->id)->rel(), 'U_DEADLINK' => DownloadUrlBuilder::dead_link($this->id)->rel(), 'U_CATEGORY' => DownloadUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name())->rel(), 'U_EDIT' => DownloadUrlBuilder::edit($this->id)->rel(), 'U_DELETE' => DownloadUrlBuilder::delete($this->id)->rel(), 'U_PICTURE' => $this->get_picture()->rel(), 'U_COMMENTS' => DownloadUrlBuilder::display_comments($category->get_id(), $category->get_rewrited_name(), $this->id, $this->rewrited_name)->rel()); }
* ################################################### * * This program is a free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in hope that it will be useful, * 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. * ###################################################*/ #################################################### # English # #################################################### $lang['root_category_description'] = 'Welcome to the downloads section of the website! <br /><br /> One category and one file were created to show you how this module works. Here are some tips to get started on this module. <br /><br /> <ul class="formatter-ul"> <li class="formatter-li"> To configure or customize the module homepage your module, go into the <a href="' . DownloadUrlBuilder::configuration()->relative() . '">module administration</a></li> <li class="formatter-li"> To create categories, <a href="' . DownloadUrlBuilder::add_category()->relative() . '">clic here</a></li> <li class="formatter-li"> To create download files, <a href="' . DownloadUrlBuilder::add()->relative() . '">clic here</a></li> </ul> <br />To learn more, don \'t hesitate to consult the documentation for the module on <a href="http://www.phpboost.com">PHPBoost</a> website.';
private function generate_response() { $response = new SiteDisplayResponse($this->tpl); $graphical_environment = $response->get_graphical_environment(); $graphical_environment->set_page_title($this->get_category()->get_name(), $this->lang['module_title']); $graphical_environment->get_seo_meta_data()->set_description($this->get_category()->get_description()); $graphical_environment->get_seo_meta_data()->set_canonical_url(DownloadUrlBuilder::display_category($this->get_category()->get_id(), $this->get_category()->get_rewrited_name(), AppContext::get_request()->get_getstring('field', 'date'), AppContext::get_request()->get_getstring('sort', 'desc'), AppContext::get_request()->get_getint('page', 1))); $breadcrumb = $graphical_environment->get_breadcrumb(); $breadcrumb->add($this->lang['module_title'], DownloadUrlBuilder::home()); $categories = array_reverse(DownloadService::get_categories_manager()->get_parents($this->get_category()->get_id(), true)); foreach ($categories as $id => $category) { if ($category->get_id() != Category::ROOT_CATEGORY) { $breadcrumb->add($category->get_name(), DownloadUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name())); } } return $response; }
private function generate_response() { $response = new SiteDisplayResponse($this->tpl); $graphical_environment = $response->get_graphical_environment(); $graphical_environment->set_page_title($this->lang['download.pending'], $this->lang['module_title']); $graphical_environment->get_seo_meta_data()->set_description($this->lang['download.seo.description.pending']); $graphical_environment->get_seo_meta_data()->set_canonical_url(DownloadUrlBuilder::display_pending(AppContext::get_request()->get_getstring('field', 'date'), AppContext::get_request()->get_getstring('sort', 'desc'), AppContext::get_request()->get_getint('page', 1))); $breadcrumb = $graphical_environment->get_breadcrumb(); $breadcrumb->add($this->lang['module_title'], DownloadUrlBuilder::home()); $breadcrumb->add($this->lang['download.pending'], DownloadUrlBuilder::display_pending()); return $response; }
protected function get_category_url(Category $category) { return DownloadUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name()); }
private function generate_response() { $response = new SiteDisplayResponse($this->tpl); $graphical_environment = $response->get_graphical_environment(); $graphical_environment->set_page_title($this->get_keyword()->get_name(), $this->lang['module_title']); $graphical_environment->get_seo_meta_data()->set_description(StringVars::replace_vars($this->lang['download.seo.description.tag'], array('subject' => $this->get_keyword()->get_name()))); $graphical_environment->get_seo_meta_data()->set_canonical_url(DownloadUrlBuilder::display_tag($this->get_keyword()->get_rewrited_name(), AppContext::get_request()->get_getstring('field', 'date'), AppContext::get_request()->get_getstring('sort', 'desc'), AppContext::get_request()->get_getint('page', 1))); $breadcrumb = $graphical_environment->get_breadcrumb(); $breadcrumb->add($this->lang['module_title'], DownloadUrlBuilder::home()); $breadcrumb->add($this->get_keyword()->get_name(), DownloadUrlBuilder::display_tag($this->get_keyword()->get_rewrited_name(), AppContext::get_request()->get_getint('page', 1))); return $response; }
* ################################################### * * This program is a free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in hope that it will be useful, * 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. * ###################################################*/ #################################################### # French # #################################################### $lang['root_category_description'] = 'Bienvenue dans l\'espace de téléchargement du site ! <br /><br /> Une catégorie et un fichier ont été créés pour vous montrer comment fonctionne ce module. Voici quelques conseils pour bien débuter sur ce module. <br /><br /> <ul class="formatter-ul"> <li class="formatter-li"> Pour configurer ou personnaliser l\'accueil de votre module, rendez vous dans l\'<a href="' . DownloadUrlBuilder::configuration()->relative() . '">administration du module</a></li> <li class="formatter-li"> Pour créer des catégories, <a href="' . DownloadUrlBuilder::add_category()->relative() . '">cliquez ici</a> </li> <li class="formatter-li"> Pour ajouter des fichiers en téléchargement, <a href="' . DownloadUrlBuilder::add()->relative() . '">cliquez ici</a></li> </ul> <br />Pour en savoir plus, n\'hésitez pas à consulter la documentation du module sur le site de <a href="http://www.phpboost.com">PHPBoost</a>.';
protected function get_delete_category_url(Category $category) { return DownloadUrlBuilder::delete_category($category->get_id()); }