  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: batch_edit.php 1850 2009-02-28 03:07:56Z hpdl $ |
| |
| 3 | + | $Id: batch_edit.php 1851 2009-02-28 03:08:07Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
7 | 7 | | |
  |
8 | | - | Copyright (c) 2007 osCommerce |
| |
| 8 | + | Copyright (c) 2009 osCommerce |
|
9 | 9 | | |
| |
10 | 10 | | This program is free software; you can redistribute it and/or modify |
| |
11 | 11 | | it under the terms of the GNU General Public License v2 (1991) |
| |
12 | 12 | | as published by the Free Software Foundation. |
| |
13 | 13 | | */ |
  |
14 | | - | |
| |
15 | | - | $osC_DirectoryListing = new osC_DirectoryListing('includes/modules/access'); |
| |
16 | | - | $osC_DirectoryListing->setIncludeDirectories(false); |
| |
17 | | - | |
| |
18 | | - | $access_modules_array = array(); |
| |
19 | | - | |
| |
20 | | - | foreach ($osC_DirectoryListing->getFiles() as $file) { |
| |
21 | | - | $module = substr($file['name'], 0, strrpos($file['name'], '.')); |
| |
22 | | - | |
| |
23 | | - | if (!class_exists('osC_Access_' . ucfirst($module))) { |
| |
24 | | - | $osC_Language->loadIniFile('modules/access/' . $file['name']); |
| |
25 | | - | include($osC_DirectoryListing->getDirectory() . '/' . $file['name']); |
| |
26 | | - | } |
| |
27 | | - | |
| |
28 | | - | $module = 'osC_Access_' . ucfirst($module); |
| |
29 | | - | $module = new $module(); |
| |
30 | | - | |
| |
31 | | - | $access_modules_array[osC_Access::getGroupTitle( $module->getGroup() )][] = array('id' => $module->getModule(), |
| |
32 | | - | 'text' => $module->getTitle()); |
| |
33 | | - | } |
| |
34 | | - | |
| |
35 | | - | ksort($access_modules_array); |
|
36 | 14 | | ?> |
| |
37 | 15 | | |
| |
38 | 16 | | <h1><?php echo osc_link_object(osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule()), $osC_Template->getPageTitle()); ?></h1> |
| |
39 | 17 | | |
| |
40 | 18 | | <?php |
  |
41 | | - | if ($osC_MessageStack->size($osC_Template->getModule()) > 0) { |
| |
| 19 | + | if ( $osC_MessageStack->exists($osC_Template->getModule()) ) { |
|
42 | 20 | | echo $osC_MessageStack->get($osC_Template->getModule()); |
| |
43 | 21 | | } |
| |
44 | 22 | | ?> |
| |
45 | 23 | | |
| |
46 | 24 | | <div class="infoBoxHeading"><?php echo osc_icon('edit.png') . ' ' . $osC_Language->get('action_heading_batch_edit_administrators'); ?></div> |
| |
47 | 25 | | <div class="infoBoxContent"> |
  |
48 | | - | <form name="aEditBatch" action="<?php echo osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule() . '&page=' . $_GET['page'] . '&action=batchSave'); ?>" method="post"> |
| |
| 26 | + | <form name="aEditBatch" class="dataForm" action="<?php echo osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule() . '&action=batch_save'); ?>" method="post"> |
|
49 | 27 | | |
| |
50 | 28 | | <p><?php echo $osC_Language->get('introduction_batch_edit_administrators'); ?></p> |
| |
51 | 29 | | |
| |
|
|
 |
… |
|
57 | 35 | | |
| |
58 | 36 | | $names_string = ''; |
| |
59 | 37 | | |
  |
60 | | - | while ($Qadmins->next()) { |
| |
61 | | - | $names_string .= osc_draw_hidden_field('batch[]', $Qadmins->valueInt('id')) . '<b>' . $Qadmins->value('user_name') . '</b>, '; |
| |
| 38 | + | while ( $Qadmins->next() ) { |
| |
| 39 | + | $names_string .= osc_draw_hidden_field('batch[]', $Qadmins->valueInt('id')) . '<b>' . $Qadmins->valueProtected('user_name') . '</b>, '; |
|
62 | 40 | | } |
| |
63 | 41 | | |
| |
64 | 42 | | if ( !empty($names_string) ) { |
| |
65 | 43 | | $names_string = substr($names_string, 0, -2); |
| |
66 | 44 | | } |
| |
67 | 45 | | |
| |
68 | 46 | | echo '<p>' . $names_string . '</p>'; |
  |
| 47 | + | ?> |
|
69 | 48 | | |
  |
70 | | - | echo '<p>' . osc_draw_radio_field('mode', array(array('id' => OSC_ADMINISTRATORS_ACCESS_MODE_ADD, 'text' => $osC_Language->get('add_to')), array('id' => OSC_ADMINISTRATORS_ACCESS_MODE_REMOVE, 'text' => $osC_Language->get('remove_from')), array('id' => OSC_ADMINISTRATORS_ACCESS_MODE_SET, 'text' => $osC_Language->get('set_to'))), OSC_ADMINISTRATORS_ACCESS_MODE_ADD) . '</p>'; |
| |
| 49 | + | <fieldset> |
| |
| 50 | + | <div><?php echo osc_draw_radio_field('mode', array(array('id' => osC_Administrators_Admin::ACCESS_MODE_ADD, 'text' => $osC_Language->get('add_to')), array('id' => osC_Administrators_Admin::ACCESS_MODE_REMOVE, 'text' => $osC_Language->get('remove_from')), array('id' => osC_Administrators_Admin::ACCESS_MODE_SET, 'text' => $osC_Language->get('set_to'))), osC_Administrators_Admin::ACCESS_MODE_ADD); ?></div> |
|
71 | 51 | | |
  |
72 | | - | echo '<ul style="list-style-type: none; padding-left: 0;">' . |
| |
73 | | - | ' <li>' . osc_draw_checkbox_field('modules[]', '*', null, 'id="access_globaladmin"') . ' <label for="access_globaladmin"><b>' . $osC_Language->get('global_access') . '</b></label></li>' . |
| |
74 | | - | '</ul>' . |
| |
75 | | - | '<ul style="list-style-type: none; padding-left: 0;">'; |
| |
| 52 | + | <div><select name="accessModules" id="modulesList"><option value="-1" disabled="disabled">-- Access Modules --</option><option value="0"><?php echo $osC_Language->get('global_access'); ?></option></select></div> |
|
76 | 53 | | |
  |
77 | | - | foreach ( $access_modules_array as $group => $modules ) { |
| |
78 | | - | echo ' <li><b>' . $group . '</b>' . |
| |
79 | | - | ' <ul style="list-style-type: none; padding-left: 15px;">'; |
| |
| 54 | + | <ul id="accessToModules" class="modulesListing"></ul> |
| |
| 55 | + | </fieldset> |
|
80 | 56 | | |
  |
81 | | - | foreach ($modules as $module) { |
| |
82 | | - | echo ' <li>' . osc_draw_checkbox_field('modules[]', $module['id'], null, 'id="access_' . $module['id'] . '"') . ' <label for="access_' . $module['id'] . '" class="fieldLabel">' . $module['text'] . '</label></li>'; |
| |
83 | | - | } |
| |
| 57 | + | <p align="center"><?php echo osc_draw_hidden_field('subaction', 'confirm') . '<input type="submit" value="' . $osC_Language->get('button_save') . '" class="operationButton" /> <input type="button" value="' . $osC_Language->get('button_cancel') . '" onclick="document.location.href=\'' . osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule()) . '\';" class="operationButton" />'; ?></p> |
|
84 | 58 | | |
  |
85 | | - | echo ' </ul>' . |
| |
86 | | - | ' </li>'; |
| |
87 | | - | } |
| |
| 59 | + | </form> |
| |
| 60 | + | </div> |
|
88 | 61 | | |
  |
89 | | - | echo '</ul>'; |
| |
90 | | - | ?> |
| |
| 62 | + | <script type="text/javascript"><!-- |
| |
| 63 | + | var accessModules = <?php echo json_encode(osC_Administrators_Admin::getAccessModules()); ?>; |
| |
| 64 | + | var deleteAccessModuleIcon = '<?php echo osc_icon('uninstall.png'); ?>'; |
|
91 | 65 | | |
  |
92 | | - | <p align="center"><?php echo osc_draw_hidden_field('subaction', 'confirm') . '<input type="submit" value="' . $osC_Language->get('button_save') . '" class="operationButton" /> <input type="button" value="' . $osC_Language->get('button_cancel') . '" onclick="document.location.href=\'' . osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule() . '&page=' . $_GET['page']) . '\';" class="operationButton" />'; ?></p> |
| |
| 66 | + | var $modulesList = $('#modulesList'); |
|
93 | 67 | | |
  |
94 | | - | </form> |
| |
95 | | - | </div> |
| |
| 68 | + | $.each(accessModules, function(i, item) { |
| |
| 69 | + | var sGroup = document.createElement('optgroup'); |
| |
| 70 | + | sGroup.label = i; |
| |
| 71 | + | |
| |
| 72 | + | $.each(item, function(key, value) { |
| |
| 73 | + | var sOption = new Option(value['text'], value['id']); |
| |
| 74 | + | sOption.id = 'am' + value['id']; |
| |
| 75 | + | |
| |
| 76 | + | sGroup.appendChild(sOption); |
| |
| 77 | + | }); |
| |
| 78 | + | |
| |
| 79 | + | $modulesList.append(sGroup); |
| |
| 80 | + | }); |
| |
| 81 | + | |
| |
| 82 | + | $('#modulesList').change(function() { |
| |
| 83 | + | if ( $('#modulesList :selected').val() == '0' ) { |
| |
| 84 | + | $('#accessToModules li').remove(); |
| |
| 85 | + | $('#accessToModules').append('<li id="atm' + $('#modulesList :selected').val() + '">' + $('#modulesList :selected').text() + ' <span style="float: right;"><a href="#" onclick="removeAccessToModule(\'' + $('#modulesList :selected').val() + '\');">' + deleteAccessModuleIcon + '</a><input type="hidden" name="modules[]" value="' + $('#modulesList :selected').val() + '" /></span></li>'); |
| |
| 86 | + | |
| |
| 87 | + | $('#modulesList').attr('disabled', 'disabled'); |
| |
| 88 | + | $('#modulesList').val('-1'); |
| |
| 89 | + | |
| |
| 90 | + | $('#accessToModules li').tsort(); |
| |
| 91 | + | } else if ( $('#modulesList :selected').val() != '-1' ) { |
| |
| 92 | + | $('#accessToModules').append('<li id="atm' + $('#modulesList :selected').val() + '">' + $('#modulesList :selected').parent().attr('label') + ' » ' + $('#modulesList :selected').text() + ' <span style="float: right;"><a href="#" onclick="removeAccessToModule(\'' + $('#modulesList :selected').val() + '\');">' + deleteAccessModuleIcon + '</a><input type="hidden" name="modules[]" value="' + $('#modulesList :selected').val() + '" /></span></li>'); |
| |
| 93 | + | |
| |
| 94 | + | $('#modulesList :selected').attr('disabled', 'disabled'); |
| |
| 95 | + | $('#modulesList').val('-1'); |
| |
| 96 | + | |
| |
| 97 | + | $('#accessToModules li').tsort(); |
| |
| 98 | + | } |
| |
| 99 | + | }); |
| |
| 100 | + | |
| |
| 101 | + | function removeAccessToModule(module) { |
| |
| 102 | + | if ( module == '0' ) { |
| |
| 103 | + | $('#modulesList').removeAttr('disabled'); |
| |
| 104 | + | $('#modulesList :disabled').removeAttr('disabled'); |
| |
| 105 | + | $('#modulesList :first').attr('disabled', 'disabled'); |
| |
| 106 | + | } else { |
| |
| 107 | + | $('#am' + module).removeAttr('disabled'); |
| |
| 108 | + | } |
| |
| 109 | + | |
| |
| 110 | + | $('#atm' + module).remove(); |
| |
| 111 | + | } |
| |
| 112 | + | //--></script> |