X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=admin%2Finst_module.php;h=5c3603d94a65e3ac3fbad120b7993f498ce806d8;hb=20c9b5846824f0489c6791d74a6c78e2bfb0b2fc;hp=52190ca7eabe2fe968df80479462ce59eb36f2d8;hpb=cef4b4de401511a4195b7b8ad04b47bec1895b20;p=fa-stable.git diff --git a/admin/inst_module.php b/admin/inst_module.php index 52190ca7..5c3603d9 100644 --- a/admin/inst_module.php +++ b/admin/inst_module.php @@ -14,6 +14,9 @@ $path_to_root=".."; include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root."/includes/packages.inc"); +if ($use_popup_windows) { + $js = get_js_open_window(900, 500); +} page(_($help_context = "Install/Activate extensions")); include_once($path_to_root . "/includes/date_functions.inc"); @@ -47,7 +50,7 @@ function check_data($id, $exts) return false; } if ($id == -1 && !is_uploaded_file($_FILES['uploadfile']['tmp_name'])) { - display_error(_("You have to select plugin file to upload")); + display_error(_("You have to select extension file to upload")); return false; } return true; @@ -64,7 +67,8 @@ function handle_submit() return false; $id = $selected_id==-1 ? $next_extension_id : $selected_id; - if ($selected_id != -1 && $extensions[$id]['type'] != 'plugin') { + if ($selected_id != -1 && $extensions[$id]['type'] != 'extension' + || (isset($extensions[$id]['tabs']) && count($extensions[$id]['tabs']))) { display_error(_('Module installation support is not implemented.')); return; } @@ -79,8 +83,9 @@ function handle_submit() $entry['title'] = $_POST['title']; $entry['section'] = 2; // menu section aka module - // Only plugin extensions can be installed manually. - $extensions[$id]['type'] = 'plugin'; + // Only simple plugin type extensions can be installed manually. + $extensions[$id]['type'] = 'extension'; + $extensions[$id]['path'] = 'modules/'.$_POST['path']; $directory = $path_to_root . "/modules/" . $_POST['path']; if (!file_exists($directory)) { @@ -88,7 +93,7 @@ function handle_submit() } if (is_uploaded_file($_FILES['uploadfile']['tmp_name'])) { - $entry['url'] = '/modules/'.$_POST['path'].'/'.$_FILES['uploadfile']['name']; + $entry['url'] = $_FILES['uploadfile']['name']; $file1 = $_FILES['uploadfile']['tmp_name']; $file2 = $directory . "/".$_FILES['uploadfile']['name']; if (file_exists($file2)) @@ -96,7 +101,7 @@ function handle_submit() move_uploaded_file($file1, $file2); } else - $entry['url'] = '/modules/'.$_POST['path'].'/'.get_post('filename'); + $entry['url'] = get_post('filename'); if (is_uploaded_file($_FILES['uploadfile2']['tmp_name'])) { @@ -107,7 +112,7 @@ function handle_submit() if (is_uploaded_file($_FILES['uploadfile3']['tmp_name'])) { - $extensions[$id]['acc_file'] = '/modules/'.$_POST['path'].'/'.$_FILES['uploadfile3']['name']; + $extensions[$id]['acc_file'] = $_FILES['uploadfile3']['name']; $file1 = $_FILES['uploadfile3']['tmp_name']; $file2 = $directory . "/".$_FILES['uploadfile3']['name']; if (file_exists($file2)) @@ -115,10 +120,10 @@ function handle_submit() move_uploaded_file($file1, $file2); } else - $extensions[$id]['acc_file'] = '/modules/'.$_POST['path'].'/'.get_post('acc_file'); + $extensions[$id]['acc_file'] = get_post('acc_file'); // security area guess for plugins - $exttext = file_get_contents($path_to_root.$entry['url']); + $exttext = file_get_contents($path_to_root.'/'.$extensions[$id]['path'].'/'.$entry['url']); $area = 'SA_OPEN'; if (preg_match('/.*\$page_security\s*=\s*[\'"]([^\'"]*)/', $exttext, $match)) { $area = trim($match[1]); @@ -147,9 +152,9 @@ function handle_delete($id) return false; } else { - $dirname = dirname(@$extensions[$id]['entries'][0]['url']); + $dirname = $extensions[$id]['path']; if ($dirname) { - $dirname = $path_to_root.$dirname; + $dirname = $path_to_root.'/'.$dirname; flush_dir($dirname, true); rmdir($dirname); } @@ -186,7 +191,7 @@ function display_extensions() table_header($th); $k = 0; - $mods = get_extensions_list(); + $mods = get_extensions_list('extension'); foreach($mods as $pkg_name => $ext) { @@ -208,7 +213,7 @@ function display_extensions() ($available && $installed ? $installed : _("Unknown"))); label_cell($available ? $available : _("None")); - if (!$available && $ext['type'] == 'plugin') // third-party plugin + if (!$available && $ext['type'] == 'extension' && !count(@$ext['tabs'])) // third-party plugin button_cell('Edit'.$id, _("Edit"), _('Edit third-party extension parameters.'), ICON_EDIT); elseif (check_pkg_upgrade($installed, $available)) // outdated or not installed extension in repo @@ -231,7 +236,7 @@ function display_extensions() end_table(1); submit_center_first('Refresh', _("Update"), '', null); - submit_center_last('Add', _("Add third-party plugin"), '', false); + submit_center_last('Add', _("Add third-party extension"), '', false); div_end(); } @@ -260,6 +265,7 @@ function company_extensions($id) $k = 0; foreach($mods as $i => $mod) { + if ($mod['type'] != 'extension') continue; alt_table_row_color($k); label_cell($mod['name']); $entries = fmt_titles(@$mod['entries']); @@ -288,7 +294,7 @@ function display_ext_edit($selected_id) start_table(TABLESTYLE2); - if ($selected_id != -1 && $extensions[$selected_id]['type'] == 'plugin') + if ($selected_id != -1 && $extensions[$selected_id]['type'] == 'extension') { if ($Mode == 'Edit') { $mod = $extensions[$selected_id]; @@ -297,7 +303,7 @@ function display_ext_edit($selected_id) $_POST['name'] = $mod['name']; $_POST['tab'] = $entry['tab_id']; $_POST['title'] = $entry['title']; - $_POST['path'] = substr(dirname($entry['url']), 9); //strip '/modules/' + $_POST['path'] = substr(dirname($mod['path']), 9); //strip '/modules/' $_POST['filename'] = basename($entry['url']); $_POST['acc_file'] = @$mod['acc_file'] ? basename($mod['acc_file']) : null; hidden('filename', $_POST['filename']); @@ -306,20 +312,22 @@ function display_ext_edit($selected_id) hidden('selected_id', $selected_id); } text_row_ex(_("Name"), 'name', 30); - text_row_ex(_("Folder"), 'path', 20); + text_row_ex(_("Subfolder (in modules directory)"), 'path', 20); tab_list_row(_("Menu Tab"), 'tab', null, true); text_row_ex(_("Menu Link Text"), 'title', 30); record_status_list_row(_("Default status"), 'active'); - file_row(_("Module File"), 'uploadfile'); - file_row(_("Access Levels Extensions"), 'uploadfile3'); + file_row(_("Extension File"), 'uploadfile'); + file_row(_("Access Levels File"), 'uploadfile3'); file_row(_("SQL File"), 'uploadfile2'); end_table(0); - display_note(_("Select your module PHP file from your local harddisk."), 0, 1); - submit_add_or_update_center($selected_id == -1, '', 'both'); + display_note(_("Select your extension PHP files from your local harddisk."), 0, 1); + echo '
'; + submit_add_or_update($selected_id == -1, '', 'both'); + echo '
'; } //---------------------------------------------------------------------------------------------