Fixed warning during database restore.
[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
13 define('MENU_ENTRY', 'menu_entry');
14 define('MENU_TRANSACTION', 'menu_transaction');
15 define('MENU_INQUIRY', 'menu_inquiry');
16 define('MENU_REPORT', 'menu_report');
17 define('MENU_MAINTENANCE', 'menu_maintenance');
18 define('MENU_UPDATE', 'menu_update');
19 define('MENU_SETTINGS', 'menu_settings');
20 define('MENU_SYSTEM', 'menu_system');
21
22         class menu_item
23         {
24                 var $label;
25                 var $link;
26                 
27                 function menu_item($label, $link) 
28                 {
29                         $this->label = $label;
30                         $this->link = $link;
31                 }
32         }
33
34         class menu 
35         {
36                 var $title;
37                 var $items;
38                 
39                 function menu($title) 
40                 {
41                         $this->title = $title;
42                         $this->items = array();
43                 }
44                 
45                 function add_item($label, $link) 
46                 {
47                         $item = new menu_item($label,$link);
48                         array_push($this->items,$item);
49                         return $item;
50                 }
51                 
52         }
53
54         class app_function 
55         {
56                 var $label;
57                 var $link;
58                 var $access;
59                 var $category;
60                 
61                 function app_function($label,$link,$access='SA_OPEN',$category='')
62                 {
63                         $this->label = $label;
64                         $this->link = $link;
65                         $this->access = $access;
66             $this->category = $category;
67                 }
68         }
69
70         class module 
71         {
72                 var $name;
73                 var $icon;
74                 var $lappfunctions;
75                 var $rappfunctions;
76                 
77                 function module($name,$icon = null) 
78                 {
79                         $this->name = $name;
80                         $this->icon = $icon;
81                         $this->lappfunctions = array();
82                         $this->rappfunctions = array();
83                 }
84                 
85                 function add_lapp_function($label,$link="",$access='SA_OPEN',$category='')
86                 {
87                         $appfunction = new app_function($label,$link,$access,$category);
88                         //array_push($this->lappfunctions,$appfunction);
89                         $this->lappfunctions[] = $appfunction;
90                         return $appfunction;
91                 }
92
93                 function add_rapp_function($label,$link="",$access='SA_OPEN',$category='')
94                 {
95                         $appfunction = new app_function($label,$link,$access,$category);
96                         //array_push($this->rappfunctions,$appfunction);
97                         $this->rappfunctions[] = $appfunction;
98                         return $appfunction;
99                 }
100                 
101                 
102         }
103
104         class application 
105         {
106                 var $id;
107                 var $name;
108                 var $help_context;
109                 var $modules;
110                 var $enabled;
111                 
112                 function application($id, $name, $enabled=true) 
113                 {
114                         $this->id = $id;
115                         $this->name = $name;
116                         $this->enabled = $enabled;
117                         $this->modules = array();
118                 }
119                 
120                 function add_module($name, $icon = null) 
121                 {
122                         $module = new module($name,$icon);
123                         //array_push($this->modules,$module);
124                         $this->modules[] = $module;
125                         return $module;
126                 }
127                 
128                 function add_lapp_function($level, $label,$link="",$access='SA_OPEN',$category='')
129                 {
130                         $this->modules[$level]->lappfunctions[] = new app_function($label, $link, $access, $category);
131                 }
132                 
133                 function add_rapp_function($level, $label,$link="",$access='SA_OPEN',$category='')
134                 {
135                         $this->modules[$level]->rappfunctions[] = new app_function($label, $link, $access, $category);
136                 }
137                 
138                 function add_extensions()
139                 {
140                         hook_invoke_all('install_options', $this);
141                 }
142                 //
143                 // Helper returning link to report class added by extension module.
144                 //
145                 function report_class_url($class)
146                 {
147                         global $installed_extensions;
148
149                         // TODO : konwencja lub ?
150                         $classno = 7;
151 //                      if (file_exists($path_to_root.'/'.$mod['path'].'/'.$entry['url']
152 //                                      .'/'.'reporting/reports_custom.php'))
153                                 return "reporting/reports_main.php?Class=".$class;
154 //                      else
155 //                              return '';
156                 }
157         }
158
159
160 ?>