Source for file CLI_TYPE.phpclass

Documentation is available at CLI_TYPE.phpclass

  1. <?php
  2. /**
  3.   * Class file CLI_TYPE.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    client
  7.   *
  8.   * @author     Peter Krebs <p.krebs@wpus.at>
  9.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  10.   *
  11.   * @since pk-06-10-02
  12.   *
  13.   * @version $Id: CLI_TYPE.phpclass,v 1.12 2008/12/02 15:08:57 peterkrebs Exp $
  14.   */
  15.  
  16.     // -------------------------------------------
  17.     // requires
  18.     // -------------------------------------------
  19.  
  20.     require_once __OCSP_DEFAULTCONFPATH__."client.conf.phpinc";
  21.     
  22.     pcf_require_class('DBMS_TABLEOBJ',"db/");
  23.     pcf_require_class('CLIENT',"client/");
  24.     pcf_require_class('CLI_STAFF_TYPE',"client/");
  25.     pcf_require_class('CLI_FORM',"client/");
  26.     pcf_require_class('INTEREST',"client/");
  27.       
  28.  
  29. /**
  30.   * Class file CLI_TYPE.phpclass
  31.   *
  32.   * @project    Open CSP-Management
  33.   * @package    client
  34.   *
  35.   * @author     Peter Krebs <p.krebs@wpus.at>
  36.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  37.   *
  38.   * @since pk-06-10-02
  39.   *
  40.   * @version $Id: CLI_TYPE.phpclass,v 1.12 2008/12/02 15:08:57 peterkrebs Exp $
  41.   */
  42. class CLI_TYPE extends DBMS_TABLEOBJ 
  43. {
  44.  
  45.     // ---------------------------------------------------------------------------
  46.     // constants
  47.     // ---------------------------------------------------------------------------
  48.     
  49.     /**
  50.       * @constant string CLASS_SRC_FILE
  51.       * @since pk-08-02-04
  52.       */
  53.     const CLASS_SRC_FILE = __FILE__;       
  54.     
  55.     // ---------------------------------------------------------------------------
  56.     // class (static)
  57.     // ---------------------------------------------------------------------------
  58.     
  59.     /*** class vars ------------------------------------------------------ */
  60.     
  61.     /**
  62.      * identity map
  63.      *
  64.      * @staticvar array $myStaffList 
  65.      */
  66.     protected static $loadedCliTypes array();
  67.     
  68.     /*** class methods --------------------------------------------------- */
  69.     
  70.     /**
  71.      * returns an instance out of the identity map
  72.      *
  73.      * @param int $aId 
  74.      * @param boolean $debug 
  75.      * 
  76.      * @return CLI_TYPE 
  77.      */
  78.     public static function &getInstance($aId,$debug=False)
  79.     {
  80.         if (!isset(self::$loadedCliTypes[$aId]))
  81.         {
  82.             self::$loadedCliTypes[$aIdself::factoryFromId($aId,$debug);
  83.         
  84.  
  85.         return self::$loadedCliTypes[$aId];
  86.     }
  87.     
  88.     /**
  89.      * returns an array with all instances
  90.      * 
  91.      * @var array $filter 
  92.      * @var boolean $debug 
  93.      * 
  94.      * @return array 
  95.      */
  96.     public static function getInstanceList($filter=Null,$debug=False)
  97.     {
  98.         if ($debugechoDebugMethod(__FILE__,"static","CLI_TYPE::getAllInstances()",print_r($filter,True));
  99.         
  100.         $arr_typeRows OCSP_OBJ::defaultReadDBObj()->getArray('T_CLI_TYPE',$filter);
  101.         $arr_ret array();
  102.         //$arr_ret[0] = self::getInstance(0);
  103.         foreach($arr_typeRows as $arr_row)
  104.         {
  105.             if (!pcf_is_instance_of(self::$loadedCliTypes[$arr_row['CTY_ID']],'CLI_TYPE'))
  106.             {
  107.                 self::$loadedCliTypes[intval($arr_row['CTY_ID'])new CLI_TYPE();
  108.                 self::$loadedCliTypes[intval($arr_row['CTY_ID'])]->setDBRow($arr_row,True);
  109.             }
  110.             $arr_ret[intval($arr_row['CTY_ID'])&self::$loadedCliTypes[intval($arr_row['CTY_ID'])];
  111.         }
  112.     
  113.         return $arr_ret;
  114.         
  115.     }
  116.     
  117.     // ---------------------------------------------------------------------------
  118.     // object vars
  119.     // ---------------------------------------------------------------------------
  120.     
  121.  
  122.     /**
  123.       * @staticvar string $myTable name of the db table
  124.       */
  125.     var $myTable="T_CLI_TYPE";
  126.     
  127.     /**
  128.      * unit of work address objects
  129.      *
  130.      * @staticvar array $clientTypeLst 
  131.      */
  132.     static $clientTypeLst array();    
  133.  
  134.     // ---------------------------------------------------------------------------
  135.     // factory / construct
  136.     // ---------------------------------------------------------------------------
  137.     
  138.     public static function factoryFromId($aId)
  139.     {
  140.         $obj_ret new CLI_TYPE();
  141.         $obj_ret->setId(intval($aId));
  142.         $obj_ret->dbPopulate();
  143.         
  144.         return $obj_ret;        
  145.     }
  146.     
  147.     /**
  148.       * init the object and populate if an id is submitted
  149.       *
  150.       * @param int $cliId CLI_ID
  151.       * @param int $cstId 
  152.       * @param bool $debug 
  153.       *
  154.       * @version pk-07-08-29
  155.       *
  156.       ***/
  157.     function CLI_TYPE($ctyId=0,$debug=False{
  158.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_TYPE::CLI_TYPE($ctyId)");;
  159.         $this->init($debug);
  160.         if ($ctyId{
  161.             $this->setId($ctyId);
  162.             $this->dbPopulate($debug);
  163.         else {
  164.             $this->setDefaults();
  165.         }
  166.     }
  167.  
  168.  
  169.     /**
  170.       * returns the id
  171.       * @return int 
  172.       ***/
  173.     function getId({
  174.         return intval($this->getDBField('CTY_ID'));
  175.     }
  176.  
  177.     /**
  178.       * sets the id
  179.       * @param int $aId 
  180.       ***/
  181.     function setId($aId{
  182.         $this->setDBField('CTY_ID',intval($aId));
  183.     }
  184.  
  185.     /**
  186.       * returns the name of the staff
  187.       * @return string 
  188.       ***/
  189.     function getName({
  190.         if (!($str_name $this->getDBField('CTY_NAME')) || empty($str_name))
  191.         {
  192.             if ($this->getid(== 0$str_name t_admin('Default');
  193.         }
  194.         return $str_name;
  195.     }
  196.     
  197.     /**
  198.      * in future it is planed to be able to split the clients into more than one table
  199.      * therefore the type must know wher to search
  200.      */
  201.     public function getClientTableName()
  202.     {
  203.         return "T_CLI_CLIENT";
  204.     }
  205.  
  206.     /**
  207.       * returns if the type has profiles enabled
  208.       *
  209.       * @param boolean $doDBCheck check if there are also profiles defined in the databas
  210.       * @param boolean $debug 
  211.       *
  212.       * @return boolean 
  213.       ***/
  214.     function hasProfiles($doDBCheck=False,$debug=False{
  215.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_TYPE::hasProfiles()");
  216.  
  217.         if (intval($this->getDBField('CTY_HASPROFILES'))) {
  218.             if ($doDBCheck)
  219.             {
  220.                 if (!$this->isConnected(True,$debug))
  221.                 {
  222.                     ocsp_logError(__FILE__,__LINE__,"no database connection",E_WARNING);
  223.                     return False;
  224.                 }
  225.                 $s_query="SELECT COUNT(*) FROM T_CLI_PROFILES WHERE CLP_KEYTABLE='T_CLI_CLIENT' AND (CTY_ID=".$this->getId()." OR CTY_ID=0)";
  226.                 if ($debugechoDebug(__FILE__,"<p>Checking DB$s_query</p>");
  227.                 if (intval($this->myDBObj->quickQuery($s_query,0))) {
  228.                     return True;
  229.                 else {
  230.                     return False;
  231.                 }
  232.             else {
  233.                 return True;
  234.             }
  235.         else {
  236.             return False;
  237.         }
  238.  
  239.     }
  240.  
  241.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  242.     // client methods
  243.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  244.  
  245.     /**
  246.       * includes the client class source file
  247.       *
  248.       * @param boolean $debug 
  249.       *
  250.       * @return boolean 
  251.       *
  252.       ***/
  253.     function incCliClassSource($debug=False{
  254.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_TYPE::incCliClassSource()");
  255.  
  256.         $s_Src=$this->getDBField('CTY_CLASSFILE');
  257.         
  258.         if ($debugechoDebugLine(__FILE__,__LINE__,"Class Source: " $s_Src);
  259.         
  260.         if (empty($s_Src)) {
  261.             if (file_exists(__OCSP_PHPINCPATH__ "client" _OCSP_DIRSEP_ $this->getDBField('CTY_CLASS'".phpclass"))
  262.             {
  263.                 require_once __OCSP_PHPINCPATH__ "client" _OCSP_DIRSEP_ $this->getDBField('CTY_CLASS'".phpclass";
  264.                 return True;
  265.             }
  266.             if (file_exists(__OCSP_PROJECTPATH__ _OCSP_DIRSEP_ $this->getDBField('CTY_CLASS'".phpclass"))
  267.             {
  268.                 require_once __OCSP_PROJECTPATH__ _OCSP_DIRSEP_ $this->getDBField('CTY_CLASS'".phpclass";
  269.                 return True;
  270.             }
  271.             
  272.             $s_Src __OCSP_PHPINCPATH__ "client" _OCSP_DIRSEP_ ."CLIENT.phpclass";
  273.         else {
  274.             $s_Src __OCSP_PROJECTPATH__ $s_Src;
  275.         }
  276.  
  277.         if ($debugechoDebug(__FILE__,"Source: ".$s_Src);
  278.         if (file_exists($s_Src)) {
  279.             require_once $s_Src;
  280.             return True;
  281.         else {
  282.             if ((strstr($s_src,_OCSP_DIRSEP_=== 0&& file_exists($s_Src))
  283.             {
  284.                 require_once $s_Src;
  285.                 return True;
  286.             }
  287.             return False;
  288.         }
  289.     }
  290.  
  291.     /**
  292.       * returns the class name of the client object defined by the type
  293.       * and ensures the class exists
  294.       *
  295.       * @param boolean $debug 
  296.       *
  297.       * @return string 
  298.       *
  299.       ***/
  300.     function getCliClassName($debug=False{
  301.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_TYPE::getCliClassName()");
  302.  
  303.         $s_className=$this->getDBField('CTY_CLASS');
  304.         if (empty($s_className)) {
  305.             $s_className="CLIENT";
  306.         }
  307.  
  308.         if (!class_exists($s_className)) {
  309.             $this->incCliClassSource($debug);
  310.         }
  311.  
  312.         return (class_exists($s_className$s_className "CLIENT");
  313.     }
  314.  
  315.     /**
  316.       * generates a new client object with this type
  317.       *
  318.       * @param array $cliRow 
  319.       * @param boolean $debug 
  320.       *
  321.       * @return CLIENT or an instance of it
  322.       *
  323.       ***/
  324.     function getCliObjectFromArray($cliRow,$debug{
  325.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_TYPE::getCliObjectFromArray()");
  326.         
  327.         $s_className=$this->getCliClassName($debug);
  328.         
  329.         $s_cmd="\$o_client=new ".$s_className."();";
  330.         eval($s_cmd);
  331.  
  332.         if (!pcf_is_instance_of($o_client,"CLIENT")) {
  333.             $o_client=new CLIENT();
  334.         }
  335.  
  336.         $o_client->setDBRow($cliRow,(intval($cliRow['CLI_ID']True:False),$debug);
  337.         $o_client->setTypeObj($this);
  338.         return $o_client;
  339.     }
  340.  
  341.     /**
  342.      * factories a client from an id
  343.      * 
  344.      * @param int $aId 
  345.      * @param boolean $debug 
  346.      * 
  347.      * @return CLIENT 
  348.      */
  349.     public function &factoryClientFromId($aId,$debug=False)
  350.     {
  351.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_TYPE::factoryClientFromId({$aId})","Type: " $this->getName(" ID: " $this->getId());
  352.         
  353.         if (!intval($aId))
  354.         {
  355.             $str_className $this->getCliClassName($debug);
  356.             $obj_client =  new $str_className();
  357.             $obj_client->setTypeObj($this);
  358.             return $obj_client;
  359.         }
  360.         
  361.         if (CLIENT::isInstanced($aId))
  362.         {
  363.             $obj_client CLIENT::getInstance($aId);
  364.             if ($obj_client->getTypeId(== $this->getId())
  365.             {
  366.                 return $obj_client;
  367.             }
  368.         }
  369.         
  370.         $arr_filter array('CLI_ID' => intval($aId));        
  371.         if ($arr_row OCSP_OBJ::defaultReadDBObj()->getRow($this->getClientTableName(),$arr_filter)) {
  372.             return $this->getCliObjectFromArray($arr_row,$debug);
  373.         }
  374.         
  375.         $str_className $this->getCliClassName($debug);
  376.         $obj_client =  new $str_className();
  377.         $obj_client->setTypeObj($this);
  378.         return $obj_client;
  379.         
  380.     }
  381.  
  382.     // ------------------------------------------------------
  383.     // staff type
  384.     // ------------------------------------------------------
  385.  
  386.     /**
  387.       * returns if the client type has staffs enabled
  388.       *
  389.       * @return boolean 
  390.       * @access public
  391.       * @since pk-07-09-18
  392.       */
  393.     function hasStaff()
  394.     {
  395.         if (intval($this->getDBField('CTY_HASSTAFF')))
  396.         {
  397.             return True;
  398.         else {
  399.             return False;
  400.         }
  401.     }
  402.  
  403.     /**
  404.       * returns the first staff type in T_CLI_STAFF_TYPE fits for this type
  405.       * by using the query:
  406.       * <code>SELECT * FROM T_CLI_STAFF_TYPE WHERE CTY_ID IN($this->getId(),0) ORDER BY CTY_ID DESC,CSTTYPE_SORTORDER</code>;
  407.       *
  408.       * @param boolean $debug 
  409.       *
  410.       * @return CLI_STAFF_TYPE 
  411.       *
  412.       ***/
  413.     function getDefaultStaffType($debug=False{
  414.         if ($debugechoDebugMethod(__FILE__,get_class(),"CLI_TYPE::getDefaultStaffType()");
  415.  
  416.         if (!$this->isConnected(True,$debug))
  417.         {
  418.             ocsp_logError(__FILE__,__LINE__,"no database connection",E_ERROR);
  419.             return NULL;
  420.         }
  421.  
  422.         $o_staType=new CLI_STAFF_TYPE();
  423.         $o_staType->setDBObj($this->getDBObj());
  424.  
  425.         $s_query ="SELECT * FROM T_CLI_STAFF_TYPE ";
  426.         $s_query.=" WHERE CTY_ID IN(".$this->getId().",0)";
  427.         $s_query.=" ORDER BY CTY_ID DESC,CSTTYPE_SORTORDER";
  428.  
  429.         if ($a_row=$this->myDBObj->quickQuery($s_query)) {
  430.             $o_staType->setDBRow($a_row,True,$debug);
  431.  
  432.         }
  433.         $o_staType->setClientTypeObj($this);
  434.         return $o_staType;
  435.     }
  436.  
  437.     /**
  438.       * returns a staff type
  439.       * if $typeId is 0 $this->getDefaultStaffType is returned
  440.       *
  441.       * @param int $typeId 
  442.       * @param boolean $debug 
  443.       *
  444.       ***/
  445.     function getStaffType($typeId=0,$debug=False{
  446.         if ($debugechoDebugMethod(__FILE__,get_class(),"CLI_TYPE::getStaffType($typeId)");
  447.  
  448.         if (intval($typeId)) {
  449.             return new CLI_STAFF_TYPE($typeId);
  450.         else {
  451.             return $this->getDefaultStaffType($debug);
  452.         }
  453.     }
  454.  
  455.     // ------------------------------------------------------
  456.     // interests
  457.     // ------------------------------------------------------
  458.     
  459.     /**
  460.      * returns the interests for available
  461.      *
  462.      * @param boolean $debug 
  463.      * 
  464.      * @return array() 
  465.      */
  466.     public function getInterestNodes($debug=False)
  467.     {
  468.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_TYPE::getInterestTree();");
  469.         
  470.         $arr_ret array();
  471.         if (!INTEREST::treeIsPopulated())
  472.         {
  473.             INTEREST::populateTree();        
  474.         }
  475.         
  476.         if ($arr_instances INTEREST::getAllInstances())
  477.         {
  478.             foreach($arr_instances as $int_id => &$obj_node)
  479.             {
  480.                 if (!$obj_node->isRoot())
  481.                 {
  482.                     if (($obj_node->getCliTypeId(== $this->getId()) || ($obj_node->getCliTypeId(==  0))
  483.                     {
  484.                         $arr_ret[$int_id&$obj_node;
  485.                     }
  486.                 }                
  487.             }
  488.         }
  489.         
  490.         return $arr_ret;
  491.     }
  492.     
  493.     // ------------------------------------------------------
  494.     // rights
  495.     // ------------------------------------------------------
  496.  
  497.     /**
  498.       * returns if the current user can show clients of this type
  499.       *
  500.       * @param boolean $debug 
  501.       *
  502.       * @return boolean 
  503.       * @since pk-06-10-02
  504.       *
  505.       ***/
  506.     function userCanShowClients($debug=False{
  507.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_TYPE::userCanShowClients(" $this->getId(.")");
  508.         if (!intval($this->getId()))
  509.         {
  510.             return OCSP_OBJ::currentUser()->isGroupMember(_OCSP_GROUP_CLIADMIN_);
  511.         }
  512.         if (OCSP_OBJ::currentUser()->isGroupMember(intval($this->getDBField('CTY_SHOWGROUP')))) {
  513.             return True;
  514.         }
  515.         return $this->userCanEditClients($debug);
  516.     }
  517.  
  518.     /**
  519.       * returns if the current user can edit clients of this type
  520.       *
  521.       * @param boolean $debug 
  522.       *
  523.       * @return boolean 
  524.       * @since pk-06-10-02
  525.       *
  526.       ***/
  527.     function userCanEditClients($debug=False{
  528.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_TYPE::userCanEditClients()");
  529.         
  530.         if (!intval($this->getId()))
  531.         {
  532.             return OCSP_OBJ::currentUser()->isGroupMember(_OCSP_GROUP_CLIADMIN_);
  533.         }
  534.         
  535.         if (OCSP_OBJ::currentUser()->isGroupMember(intval($this->getDBField('CTY_EDITGROUP')))) {
  536.             return True;
  537.         }
  538.         
  539.         return $this->userIsAdmin($debug);
  540.     }
  541.  
  542.     /**
  543.       * returns if the current user can delete clients of this type
  544.       *
  545.       * @param boolean $debug 
  546.       *
  547.       * @return boolean 
  548.       *
  549.       * @since pk-06-10-02
  550.       * @version pk-07-01-11
  551.       *
  552.       ***/
  553.     function userCanDeleteClients($debug
  554.     {
  555.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_TYPE::userCanDeleteClients()");
  556.         $i_grp_id=(intval($this->getDBField('CTY_ADMIN')) intval($this->getDBField('CTY_ADMIN')) _OCSP_GROUP_CLIADMIN_);
  557.         if (OCSP_OBJ::currentUser()->isGroupMember($i_grp_id)) {
  558.             if ($debugechoDebug(__FILE__,"<p>User isMember of ".$i_grp_id."</p>");
  559.             return True;
  560.         }
  561.         return $this->userIsAdmin($debug);
  562.     }
  563.  
  564.  
  565.     /**
  566.       * returns if the current user can delete clients of this type
  567.       *
  568.       * @param boolean $debug 
  569.       *
  570.       * @return boolean 
  571.       *
  572.       * @since pk-06-10-02
  573.       * @version pk-07-01-11
  574.       *
  575.       ***/
  576.     function userIsAdmin($debug=False{
  577.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_TYPE::userIsAdmin()");
  578.  
  579.         $i_grp_id=(intval($this->getDBField('CTY_ADMIN')) intval($this->getDBField('CTY_ADMIN')) _OCSP_GROUP_CLIADMIN_);
  580.         if (OCSP_OBJ::currentUser()->isGroupMember($i_grp_id)) {
  581.             if ($debugechoDebug(__FILE__,"<p>User isMember of ".$i_grp_id."</p>");
  582.             return True;
  583.         }
  584.         
  585.         // <pk-08-11-20>
  586.         if (OCSP_OBJ::currentUser()->isGroupMember(_OCSP_GROUP_CLIADMIN_))
  587.         {
  588.             return True;
  589.         }
  590.         // </pk-08-11-20>
  591.         
  592.         if ($debugechoDebugLine(__FILE__,__LINE__,"User not member of " $i_grp_id);
  593.         return False;
  594.     }
  595.  
  596.     /**
  597.       * return if a user can edit his own client data
  598.       *
  599.       * @param boolean $debug 
  600.       *
  601.       * @return boolean 
  602.       *
  603.       * @since pk-06-10-02
  604.       *
  605.       ***/
  606.     function userCanSelfEdit($debug=False{
  607.         if (intval($this->getDBField('CTY_SELFEDIT'))) return True;
  608.         return False;
  609.     }
  610.  
  611.     // ------------------------------------------------------
  612.     // forms
  613.     // ------------------------------------------------------
  614.  
  615.     /**
  616.       * sets the forms DBMS_TABLEOBJ
  617.       *
  618.       * @param CLI_FORM $frmObj 
  619.       * @param boolean $debug 
  620.       *
  621.       * @since pk-07-01-15
  622.       *
  623.       ***/
  624.     function setFormTblObj(&$frmObj,$debug=False{
  625.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_TYPE::setFormTblObj()");
  626.  
  627.         $s_className=$this->getDBField('CTY_CLASS');
  628.  
  629.         if ((!empty($s_className)) && file_exists($GLOBALS['PROJECT']['PATH'].$this->getDBField('CTY_CLASSFILE'))) {
  630.             $frmObj->myDBMS_TABLEOBJ_include=$GLOBALS['PROJECT']['PATH'].$this->getDBField('CTY_CLASSFILE');
  631.             $frmObj->myDBMS_TABLEOBJ_class  =$s_className;
  632.         else {
  633.             $frmObj->myDBMS_TABLEOBJ_include=dirname(__FILE__)."/CLIENT.phpclass";
  634.             $frmObj->myDBMS_TABLEOBJ_class  ="CLIENT";
  635.         }
  636.  
  637.  
  638.     }
  639.  
  640.     /**
  641.       * returns the form used in admin section
  642.       *
  643.       * @param boolean $frmMode 
  644.       * @param boolean $debug 
  645.       *
  646.       * @return CLI_FORM 
  647.       *
  648.       * @since pk-06-10-25
  649.       *
  650.       ***/
  651.     function &getAdminForm($frmMode=FRM_MODE_READONLY,$debug=False{
  652.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_TYPE::getAdminForm()");
  653.  
  654.         $o_frmObj=NULL;
  655.         if (intval($this->getDBField('CTY_ADMINFORM'))) {
  656.             $o_frmObj=OCSP_FORM::factory_from_id(intval($this->getDBField('CTY_ADMINFORM')),'CLI_FORM',$debug);
  657.         }
  658.         if (!pcf_is_instance_of($o_frmObj,'OCSP_FORM')) {
  659.             if ($debugechoDebug(__FILE__,"<p>USING TABLEDEFAULT T_CLI_CLIENT</p>");
  660.             $o_frmObj=OCSP_FORM::factory_from_name('T_CLI_CLIENT','CLI_FORM',$debug);
  661.         }
  662.  
  663.         if (!is_object($o_frmObj)) return $o_frmObj// NULL
  664.  
  665.         $this->setFormTblObj($o_frmObj,$debug)// <pk-07-01-15 />
  666.         $o_frmObj->setFrmMode($frmMode);
  667.  
  668.         return $o_frmObj;
  669.     }
  670.  
  671.     /**
  672.       * returns the form used in admin section
  673.       *
  674.       * @param boolean $frmMode 
  675.       * @param boolean $debug 
  676.       *
  677.       * @return CLI_FORM 
  678.       *
  679.       * @since pk-06-10-25
  680.       *
  681.       ***/
  682.     function &getUserForm($frmMode=FRM_MODE_READONLY,$debug=False{
  683.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_TYPE::getUserForm()");
  684.  
  685.         $o_frmObj=NULL;
  686.         if (intval($this->getDBField('CTY_USERFORM'))) {
  687.             $o_frmObj=OCSP_FORM::factory_from_id(intval($this->getDBField('CTY_USERFORM'),'CLI_FORM',$debug));
  688.         }
  689.         if (!pcf_is_instance_of($o_frmObj,'OCSP_FORM')) {
  690.             if ($debugechoDebug(__FILE__,"<p>USING TABLEDEFAULT T_CLI_CLIENT</p>");
  691.             $o_frmObj=OCSP_FORM::factory_from_name('T_CLI_CLIENT','CLI_FORM',$debug);
  692.         }
  693.  
  694.         if (!is_object($o_frmObj)) return $o_frmObj// NULL
  695.  
  696.         $this->setFormTblObj($o_frmObj,$debug);
  697.         $o_frmObj->setFrmMode($frmMode);
  698.  
  699.         return $o_frmObj;
  700.     }
  701.  
  702.     /**
  703.      * returns the address form id
  704.      *
  705.      * @return int 
  706.      * 
  707.      * @since pk-08-11-29
  708.      * 
  709.      */
  710.     public function getAddressFormId()
  711.     {
  712.         return intval($this->getDBField('CTY_ADDRESSFORM'));
  713.     }
  714.     
  715.     /*
  716.      * returns the address form object
  717.      * 
  718.      * @return OCSP_FORM
  719.      * 
  720.      * @since pk-08-11-29
  721.      */
  722.     public function &getAddressForm()
  723.     {
  724.         pcf_require_class('OCSP_FORM',"db/forms/");
  725.         if ($int_frmId $this->getAddressFormId())
  726.         {
  727.             if ($obj_form OCSP_FORM::factory_from_id($int_frmId))
  728.             {
  729.                 return $obj_form;
  730.             }
  731.         }
  732.         
  733.         $obj_form OCSP_FORM::factory_from_name('T_ADDRESS');
  734.         return $obj_form;
  735.     }
  736.     
  737.     /**
  738.       * returns the form used in admin section
  739.       *
  740.       * @param boolean $frmMode 
  741.       * @param boolean $debug 
  742.       *
  743.       * @return CLI_FORM 
  744.       *
  745.       * @since pk-06-10-25
  746.       *
  747.       ***/
  748.     function &getStaffLstForm($frmMode=FRM_MODE_LIST,$debug=False{
  749.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_TYPE::getCliUserForm()");
  750.  
  751.         pcf_require_class('CLI_STAFF_FORM',"client/");
  752.         
  753.         if ($int_frmId intval($this->getDBField('CTY_STAFFLSTFORM')))
  754.         {
  755.             if ($obj_form OCSP_FORM::factory_from_id($int_frmId,"CLI_STAFF_FORM"))
  756.             {                
  757.                 if ($obj_form->formIsLoaded())
  758.                 {
  759.                     $obj_form->setFrmMode($frmMode);
  760.                     return $obj_form;
  761.                 }
  762.             }
  763.         }
  764.         
  765.         if ($obj_staffType $this->getDefaultStaffType())
  766.         {
  767.             if ($obj_form $obj_staffType->getListForm(&& $obj_form->formIsLoaded())
  768.             {
  769.                 $obj_form->setFrmMode($frmMode);
  770.                 return $obj_form;
  771.             }
  772.         }
  773.         
  774.         if ($debugechoDebug(__FILE__,"<p>USING TABLEDEFAULT T_CLI_STAFF</p>");
  775.         $obj_form OCSP_FORM::factory_from_name('T_CLI_STAFF','CLI_STAFF_FORM',$debug);
  776.         if (!$obj_form->formIsLoaded())
  777.         {
  778.             $obj_form Null;
  779.             return $obj_form;
  780.         }
  781.  
  782.         $o_frmObj->setFrmMode($frmMode);
  783.         return $o_frmObj;
  784.     }
  785.  
  786.     /**
  787.       * returns the form used to handele values in T_CLI_USER AND T_SYS_USER
  788.       * if no form id is set the default form for T_SYS_USER is returned
  789.       *
  790.       *
  791.       * @param boolean $debug 
  792.       *
  793.       * @return DBMS_FORM 
  794.       *
  795.       * @since pk-06-10-24
  796.       *
  797.       ***/
  798.     function &getCliUserForm($debug=False{
  799.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CLI_STAFF_TYPE::getCliUserForm()");
  800.         $o_frmObj=NULL;
  801.         if ($i_frmId=intval($this->getDBField('CTY_USERFORM'))) {
  802.             $o_frmObj=OCSP_FORM::factory_from_id($i_frmId,'CLI_FORM',$debug);
  803.         }
  804.  
  805.         if (pcf_is_instance_of($o_frmObj,"OCSP_FORM")) {
  806.             return $o_frmObj;
  807.         else {
  808.             $o_frmObj=OCSP_FORM::factory_from_name("T_SYS_USER",'CLI_FORM',$debug);
  809.         }
  810.     }
  811.  
  812. }
  813. ?>

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