Source for file DBMS_FIELD_GROUPSELECT.phpclass

Documentation is available at DBMS_FIELD_GROUPSELECT.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_GROUPSELECT.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   int
  8.   *
  9.   * @author     Peter Krebs <p.krebs@lvus.at>
  10.   * @copyright  (c) 2002-2005 by LVUS <http://www.lvus.at>
  11.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  12.   *
  13.   * @version $Id: DBMS_FIELD_GROUPSELECT.phpclass,v 1.6 2008/06/05 08:38:53 pitlinz Exp $
  14.   */
  15.  
  16. pcf_require_class('DBMS_FIELD_SELECTLIST',dirname(__FILE___OCSP_DIRSEP_ "DBMS_FIELD_FOREIGNKEY.phpclass");
  17.  
  18.  
  19. /**
  20.   * Class DBMS_FIELD_GROUPSELECT
  21.   *
  22.   * @project    Open CSP-Management
  23.   * @package    dbms_field
  24.   * @category   int
  25.   *
  26.   * @author     Peter Krebs <p.krebs@lvus.at>
  27.   * @copyright  (c) 2002-2005 by LVUS <http://www.lvus.at>
  28.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  29.   *
  30.   * @version $Id: DBMS_FIELD_GROUPSELECT.phpclass,v 1.6 2008/06/05 08:38:53 pitlinz Exp $
  31.   */
  32.     extends DBMS_FIELD_SELECTLIST 
  33. {
  34.     var $className          = "GroupSelectList";
  35.     
  36.     /**
  37.       * source file of the class
  38.       *
  39.       * @var string $classSrcFile 
  40.       * @since pk-05-01-20
  41.       ***/
  42.     protected $classSrcFile=__FILE__;    
  43.     
  44.     var $allowNullSelect    = True;
  45.     var $nullLabel          = "PUBLIC";
  46.  
  47.     /**
  48.       * @var stirng $loggedInLabel Screen/List Value of Group with ID: $GLOBALS['GROUPS']['LOGGEDIN']
  49.       * @since pk-05-06-15
  50.       ***/
  51.     protected $loggedInLabel      = "Angemeldet";
  52.     /**
  53.       * @var stirng $notLoggedInLabel Screen/List Value of Group with ID: $GLOBALS['GROUPS']['NOTLOGGEDIN']
  54.       * @since pk-05-06-15
  55.       ***/
  56.     protected $notLoggedInLabel   = "(noch) Nicht Angemeldet";
  57.  
  58.     /**
  59.       * @var boolean $withoutSystemGroups do not add groups with id < 0
  60.       * @since pk-06-12-18
  61.       ***/
  62.     protected $withoutSystemGroups=FALSE;
  63.  
  64.     /**
  65.       * @var boolean $selfselectGrpsOnly only show groups which are selfselectable by the user
  66.       * @since pk-06-12-18
  67.       ***/
  68.     protected $selfselectGrpsOnly=FALSE;
  69.  
  70.     /**
  71.       * @var boolean $requireMember current user must be member of the selected group
  72.       * @since pk-06-12-18
  73.       ***/
  74.     protected $requireMember=FALSE;
  75.  
  76.     /**
  77.       * @var boolean $requireAdmin current user must be admin of the selected group
  78.       * @since pk-06-12-18
  79.       ***/
  80.     protected $requireAdmin=FALSE;
  81.  
  82.     /**
  83.       * @var boolean $showAsTree show the groups as tree
  84.       * @since pk-07-01-07
  85.       ***/
  86.     protected $showAsTree=FALSE;
  87.  
  88.  
  89.     // ###########################################################
  90.     // OBJECT SETTINGS METHODS
  91.     // ###########################################################
  92.  
  93.     /**
  94.       * returns an array of field to bie shown in the edit form
  95.       * by using editTbl_echoForm
  96.       *
  97.       * the array is in the form:
  98.       *
  99.       * <code>
  100.       * [_sectionName_]
  101.       *      [TITLE] -> string
  102.       *      [_rowName_]
  103.       *         [FLDLAB]  (complete html code with <td></td>)
  104.       *         [FLDVAL] (complete html code with <td></td>)
  105.       * </code>
  106.       *
  107.       * @param boolean $debug 
  108.       *
  109.       * @returns array
  110.       *
  111.       * @version pk-06-12-18
  112.       * @version pk-08-06-02
  113.       */
  114.     function editTbl_getFieldEditArr($debug=FALSE{
  115.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_TREEPARENTSELECT::editTbl_getFieldEditArr","",0);
  116.  
  117.         if (empty($this->nullLabel)) $this->nullLabel="Public";
  118.  
  119.         $a_ret=parent::editTbl_getFieldEditArr($debug);
  120.  
  121.         unset($a_ret['SELECT']['FLD_MULTISEL']);
  122.         unset($a_ret['VALCHECKS']['FLDNULLTOZERO']);
  123.         unset($a_ret['VALCHECKS']['FLD_EMPTYSELECT']);
  124.         unset($a_ret['VALCHECKS']['FLD_FRMRELOAD']);
  125.         
  126.         unset($a_ret['SELECT']['FLD_LSTVALS']);
  127.         unset($a_ret['SELECT']['FLD_LSTVALISHTML']);
  128.  
  129.         include __OCSP_PHPINCPATH__ "db" _OCSP_DIRSEP_ "forms" _OCSP_DIRSEP_ "languages" _OCSP_DIRSEP_ "DBMS_FIELD_GROUPSELECT_FieldEditArr.de.phpinc";
  130.         
  131.         return $a_ret;
  132.     }
  133.  
  134.     /**
  135.       * save the posted fielddefinition
  136.       *
  137.       * @returns boolean
  138.       *
  139.       * @version pk-06-12-18
  140.       * @version pk-08-03-12
  141.       ***/
  142.     function save({
  143.         $ret parent::save();
  144.                 
  145.         // <pk-06-12-18>
  146.         $this->requireMember       = ((isset($_POST['requireMember']&& intval($_POST['requireMember'])) TRUE FALSE);
  147.         $this->requireAdmin        = ((isset($_POST['requireAdmin']&& intval($_POST['requireAdmin'])) TRUE FALSE);
  148.         $this->withoutSystemGroups = ((isset($_POST['withoutSystemGroups']&& intval($_POST['withoutSystemGroups'])) TRUE FALSE);
  149.         $this->selfselectGrpsOnly  = ((isset($_POST['selfselectGrpsOnly']&& intval($_POST['selfselectGrpsOnly'])) TRUE FALSE);
  150.         // </pk-06-12-18>
  151.  
  152.         $this->lstValueIsHtml       = False;
  153.         
  154.         return $ret;
  155.     }
  156.  
  157.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  158.     //          db methods
  159.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  160.  
  161.     
  162.     
  163.     /**
  164.       * populates $this->myValues array from OCSP_GROUPTREE
  165.       *
  166.       * @param string $arrName 
  167.       * @param boolean $debug 
  168.       *
  169.       * @since pk-08-03-12
  170.       * @version pk-08-05-28
  171.       */
  172.     function setMyValues($arrName=NULL,$debug=FALSE)
  173.     {
  174.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_GROUPSEL::setMyValues()");
  175.         pcf_require_class('OCSP_GROUPTREE',__OCSP_PHPINCPATH__ "user" _OCSP_DIRSEP_ "OCSP_GROUPTREE.phpclass");
  176.         
  177.         $obj_grpTree OCSP_GROUPTREE::getInstance();
  178.         
  179.         $arr_groups $obj_grpTree->getUserGroupTreeArray($debug);
  180.         
  181.         $this->myValues=array(
  182.                 _OCSP_GROUP_LOGGEDIN_         => $this->loggedInLabel,
  183.                 _OCSP_GROUP_NOTLOGGEDIN_      => $this->notLoggedInLabel,
  184.                 _OCSP_GROUP_PUBLIC_            => "Public"
  185.             );
  186.         
  187.         foreach($arr_groups as $str_id => $arr_grp)
  188.         {
  189.             if (!$this->withoutSystemGroups || ($arr_grp['ROW']['GRP_ID'99))
  190.             {
  191.                 if ($arr_grp['SHOW'])
  192.                 {
  193.                     if ($arr_grp['ADMIN'])
  194.                     {
  195.                         $this->myValues[$arr_grp['ROW']['GRP_ID']] $arr_grp['TREEIDX'" " $arr_grp['ROW']['GRP_NAME'"*";
  196.                     else if ($arr_grp['MEMBER']{
  197.                         $this->myValues[$arr_grp['ROW']['GRP_ID']] $arr_grp['TREEIDX'.  " " $arr_grp['ROW']['GRP_NAME'];
  198.                     else {
  199.                         $this->myValues[$arr_grp['ROW']['GRP_ID']] "[" $arr_grp['TREEIDX'.  " " $arr_grp['ROW']['GRP_NAME'"]";
  200.                     }
  201.                 }
  202.             }
  203.         }
  204.         
  205.         return true;
  206.         
  207.     }
  208.  
  209.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  210.     //          form methods
  211.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  212.  
  213.  
  214.     /**
  215.       * returns the field value if the referenzed row exists
  216.       *
  217.       * @param  string  $aValue     the value
  218.       * @param  array   $err        error array
  219.       * @param  string  $arrName    name of the array to access fieldsarray  gloabl ${$arrName}
  220.       * @param  bool    $debug 
  221.       *
  222.       * @return string 
  223.       *
  224.       * @since   pk-05-06-16
  225.       *
  226.       ***/
  227.     function getValue($aValue,&$err,$arrName="DBVAL",$debug=FALSE{
  228.         $debug ($debug || $this->fldDebug || $this->fldDbgGetValue);
  229.         if ($debugecho "<p><b>DBMS_FIELD_GROUPSELECT::getValue($aValue,$err,$arrName,$debug)</b> (".get_class($this)." | ".$this->myName.")</p>";
  230.  
  231.         if (in_array(intval($aValue),$GLOBALS['GROUPS'])) {
  232.             return intval($aValue);
  233.         else {
  234.             return parent::getValue($aValue,$err,$arrName,$debug=FALSE);
  235.         }
  236.     }
  237.  
  238.     /**
  239.       * returns the screen repesantation of the key (not the key !!!)
  240.       *
  241.       * @param mixed $aValue 
  242.       * @param string $arrName 
  243.       * @param boolean $debug 
  244.       *
  245.       * @return string 
  246.       *
  247.       * @since   pk-05-06-16
  248.       *
  249.       ***/
  250.     function getScreenValue($aValue,$arrName="DBVAL",$debug=FALSE{
  251.         $debug ($debug || $this->fldDebug);
  252.         if ($debugecho "<p><b>DBMS_FIELD_GROUPSELECT::getScreenValue($aValue,$arrName,...)</b> (".get_class($this)." | ".$this->myName.")</p>";
  253.  
  254.         if (intval($aValue== $GLOBALS['GROUPS']['NOTLOGGEDIN']return $this->notloggedInLabel;
  255.         if (intval($aValue== $GLOBALS['GROUPS']['LOGGEDIN'])    return $this->loggedInLabel;
  256.         return parent::getScreenValue($aValue,$arrName,$debug);
  257.     }
  258. }
  259. ?>

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