• Payment Plugins Poll

    We need your feedback on the need for updated payment plugins. Please go here and give us your feedback.

  • Joomla 5.1

    For running J!5.1 you must install Fabrik 4.1
    See also Announcements

  • Subscription and download (Fabrik 4.1 for J!4.2+ and J!5.1) are working now

    See Announcement
    Please post subscription questions and issues here

    We have resolved the issue with the J! updater and this will be fixed in the next release.

Consent form plugin missing raw

lcollong

FabriKant d'applications web
Hi,

The form plugin "consent" generates a SQL error on form save because it get the rendered value of the juserid field rather than the raw value.

In the consent params plugin it asks to choose the column value which store the juser id in the main row (used together with the juser plugin) :
Capture.PNG



It's ok id the source column is a "pure" field element. But if this field is a user element (kind of dbjoin storing id but showing actuel user's name), the consent plugin does not get the id but the user name. Thus generating the sql error at insert time.

I did the following mod. But it should better offer to distinguish between raw and non raw value in the dropdown list choice. I guess. Meanwhile this trick does the job :


PHP:
    public function onAfterProcess()
    {
        $params    = $this->getParams();
        $formModel = $this->getModel();
        $data        = $this->getProcessData();
        $filter    = InputFilter::getInstance();
        $post      = $filter->clean($_POST, 'array');
        $contact   = array_key_exists('fabrik_contact_consent', $post);
        $rowid       = $post['rowid'];
        $user        = Factory::getUser();
        
        if($params->get('consent_juser', '0') === '1')
        {
            $userIdField = $this->getFieldName('consent_field_userid');
//            $userId      = $data[$userIdField];
// APCHEA : get raw value (integer). Otherwise got error message on SQL insert
            $userId      = $data[$userIdField . '_raw'];
        }


And also on delete time :


PHP:
    public function onDeleteRowsForm(&$groups)
    {   
        $params    = $this->getParams();
        $formModel = $this->getModel();
        $listModel = $formModel->getListModel();
        
        //// Records log of deletion of a user's consent
        foreach ($groups as $group)
        {
            foreach ($group as $rows)
            {
                foreach ($rows as $row)
                {
                    $userId = 0;
                    if($params->get('consent_juser', '0') === '1')
                    {
                        $userIdField = $this->getFieldName('consent_field_userid');               
// APCHEA : get raw value (integer). Otherwise got error message on SQL delete                       
                        $userIdField .= '_raw';
                        $userId      = $row->$userIdField;
                    }
                    $data['listid'] = $listModel->getId();
                    $data['formid'] = $formModel->getid();
                    $data['rowid']  = $row->id;
                    
                    $this->savePrivacy($data, $userId, 2);
                }
            }
         }
        
        return;
    }


Laurent
 

Members online

No members online now.
Back
Top