Log in

View Full Version : Adding a field into the edit forum menu..


TyleR
11-28-2005, 06:28 AM
Okay, coming down to the last thing for this mod conversion to vB 3.5.x, was testing it, all code works fine, but when I enable this to work for a specific forum, I get this error:

Fatal error: Field hack_poster is not defined in $validfields in class vb_datamanager_forum in /includes/class_dm.php on line 483

How would I go about making it a valid field?

Thanks!

- Tyler

Marco van Herwaarden
11-28-2005, 06:52 AM
$dm_object->validfields['hack_poster'] = array(TYPE_UINT, REQ_NO);
Ofcourse you will need to adjust the values.

TyleR
11-28-2005, 06:55 AM
$dm_object->validfields['hack_poster'] = array(TYPE_UINT, REQ_NO);
Ofcourse you will need to adjust the values.

Where would this be added to? the area added in forum.php was done by a plugin:


<plugin active="1">
<title>Forum Admin Tables</title>
<hookname>forumadmin_edit_form</hookname>
<phpcode><![CDATA[print_table_header($vbphrase['enable_disable_features_hacks']);
print_yes_no_row('Enable Hack Poster', 'forum[hack_poster]', $forum['hack_poster']);
print_yes_no_row('Show Uninstall Button', 'forum[hack_poster_private]', $forum['hack_poster_private']);]]></phpcode>
</plugin>

merk
11-28-2005, 07:20 AM
youll need to put it into the hook that is inside the constructor for the forum datamanager.

TyleR
11-28-2005, 06:02 PM
thanks for that, but it couldnt be added by a hook, i actually had to add it to includes/class_dm_forum.php

But, everything else is sorted, now i get this:

Database error in vBulletin 3.5.1:

Invalid SQL:
SELECT userid FROM lockdown_install WHERE threadid=1 AND userid=Array[userid];

MySQL Error : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '[userid]' at line 1
Error Number : 1064
Date : Monday, November 28th 2005 @ 01:59:14 PM
Script : /dev/showthread.php?p=1
Referrer : /dev/index.php?
IP Address : xx.xx.xx.xx
Username : TwiSteD
Classname : vb_database

this is the plugin code thats causing the error:

if ($foruminfo['hack_poster'] == 1)
{
// lets get all the lockdown information from the database for that thread
$hacks = $db->query_read("
SELECT *
FROM " . TABLE_PREFIX . "lockdown
WHERE threadid = '" . $threadinfo['threadid'] . "'
");

$install_check = '';
$install_button = '';
$hack_options = '';

$verif = $db->query_read("SELECT userid FROM ". TABLE_PREFIX ."lockdown_install WHERE threadid=$threadinfo[threadid] AND userid=$vbulletin->userinfo[userid]");

if ($verif)
{
$install_check = true;
}
else
{
$install_check = false;
}

if (($foruminfo['hack_poster_private'] == 1) AND ($verif))
{
eval('$install_button = "' . fetch_template('hack_uninstall') . '";');
}
else if (($foruminfo['hack_poster_private'] ==1) AND (!$verif))
{
eval('$install_button = "' . fetch_template('hack_install') . '";');
}
else if ((!$foruminfo['hack_poster_private'] ==1) AND ($verif))
{
$install_button = '';
}
else
{
eval('$install_button = "' . fetch_template('hack_install') . '";');
}

if(!$hacks['dateline'])
{
$hacks['postdate'] = '';
$hacks['posttime'] = '';
}
else
{
$hacks['postdate'] = vbdate($vboptions['dateformat'], $hacks['dateline'], true);
$hacks['posttime'] = vbdate($vboptions['timeformat'], $hacks['dateline']);
}

if(!$hacks['updated'])
{
$hacks['update'] = '';
$hacks['updatetime'] = '';
}
else
{
$hacks['update'] = vbdate($vboptions['dateformat'], $hacks['updated'], true);
$hacks['updatetime'] = vbdate($vboptions['timeformat'], $hacks['updated']);
}

if (($vbulletin->userinfo['usergroupid'] == 6) || ($vbulletin->userinfo['usergroupid'] == 7) || ($vbulletin->userinfo['usergroupid'] == 5))
{
$hack_options = true;
eval('$hack_options = "' . fetch_template('hack_moderator_options') . '";');
}
else
{
$hack_options = '';
}

}

merk
11-28-2005, 08:52 PM
It can be added via forumdata_start, just like i said :confused:

The problem you face is an itchy one, $vbulletin->userinfo is being parsed without the array component after it. Either take it out of quotes (and use . to append) or surround it in braces, like {$vbulletin->userinfo[userid]}

TyleR
11-29-2005, 02:26 AM
i used that hook location, it did nothing, i still recieved that error after trying that.

anyways, the previous post i did, was solved by just appending it in quotes..next error (sheesh, this stinks..so many errors in testing stages, heh!)

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/tyler/public_html/.../showthread.php(921) : eval()'d code on line 25

its the same plugin i posted a few up, just with that line edited.

merk
11-29-2005, 09:05 PM
You obviously didnt do it right :p


if ($foruminfo['hack_poster'] == 1)
{
// lets get all the lockdown information from the database for that thread
$hacks = $db->query_read("
SELECT *
FROM " . TABLE_PREFIX . "lockdown
WHERE threadid = '" . $threadinfo['threadid'] . "'
");

$install_check = '';
$install_button = '';
$hack_options = '';

$verif = $db->query_read("SELECT userid FROM ". TABLE_PREFIX ."lockdown_install WHERE threadid=$threadinfo[threadid] AND userid={$vbulletin->userinfo[userid]}");

if ($verif)
{
$install_check = true;
}
else
{
$install_check = false;
}

if (($foruminfo['hack_poster_private'] == 1) AND ($verif))
{
eval('$install_button = "' . fetch_template('hack_uninstall') . '";');
}
else if (($foruminfo['hack_poster_private'] ==1) AND (!$verif))
{
eval('$install_button = "' . fetch_template('hack_install') . '";');
}
else if ((!$foruminfo['hack_poster_private'] ==1) AND ($verif))
{
$install_button = '';
}
else
{
eval('$install_button = "' . fetch_template('hack_install') . '";');
}

if(!$hacks['dateline'])
{
$hacks['postdate'] = '';
$hacks['posttime'] = '';
}
else
{
$hacks['postdate'] = vbdate($vboptions['dateformat'], $hacks['dateline'], true);
$hacks['posttime'] = vbdate($vboptions['timeformat'], $hacks['dateline']);
}

if(!$hacks['updated'])
{
$hacks['update'] = '';
$hacks['updatetime'] = '';
}
else
{
$hacks['update'] = vbdate($vboptions['dateformat'], $hacks['updated'], true);
$hacks['updatetime'] = vbdate($vboptions['timeformat'], $hacks['updated']);
}

if (($vbulletin->userinfo['usergroupid'] == 6) || ($vbulletin->userinfo['usergroupid'] == 7) || ($vbulletin->userinfo['usergroupid'] == 5))
{
$hack_options = true;
eval('$hack_options = "' . fetch_template('hack_moderator_options') . '";');
}
else
{
$hack_options = '';
}

}




Or (just the query)

$verif = $db->query_read("SELECT userid FROM ". TABLE_PREFIX ."lockdown_install WHERE threadid=$threadinfo[threadid] AND userid=". $vbulletin->userinfo[userid]);

TyleR
11-30-2005, 02:56 AM
now I get:

Warning: Cannot use a scalar value as an array in /showthread.php(921) : eval()'d code on line 44

Warning: Cannot use a scalar value as an array in /showthread.php(921) : eval()'d code on line 45

Warning: Cannot use a scalar value as an array in /showthread.php(921) : eval()'d code on line 55

Warning: Cannot use a scalar value as an array in /showthread.php(921) : eval()'d code on line 56

Sigh..so frustrating :(

Thanks a bunch for your help thus far, merk :)

merk
11-30-2005, 11:24 PM
You didnt update the query properly.

It needs both a { and a } around the entire variable (and youve only put a } at the end)

TyleR
12-01-2005, 02:53 AM
You didnt update the query properly.

It needs both a { and a } around the entire variable (and youve only put a } at the end)

yeah, I meant to re-update the post to say i spotted that..now back to those error's originally posted. :ermm:

TyleR
12-03-2005, 05:41 PM
now I get:

Warning: Cannot use a scalar value as an array in /showthread.php(921) : eval()'d code on line 44

Warning: Cannot use a scalar value as an array in /showthread.php(921) : eval()'d code on line 45

Warning: Cannot use a scalar value as an array in /showthread.php(921) : eval()'d code on line 55

Warning: Cannot use a scalar value as an array in /showthread.php(921) : eval()'d code on line 56

Sigh..so frustrating :(

Thanks a bunch for your help thus far, merk :)

Anyone?

Marco van Herwaarden
12-03-2005, 07:17 PM
$hacks = $db->query_read("
$hacks['postdate'] = '';
$hacks is a MySQL resource, not an array. If you expect only 1 single row from that query, change query_read to query_first, and it will work. The same goes for your second query.

TyleR
12-04-2005, 04:49 AM
Edit..wait..i do only need one row. Nevermind :P

merk
12-04-2005, 04:51 AM
just use query_first.

TyleR
12-04-2005, 04:57 AM
Alright, looks like all PHP-end errors are done..now im not getting the new template to display as it's the first post..maybe i did something wrong with the install instructions?

here's the template edit's:

################################
template newthread & editpost:
################################

======
find:
======

<fieldset class="fieldset">
<legend>$vbphrase[miscellaneous_options]</legend>

===========
add above:
===========

$hackoptions

#####################
template showthread:
#####################

======
find:
======

<div id="posts">$postbits<div id="lastpost"></div></div>

===========
add above:
===========

<if condition="$pagenumber != 1">
<div id="firstpost">$postbits_firstpost</div>
</if>


##################################
template: threadadmin_movethread
##################################

======
find:
======

<div><label for="rb_method_movered"><input type="radio" name="method" value="movered" id="rb_method_movered" checked="checked" />$vbphrase[move_and_leave_redirect_in_previous_forum]</label></div>
<div><label for="rb_method_copy"><input type="radio" name="method" value="copy" id="rb_method_copy" />$vbphrase[copy_thread_to_destination_forum]</label></div>

==============
replace with:
==============

<if condition="$foruminfo[hack_poster] !='1'">
<div><label for="rb_method_movered"><input type="radio" name="method" value="movered" id="rb_method_movered" checked="checked" />$vbphrase[move_and_leave_redirect_in_previous_forum]</label></div>
</if>
<if condition="$foruminfo[hack_poster] !='1'">
<div><label for="rb_method_copy"><input type="radio" name="method" value="copy" id="rb_method_copy" />$vbphrase[copy_thread_to_destination_forum]</label></div>
</if>


####################################
template: threadbit
####################################


======
find:
======


$thread[movedprefix]
$thread[typeprefix]
$thread[moderatedprefix]
<if condition="$show['gotonewpost']">
<strong><a href="showthread.php?$session[sessionurl]t=$thread[threadid]$thread[highlight]" id="thread_title_$thread[realthreadid]">$thread[threadtitle]</a></strong>



===========
change to:
===========


$thread[movedprefix]
$thread[typeprefix]
$thread[moderatedprefix]
<if condition="$show['gotonewpost']">
<strong><a href="showthread.php?$session[sessionurl]t=$thread[threadid]$thread[highlight]" id="thread_title_$thread[realthreadid]"><if condition="$ishack">[$hack[version_vb]]&nbsp;</if>$thread[threadtitle]<if condition="$ishack">&nbsp;[$hack[version_hack]]</if></a></strong>


======
find:
======


<if condition="$show['paperclip']"> <img class="inlineimg" src="$stylevar[imgdir_misc]/paperclip.gif" alt="<phrase 1="$thread[attach]">$vbphrase[x_attachments]</phrase>" /> </if>


===========
add above:
===========



<if condition="$ishack">($install_count)</if>

I didnt see anything wrong with it..but I could be wrong, lol..my mind is going nuts lately, sorry for all the questions folks.