Source for file class.BEFUGNISSE.php

Documentation is available at class.BEFUGNISSE.php

  1. <?php
  2.  
  3. /**
  4.  * Ernöglicht den Zugang zur Datenbank befugnisse
  5.  *
  6.  * @author Kay Koch, <kay.koch@gmx.de>
  7.  * @package src
  8.  * @subpackage foundation_tables
  9.  */
  10.  
  11. if (version_compare(PHP_VERSION'5'))
  12. {
  13.     die('This file was generated for PHP 5');
  14. }
  15.  
  16. /**
  17.  * Basisklasse aller Klassen mit Datenbankzugriff.
  18.  *
  19.  * stellt Methoden und Objekte zur Fehlermeldung und zum Datenbankzugriff zur
  20.  *
  21.  * @author Kay Koch
  22.  * @since 1.12.04
  23.  * @version 1.1
  24.  */
  25. require_once ('src/foundation/tables/class.PARENTTABLES.php');
  26.  
  27. /**
  28.  * Interface für die Klassen zur Manipulation der Datenbanktabellen
  29.  *
  30.  * @author Kay Koch, <kay.koch@gmx.de>
  31.  */
  32. require_once ('src/interfaces/interface.TABLEINTERFACE.php');
  33.  
  34. /* user defined includes */
  35. // section -64--88-122--2-75fd0b76:103dff6128d:-7fd9-includes begin
  36. // section -64--88-122--2-75fd0b76:103dff6128d:-7fd9-includes end
  37.  
  38. /* user defined constants */
  39. // section -64--88-122--2-75fd0b76:103dff6128d:-7fd9-constants begin
  40. // section -64--88-122--2-75fd0b76:103dff6128d:-7fd9-constants end
  41.  
  42. /**
  43.  * Ernöglicht den Zugang zur Datenbank befugnisse
  44.  *
  45.  * @access public
  46.  * @author Kay Koch, <kay.koch@gmx.de>
  47.  * @package src
  48.  * @subpackage foundation_tables
  49.  */
  50. {
  51.     // --- ATTRIBUTES ---
  52.  
  53.     
  54.     /**
  55.      * Beinhaltet den Datenbanknamen (befugnisse)
  56.      *
  57.      * @access protected
  58.      * @var string 
  59.      */
  60.     protected $dbTableName = 'befugnisse';
  61.  
  62.     /**
  63.      * array mit allen Befugnissen
  64.      *
  65.      * @access private
  66.      * @var array 
  67.      */
  68.     private static $data array ();
  69.  
  70.     /**
  71.      * aktuelle see_id
  72.      *
  73.      * @access public
  74.      * @var int 
  75.      */
  76.     public $see_id = 0;
  77.  
  78.     /**
  79.      * aktueller Wochentag
  80.      *
  81.      * @access public
  82.      * @var int 
  83.      */
  84.     public $wochentag = 0;
  85.  
  86.     /**
  87.      * aktuelle Fehlernummer
  88.      *
  89.      * @access public
  90.      * @var int 
  91.      */
  92.     private $errNr 0;
  93.  
  94.     // --- OPERATIONS ---
  95.  
  96.     
  97.     /**
  98.      * liefert einen (mehrere) Datensatz die durch setzen ser Parameter
  99.      * werden
  100.      *
  101.      * @access public
  102.      * @author Kay Koch, <kay.koch@gmx.de>
  103.      * @return array 
  104.      */
  105.     public function getRow()
  106.     {
  107.         $returnValue array ();
  108.  
  109.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab begin
  110.         if (!empty ($this->see_idAND !empty ($this->wochentag))
  111.             $returnValue self :: $data[$this->see_id][$this->wochentag];
  112.         else
  113.             if (!empty ($this->see_id))
  114.                 $returnValue self :: $data[$this->see_id];
  115.             else
  116.                 $returnValue self :: $data;
  117.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab end
  118.  
  119.         return (array) $returnValue;
  120.     }
  121.  
  122.     /**
  123.      * veranlasst ein Update
  124.      *
  125.      * @access public
  126.      * @author Kay Koch, <kay.koch@gmx.de>
  127.      * @param array 
  128.      * @return boolean 
  129.      */
  130.     public function updateRow($data)
  131.     {
  132.         $returnValue = (bool) false;
  133.  
  134.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa9 begin
  135.         try
  136.         {
  137.             $sql "UPDATE  IGNORE $this->dbTableName SET  ";
  138.             foreach ($data as $key => $value)
  139.                 $sql .= " `$key` = '$value',";
  140.             $sql substr($sql0-1);
  141.             $sql .= " WHERE see_id = '$this->see_idAND wochentag='$this->wochentag'";
  142.             if (!$this->update($sql))
  143.                 throw new Exception();
  144.             $this->updateData();
  145.             $returnValue true;
  146.         catch (Exception $e)
  147.         {
  148.             ;
  149.         }
  150.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa9 end
  151.  
  152.         return (bool) $returnValue;
  153.     }
  154.  
  155.     /**
  156.      * fügt einen neuen Datensatz ein
  157.      *
  158.      * @access public
  159.      * @author Kay Koch, <kay.koch@gmx.de>
  160.      * @param array 
  161.      * @return boolean 
  162.      */
  163.     public function insertRow($data)
  164.     {
  165.         $returnValue = (bool) false;
  166.  
  167.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa6 begin
  168.         try
  169.         {
  170.             $sql "INSERT IGNORE INTO $this->dbTableName (`see_id`, `wochentag`) VALUES ";
  171.             for ($weekday 1$weekday <= 7$weekday++)
  172.             {
  173.                 $sql .= "('$this->see_id' , '$weekday "'),";
  174.             }
  175.             $sql substr($sql0-1";";
  176.             if (!$this->insert($sql))
  177.                 throw new Exception();
  178.             $returnValue true;
  179.         catch (Exception $e)
  180.         {}
  181.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa6 end
  182.  
  183.         return (bool) $returnValue;
  184.     }
  185.  
  186.     /**
  187.      * löscht einen Datensatz
  188.      *
  189.      * @access public
  190.      * @author Kay Koch, <kay.koch@gmx.de>
  191.      * @return boolean 
  192.      */
  193.     public function deleteRow()
  194.     {
  195.         $returnValue = (bool) false;
  196.  
  197.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9e begin
  198.         try
  199.         {
  200.             $sql "DELETE FROM $this->dbTableName WHERE see_id = '$this->see_id'";
  201.             if (!$this->delete($sql))
  202.                 throw new Exception();
  203.             $this->updateData();
  204.             $returnValue true;
  205.         catch (Exception $e)
  206.         {
  207.             ;
  208.         }
  209.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9e end
  210.  
  211.         return (bool) $returnValue;
  212.     }
  213.  
  214.     /**
  215.      * aktualisiert die Daten im gegenwertigen Objekt
  216.      *
  217.      * @access public
  218.      * @author Kay Koch, <kay.koch@gmx.de>
  219.      * @return boolean 
  220.      */
  221.     public function updateData()
  222.     {
  223.         $returnValue = (bool) false;
  224.  
  225.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9c begin
  226.         $sql "SELECT  * FROM " $this->dbTableName . " ORDER by see_id, wochentag ASC";
  227.         self :: $data $this->select($sqltrue"see_id""wochentag");
  228.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9c end
  229.  
  230.         return (bool) $returnValue;
  231.     }
  232.  
  233.     /**
  234.      * löscht die Parameter, die den gegenwärtigen Datensatz identifizieren
  235.      *
  236.      * @access public
  237.      * @author Kay Koch, <kay.koch@gmx.de>
  238.      * @return void 
  239.      */
  240.     public function unsetParams()
  241.     {
  242.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f97 begin
  243.         unset ($this->see_id);
  244.         unset ($this->wochentag);
  245.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f97 end
  246.     }
  247.  
  248.     /**
  249.      * überprüft ob ein verein an diesem Tag tauchen darf
  250.      *
  251.      * @access public
  252.      * @author Kay Koch, <kay.koch@gmx.de>
  253.      * @param int 
  254.      * @param string 
  255.      * @param string 
  256.      * @param string 
  257.      * @return array 
  258.      */
  259.     public function canDive($see_id$datum$hour$verein_nr)
  260.     {
  261.         $returnValue = (bool) false;
  262.  
  263.         // section -64--88-122--2-75fd0b76:103dff6128d:-7fd3 begin
  264.         $weekday src_tools_TIME :: sqlT2realT($datum"%w");
  265.         try
  266.         {
  267.             if (!isset (self :: $data[$see_id][$weekday][$hour])) // Es gibt diesen Anmeldung nicht
  268.                 throw new Exception(39);
  269.             $oVerband new src_foundation_tables_VERBAENDE();
  270.             list ($allDivers$vdstDivers$oVerband->getConstants()// spezielle IDs
  271.             $permit self :: $data[$see_id][$weekday][$hour]// Erlaubnis an dueser Anmeldung
  272.             switch ($permit)
  273.             // wer darf hier tauchen
  274.                 case $allDivers // jeder
  275.                     break;
  276.                 case $vdstDivers // nur VDST
  277.                     if (empty ($verein_nr)) // wenn Anmeldung kein VDST-Mitglied ist
  278.                         throw new Exception(37);
  279.                     break;
  280.                 default // nur bestimmte Verbände
  281.                     if (empty ($verein_nr)) // wenn Anmeldung kein VDST-Mitglied ist
  282.                         throw new Exception(37);
  283.                     if (substr($verein_nr,0,2!= $permit// der Verband darf nicht tauchen
  284.                         throw new Exception(37);
  285.                     $oVerein new src_foundation_tables_VEREINE();
  286.                     if (!$oVerein->vereinExists($verein_nr)) // der Verein existiert nicht bei uns
  287.                         throw new Exception(39);
  288.                     break;
  289.             // switch
  290.             $returnValue true;
  291.         catch (Exception $e)
  292.         {
  293.             $this->errNr $e->getMessage();
  294.         }
  295.         // section -64--88-122--2-75fd0b76:103dff6128d:-7fd3 end
  296.  
  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 int 
  308.      * @return void 
  309.      */
  310.     public function setParams($see_id$datum null$wochentag 0)
  311.     {
  312.         // section -64--88-122--2--49bf02f4:103b2814a7e:-7fc5 begin
  313.         $this->see_id = $see_id;
  314.         if (!empty ($datum))
  315.             $this->wochentag = src_tools_TIME :: sqlT2realT($datum"%w");
  316.         if (!empty ($wochentag))
  317.             $this->wochentag = $wochentag;
  318.         // section -64--88-122--2--49bf02f4:103b2814a7e:-7fc5 end
  319.     }
  320.  
  321.     public function getErrNr()
  322.     {
  323.         $returnValue = (int) 0;
  324.         //
  325.         $returnValue $this->errNr;
  326.         //
  327.         return (int) $returnValue;
  328.     }
  329.  
  330.     /**
  331.      * Konstruktor
  332.      *
  333.      * lädt alle Befugnisse
  334.      *
  335.      * @access public
  336.      * @author Kay Koch, <kay.koch@gmx.de>
  337.      * @return void 
  338.      */
  339.     public function __construct()
  340.     {
  341.         // section -64--88-122--2-7471698e:1046ab3b89c:-7fe3 begin
  342.         parent :: __construct();
  343.         if (empty (self :: $data))
  344.             $this->updateData();
  345.         // section -64--88-122--2-7471698e:1046ab3b89c:-7fe3 end
  346.     }
  347.  
  348. /* end of class src_foundation_tables_BEFUGNISSE */
  349. ?>

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