<?Lassoscript
// Last modified 7/23/09 by ECL, Landmann InterActive

// FUNCTIONALITY
// Setup add functions

// CHANGE NOTES
// 11/23/07
// Recoded for CMS v. 3.0
// 11/29/07
// Moving login check to kill session before navbar is displayed
// 4/30/08
// Added LI_CMSatend at bottom of page to set focus to login box
// 5/20/08
// Recoded URL Links
// 1/15/09
// Added new datatype "Story"
// 6/19/09
// Adding new datatype "Gallery"
// 7/19/09
// Moved a few session var declarations to fix search problem
// 7/23/09
// Added Robot Check

Include:'/siteconfig.lasso';

// Robot check
Include:($svLibsPath)'robotcheck.inc';

// Start the Admin session
Session_Start: -Name=$svSessionAdminName, -Expires=$svSessionTimeout;

// Convert action_params
Var:'vDataType' = (Action_Param:'DataType');

// Page head
Include:($svLibsPath)'page_header_admin.inc';

// Determine which container to output
Var:'OutputOpenContainer' = string;
Var:'OutputCloseContainer' = string;
If: ($vDataType == 'Testimonial') || ($vDataType == 'PortfolioGroup') || ($vDataType == 'Story');
	$OutputOpenContainer = '\t\t\t<div class="contentcontainerwhite600">\n';
	$OutputCloseContainer = '\t\t\t</div>\n';
Else: ($vDataType == 'PortfolioEntry') || ($vDataType == 'Content');
	// Output nothing
/If;

// Debugging
// Var:'svDebug' = 'Y';
?>
<table width="780">
	<tr>
		<td width="170">
			[Include:($svLibsPath)'navbar_main.inc']
		</td>
		<td>
<?Lassoscript
// Output the opening container
$OutputOpenContainer;

// Login check
If: (Var:'svUser_ID') != '';

	If: !(Var_Defined:'SQLPortfolioEntries'); Session_AddVariable: -Name=$svSessionAdminName, 'SQLPortfolioEntries'; /If;
	If: !(Var_Defined:'SQLGalleryEntries'); Session_AddVariable: -Name=$svSessionAdminName, 'SQLGalleryEntries'; /If;

	If: $vDataType == 'Content';
		Include:'/admin/frm_content.inc';
		Include:($svLibsPath)'show_content.inc';
	Else: $vDataType == 'Testimonial';
		Include:'/admin/frm_testimonial.inc';
		Include:($svLibsPath)'show_testimonials.inc';
	Else: $vDataType == 'Story';
		Include:'/admin/frm_story.inc';
		Include:($svLibsPath)'show_stories.inc';
	Else: $vDataType == 'PortfolioGroup';
		Include:'/admin/frm_portfoliogroups.inc';
		Include:($svLibsPath)'show_portfoliogroups.inc';
	Else: $vDataType == 'PortfolioEntry';
		Include:'/admin/frm_portfolioentry.inc';
		Include:($svLibsPath)'show_portfolioentries.inc';
	Else: $vDataType == 'GalleryGroup';
		Include:'/admin/frm_gallerygroup.inc';
		Include:($svLibsPath)'show_gallerygroups.inc';
	Else: $vDataType == 'GalleryEntry';
		Include:'/admin/frm_galleryentry.inc';
		Include:($svLibsPath)'show_galleryentries.inc';
// Output the closing container
$OutputCloseContainer;
	Else: $vDataType == 'User';
		Include:'/admin/frm_user.inc';
		Include:($svLibsPath)'show_users.inc';

	// If wrong parameter passed, end the session, set error to 6004 "Access Restricted" redirect to login
	Else;

		Session_End: -Name=$svSessionAdminName;
		Var:'svUser_ID' = '';
		Var:'svUserLoginID' = '';
		Var:'svUserPrivs_Priv' = '';

		Var:'vError' = '6004';
		LI_URLRedirect: -Page='login.lasso',-UseError='Y',-Error=$vError;
	/If;

Else;

	// Set error to 6003 "Session Expired", redirect to login
	Var:'vError' = '6003';
	LI_URLRedirect: -Page='login.lasso',-UseError='Y',-Error=$vError;

/If;
?>
		</td>
	</tr>
</table>
[Include:($svIncludesPath)'build_footer.inc']
[OutputFooter]
</body>
[LI_CMSatend]
</html>
