70d8eb60a34afbc5768c5d6704e634a07367fa25
[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))
30         && clean_user_themes($installed_extensions[$id]['package']))
31 {
32         $extensions = get_company_extensions();
33         $theme = $extensions[$id]['package'];
34         if (uninstall_package($theme)) {
35                 $dirname = $path_to_root.'/themes/'.$theme;
36                 flush_dir($dirname, true);
37                 rmdir($dirname);
38                 unset($extensions[$id]);
39                 if (update_extensions($extensions)) {
40                         display_notification(_("Selected theme has been successfully deleted"));
41                         meta_forward($_SERVER['PHP_SELF']);
42                 }
43         }
44 }
45
46 if ($id = find_submit('Update', false))
47         install_extension($id);
48
49 //---------------------------------------------------------------------------------------------
50 start_form(true);
51
52         div_start('ext_tbl');
53         start_table(TABLESTYLE);
54
55         $th = array(_("Theme"),  _("Installed"), _("Available"), "", "");
56         table_header($th);
57
58         $k = 0;
59         $mods = get_themes_list();
60
61         foreach($mods as $pkg_name => $ext)
62         {
63                 $available = @$ext['available'];
64                 $installed = @$ext['version'];
65                 $id = @$ext['local_id'];
66
67                 alt_table_row_color($k);
68
69 //              label_cell(is_array($ext['Descr']) ? $ext['Descr'][0] : $ext['Descr']);
70                 label_cell($available ? get_package_view_str($pkg_name, $ext['name']) : $ext['name']);
71
72                 label_cell($id === null ? _("None") :
73                         ($available && $installed ? $installed : _("Unknown")));
74                 label_cell($available ? $available : _("None"));
75
76                 if ($available && check_pkg_upgrade($installed, $available)) // outdated or not installed theme in repo
77                         button_cell('Update'.$pkg_name, $installed ? _("Update") : _("Install"),
78                                 _('Upload and install latest extension package'), ICON_DOWN);
79                 else
80                         label_cell('');
81
82                 if ($id !== null) {
83                         delete_button_cell('Delete'.$id, _('Delete'));
84                         submit_js_confirm('Delete'.$id, 
85                                 sprintf(_("You are about to remove package \'%s\'.\nDo you want to continue ?"), 
86                                         $ext['name']));
87                 } else
88                         label_cell('');
89
90                 end_row();
91         }
92
93         end_table(1);
94
95         div_end();
96
97 //---------------------------------------------------------------------------------------------
98 end_form();
99
100 end_page();