Beispiel #1
0
	/**
	 * Fetches the standard page view .
	 * @param integer $nodeid - node for which we are displaying comments
	 *
	 * @return vBCms_View				- The resolved view, or array of views
	 */
	public function getPageView($nodeid, $target_url)
	{
		global $vbphrase;

		require_once DIR . '/includes/functions_editor.php';

			vB::$vbulletin->input->clean_array_gpc('r', array(
			'nodeid'     => vB_Input::TYPE_INT,
			'page' => vB_Input::TYPE_INT,
			'direction' => vB_Input::TYPE_STR,
			'postid' => vB_Input::TYPE_UINT
		));

		if (! $row = vB::$vbulletin->db->query_first("SELECT node.comments_enabled, node.setpublish, node.publishdate,
		 nodeinfo.associatedthreadid,	thread.forumid FROM "
		. TABLE_PREFIX . "cms_node AS node LEFT JOIN "
		. TABLE_PREFIX . "cms_nodeinfo AS nodeinfo ON node.nodeid = nodeinfo.nodeid LEFT JOIN "
		. TABLE_PREFIX . "thread AS thread on thread.threadID = nodeinfo.associatedthreadid
			WHERE	nodeinfo.nodeid = $nodeid LIMIT 1;" ))
		{
			return false;
		}

		if (! $row['comments_enabled'] OR !$row['setpublish'] OR ($row['publishdate'] > TIMENOW))
		{
			return false;
		}

		if (! intval($row['forumid']))
		{
			$this->repairComments($row['associatedthreadid']);
		}

		if (!intval($row['associatedthreadid']))
		{
			return false;
		}

		$associatedthreadid = $row['associatedthreadid'];
		
		$base_url = empty($target_url) ? vB_Router::getCurrentURL() : $target_url;


		// Create view
		$view = new vB_View('vbcms_comments_page');
		$view->nodeid = $nodeid;
		$view->threadid = $row['associatedthreadid'];
		$view->this_url = str_replace('&', '&', $base_url);

		// display publish to Facebook checkbox in quick editor?
		if (is_facebookenabled())
		{
			$view->fbpublishcheckbox = construct_fbpublishcheckbox();
		}

		$this_user = new vB_Legacy_CurrentUser();

		$pageno = vB::$vbulletin->GPC_exists['page'] ?
			vB::$vbulletin->GPC['page'] : 1;
		$view->pageno = $pageno;
		$view->node_comments = self::showComments($view->nodeid,
			$this_user, $pageno, 20, $target_url, $associatedthreadid);

		// make sure user has permission to post comment before displaying comment editor
		if (self::canPostComment($view->threadid, $this_user))
		{
			// prepare the wyswiwig editor for comments
			$view->show_comment_editor = true;
			global $messagearea;
			$editor_name = construct_edit_toolbar('');
			$view->messagearea = $messagearea;//
			$view->editor_name = $editor_name;

			// include captcha validation and guest username field
			if (fetch_require_hvcheck('post'))
			{
				require_once(DIR . '/includes/class_humanverify.php');
				$reg = vB::$vbulletin;
				$verification =& vB_HumanVerify::fetch_library($reg);
				$human_verify = $verification->output_token();
			}
			else
			{
				$human_verify = '';
			}
			$view->human_verify = $human_verify;
			$view->usernamecode = new vB_View('newpost_usernamecode');
		}
		else
		{
			$view->show_comment_editor = false;
		}

		return $view;
	}