Source for file DBMS_FIELD_CURRENTUSER.phpclass

Documentation is available at DBMS_FIELD_CURRENTUSER.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_CURRENTUSER.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   any
  8.   *
  9.   * @author     Peter Krebs <pitlinz@users.sourceforge.net>
  10.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  11.   *
  12.   * @version $Id: DBMS_FIELD_CURRENTUSER.phpclass,v 1.7 2008/10/05 20:47:25 pitlinz Exp $
  13.   */
  14.  
  15. pcf_require_class('DBMS_FIELD_FOREIGNKEY',dirname(__FILE__"/");
  16.  
  17. /**
  18.   * sets db field to $_SESSION['USER_ID'] on changes or show the Login for the stored id
  19.   *
  20.   * the field is always shown in read only modus
  21.   * if insert or update is enabled $_SESSION['USER_ID'] is
  22.   * returned for an value passed to check
  23.   *
  24.   * @project    Open CSP-Management
  25.   * @package    dbms_field
  26.   * @category   any
  27.   *
  28.   * @author     Peter Krebs <pitlinz@users.sourceforge.net>
  29.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  30.   *
  31.   * @version pk-07-01-09 DBMS_FIELD_INT -> DBMS_FIELD_FOREIGNKEY
  32.   *
  33.   * @version $Id: DBMS_FIELD_CURRENTUSER.phpclass,v 1.7 2008/10/05 20:47:25 pitlinz Exp $
  34.   */
  35.     
  36.     // ---------------------------------------------------------------------------
  37.     // constants
  38.     // ---------------------------------------------------------------------------
  39.     
  40.     /**
  41.      * @constant string CLASS_SRC_FILE
  42.      */
  43.     const CLASS_SRC_FILE = __FILE__;
  44.  
  45.     // ---------------------------------------------------------------------------
  46.     // class (static)
  47.     // ---------------------------------------------------------------------------
  48.     
  49.     /*** class vars ------------------------------------------------------ */
  50.  
  51.     /*** class methods --------------------------------------------------- */    
  52.     
  53.     // ---------------------------------------------------------------------------
  54.     // object vars
  55.     // ---------------------------------------------------------------------------
  56.     
  57.     /*** compostion --------------------------------------------------- */
  58.     
  59.     /*** attributes --------------------------------------------------- */
  60.     
  61.     /**
  62.      * name of the class
  63.      *
  64.      * @var string $className 
  65.      */
  66.     protected $className     = "CURRENTUSER";
  67.         
  68.     /**#@+
  69.        * overwrite parent settings
  70.        * 
  71.        * @var string
  72.        * @since pk-08-10-05
  73.        */
  74.     protected $lookupTable          ="T_SYS_USER";
  75.     protected $lookupField          ="USR_ID";
  76.  
  77.     protected $lookupShowField      ="CONCAT(USR_LOGIN,' (',USR_ID,'/',GRP_ID,')')";
  78.     protected $lookupShowLstField   ="USR_LOGIN";
  79.     protected $lookupSort           ="USR_LOGIN";  
  80.     /**#@-*/
  81.     
  82.  
  83.     /**
  84.       * source file of the class
  85.       *
  86.       * @var string $classSrcFile 
  87.       * @since pk-05-01-20
  88.       ***/
  89.     protected $classSrcFile=__FILE__;
  90.  
  91.     // ---------------------------------------------------------------------------
  92.     // factory / construct
  93.     // ---------------------------------------------------------------------------
  94.  
  95.     // ---------------------------------------------------------------------------
  96.     // init
  97.     // ---------------------------------------------------------------------------
  98.  
  99.     /**
  100.       * convert old object vars to DBMS_FIELD_DBLOOKUPSELECTLIST
  101.       * and then calls the parent method
  102.       *
  103.       * @param array $varArr 
  104.       * @param boolean $debug 
  105.       *
  106.       * @since pk-07-09-20
  107.       */
  108.     function setObjectVars($varArr,$debug=FALSE)
  109.     {
  110.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_CURRENTUSER::setObjectVars(...)",print_r($varArr,TRUE));
  111.  
  112.         parent::setObjectVars($varArr,$debug);
  113.  
  114.         $this->lookupTable          ="T_SYS_USER";
  115.         $this->lookupField          ="USR_ID";
  116.  
  117.         $this->lookupShowField      ="CONCAT(USR_LOGIN,' (',USR_ID,'/',GRP_ID,')')";
  118.         $this->lookupShowLstField   ="USR_LOGIN";
  119.         $this->lookupSort           ="USR_LOGIN";
  120.     }
  121.  
  122.     // ---------------------------------------------------------------------------
  123.     // dbms admin backoffice 
  124.     // ---------------------------------------------------------------------------    
  125.         
  126.     /**
  127.       * returns an array of field to bie shown in the edit form
  128.       * by using editTbl_echoForm
  129.       *
  130.       * the array is in the form:
  131.       *
  132.       * <code>
  133.       * [_sectionName_]
  134.       *      [TITLE] -> string
  135.       *      [_rowName_]
  136.       *         [FLDLAB]  (complete html code with <td></td>)
  137.       *         [FLDVAL] (complete html code with <td></td>)
  138.       * </code>
  139.       *
  140.       * @param boolean $debug 
  141.       *
  142.       * @returns array
  143.       *
  144.       * @since pk-07-01-09
  145.       *
  146.       ***/
  147.     function editTbl_getFieldEditArr($debug=FALSE{
  148.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_CURRENTUSER::editTbl_getFieldEditArr","",0);
  149.  
  150.         if (empty($this->keyField)) $this->keyField=$this->myName// <pk-06-11-29 />
  151.         $a_ret=parent::editTbl_getFieldEditArr($debug);
  152.  
  153.         unset($a_ret['SELECT']);
  154.         unset($a_ret['DBLOOKUP']);
  155.         unset($a_ret['FTBL_POPUPS']);
  156.  
  157.         return $a_ret;
  158.     }
  159.  
  160.     /**
  161.       * save the filed definition form
  162.       *
  163.       * @returns bool <code>parent::save()</code>
  164.       *
  165.       * @since pk-07-01-09
  166.       *
  167.       ***/
  168.     function save($debug=FALSE{
  169.         $ret=parent::save($debug);
  170.  
  171.         $this->lookupTable          ="T_SYS_USER";
  172.         $this->lookupField          ="USR_ID";
  173.  
  174.         $this->lookupShowField      ="CONCAT(USR_LOGIN,' (',USR_ID,'/',GRP_ID,')')";
  175.         $this->lookupShowLstField   ="USR_LOGIN";
  176.         $this->lookupSort           ="USR_LOGIN";
  177.  
  178.         return $ret;
  179.     }
  180.  
  181.     // ###########################################################
  182.     // OBJECT DATA METHODS
  183.     // ###########################################################
  184.  
  185.  
  186.     
  187.     
  188.     // ###########################################
  189.  
  190.  
  191.     /**
  192.       * returns the field value if the referenzed row exists
  193.       *
  194.       * @param  string  $aValue     the value
  195.       * @param  array   $err        error array
  196.       * @param  string  $arrName    name of the array to access fieldsarray  gloabl ${$arrName}
  197.       * @param  bool    $debug 
  198.       *
  199.       * @global array $OCSP_OBJ 
  200.       *
  201.       * @returns int
  202.       *
  203.       * @since   pk-07-01-16
  204.       *
  205.       ***/
  206.     function getValue($aValue,&$err,$arrName="DBVAL",$debug=FALSE{
  207.         global $OCSP_OBJ;
  208.         
  209.         $debug ($debug || $this->fldDebug || $this->fldDbgGetValue);
  210.         if ($debug{
  211.             echoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_FOREIGNKEY::getValue()","\$aValue$aValue");
  212.             echoDebug(__FILE__,"<blockquote><pre style=\"font-size:75%\">".print_r($this->dbDesc,TRUE)."</pre><p>VALUE$aValue</p>");
  213.         }
  214.         if (!intval($aValue)) {
  215.             return $OCSP_OBJ['USER']->getId();
  216.         else {
  217.             return parent::getValue($aValue,$err,$arrName,$debug);
  218.         }
  219.     }
  220.  
  221.     /**
  222.       *
  223.       * returns the html code for the readonly field
  224.       *
  225.       * if is_array($aValue) a list (&lt;ul&gt;) is returned
  226.       *
  227.       * @param mixed $aValue 
  228.       * @param string $arrName 
  229.       * @param boolean $debug 
  230.       *
  231.       * @returns string
  232.       *
  233.       * @since pk-08-07-03
  234.       *  
  235.       */
  236.     function getScreenValue($aValue,$arrName="DBVAL",$debug=FALSE{
  237.         $debug=($debug || $this->fldDebug || $this->fldDbgGetValue);
  238.         if ($debugechoDebugMethod(__FILE__,__LINE__,"DBMS_FIELD_CURRENTUSER::getScreenValue($aValue)",0);
  239.  
  240.         return parent::getScreenValue(abs(intval($aValue)),$arrName,$debug);
  241.     }    
  242.     
  243. }
  244. ?>

Documentation generated on Thu, 08 Jan 2009 17:40:50 +0100 by phpDocumentor 1.4.0a2