<?php
/**
* @version	$Id: user_groups_config.php 14241 2011-03-16 20:24:35Z alex $
* @package	In-Portal
* @copyright	Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license      GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/

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

	$config =	Array(
					'Prefix'	=> 'ug',
					'Clones'	=> Array(
											'g-ug'	=>	Array(
																'ParentPrefix'		=>	'g',
																'ForeignKey'		=>	'GroupId',
																'ParentTableKey' 	=> 	'GroupId',

																'IDField'			=>	'PortalUserId',

																'ListSQLs'	=>	Array(
																	''	=>	'	SELECT %1$s.* %2$s FROM %1$s
																						LEFT JOIN '.TABLE_PREFIX.'PortalGroup g ON %1$s.GroupId = g.GroupId
																						LEFT JOIN '.TABLE_PREFIX.'PortalUser u ON %1$s.PortalUserId = u.PortalUserId'
															),
																'ItemSQLs'	=>	Array(
																	''	=>	'	SELECT %1$s.* %2$s FROM %1$s
																						LEFT JOIN '.TABLE_PREFIX.'PortalGroup g ON %1$s.GroupId = g.GroupId
																						LEFT JOIN '.TABLE_PREFIX.'PortalUser u ON %1$s.PortalUserId = u.PortalUserId'
																),
																'CalculatedFields'	=>	Array (
																	''	=>	Array(
																		'UserName' => 'CONCAT(u.LastName, \' \', u.FirstName)',
																		'UserLogin' => 'u.Login',
																	),
																),
																'VirtualFields'	=> Array (
																	'UserName' => Array('type' => 'string', 'default' => ''),
																	'UserLogin' => Array('type' => 'string', 'default' => ''),
																),
																'Grids'	=> Array(
																	'GroupUsers'	=>	Array(
																		'Icons' => Array ('default' => 'icon16_item.png'),
																		'Fields' => Array(
																			'PortalUserId'			=> Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 60, ),
																			'UserName'			=> Array ('title'=>'la_col_UserFirstLastName', 'width' => 200, ),
																			'UserLogin'			=> Array ('title'=>'la_col_Login', 'width' => 100, ),
																			'PrimaryGroup'	=> Array( 'title'=>'la_col_PrimaryGroup', 'filter_block' => 'grid_options_filter', 'width' => 100, ),
																			'MembershipExpires'	=>	Array ('title' => 'la_col_MembershipExpires', 'data_block' => 'grid_membership_td', 'filter_block' => 'grid_date_range_filter', 'width' => 150, ),
																		),
																	),
																),
															),

											'u-ug'	=>	Array(
																'ParentPrefix'		=>	'u',
																'ForeignKey'		=>	'PortalUserId',
																'ParentTableKey' 	=> 	'PortalUserId',
															),
									),

					'ItemClass'			=>	Array('class'=>'UserGroups_DBItem','file'=>'user_groups_dbitem.php','build_event'=>'OnItemBuild'),
					'ListClass'			=>	Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
					'EventHandlerClass'	=>	Array('class'=>'UserGroupsEventHandler','file'=>'user_groups_eh.php','build_event'=>'OnBuild'),
					'TagProcessorClass' =>	Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'),
					'AutoLoad'			=>	true,

					'QueryString' => Array (
						1 => 'id',
						2 => 'Page',
						3 => 'PerPage',
						4 => 'event',
					),

					'IDField'			=>	'GroupId',

					'TitleField' => 'GroupName',
					'TableName'			=>	TABLE_PREFIX.'UserGroup',

					'ListSQLs'			=>	Array(	''=>'	SELECT %1$s.* %2$s FROM %1$s
															LEFT JOIN '.TABLE_PREFIX.'PortalGroup g ON %1$s.GroupId = g.GroupId'),

					'ItemSQLs'			=>	Array(	''=>'	SELECT %1$s.* %2$s FROM %1$s
															LEFT JOIN '.TABLE_PREFIX.'PortalGroup g ON %1$s.GroupId = g.GroupId'),

					'AutoDelete'		=>	true,
					'AutoClone'			=> 	false,

					'CalculatedFields'	=>	Array (
						''	=>	Array(
							'GroupName' => 'g.Name',
							'GroupDescription' => 'g.Description',
						),
					),

					'Fields'			=>	Array(
						'PortalUserId'				=>	Array('type' => 'int', 'not_null' => 1, 'default' => 0),
						'GroupId'					=>	Array('type' => 'int', 'not_null' => 1, 'default' => 0),
						'MembershipExpires' 		=> Array('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => null),
						'PrimaryGroup'				=>	Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 1),
						'ExpirationReminderSent'	=>	Array('type' => 'int', 'not_null' => 1, 'default' => 0),
									        ),

					'VirtualFields'	=> Array (
						'GroupName' => Array('type' => 'string', 'default' => ''),
						'GroupDescription' => Array('type' => 'string', 'default' => ''),
					),


					'Grids'	=> Array(
						'Default'	=>	Array(
							'Icons' => Array (
								'default' => 'icon16_item.png',
								1 => 'icon16_primary.png'
							),
							'Fields' => Array(
								'GroupId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 60, ),
								'GroupName' => Array ('title'=>'la_col_GroupName', 'width' => 100, ),
								'GroupDescription' => Array ('title'=>'la_col_Description', 'width' => 150, ),
								'PrimaryGroup'	=> Array( 'title'=>'la_col_PrimaryGroup', 'filter_block' => 'grid_options_filter', 'width' => 150, ),
								'MembershipExpires'	=>	Array ('title' => 'la_col_MembershipExpires', 'data_block' => 'grid_membership_td', 'filter_block' => 'grid_date_range_filter', 'width' => 150, ),
							),
						),
					),

	);