Location: PHPKode > projects > PushOk SEMA > html/web/project/project_roles.php
<?PHP
// Pushok's SEMA (Small Enterprise Management Application)
//
// Copyright (C) 2004 Pushok Software http://www.pushok.com
//
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// 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.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html

$nIdProject = 0;
if ( isset($_GET['idproject']) && $_GET['idproject']>0 )
	$nIdProject = $_GET['idproject'];
else 
	web_RedirectRelative("sema.php");

class web_Project extends web_Layout 
{
	function Info()
	{
		global $nIdProject, $arRoles;
		
		$oIn = array('idproject' => $nIdProject, 'idcontact' => $_SESSION['iduser']);
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_PROJECT_ROLE_SEARCH", $oIn, $arProjectRoles);
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_SHORTINFO", $oIn = array('idcontact_current'=>$_SESSION['iduser']), $arContacts);
		
		$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>$nIdProject, 'type'=>ID_SEMA_PROJECT, 'mask'=>'5');
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut);
		$bCanModify = false;
		if ( isset($_oOut['result']) && $_oOut['result'] )
			$bCanModify = true;
			
		$this->tableStart();
		$arHeader = array( 
			array('value'=>_LW('Contact'), 'colspan'=>0),
			array('value'=>_LW('Role'), 'colspan'=>0),
			array('value'=>_LW('Action'), 'colspan'=>0)
							);
		$this->tableHeader($arHeader);
		
		if ( count($arProjectRoles['roles']) )
		{
			foreach ( $arProjectRoles['roles'] as $nIdRole => $arRoleInfo )
			{
				$this->tableRow();
				$this->tableCol($this->singleItem("string",$arContacts['contacts'][$arRoleInfo['idcontact']]));
				$this->tableCol($this->singleItem("string",$arRoles[$arRoleInfo['role']]['name']));
				$_oIn=array('idcontact'=>$_SESSION['iduser'], 'idobject'=>$nIdProject, 'mask'=>'W5');
				$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut=array());
				if (isset($_oOut['result']) && $_oOut['result'])
					$this->tableCol($this->singleItem("action",_LW("Remove"),
                    	array ('href' => "?action=remove&idform=GT_PROJECT_ROLE&id=$nIdRole&idproject=$nIdProject", 'onclick'=>'if (!confirm("'._LW("Are you sure?").'")) return false;')));
                else 
                	$this->tableCol("");
			}
		}
		if ( $bCanModify )
		{
			$this->tableRow();
            echo "<FORM method=post>";
			echo "<INPUT type=\"hidden\" name=\"idform\" value=\"FM_PROJECT_ROLE_CREATE\"></INPUT>\n";
			echo "<INPUT type=\"hidden\" name=\"onsuccess\" value=\"?page=/web/project/project_roles.php&idproject=".$nIdProject."\"></INPUT>\n";
			echo "<INPUT type=\"hidden\" name=\"onerror\" value=\"\"></INPUT>\n"; 
			echo "<INPUT type=\"hidden\" name=\"idproject\" value=\"$nIdProject\"></INPUT>\n"; 

			// show contacts
            $this->tableCol($this->singleInputItem(false, "select", "idcontact", "", $arContacts['contacts']));
			// show roles
			$arRolesNames = array();
			foreach ( $arRoles as $key => $arData )
				$arRolesNames[$key] = $arData['name'];

            $this->tableCol($this->singleInputItem(false, "select", "role", "", $arRolesNames));				
            $this->tableCol($this->singleInputItem(_LW("Add"), "submit"));
            echo "</FORM>";
		}
		$this->tableEnd();
		?>
		<?PHP
	}
}

$oPage = new web_Project;
$oPage->m_windowHeader = _LW("Project roles");
$oPage->WebStack("project_roles.php", $oPage->m_windowHeader, $oPage->m_windowHeader, web_GetPageGetParams());
$_SESSION['active_page'] = web_GetPageGetParams();

if ( !isset($_SESSION['iduser']) )
	web_RedirectRelative("sema.php");

$oPage->m_menuFLvl = "Projects";
$oPage->RenderPage();

?>
Return current item: PushOk SEMA