9220d14315eadd9ef10d53db4249e52e32a3790f
[fa-stable.git] / applications / application.php
1 <?php
2 /**********************************************************************
3     Copyright (C) FrontAccounting, LLC.
4         Released under the terms of the GNU General Public License, GPL, 
5         as published by the Free Software Foundation, either version 3 
6         of the License, or (at your option) any later version.
7     This program is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
10     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12         class menu_item 
13         {
14                 var $label;
15                 var $link;
16                 
17                 function menu_item($label, $link) 
18                 {
19                         $this->label = $label;
20                         $this->link = $link;
21                 }
22         }
23
24         class menu 
25         {
26                 var $title;
27                 var $items;
28                 
29                 function menu($title) 
30                 {
31                         $this->title = $title;
32                         $this->items = array();
33                 }
34                 
35                 function add_item($label, $link) 
36                 {
37                         $item = new menu_item($label,$link);
38                         array_push($this->items,$item);
39                         return $item;
40                 }
41                 
42         }
43
44         class app_function 
45         {
46                 var $label;
47                 var $link;
48                 var $access;
49                 
50                 function app_function($label,$link,$access='SA_OPEN') 
51                 {
52                         $this->label = $label;
53                         $this->link = $link;
54                         $this->access = $access;
55                 }
56         }
57
58         class module 
59         {
60                 var $name;
61                 var $icon;
62                 var $lappfunctions;
63                 var $rappfunctions;
64                 
65                 function module($name,$icon = null) 
66                 {
67                         $this->name = $name;
68                         $this->icon = $icon;
69                         $this->lappfunctions = array();
70                         $this->rappfunctions = array();
71                 }
72                 
73                 function add_lapp_function($label,$link="",$access='SA_OPEN') 
74                 {
75                         $appfunction = new app_function($label,$link,$access);
76                         //array_push($this->lappfunctions,$appfunction);
77                         $this->lappfunctions[] = $appfunction;
78                         return $appfunction;
79                 }
80
81                 function add_rapp_function($label,$link="",$access='SA_OPEN') 
82                 {
83                         $appfunction = new app_function($label,$link,$access);
84                         //array_push($this->rappfunctions,$appfunction);
85                         $this->rappfunctions[] = $appfunction;
86                         return $appfunction;
87                 }
88                 
89                 
90         }
91
92         class application 
93         {
94                 var $id;
95                 var $name;
96                 var $modules;
97                 var $enabled;
98                 
99                 function application($id, $name, $enabled=true) 
100                 {
101                         $this->id = $id;
102                         $this->name = $name;
103                         $this->enabled = $enabled;
104                         $this->modules = array();
105                 }
106                 
107                 function add_module($name, $icon = null) 
108                 {
109                         $module = new module($name,$icon);
110                         //array_push($this->modules,$module);
111                         $this->modules[] = $module;
112                         return $module;
113                 }
114                 
115                 function add_lapp_function($level, $label,$link="",$access='SA_OPEN') 
116                 {
117                         $this->modules[$level]->lappfunctions[] = new app_function($label, $link, $access);
118                 }       
119                         
120                 function add_rapp_function($level, $label,$link="",$access='SA_OPEN') 
121                 {
122                         $this->modules[$level]->rappfunctions[] = new app_function($label, $link, $access);
123                 }       
124         }
125
126
127 ?>