Source for file CMS_CHAPTER_FORM.phpclass

Documentation is available at CMS_CHAPTER_FORM.phpclass

  1. <?php
  2. /**
  3.   * Class file CMS_CHAPTER_FORM.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    cms
  7.   *
  8.   * @author     Peter Krebs <pitlinz@users.sourceforge.net>
  9.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  10.   *
  11.   * @since pk-08-01-08
  12.   * @version $Id: CMS_CHAPTER_FORM.phpclass,v 1.8 2008/12/17 16:28:51 peterkrebs Exp $
  13.   */
  14.  
  15.     pcf_require_class('OCSP_FORM',"db/forms/");
  16.     pcf_require_class('OCSP_CMS_CONF',"cms/");
  17.     pcf_require_class('CMS_CHAPTER',"cms/chapter/");
  18.  
  19.  
  20. /**
  21.   * Class file CMS_CHAPTER_FORM
  22.   *
  23.   * extends DBMS_FORM to handle different page classes
  24.   *
  25.   * @project    Open CSP-Management
  26.   * @package    cms
  27.   *
  28.   * @author     Peter Krebs <pitlinz@users.sourceforge.net>
  29.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  30.   *
  31.   * @since pk-08-01-08
  32.   * @version $Id: CMS_CHAPTER_FORM.phpclass,v 1.8 2008/12/17 16:28:51 peterkrebs Exp $
  33.   */
  34. class CMS_CHAPTER_FORM extends OCSP_FORM {
  35.  
  36.     /*** class constants  --------------------------------------------- */
  37.  
  38.     /**
  39.       * @constant string CLASS_SRC_FILE
  40.       */
  41.     const CLASS_SRC_FILE = __FILE__;
  42.  
  43.     // ----------------------------------------------------------------------------------------
  44.     // construct, load methods
  45.     // ----------------------------------------------------------------------------------------
  46.  
  47.     /*
  48.      * sets the tableobject class and include from $dataArr and 
  49.      * tries to instantiate by calling $this->getMyTblObj
  50.      * 
  51.      * if class is set in $dataArr and it could not be instantiated FALSE is returned
  52.      * else TRUE is returned 
  53.      * 
  54.      * @param array $dataArr (normaly $_POST)
  55.      * @param boolean $debug
  56.      * 
  57.      * @return boolean
  58.      * 
  59.      */
  60.     function setTblObjFromSubmitData(&$dataArr,$debug=False)
  61.     {              
  62.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_CHAPTER_FORM::setTblObjFromSubmitData()");
  63.         
  64.         //if ($debug) echoDebugLine(__FILE__,__LINE__,"\$dataArr:<pre>".print_r($dataArr,True)."</pre>");
  65.         
  66.         if (!($int_chaId (isset($dataArr[$dataArr['FRMARRAYNAME']]['CHA_ID']intval($dataArr[$dataArr['FRMARRAYNAME']]['CHA_ID']0)))
  67.         {
  68.             $int_chaId (isset($dataArr['CHA_ID']intval($dataArr['CHA_ID']0);
  69.         }
  70.                  
  71.         if (intval($int_chaId))
  72.         {     
  73.             if ($debugechoDebugLine(__FILE__,__LINE__,"Setting myTblObj from CHA_ID");       
  74.             $this->myTblObj=CMS_CHAPTER::getInstance($int_chaId);
  75.         else {
  76.               if (!($int_chaTmplId (isset($dataArr[$dataArr['FRMARRAYNAME']]['CTMP_ID']intval($dataArr[$dataArr['FRMARRAYNAME']]['CTMP_ID']0)))
  77.             {
  78.                 if (!($int_chaTmplId (isset($dataArr['CTMP_ID']intval($dataArr['CTMP_ID']0)))
  79.                 {
  80.                     $int_chaTmplId (isset($_GET['CTMP_ID']intval($_GET['CTMP_ID']0);
  81.                 }
  82.             }            
  83.             
  84.             if (intval($int_chaTmplId))
  85.             {
  86.                 if ($obj_tmpl TMPL_CHAPTER::getInstance($int_chaTmplId))
  87.                 {
  88.                     $this->myTblObj = $obj_tmpl->getNewChapter();                    
  89.                 else {
  90.                     throw new Exception('CTMP_ID ' $int_chaTmplId ' NOT FOUND');
  91.                 }
  92.             else {
  93.                 return parent::setTblObjFromSubmitData(&$dataArr,$debug);
  94.             }
  95.         }
  96.             
  97.         $obj_chaTmpl $this->myTblObj->getMyTemplate();
  98.         $obj_chaTmpl->addInputFieldsToForm($this);
  99.         
  100.         return True;
  101.     }
  102.     
  103.     // ------------------------------------------------------------------------------------------- 
  104.     // field methods
  105.     // ------------------------------------------------------------------------------------------- 
  106.     
  107.     /**
  108.       * returns a field object
  109.       *
  110.       * @param string $aFldName 
  111.       * @param string $aTable (empty to search in all tables)
  112.       * @param int $aBlockId (-1 to search in all blocks)
  113.       * @param boolean $debug 
  114.       *
  115.       * @return DBMS_FIELD 
  116.       *
  117.       * @version pk-08-07-12 (OBJVALS_)
  118.       */
  119.     function &getField($aFldName,$aTable="",$aBlockId=-1,$debug=False)
  120.     {
  121.         if($debugechoDebugMethod(__FILE__,get_class($this),"CMS_CHAPTER_FORM::getField({$aFldName},{$aTable},{$aBlockId})");
  122.  
  123.         if ($obj_field parent::getField($aFldName,$aTable,$aBlockId))
  124.         {
  125.             return $obj_field;
  126.         else if (pcf_class_implements($this->myTblObj,'INFA_CMS_CHAPTER'&& ($this->myTblObj->getMyTable(== $aTable)) {
  127.             // we have an object value 
  128.             
  129.             if ($obj_field parent::getField($aFldName,'CHAOBJVAL',$aBlockId,$debug))
  130.             {
  131.                 return $obj_field;
  132.             }
  133.  
  134.             if ($obj_field parent::getField($aFldName,'CHAOBJVAL',$aBlockId,$debug))
  135.             {
  136.                 return $obj_field;
  137.             }
  138.             if ($obj_field parent::getField($aFldName,'CHAPTER',$aBlockId,$debug))
  139.             {
  140.                 if ($debugechoDebugLine(__FILE__,__LINE__,"old field found: " $obj_field->getKey());                
  141.                 return $obj_field;
  142.             }
  143.             return $obj_field;
  144.             
  145.         else {
  146.             return $obj_field
  147.         }        
  148.     }
  149.     
  150.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  151.     // rights
  152.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  153.  
  154.     /**
  155.       * returns if the current user can save the form in the current mode
  156.       *
  157.       * @param boolean $debug 
  158.       * 
  159.       * @global array $OCSP_OBJ 
  160.       *
  161.       * @return boolean 
  162.       */
  163.     function curUserCanSave($debug=FALSE)
  164.     {        
  165.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_CHAPTER_FORM::curUserCanSave()");
  166.  
  167.         if (!self::currentUser()->isGroupMember(_OCSP_GROUP_CMSAUTHOR_))
  168.         {
  169.             return FALSE;
  170.         else {
  171.             return parent::curUserCanSave($debug);
  172.         }
  173.     }
  174.     
  175. }
  176. ?>

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