Location: PHPKode > projects > TEMS -Time and Expense Management System > tems/auth/manageauthorization.php
<?php

/*********************************************************************************
 * TES is a Time and Expense Management program developed by
 * Initechs, LLC. Copyright (C) 2009 - 2010 Initechs LLC.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY INITECHS, INITECHS DISCLAIMS THE WARRANTY
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA.
 *
 * You can contact Initechs headquarters at 1841 Piedmont Road, Suite 301,
 * Marietta, GA, USA. or at email address hide@address.com
 *
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU General Public License version 3,
 * these Appropriate Legal Notices must retain the display od the "Initechs" logo.
 * If the display of the logo is not reasonably feasible for technical reasons,
 * the Appropriate Legal Notices must display the words "Powered by Initechs".

 ********************************************************************************/

$basedir = dirname(__FILE__) . '/..';

require_once("$basedir/baseclass/DBCommonFunctions.php");
require_once("$basedir/baseclass/PageBase.php");


class ActionPage extends PageBase
{
	protected function makeAddlFormData($ControlDS, $heading='')
	{
		if (isset($_SESSION['postdata']['authorizations_id'])
		and ($_SESSION['postdata']['authorizations_id'] <> ''))
			$this->loadauthDetailData($_SESSION['postdata']['authorizations_id']);
		$str = '';
		$str .= $this->makeauthMatrix($ControlDS);

		return $str;
	}


	protected function makeauthMatrix($ControlDS)
	{
		$Module = array('invoices', 'accounts',	'projects',	'tasks', 'roles', 'users', 'projecttasks', 'projectroles', 'userprojectsroles', 'times', 'expenseheaders', 'expensedetails', 'expensecategories',);
		$Action = array('Create', 'Edit', 'Delete', 'List', 'Browse', 'Print', 'Submit', 'Approve', 'Hold', 'ChangePassword');

		$ModActionMatrix = array(
			'invoices' => array('Create', 'Browse', 'Delete', 'List', 'Print'),
			'accounts' => array('Create', 'Edit', 'Browse', 'Delete', 'List', 'Print'), 
			'projects' => array('Create', 'Edit', 'Browse', 'Delete', 'List', 'Print'), 
			'tasks' => array('Create', 'Edit', 'Browse', 'Delete', 'List'), 
			'roles' => array('Create', 'Edit', 'Browse', 'Delete', 'List'), 
			'users' => array('Create', 'Edit', 'Browse', 'Delete', 'List', 'ChangePassword'), 
			'projecttasks' => array('Create', 'Edit', 'Browse', 'Delete', 'List'),
			'projectroles' => array('Create', 'Edit', 'Browse', 'Delete', 'List'),
			'userprojectsroles' => array('Create', 'Edit', 'Browse', 'Delete', 'List'),
			'expensecategories' => array('Create', 'Edit', 'Browse', 'Delete', 'List'),
			'times' => array('Create', 'Edit', 'Browse', 'Delete', 'List', 'Print', 'Submit', 'Approve', 'Hold'),
			'expenseheaders' => array('Create', 'Edit', 'Browse', 'Delete', 'List', 'Print', 'Submit', 'Approve', 'Hold'),
			'expensedetails' =>  array('Create', 'Edit', 'Browse', 'Delete', 'List'),
		);

		$Level_array = array(
			'0' => 'None',
			'1' => 'Own',
			'2' => 'Group',
			'3' => 'All'
			);

			$str = '';

			$str .= "\n<table id = 'list'>";
			$str .= "\n<tr>";
			$str .= "\n\t<th>Modules</th>";						// Make the column heading row
			foreach($Action as $actionName)
			{
				$actionNameDisplay = changeLiteral($actionName);
				$str .= "\n\t<th>$actionNameDisplay</th>";
			}

			$str .= "\n</tr>";

			$rowStyle = "";
			foreach($Module as $moduleName)
			{
				$rowStyle == "alt" ? $rowStyle = "" : $rowStyle = "alt";
				if ($rowStyle == "alt")
					$str .= "\n<tr class=$rowStyle>";
				else
					$str .= "\n<tr>";
					
				// Make each Module row
				$moduleNameDisplay = changeLiteral($moduleName);
				$str .= "\n\t<td>$moduleNameDisplay</td>";
				foreach($Action as $actionName)
				{
					if (array_search($actionName, $ModActionMatrix[$moduleName]) === false)
						$str .= "\n\t<td>N/A</td>";
					else
					{
						$fieldName = $moduleName.'_'.$actionName;
						if (!isset($_SESSION['postdata'][$fieldName]))
							$_SESSION['postdata'][$fieldName] = '0';

						$fieldValue = $_SESSION['postdata'][$fieldName];
						$size = 5;
						$fieldLen = 5;
						$fieldAction = '';
						$addlStr = $Level_array;
						$addlAttrb = ($ControlDS->handler == 'BrowsePage' or $ControlDS->handler == 'DeletePage') ? 'disabled' : 'editable';
						$str .= "\n\t<td>".$this->optionField($fieldName, $fieldValue, $size, $fieldLen, $fieldAction, $addlAttrb, $addlStr)."</td>";
					}
				}
				$str .= "\n</tr>";
			}

			$str .= "\n</table>";
			return $str;
	}

	protected function loadauthDetailData($authid)
	{
		$where = "authorizations_id = '$authid' ";

		$DbObj = new dbObj();
		if( ($RowData = $DbObj->listRows('authorizations', $where)) === null)
			return;

		foreach ($RowData as $Record)
		{
			$field = $Record['module'].'_'.$Record['action'];
			$_SESSION['postdata'][$field] = $Record['authlevel'];
		}
	}


}

?>
Return current item: TEMS -Time and Expense Management System