Author |
Message |
draxx
Involved
![Involved Involved](modules/Forums/images/ranks/4stars.gif)
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Nov 19, 2003
Posts: 282
|
Posted:
Sat Oct 26, 2013 4:33 pm |
|
Great misterstereus! Your versions work! Thank you so much for taking the time to share.
hicuxunicorniobestbuildpc I have always had the idea that in these cases where things are being developed or debugged things like location of the language files and text etc does not really matter. The first step is to achieve functionality - then once everything is working is when I polish and tidy everything up and put everything in its proper box.
Thank you everyone for your input and help. I still hate the way the admin file works with the ordering of the blocks - it uses the old style arrowup/down but that is for another time ![Smile](modules/Forums/images/smiles/icon_smile.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
draxx
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 12:38 am |
|
Okay it seems I spoke to soon. It "mostly" works.
The problem is in the admin panel when you move a block up and down (change the module weight) it changes the module weight for that block in ALL the modules.
It should only change the weight in the current module that is being edited.
Other than this it does work and it does seem to maintain correctly which blocks go on which module page.
It does not seem to matter what module you change the weight from - it changes the weight in all of them.
Here is the admin file code that I wound up using
Code:
<?php
/************************************************************************/
/* WB_BlocksManager v0.2 */
/* Module for phpnuke 6.x by Paulo FERREIRA */
/* Copyright (C) 2003 Paulo Ferreira */
/* Web: http://www.phpnuke-belgique.org/ */
/* Email: webmaster@phpnuke-belgique.org */
/* */
/* Modifications by James Johnston, 02/07/2004 */
/* Email: jjohnston@techknowpro.com */
/* Mods: Easy Position Change, Block Position by Module, */
/* Multi Add/Remove of Selected Blocks */
/* */
/* */
/* Updated 2004-08-31 for nuke 7.4 by spcdata http://www.nextnet.se */
/* */
/* =====================================================================*/
/* PHP-NUKE: Web Portal System */
/* =====================================================================*/
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
if (!eregi("admin.php", $_SERVER['PHP_SELF']) AND !eregi("admin.php", $_SERVER['SCRIPT_NAME'])) { die ("Access Denied"); }
global $prefix, $db;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT radminsuper FROM " . $prefix . "_authors WHERE aid='$aid'"));
if ($row['radminsuper'] == 1) {
/*********************************************************/
/* Blocks_Manager Functions */
/*********************************************************/
function BlocksManager($wb_name) {
global $bgcolor2, $bgcolor4, $prefix, $db, $currentlang, $multilingual;
include("header.php");
GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>"._BLOCKMGR_BLOCKSADMIN_MANAGER."</b></font></center>";
CloseTable();
echo "<br>";
OpenTable();
$wb_url="admin.php?op=BlocksManager&wb_name=";
echo "<div align=\"center\">\n"
."<form action=\"admin.php\" method=\"post\">\n"
.""._BLOCKMGR_MODULEDROP." <select name=\"wb_name\" size=\"1\" onChange=\"top.location.href=this.options[this.selectedIndex].value\">\n";
$result = $db->sql_query("SELECT mid, title, custom_title, active, view, inmenu FROM ".$prefix."_modules WHERE active=1 ORDER BY title ASC");
while(list($mid, $title, $custom_title, $active, $view, $inmenu) = $db->sql_fetchrow($result)) {
echo "<option value=\"".$wb_url.$title."\""; if ($wb_name==$title) { echo " selected"; } echo ">$title</option>\n";
if (!isset($wb_name)) { $wb_name = $title; }
}
echo "</select> \n"
."</form></div>\n";
echo "<table border=\"1\" width=\"100%\"><tr>"
."<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._TITLE."</b></td>"
."<td align=\"center\" bgcolor=\"$bgcolor2\" colspan=\"2\"><b>"._POSITION."</b></td>"
."<td align=\"center\" bgcolor=\"$bgcolor2\" colspan=\"2\"><b>"._WEIGHT."</b></td>"
."<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._TYPE."</b></td>"
."<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._STATUS."</b></td>"
."<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._VIEW."</b></td>";
if ($multilingual == 1) {
echo "<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._LANGUAGE."</b></td>";
}
// echo "<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._FUNCTIONS."</b></tr>";
$i=0;
$sql = "SELECT b.bid, b.bkey, b.title, b.url, m.bposition, m.weight, b.active, b.blanguage, b.blockfile, b.view FROM ".$prefix."_blocks b, ".$prefix."_blocks_manager m WHERE b.bid=m.bid AND m.title='$wb_name' ORDER BY bposition, weight";
$result1 = $db->sql_query($sql);
while(list($bid, $bkey, $title, $url, $bposition, $weight, $active, $blanguage, $blockfile, $view) = $db->sql_fetchrow($result1)) {
$weight1 = $weight - 1;
$weight3 = $weight + 1;
$res = $db->sql_query("select bid from ".$prefix."_blocks_manager where title='$wb_name' AND weight='$weight1' AND bposition='$bposition'");
list ($bid1) = $db->sql_fetchrow($res);
$con1 = "$bid1";
$res2 = $db->sql_query("select bid from ".$prefix."_blocks_manager where title='$wb_name' AND weight='$weight3' AND bposition='$bposition'");
list ($bid2) = $db->sql_fetchrow($res2);
$con2 = "$bid2";
echo "<tr>"
."<td align=\"center\">$title</td>";
if ($bposition == "l") {
$bposition = ""._LEFT."</td><td align=\"center\"><a href=\"admin.php?op=BlocksManager_BlockPosition&bid=$bid&title=$wb_name&position=r\">"
."<img src=\"images/center_l.gif\" border=\"0\" alt=\""._MOVERIGHT."\" title=\""._MOVERIGHT."\">"
."</a>"
."<a href=\"admin.php?op=BlocksManager_BlockPosition&bid=$bid&title=$wb_name&position=c\">"
."<img src=\"images/up.gif\" alt=\""._MOVECENTERUP."\" title=\""._MOVECENTERUP."\" border=\"0\">"
."</a>"
."<a href=\"admin.php?op=BlocksManager_BlockPosition&bid=$bid&title=$wb_name&position=d\">"
."<img src=\"images/down.gif\" alt=\""._MOVECENTERDOWN."\" title=\""._MOVECENTERDOWN."\" border=\"0\">"
."</a>";
} elseif ($bposition == "r") {
$bposition = ""._RIGHT."</td><td align=\"center\"><a href=\"admin.php?op=BlocksManager_BlockPosition&bid=$bid&title=$wb_name&position=l\">"
."<img src=\"images/center_r.gif\" border=\"0\" alt=\""._MOVELEFT."\" title=\""._MOVELEFT."\">"
."</a>"
."<a href=\"admin.php?op=BlocksManager_BlockPosition&bid=$bid&title=$wb_name&position=c\">"
."<img src=\"images/up.gif\" alt=\""._MOVECENTERUP."\" title=\""._MOVECENTERUP."\" border=\"0\">"
."</a>"
."<a href=\"admin.php?op=BlocksManager_BlockPosition&bid=$bid&title=$wb_name&position=d\">"
."<img src=\"images/down.gif\" alt=\""._MOVECENTERDOWN."\" title=\""._MOVECENTERDOWN."\" border=\"0\">"
."</a>";
} elseif ($bposition == "c") {
$bposition = ""._CENTERUP."</td><td align=\"center\"><a href=\"admin.php?op=BlocksManager_BlockPosition&bid=$bid&title=$wb_name&position=l\">"
."<img src=\"images/center_r.gif\" border=\"0\" alt=\""._MOVELEFT."\" title=\""._MOVELEFT."\">"
."</a>"
."<a href=\"admin.php?op=BlocksManager_BlockPosition&bid=$bid&title=$wb_name&position=r\">"
."<img src=\"images/center_l.gif\" border=\"0\" alt=\""._MOVERIGHT."\" title=\""._MOVERIGHT."\">"
."</a>"
."<a href=\"admin.php?op=BlocksManager_BlockPosition&bid=$bid&title=$wb_name&position=d\">"
."<img src=\"images/down.gif\" alt=\""._MOVECENTERDOWN."\" title=\""._MOVECENTERDOWN."\" border=\"0\">"
."</a>";
} elseif ($bposition == "d") {
$bposition = ""._CENTERDOWN."</td><td align=\"center\"><a href=\"admin.php?op=BlocksManager_BlockPosition&bid=$bid&title=$wb_name&position=l\">"
."<img src=\"images/center_r.gif\" border=\"0\" alt=\""._MOVELEFT."\" title=\""._MOVELEFT."\">"
."</a>"
."<a href=\"admin.php?op=BlocksManager_BlockPosition&bid=$bid&title=$wb_name&position=r\">"
."<img src=\"images/center_l.gif\" border=\"0\" alt=\""._MOVERIGHT."\" title=\""._MOVERIGHT."\">"
."</a>"
."<a href=\"admin.php?op=BlocksManager_BlockPosition&bid=$bid&title=$wb_name&position=c\">"
."<img src=\"images/up.gif\" alt=\""._MOVECENTERUP."\" title=\""._MOVECENTERUP."\" border=\"0\">"
."</a>";
}
echo "<td align=\"center\">$bposition</td>"
."<td align=\"center\">";
// ." ".$row1[weight]." </td>";
echo "$weight</td><td align=\"center\">";
//duplicating arrows?
// if ($con1) {
echo"<a href=\"admin.php?op=BlocksManager_BlockOrder&weight=$weight&bidori=$bid&weightrep=$weight1&bidrep=$con1&title=$wb_name\"><img src=\"images/up.gif\" alt=\""._BLOCKUP."\" title=\""._BLOCKUP."\" border=\"0\" hspace=\"3\"></a>";
echo "<a href=\"admin.php?op=BlocksManager_BlockOrder&weight=$weight&bidori=$bid&weightrep=$weight3&bidrep=$con2&title=$wb_name\"><img src=\"images/down.gif\" alt=\""._BLOCKDOWN."\" title=\""._BLOCKDOWN."\" border=\"0\" hspace=\"3\"></a>";
// }
// if ($con2) {
// echo"<a href=\"admin.php?op=BlocksManager_BlockOrder&weight=$weight&bidori=$bid&weightrep=$weight1&bidrep=$con1\"><img src=\"images/up.gif\" alt=\""._BLOCKUP."\" title=\""._BLOCKUP."\" border=\"0\" hspace=\"3\"></a>";
// echo "<a href=\"admin.php?op=BlocksManager_BlockOrder&weight=$weight&bidori=$bid&weightrep=$weight3&bidrep=$con2\"><img src=\"images/down.gif\" alt=\""._BLOCKDOWN."\" title=\""._BLOCKDOWN."\" border=\"0\" hspace=\"3\"></a>";
// }
echo"</td>";
if ($bkey == "") {
if ($url == "") {
$type = "HTML";
} elseif ($url != "") {
$type = "RSS/RDF";
}
if ($blockfile != "") {
$type = _BLOCKFILE2;
}
} elseif ($bkey != "") {
$type = _BLOCKSYSTEM;
}
echo "<td align=\"center\">$type</td>";
$block_act = $active;
if ($active == 1) {
$active = _ACTIVE;
$change = _DEACTIVATE;
} elseif ($active == 0) {
$active = "<i>"._INACTIVE."</i>";
$change = _ACTIVATE;
}
echo "<td align=\"center\">$active</td>";
if ($view == 0) {
$who_view = _MVALL;
} elseif ($view == 1) {
$who_view = _MVUSERS;
} elseif ($view == 2) {
$who_view = _MVADMIN;
} elseif ($view == 3) {
$who_view = _MVANON;
}
echo "<td align=\"center\">$who_view</td>";
if ($multilingual == 1) {
if ($blanguage == "") {
$blanguage = _ALL;
} else {
$blanguage = ucfirst($blanguage);
}
echo "<td align=\"center\">$blanguage</td>";
}
/* echo "<td align=\"center\"><font class=\"content\">";
if ($bkey == "") {
echo "<a href=\"admin.php?op=BlocksManager_Delete&bid=$bid&title=$wb_name\">"._BLOCKMGR_WB_DELETE."</a>";
} elseif ($bkey != "") {
echo ""._BLOCKMGR_WB_DELETE."";
}
echo "</td>";
*/
echo "</tr>";
$wb_tabblocks[$i] = $bid;
$i++;
}
echo "</table><br>"
."<center>[ <a href=\"admin.php?op=BlocksManager_FixWeight&wb_name=$wb_name\">"._FIXBLOCKS."</a> ]</center><br>"
."<br><br>";
CloseTable();
echo "<br>";
OpenTable();
echo "<center><font class=\"option\"><b>"._BLOCKMGR_ADDNEWBLOCK_MANAGER."</b></font></center><br><br>"
."<form name=\"BM_EDIT\" action=\"admin.php\" method=\"post\">"
."<table border=\"0\" width=\"80%\" align=\"center\">"
."<tr>";
//List all inactive Blocks for selected module
echo "<td align=\"center\" valign=\"top\">"
._BLOCKMGR_ACTIVE_BLOCKS."<br><select name=\"bida[]\" size=\"10\" multiple>";
$sql = "SELECT bid, title FROM ".$prefix."_blocks ORDER BY title ASC";
$result = $db->sql_query($sql);
while(list($bid, $title) = $db->sql_fetchrow($result)) {
$ii=0; $wb_affiche=1;
while ($ii<$i) {
if ($wb_tabblocks[$ii]==$bid) { $wb_affiche=0; }
$ii++;
}
if ($wb_affiche==1) { echo "<option value=\"".$bid."\">$title</option>\n"; }
}
echo "</select><br>"
."<input type=\"submit\" value=\""._BLOCKMGR_ADD_BLOCK."\" onclick=\"document.BM_EDIT.op.value='BlocksManager_Add';\">"
."</td>";
//List all active Modules
echo "<td align=\"center\" valign=\"top\">"
.""._BLOCKMGR_MODULES."<br><select name=\"title[]\" size=\"10\" multiple>\n";
$result = $db->sql_query("SELECT mid, title, custom_title, active, view, inmenu FROM ".$prefix."_modules WHERE active=1 ORDER BY title ASC");
while(list($mid, $title, $custom_title, $active, $view, $inmenu) = $db->sql_fetchrow($result)) {
echo "<option value=\"$title\"";
if ($wb_name==$title) { echo " selected"; } echo ">$title</option>\n";
if (!isset($wb_name)) { $wb_name = $title; }
}
echo "</select><br>"
."</td>\n";
//List all active Blocks for selected module
echo "<td align=\"center\" valign=\"top\">"
._BLOCKMGR_INACTIVE_BLOCKS."<br><select name=\"bidr[]\" size=\"10\" multiple>";
$sql = "SELECT b.bid, b.title FROM ".$prefix."_blocks b, ".$prefix."_blocks_manager m WHERE b.bid=m.bid AND m.title='$wb_name' ORDER BY title ASC";
$result = $db->sql_query($sql);
while(list($bid, $title) = $db->sql_fetchrow($result)) {
echo "<option value=\"$bid\">$title</option>\n";
}
echo "</select><br>"
."<input type=\"submit\" value=\""._BLOCKMGR_REMOVE_BLOCK."\" onclick=\"document.BM_EDIT.op.value='BlocksManager_Remove';\"></td>";
echo "</tr><tr><td align=\"center\" colspan=\"2\"><br>"
."</td>"
."</tr>"
."</table>"
."<input type=\"hidden\" name=\"wb_name\" value=\"$wb_name\">"
."<input type=\"hidden\" name=\"op\" value=\"BlocksManager_Add\">"
."</form>";
CloseTable();
include("footer.php");
}
function BlocksManager_Add($bid, $title, $wb_name) {
global $prefix, $db;
foreach($title as $tKey => $tValue) {
foreach($bid as $bKey => $bValue) {
$sql = "SELECT bposition, weight FROM ".$prefix."_blocks WHERE bid='$bValue'";
echo "$sql<br>";
$result = $db->sql_query($sql);
list($bposition, $weight) = $db->sql_fetchrow($result);
$db->sql_query("INSERT INTO ".$prefix."_blocks_manager VALUES ('$bValue', '$tValue', '$bposition', '$weight')");
// echo "INSERT INTO ".$prefix."_blocks_manager VALUES ('$bValue', '$tValue', '$bposition', '$weight')<br>";
}
}
Header("Location: admin.php?op=BlocksManager&wb_name=$wb_name");
}
function BlocksManager_Remove($bid, $title, $wb_name) {
global $prefix, $db;
foreach($title as $tKey => $tValue) {
foreach($bid as $bKey => $bValue) {
$db->sql_query("DELETE FROM ".$prefix."_blocks_manager WHERE bid='$bValue' AND title='$tValue'");
// echo "DELETE FROM ".$prefix."_blocks_manager WHERE bid='$bValue' AND title='$tValue'<br>";
}
}
Header("Location: admin.php?op=BlocksManager&wb_name=$wb_name");
}
function BlocksManager_FixWeight($wb_name) {
global $prefix, $db;
$leftpos = "l";
$rightpos = "r";
$centeruppos = "c";
$centerdnpos = "d";
//Fix Left Block Weights
$result = $db->sql_query("select bid, title from ".$prefix."_blocks_manager where title='$wb_name' AND bposition='$leftpos' order by weight ASC");
$weight = 0;
while(list($bid, $title) = $db->sql_fetchrow($result)) {
$weight++;
$db->sql_query("update ".$prefix."_blocks_manager set weight='$weight' where title='$wb_name' AND bid='$bid'");
echo "$bid, $title, $weight<br>\n";
}
//Fix Right Block Weights
$result = $db->sql_query("select bid from ".$prefix."_blocks_manager where title='$wb_name' bposition='$rightpos' order by weight ASC");
$weight = 0;
while(list($bid) = $db->sql_fetchrow($result)) {
$weight++;
$db->sql_query("update ".$prefix."_blocks_manager set weight='$weight' where title='$wb_name' AND bid='$bid'");
}
//Fix Center Up Block Weights
$result = $db->sql_query("select bid from ".$prefix."_blocks_manager where title='$wb_name' bposition='$centeruppos' order by weight ASC");
$weight = 0;
while(list($bid) = $db->sql_fetchrow($result)) {
$weight++;
$db->sql_query("update ".$prefix."_blocks_manager set weight='$weight' where title='$wb_name' AND bid='$bid'");
}
//Fix Center Down Block Weights
$result = $db->sql_query("select bid from ".$prefix."_blocks_manager where title='$wb_name' bposition='$centerdnpos' order by weight ASC");
$weight = 0;
while(list($bid) = $db->sql_fetchrow($result)) {
$weight++;
$db->sql_query("update ".$prefix."_blocks_manager set weight='$weight' where title='$wb_name' AND bid='$bid'");
}
Header("Location: admin.php?op=BlocksManager&wb_name=$wb_name");
}
function BlocksManager_BlockPosition($bid, $title, $position) {
global $prefix, $db;
$db->sql_query("UPDATE ".$prefix."_blocks_manager SET bposition='$position' WHERE bid='$bid' AND title='$title'");
// echo "UPDATE ".$prefix."_blocks_manager SET bposition='$position' WHERE bid='$bid' AND title='$title'";
Header("Location: admin.php?op=BlocksManager&wb_name=$title");
}
function BlocksManager_BlockOrder($weightrep,$weight,$bidrep,$bidori,$title) {
global $prefix, $db;
$result = $db->sql_query("update ".$prefix."_blocks_manager set weight='$weight' where bid='$bidrep'");
$result2 = $db->sql_query("update ".$prefix."_blocks_manager set weight='$weightrep' where bid='$bidori'");
Header("Location: admin.php?op=BlocksManager&wb_name=$title");
//attempt to fix return
// Header("Location: admin.php?op=BlocksManager");
// Header("Location: admin.php?op=BlocksManager&wb_name=$wb_name");
}
switch($op) {
case "BlocksManager":
BlocksManager($wb_name);
break;
case "BlocksManager_Add":
BlocksManager_Add($bida, $title, $wb_name);
break;
case "BlocksManager_Remove":
BlocksManager_Remove($bidr, $title, $wb_name);
break;
case "BlocksManager_BlockPosition":
BlocksManager_BlockPosition($bid, $title, $position);
break;
case "BlocksManager_FixWeight":
BlocksManager_FixWeight($wb_name);
break;
case "BlocksManager_BlockOrder":
BlocksManager_BlockOrder ($weightrep,$weight,$bidrep,$bidori,$title);
// Adding for attempt to fix return
// BlocksManager($wb_name);
break;
}
} else {
Header("Location: index.php");
die();
}
?>
|
The admin file that mister supplied also works but in a different manner with the point being that it also does the same thing with the block weight.
Code:
<?php
/************************************************************************/
/* WB_BlocksManager v0.2 */
/* Module for phpnuke 6.x by Paulo FERREIRA */
/* Copyright (C) 2003 Paulo Ferreira */
/* Web: http://www.phpnuke-belgique.org/ */
/* Email: webmaster@phpnuke-belgique.org */
/* */
/* Modifications by James Johnston, 02/07/2004 */
/* Email: jjohnston@techknowpro.com */
/* Mods: Easy Position Change, Block Position by Module, */
/* Multi Add/Remove of Selected Blocks */
/* */
/* */
/* Updated 2004-08-31 for nuke 7.4 by spcdata http://www.nextnet.se */
/* */
/* =====================================================================*/
/* PHP-NUKE: Web Portal System */
/* =====================================================================*/
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
// WB_BlocksManager v0.2
define ("_BLOCKMGR_BLOCKS_MANAGER","Blocks Manager");
define ("_BLOCKMGR_BLOCKSADMIN_MANAGER","Management of the posting of the blocks by module");
define ("_BLOCKMGR_MODULEDROP","List blocks of the module:");
define ("_BLOCKMGR_ADDNEWBLOCK_MANAGER","Add/Remove selected block(s) to/from select module(s)");
define ("_BLOCKMGR_ACTIVE_BLOCKS","Inactive Blocks");
define ("_BLOCKMGR_MODULES","Modules");
define ("_BLOCKMGR_INACTIVE_BLOCKS","Active Blocks");
define ("_BLOCKMGR_ADD_BLOCK","Add");
define ("_BLOCKMGR_REMOVE_BLOCK","Remove");
define ( "_BLOCKMGR_TITLE", "Title" );
define ( "_BLOCKMGR_POSITION", "Position" );
define ( "_BLOCKMGR_WEIGHT", "Weight" );
define ( "_BLOCKMGR_STATUS", "Status" );
define ( "_BLOCKMGR_VIEW", "Visibile a" );
define ( "_BLOCKMGR_LANGUAGE", "Language" );
define ( "_BLOCKMGR_LEFT", "Left" );
define ( "_BLOCKMGR_CENTERUP", "Centra Up" );
define ( "_BLOCKMGR_CENTERDOWN", "Centra Down" );
define ( "_BLOCKMGR_RIGHT", "Right" );
define ( "_BLOCKMGR_BLOCKUP", "BlockUp" );
define ( "_BLOCKMGR_BLOCKDOWN", "BlockDown" );
define ( "_BLOCKMGR_DEACTIVATE", "Deactive" );
define ( "_BLOCKMGR_ACTIVATE", "Activate" );
define ( "_BLOCKMGR_INACTIVE", "Inactive" );
define ( "_BLOCKMGR_ACTIVE", "Active" );
define ( "_BLOCKMGR_ADDNEWBLOCK", "Add New Block" );
define ( "_BLOCKMGR", "Block Manager" );
if (!eregi("admin.php", $_SERVER['PHP_SELF']) AND !eregi("admin.php", $_SERVER['SCRIPT_NAME'])) { die ("Access Denied"); }
global $prefix, $db, $wb_name;
$aid = substr ( "$aid", 0, 25 );
$row = $db->sql_fetchrow ( $db->sql_query ( "SELECT radminsuper FROM " . $prefix . "_authors WHERE aid='$aid'" ) );
if ($row ['radminsuper'] == 1) {
/**
* ******************************************************
*/
/* Blocks_Manager Functions */
/**
* ******************************************************
*/
function BlocksManager($wb_name) {
global $db, $prefix, $currentlang, $multilingual, $bgcolor2;
OpenHeader ( _BLOCKMGR );
$wb_url = "admin.php?op=BlocksManager&wb_name=";
echo "<center><form action=\"admin.php\" method=\"post\">\n" . _BLOCKMGR_MODULEDROP . " <select name=\"wb_name\" size=\"1\" onChange=\"top.location.href=this.options[this.selectedIndex].value\">\n";
if (! isset ( $wb_name )) {
$wb_name = "admin";
}
echo "<option value=\"" . $wb_url . "admin\"";
if ($wb_name == "admin") {
echo " selected";
}
echo ">admin</option>\n";
$result = $db->sql_query ( "SELECT mid, title, custom_title, active, view, inmenu FROM " . $prefix . "_modules WHERE active=1 ORDER BY title ASC" );
while ( list ( $mid, $title, $custom_title, $active, $view, $inmenu ) = $db->sql_fetchrow ( $result ) ) {
echo "<option value=\"" . $wb_url . $title . "\"";
if ($wb_name == $title) {
echo " selected";
}
echo ">$title</option>\n";
if (! isset ( $wb_name )) {
$wb_name = $title;
}
}
echo "</select>\n" . "</form>\n</center>\n";
echo "<table border=\"0\" width=\"100%\">\n<tr>\n" . "<td align=\"center\" bgcolor=\"$bgcolor2\">" . _BLOCKMGR_TITLE . "</td>\n" . "<td align=\"center\" bgcolor=\"$bgcolor2\">" . _BLOCKMGR_POSITION . "</td>\n" . "<td align=\"center\" bgcolor=\"$bgcolor2\" colspan=\"2\">" . _BLOCKMGR_WEIGHT . "</td>\n" . "<td align=\"center\" bgcolor=\"$bgcolor2\">" . _BLOCKMGR_STATUS . "</td>\n" . "<td align=\"center\" bgcolor=\"$bgcolor2\">" . _BLOCKMGR_VIEW . "</td>\n";
if ($multilingual == 1) {
echo "<td align=\"center\" bgcolor=\"$bgcolor2\">" . _BLOCKMGR_LANGUAGE . "</td>\n";
}
$i = 0;
$sql = "SELECT b.bid, b.bkey, b.title, b.url, m.bposition, m.weight, b.active, b.blanguage, b.blockfile, b.view FROM " . $prefix . "_blocks b, " . $prefix . "_blocks_manager m WHERE b.bid=m.bid AND m.title='$wb_name' ORDER BY bposition, weight";
$result = $db->sql_query ( $sql );
while ( list ( $bid, $bkey, $title, $url, $bposition, $weight, $active, $blanguage, $blockfile, $view ) = $db->sql_fetchrow ( $result ) ) {
$weight1 = $weight - 1;
$weight3 = $weight + 1;
$res1 = $db->sql_query ( "SELECT bid FROM " . $prefix . "_blocks_manager WHERE title='$wb_name' AND weight='$weight1' AND bposition='$bposition'" );
list ( $con1 ) = $db->sql_fetchrow ( $res1 );
$res2 = $db->sql_query ( "SELECT bid FROM " . $prefix . "_blocks_manager WHERE title='$wb_name' AND weight='$weight3' AND bposition='$bposition'" );
list ( $con2 ) = $db->sql_fetchrow ( $res2 );
$wb_url = "admin.php?op=BlocksManager_BlockPosition&wb_name=$wb_name&bid=$bid&position=";
$t_position = "<form action=\"admin.php\" method=\"post\">\n";
$t_position .= "<select name=\"bposition\" onChange=\"top.location.href=this.options[this.selectedIndex].value\">\n";
// if (!isset($wb_name)) { $wb_name = "admin"; }
$t_position .= "<option value=\"" . $wb_url . "l\"";
if ($bposition == "l") {
$t_position .= " selected";
}
$t_position .= ">" . _BLOCKMGR_LEFT . "</option>\n";
$t_position .= "<option value=\"" . $wb_url . "c\"";
if ($bposition == "c") {
$t_position .= " selected";
}
$t_position .= ">" . _BLOCKMGR_CENTERUP . "</option>\n";
$t_position .= "<option value=\"" . $wb_url . "d\"";
if ($bposition == "d") {
$t_position .= " selected";
}
$t_position .= ">" . _BLOCKMGR_CENTERDOWN . "</option>\n";
$t_position .= "<option value=\"" . $wb_url . "r\"";
if ($bposition == "r") {
$t_position .= " selected";
}
$t_position .= ">" . _BLOCKMGR_RIGHT . "</option>\n";
$t_position .= "</select>\n</form>\n";
echo "<tr>\n" . "<td align=\"center\">$title</td>\n" . "<td align=\"center\">$t_position</td>\n" . "<td align=\"center\">$weight</td>\n" . "<td align=\"center\">\n";
if ($con1) {
echo "<a href=\"admin.php?op=BlocksManager_BlockOrder&wb_name=$wb_name&weight=$weight&bidori=$bid&weightrep=$weight1&bidrep=$con1\">" . "<img src=\"images/up.gif\" alt=\"" . _BLOCKMGR_BLOCKUP . "\" title=\"" . _BLOCKMGR_BLOCKUP . "\" border=\"0\" hspace=\"3\">" . "</a>\n";
}
if ($con2) {
echo "<a href=\"admin.php?op=BlocksManager_BlockOrder&wb_name=$wb_name&weight=$weight&bidori=$bid&weightrep=$weight3&bidrep=$con2\">" . "<img src=\"images/down.gif\" alt=\"" . _BLOCKMGR_BLOCKDOWN . "\" title=\"" . _BLOCKMGR_BLOCKDOWN . "\" border=\"0\" hspace=\"3\">" . "</a>\n";
}
echo "</td>\n";
$block_act = $active;
if ($active == 1) {
$active = _BLOCKMGR_ACTIVE;
$change = _BLOCKMGR_DEACTIVATE;
} elseif ($active == 0) {
$active = "<i>" . _BLOCKMGR_INACTIVE . "</i>";
$change = _BLOCKMGR_ACTIVATE;
}
echo "<td align=\"center\">$active</td>\n";
if ($view == 0) {
$who_view = _MVALL;
} elseif ($view == 1) {
$who_view = _MVUSERS;
} elseif ($view == 2) {
$who_view = _MVADMIN;
} elseif ($view == 3) {
$who_view = _MVANON;
}
echo "<td align=\"center\">$who_view</td>\n";
if ($multilingual == 1) {
if ($blanguage == "") {
$blanguage = _ALL;
} else {
$blanguage = ucfirst ( $blanguage );
}
echo "<td align=\"center\">$blanguage</td>\n";
}
echo "</tr>\n";
$wb_tabblocks [$i] = $bid;
$i ++;
}
echo "</table>\n";
echo "<br />\n";
echo "<center><b>" . _BLOCKMGR_ADDNEWBLOCK . "</b></center>\n" . "<form name=\"BM_EDIT\" action=\"admin.php\" method=\"post\">\n" . "<table width=\"80%\" align=\"center\">\n" . "<tr>\n";
// List all inactive Blocks for selected module
echo "<td align=\"center\" valign=\"top\">\n" . _BLOCKMGR_ACTIVE_BLOCKS . "<br />\n" . "<select name=\"bida[]\" size=\"10\" multiple>\n";
$sql = "SELECT bid, title FROM " . $prefix . "_blocks ORDER BY title ASC";
$result = $db->sql_query ( $sql );
while ( list ( $bid, $title ) = $db->sql_fetchrow ( $result ) ) {
$ii = 0;
$wb_affiche = 1;
while ( $ii < $i ) {
if ($wb_tabblocks [$ii] == $bid) {
$wb_affiche = 0;
}
$ii ++;
}
if ($wb_affiche == 1) {
echo "<option value=\"" . $bid . "\">$title</option>\n";
}
}
echo "</select><br />\n" . "<input type=\"submit\" value=\"" . _BLOCKMGR_ADD_BLOCK . "\" onclick=\"document.BM_EDIT.op.value='BlocksManager_Add';\">\n" . "</td>\n";
// List all active Blocks for selected module
echo "<td align=\"center\" valign=\"top\">\n" . _BLOCKMGR_INACTIVE_BLOCKS . "<br />\n" . "<select name=\"bidr[]\" size=\"10\" multiple>\n";
$sql = "SELECT b.bid, b.title FROM " . $prefix . "_blocks b, " . $prefix . "_blocks_manager m WHERE b.bid=m.bid AND m.title='$wb_name' ORDER BY title ASC";
$result = $db->sql_query ( $sql );
while ( list ( $bid, $title ) = $db->sql_fetchrow ( $result ) ) {
echo "<option value=\"$bid\">$title</option>\n";
}
echo "</select><br />\n" . "<input type=\"submit\" value=\"" . _BLOCKMGR_REMOVE_BLOCK . "\" onclick=\"document.BM_EDIT.op.value='BlocksManager_Remove';\">\n" . "</td>\n" . "</tr>\n" . "</table>\n" . "<input type=\"hidden\" name=\"wb_name\" value=\"$wb_name\">\n" . "<input type=\"hidden\" name=\"op\" value=\"BlocksManager_Add\">\n" . "</form>\n";
CloseFooter ();
}
function BlocksManager_Add($bid, $wb_name) {
global $db, $prefix;
$sql = "SELECT MAX(weight) FROM " . $prefix . "_blocks_manager WHERE title='$wb_name'";
$result = $db->sql_query ( $sql );
list ( $weight ) = $db->sql_fetchrow ( $result );
foreach ( $bid as $bKey => $bValue ) {
$weight ++;
$db->sql_query ( "INSERT INTO " . $prefix . "_blocks_manager VALUES ('$bValue', '$wb_name', 'r', '$weight')" );
}
BlocksManager_FixWeight ( $title );
header ( "Location: admin.php?op=BlocksManager&wb_name=$wb_name" );
}
function BlocksManager_Remove($bid, $wb_name) {
global $db, $prefix;
foreach ( $bid as $bKey => $bValue ) {
$db->sql_query ( "DELETE FROM " . $prefix . "_blocks_manager WHERE bid='$bValue' AND title='$wb_name'" );
}
BlocksManager_FixWeight ( $title );
header ( "Location: admin.php?op=BlocksManager&wb_name=$wb_name" );
}
function BlocksManager_FixWeight($wb_name) {
global $db, $prefix;
$position [] = 'l';
$position [] = 'r';
$position [] = 'c';
$position [] = 'd';
$position [] = '';
foreach ( $position as $pKey => $pValue ) {
$result = $db->sql_query ( "SELECT bid FROM " . $prefix . "_blocks_manager WHERE title='$wb_name' AND bposition='$pValue' ORDER BY weight ASC" );
$weight = 0;
while ( list ( $bid ) = $db->sql_fetchrow ( $result ) ) {
$weight ++;
if ($pValue != '') :
$db->sql_query ( "UPDATE " . $prefix . "_blocks_manager SET weight='$weight' WHERE title='$wb_name' AND bid='$bid'" );
else :
$db->sql_query ( "UPDATE " . $prefix . "_blocks_manager SET weight='$weight', bposition='r' WHERE title='$wb_name' AND bid='$bid'" );
endif;
}
}
header ( "Location: admin.php?op=BlocksManager&wb_name=$wb_name" );
}
function BlocksManager_BlockPosition($bid, $wb_name, $position) {
global $db, $prefix;
$db->sql_query ( "UPDATE " . $prefix . "_blocks_manager SET bposition='$position' WHERE bid='$bid' AND title='$wb_name'" );
BlocksManager_FixWeight ( $wb_name );
header ( "Location: admin.php?op=BlocksManager&wb_name=$wb_name" );
}
function BlocksManager_BlockOrder($wb_name, $weightrep, $weight, $bidrep, $bidori) {
global $db, $prefix;
$result = $db->sql_query ( "UPDATE " . $prefix . "_blocks_manager SET weight='$weight' WHERE bid='$bidrep'" );
$result2 = $db->sql_query ( "UPDATE " . $prefix . "_blocks_manager SET weight='$weightrep' WHERE bid='$bidori'" );
BlocksManager_FixWeight ( $wb_name );
header ( "Location: admin.php?op=BlocksManager&wb_name=$wb_name" );
}
function OpenHeader($title = "") {
include ("header.php");
GraphicAdmin ();
title ( $title );
OpenTable ();
}
function CloseFooter() {
CloseTable ();
include ("footer.php");
}
switch ($op) {
case "BlocksManager" :
BlocksManager ( $wb_name );
break;
case "BlocksManager_Add" :
BlocksManager_Add ( $bida, $wb_name );
break;
case "BlocksManager_Remove" :
BlocksManager_Remove ( $bidr, $wb_name );
break;
case "BlocksManager_BlockPosition" :
BlocksManager_BlockPosition ( $bid, $wb_name, $position );
break;
case "BlocksManager_BlockOrder" :
BlocksManager_BlockOrder ( $wb_name, $weightrep, $weight, $bidrep, $bidori );
break;
}
} else {
echo "Access Denied";
}
?>
|
Any ideas? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
hicuxunicorniobestbuildpc
The Mouse Is Extension Of Arm
![](modules/Forums/images/avatars/5ed231554a8492e2e09da.gif)
Joined: Aug 13, 2009
Posts: 1123
|
Posted:
Sun Oct 27, 2013 4:57 am |
|
I tested this one and it is not working properly!!! |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
misterstereus
Regular
![Regular Regular](modules/Forums/images/ranks/2stars.gif)
![](modules/Forums/images/avatars/gallery/108.gif)
Joined: Aug 03, 2012
Posts: 61
Location: Rome Italy
|
Posted:
Sun Oct 27, 2013 9:48 am |
|
hicuxunicorniobestbuildpc theth is my language, I can put where I whant, you can delete it part I think it is not the problem to addon work, I remember you have problems width other modules but I not for example Multiheadlines module for me work and not for you, delete part of language if is a problem for you ![Very Happy](modules/Forums/images/smiles/icon_biggrin.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
neralex
Site Admin
![](modules/Forums/images/avatars/201442295664a46e4575d46.jpg)
Joined: Aug 22, 2007
Posts: 1775
|
Posted:
Sun Oct 27, 2013 9:53 am |
|
I have a little bit played with the script and have found besides some typos also some security-issues. The queries were not enough coverage - variables were passed unaudited and are not escaped. Also i haven't found CSFR-protections.
I have tried to fix all security issues, removed all deprecated erigi calls in the admin files, removed the old query to catch super admin rights and have added a check for determine center-blocks only for the selected home-module. In all other modules makes no sense to determine a center-block, because the center-blocks are only displayed in HOME.
I have added an little db-installer to store the needed db-table in the database, if the db-table was not found while opening the block-manager.
Also modified and corected the function blocks($side) for the mainfile.php.
blocks_manger.php (admin/modules/): https://gist.github.com/neralex/816a598754bac29bbe42
case.blocks_manager.php (admin/case/): https://gist.github.com/neralex/79325c4836b99628cfb4
links.blocks_manager.php (admin/links/): https://gist.github.com/neralex/d9ed1a6ac306d0e5e385
function blocks($side) for mainfile.php:
Code:function blocks($side) {
global $admin, $currentlang, $db, $moveableblocks, $multilingual, $prefix, $storynum, $user, $name;
if ($multilingual == 1) {
$querylang = 'AND (b.`blanguage` = \'' . $currentlang . '\' OR b.`blanguage` = \'\')';
} else {
$querylang = '';
}
$side = strtolower(substr($side, 0, 1));
if (!preg_match('/[lrcdt]/', $side)) {
die('invalid parameter passed to blocks function in mainfile = ' . $side);
}
if (strlen($name) != 0) {
$name = str_replace(' ','_',$name);
$name = str_replace('%20','_',$name);
$result = $db->sql_query('SELECT * FROM `' . $prefix . '_blocks` b, `' . $prefix . '_blocks_manager` m WHERE b.`active` = 1 AND b.`bid` = m.`bid` AND m.`title` = \'' . $db->sql_escape_string($name) . '\' AND m.`bposition` = \'' . $side . '\' ' . $querylang . ' ORDER BY m.`weight` ASC');
} else {
$result = $db->sql_query('SELECT * FROM `' . $prefix . '_blocks` b, `' . $prefix . '_blocks_manager` m WHERE b.`active` = 1 AND b.`bid` = m.`bid` AND m.`title` = \'admin\' AND m.`bposition` = \'' . $side . '\' ' . $querylang . ' ORDER BY m.`weight` ASC');
}
while($row = $db->sql_fetchrow($result, SQL_ASSOC)) {
$groups = $row['groups'];
$bid = $row['bid'];
$title = $row['title'];
$content = $row['content'];
$url = $row['url'];
$blockfile = $row['blockfile'];
$view = $row['view'];
$expire = $row['expire'];
#$action = $row['action'];
$action = $row['bposition'];
$action = substr($action, 0, 1);
$now = time();
$sub = $row['subscription'];
if ($sub == 0 OR ($sub == 1 AND !paid())) {
if ($expire != 0 AND $expire <= $now) {
if ($action == 'd') {
$db->sql_query('UPDATE `' . $prefix . '_blocks` SET `active` = 0, `expire` = \'0\' WHERE `bid` = \'' . $bid . '\'');
return;
} elseif ($action == 'r') {
$db->sql_query('DELETE FROM `' . $prefix . '_blocks` WHERE `bid` = \'' . $bid . '\'');
return;
}
}
if ($row['bkey'] == 'admin') {
adminblock();
} elseif ($row['bkey'] == 'userbox') {
userblock();
} elseif (empty($row['bkey'])) {
if ($view == 0) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view == 1 AND is_user($user) || is_admin($admin)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view == 2 AND is_admin($admin)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view == 3 AND !is_user($user) || is_admin($admin)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view > 3 AND in_groups($groups)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
}
}
}
}
}
|
|
_________________ Only registered users can see links on this board! Get registered or login!
Last edited by neralex on Sun Oct 27, 2013 2:53 pm; edited 3 times in total |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
hicuxunicorniobestbuildpc
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 10:30 am |
|
misterstereus: Multiheadlines has lots of problems. Now it is working properly. Check my site and u see how good is working. Of course everything takes time. Check the examples from neralex does the job and this way should be the right thing to do.
1. Security
2. Clean Code
3. Efficient
4. Easy way for others to learn and convert old stuff.
This is the table in case you need it.
Code:CREATE TABLE IF NOT EXISTS `nuke_blocks_manager` (
`bid` int(10) NOT NULL default '0',
`title` varchar(255) NOT NULL default '0',
`bposition` char(1) NOT NULL default '',
`weight` int(10) NOT NULL default '1',
KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
|
Last edited by hicuxunicorniobestbuildpc on Sun Oct 27, 2013 1:04 pm; edited 1 time in total |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
neralex
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 11:49 am |
|
hicuxunicorniobestbuildpc, in my version the table would be created within the block manger functions. The language constants for my version are only like this (more is not needed, because up, down, left right etc is provided by RN:
Code:// WB_BlocksManager
define('_BLOCKMGR_BLOCKS_MANAGER','Blocks Manager');
define('_BLOCKMGR_BLOCKSADMIN_MANAGER','Management of the posting of the blocks by module');
define('_BLOCKMGR_MODULEDROP','List blocks of the module:');
define('_BLOCKMGR_ADDNEWBLOCK_MANAGER','Add/Remove selected block(s) to/from select module(s)');
define('_BLOCKMGR_ACTIVE_BLOCKS','Inactive Blocks');
define('_BLOCKMGR_MODULES','Modules');
define('_BLOCKMGR_INACTIVE_BLOCKS','Active Blocks');
define('_BLOCKMGR_ADD_BLOCK','Add');
define('_BLOCKMGR_REMOVE_BLOCK','Remove');
define('_BLOCKMGR_NOENTRIES','No entries found!');
|
|
Last edited by neralex on Sun Oct 27, 2013 12:29 pm; edited 1 time in total |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
misterstereus
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 11:53 am |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
misterstereus
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 11:55 am |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
draxx
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 12:03 pm |
|
@Neralex - I have modified the header and footer to display center blocks on all the modules where a center block was defined.
Can you change your code to permit that? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
draxx
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 12:05 pm |
|
When you can configure a center block to only appear on a single page they become very valuable!!!! ![Smile](modules/Forums/images/smiles/icon_smile.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
draxx
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 12:09 pm |
|
Header:
Code:
f (defined('HOME_FILE')) {
blocks('t');
message_box();
blocks('c');
} else {
blocks('c');
|
Footer: Display them everywhere except the bottom of an article page (personal choice - because they looked stupid there):
Changed this:
function foot() {
global $admin, $db, $loglevel, $name, $file;
// if(defined('HOME_FILE')) {
to this:
Code:
if(defined('MODULE_FILE') AND ($name == 'News') AND ($file == 'article')) {
// blocks('d');
// Do nothing
} else {
blocks('d'); //show bottom blocks everywhere
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
neralex
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 12:15 pm |
|
draxx wrote: | @Neralex - I have modified the header and footer to display center blocks on all the modules where a center block was defined.
Can you change your code to permit that? |
If you mean the restiction to determine the center-blocks only for the home-module, then its only needed to remove the if-statements likes this:
Code:if ($wb_name == $main_module) {
# php stuff here, don't delete it!
}
|
draxx wrote: | When you can configure a center block to only appear on a single page they become very valuable!!!! |
What do you mean with a single page? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
draxx
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 12:34 pm |
|
A single page like .... example:
I have a module that is about fishing. I also have 3 blocks about fishing and 1 of them is a center block. I only want the center block about fishing to appear on the module page about fishing. I don't want it on the home page or the your account page or any other page - just that one. Make sense? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
hicuxunicorniobestbuildpc
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 12:38 pm |
|
neralex, all my blocks got the same name from the module I selected. Is that normal? How can I edit that? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
neralex
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 1:38 pm |
|
hicuxunicorniobestbuildpc wrote: | neralex, all my blocks got the same name from the module I selected. Is that normal? How can I edit that? |
Its a issue in the mainfile function blocks($side) - replace the function with this one:
Code:function blocks($side) {
global $admin, $currentlang, $db, $moveableblocks, $multilingual, $prefix, $storynum, $user, $name;
if ($multilingual == 1) {
$querylang = 'AND (b.`blanguage` = \'' . $currentlang . '\' OR b.`blanguage` = \'\')';
} else {
$querylang = '';
}
$side = strtolower(substr($side, 0, 1));
if (!preg_match('/[lrcdt]/', $side)) {
die('invalid parameter passed to blocks function in mainfile = ' . $side);
}
if (strlen($name) != 0) {
$name = str_replace(' ','_',$name);
$name = str_replace('%20','_',$name);
$result = $db->sql_query('SELECT b.*, m.`title` as `mtitle`, m.`bposition` as `bbposition` FROM `' . $prefix . '_blocks` b, `' . $prefix . '_blocks_manager` m WHERE b.`active` = 1 AND b.`bid` = m.`bid` AND m.`title` = \'' . $db->sql_escape_string($name) . '\' AND m.`bposition` = \'' . $side . '\' ' . $querylang . ' ORDER BY m.`weight` ASC');
} else {
$result = $db->sql_query('SELECT b.*, m.`title` as `mtitle`, m.`bposition` as `bbposition` FROM `' . $prefix . '_blocks` b, `' . $prefix . '_blocks_manager` m WHERE b.`active` = 1 AND b.`bid` = m.`bid` AND m.`title` = \'admin\' AND m.`bposition` = \'' . $side . '\' ' . $querylang . ' ORDER BY m.`weight` ASC');
}
while($row = $db->sql_fetchrow($result, SQL_ASSOC)) {
$groups = $row['groups'];
$bid = $row['bid'];
$title = $row['title'];
$content = $row['content'];
$url = $row['url'];
$blockfile = $row['blockfile'];
$view = $row['view'];
$expire = $row['expire'];
#$action = $row['action'];
$action = $row['bbposition'];
$action = substr($action, 0, 1);
$now = time();
$sub = $row['subscription'];
if ($sub == 0 OR ($sub == 1 AND !paid())) {
if ($expire != 0 AND $expire <= $now) {
if ($action == 'd') {
$db->sql_query('UPDATE `' . $prefix . '_blocks` SET `active` = 0, `expire` = \'0\' WHERE `bid` = \'' . $bid . '\'');
return;
} elseif ($action == 'r') {
$db->sql_query('DELETE FROM `' . $prefix . '_blocks` WHERE `bid` = \'' . $bid . '\'');
return;
}
}
if ($row['bkey'] == 'admin') {
adminblock();
} elseif ($row['bkey'] == 'userbox') {
userblock();
} elseif (empty($row['bkey'])) {
if ($view == 0) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view == 1 AND is_user($user) || is_admin($admin)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view == 2 AND is_admin($admin)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view == 3 AND !is_user($user) || is_admin($admin)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view > 3 AND in_groups($groups)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
}
}
}
}
}
|
|
Last edited by neralex on Sun Oct 27, 2013 2:22 pm; edited 2 times in total |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
neralex
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 2:08 pm |
|
draxx wrote: | A single page like .... example:
I have a module that is about fishing. I also have 3 blocks about fishing and 1 of them is a center block. I only want the center block about fishing to appear on the module page about fishing. I don't want it on the home page or the your account page or any other page - just that one. Make sense? |
You could duplicate the function blocks($side) in the mainfile to this one:
Code:function blocks2($side, $modname) {
global $admin, $currentlang, $db, $moveableblocks, $multilingual, $prefix, $storynum, $user;
$name = $modname;
if ($multilingual == 1) {
$querylang = 'AND (b.`blanguage` = \'' . $currentlang . '\' OR b.`blanguage` = \'\')';
} else {
$querylang = '';
}
$side = strtolower(substr($side, 0, 1));
if (!preg_match('/[lrcdt]/', $side)) {
die('invalid parameter passed to blocks function in mainfile = ' . $side);
}
if (strlen($name) != 0) {
$name = str_replace(' ','_',$name);
$name = str_replace('%20','_',$name);
$result = $db->sql_query('SELECT b.*, m.`title` as `mtitle`, m.`bposition` as `bbposition` FROM `' . $prefix . '_blocks` b, `' . $prefix . '_blocks_manager` m WHERE b.`active` = 1 AND b.`bid` = m.`bid` AND m.`title` = \'' . $db->sql_escape_string($name) . '\' AND m.`bposition` = \'' . $side . '\' ' . $querylang . ' ORDER BY m.`weight` ASC');
} else {
$result = $db->sql_query('SELECT b.*, m.`title` as `mtitle`, m.`bposition` FROM `' . $prefix . '_blocks` b, `' . $prefix . '_blocks_manager` m WHERE b.`active` = 1 AND b.`bid` = m.`bid` AND m.`title` = \'admin\' AND m.`bposition` = \'' . $side . '\' ' . $querylang . ' ORDER BY m.`weight` ASC');
}
while($row = $db->sql_fetchrow($result, SQL_ASSOC)) {
$groups = $row['groups'];
$bid = $row['bid'];
$title = $row['title'];
$content = $row['content'];
$url = $row['url'];
$blockfile = $row['blockfile'];
$view = $row['view'];
$expire = $row['expire'];
#$action = $row['action'];
$action = $row['bbposition'];
$action = substr($action, 0, 1);
$now = time();
$sub = $row['subscription'];
if ($sub == 0 OR ($sub == 1 AND !paid())) {
if ($expire != 0 AND $expire <= $now) {
if ($action == 'd') {
$db->sql_query('UPDATE `' . $prefix . '_blocks` SET `active` = 0, `expire` = \'0\' WHERE `bid` = \'' . $bid . '\'');
return;
} elseif ($action == 'r') {
$db->sql_query('DELETE FROM `' . $prefix . '_blocks` WHERE `bid` = \'' . $bid . '\'');
return;
}
}
if ($row['bkey'] == 'admin') {
adminblock();
} elseif ($row['bkey'] == 'userbox') {
userblock();
} elseif (empty($row['bkey'])) {
if ($view == 0) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view == 1 AND is_user($user) || is_admin($admin)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view == 2 AND is_admin($admin)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view == 3 AND !is_user($user) || is_admin($admin)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view > 3 AND in_groups($groups)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
}
}
}
}
}
|
After now you can call the function for example in the footer.php like this:
Code: if(defined('HOME_FILE')) {
blocks('d');
} else {
if (defined('MODULE_FILE')) {
if ($name == 'Fishing' || $name == 'Hunting'' || $name == 'Smoking') { # your own module names here
blocks2('d', $name);
}
if (file_exists('modules/' . $name . '/copyright.php')) {
$cpname = str_replace('_', ' ', $name);
echo '<div align="right"><a href="javascript:openwindow()">' . $cpname . ' ©</a></div>';
}
if (file_exists('modules/' . $name . '/admin/panel.php') && is_admin($admin)) {
echo '<br />';
OpenTable();
include_once 'modules/' . $name . '/admin/panel.php';
CloseTable();
}
}
}
|
I have make it possible in the block_manager.php, if you want only set the center-blocks for the home-module or for all:
blocks_manager.php (updated): https://gist.github.com/neralex/816a598754bac29bbe42
Code:$centerblocks_only_for_home = 1; # set to 0 to have the option every time
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
draxx
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 3:12 pm |
|
That is good stuff!!! The center blocks appear on the correct pages.
I am running all of the code supplied by Neralex with still one problem:
The problem is in the admin panel when you move a block up and down (change the module weight) it changes the module weight for that block in ALL the modules.
It should only change the weight in the current module that is being edited.
It does not seem to matter what module you change the weight of a block for - it changes the weight in all of them. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
neralex
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 3:24 pm |
|
Its not a problem, its a thing about the logic behind the block-weight, because it must be change for all.
Please note: You are trying to go a way outside of this logic! To make it possible for only one module, then you must change the complete db-table an the code for blocks_manager.php for the blocks-manager.
The CMS in the current version have not these options and to recode it, it needs some time and its not a thing about 10 minutes. If you would do all this things, then you get many problems if the CMS was updated to a newer version, then you must recode all of them.
Maybe you should re-think your way ... because you have the following chances:
1. you will find a own way to recode all of them
2. you will find someone to recode it all for money (check "for hire" section here)
3. you live with it how it works |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
spasticdonkey
RavenNuke(tm) Development Team
![](modules/Forums/images/avatars/48fb116845dfecf66294c.gif)
Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA
|
Posted:
Sun Oct 27, 2013 3:45 pm |
|
On a side note there will be options for displaying center blocks and messages by module; with our new themes in the next release. Although it will only use one sort order for all modules as well; and there is no functional changes to blocks administration.. i.e. it will display the same blocks/messages for any enabled module. I like the idea of this addon and it will probably be something I look into once we get the release finished..
![Image Image](http://rtsforce.com/images/blocks.png) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
draxx
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 3:47 pm |
|
Ahhhh. I see. I thought it was a problem because it did not function that way in the last version. |
Last edited by draxx on Sun Oct 27, 2013 3:54 pm; edited 2 times in total |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
hicuxunicorniobestbuildpc
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 3:48 pm |
|
neralex, the new function did the job. Now it is working as it should be. Thank you very much for taking the time to fix this OLD addon. See ya around!!! |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
draxx
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 3:51 pm |
|
hicuxunicorniobestbuildpc wrote: | neralex, the new function did the job. Now it is working as it should be. Thank you very much for taking the time to fix this OLD addon. See ya around!!! |
+1 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
draxx
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 27, 2013 3:57 pm |
|
neralex wrote: |
1. you will find a own way to recode all of them
2. you will find someone to recode it all for money (check "for hire" section here)
3. you live with it how it works |
If this your way of saying you want me to buy you lunch for fixing this much needed module I am very happy to do so! What is your paypal?
neralex wrote: | Its not a problem, its a thing about the logic behind the block-weight, because it must be change for all.
Please note: You are trying to go a way outside of this logic! To make it possible for only one module, then you must change the complete db-table an the code for blocks_manager.php for the blocks-manager.
The CMS in the current version have not these options and to recode it, it needs some time and its not a thing about 10 minutes. If you would do all this things, then you get many problems if the CMS was updated to a newer version, then you must recode all of them.
Maybe you should re-think your way ... because you have the following chances:
|
I see in the blocks_manager database there is already a field to maintain the weight of that block for that module.
In the old version of the blocks manager when you update the weight for a block it only updates the weight field for that title.
This version when you change a block weight it updates the weight field for all titles ?? It should only update the weight for the title selected.
CREATE TABLE nuke_blocks_manager (
bid int(10) NOT NULL default '0',
title varchar(255) NOT NULL default '0',
bposition char(1) NOT NULL default '',
weight int(10) NOT NULL default '1',
KEY title (title)
) TYPE=MyISAM;
I say this logic already exists in the database. Why else would there even be a weight field for each block by title? It is so you can change it for just that title.
Otherwise there is no need for defining block weights. They are already defined in _blocks data table. It is to over-ride them by title. The code is adjusting all titles - it should only adjust 1 title.
Right? I know I am a NooB but am I that far gone? LOL! ![Very Happy](modules/Forums/images/smiles/icon_biggrin.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
misterstereus
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Oct 28, 2013 1:48 am |
|
This is my fix for your fileCode:
<?php
define ( "_BLOCKS_MANAGER", "Manager Blocchi" );
define ( "_BLOCKMGR", "Decidi Posizione Blocchi per Modulo" );
define ( "_BLOCKMGR_MODULEDROP", "Lista Blocchi per il Modulo :" );
define ( "_BLOCKMGR_ADDNEWBLOCK", "Aggiungi/Rimuovi Blocchi Selezionati dal Modulo Scelto" );
define ( "_BLOCKMGR_ACTIVE_BLOCKS", "Blocchi Non Attivi" );
define ( "_BLOCKMGR_INACTIVE_BLOCKS", "Blocchi Attivi" );
define ( "_BLOCKMGR_ADD_BLOCK", "Aggiungi" );
define ( "_BLOCKMGR_REMOVE_BLOCK", "Rimuovi" );
define ( "_BLOCKMGR_TITLE", "Titolo" );
define ( "_BLOCKMGR_POSITION", "Posizione" );
define ( "_BLOCKMGR_WEIGHT", "Weight" );
define ( "_BLOCKMGR_STATUS", "Stato" );
define ( "_BLOCKMGR_VIEW", "Visibile a" );
define ( "_BLOCKMGR_LANGUAGE", "Lingua" );
define ( "_BLOCKMGR_LEFT", "Sinistra" );
define ( "_BLOCKMGR_CENTERUP", "Centra Sopra" );
define ( "_BLOCKMGR_CENTERDOWN", "Centra Sotto" );
define ( "_BLOCKMGR_RIGHT", "Destra" );
define ( "_BLOCKMGR_BLOCKUP", "Sposta in Alto" );
define ( "_BLOCKMGR_BLOCKDOWN", "Sposta in Basso" );
define ( "_BLOCKMGR_DEACTIVATE", "Disattiva" );
define ( "_BLOCKMGR_ACTIVATE", "Attiva" );
define ( "_BLOCKMGR_INACTIVE", "Non Attivo" );
define ( "_BLOCKMGR_ACTIVE", "Attivo" );
if (! defined ( 'ADMIN_FILE' )) {
die ( "Access Denied" );
}
global $prefix, $db, $wb_name;
$aid = substr ( "$aid", 0, 25 );
$row = $db->sql_fetchrow ( $db->sql_query ( "SELECT radminsuper FROM " . $prefix . "_authors WHERE aid='$aid'" ) );
if ($row ['radminsuper'] == 1) {
/**
* ******************************************************
*/
/* Blocks_Manager Functions */
/**
* ******************************************************
*/
function BlocksManager($wb_name) {
global $db, $prefix, $currentlang, $multilingual, $bgcolor2;
OpenHeader ( _BLOCKMGR );
$wb_url = "admin.php?op=BlocksManager&wb_name=";
echo "<center><form action=\"admin.php\" method=\"post\">\n" . _BLOCKMGR_MODULEDROP . " <select name=\"wb_name\" size=\"1\" onChange=\"top.location.href=this.options[this.selectedIndex].value\">\n";
if (! isset ( $wb_name )) {
$wb_name = "admin";
}
echo "<option value=\"" . $wb_url . "admin\"";
if ($wb_name == "admin") {
echo " selected";
}
echo ">admin</option>\n";
$result = $db->sql_query ( "SELECT mid, title, custom_title, active, view, inmenu FROM " . $prefix . "_modules WHERE active=1 ORDER BY title ASC" );
while ( list ( $mid, $title, $custom_title, $active, $view, $inmenu ) = $db->sql_fetchrow ( $result ) ) {
echo "<option value=\"" . $wb_url . $title . "\"";
if ($wb_name == $title) {
echo " selected";
}
echo ">$title</option>\n";
if (! isset ( $wb_name )) {
$wb_name = $title;
}
}
echo "</select>\n" . "</form>\n</center>\n";
echo "<table border=\"0\" width=\"100%\">\n<tr>\n" . "<td align=\"center\" bgcolor=\"$bgcolor2\">" . _BLOCKMGR_TITLE . "</td>\n" . "<td align=\"center\" bgcolor=\"$bgcolor2\">" . _BLOCKMGR_POSITION . "</td>\n" . "<td align=\"center\" bgcolor=\"$bgcolor2\" colspan=\"2\">" . _BLOCKMGR_WEIGHT . "</td>\n" . "<td align=\"center\" bgcolor=\"$bgcolor2\">" . _BLOCKMGR_STATUS . "</td>\n" . "<td align=\"center\" bgcolor=\"$bgcolor2\">" . _BLOCKMGR_VIEW . "</td>\n";
if ($multilingual == 1) {
echo "<td align=\"center\" bgcolor=\"$bgcolor2\">" . _BLOCKMGR_LANGUAGE . "</td>\n";
}
$i = 0;
$sql = "SELECT b.bid, b.bkey, b.title, b.url, m.bposition, m.weight, b.active, b.blanguage, b.blockfile, b.view FROM " . $prefix . "_blocks b, " . $prefix . "_blocks_manager m WHERE b.bid=m.bid AND m.title='$wb_name' ORDER BY bposition, weight";
$result = $db->sql_query ( $sql );
while ( list ( $bid, $bkey, $title, $url, $bposition, $weight, $active, $blanguage, $blockfile, $view ) = $db->sql_fetchrow ( $result ) ) {
$weight1 = $weight - 1;
$weight3 = $weight + 1;
$res1 = $db->sql_query ( "SELECT bid FROM " . $prefix . "_blocks_manager WHERE title='$wb_name' AND weight='$weight1' AND bposition='$bposition'" );
list ( $con1 ) = $db->sql_fetchrow ( $res1 );
$res2 = $db->sql_query ( "SELECT bid FROM " . $prefix . "_blocks_manager WHERE title='$wb_name' AND weight='$weight3' AND bposition='$bposition'" );
list ( $con2 ) = $db->sql_fetchrow ( $res2 );
$wb_url = "admin.php?op=BlocksManager_BlockPosition&wb_name=$wb_name&bid=$bid&position=";
$t_position = "<form action=\"admin.php\" method=\"post\">\n";
$t_position .= "<select name=\"bposition\" onChange=\"top.location.href=this.options[this.selectedIndex].value\">\n";
// if (!isset($wb_name)) { $wb_name = "admin"; }
$t_position .= "<option value=\"" . $wb_url . "l\"";
if ($bposition == "l") {
$t_position .= " selected";
}
$t_position .= ">" . _BLOCKMGR_LEFT . "</option>\n";
$t_position .= "<option value=\"" . $wb_url . "c\"";
if ($bposition == "c") {
$t_position .= " selected";
}
$t_position .= ">" . _BLOCKMGR_CENTERUP . "</option>\n";
$t_position .= "<option value=\"" . $wb_url . "d\"";
if ($bposition == "d") {
$t_position .= " selected";
}
$t_position .= ">" . _BLOCKMGR_CENTERDOWN . "</option>\n";
$t_position .= "<option value=\"" . $wb_url . "r\"";
if ($bposition == "r") {
$t_position .= " selected";
}
$t_position .= ">" . _BLOCKMGR_RIGHT . "</option>\n";
$t_position .= "</select>\n</form>\n";
echo "<tr>\n" . "<td align=\"center\">$title</td>\n" . "<td align=\"center\">$t_position</td>\n" . "<td align=\"center\">$weight</td>\n" . "<td align=\"center\">\n";
if ($con1) {
echo "<a href=\"admin.php?op=BlocksManager_BlockOrder&wb_name=$wb_name&weight=$weight&bidori=$bid&weightrep=$weight1&bidrep=$con1\">" . "<img src=\"images/up.gif\" alt=\"" . _BLOCKMGR_BLOCKUP . "\" title=\"" . _BLOCKMGR_BLOCKUP . "\" border=\"0\" hspace=\"3\">" . "</a>\n";
}
if ($con2) {
echo "<a href=\"admin.php?op=BlocksManager_BlockOrder&wb_name=$wb_name&weight=$weight&bidori=$bid&weightrep=$weight3&bidrep=$con2\">" . "<img src=\"images/down.gif\" alt=\"" . _BLOCKMGR_BLOCKDOWN . "\" title=\"" . _BLOCKMGR_BLOCKDOWN . "\" border=\"0\" hspace=\"3\">" . "</a>\n";
}
echo "</td>\n";
$block_act = $active;
if ($active == 1) {
$active = _BLOCKMGR_ACTIVE;
$change = _BLOCKMGR_DEACTIVATE;
} elseif ($active == 0) {
$active = "<i>" . _BLOCKMGR_INACTIVE . "</i>";
$change = _BLOCKMGR_ACTIVATE;
}
echo "<td align=\"center\">$active</td>\n";
if ($view == 0) {
$who_view = _MVALL;
} elseif ($view == 1) {
$who_view = _MVUSERS;
} elseif ($view == 2) {
$who_view = _MVADMIN;
} elseif ($view == 3) {
$who_view = _MVANON;
}
echo "<td align=\"center\">$who_view</td>\n";
if ($multilingual == 1) {
if ($blanguage == "") {
$blanguage = _ALL;
} else {
$blanguage = ucfirst ( $blanguage );
}
echo "<td align=\"center\">$blanguage</td>\n";
}
echo "</tr>\n";
$wb_tabblocks [$i] = $bid;
$i ++;
}
echo "</table>\n";
echo "<br />\n";
echo "<center><b>" . _BLOCKMGR_ADDNEWBLOCK . "</b></center>\n" . "<form name=\"BM_EDIT\" action=\"admin.php\" method=\"post\">\n" . "<table width=\"80%\" align=\"center\">\n" . "<tr>\n";
// List all inactive Blocks for selected module
echo "<td align=\"center\" valign=\"top\">\n" . _BLOCKMGR_ACTIVE_BLOCKS . "<br />\n" . "<select name=\"bida[]\" size=\"10\" multiple>\n";
$sql = "SELECT bid, title FROM " . $prefix . "_blocks ORDER BY title ASC";
$result = $db->sql_query ( $sql );
while ( list ( $bid, $title ) = $db->sql_fetchrow ( $result ) ) {
$ii = 0;
$wb_affiche = 1;
while ( $ii < $i ) {
if ($wb_tabblocks [$ii] == $bid) {
$wb_affiche = 0;
}
$ii ++;
}
if ($wb_affiche == 1) {
echo "<option value=\"" . $bid . "\">$title</option>\n";
}
}
echo "</select><br />\n" . "<input type=\"submit\" value=\"" . _BLOCKMGR_ADD_BLOCK . "\" onclick=\"document.BM_EDIT.op.value='BlocksManager_Add';\">\n" . "</td>\n";
// List all active Blocks for selected module
echo "<td align=\"center\" valign=\"top\">\n" . _BLOCKMGR_INACTIVE_BLOCKS . "<br />\n" . "<select name=\"bidr[]\" size=\"10\" multiple>\n";
$sql = "SELECT b.bid, b.title FROM " . $prefix . "_blocks b, " . $prefix . "_blocks_manager m WHERE b.bid=m.bid AND m.title='$wb_name' ORDER BY title ASC";
$result = $db->sql_query ( $sql );
while ( list ( $bid, $title ) = $db->sql_fetchrow ( $result ) ) {
echo "<option value=\"$bid\">$title</option>\n";
}
echo "</select><br />\n" . "<input type=\"submit\" value=\"" . _BLOCKMGR_REMOVE_BLOCK . "\" onclick=\"document.BM_EDIT.op.value='BlocksManager_Remove';\">\n" . "</td>\n" . "</tr>\n" . "</table>\n" . "<input type=\"hidden\" name=\"wb_name\" value=\"$wb_name\">\n" . "<input type=\"hidden\" name=\"op\" value=\"BlocksManager_Add\">\n" . "</form>\n";
CloseFooter ();
}
function BlocksManager_Add($bid, $wb_name) {
global $db, $prefix;
$sql = "SELECT MAX(weight) FROM " . $prefix . "_blocks_manager WHERE title='$wb_name'";
$result = $db->sql_query ( $sql );
list ( $weight ) = $db->sql_fetchrow ( $result );
foreach ( $bid as $bKey => $bValue ) {
$weight ++;
$db->sql_query ( "INSERT INTO " . $prefix . "_blocks_manager VALUES ('$bValue', '$wb_name', 'r', '$weight')" );
}
BlocksManager_FixWeight ( $title );
header ( "Location: admin.php?op=BlocksManager&wb_name=$wb_name" );
}
function BlocksManager_Remove($bid, $wb_name) {
global $db, $prefix;
foreach ( $bid as $bKey => $bValue ) {
$db->sql_query ( "DELETE FROM " . $prefix . "_blocks_manager WHERE bid='$bValue' AND title='$wb_name'" );
}
BlocksManager_FixWeight ( $title );
header ( "Location: admin.php?op=BlocksManager&wb_name=$wb_name" );
}
function BlocksManager_FixWeight($wb_name) {
global $db, $prefix;
$position [] = 'l';
$position [] = 'r';
$position [] = 'c';
$position [] = 'd';
$position [] = '';
foreach ( $position as $pKey => $pValue ) {
$result = $db->sql_query ( "SELECT bid FROM " . $prefix . "_blocks_manager WHERE title='$wb_name' AND bposition='$pValue' ORDER BY weight ASC" );
$weight = 0;
while ( list ( $bid ) = $db->sql_fetchrow ( $result ) ) {
$weight ++;
if ($pValue != '') :
$db->sql_query ( "UPDATE " . $prefix . "_blocks_manager SET weight='$weight' WHERE title='$wb_name' AND bid='$bid'" );
else :
$db->sql_query ( "UPDATE " . $prefix . "_blocks_manager SET weight='$weight', bposition='r' WHERE title='$wb_name' AND bid='$bid'" );
endif;
}
}
header ( "Location: admin.php?op=BlocksManager&wb_name=$wb_name" );
}
function BlocksManager_BlockPosition($bid, $wb_name, $position) {
global $db, $prefix;
$db->sql_query ( "UPDATE " . $prefix . "_blocks_manager SET bposition='$position' WHERE bid='$bid' AND title='$wb_name'" );
BlocksManager_FixWeight ( $wb_name );
header ( "Location: admin.php?op=BlocksManager&wb_name=$wb_name" );
}
function BlocksManager_BlockOrder($wb_name, $weightrep, $weight, $bidrep, $bidori) {
global $db, $prefix;
$result = $db->sql_query ( "UPDATE " . $prefix . "_blocks_manager SET weight='$weight' WHERE bid='$bidrep' and title='$wb_name'" );
$result2 = $db->sql_query ( "UPDATE " . $prefix . "_blocks_manager SET weight='$weightrep' WHERE bid='$bidori' and title='$wb_name'" );
BlocksManager_FixWeight ( $wb_name );
header ( "Location: admin.php?op=BlocksManager&wb_name=$wb_name" );
}
function OpenHeader($title = "") {
include ("header.php");
GraphicAdmin ();
title ( $title );
OpenTable ();
}
function CloseFooter() {
CloseTable ();
include ("footer.php");
}
switch ($op) {
case "BlocksManager" :
BlocksManager ( $wb_name );
break;
case "BlocksManager_Add" :
BlocksManager_Add ( $bida, $wb_name );
break;
case "BlocksManager_Remove" :
BlocksManager_Remove ( $bidr, $wb_name );
break;
case "BlocksManager_BlockPosition" :
BlocksManager_BlockPosition ( $bid, $wb_name, $position );
break;
case "BlocksManager_BlockOrder" :
BlocksManager_BlockOrder ( $wb_name, $weightrep, $weight, $bidrep, $bidori );
break;
}
} else {
echo "Access Denied";
}
?>
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|