Quick Search:

View

Revision:

Diff

Diff from 1851 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/hpdl/oscommerce/admin/includes/applications/administrators/pages/batch_edit.php

Annotated File View

hpdl
1125
1 <?php
2 /*
3   $Id: batch_edit.php 1851 2009-02-28 03:08:07Z hpdl $
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
hpdl
1851
8   Copyright (c) 2009 osCommerce
hpdl
1125
9
hpdl
1497
10   This program is free software; you can redistribute it and/or modify
11   it under the terms of the GNU General Public License v2 (1991)
12   as published by the Free Software Foundation.
hpdl
1125
13 */
14 ?>
15
hpdl
1405
16 <h1><?php echo osc_link_object(osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule()), $osC_Template->getPageTitle()); ?></h1>
hpdl
1125
17
18 <?php
hpdl
1851
19   if ( $osC_MessageStack->exists($osC_Template->getModule()) ) {
hpdl
1845
20     echo $osC_MessageStack->get($osC_Template->getModule());
hpdl
1125
21   }
22 ?>
23
hpdl
1475
24 <div class="infoBoxHeading"><?php echo osc_icon('edit.png') . ' ' . $osC_Language->get('action_heading_batch_edit_administrators'); ?></div>
hpdl
1125
25 <div class="infoBoxContent">
hpdl
1851
26   <form name="aEditBatch" class="dataForm" action="<?php echo osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule() . '&action=batch_save'); ?>" method="post">
hpdl
1125
27
hpdl
1446
28   <p><?php echo $osC_Language->get('introduction_batch_edit_administrators'); ?></p>
hpdl
1125
29
30 <?php
31   $Qadmins = $osC_Database->query('select id, user_name from :table_administrators where id in (":id") order by user_name');
32   $Qadmins->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
33   $Qadmins->bindRaw(':id', implode('", "', array_unique(array_filter(array_slice($_POST['batch'], 0, MAX_DISPLAY_SEARCH_RESULTS), 'is_numeric'))));
34   $Qadmins->execute();
35
36   $names_string = '';
37
hpdl
1851
38   while ( $Qadmins->next() ) {
39     $names_string .= osc_draw_hidden_field('batch[]', $Qadmins->valueInt('id')) . '<b>' . $Qadmins->valueProtected('user_name') . '</b>, ';
hpdl
1125
40   }
41
42   if ( !empty($names_string) ) {
hpdl
1200
43     $names_string = substr($names_string, 0, -2);
hpdl
1125
44   }
45
46   echo '<p>' . $names_string . '</p>';
hpdl
1851
47 ?>
hpdl
1125
48
hpdl
1851
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>
hpdl
1125
51
hpdl
1851
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>
hpdl
1125
53
hpdl
1851
54     <ul id="accessToModules" class="modulesListing"></ul>
55   </fieldset>
hpdl
1125
56
hpdl
1851
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>
hpdl
1125
58
hpdl
1851
59   </form>
60 </div>
hpdl
1125
61
hpdl
1851
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'); ?>';
hpdl
1125
65
hpdl
1851
66   var $modulesList = $('#modulesList');
hpdl
1125
67
hpdl
1851
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') + ' &raquo; ' + $('#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>