/** * Initialisation. * Initialises the view, templaters and all other necessary objects for * successfully creating the response. */ protected function initialize() { // Get current node info $this->node = new vBCms_Item_Content($this->node_segment); // Prenotify the node item of info we will require $info_flags = vBCms_Item_Content::INFO_NODE | vBCms_Item_Content::INFO_PARENTS | vBCms_Item_Content::INFO_CONFIG; $this->node->requireInfo($info_flags); if (!$this->node->isValid()) { $this->node = new vBCms_Item_Content( vB::$vbulletin->options['default_page']); vBCms_NavBar::prepareNavBar($this->node); throw (new vB_Exception_404(new vB_Phrase('error', 'page_not_found'))); } // Prepare navbar vBCms_NavBar::prepareNavBar($this->node); }
/** * Return item-specific url to the owner of an attachment * * @param array Content information * * @return string */ protected function fetch_content_url_instance($contentinfo) { return vBCms_Route_Content::getURL(array('node' => vBCms_Item_Content::buildUrlSegment($contentinfo['nodeid'], $contentinfo['url']))); }
public function getLayout() { return $this->content->getLayout(); }
/** * Populates a view with the expected info from a content item. * * @param vB_View $view * @param int $viewtype */ protected function populateViewContent(vB_View $view, $viewtype = self::VIEW_PAGE, $increment_count = true) { global $show; $this->content->requireInfo(vBCms_Item_Content::INFO_BASIC); $this->content->requireInfo(vBCms_Item_Content::INFO_CONTENT); $this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG); $this->content->requireInfo(vBCms_Item_Content::INFO_NODE); $this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS); if ($_REQUEST['goto'] == 'newcomment') { require_once DIR . '/includes/functions_bigthree.php' ; $record = vB::$vbulletin->db->query_first("SELECT associatedthreadid FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId()); $threadid = $record['associatedthreadid']; $threadinfo = verify_id('thread', $threadid, 1, 1); if (vB::$vbulletin->options['threadmarking'] AND vB::$vbulletin->userinfo['userid']) { vB::$vbulletin->userinfo['lastvisit'] = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - (vB::$vbulletin->options['markinglimit'] * 86400)); } else if (($tview = intval(fetch_bbarray_cookie('thread_lastview', $threadid))) > vB::$vbulletin->userinfo['lastvisit']) { vB::$vbulletin->userinfo['lastvisit'] = $tview; } $coventry = fetch_coventry('string'); $posts = vB::$vbulletin->db->query_first(" SELECT MIN(postid) AS postid FROM " . TABLE_PREFIX . "post WHERE threadid = $threadinfo[threadid] AND visible = 1 AND dateline > " . intval(vB::$vbulletin->userinfo['lastvisit']) . " ". ($coventry ? "AND userid NOT IN ($coventry)" : "") . " LIMIT 1 "); $target_url = vB_Router::getURL(); $join_char = strpos($target_url,'?') ? '&' : '?'; if ($posts['postid']) { exec_header_redirect($target_url . $join_char . "commentid=" . $posts['postid'] . "#post$posts[postid]"); } else { exec_header_redirect($target_url . $join_char . "commentid=" . $threadinfo['lastpostid'] . "#post$threadinfo[lastpostid]"); } } if ($_REQUEST['commentid']) { vB::$vbulletin->input->clean_array_gpc('r', array( 'commentid' => vB_Input::TYPE_INT, )); $postinfo = verify_id('post', vB::$vbulletin->GPC['commentid'], 1, 1); $record = vB::$vbulletin->db->query_first("SELECT associatedthreadid FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId()); $threadid = $record['associatedthreadid']; // if comment id and node id do not match, we ignore commentid if ($postinfo['threadid'] == $threadid) { $getpagenum = vB::$vbulletin->db->query_first(" SELECT COUNT(*) AS posts FROM " . TABLE_PREFIX . "post AS post WHERE threadid = $threadid AND visible = 1 AND dateline <= $postinfo[dateline] "); $_REQUEST['commentpage'] = ceil($getpagenum['posts'] / 20); } } if ($_REQUEST['do']== 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode') { $this->SaveData($view); } ($hook = vBulletinHook::fetch_hook('vbcms_article_populate_start')) ? eval($hook) : false; //Now we need to get the settings for turning off content. There is the "settingsforboth" flag, which says whether we even apply // the settings to the current page, and there are the six "show" variables. if ($_REQUEST['do'] == 'delete' AND $this->content->canEdit()) { $dm = $this->content->getDM(); $dm->delete(); $this->cleanContentCache(); // Create route to redirect the user to $route = new vBCms_Route_Content(); $route->node = $this->content->getParentId(); $_REQUEST['do'] = ''; throw (new vB_Exception_Reroute($route)); } //When we come from the link to upgrade a blog post, blog, or forum post, the // router puts us here. $settings_for = $this->content->getSettingsForboth(); $showfor_this = (((self::VIEW_PAGE == $viewtype) AND ($settings_for == 0)) OR ((self::VIEW_PREVIEW == $viewtype) AND ($settings_for == 2))) ? 0 : 1; $view->showtitle = (($showfor_this AND !$this->content->getShowTitle()))? 0 : 1; $view->showpreviewonly = (($showfor_this AND !$this->content->getShowPreviewonly()))? 0 : 1; $view->showuser = (($showfor_this AND !$this->content->getShowUser()))? 0 : 1; $view->showupdated = (($showfor_this AND !$this->content->getShowUpdated()))? 0 : 1; $view->showviewcount = (($showfor_this AND !$this->content->getShowViewcount()))? 0 : 1; $view->showpublishdate = (($showfor_this AND !$this->content->getShowPublishdate()))? 0 : 1; $view->lastupdated = $this->content->getLastUpdated(); $showpreviewonly = (($showfor_this AND !$this->content->getShowPreviewonly()))? 0 : 1; parent::populateViewContent($view, $viewtype); $segments = array('node' => vBCms_Item_Content::buildUrlSegment($this->content->getNodeId(), $this->content->getUrl()), 'action' =>'view'); $view->page_url = vBCms_Route_Content::getURL($segments); if ($this->editing) { $view->pagetext = $this->content->getPageText(); } else { $rendered = $this->content->getRendered($this->data_saved); $view->pagetext = $rendered['pages'][$this->parameters['page']]; if ($this->content->canDownload()) { $view->attachments = $rendered['attachments']; $view->showattachments = empty($rendered['viewinfo']) ? 0 : 1 ; if (!empty($rendered['viewinfo'])) { foreach ($rendered['viewinfo'] as $key => $viewbit) { $view->$key = $viewbit; } } } $view->parenttitle = $this->content->getParentTitle(); $view->showattachments = empty($view->attachments) ? 0 : 1 ; if (!empty($viewinfo)) { foreach ($viewinfo as $key => $viewbit) { $view->$key = $viewbit; } } $view->pagelist = $rendered['pagelist']; $view->nodesegment = $this->content->getUrlSegment(); $view->current_page = $this->parameters['page']; if ($this->content->canDownload()) { $show['lightbox'] = (vB::$vbulletin->options['lightboxenabled'] AND vB::$vbulletin->options['usepopups']); } } // Only break pages for the page view if ((self::VIEW_PAGE == $viewtype) OR (self::VIEW_PREVIEW == $viewtype)) { if (self::VIEW_PAGE == $viewtype) { if ($increment_count) { //update the view count vB::$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "cms_nodeinfo set viewcount = viewcount + 1 where nodeid = " . $this->content->getNodeId()); } //tagging code require_once DIR . '/includes/class_taggablecontent.php'; $taggable = vB_Taggable_Content_Item::create(vB::$vbulletin, $this->content->getContentTypeId(), $this->content->getContentId(), $this->content); $view->tags = $taggable->fetch_rendered_tag_list(); $view->tag_count = $taggable->fetch_existing_tag_count(); $view->showtags = vB::$vbulletin->options['threadtagging']; // promoted threadid if ($promoted_threadid = $this->content->getThreadId()) { if ($promoted_threadid = verify_id('thread', $promoted_threadid, false)) { // get threadinfo $threadinfo = fetch_threadinfo($promoted_threadid); $forumperms = fetch_permissions($threadinfo['forumid']); $view->threadinfo = $threadinfo; // check permissions if ($threadinfo['visible'] != 1) { $promoted_threadid = false; } else if (!($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canviewthreads']) OR (!($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($threadinfo['postuserid'] != vB::$vbulletin->userinfo['userid'] OR vB::$vbulletin->userinfo['userid'] == 0) )) { $promoted_threadid = false; } else { // check forum password $foruminfo = fetch_foruminfo($threadinfo['forumid']); if ($foruminfo['password'] AND !verify_forum_password($foruminfo['forumid'], $foruminfo['password'], false)) { $promoted_threadid = false; } } $view->promoted_threadid = $promoted_threadid; } } // get pagelist for navigation $view->postitle = $this->content->getPostTitle(); $view->poststarter = $this->content->getPostStarter(); $view->postauthor = $this->content->getPostAuthor(); $view->postid = ($this->content->getPostId()); $view->threadid = $this->content->getThreadId(); $view->blogpostid = ($this->content->getBlogPostId()); $view->post_started = ($this->content->getPostStarted()); $view->post_posted = ($this->content->getPostPosted()); $view->promoted_blogid = $this->content->getBlogId(); //make links to original post and/or blog if appropriate if ($view->promoted_blogid) { $view->blog_url = fetch_seo_url('blog', array('userid' => $this->content->getPostStarter(), 'blog_title' => $this->content->getPostTitle())); } else if ($view->threadid) { $threadinfo = vB::$vbulletin->db->query_first("SELECT threadid, title FROM " . TABLE_PREFIX . "thread where threadid = " . $view->threadid); if ($threadinfo) { $post_url = fetch_seo_url('thread', $threadinfo); $post_url .= (strpos($post_url, '?' ) ? '&p=' : '?p=') . $view->postid . '#post' . $view->postid; $view->post_url = $post_url; } } $view->comment_count = $this->content->getReplyCount(); $join_char = strpos($view->page_url,'?') ? '&' : '?'; $view->newcomment_url = $view->page_url . "#new_comment"; $view->authorid = ($this->content->getUserId()); $view->authorname = ($this->content->getUsername()); $view->viewcount = ($this->content->getViewCount()); $view->replycount = ($this->content->getReplyCount()); $view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0; $view->parentid = $this->content->getParentId(); // facebook options if (is_facebookenabled()) { // display the like button for this article? $view->fblikebutton = construct_fblikebutton(); } //check to see if there is an associated thread. if ($associatedthreadid = $this->content->getAssociatedThreadId() and $this->content->getComments_Enabled()) { $comment_block = new vBCms_Comments(); $view->comment_block = $comment_block->getPageView($this->content->getNodeId(), $view->page_url); } } else if (self::VIEW_PREVIEW == $viewtype) { if ($showpreviewonly) { $view->previewtext = $this->content->getPreviewText(); $view->preview_chopped = 1; } else { $view->previewtext = $view->pagetext; if (count($view->pagelist) > 1) { $view->preview_chopped = 1; } } $segments = array('node' => $this->content->getNodeId() . '-' . $this->content->getUrl(), 'action' =>'edit'); $view->edit_url = vBCms_Route_Content::getURL($segments) ; $view->read_more_phrase = new vB_Phrase('vbcms', 'read_more'); $view->parenttitle = $this->content->getParentTitle(); $view->pagetext = $pagetext; $view->setpublish = $view->published = $this->content->getPublished(); $view->publishdate = $this->content->getPublishDateLocal(); $view->promoted_blogid = $this->content->getBlogId(); $view->comment_count = $this->content->getReplyCount(); $join_char = strpos($view->page_url,'?') ? '&' : '?'; $view->newcomment_url = $view->page_url . "#new_comment"; $view->authorid = ($this->content->getUserId()); $view->authorname = ($this->content->getUsername()); $view->viewcount = ($this->content->getViewCount()); $view->replycount = ($this->content->getReplyCount()); $view->postid = ($this->content->getPostId()); $view->blogpostid = $this->content->getBlogPostId(); $view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0; $view->parentid = $this->content->getParentId(); $view->post_started = $this->content->getPostStarted(); $view->post_posted = $this->content->getPostPosted(); //We need to check rights. If this user doesn't have download rights we hide the image. if ($this->content->canDownload()) { if ($view->previewimage= $this->content->getPreviewImage()) { $view->imagewidth= $this->content->getImageWidth(); $view->imageheight= $this->content->getImageHeight(); } if ($view->previewvideo= $this->content->getPreviewVideo()) { $view->haspreviewvideo = true; } } else { $view->previewimage = false; $view->previewvideo = false; } if (($associatedthreadid = $this->content->getAssociatedThreadId()) AND $this->content->getComments_Enabled() AND intval($this->content->getReplyCount()) > 0) { $view->echo_comments = 1; $view->comment_count = $this->content->getReplyCount(); } else { $view->echo_comments = 0; $view->comment_count = 0; } } } //If this was promoted from a blog or post, we need to verify the permissions. if (intval($view->blogpostid)) { $view->can_view_post = (!($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers'])) ? 0 : 1 ; } else if (intval($view->postid)) { $user = new vB_Legacy_CurrentUser(); if ($post = vB_Legacy_Post::create_from_id($view->postid)) { $view->can_view_post = $post->can_view($user) ? 1 : 0; } } $view->poststarter = array('userid' => $this->content->getPostStarter(), 'username' => $this->content->getPostAuthor()); $view->setpublish = $this->content->getSetPublish(); $view->publishdate = $this->content->getPublishDate(); $view->published = $this->content->getPublished() ? 1 : 0; $view->publishdatelocal = vbdate(vB::$vbulletin->options['dateformat'], $this->content->getPublishDate()); $view->publishtimelocal = vbdate( vB::$vbulletin->options['timeformat'], $this->content->getPublishDate() ); //Get links to the author, section, and categories search pages //categories- this comes as an array $view->categories = $this->content->getCategories(); $route_info = 'author/' . $this->content->getUserid() . ($this->content->getUsername() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getUsername())) : ''); $view->author_url = vB_Route::create('vBCms_Route_List', "$route_info/1")->getCurrentURL(); // prepare the member action drop-down menu $view->memberaction_dropdown = construct_memberaction_dropdown(fetch_userinfo($this->content->getUserId())); //Section $route_info = 'section/' .$this->content->getParentId() . ($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : ''); $view->section_list_url = vB_Route::create('vBCms_Route_List', "$route_info")->getCurrentURL(); //and the content $route_info = $this->content->getParentId() . ($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : ''); $view->section_url = vB_Route::create('vBCms_Route_Content', $route_info)->getCurrentURL(); $view->html_title = $this->content->getHtmlTitle(); $view->title = $this->content->getTitle(); $view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Article"); $view->dateformat = vB::$vbulletin->options['dateformat']; $view->showrating = $this->content->getShowRating(); ($hook = vBulletinHook::fetch_hook('vbcms_article_populate_end')) ? eval($hook) : false; $this->content->cacheNow(); return $view; }
/** * Validates a parentid. * Checks if the parent exists. * * @param mixed $value - The value to validate * @param mixed $error - The var to assign an error to * @return mixed | bool - The filtered value or boolean false */ protected function validateParent($value, &$error) { $parent = new vBCms_Item_Content($value); if (!$parent->isValid()) { return false; } $this->section = $parent->getSectionId(); return $value; }
public function actionList($page_url) { //This is an aggregator. We can pull in three different modes as of this writing, // and we plan to add more. We can have passed on the url the following: // author=id, category=id, section=id, and format=id. "Format" should normally // be passed as for author only, and it defines a sectionid to be used for the format. global $vbphrase; //Load cached values as appropriate $metacache_key = 'vbcms_list_data_' . implode('_', $this->segments); vB_Cache::instance()->restoreCacheInfo($metacache_key); // Create the page view $view = new vB_View_Page('vbcms_page'); $view->page_url = $page_url; $view->base_url = VB_URL_BASE_PATH; $view->html_title = $this->title; $this->content = vBCms_Content::create('vBCms', 'Section', $this->displaysectionid); $sectionnode = new vBCms_Item_Content($this->displaysectionid, vBCms_Item_Content::INFO_CONFIG) ; //There are configuration settings on the section for items per page and // section layout. If they are set let's use them. First items per page. $this->config = $sectionnode->getConfig(); if (isset($this->config['items_perhomepage']) AND intval($this->config['items_perhomepage'])) { $this->perpage = $this->config['items_perhomepage']; } // Get layout $this->layout = new vBCms_Item_Layout($this->layoutid); $this->layout->requireInfo(vBCms_Item_Layout::INFO_CONFIG | vBCms_Item_Layout::INFO_WIDGETS); // Create the layout view $layout = new vBCms_View_Layout($this->layout->getTemplate()); $layout->contentcolumn = $this->layout->getContentColumn(); $layout->contentindex = $this->layout->getContentIndex(); // Get content controller $collection = new vBCms_Collection_Content(); $collection->setContentQueryWhere($this->query_filter . " AND node.contenttypeid <> " . vB_Types::instance()->getContentTypeID("vBCms_Section") ); $collection->setContentQueryJoins($this->joins); vB::$vbulletin->input->clean_array_gpc('r', array('page' => TYPE_INT)); if ((vB::$vbulletin->GPC_exists['page'] AND intval(vB::$vbulletin->GPC['page']))) { $current_page = intval(vB::$vbulletin->GPC['page']); } elseif (intval($this->segments['page'])) { $current_page = intval($this->segments['page']); } else { $current_page = 1; } $collection->paginate(); $collection->paginateQuantity($this->perpage); $collection->paginatePage($current_page); $results = array(); // Get the content view //Our templates assume a counter beginning at one, not zero. $counter = 0; foreach($collection as $id => $content) { //make sure we've loaded all the information we need $content->requireInfo(vBCms_Item_Content::INFO_NODE | vBCms_Item_Content::INFO_CONTENT | vBCms_Item_Content::INFO_PARENTS); // get the content controller $controller = vB_Types::instance()->getContentTypeController($content->getContentTypeId(), $content); // set preview length $controller->setPreviewLength(400); // get the aggregate view from the controller if ($result = $controller->getPreview()) { $counter++; $results[$counter] = $result; } } $recordcount = $collection->getCount(); $contentview->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Section"); $contentview->contentid = $contentview->item_id = $contentview->nodeid = $this->displaysectionid; $contentview = new vB_View_Content('vbcms_content_list'); $contentview->package = 'vBCms'; $contentview->class = 'Section'; $contentview->result_type = $this->result_type; $contentview->rawtitle = $this->title; $contentview->title = $this->title; $contentview->current_page = $current_page; if (! $recordcount) { switch($this->segments['type']){ case 'author': $contentview->contents = array(1 => new vB_Phrase('vbcms', 'no_content_for_author_x', $this->title )); break; case 'section': $contentview->contents = array(1 => new vB_Phrase('vbcms', 'no_content_for_section_x', $this->title )); break; case 'category': $contentview->contents = array(1 => new vB_Phrase('vbcms', 'no_content_for_category_x', $this->title )); break; ; } // switch } else { if (isset($this->config['content_layout']) AND intval($this->config['content_layout']) AND (intval($this->config['content_layout']) < 7)) { $content_rendered = new vb_View('vbcms_content_section_type' . intval($this->config['content_layout'])); $content_rendered->contents = $results; $content_rendered->result_count = $counter; $contentview->content_rendered = $content_rendered; } else { $contentview->contents = $results; } if (intval($recordcount) > intval($this->perpage)) { $baseurl = vB_Route::create('vBCms_Route_List', $this->segments['type'] . '/' . intval($this->segments['value']) . ($this->urlstring == '' ? '' : '-' . $this->urlstring) . '/')->getCurrentURL(); $contentview->pagenav = construct_page_nav($current_page, $this->perpage, $recordcount, $baseurl); } else { $contentview->pagecount = 1; } } $layout->content = $contentview; // Get widget locations $layout->widgetlocations = $this->layout->getWidgetLocations(); if (count($layout->widgetlocations)) { $widgetids = $this->layout->getWidgetIds(); if (count($widgetids)) { // Get Widgets $widgets = vBCms_Widget::getWidgetCollection($widgetids, vBCms_Item_Widget::INFO_CONFIG, $this->displaysectionid); $widgets = vBCms_Widget::getWidgetControllers($widgets, true, $this->content); // Get the widget views $widget_views = array(); foreach($widgets AS $widgetid => $widget) { try { $widget_views[$widgetid] = $widget->getPageView(); } catch (vB_Exception $e) { if ($e->isCritical()) { throw ($e); } if (vB::$vbulletin->debug) { $widget_views[$widgetid] = 'Exception: ' . $e; } } } // Assign the widgets to the layout view $layout->widgets = $widget_views; } } // Assign the layout view to the page view $view->layout = $layout; // Add general page info $view->setPageTitle($this->content->getTitle()); $view->pagedescription = $this->content->getDescription(); $this->resolveWolPath(); vB_Cache::instance()->saveCacheInfo($metacache_key); // Render view and return return $view->render(); }
/** * Populates a view with the expected info from a content item. * * @param vB_View $view * @param int $viewtype */ protected function populateViewContent(vB_View $view, $viewtype = self::VIEW_PAGE, $increment_count = true) { global $show; if (empty($this->config)) { $this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG); $this->config = $this->content->getConfig(); } if ($_REQUEST['do']== 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode') { $this->saveData($view); $this->content->requireInfo(vBCms_Item_Content::INFO_BASIC); $this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG); $this->content->requireInfo(vBCms_Item_Content::INFO_NODE); $this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS); $this->content->requireInfo(vBCms_Item_Content::INFO_NAVIGATION); $this->config = $this->content->getConfig(); } else { $this->content->requireInfo(vBCms_Item_Content::INFO_BASIC); $this->content->requireInfo(vBCms_Item_Content::INFO_NODE); $this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS); $this->content->requireInfo(vBCms_Item_Content::INFO_NAVIGATION); } if ($_REQUEST['goto'] == 'newcomment') { require_once DIR . '/includes/functions_bigthree.php' ; $record = vB::$vbulletin->db->query_first("SELECT associatedthreadid FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId()); $threadid = $record['associatedthreadid']; $threadinfo = verify_id('thread', $threadid, 1, 1); if (vB::$vbulletin->options['threadmarking'] AND vB::$vbulletin->userinfo['userid']) { vB::$vbulletin->userinfo['lastvisit'] = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - (vB::$vbulletin->options['markinglimit'] * 86400)); } else if (($tview = intval(fetch_bbarray_cookie('thread_lastview', $threadid))) > vB::$vbulletin->userinfo['lastvisit']) { vB::$vbulletin->userinfo['lastvisit'] = $tview; } $coventry = fetch_coventry('string'); $posts = vB::$vbulletin->db->query_first(" SELECT MIN(postid) AS postid FROM " . TABLE_PREFIX . "post WHERE threadid = $threadinfo[threadid] AND visible = 1 AND dateline > " . intval(vB::$vbulletin->userinfo['lastvisit']) . " ". ($coventry ? "AND userid NOT IN ($coventry)" : "") . " LIMIT 1 "); $target_url = vB_Router::getURL(); $join_char = strpos($target_url,'?') ? '&' : '?'; if ($posts['postid']) { exec_header_redirect($target_url . $join_char . "commentid=" . $posts['postid'] . "#post$posts[postid]"); } else { exec_header_redirect($target_url . $join_char . "commentid=" . $threadinfo['lastpostid'] . "#post$threadinfo[lastpostid]"); } } if ($_REQUEST['commentid']) { vB::$vbulletin->input->clean_array_gpc('r', array( 'commentid' => vB_Input::TYPE_INT, )); $postinfo = verify_id('post', vB::$vbulletin->GPC['commentid'], 1, 1); $record = vB::$vbulletin->db->query_first("SELECT associatedthreadid FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId()); $threadid = $record['associatedthreadid']; // if comment id and node id do not match, we ignore commentid if ($postinfo['threadid'] == $threadid) { $getpagenum = vB::$vbulletin->db->query_first(" SELECT COUNT(*) AS posts FROM " . TABLE_PREFIX . "post AS post WHERE threadid = $threadid AND visible = 1 AND dateline <= $postinfo[dateline] "); $_REQUEST['commentpage'] = ceil($getpagenum['posts'] / 20); } } if ($_REQUEST['do']== 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode') { $this->saveData($view); } ($hook = vBulletinHook::fetch_hook($this->startpopulatehook)) ? eval($hook) : false; //Now we need to get the settings for turning off content. There is the "settingsforboth" flag, which says whether we even apply // the settings to the current page, and there are the six "show" variables. if ($_REQUEST['do'] == 'delete' AND $this->content->canEdit()) { $dm = $this->content->getDM(); $dm->delete(); $this->cleanContentCache(); // Create route to redirect the user to $route = new vBCms_Route_Content(); $route->node = $this->content->getParentId(); $_REQUEST['do'] = ''; throw (new vB_Exception_Reroute($route)); } //When we come from the link to upgrade a blog post, blog, or forum post, the // router puts us here. $settings_for = $this->content->getSettingsForboth(); $showfor_this = (((self::VIEW_PAGE == $viewtype) AND ($settings_for == 0)) OR ((self::VIEW_PREVIEW == $viewtype) AND ($settings_for == 2))) ? 0 : 1; $view->showtitle = (($showfor_this AND !$this->content->getShowTitle()))? 0 : 1; $view->showpreviewonly = (($showfor_this AND !$this->content->getShowPreviewonly()))? 0 : 1; $view->showuser = (($showfor_this AND !$this->content->getShowUser()))? 0 : 1; $view->showupdated = (($showfor_this AND !$this->content->getShowUpdated()))? 0 : 1; $view->showviewcount = (($showfor_this AND !$this->content->getShowViewcount()))? 0 : 1; $view->showpublishdate = (($showfor_this AND !$this->content->getShowPublishdate()))? 0 : 1; $view->lastupdated = $this->content->getLastUpdated(); $view->previewtext = $this->config['previewtext']; if ((self::VIEW_PREVIEW != $viewtype) OR !$view->showpreviewonly) { $view->pagetext = $this->config['pagetext']; } $view->previewimage = $this->config['preview_image']; $view->nodeid = $this->content->getNodeId(); parent::populateViewContent($view, $viewtype); $segments = array('node' => vBCms_Item_Content::buildUrlSegment($this->content->getNodeId(), $this->content->getUrl()), 'action' =>'view'); $view->page_url = vBCms_Route_Content::getURL($segments); $view->pagetext = $this->config['pagetext']; if (self::VIEW_PAGE == $viewtype) { if ($increment_count) { //update the view count vB::$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "cms_nodeinfo set viewcount = viewcount + 1 where nodeid = " . $this->content->getNodeId()); } //tagging code require_once DIR . '/includes/class_taggablecontent.php'; $taggable = vB_Taggable_Content_Item::create(vB::$vbulletin, $this->content->getContentTypeId(), $this->content->getNodeId(), $this->content); if ($taggable) { $view->tags = $taggable->fetch_rendered_tag_list(); $view->tag_count = $taggable->fetch_existing_tag_count(); $view->showtags = vB::$vbulletin->options['threadtagging']; } else { $view->showtags = false; } $view->comment_count = $this->content->getReplyCount(); $join_char = strpos($view->page_url,'?') ? '&' : '?'; $view->newcomment_url = $view->page_url . "#new_comment"; $view->authorid = ($this->content->getUserId()); $view->authorname = ($this->content->getUsername()); $view->viewcount = ($this->content->getViewCount()); $view->replycount = ($this->content->getReplyCount()); $view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0; $view->parentid = $this->content->getParentId(); //check to see if there is an associated thread. if ($associatedthreadid = $this->content->getAssociatedThreadId() and $this->content->getComments_Enabled()) { $comment_block = new vBCms_Comments(); $view->comment_block = $comment_block->getPageView($this->content->getNodeId(), $view->page_url); } } else if (self::VIEW_PREVIEW == $viewtype) { if ($showpreviewonly) { $view->previewtext = isset($this->config['previewtext']) ? $this->config['previewtext'] : substr(strip_tags( $this->config['pagetext'], '<br />'), 0, $this->config['previewlength']); $view->preview_chopped = 1; } else { $view->previewtext = $view->pagetext; } $segments = array('node' => $this->content->getNodeId() . '-' . $this->content->getUrl(), 'action' =>'edit'); $view->edit_url = vBCms_Route_Content::getURL($segments) ; $view->read_more_phrase = new vB_Phrase('vbcms', 'read_more'); $view->parenttitle = $this->content->getParentTitle(); $view->pagetext = $pagetext; $view->setpublish = $view->published = $this->content->getPublished(); $view->publishdate = $this->content->getPublishDateLocal(); $view->comment_count = $this->content->getReplyCount(); $join_char = strpos($view->page_url,'?') ? '&' : '?'; $view->newcomment_url = $view->page_url . "#new_comment"; $view->authorid = ($this->content->getUserId()); $view->authorname = ($this->content->getUsername()); $view->viewcount = ($this->content->getViewCount()); $view->replycount = ($this->content->getReplyCount()); $view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0; $view->parentid = $this->content->getParentId(); if (($associatedthreadid = $this->content->getAssociatedThreadId()) AND $this->content->getComments_Enabled() AND intval($this->content->getReplyCount()) > 0) { $view->echo_comments = 1; $view->comment_count = $this->content->getReplyCount(); } else { $view->echo_comments = 0; $view->comment_count = 0; } } $view->setpublish = $this->content->getSetPublish(); $view->publishdate = $this->content->getPublishDate(); $view->published = $this->content->getPublished() ? 1 : 0; $view->publishdatelocal = vbdate(vB::$vbulletin->options['dateformat'], $this->content->getPublishDate()); $view->publishtimelocal = vbdate( vB::$vbulletin->options['timeformat'], $this->content->getPublishDate() ); //Get links to the author, section, and categories search pages //categories- this comes as an array $view->categories = $this->content->getCategories(); $route_info = 'author/' . $this->content->getUserid() . ($this->content->getUsername() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getUsername())) : ''); $view->author_url = vB_Route::create('vBCms_Route_List', "$route_info/1")->getCurrentURL(); // prepare the member action drop-down menu $view->memberaction_dropdown = construct_memberaction_dropdown(fetch_userinfo($this->content->getUserId())); //Section $route_info = 'section/' .$this->content->getParentId() . ($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : ''); $view->section_list_url = vB_Route::create('vBCms_Route_List', "$route_info")->getCurrentURL(); //and the content $route_info = $this->content->getParentId() . ($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-', vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : ''); $view->section_url = vB_Route::create('vBCms_Route_Content', $route_info)->getCurrentURL(); $view->html_title = $this->content->getHtmlTitle(); $view->title = $this->content->getTitle(); $view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Article"); $view->dateformat = vB::$vbulletin->options['dateformat']; $view->showrating = $this->content->getShowRating(); ($hook = vBulletinHook::fetch_hook($this->endpopulatehook)) ? eval($hook) : false; if (method_exists($this->content, 'cacheNow')) { $this->content->cacheNow(); } return $view; }
/** * Inflate dynamic segments to canonical values. */ public function inflateSegments() { $node = new vBCms_Item_Content($this->node); if (!$node->isValid()) { return; } if ($this->node != ($segment = $node->getUrlSegment())) { $this->setSegment('node', $segment, true); } }
private function arrangeSection(&$nodes, $currentnodeid) { //We start the <ol> text; $currentnode = current($nodes); //If we are at the root node, which has no parentid, let's just advance. if (intval($currentnode['parentnode']) == 0) { $currentnode = next($nodes); } $node = vBCms_Item_Content::buildUrlSegment($currentnode['nodeid'], $currentnode['url']); $segments = array('node' => $node, 'action' => 'view'); $result = "<ul >\n<li" . (intval($currentnode['nodeid']) == intval($currentnodeid) ? ' class="active" ' : '') . '><a href="' . vBCms_Route_Content::getURL($segments) . '">' . $currentnode['title'] . "</a>\n" ; $lastnodeid = $currentnode['nodeid']; $parentnodeid = $currentnode['parentnode']; // Now walk the list of nodes while($currentnode = next($nodes)) { //If this node is our child, we call this function recursively. if ($currentnode['parentnode'] == $lastnodeid) { $result .= $this->arrangeSection($nodes, $currentnodeid) . "\n"; } //If the parent node has changed then it's time to return if ($currentnode = current($nodes) AND $currentnode['parentnode'] != $parentnodeid) { return $result . "</li>\n</ul>\n "; } //If we got here and we aren't at the end of the list, we are at the same level. Just generate another link if ($currentnode = current($nodes) AND $currentnode['parentnode'] == $parentnodeid) { $node = $currentnode['nodeid'] . ($currentnode['url'] ? '-'.$currentnode['url'] : ''); $segments = array('node' => $node, 'action' =>'view'); $result .= "</li>\n<li" . (intval($currentnode['nodeid']) == intval($currentnodeid) ? ' class="active" ' : '') . '><a href="' . vBCms_Route_Content::getURL($segments) . '">' . $currentnode['title'] . "</a>\n" ; } $lastnodeid = $currentnode['nodeid']; } //we get here if we are at the top level and we've hit the last node; if ($currentnode = current($nodes) AND $currentnode['parentnode'] == $parentnodeid) { $segments = array('node' => $currentnode['nodeid'], 'action' =>'view'); $result .= "</li>\n<li" . (intval($currentnode['nodeid']) == intval($currentnodeid) ? ' class="active" ' : '') . '><a href="' . vBCms_Route_Content::getURL($segments, array('url' => $currentnode['url'])) . '">' . $currentnode['title'] . "</a>\n" ; } return $result . "</li></ul>\n "; }
/** * Inflate dynamic segments to canonical values. */ public function inflateSegments() { // Ensure we can resolve the value if (!$value = intval($this->value)) { return; } // Inflate section if ('section' == $this->type) { $node = new vBCms_Item_Content($value); if (!$node->isValid()) { return; } if ($this->value != ($segment = $node->getUrlSegment())) { $this->setSegment('value', $segment, true); } return; } // Inflate author if ('author' == $this->type) { // TODO: Need a model for users $result = vB::$vbulletin->db->query_first(" SELECT username FROM " . TABLE_PREFIX . "user WHERE userid = $value AND username != '' "); if ($result) { $this->setSegment('value', vBCms_Item_Content::buildUrlSegment($value, $result['username']), true); } return; } // Inflate category if ('category' == $this->type) { // TODO: Need a model for categories $result = vB::$vbulletin->db->query_first(" SELECT category FROM " . TABLE_PREFIX . "cms_category WHERE categoryid = $value AND category != '' "); if ($result) { $url = vB_Search_Searchtools::stripHtmlTags($record['category']); $segments['value'] .= '-' . str_replace(' ', '-', $url) ; $this->setSegment('value', vBCms_Item_Content::buildUrlSegment($value, $result['category']), true); } } }
|| # Copyright ©2000-2013 vBulletin Solutions Inc. All Rights Reserved. || || # This file may not be redistributed in whole or significant part. # || || # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # || || # http://www.vbulletin.com | http://www.vbulletin.com/license.html # || || #################################################################### || \*======================================================================*/ // ######################## SET PHP ENVIRONMENT ########################### error_reporting(E_ALL & ~E_NOTICE); if (!is_object($vbulletin->db)) { exit; } $nodes = $vbulletin->db->query_read("\n\tSELECT nodeid\n\tFROM " . TABLE_PREFIX . "cms_node\n\tWHERE \n\t\tnew = 1\n\t\t\tAND\n\t\tlastupdated < " . (TIMENOW - 3600) . "\n"); while ($node = $vbulletin->db->fetch_array($nodes)) { $nodeitem = new vBCms_Item_Content($node['nodeid']); $class = vB_Types::instance()->getContentClassFromId($nodeitem->getContentTypeID()); $classname = $class['package'] . '_Item_Content_' . $class['class']; if (class_exists($classname)) { $nodeclass = new $classname($node['nodeid']); } else { $nodeclass = new vBCms_Item_Content($node['nodeid']); } $nodedm = $nodeclass->getDM(); $nodedm->delete(); } log_cron_action('', $nextitem, 1); /*======================================================================*\ || #################################################################### || # Downloaded: 03:13, Sat Sep 7th 2013 || # CVS: $Revision: 25612 $ || #################################################################### \*======================================================================*/
/** * Validates a nodeid. * Checks if the node exists. * * @param mixed $value - The value to validate * @param mixed $error - The var to assign an error to * @return mixed | bool - The filtered value or boolean false */ protected function validateNode($value, &$error) { $node = new vBCms_Item_Content($value); if (!$node->isValid()) { return false; } return $value; }
public static function updateSections() { // There are several possibilities. First, if the user edits a title, published, //layout, or style, we save immediately. vB::$vbulletin->input->clean_array_gpc('p', array( 'sectionid' => TYPE_INT, 'nodeid' => TYPE_INT, 'nodeid2' => TYPE_INT, 'ids' => TYPE_ARRAY, 'new_contenttype' => TYPE_INT, 'title' => TYPE_NOHTML, 'section_title' => TYPE_NOHTML, 'sentfrom' => TYPE_NOHTML )); $msg = ''; //let's see if we need a list of ID's if (vB::$vbulletin->GPC['do'] == 'publish_section' OR vB::$vbulletin->GPC['do'] == 'unpublish_section' OR vB::$vbulletin->GPC['do'] == 'publish_nodes' OR vB::$vbulletin->GPC['do'] == 'unpublish_nodes' OR vB::$vbulletin->GPC['do'] == 'delete_section' OR vB::$vbulletin->GPC['do'] == 'move_section' OR vB::$vbulletin->GPC['do'] == 'delete_nodes' OR vB::$vbulletin->GPC['do'] == 'move_node' OR vB::$vbulletin->GPC['do'] == 'save_nodes') { $ids = array(); foreach (vB::$vbulletin->GPC['ids'] as $id) { if ($_POST["cb_$id"] == 'on') { $ids[] = $id; } } } switch(vB::$vbulletin->GPC['do']) { case 'saveonetitle': if (vB::$vbulletin->GPC_exists['sectionid']) { $this_id = vB::$vbulletin->GPC['sectionid']; //We still need a title vB::$vbulletin->input->clean_array_gpc('p', array( 'title_' . $this_id => TYPE_STR)); if (vB::$vbulletin->GPC_exists['title_' . $this_id]) { self::saveRecords('cms_node', 'nodeid', array($this_id => array('title' =>vB::$vbulletin->GPC['title_' . $this_id]))); vB_Cache::instance()->purge('section_nav_' . $this_id); //we need to purge the data cache record for this id $content = vBCms_Item_Content::create('vBCms', 'Section', $this_id); vB_Cache::instance()->event($content->getCacheEvents()); unset($content); vB_Cache::instance()->event('sections_updated'); vB_Cache::instance()->cleanNow(); } } ; break; case 'set_order': //First, we validate that we have an id, and an order vB::$vbulletin->input->clean_array_gpc('p', array( 'id' => TYPE_INT, 'displayorder' => TYPE_INT, 'sectionid' => TYPE_INT )); if (vB::$vbulletin->GPC_exists['id'] AND vB::$vbulletin->GPC_exists['sectionid']) { self::setDisplayOrder(vB::$vbulletin->GPC['sectionid'], vB::$vbulletin->GPC['id'], vB::$vbulletin->GPC['displayorder']); vB_Cache::instance()->event('sections_updated'); //we need to purge the data cache record for this id $content = vBCms_Item_Content::create('vBCms', 'Section', vB::$vbulletin->GPC['sectionid']); vB_Cache::instance()->event($content->getCacheEvents()); vB_Cache::instance()->cleanNow(); unset($content); } ; break; case 'saveonesectionstate': case 'saveonenodestate': // We need a sectionid and state. 1 is published, 2 is unpublished, // and 3 means it's currently published in the future and we should leave it // that way. if (vB::$vbulletin->GPC_exists['nodeid']) { $this_id = vB::$vbulletin->GPC['nodeid']; //We still need a title vB::$vbulletin->input->clean_array_gpc('p', array( 'state_' . $this_id => TYPE_INT)); if (vB::$vbulletin->GPC['state_' . $this_id]) { if (vB::$vbulletin->GPC['state_' . $this_id] == 2) { self::saveRecords('cms_node', 'nodeid', array($this_id => array('setpublish' =>1, 'publishdate' => TIMENOW - 1))); } elseif (vB::$vbulletin->GPC['state_' . $this_id] == 1) { self::saveRecords('cms_node', 'nodeid', array($this_id => array('setpublish' =>0))); } vB_Cache::instance()->event('section_nav_' . $this_id); vB_Cache::instance()->event('articles_updated'); vB_Cache::instance()->event('sections_updated'); //we need to purge the data cache record for this id $content = vBCms_Item_Content::create('vBCms', 'Section', $this_id); vB_Cache::instance()->event($content->getCacheEvents()); vB_Cache::instance()->cleanNow(); unset($content); } } break; case 'delete_section': //first check to see if there is content under this section vB::$vbulletin->input->clean_array_gpc('p', array( 'delete_sectionid' => TYPE_INT)); if (vB::$vbulletin->GPC_exists['delete_sectionid']) //If this is id 1, don't allow deletion. if ((intval(vB::$vbulletin->GPC['delete_sectionid']) == 1) OR $record = vB::$vbulletin->db->query_first('SELECT COUNT(*) AS qty FROM ' . TABLE_PREFIX . "cms_node WHERE new != 1 AND parentnode = " . vB::$vbulletin->GPC['delete_sectionid']) and intval($record['qty'])) { return false; } vB::$vbulletin->db->query_write($sql = "DELETE FROM ". TABLE_PREFIX . "cms_nodeconfig WHERE nodeid = " . vB::$vbulletin->GPC['delete_sectionid']); vB::$vbulletin->db->query_write($sql = "DELETE FROM ". TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . vB::$vbulletin->GPC['delete_sectionid']); vB::$vbulletin->db->query_write($sql = "DELETE FROM ". TABLE_PREFIX . "cms_node WHERE nodeid = " . vB::$vbulletin->GPC['delete_sectionid']); vB::$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "cms_category WHERE parentnode = " . vB::$vbulletin->GPC['delete_sectionid']); vB_Cache::instance()->event('sections_updated'); vB_Cache::instance()->cleanNow(); break; case 'delete_nodes': foreach(vB::$vbulletin->GPC['ids'] as $this_id) { if (isset($_POST["cb_$this_id"])) { vB::$vbulletin->db->query_write($sql = "DELETE FROM ". TABLE_PREFIX . "cms_nodeconfig WHERE nodeid = $this_id" ); vB::$vbulletin->db->query_write($sql = "DELETE FROM ". TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = $this_id" ); vB::$vbulletin->db->query_write($sql = "DELETE FROM ". TABLE_PREFIX . "cms_node WHERE nodeid = $this_id"); vB::$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "cms_category WHERE parentnode = $this_id"); } } vB_Cache::instance()->event('sections_updated'); vB_Cache::instance()->event('articles_updated'); vB_Cache::instance()->cleanNow(); break; case 'saveonelayout': // We need a nodeid and a layoutid. if (vB::$vbulletin->GPC_exists['nodeid']) { $this_id = vB::$vbulletin->GPC['nodeid']; //We still need a title vB::$vbulletin->input->clean_array_gpc('p', array( 'layout_' . $this_id => TYPE_INT)); if (vB::$vbulletin->GPC['layout_' . $this_id]) { self::saveRecords('cms_node', 'nodeid', array($this_id => array('layoutid' =>vB::$vbulletin->GPC['layout_' . $this_id] ))); } else { self::saveRecords('cms_node', 'nodeid', array($this_id => array('layoutid' => null))); } //we need to purge the data cache record for this id $content = vBCms_Item_Content::create('vBCms', 'Section', $this_id); vB_Cache::instance()->event($content->getCacheEvents()); unset($content); } break; case 'saveonecl': // We need a nodeid and a clid. if (vB::$vbulletin->GPC_exists['nodeid']) { $this_id = vB::$vbulletin->GPC['nodeid']; //We still need a title vB::$vbulletin->input->clean_array_gpc('p', array( 'cl_' . $this_id => TYPE_INT)); if (vB::$vbulletin->GPC_exists['cl_' . $this_id] AND intval(vB::$vbulletin->GPC['cl_' . $this_id])) { self::saveConfig ($this_id, 'content_layout', vB::$vbulletin->GPC['cl_' . $this_id], false); } //we need to purge the data cache record for this id $content = vBCms_Item_Content::create('vBCms', 'Section', $this_id); vB_Cache::instance()->event($content->getCacheEvents()); unset($content); } break; case 'sectionpriority': // We need a nodeid and a sect_pr_XX value if (vB::$vbulletin->GPC_exists['nodeid']) { $this_id = vB::$vbulletin->GPC['nodeid']; //We still need a title vB::$vbulletin->input->clean_array_gpc('p', array( 'sect_pr_' . $this_id => TYPE_INT)); if (vB::$vbulletin->GPC_exists['sect_pr_' . $this_id] ) { if (intval(vB::$vbulletin->GPC['sect_pr_' . $this_id])) { self::saveConfig ($this_id, 'section_priority', vB::$vbulletin->GPC['sect_pr_' . $this_id], false); } else { //The we go back to default. self::saveConfig ($this_id, 'section_priority', 0, false); } } //we need to purge the data cache record for this id $content = vBCms_Item_Content::create('vBCms', 'Section', $this_id); vB_Cache::instance()->event($content->getCacheEvents()); unset($content); } break; case 'sectionpp': // We need a nodeid and a sect_pp_XX value if (vB::$vbulletin->GPC_exists['nodeid']) { $this_id = vB::$vbulletin->GPC['nodeid']; //We still need a title vB::$vbulletin->input->clean_array_gpc('p', array( 'section_pp_' . $this_id => TYPE_INT)); if (vB::$vbulletin->GPC_exists['section_pp_' . $this_id] AND intval(vB::$vbulletin->GPC['section_pp_' . $this_id])) { self::saveConfig ($this_id, 'items_perhomepage', vB::$vbulletin->GPC['section_pp_' . $this_id], false); } //we need to purge the data cache record for this id $content = vBCms_Item_Content::create('vBCms', 'Section', $this_id); vB_Cache::instance()->event($content->getCacheEvents()); unset($content); } break; case 'saveonestyle': // We need a sectionid and state. 1 is published, 2 is unpublished, // and 3 means it's currently published in the future and we should leave it // that way. if (vB::$vbulletin->GPC_exists['nodeid']) { $this_id = vB::$vbulletin->GPC['nodeid']; //We still need a title vB::$vbulletin->input->clean_array_gpc('p', array( 'style_' . $this_id => TYPE_INT)); if (vB::$vbulletin->GPC['style_' . $this_id]) { self::saveRecords('cms_node', 'nodeid', array($this_id => array('styleid' =>vB::$vbulletin->GPC['style_' . $this_id]))); } else { self::saveRecords('cms_node', 'nodeid', array($this_id => array('styleid' => null))); } vB_Cache::instance()->event('section_nav_' . $this_id); vB_Cache::instance()->event('sections_updated'); } //we need to purge the data cache record for this id $content = vBCms_Item_Content::create('vBCms', 'Section', $this_id); vB_Cache::instance()->event($content->getCacheEvents()); vB_Cache::instance()->cleanNow(); unset($content); break; case 'publish_section': case 'publish_nodes': self::savePreview(); foreach(vB::$vbulletin->GPC['ids'] as $id) { vB::$vbulletin->input->clean_array_gpc('r', array('cb_' . $id => TYPE_STR )); if (vB::$vbulletin->GPC_exists['cb_' . $id]) { $checked[] = $id; } } if (count($checked)) { self::saveRecords('cms_node', 'nodeid', array('setpublish'=> 1), $checked); foreach($checked as $id) { vB_Cache::instance()->event('section_nav_' . $id); //we need to purge the data cache record for this id $content = vBCms_Item_Content::create('vBCms', 'Section', $id); vB_Cache::instance()->event($content->getCacheEvents()); unset($content); } break; vB_Cache::instance()->event('sections_updated'); vB_Cache::instance()->event('articles_updated'); vB_Cache::instance()->cleanNow(); } break; case 'unpublish_nodes': case 'unpublish_section': self::savePreview(); foreach(vB::$vbulletin->GPC['ids'] as $id) { vB::$vbulletin->input->clean_array_gpc('r', array('cb_' . $id => TYPE_STR )); if (vB::$vbulletin->GPC_exists['cb_' . $id]) { $checked[] = $id; } } if (count($checked)) { self::saveRecords('cms_node', 'nodeid', array('setpublish'=> 0), $checked); foreach($checked as $id) { vB_Cache::instance()->event('section_nav_' . $id); //we need to purge the data cache record for this id $content = vBCms_Item_Content::create('vBCms', 'Section', $id); vB_Cache::instance()->event($content->getCacheEvents()); unset($content); } vB_Cache::instance()->event('sections_updated'); vB_Cache::instance()->event('sections_updated'); vB_Cache::instance()->event('articles_updated'); vB_Cache::instance()->cleanNow(); } break; case 'move_node': case 'move_section': //sectionid is where we're moving the records. if (vB::$vbulletin->GPC_exists['sectionid'] and $nodelist = self::getNodeList($ids)) { $msg = self::moveSection($nodelist, vB::$vbulletin->GPC['sectionid']); } foreach ($nodelist as $sectionid) { vB_Cache::instance()->event('section_nav_' . $sectionid); } vB_Cache::instance()->event('sections_updated'); vB_Cache::instance()->event('articles_updated'); vB_Cache::instance()->cleanNow(); break; case 'save_section': //We should have a title, a sectionid, and a target_sectionid vB::$vbulletin->input->clean_array_gpc('p', array('title' => TYPE_STR , 'nodeid' => TYPE_INT, 'target_sectionid' => TYPE_INT)); if (vB::$vbulletin->GPC_exists['title'] AND vB::$vbulletin->GPC_exists['nodeid']) { $this_id = vB::$vbulletin->GPC['nodeid']; //First we save the title. Then try a move. //The move subroutine will check to see if it's necessary. self::saveRecords('cms_nodeinfo', 'nodeid', array($this_id => array('title' =>vB::$vbulletin->GPC['title'], 'html_title' =>vB::$vbulletin->GPC['title']))); } if (vB::$vbulletin->GPC_exists['target_sectionid'] and vB::$vbulletin->GPC['target_sectionid']) { $msg .= self::moveSection(array($this_id), vB::$vbulletin->GPC['target_sectionid']); } vB_Cache::instance()->event('section_nav_' . $this_id); vB_Cache::instance()->event('sections_updated'); vB_Cache::instance()->event('articles_updated'); //we need to purge the data cache record for this id $content = vBCms_Item_Content::create('vBCms', 'Section', $this_id); vB_Cache::instance()->event($content->getCacheEvents()); vB_Cache::instance()->cleanNow(); unset($content); break; case 'swap_sections': if (vB::$vbulletin->GPC_exists['nodeid'] AND vB::$vbulletin->GPC_exists['nodeid2']) { $node1 = vB::$vbulletin->GPC['nodeid']; $node2 = vB::$vbulletin->GPC['nodeid2']; self::swapNodes($node1, $node2); vB_Cache::instance()->event('section_nav_' . $node1); vB_Cache::instance()->event('section_nav_' . $node2); vB_Cache::instance()->event('sections_updated'); vB_Cache::instance()->event('articles_updated'); //we need to purge the data cache record for these ids $content = vBCms_Item_Content::create('vBCms', 'Section', $node1); vB_Cache::instance()->event($content->getCacheEvents()); $content = vBCms_Item_Content::create('vBCms', 'Section', $node2); vB_Cache::instance()->event($content->getCacheEvents()); vB_Cache::instance()->cleanNow(); unset($content); } break; case 'new_section': global $vbulletin; vB::$vbulletin->input->clean_array_gpc('p', array('title' => TYPE_STR , 'sectionid' => TYPE_INT, 'target_sectionid' => TYPE_INT, 'section_title' => TYPE_STR )); if (!vB::$vbulletin->GPC_exists['parentnode'] AND vB::$vbulletin->GPC_exists['target_sectionid']) { $vbulletin->GPC_exists['parentnode'] = 1; $vbulletin->GPC['parentnode'] = $vbulletin->GPC['target_sectionid']; } elseif (!vB::$vbulletin->GPC_exists['parentnode'] AND vB::$vbulletin->GPC_exists['sectionid']) { $vbulletin->GPC_exists['parentnode'] = 1; vB::$vbulletin->GPC['parentnode'] = vB::$vbulletin->GPC['sectionid']; } if (vB::$vbulletin->GPC_exists['title'] AND vB::$vbulletin->GPC_exists['parentnode'] and vB::$vbulletin->GPC['parentnode']) { { if ($content = vBCms_Content::create('vBCms', 'Section')) { $nodedm = new vBCms_DM_Section(); $nodedm->set('parentnode', $vbulletin->GPC['parentnode']); if (! $nodeid = $content->createDefaultContent($nodedm)) { throw (new vB_Exception_DM('Could not create new node for content: ' . print_r($nodedm->getErrors()))); } } vB_Cache::instance()->event('sections_updated'); vB_Cache::instance()->cleanNow(); //now let's display the new section. vB::$vbulletin->GPC_exists['sectionid'] = 1; vB::$vbulletin->GPC['sectionid'] = $nodeid; } } break; case 'new': // if (vB::$vbulletin->GPC_exists['sectionid'] AND vB::$vbulletin->GPC_exists['new_contenttype']) { $contenttypeid = vB::$vbulletin->GPC['new_contenttype']; try { // create the nodedm $class =vB_Types::instance()->getContentClassFromId($contenttypeid); $classname = "vBCms_DM_" . $class['class']; if (class_exists($classname)) { $nodedm = new $classname; } else { $nodedm = new vBCms_DM_Node(); } // create content handler $content = vBCms_Content::create(vB_Types::instance()->getContentTypePackage($contenttypeid), vBCms_Types::instance()->getContentTypeClass($contenttypeid)); // insert default content for the contenttype and get the new contentid $content->setParentNode(vB::$vbulletin->GPC['sectionid']); $contentid = $content->createDefaultContent($nodedm); } catch (vB_Exception $e) { throw (new vB_Exception_DM('Could not create default content. Exception thrown with message: \'' . htmlspecialchars_uni($e->getMessage()) . '\'')); } // Create new content node $nodedm->set('contenttypeid', $contenttypeid); $nodedm->set('contentid', $contentid); $nodedm->set('parentnode', vB::$vbulletin->GPC['sectionid']); $nodedm->set('title', (vB::$vbulletin->GPC_exists['section_title']? vB::$vbulletin->GPC['section_title'] : vB::$vbulletin->GPC['section_title']) ); //allow child nodes to set the author. This is necessary when we //promote a post if (! $nodedm->getSet('userid')) { $nodedm->set('userid', vB::$vbulletin->userinfo['userid']); } if (!($nodeid = $nodedm->save())) { throw (new vB_Exception_DM('Could not create new node for content: ' . print_r($nodedm->getErrors()))); } vB_Cache::instance()->event('section_nav_' . vB::$vbulletin->GPC['sectionid']); vB_Cache::instance()->event('sections_updated'); vB_Cache::instance()->event('articles_updated'); vB_Cache::instance()->cleanNow(); } break; case 'save_nodes': //The only thing we're updating is the publicpreview flag self::savePreview(); vB_Cache::instance()->event('articles_updated'); default: ; } // switch return $msg; }
/** * Fetches the SQL for loading. * * @param int $required_query - The required query * @return string */ protected function getLoadQuery($required_query) { // Hooks should check the required query before populating the hook vars $hook_query_fields = $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook($this->query_hook)) ? eval($hook) : false; if (self::QUERY_BASIC == $required_query) { $sql = "SELECT node.nodeid " . ($this->requireLoad(self::INFO_BASIC) ? ", node.contenttypeid, node.contentid, node.url, node.parentnode, node.styleid, node.userid, node.permissionsfrom, node.layoutid, node.publishdate, node.publicpreview, node.nodeleft, node.noderight, node.issection, node.showtitle, node.showuser, node.showpreview, node.showupdated, node.showviewcount, node.showcreation, node.settingsforboth, " : '') . ($this->requireLoad(self::INFO_NODE) ? ", info.description, info.title, info.html_title, info.viewcount, info.creationdate, info.workflowdate, info.associatedthreadid, info.workflowstatus, info.workflowcheckedout, info.viewcount, info.workflowlevelid, user.username" : '') . ($this->requireLoad(self::INFO_CONTENT) ? ", statichtml.html " : '') . " $hook_query_fields FROM " . TABLE_PREFIX . "cms_node AS node" . ($this->requireLoad(self::INFO_CONTENT) ? " INNER JOIN " . TABLE_PREFIX . "cms_statichtml AS statichtml ON statichtml.contentid = node.contentid" : '') . ($this->requireLoad(self::INFO_NODE) ? " INNER JOIN " . TABLE_PREFIX . "cms_nodeinfo AS info ON info.nodeid = node.nodeid LEFT JOIN " . TABLE_PREFIX . "user AS user ON user.userid = node.userid" : '') . " $hook_query_joins WHERE " . (is_numeric($this->itemid) ? 'node.nodeid = ' . intval($this->nodeid) : 'node.contenttypeid = ' . intval($this->contenttypeid) . ' AND node.contentid = ' . intval($this->contentid)) . " $hook_query_where "; return $sql; } return parent::getLoadQuery($required_query); }
/** * Fetches the contentid. * How this is interpreted is up to the content handler for the contenttype. * Note that to make vB_Model work properly when instantiating a new item * we need to return the nodeid if we don't have a content id. But we should * be able to get only the contentid if we don't want the nodeid. * @return int */ public function getContentId($contentonly = false) { return parent::getNodeId(); }
/** * Gets a consistent key for cache events. * * @return array string */ public function getCacheEvents() { $events = parent::getCacheEvents(); if ($thread = $this->getAssociatedThreadId()) { $events[] = "cms_comments_change_$thread"; } return $events; }