classes/bfw/mvc/model/TGroup.php
changeset 1 56e0dbd5c243
parent 0 4869aea77e21
equal deleted inserted replaced
0:4869aea77e21 1:56e0dbd5c243
     1 <?php
     1 <?php
     2 
     2 
     3 namespace bfw\mvc\model {
     3 namespace bfw\mvc\model;
       
     4 
       
     5 use bfw\mvc\common\Model;
       
     6 
       
     7 /**
       
     8  * Class TGroup
       
     9  *
       
    10  * @method string getName()
       
    11  * @mthod setName($param)
       
    12  */
       
    13 class TGroup extends Model {
       
    14     const GUEST = 5;
       
    15     const SUPPORTER = 4;
       
    16     const MANAGER = 3;
       
    17     const ADMIN = 2;
       
    18     const SYSTEM = 1;
       
    19 
       
    20     public function __construct() {
       
    21         parent::__construct('t_group');
       
    22 
       
    23         $this->data = array(
       
    24             'id' => NULL,
       
    25             'name' => '',
       
    26         );
       
    27     }
     4 
    28 
     5     /**
    29     /**
     6      * Class TGroup
    30      * @param $name
       
    31      * @return array|null
       
    32      */
       
    33     public function findByName($name) {
       
    34         return $this->db->findByField('t_group', 'name', $name);
       
    35     }
       
    36 
       
    37     /**
       
    38      * <b>Besorgt ein Array mit der Liste der Manager und Darunter</b>
     7      *
    39      *
     8      * @method string getName()
    40      * @return array|null
     9      * @mthod setName($param)
       
    10      */
    41      */
    11     class TGroup extends Model {
    42     public function findAllManagersAndBelow() {
    12         const GUEST = 5;
    43         /**
    13         const SUPPORTER = 4;
    44          * SYSTEM = 1
    14         const MANAGER = 3;
    45          * ADMIN = 2
    15         const ADMIN = 2;
    46          *  [MANAGER = 3, SUPPORTER = 4]
    16         const SYSTEM = 1;
    47          * GUEST = 5
       
    48          */
       
    49         $groups = $this->db->fetchAll($this->table, 'id > 2 and id < 5');
    17 
    50 
    18         public function __construct() {
    51         $list = array();
    19             parent::__construct('t_group');
    52         foreach ($groups as $group) {
       
    53             $item = new static();
       
    54             $item->data = $group;
    20 
    55 
    21             $this->data = array(
    56             $list[] = $item;
    22                 'id' => NULL,
       
    23                 'name' => '',
       
    24             );
       
    25         }
    57         }
    26 
    58 
    27         /**
    59         return $list;
    28          * @param $name
       
    29          * @return array|null
       
    30          */
       
    31         public function findByName($name) {
       
    32             return $this->db->findByField('t_group', 'name', $name);
       
    33         }
       
    34 
       
    35         /**
       
    36          * <b>Besorgt ein Array mit der Liste der Manager und Darunter</b>
       
    37          *
       
    38          * @return array|null
       
    39          */
       
    40         public function findAllManagersAndBelow() {
       
    41             /**
       
    42              * SYSTEM = 1
       
    43              * ADMIN = 2
       
    44              *  [MANAGER = 3, SUPPORTER = 4]
       
    45              * GUEST = 5
       
    46              */
       
    47             $groups = $this->db->fetchAll($this->table, 'id > 2 and id < 5');
       
    48 
       
    49             $list = array();
       
    50             foreach ($groups as $group) {
       
    51                 $item = new static();
       
    52                 $item->data = $group;
       
    53 
       
    54                 $list[] = $item;
       
    55             }
       
    56 
       
    57             return $list;
       
    58         }
       
    59     }
    60     }
    60 }
    61 }