• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

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
 
I think it must be _raw in any case, #__fabrik_privacy.user_id is int(6).

Added for the next release.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top