Source for file CLI_PROFILE.phpclass
Documentation is available at CLI_PROFILE.phpclass
* Class file CLI_PROFILE.phpclass
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
// ---------------------------------------------------------
// ---------------------------------------------------------
if (!defined('_CLIENT_CONFIGURED_')) require_once __OCSP_DEFAULTCONFPATH__.
"client.conf.phpinc";
if (!defined('_CMS_CONFIGURED_')) require_once __OCSP_DEFAULTCONFPATH__.
"cms.conf.phpinc";
* class to handel CLI_PROFILES
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @todo errorhandling like DBMS_FORM
/*** class constants --------------------------------------------- */
* @constant string CLASS_SRC_FILE
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** class vars ------------------------------------------------------ */
* @staticvar array $loadedProfiles
protected static $loadedProfiles =
array();
/*** class methods --------------------------------------------------- */
* returns the unit of work instance
if (!isset
(self::$loadedProfiles[intval($aId)]) ||
!pcf_is_instance_of(self::$loadedProfiles[intval($aId)],'CLI_PROFILE'))
self::$loadedProfiles[intval($aId)] =
self::factory_fromId(intval($aId));
return self::$loadedProfiles[intval($aId)];
* returns if we already have an instance of profile $aId
if (!isset
(self::$loadedProfiles[intval($aId)]))
* @param CLI_PROFILE $aProfile
self::$loadedProfiles[$aProfile->getId()] =
$aProfile;
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* @staticvar string $myTable name of the db table
* @staticvar string $colPrefix prefix of the table col names
* @staticvar string $myClassName name of the class to use in eval statements
* @var int $FKValue user/client/staff id
* @var string $classSrcFile source file of the class
// ------------------------------------------------------
// ------------------------------------------------------
* creates and initialize the object
* if $aId the object is populate and
* all other params are replaced
* with the database values
* @param int $aId if > 0 the object is populated
* @returns bool is it populated ?
function CLI_PROFILE($projId=
0,$aId=
0,$grpId=
0,$debug=
False) {
if ($debug) echo
"<hr /><p><b>CLI_PROFILE::CLI_PROFILE($projId,$aId,$grpId,$gDBIDX,$debug)</b> (".
get_class($this).
")</p><blockquote>";
$this->dbPopulate($debug); // overwrites settings at the beginning
if ($debug) echo
"</blockquote>";
* returns a profile object
$obj_entry =
$obj_profile->getEntryObj($keyId,$clpIdx,$debug);
* returns if a profile allows multiple entries
return (intval($this->CLP_UNIQUEENTRY) ?
False :
TRUE);
* returns the number of entry rows required
* for the profile. This is used to create
return (intval($this->CLP_MINENTRY));
return 2147483646; // max integer -1
* sets the foreign key to the foreign table
* @version pk-06-10-23 (intval)
* returns the foreign key to the foreign table
* @version pk-06-10-23 (intval)
return $this->CLP_KEYTABLE;
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
* returns the profile empty error msg
if (!empty($this->CLP_ENTRYERRMSG)) {
return $this->CLP_ENTRYERRMSG;
* returns the profile error msg
* @param string $sep is planed to
* inserts a new CLI_PROFILES to the database
* - calls parent::dbInsert()
* - creates profile table
* @param boolean $debug show debug info
if ($debug) echo
"<hr /><p><b>CLI_PROFILES:dbInsert($debug)</b></p><blockquote>";
//if (!intval($this->CLP_DBVERSION))
$this->CLP_DBVERSION =
2;
parent::dbInsert($debug);
if (!parent::dbReplace($debug)) {
if ($debug) echo
"<p style='color:red'>RETURNS False</p></blockquote>";
if ($debug) echo
"</blockquote><hr />";
* save the profile to db by replacing the row
* first check if CLP_TABLE is ok
* @param boolean $debug show debug info
* @param boolean $ignorPopulated (if false the table MUST have been populated)
function dbReplace($debug=
False,$ignorPopulated=
False) {
if ($debug) echo
"<hr /><p><b>CLI_PROFILES:dbReplace()</b></p><blockquote>";
if ($debug) echo
"</blockquote>";
return parent::dbReplace($debug,$ignorPopulated);
// #####################################################################
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ENTRY TABLE Definition Methods */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
* returns the key column name
return $GLOBALS['OCSP_CLI']['PROFILETABLE'][$this->getDBField('CLP_KEYTABLE')]['KEY'];
* checks if a $this->getDBField('CLP_TABLE') is a profile table
* Column CLP_ID must be AUTO_INCREMENT
* all other columns are added if not exists
if ($debug) echoDebugMethod(__FILE__
,__LINE__
,"CLI_PROFILES:verifyEntryTbl($debug)");
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_ERROR);
if ($this->CLP_DBVERSION ==
2) $autoIncFld=
"CLP_IDX";
else $autoIncFld=
"CLP_ID";
if ((!isset
($tblDesc[$autoIncFld])) ||
(!$tblDesc[$autoIncFld]['AUTO_INCREMENT'])) {
echo
"<p>Error: column $autoIncFld not in table ".
$this->getDBField('CLP_TABLE').
" or CLP_ID is no AUTO_INC</p>";
if ($debug) echo
"\$tblDesc=<pre>".
print_r($tblDesc,TRUE).
"</pre></blockquote>";
if (!isset
($tblDesc[$fkCol])) {
$colDesc[$fkCol] =
array('TYPE'=>
'int','LEN'=>
11,'NULL'=>
False);
if (!isset
($tblDesc['CLP_ID'])) {
$colDesc['CLP_ID'] =
array('TYPE'=>
'int','LEN'=>
11,'NULL'=>
False,'DEFAULT'=>
$this->getId());
if (!isset
($tblDesc['CLP_STATE'])) {
$colDesc['CLP_STATE'] =
array('TYPE'=>
'int','LEN'=>
4,'NULL'=>
False,'DEFAULT'=>
0);
if (!isset
($tblDesc['CLP_UTIME'])) {
$colDesc['CLP_UTIME'] =
array('TYPE'=>
'timestamp','NULL'=>
False);
if (!isset
($tblDesc['CLP_UUSER'])) {
$colDesc['CLP_UUSER'] =
array('TYPE'=>
'int','NULL'=>
False,'DEFAULT'=>
0);
if (!isset
($tblDesc['CLP_CTIME'])) {
$colDesc['CLP_CTIME'] =
array('TYPE'=>
'timestamp','NULL'=>
False);
if (!isset
($tblDesc['CLP_CUSER'])) {
$colDesc['CLP_CUSER'] =
array('TYPE'=>
'int','NULL'=>
False,'DEFAULT'=>
0);
if (!isset
($tblDesc['CLP_RADDR'])) {
$colDesc['CLP_RADDR'] =
array('TYPE'=>
'string','LEN'=>
32,'NULL'=>
TRUE,'DEFAULT'=>
"\$REMOTE_ADDR\$");
if (!isset
($tblDesc['CLP_HVIA'])) {
$colDesc['CLP_HVIA'] =
array('TYPE'=>
'string','LEN'=>
32,'NULL'=>
TRUE,'DEFAULT'=>
"\$HTTP_VIA\$");
if (!isset
($tblDesc['CLP_HX_FORWD'])) {
$colDesc['CLP_HX_FORWD'] =
array('TYPE'=>
'string','LEN'=>
32,'NULL'=>
TRUE,'DEFAULT'=>
"\$HTTP_X_FORWARDED_FOR\$");
if ($debug) echo
"<blockquote><p>\$colDesc</p><pre>".
print_r($colDesc,TRUE).
"</pre></blockquote>";
foreach($colDesc as $colName =>
$dbDesc) {
* creates a table for CLI_PROFILES entries
* @param string $gDBIDX Index of $GLOBALS to the db object
* @param boolean $debug show debug info
* @todo col types are hardcoded mySQL -> change
if ($debug) echo
"<hr /><p><b>CLI_PROFILES:createEntryTbl($gDBIDX,$debug)</b></p><blockquote>";
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_ERROR);
$cmd=
"CREATE TABLE ".
$this->getDBField('CLP_TABLE').
" (\n";
$cmd.=
"CLP_IDX INT NOT NULL AUTO_INCREMENT,\n";
$cmd.=
"CLP_ID INT NOT NULL,\n";
$cmd.=
"CLP_STATE TINYINT NOT NULL DEFAULT '0',\n";
$cmd.=
"PRIMARY KEY (CLP_IDX),";
if ($debug) echo
"<pre>$cmd</pre>";
$this->myDBObj->executeCmd($cmd,$debug);
if ($debug) echo
"</blockquote>";
* returns the entry table name
* returns the table desc of entry table
if ($debug) echo
"<p><b>CLI_PROFILE::getEntryTblDesc(..)</b> (".
get_class($this).
")</p>";
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_ERROR);
* returns if for not multiple profiles the CLP_ID should
* be checked in the table or not.
* returns an array with the columns of the entry table
* in case of an error an empty array is returned
if ($debug) echo
"<p><b>CLI_PROFILE::getEntryTblColumns()</b> (".
get_class($this).
")</p>";
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ENTRY object Methods */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
* returns a (the first) entry row where keytable is $key and CLP_IDX is $idx
* if $key or $idx are 0 the are not included in the where
* useses $this->myDBObj->quickQuery()
* @version pk-07-01-12 redesign of $key $idx checks
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_WARNING);
$s_query.=
" AND etbl.CLP_IDX=".
intval($idx);
if ((!intval($key) ||
!intval($idx)) &&
($this->isMultiple())) { // <pk-05-11-23 /><pk-06-10-24 /> avoid the return of wrong rows
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<blockquote><p>Query: $s_query</p></blockquote>");
return $this->myDBObj->quickQuery($s_query);
* @return CLI_PROFILE_ENTRY
$obj_ret->setProfileObj($this,$debug);
if (!($arr_entryRow=
$this->getEntryRow($key,$idx,$debug)))
$arr_entryRow=
$obj_ret->getDefaults();
$arr_entryRow['CLP_ID']=
$this->getId();
$obj_ret->setDBRow($arr_entryRow,$b_asPopulated,$debug);
* @return mixed (the form id or the entry table name if form id is not set)
if ($debug) ocsp_logError(__FILE__
,__LINE__
,"Form Id not set",E_WARNING);
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ENTRY TABLE Value Form Methods */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
* returns a ponter to a formObj to use with the entry
* @returns CLI_PROFILE_FORM
function &getEntryForm($mode=
FRM_MODE_READONLY,$frmName=
"",$debug=
False) {
ocsp_logError(__FILE__
,__LINE__
,"could not get list form id",E_WARNING);
ocsp_logError(__FILE__
,__LINE__
,"could not get form id",E_WARNING);
$o_frmObj->setProfileObj($this);
echo
"<p>FormClass: <b>".
get_class($o_frmObj).
"</b></p>";
* inserts a posted form array into the content table
* @param CLI_PROFILE_FORM $frmObj
* @param boolean $noEmptyCheck
function insertPOSTEntry(&$frmObj,$DBVAL,$arrName=
"DBVAL",$noEmptyCheck=
False,$debug=
False) {
if ($debug) echo
"<p><b>CLI_PROFILE::insertPOSTEntry(...)</b> (".
get_class($this).
")</p>";
$o_eTbl->setProfileObj($this);
if ($debug) echo
"<p>\$frmObj is not an instance of DBMS_FORM</p>";
$o_tmpfrmObj->setDBMSValues($frmObj);
$o_tmpfrmObj->hideField('CLP_ID');
$GLOBALS['DBMS_FORMS'][$o_tmpfrmObj->getId()]=
$o_tmpfrmObj;
$frmObj=
&$GLOBALS['DBMS_FORMS'][$o_tmpfrmObj->getId()];
$i_pfId=
(isset
($DBVAL['CLP_ID']) ?
intval($DBVAL['CLP_ID']) :
0);
if ($i_pfId !=
$this->getId()) {
$DBVAL['CLP_ID']=
$this->getId();
$fkCol=
$GLOBALS['OCSP_CLI']['PROFILETABLE'][$this->CLP_KEYTABLE]['KEY'];
// <pk-05-11-04> set $this->FKValue if in $DBVAL
// to avoid null values if field is hidden
if (isset
($DBVAL[$fkCol]) &&
intval($DBVAL[$fkCol])) {
} else if (strstr($DBVAL['_DBMS_FIELDS'],$fkCol)) {
$o_eTbl->setFORMPOST($frmObj,$DBVAL,$debug,TRUE,TRUE);
if ($debug) echo
"<p>checkEntryRowArr returned FLASE</p></blockquote>";
$frmObj->setError($this->getErrorMsg,$this->colPrefix.
"ID");
return $o_eTbl->dbSave($this->get_gDBIDX(),$debug);
* updates a posted form array into the content table
* @param CLI_PROFILE_FORM $frmObj
* @param boolean $noEmptyCheck
function updatePOSTEntry(&$frmObj,$DBVAL,$arrName=
"DBVAL",$noEmptyCheck=
False,$debug=
False) {
if ($debug) echo
"<p><b>CLI_PROFILE::updatePOSTEntry(...)</b> (".
get_class($this).
")</p>";
* returns if a profile post has data
* postVals are not null and not equal to form defaults
* @param DBMS_FORM $frmObj
* @param boolean $noDefaultChk
* @version pk-05-08-22 param no defaultchk added
* @version pk-05-11-08 debug info
function postArrHasData(&$frmObj,$postVals,$debug=
False,$noDefaultChk=
False) {
if ($debug) echo
"<p><b>CLI_PROFILE::postArrHasData(...)</b> (".
get_class($this).
")</p>"; // <pk-05-11-08 />
$frmDefVals=
$frmObj->getDefaultValArr();
if (implode(",",$postVals) !=
$postVals['_DBMS_FIELDS']) {
// ok it is not empty but are the values only the default values
if ((!empty($postVals['_DBMS_FIELDS'])) &&
($flds=
explode(",",$postVals['_DBMS_FIELDS']))) {
// we have an OCSP Form Post array
// array is not a valid OCSP Form Post check with all fields
if ($debug) echo
"<p>Checking DefaultVals for fields:<p>";
foreach ($flds as $fldIdx) {
if (!empty($postVals[$fldIdx])) { //<pk-05-08-22>
if ($postVals[$fldIdx] !=
$frmDefVals[$fldIdx]) {
if ($debug) echo
"<blockquote><p>profilePostHasData() returns <b>TURE</b><p></blockquote>";
} else if ($noDefaultChk) { // <pk-05-08-22>
if ($debug) echo
"<blockquote><p>Field $fldIdx not empty</p></blockquote>";
if ($debug) echo
"<blockquote><p>profilePostHasData() returns <b>False</b></blockquote><p>";
* checks a array by including $GLOBALS['PROJECT']['PATH'].$this->CLP_ENTRYCHKIN
* returns $retVal which can be set in the include (default: TRUE)
* @note $dbVal is called by referenze so can be changed in the check include.
if ($debug) echo
"<p><b>CLI_PROFILES::checkEntryRowArr(...)</b> (".
get_class($this).
")</p>";
if (!empty($this->CLP_ENTRYCHKINC)) {
if (file_exists($GLOBALS['PROJECT']['PATH'].
$this->CLP_ENTRYCHKINC)) {
include $GLOBALS['PROJECT']['PATH'].
$this->CLP_ENTRYCHKINC;
$this->ERRMSG=
"SYSTEMERROR: Werte konnten nicht berprft werden";
if ($debug) echo
"<blockquote><p>RETURNS ".
($retVal ?
"TRUE" :
"False").
"</p></blockquote>";
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ENTRY TABLE Value Data Methods
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* inserts an Row array into the entry table
if($debug) echo
"<p><b>CLI_PROFILES::insertEntryRow(...)</b> (".
get_class($this).
")</p>";
if (!intval($dbVal[$fkCol])) {
} else if (intval($_SESSION[$fkCol])) {
$dbVal[$fkCol]=
intval($_SESSION[$fkCol]);
} else if (intval($_POST[$fkCol])) {
$dbVal[$fkCol]=
intval($_POST[$fkCol]);
if ($debug) echo
"<p>\$dbVal[".
$fkCol.
"] NOT SET</p>"; // <pk-05-11-04>
"CLP_CTIME" =>
$this->myDBObj->qs_getNowStmt(),
"CLP_CUSER" =>
$GLOBALS['USER']->getId(),
"CLP_RADDR" =>
$_SERVER['REMOTE_ADDR'],
"CLP_HVIA" =>
$_SERVER['HTTP_VIA'],
"CLP_HX_FORWD" =>
$_SERVER['HTTP_X_FORWARDED_FOR']
if ($this->CLP_DBVERSION ==
2) {
$colArr['CLP_ID']=
$this->getId();
foreach($colArr as $col=>
$defVal) {
if (empty($dbVal[$col])) $dbVal[$col]=
$defVal;
if ($debug) echo
"<blockquote><p>dbVal:</p><pre>".
print_r($dbVal,TRUE).
"</pre></blockquote>";
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_ERROR);
* updates an Row array into the entry table
if($debug) echo
"<p><b>CLI_PROFILES::updateEntryRow(...)</b> (".
get_class($this).
")</p>";
if ($this->CLP_DBVERSION ==
2) {
$dbVal['CLP_ID']=
$this->getId();
// select the row only by CLP_IDX
// to avoid errors if $fk chacnges
$query.=
" WHERE CLP_IDX=".
$dbVal['CLP_IDX'];
$query.=" WHERE ".$this->getKeyColName()."=".$fk;
if (intval($dbVal['CLP_IDX'])) {
$query.=" AND CLP_IDX=".$dbVal['CLP_IDX'];
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_ERROR);
if (!$row=
$this->myDBObj->quickQuery($query)) {
if ($debug) echo
"<p>no data found $query</p>";
foreach($dbVal as $key =>
$val) {
if ($debug) echo
"<p>row[".
$this->getKeyColName().
"] not set</p>";
if (!intval($row['CLP_CTIME'])) $row['CLP_CTIME']=
$row['CLP_UTIME'];
if (!intval($row['CLP_CUSER'])) $row['CLP_CUSER']=
0;
unset
($row['CLP_UTIME']);
$row['CLP_UUSER']=
$GLOBALS['USER']->getId();
$row["CLP_RADDR"]=
$_SERVER['REMOTE_ADDR'];
$row["CLP_HVIA"]=
$_SERVER['HTTP_VIA'];
$row["CLP_HX_FORWD"]=
$_SERVER['HTTP_X_FORWARDED_FOR'];
$row['CLP_ID']=
$this->getId();
if ($debug) echo
"<p><b>CLI_PROFILE::deleteEntryRow($key,$idx...)</b> (".
get_class($this).
")</p>";
$s_query=
"DELETE FROM ".
$this->getEntryTbl().
" WHERE 1=1 ";
$s_query.=
" AND CLP_IDX=".
intval($idx);
if ($debug) echo
"<blockquote><p>Cmd: $s_query</p></blockquote>";
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_ERROR);
return $this->myDBObj->executeCmd($s_query);
* replaces all entries of a client/user/staff
* @note deletes all entries from the table and then insert datarows in $dataArray
* @param int $fkval foreign key
* @param int $dataArray array of rows
* @returns int number of rows inserted
if ($debug) echo
"<p><b>CLI_PROFILE::replaceAllEntries($fkVal,....)</b> (".
get_class($this).
")</p>";
if (!is_array($dataArray)) return False;
$cmd.=
" AND CLP_ID=".
$this->getId();
if ($debug) echo
"<p>CMD: $cmd</p>";
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_ERROR);
foreach($dataArray as $idx =>
$dbVal) {
* returns the select statement for a join of Entrytable and Keytable
* @note values of ..TblKeys are the complete right side of condition
* - [CLI_NAME1] => "LIKE 'A%'"
* @param array $keyTblKeys
* @param array $entrTblKeys
if ($debug) echo
"<p><b>CLI_PROFILE::getEntryTblSelectStmt(...)</b> (".
get_class($this).
")</p>";
$s_stmt =
"SELECT * FROM ".
$this->getEntryTbl().
" etbl JOIN ".
$this->CLP_KEYTABLE.
" ktbl USING(".
$this->getKeyColName().
")";
$s_stmt.=
" WHERE 1=1"; // to ensure we have a where
foreach($keyTblKeys as $col =>
$con) {
$s_stmt.=
" AND ktbl.".
$col.
$con;
foreach($entrTblKeys as $col =>
$con) {
$s_stmt.=
" AND etbl.".
$col.
" ".
$con;
$s_stmt.=
" AND etbl.CLP_ID=".
$this->getId();
* returns an array of all entry rows where keytable key fit
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_ERROR);
$s_query=
"SELECT * FROM ".
$this->getEntryTbl().
" WHERE 1=1 ";
$s_query.=
" AND CLP_ID=".
$this->getId();
if ($debug) echoDebug(__FILE__
,"<blockquote>Query: ".
$s_query.
"</blockquote>");
return $this->myDBObj->queryArray($s_query,-
1,-
1,TRUE,$debug);
* returns the number of entries for a key with state
* @param int $state use -1 to ignore it
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_ERROR);
$s_query.=
"SELECT COUNT(*) FROM ".
$this->getEntryTbl();
if ($state > -
1) $s_query.=
" AND CLP_STATE=".
intval($state);
if ($debug) echoDebug(__FILE__
,"<p>".
$s_query.
"</p>");
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
* returns if the current user is allowed to show the profile
* @global array $OCSP_OBJ
if (!intval($this->getId())) return False; // no profile loaded
* returns if the current user is allowed to show the profile
* @global array $OCSP_OBJ
if (!intval($this->getId())) return False; // no profile loaded
if (OCSP_OBJ::currentUser()->isPublic()) return TRUE; // as we have no user we asume that we are in the register process
// so we allow him to add data later
* returns if the current user is allowed to edit the profile
* @global array $OCSP_OBJ
if (!intval($this->getId())) return False; // no profile loaded
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
return intval($this->{$this->colPrevix.
"SORTORDER"});
* moves the profile up (decrease sortorder)
* note autosaves sortorder
if ($debug) echo
"<p><b>CLI_PROFILE::sort_MoveUp()</b> (".
get_class($this).
")</p>";
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_ERROR);
if (intval($this->{$this->colPrevix.
"SORTORDER"}) >
1) {
$s_Query =
"SELECT ".
$this->colPrevix.
"ID AS IDCOL, ".
$this->colPrevix.
"SORTORDER AS ORDERCOL";
$s_Query.=
" FROM ".
$this->myTable;
$s_Query.=
" WHERE PROJ_ID=".
$this->getProjId();
$s_Query.=
" AND ".
$this->colPrevix.
"SORTORDER <= ".
$this->getSortOrder();
$s_Query.=
" AND ".
$this->colPrevix.
"ID <> ".
$this->getId();
$s_Query.=
" ORDER BY ".
$this->colPrevix.
"SORTORDER DESC";
if ($debug) echo
"<p>".
$s_Query.
"</p>";
if ($a_Row=
$this->myDBObj->quickQuery($s_Query)) {
// get only the first row
$this->{$this->colPrevix.
"SORTORDER"} =
intval($a_Row['ORDERCOL']);
$s_Query =
"UPDATE ".
$this->myTable.
" SET ".
$this->colPrevix.
"SORTORDER=".
$this->getSortOrder();
$s_Query.=
" WHERE ".
$this->colPrevix.
"ID = ".
$this->getId();
if ($debug) echo
"<p>".
$s_Query.
"</p>";
$this->myDBObj->executeCmd($s_Query);
$s_Query =
"UPDATE ".
$this->myTable.
" SET ".
$this->colPrevix.
"SORTORDER=".
($this->getSortOrder()+
1);
$s_Query.=
" WHERE ".
$this->colPrevix.
"ID = ".
$a_Row['IDCOL'];
if ($debug) echo
"<p>".
$s_Query.
"</p>";
$this->myDBObj->executeCmd($s_Query);
* moves the profile down (increase sortorder)
* note: autosaves sortorder
if ($debug) echo
"<p><b>CLI_PROFILE::sort_MoveDown()</b> (".
get_class($this).
")</p>";
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_ERROR);
if (intval($this->{$this->colPrevix.
"SORTORDER"}) >
1) {
$s_Query =
"SELECT ".
$this->colPrevix.
"ID AS IDCOL, ".
$this->colPrevix.
"SORTORDER AS ORDERCOL";
$s_Query.=
" FROM ".
$this->myTable;
$s_Query.=
" WHERE PROJ_ID=".
$this->getProjId();
$s_Query.=
" AND ".
$this->colPrevix.
"SORTORDER >= ".
$this->getSortOrder();
$s_Query.=
" AND ".
$this->colPrevix.
"ID <> ".
$this->getId();
$s_Query.=
" ORDER BY ".
$this->colPrevix.
"SORTORDER";
if ($debug) echo
"<p>".
$s_Query.
"</p>";
if ($a_Row=
$this->myDBObj->quickQuery($s_Query)) {
// get only the first row
$this->{$this->colPrevix.
"SORTORDER"} =
$this->getSortOrder()+
1;
$s_Query =
"UPDATE ".
$this->myTable.
" SET ".
$this->colPrevix.
"SORTORDER=".
$this->getSortOrder();
$s_Query.=
" WHERE ".
$this->colPrevix.
"ID = ".
$this->getId();
if ($debug) echo
"<p>".
$s_Query.
"</p>";
$this->myDBObj->executeCmd($s_Query);
$s_Query =
"UPDATE ".
$this->myTable.
" SET ".
$this->colPrevix.
"SORTORDER=".
($this->getSortOrder()-
1);
$s_Query.=
" WHERE ".
$this->colPrevix.
"ID = ".
$a_Row['IDCOL'];
if ($debug) echo
"<p>".
$s_Query.
"</p>";
$this->myDBObj->executeCmd($s_Query);
* moves the profile to a position
* note: autosaves sortorder
* if $postion > last postion
* the object will be moved to the end
* @var DBMS_CURSOR $o_Cursor
if ($debug) echo
"<p><b>CLI_PROFILE::sort_MoveToPos($position)</b> (".
get_class($this).
")</p>\n";
if (!intval($position)) return False; // error illegal position
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_ERROR);
$s_Query =
"SELECT ".
$this->colPrevix.
"ID AS IDCOL, ".
$this->colPrevix.
"SORTORDER AS ORDERCOL";
$s_Query.=
" FROM ".
$this->myTable;
$s_Query.=
" WHERE PROJ_ID=".
$this->getProjId();
$s_Query.=
" AND ".
$this->colPrevix.
"ID <> ".
$this->getId(); // without me
$s_Query.=
" ORDER BY ".
$this->colPrevix.
"SORTORDER";
if ($o_Cursor=
$this->myDBObj->query($s_Query)) {
while($a_Row =
$o_Cursor->fetchArrayFld()) {
if ($i_ordNr ==
$position) {
$this->{$this->colPrevix.
"SORTORDER"}=
$position;
if (intval($a_Row['ORDERCOL']) !=
$i_ordNr) {
$s_Query =
"UPDATE ".
$this->myTable.
" SET ".
$this->colPrevix.
"SORTORDER=".
$i_ordNr;
$s_Query.=
" WHERE ".
$this->colPrevix.
"ID = ".
$a_Row['IDCOL'];
if ($debug) echo
"<p>".
$s_Query.
"</p>";
$this->myDBObj->executeCmd($s_Query);
$this->{$this->colPrevix.
"SORTORDER"}=
$i_ordNr;
// finaly save my own order position to the database
$s_Query =
"UPDATE ".
$this->myTable.
" SET ".
$this->colPrevix.
"SORTORDER=".
$this->getSortOrder();
$s_Query.=
" WHERE ".
$this->colPrevix.
"ID = ".
$this->getId();
if ($debug) echo
"<p>".
$s_Query.
"</p>";
$this->myDBObj->executeCmd($s_Query);
Documentation generated on Thu, 08 Jan 2009 17:38:02 +0100 by phpDocumentor 1.4.0a2