Exemple #1
0
	/**
	 * Initialisation.
	 * Initialises the view, templaters and all other necessary objects for
	 * successfully creating the response.
	 */
	protected function initialize()
	{
		// Setup the templater.  Even XML output needs this for the html response
		//First we need a node from which we can get a style.

		//We need to set sectionid, style, and layout
		global $vbphrase;
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('vbcms');

		//we are going to use simple paging, so let' limit the number of records return.

		if (count($this->segments) < 2)
		{
			$value = 1;
		}
		else
		{
			$value = max(1, intval($this->segments['value']));
			}
			switch($this->segments['type'])
		{
			case 'author':
				//if we were passed a parameter for fromsection, we use that.
				//or it could be the fourth parameter.
				vB::$vbulletin->input->clean_array_gpc('r', array(
					'fromsection' => TYPE_INT,
					'sectionid' => TYPE_INT,
					));


				$this->query_filter = " AND node.userid = " . intval($value);

				if (vB::$vbulletin->GPC_exists['fromsection'] AND intval(vB::$vbulletin->GPC['fromsection']))
				{
					$displaysectionid = intval(vB::$vbulletin->GPC['fromsection']);
				}
				//we haven't got a section.
				else $displaysectionid = "SELECT MIN(nodeid) AS nodeid FROM " . TABLE_PREFIX . "cms_node WHERE
					parentnode IS NULL";
				;
				if ($record = vB::$vbulletin->db->query_first("SELECT username FROM " .TABLE_PREFIX .
					"user WHERE userid = $value" ))
				{
					$this->title = $record['username'];
					$this->urlstring = $this->title;
				}
				$this->result_type = $vbphrase['author'];
				break;
			case 'section':

				$this->query_filter = " AND node.parentnode = " . $value;
				$displaysectionid = $value;


				if ($record = vB::$vbulletin->db->query_first("SELECT title FROM " .TABLE_PREFIX .
					"cms_nodeinfo WHERE nodeid = $value" ))
				{
					$this->title = $record['title'];
					$this->urlstring = urlencode($this->title);
				}

				$this->result_type = $vbphrase['section'];
				break;

			case 'category':

				$record = vB::$vbulletin->db->query_first("SELECT category, parentnode FROM " .TABLE_PREFIX .
				"cms_category WHERE categoryid = $value") ;
				if (!$record)
				{
					$record = vB::$vbulletin->db->query_first("SELECT category, parentnode, categoryid FROM " .TABLE_PREFIX .
					"cms_category LIMIT 1") ;
					if ($record)
					{
						$this->segments['value'] = $value = $record['categoryid'];
					}

				}
				if (!$record)
				{
					throw (new vB_Exception_User(new vB_Phrase('error', 'no_categories_defined')));
				}
				$this->joins = " INNER JOIN " . TABLE_PREFIX . "cms_nodecategory AS nodecat ON nodecat.nodeid = node.nodeid
						 AND nodecat.categoryid = $value" ;

				$this->title = $record['category'];
				$this->urlstring = urlencode($record['category']);
				$displaysectionid = $record['parentnode'];

				$this->result_type = $vbphrase['category'];
				break;

			case 'day':
				//Here we displaying for a specific day. We need to get the date range for the
				//where clause. We have nothing to set the $displaysectionid, so set it to false
				$displaysectionid = false;

				//default date to today
				if (! (intval($value) > 1000000))
				{
					$value = TIMENOW;
				}

				$this->query_filter = " AND node.setpublish > 0 AND (node.publishdate BETWEEN $value  AND " .
					 ($value + 86399) . ") " ;
				$this->title = vbdate( vB::$vbulletin->options['dateformat'], $value);
				$this->urlstring = urlencode($value);

				$displaysectionid = "SELECT MIN(nodeid) AS nodeid FROM " . TABLE_PREFIX . "cms_node WHERE
					parentnode IS NULL";
				$this->result_type = $vbphrase['date'];
				break;

			default:
				//we haven't got a section.
				$displaysectionid = "SELECT MIN(nodeid) AS nodeid FROM " . TABLE_PREFIX . "cms_node WHERE
					parentnode IS NULL";
				;
				if ($record = vB::$vbulletin->db->query_first("SELECT title FROM " .TABLE_PREFIX .
					"cms_nodeinfo WHERE nodeid = ($displaysectionid)"))
				{
					$this->title = $record['title'];
					$this->result_type = $vbphrase['section'];
					$this->urlstring = urlencode($this->title );
				}
				$this->result_type = $vbphrase['section'];
			;
		} // switch

		if (! is_numeric($displaysectionid) )
		{

			$record = vB::$vbulletin->db->query_first($displaysectionid);
			$displaysectionid = $record['nodeid'];
		}

		$rst = vB::$vbulletin->db->query_read("SELECT parent.nodeid, parent.styleid, parent.layoutid from " .
			TABLE_PREFIX . "cms_node AS node	INNER JOIN " . TABLE_PREFIX .
			"cms_node AS parent ON (node.nodeleft >= parent.nodeleft AND node.nodeleft <= parent.noderight)
			   WHERE node.nodeid = " . $displaysectionid . "
			 ORDER BY parent.nodeleft DESC ;");

		$record = vB::$vbulletin->db->fetch_array($rst);

		$this->sectionid = $record['nodeid'];

		$node = vBCms_Item_Content::create('vBCms', 'Section', $displaysectionid);

		if (! $node->canView())
		{
			throw (new vB_Exception_AccessDenied());
		}
		$node->requireInfo(vBCms_Item_Content::INFO_NODE);
		vBCms_NavBar::prepareNavBar($node);

		while($record)
		{
			if (intval($record['layoutid']) AND !intval($this->layoutid))
			{
				$this->layoutid = $record['layoutid'];
			}
			if (intval($record['styleid']) AND !intval($this->styleid))
			{
				$this->styleid = $record['styleid'];
			}

			if (intval($this->layoutid))
			{
				$this->displaysectionid = $displaysectionid;
				return;
			}

			$record = vB::$vbulletin->db->fetch_array($rst);
		}

		if (!intval($this->styleid))
		{
			$this->styleid = vB::$vbulletin->options['styleid'];
		}

		if (!intval($this->layoutid))
		{
			$this->layoutid = 1;
		}

	}
Exemple #2
0
	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;
	}