Location: PHPKode > projects > DIY Blog > diy-blog/classes/diy-blog/model/AdminCommentsResource.php
<?php

require_once 'diy-blog/model/BackEndResource.php';

require_once 'diy-blog/model/om/BaseBackEndResource.php';

/**
 * Backend Resource for displaying and managing Comments.
 * Originally generated by Propel.
 *
 * @package	diy-blog.model
 * @author	Martynas Jusevicius <hide@address.com>
 * @link	http://www.xml.lt
 */

class AdminCommentsResource extends BackEndResource
{

	/**
	 * Constructs a new AdminCommentsResource class, setting the Type column to BackEndResourcePeer::CLASSKEY_ADMINCOMMENTSRESOURCE.
	 */
	public function __construct()
	{

		$this->setType(BackEndResourcePeer::CLASSKEY_ADMINCOMMENTSRESOURCE);
	}

	public function doGet(Request $request, Response $response)
	{
		$view = null;
		$parent = parent::doGet($request, $response);

		if ($parent != null) $view = $parent;
		else $view = new CommentsView($this);

		return $view;
	}

	public function doPost(Request $request, Response $response)
	{
		$view = null;
		$parent = parent::doPost($request, $response);

		if ($parent != null) $view = $parent;
		else
		{
			$view = new CommentsView($this);

			if ($request->getParameter("action") == "delete")
			{
				$errors = array();
				$form = new CommentsForm($request);
				$errors = $form->validate();

				try
				{
					if (count($errors) != 0) throw new InvalidFormException();

					$this->deleteComments($form->getIDs());

					$request->setAttribute("comments-result", "success");
				}
				catch (InvalidFormException $e)
				{
					$request->setAttribute("comments-result", "failure");
				}

				$request->setAttribute("comments-form", $form);
				$request->setAttribute("comments-errors", $errors);
			}
		}

		return $view;
	}

	private function deleteComments($ids)
	{
		CommentPeer::doDelete($ids);
	}

} // AdminCommentsResource
Return current item: DIY Blog