<div class="gmail_quote">On Thu, Jun 14, 2012 at 8:26 AM, Alan Lord <span dir="ltr">&lt;<a href="mailto:alanslists@gmail.com" target="_blank">alanslists@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Is there a &quot;proper&quot; way to override a core vtiger function?<br>...<br>
What do others do in this kind of situation?<br></blockquote><div><br></div><div>Strictly speaking, the &quot;proper&quot; way to override a function is to subclass the class and override it in the subclass.  I&#39;ve actually done something along these lines to the calendar with two surgical modifications to Calendar.php</div>
<div><br></div><div>- class Calendar</div><div>+abstract class VTCalendar</div><div><br></div><div>and at the bottom of the file</div><div><br></div><div>+require_once(&#39;modules/MyCalendar/MyCalendar.php&#39;);</div><div>
<br></div><div>which defines a class named Calendar that extends VTCalendar.  It&#39;s very easy to merge these two hunks, and I can now use all the standard OOP tricks to change behavior as I see fit.</div><div><br></div>
<div>Now, to your point specifically, the function you want to modify isn&#39;t on a class, so the trick I describe above won&#39;t work.  You could do something similar though</div><div><br></div><div><div>function getConvertQuoteToInvoice($focus,$quote_focus,$quoteid)</div>
<div>+{</div><div>+    // override behavior here</div><div>+   _getConvertQuoteToInvoice($focus,$quote_focus,$quoteid)</div><div>+    // more override behavior here</div><div>+}</div><div>+</div><div>+function _getConvertQuoteToInvoice($focus,$quote_focus,$quoteid)</div>
<div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>global $log,$current_user;</div></div><div><br></div><div>This will leave you with only one hunk that should merge easily.</div><div><br></div>
<div>And to chime in with Joe, at some point you have to decide whether the added flexibility of being able to do exactly what you want in the CRM is worth the overhead of merging and maintaining the code.</div></div>