<?php
/******************************************************************************/
//                                                                            //
//                             Smarty plugin                                  //
//                            @package Smarty                                 //
//							 @subpackage plugins                              //
//                        http://life-style.uz/                               //
//                   produced by Life Style, life-style.uz                    //
//                                                                            //
/******************************************************************************/

function smarty_function_fetch_block($params, &$smarty){

	$assign        = fetch_getParam('assign', $params, 'block');
	$fields        = fetch_getParam('fields', $params, 'blockId, sectionId, title, content, status, position');
	$status        = fetch_getParam('status', $params, 'V');
    $sectionId     = (int) fetch_getParam('sectionId', $params);
    $position      = (int) fetch_getParam('position', $params);

	/* conditions */
	if($sectionId > 0) connect()->where('sectionId', $sectionId);
	if($position > 0) connect()->where('position', $position);

	$block =  connect('blocks')->select($fields)->where('status',  $status)->get('array');
    $block = prepareBlock($block);
//	print_r($block);
	$smarty->assign($assign, $block);

	return null;
}
?>