[geeklog-cvs] geeklog: When you had more than 50 blocks per side, disabling a ...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Wed Feb 17 14:32:22 EST 2010
changeset 7732:c6c6219eb470
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/c6c6219eb470
user: Dirk Haun <dirk at haun-online.de>
date: Wed Feb 17 17:13:11 2010 +0100
description:
When you had more than 50 blocks per side, disabling a block on one page of the block list would also disable all blocks on all the other pages of the list (reported by cesar)
diffstat:
public_html/admin/block.php | 46 ++++++++++++++++++++++++++++++++++------------
public_html/docs/history | 3 +++
system/lib-admin.php | 28 +++++++++++++++++++++++++---
3 files changed, 62 insertions(+), 15 deletions(-)
diffs (166 lines):
diff -r 60c5f6c9b22d -r c6c6219eb470 public_html/admin/block.php
--- a/public_html/admin/block.php Wed Feb 17 14:32:34 2010 +0100
+++ b/public_html/admin/block.php Wed Feb 17 17:13:11 2010 +0100
@@ -662,16 +662,16 @@
return $retval;
}
+
/**
-*
-* Re-orders all blocks in steps of 10
+* Re-orders all blocks in increments of 10
*
*/
function reorderblocks()
{
global $_TABLES;
- $sql = "SELECT * FROM {$_TABLES['blocks']} ORDER BY onleft asc, blockorder asc;";
+ $sql = "SELECT * FROM {$_TABLES['blocks']} ORDER BY onleft ASC, blockorder ASC;";
$result = DB_query($sql);
$nrows = DB_numRows($result);
@@ -741,24 +741,45 @@
/**
* Enable and Disable block
+*
+* @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
+* @return void
+*
*/
-function changeBlockStatus($side, $bid_arr)
+function changeBlockStatus($side, $bid_arr, $toporder)
{
global $_CONF, $_TABLES;
- // first, disable all on the requested side
- $side = COM_applyFilter($side, true);
- $sql = "UPDATE {$_TABLES['blocks']} SET is_enabled = '0' WHERE onleft='$side';";
+ require_once $_CONF['path_system'] . 'lib-admin.php';
+
+ 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)";
DB_query($sql);
+
if (isset($bid_arr)) {
foreach ($bid_arr as $bid => $side) {
$bid = COM_applyFilter($bid, true);
- // the enable those in the array
- $sql = "UPDATE {$_TABLES['blocks']} SET is_enabled = '1' WHERE bid='$bid' AND onleft='$side'";
- DB_query($sql);
+ // then enable those in the array
+ DB_change($_TABLES['blocks'], 'is_enabled', 1,
+ array('bid', 'onleft'), array($bid, $side));
}
}
- return;
}
/**
@@ -802,7 +823,8 @@
if (isset($_POST['enabledblocks'])) {
$enabledblocks = $_POST['enabledblocks'];
}
- changeBlockStatus($_POST['blockenabler'], $enabledblocks);
+ changeBlockStatus($_POST['blockenabler'], $enabledblocks,
+ COM_applyFilter($_POST['toporder'], true));
}
if (($mode == $LANG_ADMIN['delete']) && !empty ($LANG_ADMIN['delete'])) {
diff -r 60c5f6c9b22d -r c6c6219eb470 public_html/docs/history
--- a/public_html/docs/history Wed Feb 17 14:32:34 2010 +0100
+++ b/public_html/docs/history Wed Feb 17 17:13:11 2010 +0100
@@ -3,6 +3,9 @@
Apr ??, 2010 (1.6.2)
------------
+- When you had more than 50 blocks per side, disabling a block on one page of
+ the block list would also disable all blocks on all the other pages of the
+ list (reported by cesar) [Dirk]
- Improved comment readability by adding a paragraph tag around "Plain Old Text"
comments and some padding in threaded mode (bug #0000833) [Dirk]
- Hide the "Logout" link when editing a comment or comment submission
diff -r 60c5f6c9b22d -r c6c6219eb470 system/lib-admin.php
--- a/system/lib-admin.php Wed Feb 17 14:32:34 2010 +0100
+++ b/system/lib-admin.php Wed Feb 17 17:13:11 2010 +0100
@@ -44,6 +44,13 @@
}
/**
+* Default number of list entries per page
+*/
+if (! defined('DEFAULT_ENTRIES_PER_PAGE')) {
+ define('DEFAULT_ENTRIES_PER_PAGE', 50);
+}
+
+/**
* Common function used in Admin scripts to display a list of items
*
* @param string $fieldfunction Name of a function used to display the list item row details
@@ -235,7 +242,7 @@
if (isset($_REQUEST['query_limit'])) { // get query-limit (list-length)
$query_limit = COM_applyFilter($_REQUEST['query_limit'], true);
if ($query_limit == 0) {
- $query_limit = 50;
+ $query_limit = DEFAULT_ENTRIES_PER_PAGE;
}
}
@@ -428,8 +435,11 @@
}
if ($has_extras) {
- $limit = 50; # default query limit if not other chosen.
- # maybe this could be a setting from the list?
+ /**
+ * default query limit if no other ch osen.
+ * @todo maybe this could be a setting from the list?
+ */
+ $limit = DEFAULT_ENTRIES_PER_PAGE;
if (!empty($query_limit)) {
$limit = $query_limit;
}
@@ -623,6 +633,8 @@
{
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'],
@@ -646,6 +658,16 @@
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':
More information about the geeklog-cvs
mailing list