public function index() { $P = PVars::getObj('page'); $vw = new ViewWrap($this->_view); $cw = new ViewWrap($this); // index is called when http request = ./blog if (PPostHandler::isHandling()) { return; } $request = PRequest::get()->request; $member = $this->_model->getLoggedInMember(); //$User = A PP_User::login(); if (!isset($request[1])) { $request[1] = ''; } // user bar // show the userbar always for now: /*if ($User && $request[1] != 'tags') { */ // $P->newBar .= $vw->userbar(); /*} */ $bloguser = 0; $RSS = false; switch ($request[1]) { case 'ajax': if (!isset($request[2])) { PPHP::PExit(); } switch ($request[2]) { case 'post': $this->ajaxPost(); break; } break; case 'suggestTags': // ignore current request, so we can use the last request PRequest::ignoreCurrentRequest(); if (!isset($request[2])) { PPHP::PExit(); } $new_tags = $this->_model->suggestTags($request[2]); echo $this->_view->generateClickableTagSuggestions($new_tags); PPHP::PExit(); break; case 'suggestLocation': // ignore current request, so we can use the last request PRequest::ignoreCurrentRequest(); if (!isset($request[2])) { PPHP::PExit(); } $locations = $this->_model->suggestLocation($request[2]); echo $this->_view->generateLocationOverview($locations); PPHP::PExit(); break; case 'create': if (!$member) { PRequest::home(); } if (isset($request[2]) && $request[2] == 'finish' && isset($request[3]) && $this->_model->isPostId($request[3])) { $page = new BlogSinglePostPage($this->_model); $page->member = $member; $page->post = $this->_model->getPost($request[3]); } else { $page = new BlogCreatePage($this->_model); } return $page; case 'del': if (!$member || !isset($request[2]) || !$this->_model->isUserPost($member->id, $request[2])) { PRequest::home(); } $post = $this->_model->getPost($request[2]); $p = new BlogDeletePage($this->_model); $p->member = $member; $p->post = $post; return $p; case 'edit': if (!$member || !isset($request[2]) || !$this->_model->isUserPost($member->id, $request[2])) { PRequest::home(); } if (isset($request[3]) && $request[3] == 'finish') { $p = new BlogSinglePostPage($this->_model); $p->member = $member; $p->post = $this->_model->getPost($request[2]); return $p; } else { //$callbackId = $this->editProcess((int)$request[2]); //$vars =& PPostHandler::getVars($callbackId); if (!isset($vars['errors']) || !is_array($vars['errors'])) { $vars['errors'] = array(); } $this->_editFill($request[2], $vars); $p = new BlogEditPage($this->_model); $p->post = $this->_model->getPost($request[2]); $p->member = $member; $p->vars = $vars; return $p; $P->content .= $vw->editForm((int) $request[2], $callbackId); } break; case 'search': if (!empty($this->args_vars->get['s']) && strlen($this->args_vars->get['s']) >= 3) { $search = $this->args_vars->get['s']; $tagsposts = $this->_model->getTaggedPostsIt($search); $posts = $this->_model->searchPosts($search); } else { $error = 'To few arguments'; $posts = false; $tagsposts = false; $search = ''; } $p = new BlogSearchPage($this->_model); $p->posts = $posts; $p->tagged_posts = $tagsposts; $p->search = $search; return $p; $P->content .= $vw->searchPage($posts, $tagsposts); break; /* removed - references user app case 'settings': $p = new BlogSettingsPage($this->_model); return $p; $P->content .= $vw->settingsForm(); break; */ /* removed - references user app case 'settings': $p = new BlogSettingsPage($this->_model); return $p; $P->content .= $vw->settingsForm(); break; */ case 'tags': $p = new BlogTagsPage($this->_model); $p->tag = isset($request[2]) ? $request[2] : false; return $p; $P->content .= $vw->tags(isset($request[2]) ? $request[2] : false); break; case 'cat': $p = new BlogCategoriesPage($this->_model); return $p; break; default: $page = isset($this->args_vars->get['page']) && intval($this->args_vars->get['page']) ? intval($this->args_vars->get['page']) : 1; // display blogs of user $request[1] $memberBlog = $this->_model->getMemberByUsername($request[1]); if ($memberBlog) { if (!isset($request[2])) { $request[2] = ''; } switch ($request[2]) { case 'cat': if (isset($request[3])) { $p = new BlogPage($this->_model); $p->page = $page; $p->category = $request[3]; $p->member = $memberBlog; $p->initPager($this->_model->countRecentPosts($memberBlog->id, $request[3]), $page); $p->posts = $this->_model->getRecentPostsArray($memberBlog->id, $request[3], $page); break; } // if we're not dealing with a category, fall through and hit the default // if we're not dealing with a category, fall through and hit the default case '': default: // show different blog layout for public visitors if ($post = $this->_model->getPost($request[2])) { $p = new BlogSinglePostPage($this->_model); $p->member = $memberBlog; $p->post = $post; } else { $p = new BlogPage($this->_model); $p->page = $page; $p->member = $memberBlog; $p->initPager($this->_model->countRecentPosts($memberBlog->id, false), $page); $p->posts = $this->_model->getRecentPostsArray($memberBlog->id, false, $page); } break; } } else { $p = new BlogPage($this->_model); $p->page = $page; $p->initPager($this->_model->countRecentPosts(false, false), $page); $p->posts = $this->_model->getRecentPostsArray(false, false, $page); } return $p; } }
/** * index is called when http request = ./forums * or during a new topic/edit of a group */ public function index($subforum = false) { if (PPostHandler::isHandling()) { return; } // Determine the search callback and tell the view about it $searchCallbackId = $this->searchProcess(); $view = $this->_view; $view->searchCallbackId = $searchCallbackId; $page = $view->page = new RoxGenericPage(); $request = $this->request; if (isset($request[0]) && $request[0] != 'forums') { // if this is a ./groups url get the group number if any if ($request[0] == "groups" && isset($request[1])) { $IdGroup = intval($request[1]); } $new_request = array(); $push = false; foreach ($request as $r) { if ($r == 'forums' or $r == 'forum') { $push = true; } if ($push == true) { array_push($new_request, $r); } } $request = $new_request; $page = $view->page = new PageWithHTMLpart(); } // First check if the feature is closed if ($_SESSION["Param"]->FeatureForumClosed != 'No' and !$this->BW_Right->HasRight("Admin")) { $this->_view->showFeatureIsClosed(); PPHP::PExit(); } // end of test "if feature is closed" if (APP_User::isBWLoggedIn()) { $User = APP_User::login(); } else { $User = false; } $showSticky = true; $this->parseRequest(); // set uri for correct links in group pages etc. $view->uri = $this->uri; $page->uri = $this->uri; $view->BW_Right = $this->BW_Right; $page->BW_Right = $this->BW_Right; $this->_model->prepareForum($showSticky); // first include the col2-stylesheet $page->addStyles .= $view->customStyles(); $page->currentTab = 'forums'; // then the userBar $page->newBar .= $view->getAsString('userBar'); // we can't replace this ob_start() if ($this->action == self::ACTION_NOT_LOGGED_IN) { $this->_redirectNotLoggedIn(); } ob_start(); if ($this->action == self::ACTION_VOTE_POST) { if (!isset($request[2])) { die("Need to have a IdPost"); } $IdPost = $request[2]; if (!isset($request[3])) { die("Need to have a vote value"); } $Value = $request[3]; $this->_model->VoteForPost($IdPost, $Value); $this->_model->setThreadId($this->_model->GetIdThread($IdPost)); $this->isTopLevel = false; $this->_model->prepareTopic(true); $this->_view->showTopic(); } elseif ($this->action == self::ACTION_DELETEVOTE_POST) { if (!isset($request[2])) { die("Need to have a IdPost"); } $IdPost = $request[2]; $this->_model->DeleteVoteForPost($IdPost); $this->_model->setThreadId($this->_model->GetIdThread($IdPost)); $this->isTopLevel = false; $this->_model->prepareTopic(true); $this->_view->showTopic(); } elseif ($this->action == self::ACTION_MODERATOR_FULLEDITPOST) { if (!isset($request[2])) { die("Need to have a IdPost"); } $IdPost = $request[2]; if (!$this->BW_Right->HasRight("ForumModerator", "Edit")) { MOD_log::get()->write("Trying to edit post #" . $IdPost . " without proper right", "ForumModerator"); die("You miss right ForumModerator"); } $callbackId = $this->ModeratorEditPostProcess(); $DataPost = $this->_model->prepareModeratorEditPost($IdPost); $this->_view->showModeratorEditPost($callbackId, $DataPost); PPostHandler::clearVars($callbackId); } elseif ($this->action == self::ACTION_MODERATOR_EDITTAG) { if (!isset($request[2])) { die("Need to have a IdTag"); } $IdTag = $request[2]; if (!$this->BW_Right->HasRight("ForumModerator", "Edit")) { MOD_log::get()->write("Trying to edit Tag #" . $IdTag . " without proper right", "ForumModerator"); die("You miss right ForumModerator"); } $callbackId = $this->ModeratorEditTagProcess(); $DataTag = $this->_model->prepareModeratorEditTag($IdTag); $this->_view->showModeratorEditTag($callbackId, $DataTag); PPostHandler::clearVars($callbackId); } else { if ($this->action == self::ACTION_VIEW) { if ($this->_model->isTopic()) { $this->_model->prepareTopic(true); $this->_view->showTopic(); } else { if ($this->isTopLevel) { $this->_model->setTopMode(Forums::CV_TOPMODE_LANDING); $this->_model->prepareForum(); $onlymygroupscallbackId = $this->mygroupsonlyProcess(); $morelessthreadscallbackid = $this->morelessthreadsProcess(); $this->_view->showTopLevelLandingPage($onlymygroupscallbackId, $morelessthreadscallbackid); PPostHandler::clearVars($onlymygroupscallbackId); PPostHandler::clearVars($morelessthreadscallbackid); } else { $this->_model->prepareForum(); $this->_view->showForum(); } } } else { if ($this->action == self::ACTION_VIEW_CATEGORY) { $this->_view->showTopLevelCategories(); } else { if ($this->action == self::ACTION_VIEW_LASTPOSTS) { $callbackId = $this->mygroupsonlyProcess(); $this->_view->showTopLevelRecentPosts($callbackId); PPostHandler::clearVars($callbackId); } else { if ($this->action == self::ACTION_VIEW_LANDING) { $callbackId = $this->mygroupsonlyProcess(); $this->_view->showTopLevelLandingPage($callbackId); PPostHandler::clearVars($callbackId); } else { if ($this->action == self::ACTION_VIEW_FORUM) { $groupsCallback = false; $member = $this->_model->getLoggedInMember(); if ($member && $member->Status != 'ChoiceInactive') { $noForumNewTopicButton = false; } else { // Don't offer the new topic button to 'silent' members $noForumNewTopicButton = true; } $this->_view->showTopLevelRecentPosts($groupsCallback, $noForumNewTopicButton); } else { if ($this->action == self::ACTION_VIEW_GROUPS) { $callbackId = $this->mygroupsonlyProcess(); $this->_view->showTopLevelRecentPosts($callbackId, true); PPostHandler::clearVars($callbackId); } else { if ($this->action == self::ACTION_RULES) { $this->_view->rules(); } else { if ($this->action == self::ACTION_NEW) { if ($this->BW_Flag->hasFlag("NotAllowedToPostInForum")) { // Test if the user has right for this, if not rough exit MOD_log::get()->write("Forums.ctrl : Forbid to do action [" . $this->action . "] because of Flag " . "NotAllowedToPostInForum", "FlagEvent"); $words = new MOD_Words(); die($words->get('NotAllowedToPostInForum')); } if (!$User) { PRequest::home(); } if (isset($request[2]) and $request[2][0] == 'u') { $IdGroup = substr($request[2], 1); } else { if (!isset($IdGroup)) { $IdGroup = 0; } } $this->_model->prepareForum(); $callbackId = $this->createProcess(); $this->_view->createTopic($callbackId, $IdGroup); PPostHandler::clearVars($callbackId); } else { if ($this->action == self::ACTION_REPORT_TO_MOD) { if ($this->BW_Flag->hasFlag("NotAllowedToPostInForum")) { // Test if the user has right for this, if not rough exit MOD_log::get()->write("Forums.ctrl : Forbid to do action [" . $this->action . "] because of Flag " . "NotAllowedToPostInForum", "FlagEvent"); $words = new MOD_Words(); die($words->get('NotAllowedToPostInForum')); } if (!$User) { PRequest::home(); } $callbackId = $this->reportpostProcess(); if (isset($request[2])) { if ($request[2] == 'AllMyReport') { $DataPost = $this->_model->prepareReportList($_SESSION["IdMember"], ""); // This retrieve all the reports for the current member $this->_view->showReportList($callbackId, $DataPost); } elseif ($request[2] == 'MyReportActive') { $DataPost = $this->_model->prepareReportList($_SESSION["IdMember"], "('Open','OnDiscussion')"); // This retrieve the Active current pending report for the current member $this->_view->showReportList($callbackId, $DataPost); } elseif ($request[2] == 'AllActiveReports') { if (!$this->BW_Right->HasRight("ForumModerator")) { // if a non forum moderator tries to access this just pull the brakes PPHP::PExit(); } $DataPost = $this->_model->prepareReportList(0, "('Open','OnDiscussion')"); // This retrieve all the current Active pending report $this->_view->showReportList($callbackId, $DataPost); } else { $IdPost = $request[2]; $IdWriter = $_SESSION["IdMember"]; if (!empty($request[3]) and $this->BW_Right->HasRight("ForumModerator")) { $IdWriter = $request[3]; } $DataPost = $this->_model->prepareModeratorEditPost($IdPost, $this->BW_Right->HasRight('ForumModerator')); // We will use the same data as the one used for Moderator edit if ($DataPost->Error == 'NoGroupMember') { // if someone who isn't a member of the associated group // tries to access this just pull the brakes PPHP::PExit(); } $DataPost->Report = $this->_model->prepareReportPost($IdPost, $IdWriter); $this->_view->showReportPost($callbackId, $DataPost); } PPostHandler::clearVars($callbackId); } } else { if ($this->action == self::ACTION_REPLY) { if ($this->BW_Flag->hasFlag("NotAllowedToPostInForum")) { // Test if teh user has right for this, if not rough exit MOD_log::get()->write("Forums.ctrl : Forbid to do action [" . $this->action . "] because of Flag " . "NotAllowedToPostInForum", "FlagEvent"); $words = new MOD_Words(); die($words->get('NotAllowedToPostInForum')); } if (!$User) { PRequest::home(); } $this->_model->prepareForum(); $this->_model->prepareTopic(); $this->_model->initLastPosts(); $callbackId = $this->replyProcess(); $this->_view->replyTopic($callbackId); PPostHandler::clearVars($callbackId); } else { if ($this->action == self::ACTION_SUGGEST) { // ignore current request, so we can use the last request PRequest::ignoreCurrentRequest(); if (!isset($request[2])) { PPHP::PExit(); } $new_tags = $this->_model->suggestTags($request[2]); echo $this->_view->generateClickableTagSuggestions($new_tags); PPHP::PExit(); } else { if ($this->action == self::ACTION_LOCATIONDROPDOWNS) { // ignore current request, so we can use the last request PRequest::ignoreCurrentRequest(); if (!isset($request[2])) { PPHP::PExit(); } echo $this->_view->getLocationDropdowns(); PPHP::PExit(); } else { if ($this->action == self::ACTION_DELETE) { if ($this->BW_Flag->hasFlag("NotAllowedToPostInForum")) { // Test if the user has right for this, if not rough exit MOD_log::get()->write("Forums.ctrl : Forbid to do action [" . $this->action . "] because of Flag " . "NotAllowedToPostInForum", "FlagEvent"); $words = new MOD_Words(); die($words->get('NotAllowedToPostInForum')); } if (!$User || !$this->BW_Right->HasRight("ForumModerator", "Delete")) { PRequest::home(); } $this->delProcess(); } else { if ($this->action == self::ACTION_EDIT) { if ($this->BW_Flag->hasFlag("NotAllowedToPostInForum")) { // Test if the user has right for this, if not rough exit MOD_log::get()->write("Forums.ctrl : Forbid to do action [" . $this->action . "] because of Flag " . "NotAllowedToPostInForum", "FlagEvent"); $words = new MOD_Words(); die($words->get('NotAllowedToPostInForum')); } if (!$User) { PRequest::home(); } $callbackId = $this->editProcess(); $this->_model->prepareForum(); $this->_model->getEditData($callbackId); $this->_view->editPost($callbackId, false); PPostHandler::clearVars($callbackId); } else { if ($this->action == self::ACTION_TRANSLATE) { if ($this->BW_Flag->hasFlag("NotAllowedToPostInForum")) { // Test if the user has right for this, if not rough exit MOD_log::get()->write("Forums.ctrl : Forbid to do action [" . $this->action . "] because of Flag " . "NotAllowedToPostInForum", "FlagEvent"); $words = new MOD_Words(); die($words->get('NotAllowedToPostInForum')); } if (!$User) { PRequest::home(); } $callbackId = $this->editProcess(); $this->_model->prepareForum(); $this->_model->getEditData($callbackId); $this->_view->editPost($callbackId, true); PPostHandler::clearVars($callbackId); } else { if ($this->action == self::ACTION_MODEDIT) { if (!$User) { PRequest::home(); } $callbackId = $this->editProcess(); $this->_model->prepareForum(); $this->_model->getEditData($callbackId); $this->_view->ModeditPost($callbackId); PPostHandler::clearVars($callbackId); } else { if ($this->action == self::ACTION_SEARCH_FORUMS) { $this->_view->keyword = $request[2]; $this->_view->showSearchResultPage($request[2]); PPostHandler::clearVars($searchCallbackId); } else { if ($this->action == self::ACTION_SEARCH_USERPOSTS) { if (!isset($request[2])) { PPHP::PExit(); } $this->searchUserposts($request[2]); } else { if ($this->action == self::ACTION_SUBSCRIBE) { if (!isset($request[2])) { PPHP::PExit(); } if ($request[2] == "thread") { $this->SubscribeThread($request[3]); } if ($request[2] == "tag") { $this->SubscribeTag($request[3]); } } else { if ($this->action == self::ACTION_SEARCH_SUBSCRIPTION) { /* * Here the following syntax can be used : * forums/subscriptions : allow current user to see his subscribtions * forums/subscriptions/unsubscribe/thread/xxx/yyy : allow current user to unsubscribe from members_threads_subscribed.id xxx with key yyy * forums/subscriptions/member/xxx : allow a forum moderator to see all subscribtions of member xxx * forums/subscriptions/thread/xxx : allow a forum moderator to see all subscribers and subscribtions for thread xxx * forums/subscribe/thread/xxx : subscribe to thread xxx */ $operation = ""; if (isset($request[2])) { $operation = $request[2]; } switch ($operation) { case "enable": if (isset($request[3])) { switch ($request[3]) { case 'thread': $this->EnableThread($request[4]); break; case 'tag': $this->EnableTag($request[4]); break; case 'group': $this->EnableGroup($request[4]); break; } } else { $this->enableSubscriptions(); } break; case "disable": if (isset($request[3])) { switch ($request[3]) { case 'tag': $this->DisableTag($request[4]); break; case 'thread': $this->DisableThread($request[4]); break; case 'group': $this->DisableGroup($request[4]); break; } } else { $this->disableSubscriptions(); } break; case "subscribe": if (isset($request[3]) and $request[3] == 'group') { $this->SubscribeGroup($request[4]); } break; case "unsubscribe": switch ($request[3]) { case 'thread': $this->UnsubscribeThread($request[4], $request[5]); break; case 'tag': $this->UnsubscribeTag($request[4], $request[5]); break; case 'group': $this->UnsubscribeGroup($request[4]); break; } break; default: $this->searchSubscriptions(); } } else { if (PVars::get()->debug) { throw new PException('unexpected forum action!'); } else { PRequest::home(); } } } } } } } } } } } } } } } } } } } } } } $page->content .= ob_get_contents(); ob_end_clean(); $page->newBar .= $view->getAsString('showCategoriesContinentsTagcloud'); $page->teaserBar .= $view->getAsString('teaser'); $page->render(); }
/** * Fetch all required data for the view to display a forum * this data are stored in $this->board */ public function prepareForum($showsticky = true) { if (!$this->geonameid && !$this->countrycode && !$this->continent && !$this->IdGroup) { if ($this->TopMode == Forums::CV_TOPMODE_CATEGORY) { $this->boardTopLevelCategories(); } elseif ($this->TopMode == Forums::CV_TOPMODE_LASTPOSTS) { $this->boardTopLevelLastPosts($showsticky); } elseif ($this->TopMode == Forums::CV_TOPMODE_LANDING) { $this->boardTopLevelLanding($showsticky); } elseif ($this->TopMode == Forums::CV_TOPMODE_FORUM) { $this->boardTopLevelForum($showsticky); } elseif ($this->TopMode == Forums::CV_TOPMODE_GROUPS) { $this->boardTopLevelGroups($showsticky); } else { $this->boardTopLevelLanding($showsticky); } } else { if ($this->continent && !$this->geonameid && !$this->countrycode) { $this->boardContinent(); } else { if ($this->IdGroup) { $this->boardGroup($showsticky); } else { if (isset($this->admincode) && $this->admincode && $this->continent && $this->countrycode && !$this->geonameid) { $this->boardadminCode(); } else { if ($this->continent && $this->countrycode && !$this->geonameid) { $this->boardCountry(); } else { if ($this->continent && $this->countrycode && $this->geonameid && isset($this->admincode) && $this->admincode) { $this->boardLocation(); } else { if (PVars::get()->debug) { throw new PException('Invalid Request'); } else { PRequest::home(); } } } } } } } }