vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Right way to install custom PHP code in the core vB PHP files (https://vborg.vbsupport.ru/showthread.php?t=299571)

QSTR 06-27-2013 10:12 PM

Right way to install custom PHP code in the core vB PHP files
 
Hello everyone,

I've made a 'plugin' for my community (couple custom PHP files, some templates and tables)
All is working great BUT.

In order to use this plugin I need to add piece of code to the 'newthread.php' file, in this place (VB 4.1.12 PL3:
Code:

271        else
272        {
                      // something to do here
292
293                // ### NOT PREVIEW - ACTUAL POST ###
294                $threadinfo = fetch_threadinfo($newpost['threadid']); // need the forumread variable from this

I've made it via VIM but I think this is not right way to do it (if I use diagnostics, vB says this file is not OK ;))
So, is there any easy way to install this code exactly in this place via some feature in Admin Panel?

Or if there is no 'easy and nice way' to do this, tell me please if will it be any problem for vB when I leave this code there. (during installation/deinstallation of products? [i know about vB upgrades, when I need to fe. update the newthread.php file])

Thank you.
/sorry for my english/

kh99 06-27-2013 10:27 PM

If you can't figure out a way to do it using the existing hook locations, then you have no choice but to change the files. There isn't any way to do it from the admincp, so what you have done is ok. Vbulletin will tell you the file has been changed because that's what the feature does - it tells you if any files have been changed from the original. It won't cause any problems other than being reported as changed.

QSTR 06-27-2013 10:31 PM

Okey, I got this.
I rly do not care about diagnostics - just checked it for fun.

I'm very happy there will be no problems - this is important for me.

Thanks for the fast answer.
Maybe sometime I'll study the hook engine, for now I will stay with my old-school 'hand made' style.

Best regards from Poland
Case closed.

kh99 06-27-2013 10:36 PM

Well, I thought maybe you had already looked for hook locations. It turns out there's one a couple lines after the "something to do here", so if it's not important to do it before those two lines, you might be able to use a plugin. In case you want to try, it would be hook location newthread_post_complete.

QSTR 06-27-2013 10:44 PM

Don't know what to say, but I moved this piece of code from 'newthread.php' to the new plugin with location newthread_post_complete and it's working.
So good software.
Your hint was very helpful for me.

Funny, because as you said the code:
Code:

($hook = vBulletinHook::fetch_hook('newthread_post_complete')) ? eval($hook) : false;
...is just below.

Very nice, 'newthread.php' restored and all is great.
Found the right way ;)

Thank you very much.

--------------- Added [DATE]1372376961[/DATE] at [TIME]1372376961[/TIME] ---------------

/edit/
Didn't know this might be so easy.


All times are GMT. The time now is 07:08 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01172 seconds
  • Memory Usage 1,717KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete