as requested...
Add-On: Allow users to choose which posting engine to use via UserCp Options
A nice addition by Velocd
This will help users whose browser does not support the WYSIWYG editor, such as Mozilla 1.0 (stated by GameCrash earlier in this thread). Also, everything is about user preference so its good to give your members an option.
Very easy to install, shouldn't take long at all. Although, if you currently have the WYSIWYG editor installed you will have to do a few things on your own.
--------------------------------------------------------------
Install Procedure:
--------------------------------------------------------------
1. Run the following query in PhpMyAdmin:
Code:
alter table user
add enablewysiwyg smallint(5) UNSIGNED not null default '0';
2. In
member.php, find the following:
PHP Code:
$showsignaturesnotchecked="checked";
}
Directly below it add:
PHP Code:
if ($bbuserinfo[enablewysiwyg]) {
$enablewysiwygchecked="checked";
$enablewysiwygnotchecked="";
} else {
$enablewysiwygchecked="";
$enablewysiwygnotchecked="checked";
}
Now find:
PHP Code:
$options=iif($showsignatures=="yes",1,0);
Below it add:
PHP Code:
$enablewysiwyg=iif($enablewysiwyg=="yes",1,0);
Last but no least, find:
PHP Code:
$DB_site->query("UPDATE user
SET ".$updatestyles."adminemail='$adminemail',enablewysiwyg='$enablewysiwyg',allowrate='$allowrate',
showemail='$showemail',invisible='$invisible',cookieuser='$cookieuser',
maxposts='".addslashes($umaxposts)."',daysprune='".addslashes($prunedays)."',
timezoneoffset='".addslashes($timezoneoffset)."',emailnotification='$emailnotification',
startofweek='".addslashes($startofweek)."',options='$options',receivepm='$receivepm',
emailonpm='$emailonpm',pmpopup='$pmpopup',usergroupid='$bbuserinfo[usergroupid]',
nosessionhash='$nosessionhash'
WHERE userid='$bbuserinfo[userid]'");
And see in that code on the 2nd line where I have:
PHP Code:
enablewysiwyg='$enablewysiwyg',
You wanna add that too

After your finish that, save
member.php
3. Open
newthread.php, and find the following:
PHP Code:
eval("dooutput(\"".gettemplate("newthread")."\");");
Replace it with this code:
PHP Code:
$threadengine = $DB_site->query_first("SELECT enablewysiwyg FROM user WHERE userid='$bbuserinfo[userid]'");
if($threadengine[enablewysiwyg]){ eval("dooutput(\"".gettemplate("newthread_wysiwyg")."\");");
} else { eval("dooutput(\"".gettemplate("newthread")."\");"); }
4. Open
newreply.php, and find the following:
PHP Code:
eval("dooutput(\"".gettemplate("newreply")."\");");
Replace it with this code:
PHP Code:
$replyengine = $DB_site->query_first("SELECT enablewysiwyg FROM user WHERE userid='$bbuserinfo[userid]'");
if($replyengine[enablewysiwyg] == 1) { eval("dooutput(\"".gettemplate("newreply_wysiwyg")."\");");
} else { eval("dooutput(\"".gettemplate("newreply")."\");"); }
5. The same thing still needs to be done with the
private.php and
editpost.php, only problem is that their templates have not yet been implemented with the WYSIWYG system, so we will have to wait awhile...
6. Go into your
admin/functions.php, find the following:
PHP Code:
global $vbcodemode,$vbcode_smilies;
Replace it with:
PHP Code:
global $DB_site,$vbcodemode,$vbcode_smilies;
Now find:
PHP Code:
eval ("\$vbcode_buttons = \"".gettemplate("vbcode_buttons")."\";");
Place above it on a new line the following:
PHP Code:
$vbcodetype = $DB_site->query_first("SELECT enablewysiwyg FROM user WHERE userid='$bbuserinfo[userid]'");
if($vbcodetype[enablewysiwyg]) { $vbcodetype = "vbcode2.js"; } else { $vbcodetype = "vbcode.js"; }
7.. Now to create new templates! In your
Admin Cp, create the following template with its content:
newreply_wysiwyg:
newreply.txt that was provided in the hack zip needs to be in this template.
newthread_wysiwyg:
newthread.txt that was provided in the hack zip needs to be in this template.
8. Now you need to revert the templates, or change back to what you originally had,
newthread and
newreply.
9. Now to modify a couple templates, and then we're finished. In
vbcode_buttons find the following:
Code:
<script language="Javascript" src="vbcode.js"></script>
Replace it with:
Code:
<script language="Javascript" src="$vbcodetype"></script>
10. In the template
modifyoptions, find the following:
Code:
<input type="radio" name="pmpopup" $pmpopupnotchecked value="no"> no
</normalfont></td>
</tr>
<!-- *** -->
And just below it place:
Code:
<tr>
<td bgcolor="#1D6AA0" colspan="2"><normalfont color="#EEEEFF"><b>New Thread, Reply & Personal Messaging Engine</b></normalfont></td>
</tr>
<tr>
<td bgcolor="#1C5780"><normalfont><b>Use the WYSIWYG enhanced HTML engine? *IS IN BETA*</b></normalfont><br>
<smallfont>Selecting yes will enable the new WYSIWYG posting engine, which does not require the use of some VBcode tags and has a typing interface similar to that of Microsoft Word. <br><b><u>Note:</u> May be incompatible with some internet browsers.</b><br><b><u>Note2:</u> To use such VBcodes as the [img] tag, you must first initialize <i>enhanced mode</i> on the posting screen. Then simply type in the tags and close them as you would normally do.</b>
</smallfont></td>
<td bgcolor="#1C5780"><normalfont>
<input type="radio" name="enablewysiwyg" value="yes" $enablewysiwygchecked> yes
<input type="radio" name="enablewysiwyg" value="no" $enablewysiwygnotchecked> no
</normalfont></td>
</tr>
When the WYSIWYG is out of beta, meaning fixed of bugs, you should probably reomve the *IS IN BETA* from the chunk above.
--------------------------------------------------------------
Well thats it! If I missed anything or there are problems be sure to let me know, but I'm fairly sure I got everything down.
UPDATE:
To reduce the ues of extra queries, its always good to add the custom templates to the $templatesused = "" list.
1. In
newthread.php, find:
PHP Code:
$templatesused = "newpost_postpreview,
Replace it with this:
PHP Code:
$templatesused = "newpost_postpreview, newthread_wysiwyg,
2. In
newreply.php, find:
PHP Code:
$templatesused = "quotereply,
Replace it with this:
PHP Code:
$templatesused = "quotereply, newreply_wysiwyg,