/**
  * Add a filter on fields. All fields can be used native of custom.
  * You must pass an array of array. Any element of the ancestor array
  * is an array:
  * 		for native fields this is
  * 			- 'value' => the value of the field
  * 			- 'fieldname' => the name of the field
  * 			- 'field_type' = the type of the field
  * 		for custom fields
  * 			- 'value' => the value of the field
  * 			- FIELD_INFO_ID => the id of the custom field
  * 			- FIELD_INFO_TYPE => the type of the custom field
  * @param array $arr_filter the array of fields to filter (see above)
  */
 function addFieldFilters($arr_filter, $strict = FALSE)
 {
     if ($this->lms_editions_filter === true) {
         // filter for the editions selected =====================================
         $fvalue = isset($_POST[$this->id]['edition_filter']) ? (int) $_POST[$this->id]['edition_filter'] : '';
         if ($fvalue != false) {
             $acl_man =& Docebo::user()->getAclManager();
             $members = $acl_man->getGroupAllUser($fvalue);
             if ($members && !empty($members)) {
                 $this->data->addCustomFilter('', "idst IN (" . implode(',', $members) . ") ");
             }
         }
     }
     if ($this->show_simple_filter === true) {
         // filter for userid firstname e lastname , fulltext search ====================
         $fvalue = isset($_POST[$this->id]['simple_fulltext_search']) ? strip_tags(html_entity_decode($_POST[$this->id]['simple_fulltext_search'])) : '';
         if (trim($fvalue !== '')) {
             $this->data->addCustomFilter('', " ( userid LIKE '%" . $fvalue . "%' OR firstname LIKE '%" . $fvalue . "%' OR lastname LIKE '%" . $fvalue . "%' ) ");
         }
         return;
     }
     require_once $GLOBALS['where_framework'] . '/modules/field/class.field.php';
     $field = new Field(0);
     foreach ($arr_filter as $fname => $fvalue) {
         if (is_numeric($fname)) {
             $fname = "cfield_" . $fname;
         }
         if (isset($fvalue['value'])) {
             if (isset($fvalue['fieldname'])) {
                 if ($fvalue['field_type'] == 'upload') {
                     $this->data->addFieldFilter($fvalue['fieldname'], '', '<>');
                 } else {
                     if ($fvalue['value'] == '') {
                         $search_op = " = ";
                         $search_val = "";
                     } else {
                         if ($strict) {
                             $search_op = " LIKE ";
                             $search_val = "%" . $fvalue['value'] . "%";
                         } else {
                             $search_op = " = ";
                             $search_val = $fvalue['value'];
                         }
                     }
                     $this->data->addFieldFilter($fvalue['fieldname'], $search_val, $search_op);
                 }
             } else {
                 if ($fvalue[FIELD_INFO_TYPE] == 'upload') {
                     $this->data->addCustomFilter(" LEFT JOIN " . $field->_getUserEntryTable() . " AS " . $fname . " ON ( {$fname}.id_common = '" . (int) $fvalue[FIELD_INFO_ID] . "'" . " AND {$fname}.id_user = idst ) ", " ({$fname}.user_entry IS " . ($fvalue['value'] == 'true' ? 'NOT' : '') . " NULL ) ");
                 } else {
                     if ($fvalue['value'] == '') {
                         $where = " ({$fname}.user_entry = '' OR {$fname}.user_entry IS NULL )";
                     } else {
                         if ($strict) {
                             $where = " ({$fname}.user_entry = '" . $fvalue['value'] . "' ) ";
                         } else {
                             $where = " ({$fname}.user_entry LIKE '%" . $fvalue['value'] . "%' ) ";
                         }
                     }
                     $this->data->addCustomFilter(" LEFT JOIN " . $field->_getUserEntryTable() . " AS " . $fname . " ON ( {$fname}.id_common = '" . (int) $fvalue[FIELD_INFO_ID] . "'" . " AND {$fname}.id_user = idst ) ", $where);
                 }
             }
         }
     }
 }