Source for file class.ADMINBEFUGNISSE.php

Documentation is available at class.ADMINBEFUGNISSE.php

  1. <?php
  2.  
  3.  
  4. /**
  5.  * Verwaltet die Adminitration der Datenbanktabelle 'befugnisse'
  6.  *
  7.  * @author Kay Koch, <kay.koch@gmx.de>
  8.  * @package src
  9.  * @subpackage foundation_admin
  10.  */
  11.  
  12. if (version_compare(PHP_VERSION'5')) {
  13.     die('This file was generated for PHP 5');
  14. }
  15.  
  16. /**
  17.  * Parentklasse zur Administration der Tabellen
  18.  *
  19.  * @author Kay Koch, <kay.koch@gmx.de>
  20.  */
  21. require_once('src/foundation/admin/class.PARENTADMIN.php');
  22.  
  23. /**
  24.  * Interface zur Administration der Datenbank
  25.  *
  26.  * @author Kay Koch
  27.  * @since 06.2005
  28.  * @version 1.0
  29.  */
  30. require_once('src/interfaces/interface.ADMININTERFACE.php');
  31.  
  32. /* user defined includes */
  33. // section -64--88-122--2--49bf02f4:103b2814a7e:-7fd2-includes begin
  34. // section -64--88-122--2--49bf02f4:103b2814a7e:-7fd2-includes end
  35.  
  36. /* user defined constants */
  37. // section -64--88-122--2--49bf02f4:103b2814a7e:-7fd2-constants begin
  38. // section -64--88-122--2--49bf02f4:103b2814a7e:-7fd2-constants end
  39.  
  40. /**
  41.  * Verwaltet die Adminitration der Datenbanktabelle 'befugnisse'
  42.  *
  43.  * @access public
  44.  * @author Kay Koch, <kay.koch@gmx.de>
  45.  * @package src
  46.  * @subpackage foundation_admin
  47.  */
  48.         implements src_interfaces_ADMININTERFACE
  49. {
  50.     // --- ATTRIBUTES ---
  51.  
  52.     
  53.     /**
  54.      * Objekt der aktellen Datenbankklasse
  55.      *
  56.      * @access private
  57.      * @var BEFUGNISSE 
  58.      */
  59.     private $oBefugnisse null;
  60.  
  61.     /**
  62.      * Array mit den Feldnamen der aktuellen Datebank
  63.      *
  64.      * @access protected
  65.      * @var array 
  66.      */
  67.     protected $arrKeys = array();
  68.  
  69.     /**
  70.      * Name des Haupttemplates
  71.      *
  72.      * @access private
  73.      * @var string 
  74.      */
  75.     protected $pageTemplate = '';
  76.  
  77.     // --- OPERATIONS ---
  78.  
  79.     
  80.     /**
  81.      * zeigt alle Einträge einer Tabelle
  82.      *
  83.      * @access public
  84.      * @author Kay Koch, <kay.koch@gmx.de>
  85.      * @return void 
  86.      */
  87.     public function show()
  88.     {
  89.         // section -64--88-122--2--6176e79b:103fa06a375:-7fad begin
  90.         if ($this->loginOK{
  91.             $this->todo "change";
  92.             $this->rows "";
  93.             $this->oBefugnisse->unsetParams();
  94.             $arrTmp $this->oBefugnisse->getRow();
  95.             $arrTimeRange $this->oSeen->getTimeRanges();
  96.             $this->timeHeader $this->prepareTimeHeader($arrTimeRange);
  97.             foreach ($arrTmp as $see_id => $arrSee//alle Seen
  98.                 $oSee $this->oSeen-> $see_id;
  99.                 $this->seename $oSee->name;
  100.                 foreach($arrSee as $this->data// alle Wochentage
  101.                     $this->wochentagName src_tools_TIME::dayNr2dayName($this->data['wochentag']);
  102.                     $this->timeRows $this->prepareTimeRows("admin_time_row"$oSee$arrTimeRange);
  103.                     $this->rows .= src_tools_TEMPLATE::getTemplate("admin_" $this->pageTemplate . "_row"$this);
  104.                 }
  105.             }
  106.             $this->makePage("admin_" $this->pageTemplate);
  107.         }
  108.         // section -64--88-122--2--6176e79b:103fa06a375:-7fad end
  109.     }
  110.  
  111.     /**
  112.      * liefert ein Formular zur Änderung bzw. Neueingabe eines Datensatzes
  113.      *
  114.      * Wenn die Tabellenspezifischen Parameter vorhergesetzt wurden wird der
  115.      * Datensatz ausgegeben. Ansonsten erscheint ein leeres Formular
  116.      *
  117.      * @access public
  118.      * @author Kay Koch, <kay.koch@gmx.de>
  119.      * @return void 
  120.      */
  121.     public function change()
  122.     {
  123.         // section -64--88-122--2--6176e79b:103fa06a375:-7fa9 begin
  124.         if ($this->loginOK{
  125.             if ((!empty($this->oBefugnisse->see_id))) {
  126.                 $this->todo "update";
  127.                 $this->data $this->oBefugnisse->getRow();
  128.                 $oSee $this->getSeen($this->oBefugnisse->see_id);
  129.                 $this->seename $oSee->name;
  130.                 $this->wochentagName src_tools_TIME::dayNr2dayName($this->oBefugnisse->wochentag);
  131.                 $this->timeRows $this->prepareTimeRows("admin_permit_input"$oSee);
  132.                 $this->makePage("admin_" $this->pageTemplate . "_input");
  133.             }
  134.         }
  135.         // section -64--88-122--2--6176e79b:103fa06a375:-7fa9 end
  136.     }
  137.  
  138.     /**
  139.      * Aktualisieet den vorher durch setzen der Parameter ausgewählten
  140.      *
  141.      * Die Neuen Daten befinden sich im Übergabefeld $data
  142.      *
  143.      * @access public
  144.      * @author Kay Koch, <kay.koch@gmx.de>
  145.      * @param array 
  146.      * @return void 
  147.      */
  148.     public function update($data)
  149.     {
  150.         // section -64--88-122--2--6176e79b:103fa06a375:-7f83 begin
  151.         if ($this->loginOK{
  152.             if ($this->checkData($data)) {
  153.                 $this->oBefugnisse->updateRow($data);
  154.                 $this->show();
  155.             else
  156.                 $this->change();
  157.         }
  158.         // section -64--88-122--2--6176e79b:103fa06a375:-7f83 end
  159.     }
  160.  
  161.     /**
  162.      * Löscht den Datensatz der vorher durch Parameter ausgewählt wurde
  163.      *
  164.      * @access public
  165.      * @author Kay Koch, <kay.koch@gmx.de>
  166.      * @return void 
  167.      */
  168.     public function delete()
  169.     {
  170.         // section -64--88-122--2--6176e79b:103fa06a375:-7f7f begin
  171.         if ($this->loginOK{
  172.             $this->oBefugnisse->deleteRow();
  173.             $this->show();
  174.         }
  175.         // section -64--88-122--2--6176e79b:103fa06a375:-7f7f end
  176.     }
  177.  
  178.     /**
  179.      * Fügt einen neuen datensatz mit den Werten des Übergabeparameter $data
  180.      *
  181.      * @access public
  182.      * @author Kay Koch, <kay.koch@gmx.de>
  183.      * @param array 
  184.      * @return void 
  185.      */
  186.     public function insert($data)
  187.     {
  188.         // section -64--88-122--2--6176e79b:103fa06a375:-7f7d begin
  189.         if ($this->loginOK{
  190.             $this->show();
  191.         }
  192.         // section -64--88-122--2--6176e79b:103fa06a375:-7f7d end
  193.     }
  194.  
  195.     /**
  196.      * überprüft die Korrektheit der eingebenen bzw. geänderten Daten
  197.      *
  198.      * @access public
  199.      * @author Kay Koch, <kay.koch@gmx.de>
  200.      * @param void 
  201.      * @return boolean 
  202.      */
  203.     public function checkData(&$data)
  204.     {
  205.         $returnValue = (bool) false;
  206.  
  207.         // section -64--88-122--2--62c31de:1048594e50f:-7fef begin
  208.         try {
  209.             foreach($data as $key => $id{
  210.                 if (src_tools_CHECK::checkHour($key)) //hh:mm
  211.                     if (!src_tools_CHECK::checkID($id)) {
  212.                         throw new Exception ("55,$key");
  213.                     }
  214.                 }
  215.             }
  216.             $returnValue true;
  217.         }
  218.         catch (Exception $e{
  219.             $message explode(","$e->getMessage());
  220.             $this->errorMsg "<b>[" $message[1"] : </b>" src_tools_ERROR::getErrTxt($message[0]);
  221.             $this->error src_tools_TEMPLATE::getTemplate('error'$this);
  222.         }
  223.         // section -64--88-122--2--62c31de:1048594e50f:-7fef end
  224.  
  225.         return (bool) $returnValue;
  226.     }
  227.  
  228.     /**
  229.      * Konstruktor
  230.      *
  231.      * erstellt ein Obejkt der zu beabeitenden Klassen
  232.      * list alle erlaubten Datenbankschlüssel ein
  233.      * liest das Template
  234.      *
  235.      * @access public
  236.      * @author Kay Koch, <kay.koch@gmx.de>
  237.      * @param string 
  238.      * @param int 
  239.      * @param date 
  240.      * @return void 
  241.      */
  242.     public function __construct($token$see_id 0$wochentag null)
  243.     {
  244.         // section -64--88-122--2--49bf02f4:103b2814a7e:-7fcd begin
  245.         parent::__construct($token);
  246.         $this->oBefugnisse new src_foundation_tables_BEFUGNISSE();
  247.         $this->oBefugnisse->setParams($see_id""$wochentag);
  248.         $this->see_id $see_id;
  249.         $this->wochentag $wochentag;
  250.         $this->setStartParameters ($this,$this->oBefugnisse);
  251.         // section -64--88-122--2--49bf02f4:103b2814a7e:-7fcd end
  252.     }
  253.  
  254.     /**
  255.      * estellt aus den Zeitdaten  HTML Reihen
  256.      *
  257.      * @access private
  258.      * @author Kay Koch, <kay.koch@gmx.de>
  259.      * @param string 
  260.      * @param EINSEE 
  261.      * @param array 
  262.      * @return string 
  263.      */
  264.     private function prepareTimeRows($tpl$oSee$arrTimeRange null)
  265.     {
  266.         $returnValue = (string) '';
  267.  
  268.         // section -64--88-122--2--49bf02f4:103b2814a7e:-7fbe begin
  269.         $rowTpl src_tools_TEMPLATE::getTemplate($tpl)// Template einladen
  270.         $isInput (isset($arrTimeRange))false true;
  271.         $oVerband new src_foundation_tables_VERBAENDE();
  272.         $arrVerband $oVerband->getRow();        
  273.         if ($oSee->buchbarProTag// ganzer Tag buchbar
  274.             if ($isInput// Eingabeformular
  275.                 $verbandOL $oVerband->getOptionLIst($this->data['00:00']);
  276.                 $returnValue sprintf($rowTpl"00:00"$verbandOL);
  277.             else // Gesamtdarstellung
  278.                 for ($stunde = (int)$arrTimeRange[0]$stunde <= (int)$arrTimeRange[1]$stunde++{
  279.                     if (!$oSee->isInDiveRangeByHour($this->data['wochentag'],$stunde))// außerhalb der Tauchzeit für diesen See
  280.                         $returnValue .= sprintf($rowTpl"");
  281.                     else {
  282.                         $returnValue .= sprintf($rowTpl$arrVerband[$this->data['00:00']]['name']);
  283.                     }
  284.                 }
  285.             }
  286.         else // stundenweise Anmeldung
  287.             foreach ($this->arrKeys as $key// alle Datenbankfelder durchlaufen
  288.                 if (isset($this->data[$key]AND src_tools_CHECK::checkHour($key)) //hh:mm
  289.                     if ($isInput// Eingabeformular
  290.                         if ($oSee->isInDiveRangeByHour($this->data['wochentag'],$key)) // erlaubte Uhrzeit und Eingabeformular
  291.                             $verbandOL $oVerband->getOptionList($this->data[$key]);
  292.                             $returnValue .= sprintf($rowTpl$key$verbandOL);
  293.                         }
  294.                     else // Gesamtdarstellung
  295.                         if ((int)$key $arrTimeRange[0OR (int)$key $arrTimeRange[1]// außerhalb jeder Tauchzeit
  296.                             continue;
  297.                         else if (!$oSee->isInDiveRangeByHour($this->data['wochentag'],$key)) // außerhalb der Tauchzeit für diesen See
  298.                             $returnValue .= sprintf($rowTpl"");
  299.                         else {
  300.                             $returnValue .= sprintf($rowTpl$arrVerband[$this->data[$key]]['name']);
  301.                         }
  302.                     }
  303.                 }
  304.             }
  305.         }
  306.         // section -64--88-122--2--49bf02f4:103b2814a7e:-7fbe end
  307.  
  308.         return (string) $returnValue;
  309.     }
  310.  
  311.     /**
  312.      * estellt aus den Zeitdaten  HTML überschriften für eine Tabelle
  313.      *
  314.      * @access private
  315.      * @author Kay Koch, <kay.koch@gmx.de>
  316.      * @param void 
  317.      * @return string 
  318.      */
  319.     private function prepareTimeHeader($arrTimeRange)
  320.     {
  321.         $returnValue = (string) '';
  322.  
  323.         // section -64--88-122--2--49bf02f4:103b2814a7e:-7fb9 begin
  324.         list($min$max$arrTimeRange;
  325.         for($hour = (int)$min$hour <= (int)$max$hour++{
  326.             $returnValue .= "<th>" $hour ":00 h</th>\n";
  327.         }
  328.         // section -64--88-122--2--49bf02f4:103b2814a7e:-7fb9 end
  329.  
  330.         return (string) $returnValue;
  331.     }
  332.  
  333. /* end of class src_foundation_admin_ADMINBEFUGNISSE */
  334.  
  335. ?>

Documentation generated on Sat, 24 Mar 2007 09:58:02 +0100 by phpDocumentor 1.3.1