PHP Email Template error after upgrade

aaronpie

New Member
A while back I found a php email template in the forums that only sent updated fields from a form which is very helpful in my case because I have clients updating their forms all the time. Now that I have upgraded my site to Joomla 2.5 and Fabrik 3 the template does not work and gives me the below error. Is there a way to fix this error?

Fatal error: Call to protected method FabrikFEModelForm::setOrigData() from context 'plgFabrik_FormEmail' in /home/public_html/plugins/fabrik_form/email/tmpl/old_new_showupdated.php on line 21

Line 21: $tableid = JRequest::getInt('tableid');

PHP:
<!-- This is a sample email template.
It will tell the user if the record is a new one or an updated one
It contains a link to the record in question
It shows in the table a list of the updated fields.
 -->

<?php
//the original data
$orig = JArrayHelper::fromObject($this->formModel->_origData[0]);
if (empty($orig)) {
    $action = 'toegevoegd';//new
} else {
    $action = 'aangepast';//existing
}
$formid = JRequest::getInt('fabrik');
$tableid = JRequest::getInt('tableid');
$rowid = JRequest::getInt('rowid');

//get the updated record from the database
$this->formModel->set('_origData', null);
$this->formModel->setOrigData();
$data = JArrayHelper::fromObject($this->formModel->_origData[0]);

$config =& JFactory::getConfig();
$live_site = $config->getValue('config.live_site');
$uri =& JURI::getInstance($live_site);
$url  =  'http://www.mysite.com'.$uri->getHost().JRoute::_("index.php?option=com_fabrik&view=form&fabrik=$formid&tableid=$tableid&rowid=$rowid");
?>
<p>Dear Administrator,</p>
<p>
There  is an updated record <?php echo $action ?> on the website <a  href="http://www.afpcomputers.com">http://www.afpcomputers.com</a>.
For the record view online click on the link below:

</p>
<a href="<?php echo $url?>"><?php echo $url?></a>
<p>(If you want to modify information from the record first make sure that you are logged onto the website.)</p>
<table>
<?php
foreach ($data as $key => $val) {
    if (substr($key, -4) == '_raw') {
        continue;
    }
    if(!array_key_exists($key, $orig) || $orig[$key] !== $val) {
      echo "<tr><td>$key</td><td>";
      if (is_array($val)) {
          foreach ($val as $v) {
              if (is_array($v)) {
                  echo implode("<br>", $v);
              } else {
                  echo implode("<br>", $val);
              }
          }
      } else {
          echo $val;
      }
      echo "</td></tr>";
    }
}
?>
</table>
 
The URL structure is different in Fabrik3, the from is called with
...option=com_fabrik&view=form&Itemid=165&formid=54&rowid=1&listid=48

So I assume (not tested) you have to modify at least
PHP:
$formid = JRequest::getInt('formid');
$listid = JRequest::getInt('listid');
$rowid = JRequest::getInt('rowid');
...
... 
JRoute::_("index.php?option=com_fabrik&view=form&formid=$formid&listid=$listid&rowid=$rowid");
 
Hi

Replace
Code:
[COLOR=#000000][COLOR=#0000BB]$this[/COLOR][COLOR=#007700]->[/COLOR][COLOR=#0000BB]formModel[/COLOR][COLOR=#007700]->[/COLOR][COLOR=#0000BB]setOrigData[/COLOR][COLOR=#007700]();
[/COLOR][COLOR=#0000BB]$data [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]JArrayHelper[/COLOR][COLOR=#007700]::[/COLOR][COLOR=#0000BB]fromObject[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$this[/COLOR][COLOR=#007700]->[/COLOR][COLOR=#0000BB]formModel[/COLOR][COLOR=#007700]->[/COLOR][COLOR=#0000BB]_origData[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000BB]0[/COLOR][COLOR=#007700]]);[/COLOR][/COLOR]

with:

Code:
$listModel = $this->formModel->getListModel();
$fabrikDb = $listModel->getDb();
$sql = $this->formModel->_buildQuery();
$fabrikDb->setQuery($sql);
$data = $fabrikDb->loadObjectList();
$data  = $data[0];
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top