function JB_delete_image_from_field_id($table_name, $primary_key_name, $primary_key_id, $field_id) { $sql = "SELECT `{$field_id}` FROM `{$table_name}` WHERE `{$primary_key_name}`='" . JB_escape_sql($primary_key_id) . "'"; $result = JB_mysql_query($sql) or die(mysql_error() . $sql); $row = mysql_fetch_array($result, MYSQL_ASSOC); if ($row[$field_id] != '') { JB_delete_image($row[$field_id]); } }
function display_form_section($mode, $section, $admin, $dont_break_container = false) { global $label; # HTML output for this function comes from JBDynamicFormMarkup Class # include/themes/default/JBDynamicFormMarkup.php # Any HTML customizations should be done there. # Please copy this class in to your custom theme directory, and # customize form there $DFM =& $this->get_DynamicFormMarkup(); $this->set_mode($mode); $cache_key = 'field_list_' . $section . '_' . $this->form_id . '_' . $_SESSION['LANG']; if (!($field_list = jb_cache_get($cache_key))) { $sql = "SELECT t2.field_label AS FLABEL, t1.*, t1.field_id AS ID, t2.field_comment AS FCOMMENT FROM form_fields AS t1, form_field_translations AS t2 WHERE t1.field_id=t2.field_id AND lang='" . JB_escape_sql($_SESSION['LANG']) . "' AND section='" . JB_escape_sql($section) . "' AND form_id='" . JB_escape_sql($this->form_id) . "' ORDER BY field_sort "; $result = JB_mysql_query($sql) or die(mysql_error()); $field_list = array(); while ($field_row = mysql_fetch_array($result, MYSQL_ASSOC)) { $field_list[] = $field_row; } jb_cache_add($cache_key, $field_list); } if (!$dont_break_container) { $DFM->open_container(); // put in a tag to start the element containing the form } if (!sizeof($field_list)) { } // There are no fields in this section to render... $i = 0; foreach ($field_list as $field_row) { $i++; if (method_exists($DFM, 'set_field_row')) { $DFM->set_field_row($field_row); } if ($DFM->get_mode() == 'EDIT' && $_REQUEST['field_id'] == $field_row['field_id']) { // edit the form via Admin, and the field is being edited $bg_selected = ' style="background-color: #FFFFCC;" '; } else { $bg_selected = ''; } // load init value... if ($this->data[$field_row['field_id']] == '') { $this->data[$field_row['field_id']] = $field_row['field_init']; } // For blocked fields, has the user chosen to remain annonymous? $is_restricted = JB_process_field_restrictions($this->data, $field_row, $DFM->get_mode(), $admin); JBPLUG_do_callback('pre_process_field', $this->data, $field_row); ######################## JBPLUG_do_callback('display_custom_2col_field', $field_row, $this->data, $admin, $DFM->get_mode()); // your plugin should set $field_row['field_type'] to 'PLUGIN' to signal that it printed something out if ($field_row['is_hidden'] == 'Y' && $DFM->get_mode() == 'view' && !$admin) { # Hidden Fields, do not appear on website (view mode) } elseif ($field_row['field_type'] == 'PLUGIN') { // do nothing, already printed by plugin } elseif ($field_row['field_type'] == 'SEPERATOR') { $DFM->field_start(); $DFM->seperator_open($bg_selected); if ($DFM->get_mode() == 'EDIT') { JB_echo_order_arrows($field_row); echo '<a href="' . htmlentities($_SERVER['PHP_SELF']) . '?field_id=' . $field_row['field_id'] . '&mode=EDIT"><IMG SRC="../admin/edit.gif" WIDTH="16" HEIGHT="16" align="middle" BORDER="0" ALT="-"> '; } $DFM->seperator_display(); // display the label if ($DFM->get_mode() == 'EDIT') { echo '</a>'; } $DFM->seperator_close(); $DFM->field_end(); } elseif ($field_row['field_type'] == "SKILL_MATRIX") { $DFM->field_start($bg_selected); $DFM->skill_matrix_field_open($bg_selected); if ($DFM->get_mode() == 'EDIT') { JB_echo_order_arrows($field_row); echo '<a href="' . htmlentities($_SERVER['PHP_SELF']) . '?field_id=' . $field_row['field_id'] . '&mode=EDIT"><IMG SRC="../admin/edit.gif" WIDTH="16" HEIGHT="16" align="middle" BORDER="0" ALT="-"> '; } $DFM->skill_matrix_field_label(); if ($DFM->get_mode() == 'EDIT') { echo '</a>'; ?> <br> - <a href="" onclick="window.open('build_matrix.php?field_id=<?php echo $field_row['field_id']; ?> ', '', 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=1,width=550,height=500,left = 50,top = 50');return false;"> [Skill Matrix Settings...] </a> <?php } $DFM->skill_matrix_field_close(); $DFM->skill_matrix_value_open($bg_selected); if ($is_restricted) { echo $this->data[$field_row['field_id']]; } else { $DFM->skill_matrix_form(); } $DFM->skill_matrix_value_close(); $DFM->field_end(); } elseif ($field_row['field_type'] == 'YOUTUBE') { if ($DFM->get_mode() == 'view' && $this->data[$field_row['field_id']] == '') { // do not show the youtube field if it is blank continue; } $DFM->field_start(); $DFM->youtube_field_open($bg_selected); if ($DFM->get_mode() == 'EDIT') { JB_echo_order_arrows($field_row); echo '<a href="' . htmlentities($_SERVER['PHP_SELF']) . '?field_id=' . $field_row['field_id'] . '&mode=EDIT"><IMG SRC="../admin/edit.gif" WIDTH="16" HEIGHT="16" align="middle" BORDER="0" ALT="-">'; } $DFM->youtube_label(); if ($DFM->get_mode() == 'EDIT') { echo '</a>'; } if ($DFM->get_mode() == 'EDIT' && JB_is_reserved_template_tag($field_row['template_tag'])) { $alt = JB_get_reserved_tag_description($field_row['template_tag']); ?> <a href="" onclick="alert('<?php echo htmlentities($alt); ?> ');return false;"> <IMG SRC="../admin/reserved.gif" WIDTH="13" HEIGHT="13" BORDER="0" ALT="<?php echo $alt; ?> "> </a> <?php } if ($_REQUEST['del_video' . $field_row['field_id']] != '') { // delete video if (!$admin) { $user_sql = " AND user_id='" . JB_escape_sql($_SESSION['JB_ID']) . "' "; } else { $user_sql = " AND user_id='" . JB_escape_sql($this->data['user_id']) . "'"; } $where = ' 1=2 '; if (is_numeric($_REQUEST['resume_id'])) { $where = " `resume_id`='" . JB_escape_sql($_REQUEST['resume_id']) . "' "; } elseif (is_numeric($_REQUEST['post_id'])) { $where = " `post_id`='" . JB_escape_sql($_REQUEST['post_id']) . "' "; } elseif (is_numeric($_REQUEST['profile_id'])) { $where = " `profile_id`='" . JB_escape_sql($_REQUEST['profile_id']) . "' "; } elseif (is_numeric($_REQUEST['user_id'])) { $where = " `ID`='" . JB_escape_sql($_REQUEST['user_id']) . "' "; } $table_name = JB_get_table_name_by_id($this->form_id); $sql = "UPDATE `" . $table_name . "` SET `" . JB_escape_sql($field_row['field_id']) . "` = '' WHERE {$where} {$user_sql} "; JB_mysql_query($sql) or die(mysql_error()); $this->data[$field_row['field_id']] = ''; $_REQUEST[$field_row['field_id']] = ''; } if ($this->data[$field_row['field_id']] != '') { if ($is_restricted) { echo $this->data[$field_row['field_id']]; } else { // embed the field if ($field_row['field_width'] < 30) { $field_row['field_width'] = 325; } if ($field_row['field_height'] < 30) { $field_row['field_height'] = 250; } $DFM->youtube_display(); // embed youtube vid } } if (strtolower($DFM->get_mode()) == 'edit') { // display input fields for the form if (!$this->data[$field_row['field_id']]) { $DFM->youtube_field(); // input youtube url } else { $DFM->youtube_delete_button(); } } $DFM->youtube_field_close(); $DFM->field_end(); } elseif ($field_row['field_type'] == "IMAGE") { $DFM->field_start(); $DFM->image_field_open($bg_selected); if ($DFM->get_mode() == 'EDIT') { // admin's form editor JB_echo_order_arrows($field_row); echo '<a href="' . htmlentities($_SERVER['PHP_SELF']) . '?field_id=' . $field_row['field_id'] . '&mode=EDIT"><IMG SRC="../admin/edit.gif" WIDTH="16" HEIGHT="16" align="middle" BORDER="0" ALT="-">'; } if ($field_row['is_required'] == 'Y' && $DFM->get_mode() != 'view') { echo $DFM->get_required_mark(); } $DFM->image_label($field_row); if ($DFM->get_mode() == 'EDIT') { echo '</a>'; } if ($DFM->get_mode() == 'EDIT' && JB_is_reserved_template_tag($field_row['template_tag'])) { $alt = JB_get_reserved_tag_description($field_row['template_tag']); ?> <a href="" onclick="alert('<?php echo htmlentities($alt); ?> ');return false;"> <IMG SRC="../admin/reserved.gif" WIDTH="13" HEIGHT="13" BORDER="0" ALT="<?php echo $alt; ?> "> </a> <?php } if ($this->data[$field_row['field_id']] != '') { if ($is_restricted) { echo $this->data[$field_row['field_id']]; } else { // display the field if ($_REQUEST['del_image' . $field_row['field_id']] != '') { if ($admin || strpos($this->data[$field_row['field_id']], $_SESSION['JB_ID'] . '_') === 0) { // if Admin or the filename starts with the user's id JB_delete_image($this->data[$field_row['field_id']]); } } if (JB_image_thumb_file_exists($this->data[$field_row['field_id']])) { // display the image if (JB_KEEP_ORIGINAL_IMAGES == 'YES' && JB_image_original_file_exists($this->data[$field_row['field_id']])) { $DFM->image_linked_display(); } else { $DFM->image_thumb_display(); } } else { // no image (but value exists in the database!) $DFM->image_display_null(); } } } else { // no data uploaded $DFM->image_display_null(); } if (strtolower($DFM->get_mode()) == 'edit') { // display input fields for the form // delete image button if (JB_image_thumb_file_exists($this->data[$field_row['field_id']]) && $this->data[$field_row['field_id']] != '') { $DFM->image_delete_button(); } else { // upload image form $DFM->image_field(); } } $DFM->image_field_close(); $DFM->field_end(); } elseif ($field_row['field_type'] == 'FILE') { $DFM->field_start(); $DFM->file_field_open($bg_selected); if ($DFM->get_mode() == 'EDIT') { JB_echo_order_arrows($field_row); echo '<a href="' . htmlentities($_SERVER['PHP_SELF']) . '?field_id=' . $field_row['field_id'] . '&mode=EDIT"><IMG SRC="../admin/edit.gif" WIDTH="16" HEIGHT="16" align="middle" BORDER="0" ALT="-">'; } $DFM->file_label(); if ($DFM->get_mode() == 'EDIT') { echo '</a>'; } if ($field_row['is_required'] == 'Y' && $DFM->get_mode() != 'view') { echo $DFM->get_required_mark(); } if ($DFM->get_mode() == 'EDIT' && JB_is_reserved_template_tag($field_row['template_tag'])) { $alt = JB_get_reserved_tag_description($field_row['template_tag']); ?> <a href="" onclick="alert('<?php echo htmlentities($alt); ?> ');return false;"> <IMG SRC="../admin/reserved.gif" WIDTH="13" HEIGHT="13" BORDER="0" ALT="<?php echo $alt; ?> "> </a> <?php } if ($_REQUEST['del_file' . $field_row['field_id']] != '') { if ($admin || strpos($this->data[$field_row['field_id']], $_SESSION['JB_ID'] . '_') === 0) { // if admin or the filename starts with the user's id JB_delete_file($this->data[$field_row['field_id']]); } } if ($is_restricted) { echo $this->data[$field_row['field_id']]; } elseif (JB_upload_file_exists($this->data[$field_row['field_id']])) { $DFM->file_display_link(); } elseif ($DFM->get_mode() == 'view') { $DFM->file_not_uploaded(); } if (strtolower($DFM->get_mode()) == 'edit') { if (JB_upload_file_exists($this->data[$field_row['field_id']]) && $this->data[$field_row['field_id']] != '') { $DFM->file_delete_button(); } else { $DFM->file_field(); } } $DFM->file_field_close(); $DFM->field_end(); } elseif ($field_row['field_type'] == 'NOTE') { if ($DFM->get_mode() == 'view') { // note is only shown when edting the form } else { $DFM->field_start(); $DFM->note_open($bg_selected); if ($DFM->get_mode() == 'EDIT') { JB_echo_order_arrows($field_row); echo '<a href="' . htmlentities($_SERVER['PHP_SELF']) . '?field_id=' . $field_row['field_id'] . '&mode=EDIT"><IMG SRC="../admin/edit.gif" WIDTH="16" HEIGHT="16" align="middle" BORDER="0" ALT="-"> '; } $DFM->note_field(); if ($DFM->get_mode() == 'EDIT') { echo '</a>'; } if ($DFM->get_mode() == 'EDIT' && JB_is_reserved_template_tag($field_row['template_tag'])) { $alt = JB_get_reserved_tag_description($field_row['template_tag']); ?> <a href="" onclick="alert('<?php echo htmlentities($alt); ?> ');return false;"> <IMG SRC="../admin/reserved.gif" WIDTH="13" HEIGHT="13" BORDER="0" ALT="<?php echo $alt; ?> "> </a> <?php } $DFM->note_close(); $DFM->field_end(); } } elseif ($field_row['field_type'] == 'GMAP') { // Google map if ($DFM->get_mode() == 'view' && JB_GMAP_SHOW_IF_MAP_EMPTY != 'YES' && $this->data[$field_row['field_id'] . '_lat'] == 0) { continue; // do not show this field } require_once JB_basedirpath() . 'include/classes/JBGoogleMap.php'; $DFM->field_start(); $DFM->gmap_open($bg_selected); if ($DFM->get_mode() == 'EDIT') { JB_echo_order_arrows($field_row); echo '<a href="' . htmlentities($_SERVER['PHP_SELF']) . '?field_id=' . $field_row['field_id'] . '&mode=EDIT"><IMG SRC="../admin/edit.gif" WIDTH="16" HEIGHT="16" align="middle" BORDER="0" ALT="-">'; } if ($field_row['is_required'] == 'Y' && $DFM->get_mode() != 'view') { echo $DFM->get_required_mark(); } $DFM->gmap_field_label(); if ($DFM->get_mode() == 'EDIT') { echo '</a>'; } if ($DFM->get_mode() == 'view') { if ($is_restricted) { echo $this->data[$field_row['field_id']]; } else { $DFM->gmap_show(); } } else { $DFM->gmap_mark(); } $DFM->gmap_close(); $DFM->field_end(); } else { // Fields below are made from two sides // Left side: field_left_open() // - The left side is used to display the field's label // // Right side: field_right_open() // - The right side is where the form widget is displayed when // editing the form, or where the data value is displayed // close with field_right_clode() if ($field_row['FLABEL'] == '') { // field label is blank? $field_row['FLABEL'] = $DFM->get_blank_field_label(); } $DFM->field_start(); $DFM->field_left_open($bg_selected); if ($DFM->get_mode() == 'EDIT') { JB_echo_order_arrows($field_row); echo '<a href="' . htmlentities($_SERVER['PHP_SELF']) . '?field_id=' . $field_row['field_id'] . '&mode=EDIT"><IMG SRC="../admin/edit.gif" WIDTH="16" HEIGHT="16" align="middle" BORDER="0" ALT="-">'; } $DFM->field_label(); if ($DFM->get_mode() == 'EDIT') { echo '</a>'; } if ($field_row['is_required'] == 'Y' && $DFM->get_mode() != 'view') { echo $DFM->get_required_mark(); } if ($DFM->get_mode() == 'EDIT' && JB_is_reserved_template_tag($field_row['template_tag'])) { $alt = JB_get_reserved_tag_description($field_row['template_tag']); ?> <a href="" onclick="alert('<?php echo htmlentities($alt); ?> ');return false;"> <IMG SRC="../admin/reserved.gif" WIDTH="13" HEIGHT="13" BORDER="0" ALT="<?php echo $alt; ?> "> </a> <?php } if ($DFM->get_mode() == 'EDIT' && $field_row['field_type'] == 'BLANK') { echo '<a href="' . htmlentities($_SERVER['PHP_SELF']) . '?field_id=' . $field_row['field_id'] . '&mode=EDIT">[]</a>'; } $DFM->field_left_close(); $DFM->field_right_open($bg_selected); if ($is_restricted) { echo $this->data[$field_row['field_id']]; // display blocked field message } else { switch ($field_row['field_type']) { case 'URL': $val = $this->get_template_value($field_row['template_tag'], $admin); if ($DFM->get_mode() == 'view') { echo $DFM->get_url_templated($val); } else { $DFM->text_field(); } break; case "TEXT": case "URL": case "CURRENCY": case "NUMERIC": case "INTEGER": if ($DFM->get_mode() == 'view') { // $this->get_template_value() will get and process the data value // for example, if CURRENCY, then it format in to a currency $val = $this->get_template_value($field_row['template_tag'], $admin); $val = JB_email_at_replace($val); $DFM->_print($val); } else { $DFM->text_field(); } break; case 'EDITOR': if ($DFM->get_mode() == 'view') { $val = $this->get_template_value($field_row['template_tag'], $admin); if (!preg_match("/<.*?>/U", $val)) { // Not text mode? $val = preg_replace('/\\n/', '<br>', $val); } if (JB_EMAIL_AT_REPLACE != 'NO') { // eliminate tags with mailto: $val = preg_replace('@<a href=["|\']mailto:.*["|\'] *>(.*)</a>@Ui', '$1', $val); $val = JB_email_at_replace($val); } # $DFM->_print($val); } else { $DFM->editor_field(); } break; case "TEXTAREA": if ($DFM->get_mode() == 'view') { $val = $this->get_template_value($field_row['template_tag'], $admin); $val = str_replace("\n", "<br>", $val); $val = JB_email_at_replace($val); echo $DFM->_print($val); } else { $DFM->textarea_field(); } break; case "CATEGORY": if ($DFM->get_mode() == 'view') { if ($this->form_id != 1 || strpos($_SERVER['PHP_SELF'], 'index.php') === false) { // not posting form, not index.php, assuming index.php is the home page. Only the home page has functionality for displaying the category after the links are clicked // not linked to the category $DFM->_print($this->get_template_value($field_row['template_tag'], $admin)); } elseif (JB_CAT_PATH_ONLY_LEAF == 'YES') { // with link $cat = array(); $cat = JB_get_category($this->data[$field_row['field_id']]); $cat_url = JB_cat_url_write($this->data[$field_row['field_id']], $cat['NAME'], $cat['seo_fname']); $DFM->category_link($cat_url, $cat['NAME']); } else { // Multiple links - // Output the category using breadcrumb navigation // eg. Location -> Australia -> NSW $DFM->category_breadcrumbs(); } } else { $DFM->category_field(); } break; case "DATE": case "DATE_CAL": if ($DFM->get_mode() == 'view') { $val = $this->get_template_value($field_row['template_tag'], $admin); $DFM->_print($val); } else { if ($field_row['field_type'] == 'DATE') { // traditional date input if ($this->data[$field_row['field_id']] == '0000-00-00 00:00:00' || $this->data[$field_row['field_id']] == '') { $year = ''; $day = ''; $month = ''; } else { preg_match("/(\\d+)-(\\d+)-(\\d+)/", $this->data[$field_row['field_id']], $m); // Year - Month - Day (database output format) $year = $m[1]; $day = $m[3]; $month = $m[2]; } $DFM->date_field($day, $month, $year); } else { // scw input $DFM->date_field_scw(); } } break; case "SELECT": if ($DFM->get_mode() == 'view') { $val = $this->get_template_value($field_row['template_tag'], $admin); $DFM->_print($val); } else { $DFM->select_field(); } if ($DFM->get_mode() == 'EDIT') { ?> <a href="" onclick="window.open('maintain_codes.php?field_id=<?php echo $field_row['field_id']; ?> ', '', 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=1,width=400,height=500,left = 50,top = 50');return false;"> [Edit Options]</a> <?php } break; case "RADIO": if ($DFM->get_mode() == 'view') { $val = $this->get_template_value($field_row['template_tag'], $admin); $DFM->_print($val); } else { $DFM->radio_field(); } if ($DFM->get_mode() == 'EDIT') { ?> <a href="" onclick="window.open('maintain_codes.php?field_id=<?php echo $field_row['field_id']; ?> ', '', 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=1,width=400,height=500,left = 50,top = 50');return false;"> [Edit Options]</a> <?php } break; case "CHECK": if ($DFM->get_mode() == 'view') { $val = $this->get_template_value($field_row['template_tag'], $admin); $DFM->_print($val); } else { $DFM->checkbox_field(); } if ($DFM->get_mode() == 'EDIT') { ?> <a href="" onclick="window.open('maintain_codes.php?field_id=<?php echo $field_row['field_id']; ?> ', '', 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=1,width=400,height=500,left = 50,top = 50');return false;"> [Edit Options]</a> <?php } break; case "MSELECT": if ($DFM->get_mode() == 'view') { $val = $this->get_template_value($field_row['template_tag'], $admin); $DFM->_print($val); } else { $DFM->multiple_select_field(); } if ($DFM->get_mode() == 'EDIT') { ?> <a href="" onclick="window.open('maintain_codes.php?field_id=<?php echo $field_row['field_id']; ?> ', '', 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=1,width=400,height=500,left = 50,top = 50');return false;"> [Edit Options] </a> <?php } break; case "BLANK": $DFM->blank_field(); break; default: JBPLUG_do_callback('display_custom_field', $field_row, $this->data, $admin, $DFM->get_mode()); // Your module should change $field_row['field_type'] to 'PLUGIN' break; } } $DFM->field_right_close(); $DFM->field_end(); } } if (!$dont_break_container) { $DFM->close_container(); } }