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); } }
function Alert_topic($alert_post, $alert_title, $alert_contents) { global $LANG; try { $topic_infos = PersistenceContext::get_querier()->select_single_row(PREFIX . 'forum_topics', array("idcat", "title"), 'WHERE id=:id', array('id' => $alert_post)); } catch (RowNotFoundException $e) { $error_controller = PHPBoostErrors::unexisting_element(); DispatchManager::redirect($error_controller); } $result = PersistenceContext::get_querier()->insert(PREFIX . "forum_alerts", array('idcat' => $topic_infos['idcat'], 'idtopic' => $alert_post, 'title' => $alert_title, 'contents' => $alert_contents, 'user_id' => AppContext::get_current_user()->get_id(), 'status' => 0, 'idmodo' => 0, 'timestamp' => time())); $alert_id = $result->get_last_inserted_id(); $contribution = new Contribution(); //The id of the file in the module. It's useful when the module wants to search a contribution (we will need it in the file edition) $contribution->set_id_in_module($alert_id); //The entitled of the contribution $contribution->set_entitled(sprintf($LANG['contribution_alert_moderators_for_topics'], stripslashes($alert_title))); //The URL where a validator can treat the contribution (in the file edition panel) $contribution->set_fixing_url('/forum/moderation_forum.php?action=alert&id=' . $alert_id); //Description $contribution->set_description(stripslashes($alert_contents)); //Who is the contributor? $contribution->set_poster_id(AppContext::get_current_user()->get_id()); //The module $contribution->set_module('forum'); //It's an alert, we will be able to manage other kinds of contributions in the module if we choose to use a type. $contribution->set_type('alert'); //Assignation des autorisations d'écriture / Writing authorization assignation $contribution->set_auth(Authorizations::capture_and_shift_bit_auth(ForumService::get_categories_manager()->get_heritated_authorizations($topic_infos['idcat'], Category::MODERATION_AUTHORIZATIONS, Authorizations::AUTH_CHILD_PRIORITY), Category::MODERATION_AUTHORIZATIONS, Contribution::CONTRIBUTION_AUTH_BIT)); //Sending the contribution to the kernel. It will place it in the contribution panel to be approved ContributionService::save_contribution($contribution); }
function Alert_topic($alert_post, $alert_title, $alert_contents) { global $Sql, $User, $CAT_FORUM, $LANG; $topic_infos = $Sql->query_array(PREFIX . "forum_topics", "idcat", "title", "WHERE id = '" . $alert_post . "'", __LINE__, __FILE__); $Sql->query_inject("INSERT INTO " . PREFIX . "forum_alerts (idcat, idtopic, title, contents, user_id, status, idmodo, timestamp) VALUES ('" . $topic_infos['idcat'] . "', '" . $alert_post . "', '" . $alert_title . "', '" . $alert_contents . "', '" . $User->get_attribute('user_id') . "', 0, 0, '" . time() . "')", __LINE__, __FILE__); $alert_id = $Sql->insert_id("SELECT MAX(id) FROM " . PREFIX . "forum_alerts"); import('events/contribution'); import('events/contribution_service'); $contribution = new Contribution(); $contribution->set_id_in_module($alert_id); $contribution->set_entitled(sprintf($LANG['contribution_alert_moderators_for_topics'], stripslashes($alert_title))); $contribution->set_fixing_url('/forum/moderation_forum.php?action=alert&id=' . $alert_id); $contribution->set_description(stripslashes($alert_contents)); $contribution->set_poster_id($User->get_attribute('user_id')); $contribution->set_module('forum'); $contribution->set_type('alert'); $contribution->set_auth(Authorizations::capture_and_shift_bit_auth($CAT_FORUM[$topic_infos['idcat']]['auth'], EDIT_CAT_FORUM, CONTRIBUTION_AUTH_BIT)); ContributionService::save_contribution($contribution); }