Source for file class.BLOCKADEN.php

Documentation is available at class.BLOCKADEN.php

  1. <?php
  2.  
  3. /**
  4.  * Stellt die Verbindung zur Tabelle 'Blockaden' her
  5.  *
  6.  * Verwaltet die ganztägigen Blockaden einzelner Seen
  7.  *
  8.  * @author Kay Koch, <kay.koch@gmx.de>
  9.  * @package src
  10.  * @subpackage foundation_tables
  11.  */
  12.  
  13. if (version_compare(PHP_VERSION'5')) {
  14.     die('This file was generated for PHP 5');
  15. }
  16.  
  17. /**
  18.  * Basisklasse aller Klassen mit Datenbankzugriff.
  19.  *
  20.  * stellt Methoden und Objekte zur Fehlermeldung und zum Datenbankzugriff zur
  21.  *
  22.  * @author Kay Koch
  23.  * @since 1.12.04
  24.  * @version 1.1
  25.  */
  26. require_once ('src/foundation/tables/class.PARENTTABLES.php');
  27.  
  28. /**
  29.  * Interface für die Klassen zur Manipulation der Datenbanktabellen
  30.  *
  31.  * @author Kay Koch, <kay.koch@gmx.de>
  32.  */
  33. require_once ('src/interfaces/interface.TABLEINTERFACE.php');
  34.  
  35. /* user defined includes */
  36. // section -64--88-122--2--78ecc2cb:103d1b5ef00:-7fe0-includes begin
  37. // section -64--88-122--2--78ecc2cb:103d1b5ef00:-7fe0-includes end
  38.  
  39. /* user defined constants */
  40. // section -64--88-122--2--78ecc2cb:103d1b5ef00:-7fe0-constants begin
  41. // section -64--88-122--2--78ecc2cb:103d1b5ef00:-7fe0-constants end
  42.  
  43. /**
  44.  * Stellt die Verbindung zur Tabelle 'Blockaden' her
  45.  *
  46.  * Verwaltet die ganztägigen Blockaden einzelner Seen
  47.  *
  48.  * @access public
  49.  * @author Kay Koch, <kay.koch@gmx.de>
  50.  * @package src
  51.  * @subpackage foundation_tables
  52.  */
  53.     // --- ATTRIBUTES ---
  54.  
  55.     
  56.     /**
  57.      * Beinhaltet den Datenbanknamen (blockaden)
  58.      *
  59.      * @access protected
  60.      * @var string 
  61.      */
  62.     protected $dbTableName'blockaden';
  63.  
  64.     /**
  65.      * beinhaltet einen Datensatz der zuständigen Tabelle aus der Datenbank
  66.      *
  67.      * @access private
  68.      * @var array 
  69.      */
  70.     private static $dataarray ();
  71.  
  72.     /**
  73.      * beinhaltet einen Datensatz der zuständigen Tabelle aus der Datenbank
  74.      *
  75.      * @access private
  76.      * @var array 
  77.      */
  78.     private static $dataIDarray ();
  79.  
  80.     /**
  81.      * aktuelle See_id
  82.      *
  83.      * @access public
  84.      * @var int 
  85.      */
  86.     public $see_id0;
  87.  
  88.     /**
  89.      * aktuelles Datum
  90.      *
  91.      * @access public
  92.      * @var date 
  93.      */
  94.     public $datumnull;
  95.  
  96.     /**
  97.      * aktuelle Stunde
  98.      *
  99.      * @access public
  100.      * @var time 
  101.      */
  102.     public $stundenull;
  103.  
  104.     public $block_idnull;
  105.     // --- OPERATIONS ---
  106.  
  107.     
  108.     /**
  109.      * liefert einen (mehrere) Datensatz
  110.      *
  111.      * der Datensatz wird durch Setzen der Parameter identifiziert
  112.      *
  113.      * @access public
  114.      * @author Kay Koch, <kay.koch@gmx.de>
  115.      * @return array 
  116.      */
  117.     public function getRow({
  118.         $returnValuearray ();
  119.  
  120.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab begin
  121.         if (!empty ($this->stundeAND !empty ($this->datumAND !empty ($this->see_id))
  122.             $returnValueself :: $data[$this->see_id][$this->datum][$this->stunde];
  123.         else
  124.             if (!empty ($this->datumAND !empty ($this->see_id))
  125.                 $returnValueself :: $data[$this->see_id][$this->datum];
  126.             else
  127.                 if (!empty ($this->see_id))
  128.                     $returnValueself :: $data[$this->see_id];
  129.                 else
  130.                     $returnValueself :: $data;
  131.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab end
  132.         return (array) $returnValue;
  133.     }
  134.  
  135.     public function getRowByID($block_id=""{
  136.         $returnValue array ();
  137.  
  138.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab begin
  139.         if (!empty ($block_id)){
  140.             $returnValue = isset(self :: $dataID[$block_id])?self :: $dataID[$block_id]:"";
  141.             $this->block_id$block_id;
  142.         }else
  143.              $returnValue self :: $dataID;
  144.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab end
  145.         return (array) $returnValue;
  146.     }
  147.  
  148.     /**
  149.      * veranlasst ein Update
  150.      *
  151.      * @access public
  152.      * @author Kay Koch, <kay.koch@gmx.de>
  153.      * @param array 
  154.      * @return boolean 
  155.      */
  156.     public function updateRow($data{
  157.         $returnValue= (bool) false;
  158.  
  159.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa9 begin
  160.         try {
  161.             $sql"UPDATE IGNORE $this->dbTableName
  162.                                 SET see_id = '$data['see_id'"',
  163.                                     datum = '" $data['datum'"',
  164.                                     ganzerTag = '" $data['ganzerTag'"',
  165.                                     stunde = '" $data['stunde'"',
  166.                                     anzahlStunden = '" $data['anzahlStunden'"',
  167.                                     wiederholung = '" $data['wiederholung'"',
  168.                                     anzahlWiederholung = '" $data['anzahlWiederholung'"',
  169.                                     anzahl = '" $data['anzahl'"',
  170.                                     anzahlZahler = '" $data['anzahlZahler'"',
  171.                                     verein_nr = '" $data['verein_nr'"',
  172.                                     info = '" $data['info'"'
  173.                                 WHERE block_id = '" $data['block_id'"'";
  174.             if (!$this->update($sql))
  175.                 throw new Exception();
  176.             $this->updateData();
  177.             $returnValuetrue;
  178.         catch (Exception $e{
  179.             ;
  180.         }
  181.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa9 end
  182.  
  183.         return (bool) $returnValue;
  184.     }
  185.  
  186.     /**
  187.      * fügt einen neuen Datensatz ein
  188.      *
  189.      * @access public
  190.      * @author Kay Koch, <kay.koch@gmx.de>
  191.      * @param array 
  192.      * @return boolean 
  193.      */
  194.     public function insertRow($data{
  195.         $returnValue= (bool) false;
  196.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa6 begin
  197.         try {
  198.             $sql"INSERT IGNORE INTO $this->dbTableName
  199.                    SET see_id = '$data['see_id'"',
  200.                            datum = '" $data['datum'"',
  201.                         ganzerTag = '" $data['ganzerTag'"',
  202.                         stunde = '" $data['stunde'"',
  203.                         anzahlStunden = '" $data['anzahlStunden'"',
  204.                         wiederholung = '" $data['wiederholung'"',
  205.                         anzahlWiederholung = '" $data['anzahlWiederholung'"',
  206.                         anzahl = '" $data['anzahl'"',
  207.                         anzahlZahler = '" $data['anzahlZahler'"',
  208.                         verein_nr = '" $data['verein_nr'"',
  209.                         info = '" $data['info'"'";
  210.             if (!$this->block_id = $this->insert($sql)) // Blockade eintragen
  211.                 throw new Exception();
  212.             $this->updateData();
  213.             $returnValuetrue;
  214.         catch (Exception $e{
  215.             ;
  216.         }
  217.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa6 end
  218.  
  219.         return (bool) $returnValue;
  220.     }
  221.  
  222.     /**
  223.      * löscht einen Datensatz
  224.      *
  225.      * @access public
  226.      * @author Kay Koch, <kay.koch@gmx.de>
  227.      * @return boolean 
  228.      */
  229.     public function deleteRow({
  230.         $returnValue= (bool) false;
  231.  
  232.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9e begin
  233.         try {
  234.             $whereit(empty ($this->datum)) "" "AND datum='$this->datumAND stunde='$this->stunde'";
  235.             $sql"DELETE FROM $this->dbTableName WHERE `block_id` = '$this->block_id."';";
  236.             if (!$this->delete($sql))
  237.                 throw new Exception();
  238.             $this->updateData();
  239.             $returnValuetrue;
  240.         catch (Exception $e{
  241.             ;
  242.         }
  243.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9e end
  244.  
  245.         return (bool) $returnValue;
  246.     }
  247.  
  248.     /**
  249.      * aktualisiert die Daten im gegenwertigen Objekt
  250.      *
  251.      * @access public
  252.      * @author Kay Koch, <kay.koch@gmx.de>
  253.      * @return boolean 
  254.      */
  255.     public function updateData({
  256.         $returnValue= (bool) false;
  257.  
  258.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9c begin
  259.         $sql"SELECT * FROM  $this->dbTableName ORDER by see_id,datum,stunde ASC";
  260.         self :: $data$this->select($sqltrue"see_id""datum""stunde");
  261.         self :: $dataID$this->select($sqltrue"block_id");
  262.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9c end
  263.         return (bool) $returnValue;
  264.     }
  265.  
  266.     /**
  267.      * löscht die Parameter,
  268.      * die den gegenwärtigen Datensatz identifizieren
  269.      *
  270.      * @access public
  271.      * @author Kay Koch, <kay.koch@gmx.de>
  272.      * @return void 
  273.      */
  274.     public function unsetParams({
  275.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f97 begin
  276.         unset ($this->see_id);
  277.         unset ($this->datum);
  278.         unset ($this->stunde);
  279.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f97 end
  280.     }
  281.  
  282.     /**
  283.      * überprüft Datum und See auf Blockade
  284.      *
  285.      * @access public
  286.      * @author Kay Koch, <kay.koch@gmx.de>
  287.      * @return boolean 
  288.      */
  289.     public function isBlocked({
  290.         $returnValue= (bool) false;
  291.         // section -64--88-122--2--78ecc2cb:103d1b5ef00:-7fda begin
  292.         if (!empty ($this->stunde))
  293.             $returnValue= isset (self :: $data[$this->see_id][$this->datum][$this->stunde]);
  294.         else
  295.             $returnValue= isset (self :: $data[$this->see_id][$this->datum]);
  296.         // section -64--88-122--2--78ecc2cb:103d1b5ef00:-7fda end
  297.         return (bool) $returnValue;
  298.     }
  299.  
  300.     /**
  301.      * setzt die Daten für die aktuelle Bearbeitung
  302.      *
  303.      * @access public
  304.      * @author Kay Koch, <kay.koch@gmx.de>
  305.      * @param int 
  306.      * @param date 
  307.      * @param time 
  308.      * @return void 
  309.      */
  310.     public function setParams($see_id$datumnull$stundenull{
  311.         // section -64--88-122--2-339007d5:1043cd4e8c9:-7f9f begin
  312.         $this->see_id$see_id;
  313.         if (!empty ($datum))
  314.             $this->datum$datum;
  315.         if (!empty ($stunde))
  316.             $this->stundesrc_tools_TIME :: time2longTime($stunde);
  317.         // section -64--88-122--2-339007d5:1043cd4e8c9:-7f9f end
  318.     }
  319.  
  320.  
  321.  
  322.     /**
  323.      * Konstruktor
  324.      *
  325.      * lädt alle Blockaden
  326.      *
  327.      * @access public
  328.      * @author Kay Koch, <kay.koch@gmx.de>
  329.      * @return void 
  330.      */
  331.     public function __construct({
  332.         // section -64--88-122--2-7471698e:1046ab3b89c:-7fe5 begin
  333.         parent :: __construct();
  334.         if (empty (self :: $data))
  335.             $this->updateData();
  336.         // section -64--88-122--2-7471698e:1046ab3b89c:-7fe5 end
  337.     }
  338.     /**
  339.      * liefert den Inhalt eines Feldes mit Namen Index
  340.      * aus dem Array $data
  341.      *
  342.      * @access public
  343.      * @author Kay Koch, <kay.koch@gmx.de>
  344.      * @param string 
  345.      * @return string 
  346.      */
  347.     private function __get($index{
  348.         $returnValue= (string) '';
  349.         //
  350.         try {
  351.             if (empty ($index))
  352.                 throw new Exception(4);
  353.             if (!isset (self :: $dataID[$index]))
  354.                 throw new Exception(4);
  355.             $returnValueself :: $dataID[$index];
  356.         catch (Exception $e{
  357.             src_tools_ERROR :: setError($e__METHOD__);
  358.         }
  359.         //
  360.         return ($returnValue);
  361.     }
  362.  
  363.     /**
  364.      * ändert das Datum aller Blockaden mit Wiederholung
  365.      * auf eine Woche später
  366.      *
  367.      * @access public
  368.      * @author Kay Koch, <kay.koch@gmx.de>
  369.      * @return boolean 
  370.      */
  371.     public function setEntriesToNewWeek({
  372.         $returnValue= (bool) false;
  373.         // section -64--88-60-100--6299d47e:109acba51de:-7ff1 begin
  374.         $whereWeekLimit$this->getFlags()->getWhereWeekLimit();
  375.         $sql"UPDATE IGNORE $this->dbTableName SET datum = ADDDATE(`datum`, INTERVAL 7 DAY)$whereWeekLimit " AND `wiederholung` = '1';";
  376.         if ($this->update($sql))
  377.             $returnValuetrue;
  378.         return (bool) $returnValue;
  379.         // section -64--88-60-100--6299d47e:109acba51de:-7ff1 end
  380.     }
  381.  
  382.     /**
  383.      * löscht alle Blockaden ohne Wiederholung
  384.      * bis zum nächsten Update
  385.      *
  386.      * @access public
  387.      * @author Kay Koch, <kay.koch@gmx.de>
  388.      * @return boolean 
  389.      */
  390.     public function deleteOldEntries({
  391.         $returnValue= (bool) false;
  392.  
  393.         // section -64--88-60-100--6299d47e:109acba51de:-7fee begin
  394.         $weekLimit$this->getFlags()->getWhereWeekLimit();
  395.         $sql"DELETE FROM " $this->dbTableName . $weekLimit " AND `wiederholung` = '0' ";
  396.         if ($this->delete($sql))
  397.             $returnValuetrue;
  398.         // section -64--88-60-100--6299d47e:109acba51de:-7fee end
  399.  
  400.         return (bool) $returnValue;
  401.     }
  402.  
  403.  
  404. /* end of class src_foundation_tables_BLOCKADEN */
  405. ?>

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