<?php
/**
*
* @version $Id: waform.inc.php,v 1.1 2003/11/23 06:08:04 freedev Exp $
* @author Vincenzo D'Amore <hide@address.com>
* @package wa_includes
*/
/**
* Class used to hide the Form handling
* @package wa_includes
*/
class WAForm
{
/**
* Private Var used to handle a reference to the form.
*/
var $m_Form = 0;
/**
* Standard constructor
*/
function WAForm()
{
}
/**
* Release the reference
*/
function Clear()
{
$this->m_Form = 0;
}
/**
* Initialize the object
* @param long Form ID
* @param long Current Stack Id
* @param boolean Optional check for grants, default true
* @return boolean True if form is build
*/
function Init($IdForm, $iCurrentForm, $bGrantCheck = True)
{
$bRC = FALSE;
if (!empty($IdForm) &&
!empty($iCurrentForm) )
{
$this->InitByUID( BuildForm($IdForm, $iCurrentForm, $bGrantCheck) );
$bRC = $this->IsBuild();
}
return $bRC;
}
/**
* check if the object refer to existing form
* @return boolean True if form is build
*/
function IsBuild()
{
$bRC = FALSE;
if (!empty($this->m_Form))
$bRC = TRUE;
return $bRC;
}
/**
* Attach an existing form (array memory structure) to current object
* @param array Form
* @return boolean True if attached
*/
function Attach(&$Form)
{
$bRC = FALSE;
// inconsistent check, need to be more secure
if (is_array($Form))
{
$this->m_Form = &$Form;
$bRC = TRUE;
}
return $bRC;
}
/**
* Check in the session if exist a form with UID parameters and attach it to current object
* @param string Form UID
* @return boolean True if the form exist in current session
*/
function InitByUID($UID)
{
$bRC = FALSE;
// if exists in global session array the element assign it to current object
if ((isset($_SESSION["gaForms"])) &&
(is_array($_SESSION["gaForms"])) &&
(!empty($UID)) &&
(array_key_exists($UID, $_SESSION["gaForms"])) )
{
$this->m_Form = &$_SESSION["gaForms"][$UID];
$bRC = TRUE;
}
return $bRC;
}
/**
* Get a reference to Fields Array
* @return array return the reference to the fields array or false if unsuccessful
*/
function GetFields()
{
if ($this->IsBuild())
{
return $this->m_Form["WAFields"];
}
return false;
}
/**
* Get a reference to an array witch contains Tables Relations info
* @return array return the reference to the tables relations array or false if unsuccessful
*/
function GetTablesRel()
{
if ($this->IsBuild())
{
return $this->m_Form["WATablesRel"];
}
return false;
}
/**
* retrive the form UID
* @return string the form UID
*/
function GetUID()
{
return $this->m_Form["WAUID"];
}
/**
* retrive the form ID Number
* @return long the form ID Number
*/
function GetID()
{
return $this->m_Form["WAIdForm"];
}
/**
* retrive the form Description
* @return string the form UID
*/
function GetDescription()
{
return $this->m_Form["WADescr"];
}
}
?>