Source for file DBMS_FIELD_STATUS_CONFARR_SELECT.phpclass
Documentation is available at DBMS_FIELD_STATUS_CONFARR_SELECT.phpclass
* Class file DBMS_FIELD_STATUS_CONFARR_SELECT.phpclass
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* Class DBMS_FIELD_STATUS_CONFARR_SELECT
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @todo only checked when form is shown no check is done for
* this::slashedValue() and this::getValue() needs a major
* change in the dbms function calls
* source file of the class
* @var string $classSrcFile
// ###########################################################
// OBJECT (CONST) VAR DECLARATION
// ###########################################################
* @var string $grpKey index to look for the group
* @var string $iconKey index to look for the icon
* @var string $requireValueKey index to look for the required value
// ###########################################################
// FIELD DEFINITION DATA METHODS
// ###########################################################
* returns an array of field to bie shown in the edit form
* by using editTbl_echoForm
* the array is in the form:
* [FLDLAB] (complete html code with <td></td>)
* [FLDVAL] (complete html code with <td></td>)
unset
($a_ret['SELECT']['FLD_LSTVALS']); // unset parent field as it is of no use here
$a_ret['STATUSARR']=
array(
'TITLE'=>
"Status Einstellungen/Berechtigungen",
'FLDVAL'=>
"<input name=\"grpKey\" value=\"".
$this->grpKey.
"\" size=\"40\">"
'FLDLAB'=>
"REQUIRE VALUE INDEX",
'FLDVAL'=>
"<input name=\"requireValueKey\" value=\"".
$this->requireValueKey.
"\" size=\"40\">"
'FLD_REQUIREDKEY'=>
array(
'FLDVAL'=>
"<input name=\"iconKey\" value=\"".
$this->iconKey.
"\" size=\"40\">"
$this->grpKey =
$_POST['grpKey'];
###################################
* returns if we have to check the array for group and required value
if ($debug) echo
"<p><b>DBMS_FIELD_STATUS_CONFARR_SELECT::globalArrIsToCheck($mode)</b> (".
get_class($this).
")</p>\n";
return TRUE; // input fields -> we need to check
return FALSE; // no need to check for readonly modes
if ($debug) echo
"<p>UNKNOWN MODE: $mode</p>";
* returns if the user is member of the grpKey groups
* @param array $globalValArr the subarray in the global array
if ($debug) echo
"<p><b>DBMS_FIELD_STATUS_CONFARR_SELECT::check_globalArrGroup(...)</b> (".
get_class($this).
")</p>";
if (empty($this->grpKey)) return TRUE; // group net set -> no check
if (!isset
($globalValArr[$this->grpKey])) {
// we do not have a group key in the array => return TRUE
// we have an array of groups which are allowed
foreach($globalValArr[$this->grpKey] as $i_GrpId) {
if ($GLOBALS['USER']->isGroupMember($i_GrpId)) return TRUE; // user is member
// still here -> no group found
// we have a single value
// use intval to have public (0) if no group is set
return $GLOBALS['USER']->isGroupMember(intval($globalValArr[$this->grpKey]));
* returns if the global array $arrName as the required value
* @param array $globalValArr
if ($debug) echo
"<p><b>DBMS_FIELD_STATUS_CONFARR_SELECT::check_globalArrReqValue(...)</b> (".
get_class($this).
")</p>";
if (empty($this->requireValueKey)) return TRUE; // no requireValueKey set -> no check
// we do not have a require value key in the array => return TRUE
if ($debug) echo
"<p>Global Array (\$".
$arrName.
"):</p><pre>".
print_r($
{$arrName}[$this->myName]).
"</pre>";
if ($chkVal==$
{$arrName}[$this->myName]) return TRUE; // value found
// still here -> value not found
* returns an array of allowed values
* if mode is FRM_MODE_EDIT, FRM_MODE_NEW or FRM_MODE_HIDDEN
* for eache array ellement is checkt if
* the curent user ($GLOBALS['USER'])
* is member of the group (ID specified by
* @example config include file
* $GLOBALS['CMS']['PAGESTATE'][0]=array(
* Setting to a variable (note the value when the conf file is included is checked
* $GLOBALS['CMS']['PAGESTATE'][1]=array(
* 'GROUP'=>$GLOBALS['GROUPS']['CMSAUTHOR']);
* you can also reference to a global var
* $GLOBALS['CMS']['PAGESTATE'][1]=array(
* 'GROUP'=><b>&</b>$GLOBALS['GROUPS']['AKT_PROJADMIN']
* or simply set to an array
* $GLOBALS['CMS']['PAGESTATE'][1]=array(
* @var array $a_globalArr
* @var array $a_globalValArr
* @var boolean $b_SetValue
function setMyValues($arrName=
"DBVAL",$debug=
FALSE,$mode=
FRM_MODE_EDIT) {
global $
{$arrName}; // <pk-05-08-03 />
$this->allowNull =
False; // to have the first state selected if no value is submitted
switch(True) // <pk-08-12-18>
foreach($arr_states as &$obj_state)
if ($obj_state->curUserIsInGroup(intval($
{$arrName}['PROJ_ID'])))
$this->myValues[$obj_state->getId()] =
$obj_state->getName();
$this->myValues=
array(); // <pk-06-10-04 />
foreach($a_globalArr as $key =>
$a_globalValArr) {
if ($debug) echo
"<p>Checking: ".
$a_globalValArr[$this->subKey].
" ($key)</p><blockquote>";
if (isset
($
{$arrName}[$this->myName]) &&
($
{$arrName}[$this->myName] ==
$key)) { // <pk-05-08-03 />
// no need to check as we already have this state
if ($debug) echo
"<p>Setting Value: ".
$a_globalValArr[$this->subKey].
" ($key)</p>";
if ($debug) {echo
"<blockquote>ICON SET<pre>$key ".
$this->iconKey.
"\n";print_r($a_globalValArr);echo
"</pre><p>".
$a_globalValArr[$this->iconKey].
"</blockquote>";}
$this->myValues[$key]=
"<img src=\"".
$a_globalValArr[$this->iconKey].
"\" border=\"0\" align=\"middle\" alt=\"".
$a_globalValArr[$this->subKey].
"\">";
if (!empty($a_globalValArr[$this->subKey])) {
if ($debug) echo
"</blockquote>";
if ($debug) echo
"<blockquote>myValues:<pre>".
print_r($this->myValues,TRUE).
"</pre><hr /></blockquote>";
if ($debug) echo
"<p>subKey NOT SET </p>";
* returns a string with the options
* calls setMyValues to be sure $this->myValues is set correkt
* @param array $aValArr array of selected values
* @param bool $addNULL add the null option (for search)
echo
"<p><b>DBMS_FIELD_STATUS_CONFARR_SELECT::getOptionList(\$aValArr,$addNULL,...)</b> (".
get_class($this).
"/".
$this->myName.
")</p>";
echo
"<blockquote><p>\$aValArr</p><pre>".
print_r($aValArr,TRUE).
"</pre></blockquote>";
$ret.=
"\t<option value=\"\">".
$this->nullLabel.
"</option>\n";
$ret.=
"\t<option value=\"$key\"";
if ((!empty($key)) &&
in_array($key,$aValArr)) {
$ret.=
">$val</option>\n";
foreach($aValArr as $s_value) {
if (!empty($s_value)) $ret.=
"<option value=\"$s_value\" selected>$s_value</option>\n";
* returns the html code for the readonly field
* @version pk-05-08-02 bugifx
if ($debug) echo
"<hr /><p><b>DBMS_FIELD_STATUS_CONFARR_SELECT::getScreenValue($aValue,$arrName,...)</b></p>";
return parent::getScreenValue($aValue,$arrName,$debug); // <pk-05-08-02 />
* returns a html select with all values (distinct) where $aValue
* NOTE only works on database fields
* @param string $selTagAdd added into <select ...>
* @param string $whereCond added to query ($s_query="SELECT ... FROM TABLE ".$whereCond)
* @todo object value tables
function getTableValSelect(&$aValue,$arrName=
"",$selTagAdd=
"",$whereCond=
"",$nullLabel=
"",$debug=
FALSE) {
if ($debug) echo
"<p><b>DBMS_FIELD::getTableValSelect(aValue=".
$aValue.
",arrName=".
$arrName.
")</b> (".
get_class($this).
")</p>\n";
$s_selName=
$arrName.
"[".
$this->myName.
"]";
$ret=
"\n<select name=\"".
$s_selName.
"\" ".
$selTagAdd.
">\n";
if (!empty($nullLabel)) {
$ret.=
"\t<option value=\"\">".
$nullLabel.
"</option>\n";
$ret.=
"\t<option value=\"\">--- ??? ---</option>\n";
foreach($a_globalArr as $key =>
$a_globalValArr) {
$s_query =
"SELECT COUNT(*) FROM ".
$this->myTable;
if (!empty($whereCond)) {
$s_query.=
" AND ".
$this->myName.
"=".
$GLOBALS['USRDB']->qs_getSlashedValue($key);
$s_query.=
" WHERE ".
$this->myName.
"=".
$GLOBALS['USRDB']->qs_getSlashedValue($key);
if ($debug) echo
"<p>".
$s_query.
"</p>";
if ($i_nofEntries=
intval($GLOBALS['USRDB']->quickQuery($s_query,0))) {
$ret.=
"\t<option value=\"".
$key.
"\"";
// no null Label -> we have to set the $aValue called by ref
if ($debug) echo
" <b>SELECTED</b>";
if (!empty($a_globalValArr[$this->subKey])) {
$ret.=
">".
$a_globalValArr[$this->subKey].
"</option>";
$ret.=
">".
$key.
"</option>";
} // end class DBMS_FIELD_GLOBALARRSELECTLIST
Documentation generated on Thu, 08 Jan 2009 17:42:57 +0100 by phpDocumentor 1.4.0a2