protected function load_content_info() { $type_instance = vB_Types::instance(); $class = $type_instance->getContentTypeClass($this->contenttypeid); $package = $type_instance->getContentTypePackage($this->contenttypeid); //this forces some of the fields we access to be loaded. $contentinfo = vBCms_Content::create($package, $class); //we have a contenttype and content id, but we need the nodeid. if ($record = vB::$vbulletin->db->query_first("SELECT nodeid FROM " . TABLE_PREFIX . "cms_node WHERE contenttypeid = " . $this->contenttypeid . " AND contentid = " . $this->contentid)) { $item = vB_Item_Content::create($package, $class, $this->nodeid = $record['nodeid']); $item->requireInfo($contentinfo->getViewInfoFlags(vB_Content::VIEW_PREVIEW)); $contentinfo->setContentItem($item); return $contentinfo; } return false; }
/** * Returns the inline edit view for the widget. * Widgets do not have to support this, however if they are editable and * configurable then the page view can be returned in a tool block view, which * the default implementation provides. * * The inline edit view allows the current user to edit the contents of the * widget. This should only be allowed for users with permission and should * generally be used to edit widget content rather than configuration. * * @return vBCms_View_Widget - The view result */ public function getInlineEditView() { $this->assertWidget(); // add the tool block $view = new vBCms_View_EditBlock('vbcms_edit_block'); if ($this->canEdit()) { $view->content = $this->getInlineEditBodyView(); if ($this->is_editable) { $view->edit_url = vBCms_Route_Content::getURL(array('node' => $this->content->getNodeURLSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Widget', 'Edit')), array($this->widget->getId())); } if ($this->is_configurable) { $view->config_url = vBCms_Route_Content::getURL(array('node' => $this->content->getNodeURLSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Widget', 'Config')), array($this->widget->getId())); } } else { $view->content = $this->getPageView(); } $view->type = new vB_Phrase('vbcms', 'widget'); $view->typetitle = $this->widget->getTypeTitle(); $view->title = $this->widget->getTitle(); return $view; }
/** * Populates a view with the expected info from a content item. * Note: The view type should be based on the VIEW constants defined by the * content handler class. * * Child classes will need to extend or override this for custom content. * * @param vB_View $view * @param int $viewtype */ protected function populateViewContent(vB_View $view, $viewtype = self::VIEW_PAGE, $increment_count = true) { if ($_REQUEST['do'] == 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode') { $this->SaveData(); $this->content->reloadContent(); } 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)); } 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()); } parent::populateViewContent($view, $viewtype); $view->url = $this->content->getUrl(); $view->html = $this->content->getHtml(); $view->html_title = $this->content->getHtmlTitle(); $view->title = $this->content->getTitle(); $view->font = $this->content->getConfig('font'); $view->fontsize = $this->content->getConfig('size'); $view->update_url = vB_Router::getURL(); $view->parenttitle = $this->content->getParentTitle(); $view->setpublish = $this->content->getSetPublish(); $view->dateformat = vB::$vbulletin->options['dateformat']; //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']; $view->categories = $this->content->getCategories(); $view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_StaticHtml"); }
/** This function gets the article information based on the defined criteria * * @return array */ protected function getContent() { // First, compose the sql $sql = "SELECT node.contenttypeid, node.url, node.publishdate, node.userid, node.setpublish, node.publicpreview, info.title, user.username, node.showuser, node.nodeid, node.contenttypeid, thread.replycount FROM " . TABLE_PREFIX . "cms_node AS node INNER JOIN " . TABLE_PREFIX . "contenttype AS type on type.contenttypeid = node.contenttypeid INNER JOIN " . TABLE_PREFIX . "cms_nodeinfo AS info on info.nodeid = node.nodeid " . ( (($this->config['categories'] != '') AND ($this->config['categories'] != '0')) ? " INNER JOIN " . TABLE_PREFIX . "cms_nodecategory nc ON nc.nodeid = node.nodeid " : '') . " LEFT JOIN " . TABLE_PREFIX . "user AS user ON user.userid = node.userid LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON thread.threadid = info.associatedthreadid WHERE type.isaggregator = '0' AND " . vBCMS_Permissions::getPermissionString() ; if (($this->config['categories'] != '') AND ($this->config['categories'] != '0') ) { $sql .= "\n AND nc.categoryid IN (" . $this->config['categories'] . ")\n"; } if (($this->config['sections'] != '') AND ($this->config['sections'] != '0')) { $sql .= "\n AND node.parentnode IN (" . $this->config['sections'] . ")\n"; } if (isset($this->config['days']) AND (intval($this->config['days'])) ) { $sql .= "\n AND node.publishdate > " . (TIMENOW - (86400 * $this->config['days'])) . "\n"; } $sql .= "\n ORDER BY node.publishdate DESC LIMIT " . $this->config['count']; $items = array(); //Execute if ($rst = vB::$db->query_read($sql)) { $current_record = array('contentid' => -1); //now build the results array while($item = vB::$db->fetch_array($rst)) { $item['categories'] = array(); $item['tags'] = array(); $class = vB_Types::instance()->getContentTypeClass($item['contenttypeid']); $package = vB_Types::instance()->getContentTypePackage($item['contenttypeid']); $node = vBCms_Content::create($package, $class, $item['nodeid']); $item['pagetext'] = $item['previewtext'] = ''; //get the avatar if (vB::$vbulletin->options['avatarenabled']) { $item['avatar'] = fetch_avatar_url($item['userid']); } if (method_exists($node, 'getPageText')) { $item['pagetext'] = fetch_censored_text($node->getPageText()); } if (method_exists($node, 'getPreviewText')) { $item['previewtext'] = fetch_censored_text($node->getPreviewText()); } else if (!empty($item['pagetext'])) { $item['previewtext'] = vB_Search_Searchtools::getSummary($item['pagetext'], 200); } if (method_exists($node, 'getPreviewImage')) { $item['pagetext'] = fetch_censored_text($node->getPageText()); } $items[$item['nodeid']] = $item; } //Let's get the tags and the categories // we can do that with one query each. if (count($articles)) { //first let's get categories $nodeids = implode(', ', array_keys($item)); $sql = "SELECT nc.nodeid, nc.categoryid, category.category FROM " . TABLE_PREFIX . "cms_nodecategory AS nc INNER JOIN " . TABLE_PREFIX . "cms_category AS category ON category.categoryid = nc.categoryid WHERE nc.nodeid IN ($nodeids)"; if ($rst = vB::$db->query_read($sql)) { while ($record = vB::$db->fetch_array($rst)) { $route_info = $record['categoryid'] . ($record['category'] != '' ? '-' . str_replace(' ', '-', $record['category']) : ''); $record['route_info'] = $route_info; $record['category_url'] = vB_Route::create('vBCms_Route_List', "category/" . $record['route_info'] . "/1")->getCurrentURL(); $items[$record['nodeid']]['categories'][$record['categoryid']] = $record; } } //next tags; $sql = "SELECT tag.tagid, node.nodeid, tag.tagtext FROM " . TABLE_PREFIX . "cms_node AS node INNER JOIN " . TABLE_PREFIX . "tagcontent AS tc ON (tc.contentid = node.contentid AND tc.contenttypeid = node.contenttypeid) INNER JOIN " . TABLE_PREFIX . "tag AS tag ON tag.tagid = tc.tagid WHERE node.nodeid IN ($nodeids) "; if ($rst = vB::$db->query_read($sql)) { while ($record = vB::$db->fetch_array($rst)) { $items[$record['nodeid']]['tags'][$record['tagid']] = $record['tagtext']; } } } } return $items; }
/** * Config Widget * * @return string - The final page output */ public function actionConfig($widget = false) { if (!$widget) { throw (new vB_Exception_404(new vB_Phrase('error', 'page_not_found'))); } // Setup the templater for xhtml vB_View::registerTemplater(vB_View::OT_XHTML, new vB_Templater_vB()); // Get the content controller $this->content = vBCms_Content::create($this->node->getPackage(), $this->node->getClass(), $this->node->getContentId()); // Add the node as content $this->content->castFrom($this->node); // Get Widget that we're configuring $widgets = vBCms_Widget::getWidgetCollection(array($widget), vBCms_Item_Widget::INFO_CONFIG, $this->node->getId()); $widgets = vBCms_Widget::getWidgetControllers($widgets, true, $this->content); if (!isset($widgets[$widget])) { throw (new vB_Exception_404()); } $widget = $widgets[$widget]; // Render the content's config view and return return $widget->getConfigView()->render(true); }
/** * 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; }
/** * 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; }
/** * Gets the events that need to be cleaned when the content is updated. * Add a generic 'sections_updated' event. Useful for widgets. */ protected function getCleanCacheEvents() { $events = parent::getCleanCacheEvents(); foreach ($this->content->getCacheEvents() as $event) { $events[] = $event; } $events[] = 'sections_updated'; return array_unique($events); }
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(); }
/** * Builds the toolbar view for managing the page. * * @param bool $edit_mode - Whether the user is currently in edit mode * @return vB_View */ protected function getToolbarView($edit_mode = false) { global $vbulletin; global $vbphrase; if (!$this->content->canCreate() AND !$this->content->canEdit() AND !$this->content->canPublish()) { return; } require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('cpcms'); // Create view $view = new vB_View('vbcms_toolbar'); $view->edit_mode = $edit_mode; $view->page_url = vB_Router::getURL(); $view->access = ($this->content->publicCanView() ? $vbphrase['public'] : $vbphrase['public']); // Setup a new route to get URLs $route = new vBCms_Route_Content(); $route->node = $this->node->getURLSegment(); $view->view_url = $route->getCurrentURL(array('action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'))); $view->edit_url = $route->getCurrentURL(array('action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'))); $view->edit_label = new vB_Phrase('vbcms', 'edit_this_page'); // New content options $view->add_url = $route->getCurrentURL(array('action' => vB_Router::getUserAction('vBCms_Controller_Content', 'AddNode'))); $view->add_label = new vB_Phrase('vbcms', 'create_new'); // Get placable contenttypes. TODO: This should be a method of vB_Types for reuse if (!($view->contenttypes = vB_Cache::instance()->read('vbcms_controller_content.place_nonaggs', true, true))) { $contenttype_collection = new vB_Collection_ContentType(); $contenttype_collection->filterPlaceable(true); $contenttype_collection->filterNonAggregators(true); $contenttypes = array(); $permissionsfrom = $this->content->getPermissionsFrom(); foreach ($contenttype_collection AS $contenttype) { $this_type = vBCms_Content::create($contenttype->getPackageClass(), $contenttype->getClass(), 0); if ($this_type->canCreateHere($permissionsfrom)) { $title = (string)$contenttype->getTitle(); $contenttypes[$title] = array('id' => $contenttype->getId(), 'title' => $title); }; unset($this_type); } ksort($contenttypes); $view->contenttypes = $contenttypes; unset($contenttype_collection, $contenttypes); vB_Cache::instance()->write('vbcms_controller_content.place_nonaggs', $view->contenttypes, false, vB_Types::instance()->getContentTypeCacheEvents()); } // Set the publish state description if ($this->node->isPublished()) { $view->publish_status = new vB_Phrase('vbcms', 'page_is_published'); } else if ($this->node->getPendingParentId()) { $pending_title = $this->node->getPendingParentTitle(); $pending_route = vB_Route::create('vBCms_Route_Content')->getCurrentURL(array('node' => $this->node->getPendingParentId())); $view->publish_status = new vB_Phrase('vbcms', 'section_x_not_published', $pending_route, $pending_title); } else if ($date = $this->node->getPublishDate()) { $date = vbdate(vB::$vbulletin->options['dateformat'], $date, true); $view->publish_status = new vB_Phrase('vbcms', 'page_will_be_published_x', $date); } else { $view->publish_status = new vB_Phrase('vbcms', 'page_not_published'); } $view->can_publish = $this->content->canPublish(); $view->can_edit = $this->content->canEdit(); $view->can_create = $this->content->canCreate(); // Add postid $this->addPostId($view); return $view; }
public static function fixNodeLR($sectionid = false, $nodeleft = 0, $sectiontypeid = false, $findmissing = true) { //We pull the list of items that are children of the current node. global $vbulletin; global $vbphrase; $result = ''; if (! intval($sectiontypeid)) { $sectiontypeid = vB_Types::instance()->getContentTypeID("vBCms_Section"); } //There can be nodes that don't have a valid parent. In that case, we make a //"lost and found" section and put them into it. If we do this first, then //we will automatically fix it. if ($findmissing) { if ($rst = $vbulletin->db->query_read("SELECT n1.nodeid FROM " . TABLE_PREFIX . "cms_node n1 LEFT JOIN " . TABLE_PREFIX . "cms_node n2 ON n2.nodeid = n1.parentnode AND n2.nodeid <> n1.nodeid AND n2.contenttypeid = $sectiontypeid WHERE n2.nodeid IS NULL AND n1.contenttypeid <> $sectiontypeid;")) { $orphans = array(); while($record = $record = $vbulletin->db->fetch_array($rst)) { $orphans[] = $record['nodeid']; } } //Do we have orphans? if (count($orphans)) { //We need to make a lost and found folder. $record = $vbulletin->db->query_first("SELECT node.nodeid FROM " . TABLE_PREFIX . "cms_node AS node WHERE node.parentnode IS NULL LIMIT 1"); //Now create a node. $vbulletin->GPC_exists['parentnode'] = $vbulletin->GPC_exists['sectionid'] = 1; $vbulletin->GPC['parentnode'] = $vbulletin->GPC['sectionid'] = $record['nodeid']; if ($content = vBCms_Content::create('vBCms', 'Section')) { require_once DIR . '/includes/functions_misc.php'; $nodedm = new vBCms_DM_Section(); $nodedm->set('parentnode', $record['nodeid']); $nodedm->set('contenttypeid', $sectiontypeid); vB::$vbulletin->GPC_exists['title'] = 1; vB::$vbulletin->GPC['title'] = fetch_phrase('lost_found', 'cpcms'); // create content handler $content = vBCms_Content::create('vBCms', 'Section'); $content->setParentNode( $record['nodeid']); if (! $sectionid = $content->createDefaultContent($nodedm)) { throw (new vB_Exception_DM('Could not create new node for content: ' . print_r($nodedm->getErrors()))); } $result = fetch_phrase('check_lost_found', 'cpcms'); } vB_Cache::instance()->event('sections_updated'); vB_Cache::instance()->cleanNow(); //We have everything we need. Let's update $vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "cms_node SET parentnode = $sectionid, permissionsfrom = 1 WHERE nodeid IN(" . implode(',', $orphans) . ")"); } self::fixNodeLR(false, 0, $sectiontypeid, false); return $result; } else { $rst = $vbulletin->db->query_read($sql = "SELECT node.nodeid, contenttypeid FROM " . TABLE_PREFIX . "cms_node AS node INNER JOIN " . TABLE_PREFIX . "cms_nodeinfo AS info ON info.nodeid = node.nodeid WHERE node.parentnode " . (intval($sectionid) ? "= $sectionid" : "IS NULL") . " ORDER BY nodeleft" ); $nodes = array(); while ($record = $vbulletin->db->fetch_array($rst)) { $nodes[] = $record; } $vbulletin->db->free_result($rst); $childnodeleft = intval($nodeleft) + 1; if ($sectionid) { //Find out if we should assign permissionsfrom for this record, or inherit from a parent. if ($permission_record = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX . "cms_permissions WHERE nodeid = $sectionid LIMIT 1;" )) { $permissionsfrom = $sectionid; } else { $permission_record = $vbulletin->db->query_first("SELECT permissionsfrom FROM " . TABLE_PREFIX . "cms_node WHERE nodeid = $sectionid LIMIT 1;" ); $permissionsfrom = $permission_record['permissionsfrom']; } } else { //We are at the root. Our early code created orphan nodecategory records. Let's find and // remove any. $vbulletin->db->query_write("CREATE TEMPORARY TABLE cms_nc_orphans AS select nc.nodeid FROM " . TABLE_PREFIX . "cms_nodecategory nc LEFT JOIN " . TABLE_PREFIX . "cms_node AS node on node.nodeid = nc.nodeid WHERE node.nodeid IS NULL;"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "cms_nodecategory WHERE nodeid IN (SELECT nodeid from cms_nc_orphans);"); $vbulletin->db->query_write("DROP TEMPORARY TABLE cms_nc_orphans"); $permissionsfrom = false; } foreach ($nodes as $node) { if (intval($node['contenttypeid']) == intval($sectiontypeid)) { if ($permissionsfrom) { $vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "cms_node SET permissionsfrom = $permissionsfrom WHERE nodeid = " . $node['nodeid']); } $childnodeleft = self::fixNodeLR($node['nodeid'], $childnodeleft, $sectiontypeid, false); } else { $rst = $vbulletin->db->query_write($sql = "UPDATE " . TABLE_PREFIX . "cms_node SET nodeleft = $childnodeleft, noderight = " . ($childnodeleft + 1) . ", permissionsfrom = $permissionsfrom WHERE nodeid = " . $node['nodeid'] ); $childnodeleft += 2; } } if (intval($sectionid)) { $rst = $vbulletin->db->query_write($sql = "UPDATE " . TABLE_PREFIX . "cms_node set nodeleft = $nodeleft, noderight = " . $childnodeleft . ($permissionsfrom ? ", permissionsfrom = $permissionsfrom" : '') . " WHERE nodeid = $sectionid " ); return $childnodeleft + 1; } } self::fixCategoryLR(); return $result; }