function JB_save_skill_matrix_data($field_id, $object_id, $user_id) { if ($object_id == '') { return false; } $row_count = JB_get_matrix_row_count($field_id); $sql = "DELETE FROM skill_matrix_data WHERE field_id='" . jb_escape_sql($field_id) . "' AND `object_id`='" . jb_escape_sql($object_id) . "' AND user_id='" . jb_escape_sql($user_id) . "' "; JB_mysql_query($sql) or die($sql . mysql_error()); for ($i = 0; $i < $row_count; $i++) { // field id=110, row=0, user_id /* primary key is: field_id row user_id */ $sql = "REPLACE INTO skill_matrix_data (field_id, row, name, years, rating, object_id, user_id) values({$field_id}, {$i}, '" . JB_clean_str($_REQUEST[$field_id . "name" . $i]) . "', '" . jb_escape_sql($_REQUEST[$field_id . "years" . $i]) . "', '" . jb_escape_sql($_REQUEST[$field_id . "rating" . $i]) . "', '" . jb_escape_sql($object_id) . "', '" . jb_escape_sql($user_id) . "') "; if (trim($_REQUEST[$field_id . "name" . $i]) != '') { JB_mysql_query($sql) or die("[skill matrix]" . $sql . mysql_error()); } } }
function init_data_from_request(&$data) { // Init the static fields $fields =& JB_schema_get_static_fields($this->form_id, JB_DB_MAP); foreach ($fields as $field_id => $field) { if (!isset($data[$field_id]) && isset($_REQUEST[$field_id])) { switch ($field['field_type']) { case 'PASS': // password fields have a 'confirm' password field $data[$field_id] = $_REQUEST[$field_id]; $data[$field_id . '2'] = $_REQUEST[$field_id . '2']; break; case 'ID': $data[$field_id] = (int) $_REQUEST[$field_id]; break; default: $data[$field_id] = stripslashes($_REQUEST[$field_id]); break; } } } // init the dynamic fields foreach ($this->tag_to_field_id as $field) { switch ($field['field_type']) { case 'SEPERATOR': case 'BLANK': case 'NOTE': // do nothing for these break; case 'DATE': // Date field always comes out of the DB as Y-m-d $day = jb_alpha_numeric($_REQUEST[$field['field_id'] . "d"]); $month = jb_alpha_numeric($_REQUEST[$field['field_id'] . "m"]); $year = jb_alpha_numeric($_REQUEST[$field['field_id'] . "y"]); $data[$field['field_id']] = "{$year}-{$month}-{$day}"; break; case 'DATE_CAL': // SCW calendar field $data[$field['field_id']] = JB_SCWDate_to_ISODate($_REQUEST[$field['field_id']]); break; case 'MSELECT': case 'CHECK': // multiple select and checkboxes - these fields come in // as an array, need to be comma delimited if (is_array($_REQUEST[$field['field_id']])) { $data[$field['field_id']] = implode(",", $_REQUEST[$field['field_id']]); } else { $data[$field['field_id']] = $_REQUEST[$field['field_id']]; } break; case 'GMAP': $data[$field['field_id'] . '_lat'] = $_REQUEST[$field['field_id'] . '_lat']; $data[$field['field_id'] . '_lng'] = $_REQUEST[$field['field_id'] . '_lng']; break; case 'SKILL_MATRIX': $row_count = JB_get_matrix_row_count($field_row['field_id']); for ($i = 0; $i < $row_count; $i++) { $data[$field['field_id'] . "name" . $i] = stripslashes($_REQUEST[$field['field_id'] . "name" . $i]); $data[$field['field_id'] . "years" . $i] = jb_alpha_numeric($_REQUEST[$field['field_id'] . "years" . $i]); $data[$field['field_id'] . "rating" . $i] = jb_alpha_numeric($_REQUEST[$field['field_id'] . "rating" . $i]); } break; case 'TEXT': case 'TEXTAREA': case 'EDITOR': $data[$field['field_id']] = stripslashes($_REQUEST[$field['field_id']]); break; default: $val = false; JBPLUG_do_callback('init_data_from_request', $val, $field, $this->form_id); if ($val !== false) { $data[$field['field_id']] = $val; break; } elseif (isset($_REQUEST[$field['field_id']])) { $data[$field['field_id']] = stripslashes($_REQUEST[$field['field_id']]); } break; } } }