Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Building Forums With vBulletin (2006).pdf
Скачиваний:
40
Добавлен:
17.08.2013
Размер:
6.3 Mб
Скачать

Developing a Hack

Hack Distribution

So now you have a hack and you want to make it available to other people. The question is, how do you do this? The license agreement prevents you from distributing whole templates, and anyway, you're only making small changes to the template so it's silly to get people to replace code that is unchanged.

The best way to distribute hacks is in the form of clear instructions that others can easily follow. There are many ways to do this but the following is an example of one way that is clear and straightforward.

MODIFICATION – PM READ RECEIPT CHECKBOX Version 1.0.2

-----------------------------------------------------

Open TEMPLATE pm_newpm

Find and DELETE/COMMENT OUT:

else if (formname.dopreview != true)

{

<if condition="$show['trackpm']">

if (confirm("$vbphrase[request_receipt_for_message]"))

{

formname.receipt.value = 1;

}

</if>

}

Find and DELETE/COMMENT OUT:

<input type="hidden" name="receipt" value="0" />

Find:

<div>

<label for="cb_parseurl">

<input type="checkbox" name="parseurl" value="1" id="cb_parseurl" tabindex="1" $checked[parseurl] />

$vbphrase[automatically_parse_links_in_text] </label>

</div>

Below code ADD:

<div>

<label for="cb_receipt">

<input type="checkbox" name="receipt" id="cb_receipt" value="1" /> Request Read Receipt?

</label>

</div>

SAVE pm_newpm and CLOSE.

Test modification.

END OF MODIFICATION

-------------------

With this hack we needed only to modify templates, but there are times when you need to document edits to settings or even to actual PHP files. Settings changes can be documented by specifying the menu navigation and the final setting change.

172

Chapter 8

Admin CP

-> Usergroups -> Usergroup Manager -> Edit

Usergroup

Set

"Can

Use Message Tracking"

 

and

"Can

Deny Private Message Read Receipt Request"

to "No".

The PHP file modification that we saw in Chapter 4 can also be documented in this way:

PAYPAL MODIFICATION Version 1.0.2

---------------------------------

Open includes\functions_subscriptions.php

Find:

<input type=\"hidden\" name=\"no_shipping\" value=\"1\" />

Replace with:

<input type=\"hidden\" name=\"no_shipping\" value=\"0\" />

SAVE and UPLOAD

Test modification.

END OF MODIFICATION

-------------------

Tips for Hack Distribution

Here are a few tips that make code distribution easier for both you and the person following the instructions:

1.Test hacks thoroughly. If possible, try them out on a test installation of vBulletin before making changes to your active board.

2.Be specific as to which file or template requires modification.

3.Replace whole lines of code—don't mess about trying to explain which bit of the line needs changing.

4.Feel free to add comments to the code you include. This will make life easier for the person using the instructions—but will also bulk out your code.

5.Be clear as to what code you want the user to find and what they should then do with it (e.g. replace it with different code or add something above or below it). Be careful to check that the code you want the user to search for isn't duplicated elsewhere in the file. If this is the case, then be more specific and display more than one line of code.

6.Don't use line numbers—these can change with updates to the software. Also, any code changes (or other hacks) above the line will cause the line numbers to be wrong.

7.Make sure that you give the proper name for the template or PHP file you want editing. In the case of PHP files, include the path within the vBulletin installation.

8.Keep version numbers updated. If you make a small change to the code (to fix a typo say or make a small modification), then change the minor version number (say from 1.0.2 to 1.0.3). For big changes or alterations that allow the code to work for a new version of vBulletin, change the major version number (say from 1.0.4 to 2.0.0).

173