• Holiday Schedule

    Your code gophers will be away for the next couple of weeks so support will be sporadic. We should be fully back online by the end of September.

  • A new version of Full Calendar is now available.

    See the details here

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