Prevent empty log lines and a couple of include cleanups.
[fa-stable.git] / admin / inst_theme.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 $page_security = 'SA_CREATEMODULES';
13 $path_to_root="..";
14 include_once($path_to_root . "/includes/session.inc");
15 include_once($path_to_root."/includes/packages.inc");
16
17 if ($SysPrefs->use_popup_windows) {
18         $js = get_js_open_window(900, 500);
19 }
20 page(_($help_context = "Install Themes"), false, false, '', $js);
21
22 include_once($path_to_root . "/includes/date_functions.inc");
23 include_once($path_to_root . "/admin/db/company_db.inc");
24 include_once($path_to_root . "/admin/db/maintenance_db.inc");
25 include_once($path_to_root . "/includes/ui.inc");
26
27 //---------------------------------------------------------------------------------------------
28
29 if (($id = find_submit('Delete', false)) && isset($installed_extensions[$id])
30         && clean_user_themes($installed_extensions[$id]['package']))
31 {
32         $extensions = get_company_extensions();
33         $theme = $extensions[$id]['package'];
34         $path = $extensions[$id]['path'];
35
36         if (uninstall_package($theme)) {
37                 $dirname = $path_to_root.'/'.$path;
38                 flush_dir($dirname, true);
39                 rmdir($dirname);
40                 unset($extensions[$id]);
41                 if (update_extensions($extensions)) {
42                         display_notification(_("Selected theme has been successfully deleted"));
43                         meta_forward($_SERVER['PHP_SELF']);
44                 }
45         }
46 }
47
48 if ($id = find_submit('Update', false))
49         install_extension($id);
50
51 //---------------------------------------------------------------------------------------------
52 start_form(true);
53
54         div_start('ext_tbl');
55         start_table(TABLESTYLE);
56
57         $th = array(_("Theme"),  _("Installed"), _("Available"), "", "");
58         $k = 0;
59
60         $mods = get_themes_list();
61
62         if (!$mods)
63                 display_note(_("No optional theme is currently available."));
64         else
65         {
66                 table_header($th);
67
68                 foreach($mods as $pkg_name => $ext)
69                 {
70                         $available = @$ext['available'];
71                         $installed = @$ext['version'];
72                         $id = @$ext['local_id'];
73
74                         alt_table_row_color($k);
75
76 //              label_cell(is_array($ext['Descr']) ? $ext['Descr'][0] : $ext['Descr']);
77                         label_cell($available ? get_package_view_str($pkg_name, $ext['name']) : $ext['name']);
78
79                         label_cell($id === null ? _("None") :
80                                 ($available && $installed ? $installed : _("Unknown")));
81                         label_cell($available ? $available : _("None"));
82
83                         if ($available && check_pkg_upgrade($installed, $available)) // outdated or not installed theme in repo
84                                 button_cell('Update'.$pkg_name, $installed ? _("Update") : _("Install"),
85                                         _('Upload and install latest extension package'), ICON_DOWN, 'process');
86                         else
87                                 label_cell('');
88
89                         if ($id !== null) {
90                                 delete_button_cell('Delete'.$id, _('Delete'));
91                                 submit_js_confirm('Delete'.$id, 
92                                         sprintf(_("You are about to remove package \'%s\'.\nDo you want to continue ?"), 
93                                                 $ext['name']));
94                         } else
95                                 label_cell('');
96
97                         end_row();
98                 }
99
100                 end_table(1);
101         }
102         div_end();
103
104 //---------------------------------------------------------------------------------------------
105 end_form();
106
107 end_page();