Location: PHPKode > projects > PushOk SEMA > html/web/note/note.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_NoteCreateFLvlMenu(&$oIn, &$oOut)
{
	if ( !is_array($oOut) )
		$oOut = array();
	$oOut[5][_LW('Notes')]= "note/note_main.php";
	return true;
}

//! add second menu's items
function web_NoteCreateSLvlMenu(&$oIn, &$oOut)
{
	if ( !is_array($oOut) )
		$oOut = array();
	if ( isset($oIn['menu_flvl']) && $oIn['menu_flvl'] == "Notes" )
	{
		$oOut[5][_LW('Search notes')] = "note/note_main.php";
		
		$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>0, 'type'=>ID_SEMA_NOTE, 'mask'=>'W');
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut);
		if ( isset($_oOut['result']) && $_oOut['result'] )
			$oOut[5][_LW('Create new note')] = "note/note_form.php";
	}
	return true;
}

//! validate user's data and transmit it to kernel 
function web_NoteCreate(&$oIn, &$oOut)
{
	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']['body']) || !strlen($oIn['post']['body']) )
			web_AddErrorMsg($oOut, "You must specify 'Body'!");
		return true;
	}
	elseif ( $oIn['step'] == 2 )
	{
		$oIn['post']['idcontact_current'] = $_SESSION['iduser'];
		
		if ( isset($oIn['post']['idnote']) && $oIn['post']['idnote']>0 )
			return $GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_NOTE_MODIFY", $oIn['post'], $oOut);
		else
			return $GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_NOTE_CREATE", $oIn['post'], $oOut);
	}
	return PEAR::raiseError("FILE: \"".__FILE__."\" LINE: \"".__LINE__."\" MSG: \""._LW("Bad params!")."\"", E_USER_ERROR);
}

function web_NoteViewShow(&$oIn, &$oOut)
{
	$_oIn = array('idcontact_current'=>$_SESSION['iduser'], 'idparent'=>$oIn['idparent']);
	$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_NOTE_SEARCH", $_oIn, $arNotes);
	$this = $oIn['layout'];
	
	if (count($arNotes['notes'])) {
        $this->formSection(_LW("Notes"));
        $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'),
							);
		$this->tableHeader($arHeader);
		
		if (count($arNotes['notes']))
	        foreach ( $arNotes['notes'] as $nIdNote => $arNoteInfo )
	        {
				$this->tableRow();
				$this->tableCol($this->singleItem("string",$nIdNote));
				$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>$nIdNote, 'type'=>ID_SEMA_NOTE, 'mask'=>'W');
				$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut);
				if ( isset($_oOut['result']) && $_oOut['result'] )
					$this->tableCol($this->singleItem("link",$arNoteInfo['title'], array("href" => "?page=/web/note/note_form.php&idnote=".$nIdNote)));
				else
					$this->tableCol($arNoteInfo['title']);
			}
        $this->tableEnd();
	}
}

function web_NoteMenuCreate(&$oIn, &$oOut)
{
	if ( !is_array($oIn) || !isset($oIn['idobject']) || !isset($oIn['type']) )
		return false;
	
	if ($oIn['type'] != ID_SEMA_NOTE) {	
		$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>$oIn['idobject'], 'type'=>$oIn['type'], 'mask'=>'R');
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut);
		if ( isset($_oOut['result']) && $_oOut['result'] )
			$oOut[5][_LW('View notes')] = "?page=/web/note/note_main.php&idparent=".$oIn['idobject'];
	
		$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>$oIn['idobject'], 'type'=>ID_SEMA_NOTE, 'mask'=>'W');
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut);
		if ( isset($_oOut['result']) && $_oOut['result'] )
			$oOut[10][_LW('Create note')] = "?page=/web/note/note_form.php&idparent=".$oIn['idobject'];
	}
	elseif ($oIn['type'] == ID_SEMA_NOTE) {
		$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>$oIn['idobject'], 'type'=>ID_SEMA_NOTE, 'mask'=>'W');
		$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut);
		if ( isset($_oOut['result']) && $_oOut['result'] )
			$oOut[10][_LW("Modify")] = "?page=/web/note/note_form.php&idnote=".$oIn['idobject'];
	}

	return true;
}

function web_NoteActionMenuCreate(&$oIn, &$oOut)
{
	if ( !is_array($oIn) || !isset($oIn['idobject']) || !isset($oIn['type']) )
		return false;
	
	if ( $oIn['type'] != ID_SEMA_NOTE )
		return true;
			
	$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>$oIn['idobject'], 'type'=>ID_SEMA_NOTE, 'mask'=>'W');
	$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut);
	if ( isset($_oOut['result']) && $_oOut['result'] ) {
		$oOut[10][_LW("edit")] = array('href'=>"?page=/web/note/note_form.php&idnote=".$oIn['idobject']);
		$oOut[10][_LW("del")] =  array('href'=>"?action=remove&idobject=".$oIn['idobject']."&type=".constant("ID_SEMA_NOTE")."&redirect=page@@/web/note/note_main.php", 'onclick'=>'if (!confirm("'._LW("Are you sure?").'")) return false;');
	}
	return true;
}

function web_NoteDefaultViewShow(&$oIn, &$oOut)
{
	return true;
	if ( !is_array($oIn) || !isset($oIn['layout']) )
		return false;
		
	$this = &$oIn['layout'];
	
	$_oIn = array('idcontact_current'=>$_SESSION['iduser'], 'idcreator'=>$_SESSION['iduser'], 'idparent'=>0);
	$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_NOTE_SEARCH", $_oIn, $arNotes);
	
	if (count($arNotes['notes'])) 
	{
		$this->formSection(_LW("Notes"));
		$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('Action'), 'colspan'=>0, 'align'=>'left')
							);
		$this->tableHeader($arHeader);

		foreach ( $arNotes['notes'] as $nIdNote => $arNoteInfo )
	    {
			$this->tableRow();
			$this->tableCol($this->singleItem("string",$nIdNote));
			$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>$nIdNote, 'type'=>ID_SEMA_NOTE, 'mask'=>'W');
			$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut);
			if ( isset($_oOut['result']) && $_oOut['result'] ) {
				$this->tableCol($this->singleItem("link",$arNoteInfo['title'], array("href" => "?page=/web/note/note_view.php&idnote=".$nIdNote)));
				$this->tableCol($this->singleItem("link",_LW("Modify"), array("href" => "?page=/web/note/note_form.php&idnote=".$nIdNote)));
			}
			else
				$this->tableCol($arNoteInfo['title']);
		}
		$this->tableEnd();
		$this->formSectionEnd();
	}
	
	return true;
}

function web_NoteGlobalMenuCreate(&$oIn, &$oOut)
{
	$_oIn = array('idcontact'=>$_SESSION['iduser'], 'idobject'=>0, 'type'=>ID_SEMA_NOTE, 'mask'=>'W');
	$GLOBALS['LIB_DISPATCHER']->ProcessMessage("LM_CONTACT_HAS_MASK", $_oIn, $_oOut);
	if ( isset($_oOut['result']) && $_oOut['result'] )
		$oOut[5][_LW('Create my note')] = "note/note_form.php";
}
?>
Return current item: PushOk SEMA