public function execute(HTTPRequestCustom $request) { $module_id = $request->get_getstring('module_id', ''); if (empty($module_id)) { AppContext::get_response()->redirect(Environment::get_home_page()); } $this->init(); $module_category_id = $request->get_getint('module_category_id', 0); $feed_name = $request->get_getstring('feed_name', Feed::DEFAULT_FEED_NAME); $feed = new ATOM($module_id, $feed_name, $module_category_id); if ($feed !== null && $feed->is_in_cache()) { $this->tpl->put('SYNDICATION', $feed->read()); } else { $eps = AppContext::get_extension_provider_service(); if ($eps->provider_exists($module_id, FeedProvider::EXTENSION_POINT)) { $provider = $eps->get_provider($module_id); $feeds = $provider->feeds(); $data = $feeds->get_feed_data_struct($module_category_id, $feed_name); if ($data === null) { AppContext::get_response()->set_header('content-type', 'text/html'); DispatchManager::redirect(PHPBoostErrors::unexisting_element()); } else { $feed->load_data($data); $feed->cache(); $this->tpl->put('SYNDICATION', $feed->export()); } } else { DispatchManager::redirect(PHPBoostErrors::module_not_installed()); } } return $this->build_response($this->tpl); }
public function execute(HTTPRequestCustom $request) { $this->init(); $user_id = $request->get_getint('user_id', AppContext::get_current_user()->get_id()); try { $this->user_infos = PersistenceContext::get_querier()->select_single_row(PREFIX . 'member', array('*'), 'WHERE user_id=:user_id', array('user_id' => $user_id)); } catch (RowNotFoundException $e) { $error_controller = PHPBoostErrors::unexisting_element(); DispatchManager::redirect($error_controller); } $this->build_form($this->user_infos['user_id']); $this->tpl->put('FORM', $this->form->display()); return $this->build_response($this->tpl, $user_id); }
public function execute(HTTPRequestCustom $request) { $this->init(); $user_id = $request->get_getint('user_id', 0); if (empty($user_id)) { AppContext::get_response()->redirect(UserUrlBuilder::home()); } try { $this->user = UserService::get_user($user_id); } catch (RowNotFoundException $e) { $error_controller = PHPBoostErrors::unexisting_element(); DispatchManager::redirect($error_controller); } $this->build_form(); return $this->build_response($this->tpl); }
public function execute(HTTPRequestCustom $request) { $user_id = $request->get_int('id', null); $user = UserService::get_user($user_id); if (!$user->is_admin() || $user->is_admin() && UserService::count_admin_members() > 1) { try { UserService::delete_by_id($user_id); } catch (RowNotFoundException $ex) { $error_controller = PHPBoostErrors::unexisting_element(); DispatchManager::redirect($error_controller); } AppContext::get_response()->redirect($request->get_url_referrer() ? $request->get_url_referrer() : AdminMembersUrlBuilder::management(), StringVars::replace_vars(LangLoader::get_message('user.message.success.delete', 'user-common'), array('name' => $user->get_display_name()))); } else { $error_controller = PHPBoostErrors::unauthorized_action(); DispatchManager::redirect($error_controller); } }
public function execute(HTTPRequestCustom $request) { $module_id = $request->get_getstring('module_id', ''); $user_id = $request->get_getint('user_id', 0); if (!empty($user_id)) { try { $this->user = UserService::get_user($user_id); } catch (Exception $e) { $error_controller = PHPBoostErrors::unexisting_element(); DispatchManager::redirect($error_controller); } } if (!empty($module_id)) { $this->module = ModulesManager::get_module($module_id); } $this->init($request); return $this->build_response(); }
public function execute(HTTPRequestCustom $request) { $this->init(); $user_id = $request->get_getint('user_id', AppContext::get_current_user()->get_id()); try { $this->user = UserService::get_user($user_id); } catch (RowNotFoundException $e) { $error_controller = PHPBoostErrors::unexisting_element(); DispatchManager::redirect($error_controller); } try { $this->internal_auth_infos = PHPBoostAuthenticationMethod::get_auth_infos($user_id); } catch (RowNotFoundException $e) { } $this->user_auth_types = AuthenticationService::get_user_types_authentication($user_id); if (!$this->check_authorizations($user_id)) { $error_controller = PHPBoostErrors::user_not_authorized(); DispatchManager::redirect($error_controller); } $associate_type = $request->get_getvalue('associate', false); if ($associate_type) { if (!in_array($associate_type, $this->user_auth_types)) { $authentication_method = AuthenticationService::get_authentication_method($associate_type); AuthenticationService::associate($authentication_method, $user_id); AppContext::get_response()->redirect(UserUrlBuilder::edit_profile($user_id)); } } $dissociate_type = $request->get_getvalue('dissociate', false); if ($dissociate_type) { if (in_array($dissociate_type, $this->user_auth_types) && count($this->user_auth_types) > 1) { $authentication_method = AuthenticationService::get_authentication_method($dissociate_type); AuthenticationService::dissociate($authentication_method, $user_id); AppContext::get_response()->redirect(UserUrlBuilder::edit_profile($user_id)); } } $this->build_form(); if ($this->submit_button->has_been_submited() && $this->form->validate()) { $this->save($request); } $this->tpl->put('FORM', $this->form->display()); return $this->build_response(); }
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); }
try { $check_mbr = PersistenceContext::get_querier()->get_column_value(PREFIX . 'forum_topics', 'user_id', 'WHERE id=:id', array('id' => $idt_get)); } catch (RowNotFoundException $e) { } if (!empty($check_mbr) && AppContext::get_current_user()->get_id() == $check_mbr || ForumAuthorizationsService::check_authorizations($topic['idcat'])->moderation()) { PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "forum_topics SET display_msg = 1 - display_msg WHERE id = '" . $idt_get . "'"); AppContext::get_response()->redirect('/forum/topic' . url('.php?id=' . $idt_get, '-' . $idt_get . $rewrited_title . '.php', '&')); } else { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } } elseif ($poll && AppContext::get_current_user()->get_id() !== -1) { try { $info_poll = PersistenceContext::get_querier()->select_single_row(PREFIX . 'forum_poll', array('voter_id', 'votes', 'type'), 'WHERE idtopic=:id', array('id' => $idt_get)); } catch (RowNotFoundException $e) { $error_controller = PHPBoostErrors::unexisting_element(); DispatchManager::redirect($error_controller); } //Si l'utilisateur n'est pas dans le champ on prend en compte le vote. $voter_id = explode('|', $info_poll['voter_id']); if (!in_array(AppContext::get_current_user()->get_id(), $voter_id)) { //On concatène avec les votans existants. $voter_id[] = AppContext::get_current_user()->get_id(); $array_votes = explode('|', $info_poll['votes']); if ($info_poll['type'] == 0) { $id_answer = retrieve(POST, 'forumpoll', 0); if (isset($array_votes[$id_answer])) { $array_votes[$id_answer]++; } } else { //On boucle pour vérifier toutes les réponses du sondage.
public function Del_pics($id_pics) { try { $info_pics = PersistenceContext::get_querier()->select_single_row(GallerySetup::$gallery_table, array('path', 'idcat', 'aprob'), "WHERE id = :id", array('id' => $id_pics)); } catch (RowNotFoundException $e) { $error_controller = PHPBoostErrors::unexisting_element(); DispatchManager::redirect($error_controller); } if (!empty($info_pics['path'])) { PersistenceContext::get_querier()->delete(PREFIX . 'gallery', 'WHERE id=:id', array('id' => $id_pics)); //Suppression physique. $file = new File(PATH_TO_ROOT . '/gallery/pics/' . $info_pics['path']); $file->delete(); $file = new File(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $info_pics['path']); $file->delete(); NotationService::delete_notes_id_in_module('gallery', $id_pics); CommentsService::delete_comments_topic_module('gallery', $id_pics); } }