avatar Chris B. @ SilenceIT Sep 1. 2010. 4:43 pm
I've been banging my head against the desk trying to figure out how and when this occurs. We love the fact that milestone copies can now have their subitems copied as well, but we don't want the time to be included!
What I really don't understand is even though there seems to be this nice hierarchy followed to copy every object... task and time objects are not instantiated during this string of events, yet get copied.
I'm stumped.
I've tried doing something as simple as adding echo statements to copy() (ProjectObject class) and to on_object_inserted (oops.. that was for checklists, but it gets every event regardless, doesn't it?), and all I get for output looks like this:

---copy new Milestone---
inserted: Milestone
inserted: Subscription
---copy new Checklist---
inserted: Checklist
---copy new Discussion---
inserted: Discussion
inserted: Subscription
---copy new File---
inserted: File
inserted: Subscription
---copy new Ticket---
inserted: Ticket
inserted: Subscription
inserted: Subscription
inserted: Subscription
inserted: Subscription
---copy new Ticket---
inserted: Ticket
inserted: Subscription

.. in other words, no tasks, no time, so ... how do I stop time from being copied?
avatar Ilija Studen Staff Sep 1. 2010. 4:55 pm
Hello,

activeCollab cascades copy for subitems - tasks, comments etc. Check on_project_object_copied even handler of resources module to see where subitems are being copied.
avatar Chris B. @ SilenceIT Sep 2. 2010. 8:43 am
Ilija Studen,

Thanks for the answer. I was able to find where it happens, but I don't understand why items are copied using the ProjectObject's copy function whereas subitems are copied via direct database manipulation. Is this for compatibility with third-party modules..?

Anyway, for anyone else looking for this solution, this is what I did: In
activecollab/application/modules/resources/handlers/on_project_object_copied.php

I found:
foreach($rows as $row) {

and right after that line added:
if (strtolower($row['type']) == 'timerecord') continue;

which did the trick.

- Chris