<?php

	/*
	*	Gekko - Open Source Web Development Framework
	*	------------------------------------------------------------------------
	*	Copyright (C) 2004-2006, J. Carlos Nieto <xiam@users.sourceforge.net>
	*	This program is Free Software.
	*
	*	@package	Gekko
	*	@license	http://www.gnu.org/copyleft/gpl.html GNU/GPL License 2.0
	*	@author		J. Carlos Nieto <xiam@users.sourceforge.net>
	*	@link		http://www.gekkoware.org
	*/

	if (!defined("IN-GEKKO")) die("Get a life!");

	LoadLib ("blocks");

	Class Plugin_modBlocks {
		function Plugin_modBlocks() {
			$PluginCore =& $GLOBALS["PluginCore"];
			$PluginCore->Register("plugin_modblocks", "gbbcodeparser_parse");
		 }
		 function Invoke ($event, $buff) {
		 	if (gekkoModule::isInstalled("blocks")) {
				switch ($event) {
					case "gbbcodeparser_parse":
						if (gauth("blocks", $buff["groups"])) {
							$buff["content"] = preg_replace_callback("/\[block\](\d*)\[\/block\]/s",
								create_function('$a', 'return blocks::load($a[1]);'),
								$buff["content"]
							);
						}
					break;
				}
			}
			return $buff;
		}
	}
?>