I'm currently writing a module that requires extending the ProjectObject class, and also creating a custom ActivityLog. So basically, I need something on the same level as the NewFileActivityLog class.
Now, there's no issue with creating either of the classes, but the problem comes with the save method of my new ProjectObject class. In ProjectObject.class.php, you have this:
if($this->log_creation) {
if (instance_of($this, 'File')) {
$activity_log = new NewFileActivityLog();
} else {
$activity_log = new ObjectCreatedActivityLog();
} // if
$activity_log->log($this, $this->getCreatedBy());
} // if
So it looks like you're hacking in the NewFileActivityLog class. It doesn't look like there's a way to implement a custom ActivityLog class without hacking the core, right? Unless I'm missing something.
Also note, that I must extend ProjectObject. I tried extending BaseProjectObject to bypass the parent::save() but then I get a bunch of type errors.
I'd like to be able to bundle this up as a normal module, instead of a module that requires to be hacked in and broken when upgraded.
Actually, I tore into the time tracking module, and I see it's extending the ActivityLog, but using the parent_id to associate the project it's with. That makes more sense.
I ended up getting it working with a lot of hacking, so I'll rewrite it to be a bit more clean.
If you wish to introduce new activity log type, there is no need to hack any core files - just extend ActivityLog class and make sure that type field in acx_activity_logs table has proper class name.
Instead of hacking save() method, you may consider listening to events (such is on_object_inserted for example).
Classes like Task, Ticket, Checklists etc all extend ProjectObject class. It's not something that requires any hacking - system is designed from the ground up to support such implementation.
Best advice I can give at the moment is not to hack any core file. If you get in situation where you think that is necessary, dig deeper or post a question here. There are limitations to what you can do without hacks, but you'll get less dependent code this way.
Hmm, I've been tearing into the time tracking module, and that seems more down the lines of what I'll need to do.
Thanks for the help. Any plans on releasing full source code documentation? At least in the area of module development. I'd like to know what objects I'm working with, all available methods and what they do. What properties they have, etc. It's a bit hard to dig through the source and pull together exactly what methods are available after all of the inheritance.
There are no exact plans for release of development documentation. It would take a huge amount of time to create such documentation and maintain it and we feel that, at the moment, our time can be better spent on development of the system itself and some other things we are working on.
Code is well documented so you can use tools like Doxygen or PHPDocumentor to extract it in readable format (HTML, PDF, CHM - there are multiple output formats).
Ahh, ok, I forgot completely about PHPDocumentor. Do you mind if I generate HTML output for PHPDocumentor and put a post on the forums to it on my server? Might help some people out who are looking for this kind of documentation.
If I can, is there something I should watch out for posting? Like the time tracking module or something for the people who don't have the corporate license.
Now, there's no issue with creating either of the classes, but the problem comes with the save method of my new ProjectObject class. In ProjectObject.class.php, you have this:
if($this->log_creation) { if (instance_of($this, 'File')) { $activity_log = new NewFileActivityLog(); } else { $activity_log = new ObjectCreatedActivityLog(); } // if $activity_log->log($this, $this->getCreatedBy()); } // ifSo it looks like you're hacking in the NewFileActivityLog class. It doesn't look like there's a way to implement a custom ActivityLog class without hacking the core, right? Unless I'm missing something.Also note, that I must extend ProjectObject. I tried extending BaseProjectObject to bypass the parent::save() but then I get a bunch of type errors.
I'd like to be able to bundle this up as a normal module, instead of a module that requires to be hacked in and broken when upgraded.
Thanks!