xoops forums

redheadedrod

Home away from home
Posted on: 2010/8/1 3:30
redheadedrod
redheadedrod (Show more)
Home away from home
Posts: 1296
Since: 2008/2/26
#1

Question about how the PM module works to override PMlite in core

I am relatively new to PHP at this point but I am curious how it works that in the core without any modules added you are able to send some basic Private Messages. Then when you install the PM module the core Private Message stuff is bypassed and the PM module is used instead. I am curious how this works and if the same mechanism can be used to "overload" other functions of the core with a module such as a tab in the admin menu as an example.

I think if I understand how the PM module replaces the core "Pmlite" then it will help me along with a project I am looking at.

Thanks!

Catzwolf

Home away from home
Posted on: 2010/8/1 10:46
Catzwolf
Catzwolf (Show more)
Home away from home
Posts: 1392
Since: 2007/9/30
#2

Re: Question about how the PM module works to override PMlite in core

The pmlite (which should have been taken out when the PM module was created) is 'overloaded' with the new preloader system. Look in the PM module Preloader and that should give a good understanding of how this is done.

I also think that there is a smarty plugin somewhere, I might be wrong.

redheadedrod

Home away from home
Posted on: 2010/8/1 12:57
redheadedrod
redheadedrod (Show more)
Home away from home
Posts: 1296
Since: 2008/2/26
#3

Re: Question about how the PM module works to override PMlite in core

Is that found in the pmlite.php file of both the core and pm module?

Also I assume that this same method will work with other core functions that I would like to replace with a more extensive version?

I am looking to add things to one of the admin tabs and don't want to hack the core to do it but this method looks like a simpler way to tie into it.

Rodney

Catzwolf

Home away from home
Posted on: 2010/8/1 13:14
Catzwolf
Catzwolf (Show more)
Home away from home
Posts: 1392
Since: 2007/9/30
#4

Re: Question about how the PM module works to override PMlite in core

The preloader folder will be found in the pm module folder.

I'm not quite sure that you will be able to do it from the way you are suggesting, but it is worth a try.

You should however be able to add another tab quite easy by adding one by editing the '/module/pm/admin/menu.php' file:

and

$adminmenu = array();
$adminmenu[1]['title'] = _PM_MI_INDEX;
$adminmenu[1]['link'] = "admin/admin.php";
$adminmenu[2]['title'] = _PM_MI_PRUNE;
$adminmenu[2]['link'] = "admin/prune.php";
$adminmenu[3]['title'] = 'Newtabconstant;
$adminmenu[3]['link'] = "newtabfile.php";

Easypeasy huh

trabis

Core Developer
Posted on: 2010/8/1 13:32
trabis
trabis (Show more)
Core Developer
Posts: 2268
Since: 2006/9/1 1
#5

Re: Question about how the PM module works to override PMlite in core

There are some hooks(event triggers) availabe in Xoops files being one of them in pmlite.php if I'm not mistaken. Modules that listen to those events must follow some folder, file and class name conventions. You can start by looking into preloads folder in modules such as PM, Profile, Protector, XLanguage, Defacer. When this Xoops hooks are met during script execution, the listening methods are executed. Methods can issue redirects(as in PM module) or perform any other logic, they can also manipulate any entities that are passed as arguments by the hook. There are limited hooks in XOOPS core, there is no hook available for extending admin menus. The hooks are mainly placed in system front controllers(pmlite.php, register.php, user.php),and in bootstrap files such as common.php, header.php, and footer.php.

If you need to hack xoops core, instead of placing all your logic in the file you need to hack, you could just add a hook there, then you can build a preload to reply to that hook. It will keep upgrades easier for you. You can then propose that hook to the core team.

redheadedrod

Home away from home
Posted on: 2010/8/2 1:54
redheadedrod
redheadedrod (Show more)
Home away from home
Posts: 1296
Since: 2008/2/26
#6

Re: Question about how the PM module works to override PMlite in core

Thanks Trabis, I was hoping to keep away from hacking the core but for what I want to do at this point I don't see any other option.
Attending College working towards Bachelors in Software Engineering and Network Security.