Exemplo n.º 1
0
	/**
	 * Constructor.
	 *
	 * @param array mixed $parameters			- User requested parameters.
	 * @param string $action					- Optional action for the controller's getResponse()
	 */
	public function __construct(array $parameters = null, $action = false)
	{
		parent::__construct($parameters, $action);

		vBCms_NavBar::prepareNavBar();
	}
Exemplo n.º 2
0
	/**
	 * 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);
	}
Exemplo n.º 3
0
	/**
	 * 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)
	{
		parent::populateViewContent($view, $viewtype);

		$view->node = $this->content->getNodeId();
		$view->type = new vB_Phrase('global', 'content');

		if (vB::$vbulletin->userinfo['userid'])
		{
			$view->published = $this->content->isPublished();
		}
		else
		{
			$view->published = true;
		}

		$view->page_url = $this->getPageUrl();
		//Let's pass an url for editing.
		$view->edit_url = $this->getEditUrl();

		if ($date = $this->content->getPublishDate())
		{
			$view->publishdate = $date;
		}

		$view->publish_phrase = new vB_Phrase('vbcms', 'page_not_published');

		// Get comments
		if ((self::VIEW_PAGE == $viewtype) AND (vB::$vbulletin->options['vbcmsforumid'] > 0) AND $this->content->isPublished() AND !$this->isSection())
		{
			try
			{
				$thread = $this->getAssociatedThread();
				$view->show_comments = ($thread AND $thread->can_view(new vB_Legacy_CurrentUser()));

				if ($view->show_comments)
				{
					$postids = $this->getCommentPosts($thread);
					require_once DIR . '/includes/functions_forumdisplay.php' ;
					$view->thread = process_thread_array($thread->get_record());
				}
			}
			catch (Exception $e)
			{
				if (vB::$vbulletin->config['debug'])
				{
					throw ($e);
				}
			}
		}


		// Check if the user has voted
		$check = true;
		if (vB::$vbulletin->userinfo['userid'])
		{
			$row = vB::$db->query_first("SELECT vote FROM " . TABLE_PREFIX . "cms_rate WHERE userid = " . vB::$vbulletin->userinfo['userid'] . " AND nodeid = " . $view->node);
			if ($row[0])
			{
				$check = false;
			}
		}
		$rated = intval(fetch_bbarray_cookie('cms_rate', $view->node));

		// voted already
		if ($row[0] OR $rated)
		{
			$rate_index = $rated;
			if ($row[0])
			{
				$rate_index = $row[0];
			}
			$view->voteselected["$rate_index"] = 'selected="selected"';
			$view->votechecked["$rate_index"] = 'checked="checked"';
		}
		else
		{
			$view->voteselected[0] = 'selected="selected"';
			$view->votechecked[0] = 'checked="checked"';
		}

		$view->showratenode =
		(
			(
				$check
			OR
				(!$rated AND !vB::$vbulletin->userinfo['userid'])
			)
			OR
				vB::$vbulletin->options['votechange']
		);

		// Get ratings
		if ($this->content->getRatingNum() >= vB::$vbulletin->options['showvotes'])
		{
			$view->ratingtotal = $this->content->getRatingTotal();
			$view->ratingnum = $this->content->getRatingNum();
			$view->ratingavg = vb_number_format($view->ratingtotal / $view->ratingnum, 2);
			$view->rating = intval(round($view->ratingtotal / $view->ratingnum));
			$view->showrating = true;
		}
		else
		{
			$view->showrating = false;
		}
		vB_Cache::instance()->event(vBCms_NavBar::getCacheEventId($this->content->getNodeId()));


	}
Exemplo n.º 4
0
	/**
	* Additional tasks to perform after a delete.
	*
	* Return false to indicate that the entire delete process was not a success.
	*
	* @param mixed								- The result of execDelete()
	*/
	protected function postDelete($result)
	{
		$this->treeUpdated();

		$this->assertItem();

		vB::$db->query_write("
			DELETE FROM " . TABLE_PREFIX . "cms_nodeconfig
			WHERE nodeid = " . intval($this->item->getNodeId())
		);

		vB::$db->query_write("
			DELETE FROM " . TABLE_PREFIX . "cms_nodeinfo
			WHERE nodeid = " . intval($this->item->getNodeId())
		);

		vB::$db->query_write("
			DELETE FROM " . TABLE_PREFIX . "cms_navigation
			WHERE nodeid = " . intval($this->item->getNodeId())
		);

		// Delete associated thread
		if ($threadid = $this->item->getAssociatedThreadId())
		{
			if ($threadinfo = verify_id('thread', $threadid, false, true))
			{
				$threadman =& datamanager_init('Thread', vB::$vbulletin, ERRTYPE_SILENT, 'threadpost');
				$threadman->set_existing($threadinfo);
				$threadman->delete(true, true, NULL, false);
				unset($threadman);

				build_forum_counters($threadinfo['forumid']);
			}
		}

		vB_Cache::instance()->event(vBCms_NavBar::getCacheEventId(vBCms_NavBar::GLOBAL_CACHE_EVENT));

		return parent::postDelete($result);
	}
Exemplo n.º 5
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;
		}

	}
Exemplo n.º 6
0
}
$vbulletin->input->clean_array_gpc('r', array('return_node' => TYPE_UINT));
if ($vbulletin->GPC['return_node']) {
    $report_type = 'article_comment';
    $content = new vBCms_Item_Content_Article($vbulletin->GPC['return_node']);
    $reportobj = new vB_ReportItem_ArticleComment($vbulletin);
    $reportobj->set_extrainfo('node', $vbulletin->GPC['return_node']);
    $reportobj->set_extrainfo('forum', $foruminfo);
    $reportobj->set_extrainfo('thread', $threadinfo);
    // check cms permissions on the article
    if (!$content->canView()) {
        print_no_permission();
    }
    define('CMS_SCRIPT', true);
    vB_View::registerTemplater(vB_View::OT_XHTML, new vB_Templater_vB());
    vBCms_NavBar::prepareNavBar($content);
} else {
    $report_type = 'post';
    $reportobj = new vB_ReportItem_Post($vbulletin);
    $reportobj->set_extrainfo('forum', $foruminfo);
    $reportobj->set_extrainfo('thread', $threadinfo);
    $forumperms = fetch_permissions($threadinfo['forumid']);
    if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) or $threadinfo['postuserid'] != $vbulletin->userinfo['userid'] and !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers'])) {
        print_no_permission();
    }
    // check if there is a forum password and if so, ensure the user has it set
    verify_forum_password($foruminfo['forumid'], $foruminfo['password']);
}
$perform_floodcheck = $reportobj->need_floodcheck();
if ($perform_floodcheck) {
    $reportobj->perform_floodcheck_precommit();
Exemplo n.º 7
0
	/**
	 * Prepares the navbar view so that it can be fetched and rendered.
	 * Note: Forcing the cache to be ignored is useful if the subnav has just been
	 * updated.
	 *
	 * @param vBCms_Item_Content $node			- The current node
	 * @param bool $refresh						- Forces the cache to be ignored and the view to be rebuilt.
	 */
	public static function prepareNavBar($node = false, $refresh = false)
	{
		// Normalize node
		$node = ($node ?  $node : 1);

		if (!$node instanceof vBCms_Item_Content)
		{
			$node = new vBCms_Item_Content($node, vBCms_Item_Content::INFO_NAVIGATION);
		}

		$cache_key = self::getHash($node);

		if ($refresh OR !$navnodes = vB_Cache::instance()->read($cache_key, false, true))
		{

			//The query to pull the navigation requires that the
			//parent information be available
			$node->requireInfo(vBCms_Item_Content::INFO_PARENTS);
			$node->isValid();
			$node->requireInfo(vBCms_Item_Content::INFO_NAVIGATION);

			if ($navnodes = $node->getNavigationNodes())
			{
				// get collection
				$collection = new vBCms_Collection_Content($navnodes, vBCms_Item_Content::INFO_NODE | vBCms_Item_Content::INFO_PARENTS);
				$collection->filterVisible(false);

				// check count
				if (!$collection->isValid())
				{
					return false;
				}

				// set original ids as keys
				$navnodes = array_flip($navnodes);
				// remap order
				foreach ($collection AS $navnode)
				{
					$navnodes[$navnode->getNodeId()] = $navnode;
				}
				unset($collection);

				// remove unfound entries
				foreach ($navnodes AS $id => $navnode)
				{
					if (!$navnode instanceof vBCms_Item_Content)
					{
						unset($navnodes[$id]);
					}
				}
				// write cache
				vB_Cache::instance()->write(
					$cache_key,
					$navnodes,
					self::$cache_ttl,
					array(
						self::getCacheEventId($node->getNavigationNode()),
						self::GLOBAL_CACHE_EVENT,
						self::GLOBAL_SECTION_CACHE_EVENT
					)
				);
			}
		}

		if (is_array($navnodes) AND !empty($navnodes))
		{
			$perms_load = array();
			foreach($navnodes as $navnode)
			{
				$perms_load[] = $navnode->getNodeId();
			}

			vBCMS_Permissions::loadPermissionsfrom(array_keys($perms_load));
		}

		// create navlinks for published nodes
		$links = array();
		$route = new vBCms_Route_Content();

		foreach ((array)$navnodes AS $navnode)
		{
			if ($navnode->isPublished() AND $navnode->canView())
			{
				$route->node = $navnode->getUrlSegment();
				$links[] = array(
					'title' => $navnode->getTitle(),
					'url' => $route->getCurrentUrl()
				);
			}
		}


		if (!self::$view OR $refresh)
		{
			self::$view = new vB_View('vbcms_navbar_link');
			self::$view->links = $links;
		}

	}