Location: PHPKode > projects > PushOk SEMA > html/web/project/project.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

//! add menu item to main menu
function web_ProjectCreateFLvlMenu(&$oIn, &$oOut)
{
	if ( !is_array($oOut) )
		$oOut = array();
	$oOut[5][_LW('Projects')] = "project/project_main.php";
	return true;
}

//! add second menu's items
function web_ProjectCreateSLvlMenu(&$oIn, &$oOut)
{
	if ( !is_array($oOut) )
		$oOut = array();
	if ( isset($oIn['menu_flvl']) && $oIn['menu_flvl'] == "Projects" )
	{
		$oOut[5][_LW('Search projects')] = "project/project_main.php";
		
		$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>0, 'type'=>ID_SEMA_PROJECT, 'mask'=>'W');
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut);
		if ( isset($_oOut['result']) && $_oOut['result'] )
			$oOut[5][_LW('Create new project')] = "project/project_form.php";
	}
	return true;
}

//! validate user's data and transmit it to kernel 
function web_ProjectCreate(&$oIn, &$oOut)
{
	global $nIdProject;
	
	if ( !is_array($oIn) )
		return PEAR::raiseError("FILE: \"".__FILE__."\" LINE: \"".__LINE__."\" MSG: \""._LW("Not enough params!")."\"", E_USER_ERROR);
		
	if ( $oIn['step'] == 1 )
	{
		if ( !isset($oIn['post']['title']) || !strlen($oIn['post']['title']) )
			web_AddErrorMsg($oOut, "You must specify 'Title'!");
			
		if ( !isset($oIn['post']['description']) || !strlen($oIn['post']['description']) )
			web_AddErrorMsg($oOut, "You must specify 'Description'!");
			
		if ( !isset($oIn['post']['time_type']) || !strlen($oIn['post']['time_type']) )
			web_AddErrorMsg($oOut, "You must specify 'Time type'!");
		return true;
	}
	elseif ( $oIn['step'] == 2 )
	{
		$oIn['post']['idcontact_current'] = $_SESSION['iduser'];
		if ( isset($oIn['post']['idproject']) && $oIn['post']['idproject']>0 )
			return $GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_PROJECT_MODIFY", $oIn['post'], $oOut);
		else
			return $GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_PROJECT_CREATE", $oIn['post'], $oOut);
	}
	return PEAR::raiseError("FILE: \"".__FILE__."\" LINE: \"".__LINE__."\" MSG: \""._LW("Bad params!")."\"", E_USER_ERROR);
}

//! add project menu 
function web_ProjectMenuCreate(&$oIn, &$oOut)
{
	if ( !is_array($oIn) || !isset($oIn['idobject']) || !isset($oIn['type']) )
		return false;

	if ( $oIn['type'] != ID_SEMA_PROJECT )
		return true;
		
	$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>$oIn['idobject'], 'type'=>ID_SEMA_PROJECT, 'mask'=>'R');
	$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut);
	if ( isset($_oOut['result']) && $_oOut['result'] )
		$oOut[1][_LW('Roles')] = "?page=/web/project/project_roles.php&idproject=".$oIn['idobject'];
		
	// check can user modify current project
	$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>$oIn['idobject'], 'type'=>ID_SEMA_PROJECT, 'mask'=>'W');
	$_oOut = array();
	$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut);
	if ( isset($_oOut['result']) && $_oOut['result'] )
		$oOut[10][_LW("Modify")] = "?page=/web/project/project_form.php&idproject=".$oIn['idobject'];
		
	return true;
}

function web_ProjectRoleCreate(&$oIn, &$oOut)
{
	if ( $oIn['step'] == 2 )
	{
		$oIn['post']['idcontact_current'] = $_SESSION['iduser'];
		// add contact addition info
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_PROJECT_ROLE_CREATE", $oIn['post'], $oTemp);
	}
	return true;
}

function web_ProjectActionMenuCreate(&$oIn, &$oOut)
{
	if ( !is_array($oIn) || !isset($oIn['idobject']) || !isset($oIn['type']) )
		return false;

	$level = 0;
	if (isset($oIn['level'])) $level =$oIn['level'];

	
	if ( $oIn['type'] != ID_SEMA_PROJECT )
		return true;
			
	// check can user modify current project
	$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>$oIn['idobject'], 'type'=>ID_SEMA_PROJECT, 'mask'=>'W');
	$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut=array());
	if ( isset($_oOut['result']) && $_oOut['result'] ) {
		$oOut[10][_LW("edit")] = array('href'=>"?page=/web/project/project_form.php&idproject=".$oIn['idobject']);
		if ($level==0) $oOut[10][_LW("del")] =  array('href'=>"?action=remove&idobject=".$oIn['idobject']."&type=".constant("ID_SEMA_PROJECT")."&redirect=page@@/web/project/project_main.php", 'onclick'=>'if (!confirm("'._LW("Are you sure?").'")) return false;');
	}
                        
	return true;
}

function web_ProjectDefaultViewShow(&$oIn, &$oOut)
{
	if ( !is_array($oIn) || !isset($oIn['layout']) )
		return false;
		
	global $arProjectStatus;
	$this = &$oIn['layout'];
	
	$_oIn = array('idcontact_current'=>$_SESSION['iduser']);
	$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_PROJECT_SEARCH_DEFVIEW", $_oIn, $arProjects);
	
	if ( isset($arProjects['projects']) && count($arProjects['projects']) )
	{
		$this->formSection(_LW("Active projects"));
		$this->formItem("" ,"subitem");
		$this->tableStart("default_sub");
		$arHeader = array( 
			array('value'=>_LW('ID'), 'colspan'=>0, 'align'=>'left'),
			array('value'=>_LW('Title'), 'colspan'=>0, 'align'=>'left'),
			array('value'=>_LW('Status'), 'colspan'=>0, 'align'=>'left'),
			array('value'=>_LW('Action'), 'colspan'=>0, 'align'=>'left')
							);
		$this->tableHeader($arHeader);

	    foreach ( $arProjects['projects'] as $nIdProject => $arProjectInfo )
	    {
			$this->tableRow();
			$this->tableCol($this->singleItem("string",$nIdProject));
			$this->tableCol($this->singleItem("link", $arProjectInfo['title'], array('href'=>"?page=/web/project/project_view.php&idproject=$nIdProject")));
			$this->tableCol($arProjectStatus[$arProjectInfo['status']]);

			// prepare actions for current task
			$this->tableCol("");
			$_oIn=array('idobject'=>$nIdProject, 'type'=>ID_SEMA_PROJECT, 'level'=>1);
			$GLOBALS['WEB_DISPATCHER']->ProcessMessage("WM_ACTION_MENU_CREATE", $_oIn, $_oOut=array());
			if ( count($_oOut) )
			{
				krsort($_oOut);
				foreach ($_oOut as $nPriority=>$arMenues) 
					foreach ($arMenues as $sName => $arData) 
						echo $this->singleItem("action",$sName,$arData);
			}
		}
	    $this->tableEnd();
	    $this->formSectionEnd();
	}
	
	return true;
}

?>
Return current item: PushOk SEMA