<inp2:m_include t="incs/header"/>
<inp2:m_RenderElement name="combined_header" section="in-portal:user_list" grid="RegularUsers" title_preset="users_list" pagination="1" prefix="u.regular"/>

<!-- ToolBar -->
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
	<tr>
	  	<td>
	  		<script type="text/javascript">
	  			//do not rename - this function is used in default grid for double click!
	  			function edit()
	  			{
	  				set_hidden_field('remove_specials[u.regular]', 1);
	  				std_edit_item('u.regular', 'users/users_edit');
	  			}

	  			var a_toolbar = new ToolBar();
				a_toolbar.AddButton( new ToolBarButton('new_item', '<inp2:m_phrase label="la_ToolTip_NewUser" escape="1"/>::<inp2:m_phrase label="la_ToolTip_Add" escape="1"/>',
						function() {
							set_hidden_field('remove_specials[u.regular]', 1);
							std_precreate_item('u.regular', 'users/users_edit')
						} ) );

				a_toolbar.AddButton( new ToolBarButton('edit', '<inp2:m_phrase label="la_ToolTip_Edit" escape="1"/>::<inp2:m_phrase label="la_ShortToolTip_Edit" escape="1"/>', edit) );
				a_toolbar.AddButton( new ToolBarButton('delete', '<inp2:m_phrase label="la_ToolTip_Delete" escape="1"/>',
						function() {
							set_hidden_field('remove_specials[u.regular]', 1);
							std_delete_items('u.regular')
						} ) );

				/*a_toolbar.AddButton (
					new ToolBarButton(
						'setprimary',
						'<inp2:m_phrase label="la_ToolTip_PrimaryGroup" escape="1"/>::<inp2:m_phrase label="la_ShortToolTip_SetPrimary" escape="1"/>',
						function() {
							openSelector('u.regular', '<inp2:m_Link t="users/group_selector" pass="m,u" no_amp="1" js_escape="1"/>', 'PrimaryGroupId', '800x600', 'OnSaveSelected');
						}
					)
				);*/

				a_toolbar.AddButton( new ToolBarSeparator('sep1') );


				a_toolbar.AddButton( new ToolBarButton('approve', '<inp2:m_phrase label="la_ToolTip_Approve" escape="1"/>', function() {
							set_hidden_field('remove_specials[u.regular]', 1);
							submit_event('u.regular', 'OnMassApprove');
						}
				 ) );

				a_toolbar.AddButton( new ToolBarButton('decline', '<inp2:m_phrase label="la_ToolTip_Decline" escape="1"/>', function() {
							set_hidden_field('remove_specials[u.regular]', 1);
							submit_event('u.regular', 'OnMassDecline');
						}
				 ) );

				a_toolbar.AddButton( new ToolBarSeparator('sep2') );

				a_toolbar.AddButton( new ToolBarButton('frontend_mail', '<inp2:m_phrase label="la_ToolTip_LoginAs" escape="1"/>',
					function() {
						var $user_ids = Grids['u.regular'].GetSelected();

						if ($user_ids.length > 1) {
							alert('<inp2:m_Phrase label="la_error_YouMustSelectOnlyOneUser" js_escape="1"/>');
						}
						else {
							var $user_id = $user_ids.shift(),
								$url = '<inp2:m_Link template="index" index_file="../index.php" user_id="#USER_ID#" u_event="OnLoginAs" pass="m,u" no_amp="1" js_escape="1"/>';

							window.open($url.replace('#USER_ID#', $user_id), 'frontend_login');
						}
					}
				) );

				<inp2:m_if check="m_ModuleEnabled" module="In-Portal">
					a_toolbar.AddButton(
						new ToolBarButton(
							'e-mail',
							'<inp2:m_phrase label="la_ToolTip_SendMail" escape="1"/>',
							function() {
								Application.SetVar('remove_specials[u.regular]', 1);
								Application.SetVar('mailing_recipient_type', 'u');
								openSelector('mailing-list', '<inp2:m_Link template="mailing_lists/mailing_list_edit" no_amp="1" js_escape="1"/>', 'UserEmail', null, 'OnNew');
							}
						)
					);
				</inp2:m_if>

				a_toolbar.AddButton( new ToolBarButton('export', '<inp2:m_phrase label="la_ToolTip_Export" escape="1"/>', function() {
							set_hidden_field('remove_specials[u.regular]', 1);
							std_csv_export('u.regular', 'RegularUsers', 'export/export_progress');
						}
				) );

				a_toolbar.AddButton( new ToolBarSeparator('sep3') );

				a_toolbar.AddButton( new ToolBarButton('view', '<inp2:m_phrase label="la_ToolTip_View" escape="1"/>', function() {
							show_viewmenu(a_toolbar,'view');
						}
				) );

				a_toolbar.Render();
			</script>
		</td>

		<inp2:m_RenderElement name="search_main_toolbar" prefix="u.regular" grid="RegularUsers"/>
	</tr>
</tbody>
</table>

<inp2:m_RenderElement name="grid" PrefixSpecial="u.regular" IdField="PortalUserId" grid="RegularUsers"/>
<script type="text/javascript">
	Grids['u.regular'].SetDependantToolbarButtons( new Array('edit', 'delete', 'setprimary', 'frontend_mail', 'e-mail', 'approve', 'decline') );
</script>
<inp2:m_include t="incs/footer"/>