[geeklog-cvs] geeklog: Let's try that again: Fixed enabling/disabling blocks w...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sat Feb 20 10:35:43 EST 2010
changeset 7735:ef9b20942a0b
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/ef9b20942a0b
user: Dirk Haun <dirk at haun-online.de>
date: Sat Feb 20 13:41:51 2010 +0100
description:
Let's try that again: Fixed enabling/disabling blocks when you had more than 50
diffstat:
public_html/admin/block.php | 51 +++++++++++++++++++--------------------------------
system/lib-admin.php | 19 +++++--------------
2 files changed, 24 insertions(+), 46 deletions(-)
diffs (121 lines):
diff -r d04aac33dfdd -r ef9b20942a0b public_html/admin/block.php
--- a/public_html/admin/block.php Fri Feb 19 21:16:10 2010 +0100
+++ b/public_html/admin/block.php Sat Feb 20 13:41:51 2010 +0100
@@ -750,46 +750,30 @@
/**
-* Enable and Disable block
+* Enable and Disable blocks
*
-* @param string $side "1" = left-side blocks, "0" right-side blocks
-* @param array $bid_arr array containing ids of enabled blocks
-* @param int $toporder blockorder value of first block on current page
+* @param array $enabledblocks array containing ids of enabled blocks
+* @param array $visibleblocks array containing ids of visible blocks
* @return void
*
*/
-function changeBlockStatus($side, $bid_arr, $toporder)
+function changeBlockStatus($enabledblocks, $visibleblocks)
{
global $_CONF, $_TABLES;
- require_once $_CONF['path_system'] . 'lib-admin.php';
+ $enabled = array_keys($enabledblocks);
+ $visible = array_keys($visibleblocks);
+ $disabled = array_diff($visible, $enabled);
- if ($toporder < 10) {
- return;
- }
-
- $perpage = 0;
- if (isset($_REQUEST['query_limit'])) {
- $perpage = COM_applyFilter($_REQUEST['query_limit'], true);
- }
- if ($perpage == 0) {
- $perpage = DEFAULT_ENTRIES_PER_PAGE;
- }
- $maxorder = $toporder + (10 * $perpage);
-
- // first, disable all on the requested side (and page)
- $side = ($side == '1' ? 1 : 0);
- $sql = "UPDATE {$_TABLES['blocks']} SET is_enabled = 0 WHERE onleft = $side AND (blockorder >= $toporder AND blockorder < $maxorder)";
+ // disable blocks
+ $in = implode(',', $disabled);
+ $sql = "UPDATE {$_TABLES['blocks']} SET is_enabled = 0 WHERE bid IN ($in)";
DB_query($sql);
- if (isset($bid_arr)) {
- foreach ($bid_arr as $bid => $side) {
- $bid = COM_applyFilter($bid, true);
- // then enable those in the array
- DB_change($_TABLES['blocks'], 'is_enabled', 1,
- array('bid', 'onleft'), array($bid, $side));
- }
- }
+ // enable blocks
+ $in = implode(',', $enabled);
+ $sql = "UPDATE {$_TABLES['blocks']} SET is_enabled = 1 WHERE bid IN ($in)";
+ DB_query($sql);
}
/**
@@ -833,8 +817,11 @@
if (isset($_POST['enabledblocks'])) {
$enabledblocks = $_POST['enabledblocks'];
}
- changeBlockStatus($_POST['blockenabler'], $enabledblocks,
- COM_applyFilter($_POST['toporder'], true));
+ $visibleblocks = array();
+ if (isset($_POST['visibleblocks'])) {
+ $visibleblocks = $_POST['visibleblocks'];
+ }
+ changeBlockStatus($enabledblocks, $visibleblocks);
}
if (($mode == $LANG_ADMIN['delete']) && !empty ($LANG_ADMIN['delete'])) {
diff -r d04aac33dfdd -r ef9b20942a0b system/lib-admin.php
--- a/system/lib-admin.php Fri Feb 19 21:16:10 2010 +0100
+++ b/system/lib-admin.php Sat Feb 20 13:41:51 2010 +0100
@@ -633,8 +633,6 @@
{
global $_CONF, $LANG_ADMIN, $LANG21, $_IMAGE_TYPE;
- static $toporder_left, $toporder_right;
-
$retval = false;
$access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'],
@@ -658,16 +656,6 @@
case 'blockorder':
$retval .= $A['blockorder'];
- if ((!isset($toporder_left) && ($A['onleft'] == 1)) ||
- (!isset($toporder_right) && ($A['onleft'] == 0))) {
- if ($A['onleft'] == 1) {
- $toporder_left = $A['blockorder'];
- } else {
- $toporder_right = $A['blockorder'];
- }
- $retval .= LB . '<input type="hidden" name="toporder" value="'
- . $A['blockorder'] . '"' . XHTML . '>';
- }
break;
case 'is_enabled':
@@ -677,8 +665,11 @@
} else {
$switch = '';
}
- $retval = "<input type=\"checkbox\" name=\"enabledblocks[{$A['bid']}]\" "
- . "onclick=\"submit()\" value=\"{$A['onleft']}\"$switch" . XHTML . ">";
+ $retval = '<input type="checkbox" name="enabledblocks['
+ . $A['bid'] . ']" onclick="submit()" value="'
+ . $A['onleft'] . '"' . $switch . XHTML . '>'
+ . '<input type="hidden" name="visibleblocks['
+ . $A['bid'] . ']" value="1"' . XHTML . '>';
}
break;
More information about the geeklog-cvs
mailing list