Source for file OCSP_FRMCONTR.phpclass
Documentation is available at OCSP_FRMCONTR.phpclass
* Class file OCSP_FRMCONTR.phpclass
* @project Open CSP-Management
* @author Peter Krebs (pk) <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: OCSP_FRMCONTR.phpclass,v 1.33 2008/12/17 16:28:51 peterkrebs Exp $
require_once __OCSP_PHPINCPATH__.
"common".
_OCSP_DIRSEP_.
"pcf_templates.phpinc";
require_once __OCSP_PHPINCPATH__.
"common".
_OCSP_DIRSEP_.
"OCSP_OBJ.phpclass";
* @project Open CSP-Management
* @author Peter Krebs (pk) <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version pk-08-01-21 // extends OCSP_OBJ
* @version $Id: OCSP_FRMCONTR.phpclass,v 1.33 2008/12/17 16:28:51 peterkrebs Exp $
* @requires common/pcf_templates.phpinc
* @deprecated since pk-08-08-18 use OCSP_OBJ db ojbects
* @var double $rowPopulateTS
* url to submit the form on reload
* Note: $this->myForm->getSubmitAction($this->myForm->getFrmMode(),'RELOAD')
* @var string $myReloadUrl
* only used in checkRights() must not be used outside
* @var array $checkRights_userRights (array for each user)
* only used in checkRights() must not be used outside
* @var int $checkRights_hasDBRightsSet (we have group entries in T_DBMS_FORMRIGHTS);
* if the form has a table object this method is called to check if a user has the rights
* @var string $userCanShowMethod
* hash key to identify the form in jOCSP
* @var OCSP_FRMVIEW $myView
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* @param OCSP_FORM $aForm
// cast the forms controll
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* @param OCSP_FORM $aForm
* returns the current view
* @param OCSP_FRMVIEW $aView
* removes a filter value from the current filter
* returns all values of the object
$arr_ret['myForm'] =
&$this->myForm;
$arr_ret['myDBObj'] =
&$this->myDBObj;
$arr_ret['myView'] =
&$this->myView;
foreach($objVals as $str_name =>
$m_val)
$this->{$str_name}=
$m_val;
* @param string $aCmdName
* @param int $aType (_OCSP_FRMCMDTYPE_...)
* @param string $aBlockName
function setCommand($aCmdName,$aType,$cmdCode,$aBlockName=
'_FORM_')
if (empty($aBlockName)) $aBlockName=
'_FORM_';
* @param string $aAction URL to send the form to
* returns the action URL if set otherwise the default action for $this->myForm->getFrmMode()
{ // <pk-08-02-07 /> check if the form has a special action url
switch($this->myForm->getFrmMode())
return $OCSP_CONF['SYSTEMURL'].
"forms/insert.php?".
$_SERVER['QUERY_STRING'];
return $OCSP_CONF['SYSTEMURL'].
"forms/update.php?".
$_SERVER['QUERY_STRING'];
return $OCSP_CONF['SYSTEMURL'].
"forms/delete.php?".
$_SERVER['QUERY_STRING'];
* returns a reload url if set either in form or with setReloadUrl
* the reload url is set when a (select) field change requires
* to reload the form. in this case the form is sent to the url
* as ajax request which returns a java script
* settings stored in $this->myForm->getSubmitAction
* overwrites $this->myReloadUrl
$str_reloadUrl =
$this->myForm->getSubmitAction($this->myForm->getFrmMode(),'RELOAD');
if (!empty($str_reloadUrl))
* Note: $this->myForm->getSubmitAction overrules $this->myReloadUrl
* @param OCSP_AJAX $ajaxObj
$this->myForm->ajax_setObj(&$ajaxObj);
* @param boolean $force (the instantiation of a new object)
return $this->myForm->ajax_getObj(False);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* returns a hash to identify the form
* if not set a new one is generated
$str_idStr = $this->myForm->getId();
$str_idStr .= print_r($this->myFilter,True);
$str_idStr .= $this->myForm->getFrmMode();
$this->myjOCSPHash = md5($str_idStr);
$this->myForm->setMyJsId($aHash);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* returns the db object from the form
* populates one row from the database
* this is the first row fitting $this->myFilter
* @param array $filterAdd
* @todo for more than one table
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<h3>could not populate row from " .
$this->myForm->getMasterTable() .
"</h3>");
* sets the current row from outside
* sets a value in $this-curRow
* if (!$this->rowIsPopulated()) this->populateRow() is called
* before setting the value
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"populateing row first (FrmMode: " .
$this->myForm->getFrmMode() .
")");
$this->getDefaultValues(True,$debug);
$this->curRow[$colName]=
$value;
* returns the array of the current select DB values
* @deprecated since pk-08-01-14 (use getCurRow() instead)
* returns the array of the current select DB values
* returns a column value of the current row
if (isset
($this->curRow[$aColumn]))
return $this->curRow[$aColumn];
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* returns a template parsed with the current row
* @requires pcf_templates.phpinc
* @param DBMS_FIELD $aField
* @param string $aTemplate
* @requires common/pcf_templates.phpinc
$arr_fldVals=
$aField->getObjectVars();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* @requires $GLOBALS['OCSP']['PHPINCPATH']."common/pcf_md5.phpinc"
$this->getMyForm(); // ensure $this->myForm is set.
$this->myForm->setFrmMode($mode);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<hr><h2>\$data: </h2><pre>".
print_r($data,true).
"</pre>");
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<h3>NO FILTER SET</h3>");
$this->myForm->setError($this->myForm->getLangTxt('NO_FILTER_SET'));
$GLOBALS[$this->myForm->getDataArrName()]=
&$data;
// we have a read only form posted ignore value checks
if (!isset
($_POST['DELKEY']) ||
empty($_POST['DELKEY']))
$this->myForm->setError('NO DELKEY set');
$this->populateRow(NULL,$debug); // to ensure having db values set
$str_delKey =
$_POST['DELKEY'];
$this->myForm->setError("DELKEY do not match");
$arr_blocks=
$this->myForm->getBlocks($debug);
foreach($arr_blocks as $int_blockId =>
&$obj_block)
if ($obj_block->isToShow($this->myForm->getFrmMode(),$debug))
$this->myForm->setError('NO DATA');
* validates the block fields
* @param OCSP_FORM_BLOCK $aBlock
//echoDebugLine(__FILE__,__LINE__,"<pre style=\"font-size:80%\">" . print_r($this->curRow,True) . "</pre>");
$arr_flds=
$aBlock->getFields($this->myForm->getFrmMode(),False);
$str_debug=
"<table border=\"1\">";
foreach($arr_flds as &$obj_fld)
$str_debug.=
"<tr><td>".
$obj_fld->getKey().
"</td>";
unset
($arr_tmpData[$obj_fld->getName()]);
$str_debug.=
"<tr><td colspan=\"3\"><strong>NOT IN BLOCK</strong></td></tr>";
foreach($arr_tmpData as $str_col =>
$m_val)
$str_debug.=
"<tr><td>$str_col</td>";
if (isset
($this->curRow[$str_col]))
$str_debug.=
"<td><notset></td>";
foreach($arr_flds as &$obj_fld)
$arr_error=
array('ERROR'=>
False);
$m_val=
(isset
($data[$obj_fld->getName()]) ?
$data[$obj_fld->getName()] :
NULL);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"FOREIGNKEY: ".
$obj_fld->getKey());
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"AUTINC_KEY: ".
$obj_fld->getKey());
unset
($arr_error['ERROR']);
foreach($arr_error as $str_fld =>
$arr_msg)
$this->myForm->setError($arr_msg,$obj_fld->getKey());
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Error setting Field: ".
$obj_fld->getKey().
" to ".
$m_val.
"<pre>".
print_r($arr_error,True).
"</pre>");
echoDebugLine(__FILE__
,__LINE__
,$obj_fld->getKey().
" NOT set to ");
* save the row to the database
switch($this->myForm->getFrmMode())
$this->myForm->setError($this->myForm->getLangTxt('CAN_NOT_UPDATE_ROW').
":".
$this->myForm->getLangTxt('ROW_IS_NOT_POPULATED'));
$this->getDBObj(); // ensure $this->myDBObj is a valid DB Object
$arr_tables=
$this->myForm->getTables();
foreach($arr_tables as $str_tbl)
if (!$this->myDBObj->replaceArray($str_tbl,$this->curRow,$debug))
$this->myForm->setError("Error updating table ",$str_tbl);
$this->getDBObj(); // ensure $this->myDBObj is a valid DB Object
$arr_tables=
$this->myForm->getTables();
if ($str_masterTbl=
$this->myForm->getMasterTable())
$obj_masterAutoInc=
$this->myForm->getAutoIncField($str_masterTbl,$debug);
if ((sizeof($arr_tables) >
1) &&
!$obj_masterAutoInc)
ocsp_logError(__FILE__
,__LINE__
,"could not find autoinc key column for mastertable ($str_masterTbl)",E_ERROR);
if ($mix_masterKey=
$this->myDBObj->insertArray($str_masterTbl,$this->curRow,$debug))
$this->setCurRowValue($obj_masterAutoInc->getDBColName(False),$mix_masterKey);
foreach($arr_tables as $str_tbl)
if (($str_tbl !=
$str_masterTbl))
if ($mix_key=
$this->myDBObj->insertArray($str_tbl,$this->curRow,$debug))
if ($obj_autoInc=
$this->myForm->getAutoIncField($str_tbl,$debug))
$this->getDBObj(); // ensure $this->myDBObj is a valid DB Object
$this->myForm->setError('Löschen als Public ist nicht erlaubt');
$this->myForm->setError('Kein Filter gesetzt');
$arr_tables=
$this->myForm->getTables();
$this->myForm->setError('Löschen in mehreren Tabellen nicht erlaubt');
$this->myForm->setError('konnte Datensatz nicht löschen');
ocsp_logError(__FILE__
,__LINE__
,"mode: ".
$this->myForm->getFrmMode().
" not implemented",E_ERROR);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* checks the user rights form the database
* @param mixed $aUser (int) userId or (OCSP_USER) a user if 0 $GLOBALS['OCSP_OBJ']['USER'] is used
* @todo OCSP_FRMCONTR::checkRights => use cache
* @requires user/OCSP_USER.phpclass
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"returns True (no rows in T_DBMS_FORMRIGHTS *CACHED*)");
return true; // no entries in T_DBMS_FORMRIGHTS
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_ERROR);
require_once __OCSP_PHPINCPAHT__.
"user".
_OCSP_DIRSEP_.
"OCSP_USER.phpclass";
$str_query=
"SELECT COUNT(*) FROM T_DBMS_FORMRIGHTS WHERE FRM_ID=".
$this->myForm->getId();
$str_query=
"SELECT GRP_ID FROM T_DBMS_FORMRIGHTS WHERE FRM_ID=".
$this->myForm->getId();
switch($this->myForm->getFrmMode())
$str_query.=
" AND FRI_SHOW=1";
$str_query.=
" AND FRI_INSERT=1";
$str_query.=
" AND FRI_SHOW=1";
$str_query.=
" AND FRI_UDPDATE=1";
$str_query.=
" AND FRI_SHOW=1";
$str_query.=
" AND FRI_DELETE=1";
$str_query.=
" AND FRI_SHOW=1";
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"rights query: <br />".
$str_query.
"<pre>".
print_r($arr_groups,True).
"</pre>");
if ($arr_groups=
$this->myDBObj->queryArray($str_query,0))
foreach($arr_groups as $int_grpId)
// no special settings for the form in the database found
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"returns True (no rows in T_DBMS_FORMRIGHTS)");
* if the form has a tableobject class getRowValue calls this
* method to check if the current user is allowed to see the row
* NOTE: this leads to errors in counting as nofRows returns
* @param string $methodName
} // end of OCSP_FRMCONTR
Documentation generated on Thu, 08 Jan 2009 17:46:10 +0100 by phpDocumentor 1.4.0a2