<?php
/**
* @version	$Id: payment_type_tag_processor.php 15156 2012-03-04 09:27:14Z alex $
* @package	In-Commerce
* @copyright	Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license	Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/

	defined('FULL_PATH') or die('restricted access!');

	class PaymentTypeTagProcessor extends kDBTagProcessor {

		function DeleteError($params){
			$o = '';
			$error = $this->Application->RecallVar('pt_delete_error');
			if ($error){
				$params['name']=$params['block'];
				$o = $this->Application->ParseBlock($params);
				$this->Application->RemoveVar('pt_delete_error');
			}
			return $o;
		}

		function ListGroups($params)
		{

			$object = $this->getObject($params);
			$selected = trim($object->GetDBField('PortalGroups'), ',');
			$selected_arr = explode(',', $selected);
			$all_groups = $this->Conn->Query('SELECT GroupId, Name FROM '.TABLE_PREFIX.'UserGroups ORDER BY NAME', 'GroupId');


			$o = '';
			$mode = array_key_exists('mode', $params) ? $params['mode'] : false;

			foreach ($all_groups as $a_group) {
				$is_selected = in_array($a_group['GroupId'], $selected_arr);
				$continue = $mode == 'selected' ? !$is_selected : $is_selected;
				if ($continue) continue;
				$block_params = $a_group;
				$block_params['name']	= $params['render_as'];
				$o .= $this->Application->ParseBlock($block_params);
			}

			return $o;
		}

	}