function JB_profile_tag_to_field_id_init() { global $label; global $profile_tag_to_field_id; if ($profile_tag_to_field_id = JB_cache_get('tag_to_field_id_3_' . $_SESSION['LANG'])) { return $profile_tag_to_field_id; } $fields = JB_schema_get_fields(3); // the template tag becomes the key foreach ($fields as $field) { $profile_tag_to_field_id[$field['template_tag']] = $field; } JBPLUG_do_callback('profile_tag_to_field_id_init', $profile_tag_to_field_id); JB_cache_set('tag_to_field_id_3_' . $_SESSION['LANG'], $profile_tag_to_field_id); return $profile_tag_to_field_id; }
function JB_resume_tag_to_field_id_init() { global $resume_tag_to_field_id; // deprecated since 3.6 if ($resume_tag_to_field_id = JB_cache_get('tag_to_field_id_2_' . $_SESSION['LANG'])) { return $resume_tag_to_field_id; } $fields = JB_schema_get_fields(2); // the template tag becomes the key foreach ($fields as $field) { $resume_tag_to_field_id[$field['template_tag']] = $field; } JBPLUG_do_callback('resume_tag_to_field_id_init', $resume_tag_to_field_id); JB_cache_set('tag_to_field_id_2_' . $_SESSION['LANG'], $resume_tag_to_field_id); return $resume_tag_to_field_id; }
function JB_tag_to_field_id_init_emp() { global $adv_tag_to_field_id; global $label; if ($adv_tag_to_field_id = JB_cache_get('tag_to_field_id_4_' . $_SESSION['LANG'])) { return $adv_tag_to_field_id; } $fields = JB_schema_get_fields(4); // the template tag becomes the key foreach ($fields as $field) { $adv_tag_to_field_id[$field['template_tag']] = $field; } JBPLUG_do_callback('tag_to_field_id_init_emp', $adv_tag_to_field_id); JB_cache_set('tag_to_field_id_4_' . $_SESSION['LANG'], $adv_tag_to_field_id); return $adv_tag_to_field_id; }
function JB_schema_alter_table($form_id) { $fields =& JB_schema_get_fields($form_id, JB_DB_MAP); // JB_DB_MAP will get the 1 to 1 mapping of the database table $columns = JB_schema_get_columns($form_id); // actual columns of the table $table_name = JB_get_table_name_by_id($form_id); /* * Rules: * If exists in both, do nothing * If exists in form but not table, add to table * if NOT exists form, but is in table, remove from table */ $change = ''; $sql_list = array(); foreach ($fields as $key => $val) { if ($change == '') { $sql = "ALTER TABLE `{$table_name}` "; } # If exists in both, do nothing if ($columns[$key] != '' && $fields[$key]['field_id'] != '') { // do nothing } # If exists in form but not table, add to table if ($columns[$key] == '' && $fields[$key]['field_id'] != '') { // ADD to table if ($i > 0) { $sql .= ", "; } jb_schema_add_field($table_name, $key, $fields[$key]['field_type'], $fields[$key]['field_label']); $change = 'Y'; $i++; } } $i = 0; ## foreach ($columns as $key => $val) { # If exists in both, do nothing if ($columns[$key] != '' && $fields[$key]['field_id'] != '') { // do nothing } # if NOT exists form, but is in table, ($columns = columns in table, $fields = fields in the form_fields table) /* the $key can be numeric, eg 92 or it can be alpha-numeric, eg 92_lat fields consisting of multiple columns such as the google map can have multiple columns for each field 92_lat, 92_lng and 92 (always prefixed with the field_id) Here we need to get the field_id from the column name */ $m = array(); $field_id = null; if (is_numeric($columns[$key]) || preg_match('#(\\d+)_#', $columns[$key], $m)) { if (isset($m[1])) { $field_id = $m[1]; } else { $field_id = $key; } if ($fields[$field_id]['field_id'] == '') { // REMOVE from table JB_schema_remove_field($table_name, $key); $change = 'Y'; $i++; } } } if ($change == 'Y') { //JBPLUG_do_callback('schema_alter_table', $sql, $columns, $fields, $form_id); //plugins can alter the sql //JB_mysql_query ($sql) or die (mysql_error().$sql); JB_cache_del_keys_for_form($form_id); //echo $sql; return true; } else { return false; } }
function JB_field_select_option_list($form_id, $selected, $prefix = '') { global $label; $col_row['field_id'] = $selected; $fields = JB_schema_get_fields($form_id); foreach ($fields as $field) { if ($field['field_type'] == 'BLANK' || $field['field_type'] == 'SEPERATOR' || $field['field_type'] == 'NOTE') { continue; } if ($field['field_id'] == $selected) { $sel = " selected "; } else { $sel = ""; } if ($field['field_type']) { $field_type = "(" . $field['field_type'] . ")"; } else { $field_type = ''; } if (strlen($field['field_label']) > 0) { echo "<option {$sel} value='" . $prefix . $field['field_id'] . "'>" . $prefix . JB_escape_html($field['field_label']) . " {$field_type}</option>\n"; } } }
function JB_tag_to_field_id_init_candidate() { global $label; global $candidate_tag_to_field_id; if ($candidate_tag_to_field_id = JB_cache_get('tag_to_field_id_5_' . $_SESSION['LANG'])) { return $candidate_tag_to_field_id; } $fields = JB_schema_get_fields(5); // the template tag becomes the key foreach ($fields as $field) { $candidate_tag_to_field_id[$field['template_tag']] = $field; } JBPLUG_do_callback('tag_to_field_id_init_can', $candidate_tag_to_field_id); JB_cache_add('tag_to_field_id_5_' . $_SESSION['LANG'], $candidate_tag_to_field_id); return $candidate_tag_to_field_id; }