Actually, I love it because it extends the original file with other file rather than modifying it. Currently in 1.0 branch, we modify as follows:
<file name="SOURCEDIR/database/Db-mysql.class.php">
<operation>
<search position="replace"><![CDATA[
public static function initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options = array())
{
global $mysql_set_mode;
]]></search>
<add><![CDATA[
public static function initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options = array())
{
global $mysql_set_mode;
// include SubForums DB functions
include_once(ADMINDIR .'/SubForums/Subforums-DB.php');
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
public function replacement__callback($matches)
{
global $db_callback, $user_info, $db_prefix;
list ($values, $connection) = $db_callback;
// Connection gone??? This should *never* happen at this point, yet it does :'(
if (!is_object($connection))
display_db_error();
if ($matches[1] === 'db_prefix')
return $db_prefix;
if ($matches[1] === 'query_see_board')
return $user_info['query_see_board'];
if ($matches[1] === 'query_wanna_see_board')
return $user_info['query_wanna_see_board'];
]]></search>
<add><![CDATA[
public function replacement__callback($matches)
{
global $db_callback, $user_info, $db_prefix;
list ($query, $values, $connection) = $db_callback;
// subforums db_callback.
if(($subvar = SubForums_dbcallback($matches, $query)) !== null)
return $subvar;
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
// Only bother if there's something to replace.
if (strpos($db_string, '{') !== false)
{
// This is needed by the callback function.
$db_callback = array($db_values, $connection === null ? $this->_connection : $connection);
]]></search>
<add><![CDATA[
// Only bother if there's something to replace.
if (strpos($db_string, '{') !== false)
{
// This is needed by the callback function.
$db_callback = array($db_string, $db_values, $connection === null ? $this->_connection : $connection);
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false))
{
// Pass some values to the global space for use in the callback function.
$db_callback = array($db_values, $connection);
]]></search>
<add><![CDATA[
if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false))
{
// Pass some values to the global space for use in the callback function.
$db_callback = array($db_string, $db_values, $connection);
]]></add>
</operation>
</file>
<file name="SOURCEDIR/database/Db-postgresql.class.php">
<operation>
<search position="replace"><![CDATA[
public static function initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options = array())
{
]]></search>
<add><![CDATA[
public static function initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options = array())
{
include_once(ADMINDIR .'/SubForums/Subforums-DB.php');
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
public function replacement__callback($matches)
{
global $db_callback, $user_info, $db_prefix;
list ($values, $connection) = $db_callback;
// Connection gone?
if (!is_resource($connection))
display_db_error();
if ($matches[1] === 'db_prefix')
return $db_prefix;
if ($matches[1] === 'query_see_board')
return $user_info['query_see_board'];
if ($matches[1] === 'query_wanna_see_board')
return $user_info['query_wanna_see_board'];
]]></search>
<add><![CDATA[
public function replacement__callback($matches)
{
global $db_callback, $user_info, $db_prefix;
list ($query, $values, $connection) = $db_callback;
// call the subforums db_callback.
if(($subvar = SubForums_dbcallback($matches, $query)) !== null)
return $subvar;
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
// Only bother if there's something to replace.
if (strpos($db_string, '{') !== false)
{
// This is needed by the callback function.
$db_callback = array($db_values, $connection === null ? $this->_connection : $connection);
]]></search>
<add><![CDATA[
// Only bother if there's something to replace.
if (strpos($db_string, '{') !== false)
{
// This is needed by the callback function.
$db_callback = array($db_string, $db_values, $connection === null ? $this->_connection : $connection);
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false))
{
// Pass some values to the global space for use in the callback function.
$db_callback = array($db_values, $connection);
]]></search>
<add><![CDATA[
if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false))
{
// Pass some values to the global space for use in the callback function.
$db_callback = array($db_string, $db_values, $connection);
]]></add>
</operation>
</file>
I will test this first, soonest.
Questions:
1. Can most of core files be extended and overwritten like that?
2. Can I used that similar method instead of using manual modification (currently being used)?