[Vtigercrm-developers] Make main module class independant of related module functions.

Joe Bordes joe at tsolucio.com
Tue Feb 20 15:51:03 PST 2007


Hi all,

I am part of the Module Generator project on vtigerforge. I have been
assigned the task of designing the related functions from one module to
another. The idea is to be able to establish a relation between the new
module and the already existing modules in VTiger (the new module will
appear in the "More Information" tab).

As you may know this is done by inserting a row in the
vtiger_relatedlists table and inserting a new function into the main
class of the already existing related module that returns the related
elements, among other things that have to be done.

In the TSProjects module which I am (also) programming I have used a new
technique to make the main class (TSProject.php) independant of these
"related" functions.

Instead of adding functions to the main module's class I have created a
directory inside the modules "home":

modules/TSProjects/related

I have put in this directory one file per each related module with the
same name I establish in the vtiger_relatedlist table:

get_attachments.inc
get_prjtasks.inc
get_stakeholders.inc
...

Each of these files has a function of the same name which is the one
that we usually add to the main class.

I, obviously, eliminate these functions from the main module class and
add this piece of code:

-----------------------------------
  // Load related functions from included files in module/related
directory
  // TSolucio 2007-02-21
  function __call( $method, $args )
  {
    global $currentModule;
    $include_file="modules/$currentModule/related/$method.inc";
    if (file_exists($include_file)) {
        include $include_file;
        return $method($args[0]);
    }
  }
-----------------------------------

I can now add related modules simply adding a .inc file in the related
directory.

If we could get all modules to implement this feature we would get a
much more modular application, would simplify the module generator and
avoid coding errors as all the code is more modular and independant.

I (again) offer my time and knowledge to modify all the modules with
this change. For this I would like that somebody on the vtiger
development team get in touch with me (Richie?). I have been asking this
proactivly during various months now with no answer as the change I
propose here is not the only one I have proposed or asked about. I have
sent various emails through the web and others on this forum with no
answer. As Richie stated today in a forum answer, I understand that you
can't answer them all. But you haven't answered ANY of mine. Not even
the ones I sent through your web which are "commercial" questions.

Well, let's see what happens.

Regards, Joe
TSolucio




More information about the vtigercrm-developers mailing list