<?php

	include_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
	include_once( PLOG_CLASS_PATH."class/view/plugintemplatedview.class.php");
	include_once( PLOG_CLASS_PATH."class/net/client.class.php" );
	include_once( PLOG_CLASS_PATH."plugins/guestbook/class/dao/guestbookdata.class.php" );
	include_once( PLOG_CLASS_PATH."plugins/guestbook/class/dao/guestbookrecord.class.php" );

	class UpdateGuestbookAction extends BlogAction
	{
		var $_pluginEnabled;
		var $_data;
		var $_mode;

		var $_blogId;
		var $_id;
		var $_parentContent;

		function UpdateGuestbookAction($actionInfo, $request)
		{
			$this->BlogAction($actionInfo, $request);

			$this->_blogId = $this->_blogInfo->getId();

			$blogSettings = $this->_blogInfo->getSettings();

			$this->_pluginEnabled = $blogSettings->getValue("plugin_guestbook_enabled");

			if(!$this->_pluginEnabled)
				return;

			$this->_mode = $this->_request->getValue("mode");

			if($this->_mode=="reply")
			{
				$this->_id = $this->_request->getValue("id");

				$data = new GuestbookData();

				$post = $data->getPost($this->_blogId, $this->_id);

				$this->_parentContent = $post->getContent();
			}
		}

		function setCommonData()
		{
			$this->_view->setValue("blogId", $this->_blogId);
			$this->_view->setValue("id", $this->_id);
			$this->_view->setValue("mode", $this->_mode);
			$this->_view->setValue("parentContent", $this->_parentContent);

			return true;
		}

		function perform()
		{
			$this->_view = new PluginTemplatedView($this->_blogInfo, "guestbook", "updateguestbook", SMARTY_VIEW_CACHE_DISABLED);

			$this->setCommonData();
		}
	}
?>
