Source for file CLIENT.phpclass
Documentation is available at CLIENT.phpclass
-   * Class file CLIENT.phpclass 
-   * @project    Open CSP-Management 
-   * @author     Peter Krebs <pitlinz@users.sourceforge.net> 
-   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License 
-   * @version $Id: CLIENT.phpclass,v 1.24 2008/11/30 13:35:30 pitlinz Exp $ 
-     // --------------------------------------------------------- 
-     // --------------------------------------------------------- 
-     require_once __OCSP_DEFAULTCONFPATH__- . "client.conf.phpinc";
 
-   * @project    Open CSP-Management 
-   * @author     Peter Krebs <pitlinz@users.sourceforge.net> 
-   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License 
-   * @version $Id: CLIENT.phpclass,v 1.24 2008/11/30 13:35:30 pitlinz Exp $ 
-     // --------------------------------------------------------------------------- 
-     // --------------------------------------------------------------------------- 
-       * @constant string CLASS_SRC_FILE 
-     // --------------------------------------------------------------------------- 
-     // --------------------------------------------------------------------------- 
-     /*** class vars ------------------------------------------------------ */ 
-      * unit of work client objects 
-      * @staticvar array $clientLst  
-     /*** class methods --------------------------------------------------- */ 
-      * returns an unit of work client object 
-         if (!- isset (self::$clientLst[$aId])- ||  !is_object(self::$clientLst[$aId]))
 
-             self::$clientLst[$aId] - =  self::factoryFromId($aId);
 
-         return self::$clientLst[$aId]; 
-      * returns if a client with id $aId has already been instanced 
-         if (- isset (self::$clientLst[$aId])- &&  pcf_class_implements($aClient,'INFA_CLIENT'))
 
-      * sets a client instance in the unit of work 
-     public static function setInstance(&$aClient, $debug- = False)
 
-             self::$clientLst[$aClient->getId()] - =  $aClient;
 
-     // --------------------------------------------------------------------------- 
-     // --------------------------------------------------------------------------- 
-     /*** compostion --------------------------------------------------- */ 
-       * @var ADDRESS $myAddress  
-       * @var CLI_TYPE $myTypeObj  
-     /*** attributes  -------------------------------------------------- */ 
-       * @var string $myTable name of the db table 
-       * @var string $myClassSrcFile if is set the DBMS_FORM get the class object 
-       * @deprecated since pk-07-10-18 
-       * @var string $staffClass  
-       * @var string $myUserClass class name of the user object 
-     // -------------------------------------------- 
-     // -------------------------------------------- 
-       * init the object and populate if an id is submitted 
-       * @param string $gDBIdx   database index in $GLOBALS 
-     function CLIENT($aId- = 0,$debug- = False)
 
-         if ($debug) echoDebugMethod(- __FILE__ ,get_class($this),"CLIENT::CLIENT($aId)");
 
-      * factory a client object 
-             return self::factoryFromDBRow($arr_cliRow,$debug); 
-             $obj_ret->setId(intval($aId)); 
-      * factory a client object from a client database row 
-         if ($debug) echoDebugMethod(- __FILE__ ,"static","CLIENT::factoryFromDBRow();");
 
-             return $o_cliType->getCliObjectFromArray($cliRow,$debug); 
-     // -------------------------------------------- 
-     // -------------------------------------------- 
-       * @version pk-06-07-21 bugfix 
-       * gets the clients type object 
-       * sets the clients type object 
-      * retruns the state object 
-      * marks a client as deleted 
-      * @return boolean (userCanEdit) 
-     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 
-       * returns the client name (CLI_NAME1 + CLI_NAME2) 
-       * returns the client number or the ID if no number isset 
-         if (empty($s_ret)) $s_ret- = "ID:"- . $this->getId();
 
-     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 
-     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 
-       * @param boolean $frmMode  
-       * @version pk-06-10-25 use $this->myTypeObj->getAdminForm() 
-         if ($debug) - echo  "<p><b>CLIENT::dbGetAdminForm(...)</b> ("- . get_class($this)- . ")</p>";
 
-         $this->getTypeObj(); // ensure $this->myTypeObj is set propper; 
-         $obj_ret->setMyTblObj($this); 
-       * @param boolean $frmMode  
-       * @version pk-06-10-25 use $this->myTypeObj->getAdminForm() 
-         $this->getTypeObj(); // ensure $this->myTypeObj is set propper; 
-         $obj_ret->setMyTblObj($this); 
-       * returns a database form 
-       * @param int $mode        dbms form show mode 
-       * @param string $frmName  dbms form name 
-       * @param boolean $debug   since pk-05-01-11 
-       * @param boolean $autonew generate a default form if no form is found 
-       * @deprecated since pk-07-10-03 
-     function &dbGetForm($mode,$frmName- = "",$debug- = False,$autoNew- = False)  {
 
-         return $this->getForm($mode,$frmName,'CLI_FORM',$debug); 
-       * replaces dbGetForm and returns a OCSP_FORM 
-       * @param mixed $form (string) form name (int) form id 
-       * @requires CLI_FORM.phpclass 
-     function &getForm($mode- = FRM_MODE_READONLY,$form- = '',$frmClass- = 'CLI_FORM',$debug- = False)
 
-         if (empty($frmClass)) $frmClass- = 'CLI_FORM';
 
-             return parent::getForm($mode,$form,$frmClass,$debug); 
-       * returns the the data array of a join 
-       * @param boolean $withObjVars  
-     function dbGetDataArray($tables,$filter- = NULL,$withObjVars- = TRUE,$debug- = False) {
 
-         $a_ret- = $this->getDBVal(False,$debug,$withObjVars);
 
-             ocsp_logError(- __FILE__ ,- __LINE__ ,"no database connection",E_ERROR);
 
-             foreach($tables as $tbl) { 
-                 if ($debug) echoDebugLine(- __FILE__ ,- __LINE__ ,"<h3>getting data for: "- . $tbl- . "</h3>\n");
 
-                         $s_query- = "SELECT * FROM "- . $tbl- . " WHERE CLI_ID="- . $this->getId();
 
-                         if ($debug) - echo  "<p>$s_query</p>\n";
 
-                         if ($a_tmp- = $this->myDBObj->quickQuery($s_query)) {
 
-                 if ($debug) - echo  "</blockquote>";
 
-       * sets post array with form checks 
-       * @param DBMS_FORM $frmObj a formObj as ref 
-       * @param array $dbVal array with data 
-       * @param bool $asPopulate  
-       * @version pk-07-02-16 ensure we have a type 
-     function setFORMPOST(&$frmObj,$dbval,$debug- = False,$asPopulate- = TRUE) {
 
-         if ($debug) - echo  "<p><b>CLIENT::setFORMPOST(...)</b> ("- . get_class($this)- . ")</p><blockquote style=\"font-size: 75%\">\n";
 
-         if (intval($dbval['CTY_ID'])) { 
-         $a_frmData- = $frmObj->getTableValueArrays($dbval,$debug);
 
-         if ($frmObj->hasErrors()) { 
-             if ($debug) {- echo  "<p style=\"color:red\"><b>FORM "- . $frmObj->getName()- . " HAS ERRORS:</b></p><pre style=\"font-size:10px;\">";print_r($valArray);- echo  "</pre>";$frmObj->writeErros();- echo  "</blockquote>";}
 
-         $this->setObjValArray($a_frmData['OBJVALS_'- . $this->myTable],$debug); // <pk-07-01-10 /> bugfix in array index
 
-         $a_editablePFStates- = array();
 
-         foreach($GLOBALS['OCSP_CLI']['PROFILESTATE'] as $i_statId - =>  $a_state) {
 
-             if (- isset ($a_state['EDITABLE'])- &&  $a_state['EDITABLE']) {
 
-                 $a_editablePFStates[]- = $i_statId;
 
-         foreach($a_frmData as $s_tbl - =>  $a_values) {
 
-                     // do nothing as already done above 
-                 default- :  // <pk-06-10-20>
 
-                     // first check for profile Data 
-                     $s_query - = "SELECT * FROM T_CLI_PROFILES";
 
-                     $s_query- .= " WHERE CLP_KEYTABLE='T_CLI_CLIENT' AND CLP_TABLE='"- . $s_tbl- . "'";
 
-                     $s_query- .= " AND CLP_STATE IN ("- . implode(',',$a_editablePFStates)- . ")";
 
-                     $s_query- .= " AND CTY_ID IN (0,"- . $this->getTypeId()- . ")";
 
-                     $s_query- .= " ORDER BY CLP_SORTORDER";
 
-                     if (($a_pfRow- = $GLOBALS['USRDB']->quickQuery($s_query))- &&  (intval($a_pfRow['CLP_ID']))) {
 
-                         if ($debug) - echo  "<h1>Profiledata found</h1><blockquote><hr>";
 
-                         $s_tblKey- = $s_tbl- . "-PF"- . $a_pfRow['CLP_ID'];
 
-                         require_once dirname(- __FILE__ )- . "/CLI_PROFILE_ENTRY.phpclass";
 
-                         $a_dbval['CLP_ID']- = $a_pfRow['CLP_ID'];
 
-                         if ($debug) - echo  "<hr></blockquote>";
 
-         if ($debug) - echo  "</blockquote>";
 
-       * adds an object to the frmPostSubOjects 
-       * @param DBMS_TABLEOBJ $obj  
-     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 
-     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 
-       * inserts a new row to the table 
-       * @param boolean $debug (show debug info) 
-       * @returns int   returns the autoIncFld ID if exists or 1 on success 
-       * @version pk-05-11-09 $GLOBALS['CLIENT']['DEFAULT']['CTY_ID'] added 
-             $this->CLI_CREATOR  - = $OCSP_OBJ['USER']->getId(); // <pk-05-11-03 />
 
-             $this->CLI_CHANGEDBY- = $OCSP_OBJ['USER']->getId(); // <pk-05-11-03 />
 
-             $this->CTY_ID- = intval($GLOBALS['CLIENT']['DEFAULT']['CTY_ID']);
 
-       * replaces a row in the table 
-       * if the object has not been populated (!$this->populateTS) 
-       * @param string $gDBIDX Index of $GLOBALS to the db object 
-       * @param boolean $debug  show debug info 
-       * @version pk-05-11-25 bugfix return value 
-     function dbReplace($debug- = False,$ignorPopulated- = False)
 
-         if ($debug) - echo  "<hr><p><b>CLIENT::dbReplace($gDBIDX,$debug)</b> ("- . get_class($this)- . ")</p>";
 
-             $this->CLI_CHANGEDBY- = $GLOBALS['USER']->getId();
 
-             $this->CLI_LASTCHANGE- = NULL;
 
-                             $o_obj->setClient(&$this,$debug); 
-                             if (($o_obj->getId()- == $this->CLI_DEFAULTADDR)- ||  (!intval($this->CLI_DEFAULTADDR))) {
 
-                                 $o_obj->setDBField('ADR_ISPRIMARY',1); 
-                             if ($debug) - echo  "<pre>"- . print_r($o_obj->getDBVal(),TRUE)- . "</pre>";
 
-                             $o_obj->dbSave($gDBIDX,$debug); 
-                             if (!intval($this->CLI_DEFAULTADDR)) { 
-                                 if ($this->CLI_DEFAULTADDR- = $o_obj->getId()) {
 
-                                     $s_cmd - = "UPDATE "- . $this->myTable- . " SET CLI_DEFAULTADDR="- . intval($this->CLI_DEFAULTADDR);
 
-                                     $s_cmd- .= " WHERE CLI_ID="- . $this->getId();
 
-                                     $GLOBALS[$gDBIDX]->executeCmd($s_cmd); 
-                                 if ($debug) - echo  "<p>Saving Table: $s_tbl</p><blockquote>";
 
-                                 $o_obj->CLI_ID- = $this->getId();
 
-                                 $o_obj->dbSave($gDBIDX,$debug); 
-                                 if ($debug) - echo  "</blockquote>";
 
-             return TRUE; // <pk-05-11-25 /> 
-         return False; // <pk-05-11-25 /> 
-       * deletes the row from the database 
-       * @param boolean $backupData  
-       * @todo move functionality from deleteAllData to this method 
-     function dbDelete($backupData- = TRUE,$debug- = False)
 
-             $xmlFile- = $GLOBALS['PROJECT']['BACKUPPATH']- . "client-"- . $this->getId()- . ".xml";
 
-         $s_query- = "SELECT * FROM T_CLI_STAFF WHERE CLI_ID="- . $this->getId();
 
-         if ($o_staffCursor- = $this->myDBObj->query($s_query)) {
 
-             while($a_staff - =  $o_staffCursor->fetchArrayFld()) {
 
-                 $o_staff->setDBRow($a_staff,TRUE); 
-                 $o_staff->dbDelete($backupData,$debug); 
-       * deletes all client data 
-       * @todo store deleted data to be able to undo 
-       * @deprecated since pk-05-12-06 
-         $query- = "SELECT CLP_TABLE FROM T_CLI_PROFILES WHERE CLP_KEYTABLE='T_CLI_CLIENT'";
 
-         if ($cursor- = $this->myDBObj->query($query)) {
 
-             while($row- = $cursor->fetchArrayFld()) {
 
-                 $cmd- = "DELETE FROM "- . $row['CLP_TABLE']- . " WHERE CLI_ID="- . $this->getId();
 
-                 if ($debug) - echo  "<p>$cmd</p>";
 
-                 $this->myDBObj->executeCmd($cmd,$debug); 
-         $query- = "SELECT USR_ID FROM T_CLI_USER WHERE CLI_ID="- . $this->getId();
 
-         if ($users- = $this->myDBObj->queryArray($query,- - 1)) {
 
-             foreach($users as $usrId) { 
-                 $query- = "SELECT CLP_TABLE FROM T_CLI_PROFILES WHERE CLP_KEYTABLE='T_SYS_USER'";
 
-                 if ($cursor- = $this->myDBObj->query($query)) {
 
-                     while($row- = $cursor->fetchArrayFld()) {
 
-                         $cmd- = "DELETE FROM "- . $row['CLP_TABLE']- . " WHERE USR_ID="- . $usrId;
 
-                         $this->myDBObj->executeCmd($cmd,$debug); 
-                 $cmd- = "DELETE FROM T_SYS_GROUPMEMBER WHERE USR_ID="- . $usrId;
 
-                 $this->myDBObj->executeCmd($cmd,$debug); 
-                 $cmd- = "DELETE FROM T_SYS_USER WHERE USR_ID="- . $usrId;
 
-                 $this->myDBObj->executeCmd($cmd,$debug); 
-         $cmd - =  "DELETE FROM T_CLI_USER WHERE CLI_ID="- . $this->getId();
 
-         $this->myDBObj->executeCmd($cmd,$debug); 
-         $cmd - =  "DELETE FROM T_ADDRESS WHERE CLI_ID="- . $this->getId();
 
-         $this->myDBObj->executeCmd($cmd,$debug); 
-         $cmd - =  "DELETE FROM T_CLI_COSTCENTER WHERE CLI_ID="- . $this->getId();
 
-         $this->myDBObj->executeCmd($cmd,$debug); 
-         $cmd - =  "DELETE FROM T_CLI_CLIENT WHERE CLI_ID="- . $this->getId();
 
-         $this->myDBObj->executeCmd($cmd,$debug); 
-         $cmd - =  "DELETE FROM T_CLI_CLIENT_OV WHERE CLI_ID="- . $this->getId();
 
-         $this->myDBObj->executeCmd($cmd,$debug); 
-     // ---------------------------------------------------------- 
-     // ---------------------------------------------------------- 
-      * saves a linked row due to $cmd 
-      * @param string $cmd (_OCSP_DBCMD_*) 
-         $row['CLI_ID'] - =  $this->getId();
 
-                 $obj_addr->setDBRow($row,TRUE,$debug); 
-                 $obj_addr->setCliId($this->getId()); 
-                         return $obj_addr->dbSave($debug);                         
-                         return $obj_addr->dbDelete(TRUE,$debug); 
-         if (- isset ($row['CLP_ID']))
 
-                 $int_idx- = (- isset ($row['CLP_IDX'])- ?  intval($row['CLP_IDX'])- :  0);
 
-                 $obj_entry - =  $obj_profile->getEntryObj($this->getId(),$int_idx,$debug);
 
-                 $obj_entry->setDBRow($row,TRUE,$debug); 
-                 $obj_entry->setDBField('CLI_ID',$this->getId()); 
-                         return $obj_entry->dbSave($debug); 
-                         return $obj_entry->dbDelete(TRUE,$debug); 
-       * returns the CLI_ID if a client is found with same addresse and cols filled in 
-       * @return int 0 if not found otherwise the id of the client 
-         $sFrom - = " FROM T_CLI_CLIENT c";
 
-                 if ($debug) - echo  "<p>checking: $s_key </p>";
 
-                         $aVals- = $o_subObj->getDBVal();
 
-                         unset ($aVals['ADR_ISPRIMARY']);
-                         unset ($aVals['ADR_CREATOR']);
-                         unset ($aVals['ADR_CHANGEDBY']);
-                         unset ($aVals['ADR_LASTCHANGE']);
-                         unset ($aVals['ADR_SEX']);
-                         $s_query- = "SELECT ADR_ID FROM T_ADDRESS WHERE 1=1";
 
-                         foreach($aVals as $s_col - =>  $s_val) {
 
-                             $s_query- .= " AND $s_col="- . $GLOBALS['USRDB']->qs_getSlashedValue($s_val);
 
-                         if ($debug) - echo  "<p>T_ADDRESS: $s_query</p>";
 
-                         if ($a_addr- = $this->myDBObj->queryArray($s_query)) {
 
-                             if ($debug) - echo  "<pre>"- . print_r($a_addr,TRUE)- . "</pre>";
 
-                             $sFrom - .= " JOIN T_ADDRESS a USING(CLI_ID)";
 
-                             $sWhere- .= " AND a.ADR_ID IN ("- . implode(',',$a_addr)- . ")";
 
-                         echo  "<p>chkDuplicate Object Key: $s_key</p>";
-                         echo  "<blockquote><pre>"- . print_r($o_subObj,TRUE)- . "</pre></blockquote>";
-         if ($debug) - echo  "<pre>"- . print_r($aVals,TRUE)- . "</pre>";
 
-         unset ($aVals['CLI_DEFAULTADDR']);
-         unset ($aVals['CLI_LASTCHANGE']);
-         unset ($aVals['CLI_CREATION']);
-         unset ($aVals['CLI_LASTVISIT']);
-         unset ($aVals['CLI_NWLMODE']);
-         unset ($aVals['CLI_DOUBLET']);
-         unset ($aVals['CLI_STATE']);
-         unset ($aVals['CLI_CREATOR']);
-         unset ($aVals['CLI_CHANGEDBY']);
-         unset ($aVals['CLI_AGENTGROUP']);
-         unset ($aVals['CLI_CONSULTANT']);
-         unset ($aVals['CLI_FOREIGNKEY']);
-         foreach($aVals as $s_col - =>  $s_val) {
 
-             $sWhere- .= " AND $s_col="- . $GLOBALS['USRDB']->qs_getSlashedValue($s_val);
 
-         $s_query- = "SELECT c.CLI_ID "- . $sFrom- . $sWhere;
 
-         if ($debug) - echo  "<p>"- . $s_query- . "</p>";
 
-     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 
-     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 
-       * returns a dbrow with the primary address 
-       * @param boolean $withoutNull null values are not added to the array 
-         if ($debug) - echo  "<p><b>CLIENT::getAddressDBRow(...)</b> ("- . get_class($this)- . ")</p>";
 
-         if ($dbRow- = $this->getDBRow($withoutNull,$debug)) {
 
-                 $addrRow- = $addrObj->getDBRow($withoutNull,$debug);
 
-             $addrRow['CLI_ID']- = $this->getId();
 
-       * returns an array with dbvalues for the client and the primary address 
-         if ($debug) - echo  "<p><b>CLIENT::getCliAddrDBVal(...)</b> ("- . get_class($this)- . ")</p>";
 
-         if ($debug) - echo  "<p><b>CLIENT::getDefaultAddress()</b> ("- . get_class($this)- . ")</p>\n";
 
-       * returns a address of the client 
-       * @param int $addrId if 0 the default address is used 
-                 // we have no primary address set -> ask the db 
-                 if ($arr_address - =   $this->myDBObj->getArray('T_ADDRESS',array('CLI_ID'- =>  $this->getId()),0,1,'ADR_ISPRIMARY DESC',$debug))
 
-         if (!$obj_addr->getCliId() - ==  $this->getId())
 
-             $obj_addr->setClient($this,$debug); 
-       * returns the default Address ID 
-       * if column CLI_DEFAULTADDR is 0 the first ADR_ID in T_ADDRESS of the client is set as primary 
-       * @param boolean $autosave (save changes to the database) 
-       * @version pk-05-08-29 $autosave added 
-       * @version pk-07-08-28 $this->myDBObj 
-       * @todo CLIENT::getPriAddrId() inline SQL Code 
-                 ocsp_logError(- __FILE__ ,- __LINE__ ,"no database connection",E_ERROR);
 
-             $query - = "SELECT ADR_ID FROM T_ADDRESS WHERE CLI_ID="- . $this->getId();
 
-             $query- .= " ORDER BY ADR_ISPRIMARY DESC";
 
-             if ($autosave) { // <pk-05-08-29> 
-                 $str_cmd- = "UPDATE T_CLI_CLIENT SET CLI_DEFAULTADDR="- . intval($this->CLI_DEFAULTADDR)- . ",CLI_CHANGEDBY="- . ($OCSP_OBJ['USER']->getId()- *- 1)- . " WHERE CLI_ID="- . $this->getId();
 
-                 $this->myDBObj->executeCmd($str_cmd); 
-                 $str_cmd- = "UPDATE T_ADDRESS SET ADR_ISPRIMARY=0,ADR_CHANGEDBY="- . ($OCSP_OBJ['USER']->getId()- *- 1)- . " WHERE CLI_ID="- . $this->getId()- . " AND ADR_ISPRIMARY <> 0";
 
-                 $this->myDBObj->executeCmd($str_cmd); 
-                 $str_cmd- = "UPDATE T_ADDRESS SET ADR_ISPRIMARY=1,ADR_CHANGEDBY="- . ($OCSP_OBJ['USER']->getId()- *- 1)- . " WHERE CLI_ID="- . $this->getId()- . " AND ADR_ID="- . $this->getDBField('CLI_DEFAULTADDR');
 
-                 $this->myDBObj->executeCmd($str_cmd); 
-       * returns the default address 
-         if ($debug) - echo  "<p><b>CLIENT::getPriAddr($debug)</b> ("- . get_class($this)- . ")</p>";
 
-             require_once $GLOBALS['CLIENT']['PHPINCPATH']."ADDRESS.phpclass"; 
-             return new ADDRESS($this->getId(),$this->getPriAddrId(),$this->gDBIDX,$debug); 
-       * sets the default Address ID 
-       * @param int $aId a Address ID 
-         $this->CLI_DEFAULTADDR- = intval($aId);
 
-       * sets the default Address by object 
-       * @note if $addrObj->getId() returns null $address->dbSave() is executed 
-       * @param ADDRESS $addrObj  
-       * @param boolean $saveAddr execute $addrObj->dbSave() after updateing the object 
-       * @param boolean $autosave if true $this->dbSave() is called 
-     function setPriAddr($addrObj,$saveAddr- = TRUE,$debug- = False,$autosave- = False) {
 
-         if ($debug) - echo  "<p><b>CLIENT::setPriAddr(...)</b> ("- . get_class($this)- . ")</p>";
 
-         if (!$this->getId()) return False;  // save the client first to get an id 
-             $addrObj->setCliId($this->getId()); 
-             $addrObj->setPrimary(False,$debug); 
-             if ((!$addrObj->getId()) - ||  $saveAddr) {
 
-             if ($autosave) $this->dbSave(); 
-      * returns an array with all address objects 
-         $arr_filter - =  array('CLI_ID'- =>  $this->getId());
 
-             $orderBy - =  'ADR_ISPRIMARY DESC,ADR_COUNTRY,ADR_ZIP';
 
-             foreach($arr_addrRow as $arr_Addr) 
-     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 
-     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 
-       * sets the user id and updates the Client user Table 
-         if ($debug) - echo  "<p><b>CLIENT::setUSR_ID($aId,$debug)</b> ("- . get_class($this)- . ")</p>";
 
-         if (!$this->getId()) return False; 
-         $query- = "REPLACE INTO T_CLI_USER(CLI_ID,USR_ID) SELECT "- . $this->getId()- . ",USR_ID FROM T_SYS_USER WHERE USR_ID="- . intval($aId);
 
-         // select USR_ID form T_SYS_USER to ensure user exists 
-         // use REPLACE to avoid errors if done twice 
-         // and to keep old values 
-         if ($debug) - echo  "<blockquote><p>$query</p></blockquote>";
 
-         return $GLOBALS[$this->gDBIDX]->executeCmd($query); 
-       * generates a user for the client 
-       * and returns the user ID or False in case of error 
-       * @param string $pwd the clear text version 
-       * @param boolean $enabled  
-     function createUser($login,$pwd,$enabled- = TRUE,$groups- = NULL,$debug- = False,$defaultGrp- = 0) {
 
-         if ($debug) - echo  "<p><b>CLIENT::createUser($login,*****,....)</b> ("- . get_class($this)- . ")</p>";
 
-         if (empty($login) - ||  empty($pwd)) {
 
-         // create a new user object 
-         if (!is_object($o_User)) return False; // something went wrong :-( 
-             'USR_ENABLED'   - =>  intval($enabled),
 
-             'CLI_ID'        - =>  $this->getId(),
 
-         return $o_User->generateUser($a_userData,False,$debug,$defaultGrp); // (userDate,login,debug) 
-       * creates a user from post values 
-       * @param DBMS_FORM $frmObj  
-       * @param int $usrId becomes the userId 
-             if (!- isset ($_POST['DBMSFORMID'])- ||  !intval($_POST['DBMSFORMID'])) {
 
-         $s_arrName- = (- isset ($_POST['FRMARRAYNAME'])- ?  $_POST['FRMARRAYNAME']- :  "DBVAL");
 
-             if ($a_postVals- = $frmObj->getValueArray($_POST[$s_arrName],"",$s_arrName)) {
 
-                 $b_enabled      - = (- isset ($a_postVals['USR_ENABLED'])- ?  intval($a_postVals['USR_ENABLED'])- :  TRUE);
 
-                 $i_defaultGrp   - = (- isset ($a_postVals['GRP_ID'])- ?  intval($a_postVals['GRP_ID'])- :  0);
 
-                 if ($usrId- = $this->createUser($a_postVals['USR_LOGIN'],$a_postVals['USR_PWD'],$b_enabled,NULL,$debug,$i_defaultGrp)) {
 
-                     if ($frmObj->usesTable('T_CLI_USER')) { 
-                         $s_query- = "SELECT * FROM T_CLI_USER WHERE UPPER USR_ID="- . $usrId- . " AND CST_ID="- . $this->getId()- . " AND CLI_ID="- . $this->getCLI_ID();
 
-                         $a_cliUsr- = $this->myDBObj->quickQuery($s_query);
 
-                         foreach($a_cliUsr as $s_key - =>  $m_val) {
 
-                             if (- isset ($a_postVals[$s_key])) {
 
-                                 $a_cliUsr- = $a_postVals[$s_key];
 
-                         $this->myDBObj->replaceArray('T_CLI_USER',$a_cliUsr); 
-                     $frmObj->setError(array('LABEL'- => "Login",'MSG'- => "Benutzername bereits vorhanden"));
 
-     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 
-     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 
-       * @requires CLI_PROFILE.phpclass 
-         $obj_profile->setDBField('CLI_ID',$this->getId()); 
-       * stores profile data to the database 
-       * calls addProfileObj() for each value array 
-       * @param boolean $multiArr    if the profile allows multiple entries is $valArr a single entry or an array of entries? 
-       * @param boolean $dataCheck   check the data by calling 
-       * @returns int     number of rows added 
-     function addProfile($clpId,$valArr,$multiArr- = False,$dataCheck- = TRUE,$debug- = False) {
 
-         if ($debug) - echo  "<p><b>CLIENT::addProfile($clpId,....)</b> ("- . get_class($this)- . ")</p>";
 
-         if (!$this->getId())    return False; 
-         if (!intval($clpId))    return False; 
-         require_once $GLOBALS['OCSP']['DEFAULTCONFPATH']- . "client.conf.phpinc";
 
-         require_once $GLOBALS['CLIENT']['PHPINCPATH']- . "CLI_PROFILE.phpclass";
 
-         if ($debug) - echo  "<blockquote>";
 
-             if ((!$profile->isMultiple()) - ||  (!$multiArr)) {
 
-                 // signle data row processing 
-                 foreach($valArr as $profileData) { 
-                     if ($this->addProfileObj($profile,$profileData,$dataCheck,$debug)) { 
-         if ($debug) - echo  "<p>Returns: <b>$noRows</b></p></blockquote>";
 
-       * stores profile data to the database 
-       * processes only one data row 
-       * @param CLP_PROFILE $profile the profile 
-       * @param array $valArr the posted array 
-       * @param boolean $dataCheck check the data by calling 
-     function addProfileObj(&$profile,$valArr,$dataCheck- = TRUE,$debug- = False) {
 
-         if ($debug) - echo  "<p><b>CLIENT::addProfileObj(...)</b> ("- . get_class($this)- . ")</p>";
 
-         if (!is_object($profile)) return False;  // no profile object 
-         if (!$profile->getId()) return False;   // empty profile 
-         if (!is_array($valArr)) return False;   // no data 
-         if ($debug) - echo  "<blockquote><pre>"- . print_r($valArr,TRUE)- . "</pre></blockquote>";
 
-         if (!empty($valArr['_DBMS_FIELDS'])) { 
-             if ($a_keys- = explode(",",$valArr['_DBMS_FIELDS'])) {
 
-                 while($b_isempty - &&  (- list ($idx,$s_key)- =  each($a_keys))) {
 
-                     if (!empty($valArr[$s_key])) $b_isempty- = False;
 
-                     if ($debug) - echo  "<p>ROW is empty</p>";
 
-         $b_useCurrentUser- = ($this->getId()- == $GLOBALS['USER']->getCliId());
 
-         if ($valArr[$profile->getKeyColName()]- = $this->getProfileKey($profile,$b_useCurrentUser,$debug)) {
 
-             if (($dataCheck) - &&  (!$profile->checkEntryRowArr($valArr,$debug))) {
 
-             if ($profile->isMultiple()) { 
-                 return $profile->insertEntryRow($valArr,$debug); 
-                 return $profile->updateEntryRow($valArr,TRUE,$debug); 
-       * returns the key value to use in the profile 
-       * @param CLI_PROFILE $profile  
-       * @param boolean $useCurrentUser  
-     function getProfileKey(&$profile,$useCurrentUser- = TRUE,$debug- = False) {
 
-         if ($debug) - echo  "<p><b>CLIENT::getProfileData(...)</b> ("- . get_class($this)- . "</p>";
 
-         switch($profile->getKeyColName()) { 
-                 if (($useCurrentUser) - &&  ($GLOBALS['USER']->getCliId()- == $this->getId())) {
 
-                     $pfKey- = $GLOBALS['USER']->getId();
 
-                         ocsp_logError(- __FILE__ ,- __LINE__ ,'no database connection',E_WARNING);
 
-                     $s_query- = "SELECT USR_ID FROM T_CLI_USER WHERE CLI_ID="- . $this->getId()- . " ORDER BY CST_ID";
 
-                 ocsp_logError(- __FILE__ ,- __LINE__ ,"<p>CLIENT::getProfileData <b>"- . $profile->getKeyColName()- . " not implemented</p>");
 
-       * returns an array with the profileData of the client 
-       * retValue is array['ROW_NR'][COL] 
-       * @param CLI_PROFILE $profile  
-       * @param boolean $useCurrentUser  
-     function getProfileData(&$profile,$useCurrentUser- = TRUE,$debug- = False) {
 
-             return $profile->getEntryRowArray($pfKey,$debug); 
-       * returns a DB-RowArray of profile 
-       * @param CLI_PROFILE $profile  
-       * @param boolean $useCurrentUser  
-         return $profile->getEntryRow($pfKey,$clpidx,$debug); 
-       * deletes all profile entries for the user 
-       * @param CLP_PROFILE $profile  
-       * @param boolean $useCurrentUser  
-         if ($debug) - echo  "<p><b>CLIENT::clearProfileData("- . $profile->getId()- . ")</b> ("- . get_class($this)- . ")</p>";
 
-         if (!$GLOBALS['USER']->canEditClient($this->getId(),$debug)) { 
-         if ($pfKey- = $this->getProfileKey($profile,$useCurrentUser,$debug)) {
 
-             $profile->deleteEntryRow($pfKey,0,$debug); 
-       * replaces all profile data 
-       * @param CLP_PROFILE $profile  
-       * @param array $pfDataArr  
-       * @param boolean $useCurrentUser  
-         if ($debug) - echo  "<p><b>CLIENT::replaceProfileData("- . (is_object($profile)- ?  $profile->getId()- :  "NO PROFILE")- . ",...)</b> ("- . get_class($this)- . ")</p>";
 
-         if (!is_array($pfDataArr)) return False; 
-         if ($debug) - echo  "<blockquote>";
 
-             foreach($pfDataArr as $i_pfNr - =>  $a_pfData) {
 
-                 if ($this->addProfileObj($profile,$a_pfData,TRUE,$debug)) $i_noPf- ++ ;
 
-         if ($debug) - echo  "</blockquote>";
 
-      * returns an profile entry object 
-      * @return CLI_PROFILE_ENTRY  
-     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
-     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
-       * adds TableObject Contents to domRoot 
-       * @param mixed &$domObj           //reference to Parent DomObject 
-       * @param string $domRoot      //reference to Parent DomRoot 
-             $query - = "SELECT * FROM T_ADDRESS WHERE CLI_ID = "- . $this->getId();
 
-             if($cursor- = $this->myDBObj->query($query)) {
 
-                     $valRoot - =  $domObj->createElement("ADR_LST");
 
-                     $domRoot->appendChild($valRoot); 
-                     while($AdrRow- = $cursor->fetchArray()) {
 
-                         $AdrObj->setDBRow($AdrRow,TRUE,$debug); 
-                         $AdrObj->xmladdDOMElement($domObj,$valRoot,$base64,$debug); 
-             $query - = "SELECT * FROM T_CLI_STAFF WHERE CLI_ID = "- . $this->getId();
 
-             if($cursor- = $this->myDBObj->query($query)) {
 
-                 require_once $GLOBALS['CLIENT']['PHPINCPATH']- . "CLI_STAFF.phpclass";
 
-                 $valRoot - =  $domObj->createElement("STAFF_LST");
 
-                 $domRoot->appendChild($valRoot); 
-                 while($AdrRow- = $cursor->fetchArray()) {
 
-                     $AdrObj->setDBRow($AdrRow,TRUE,$debug); 
-                     $AdrObj->xmladdDOMElement($domObj,$valRoot,$base64,$debug); 
-             $query - = "SELECT * FROM T_CLI_USER WHERE CLI_ID = "- . $this->getId();
 
-             $query- .=  " AND CST_ID = 0";
 
-             if($cursor- = $this->myDBObj->query($query)) {
 
-                 require_once $GLOBALS['CLIENT']['PHPINCPATH']- . "CLI_STAFF.phpclass";
 
-                 $valRoot - =  $domObj->createElement("USER_LST");
 
-                 $domRoot->appendChild($valRoot); 
-                 while($UsrRow- = $cursor->fetchArray()) {
 
-                     $UsrObj->myTable - =  "T_CLI_USER";
 
-                     $UsrObj->setDBRow($UsrRow,TRUE,$debug); 
-                     $UsrObj->xmladdDOMElement($domObj,$valRoot,$base64,$debug); 
-     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
-     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
-     // since TBL_VERSION 17 (pk-05-09-20) the colum CLI_STATE is added 
-     // CLI_STATE > 0 are treatened as active clients 
-     // CLI_STATE < 0 are treatened as disabled/deleted clients 
-       * activates the client (state=1 if < 1) 
-         if (intval($this->CLI_STATE) - <  1) {
 
-         return (intval($this->CLI_STATE) - >  0);
 
-     function setState($clsId,$debug- = False) {
 
-     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
-     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
-       * returns an array with staffId's 
-       * @version pk-06-05-15 debugging 
-         $s_query - = "SELECT CST_ID FROM T_CLI_STAFF";
 
-         $s_query- .= " WHERE CLI_ID="- . $this->getId();
 
-             $s_query- .= " AND CTY_ID="- . intval($ctyId);
 
-             $s_query- .= " AND CLS_ID="- . intal($clsId);
 
-         if ($debug) - echo  "<p>Query: $s_query</p>";
 
-             ocsp_logError(- __FILE__ ,- __LINE__ ,"no database connection",E_ERROR);
 
-         $a_ret- = $this->myDBObj->queryArray($s_query,0,0);
 
-         if ($debug) - echo  "<p>Result: </p><pre>"- . print_r($a_ret,TRUE)- . "</pre>";
 
-      * returns an array of staff objects 
-      * @return array (of CLI_STAFF* objects) 
-      * @version pk-08-07-30 $orderBy added 
-     function getSaffList($csttypeId- = 0,$orderBy- = "",$debug- = False)
 
-         $arr_filter - =  array('CLI_ID'- =>  $this->getId());
 
-             $arr_filter['CSTTYPE_ID'] - =  $csttypeId;
 
-             $str_table - =  'T_CLI_STAFF';
 
-             $str_table - =  'T_CLI_STAFF LEFT OUTER JOIN T_CLI_STAFF_TYPE USING(CSTTYPE_ID)';
 
-             $str_order - =  'CSTTYPE_SORTORDER,';
 
-             $orderBy - =  $str_order- .  'CST_FIRSTNAME,CST_LASTNAME';
 
-             foreach($arr_cstRow as $arr_staff) 
-       * @param int $cstId the id 
-       * @param boolean $useCliData if TRUE the data from the client fits into staff are copied 
-       * @version pk-08-08-20 // use identity map 
-     function getStaff($cstId- = 0,$useCliData- = False,$debug- = False)
 
-             if ($obj_ret->getCliId() - !=  $this->getId())
 
-             $this->getTypeObj(); // ensure $this->myTypeObj is set propper 
-         $obj_ret->setClient($this); 
-             $obj_ret->setClientValuesToStaff($debug); 
-     // ------------------------------------------------------ 
-     // ------------------------------------------------------ 
-       * returns if the current user is allowed for mode 
-     function userCan($frmMode- = 0,$debug- = False) {
 
-         if ($GLOBALS['USER']->isGroupMember($GLOBALS['GROUPS']['CLIENT-ADMIN'])) { 
-             // user is client admin no need to proceed with checks 
-       * returns if the current user can show the client data 
-       * @global array $OCSP_OBJ  
-       * @version pk-07-01-15 return if the user can edit 
-             // empty clients can be viewed by every one :-) 
-             // user is client admin no need to proceed with checks 
-         $this->getTypeObj(); // to ensure $this->myTypeObj is set 
-         // finaly check if the client is staff of the user 
-             ocsp_logError(- __FILE__ ,- __LINE__ ,"no database connection",E_WARNING);
 
-         $s_query- = "SELECT COUNT(*) FROM T_CLI_USER WHERE CLI_ID="- . $this->getId()- . " AND USR_ID="- . OCSP_OBJ::currentUser()->getId();
 
-         if ($i_count- = intval($this->myDBObj->quickQuery($s_query,0))) return TRUE;
 
-       * returns if the current user can edit the client data 
-             // empty or new clients can be edited by every one as they are not in the DB 
-             // user is client admin no need to proceed with checks 
-         $this->getTypeObj(); // to ensure $this->myTypeObj is set 
-             // finaly check if the client is staff of the user 
-                 ocsp_logError(- __FILE__ ,- __LINE__ ,"no database connection",E_NOTICE);
 
-             $s_query- = "SELECT COUNT(*) FROM T_CLI_USER WHERE CLI_ID="- . $this->getId()- . " AND USR_ID="- . OCSP_OBJ::currentUser()->getId();
 
-             if ($i_count- = intval($this->myDBObj->quickQuery($s_query,0))) return TRUE;
 
-       * returns if the current user can edit the client data 
-             // user is client admin no need to proceed with checks 
-         $this->getTypeObj(); // to ensure $this->myTypeObj is set 
-       * returns if the current user is an admin for the client 
-       * first checks common and type rights and then T_CLI_USER.CLU_ISADMIN 
-             // user is client admin no need to proceed with checks 
-         $this->getTypeObj(); // to ensure $this->myTypeObj is set 
-             $s_query - = "SELECT COUNT(*) FROM T_CLI_USER ";
 
-             $s_query- .= " WHERE CLI_ID="- . $this->getId();
 
-             $s_query- .= "   AND USR_ID="- . $GLOBALS['USER']->getId();
 
-             $s_query- .= "   AND CLU_ISADMIN=1";
 
 
	
		Documentation generated on Thu, 08 Jan 2009 17:37:47 +0100 by phpDocumentor 1.4.0a2