function build_new_items_feed($URL, $datemask) { $rssout = ''; $last_items_list_conf_r = get_opendb_config_var('feeds.new_items'); $list_item_rs = get_last_num_items_rs($last_items_list_conf_r['total_num_items'], NULL, NULL, NULL, NULL, NULL, 'feeds'); if (is_not_empty_array($list_item_rs)) { reset($list_item_rs); while (list(, $list_item_r) = @each($list_item_rs)) { $rssout .= "\n\t<item>" . "\n\t\t<title>" . rss_encoded($list_item_r['title']) . "</title>" . "\n\t\t<link>" . rss_encoded($URL . $list_item_r['item_display_url']) . "</link>" . "\n\t\t<pubDate>" . $list_item_r['update_on'] . " " . date('T') . "</pubDate>" . "\n\t\t<guid>" . rss_encoded($URL . $list_item_r['item_display_url']) . "</guid>" . "\n\t\t<description>"; $results = fetch_item_attribute_type_rs($list_item_r['s_item_type'], 'rss_ind'); if ($results) { $attribute_block = ''; while ($item_attribute_type_r = db_fetch_assoc($results)) { if (has_role_permission($item_attribute_type_r['view_perm'])) { if (strlen($attribute_block) > 0) { $attribute_block .= "\n"; } $attributes_r = fetch_attribute_val_r($list_item_r['item_id'], $list_item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']); if (is_array($attributes_r)) { $attribute = ""; while (list(, $value) = each($attributes_r)) { if (strlen($attribute) > 0) { $attribute .= ", "; } $attribute .= rss_encoded($value); } $attribute_block .= $attribute; } } } //while db_free_result($results); $rssout .= $attribute_block; } $rssout .= "\n\t\t</description>" . "\n\t</item>"; } } return $rssout; }
function __getItemTypeAttribs($s_item_type) { if (!is_array($this->_item_type_structure_rs[$s_item_type])) { if (is_exists_item_type($s_item_type)) { $results = fetch_item_attribute_type_rs($s_item_type, NULL, 's_attribute_type'); if ($results) { while ($item_attribute_type_r = db_fetch_assoc($results)) { $this->_item_type_structure_rs[$s_item_type][] = $item_attribute_type_r; } db_free_result($results); } } else { return NULL; } } return $this->_item_type_structure_rs[$s_item_type]; }
/** * */ function copy_item_to_http_vars($old_item_r, $new_item_type) { $HTTP_VARS = array(); $results = fetch_item_attribute_type_rs($old_item_r['s_item_type'], 'not_instance_field_types'); if ($results) { $attr_order_no_r = array(); while ($item_attribute_type_r = db_fetch_assoc($results)) { if ($item_attribute_type_r['s_field_type'] == 'TITLE') { $order_no = fetch_s_item_attribute_type_next_order_no($new_item_type, $item_attribute_type_r['s_attribute_type']); $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $order_no); $HTTP_VARS[$fieldname] = $old_item_r['title']; } else { $last_order_no = NULL; if (is_numeric($attr_order_no_r[$item_attribute_type_r['s_attribute_type']])) { $last_order_no = $attr_order_no_r[$item_attribute_type_r['s_attribute_type']]; } $order_no = fetch_s_item_attribute_type_next_order_no($new_item_type, $item_attribute_type_r['s_attribute_type'], $last_order_no); if ($order_no !== FALSE) { $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $order_no); // update with latest order no $attr_order_no_r[$item_attribute_type_r['s_attribute_type']] = $order_no; if ($item_attribute_type_r['lookup_attribute_ind'] == 'Y' || $item_attribute_type_r['multi_attribute_ind'] == 'Y') { $attribute_val_r = fetch_attribute_val_r($old_item_r['item_id'], $old_item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']); if (is_not_empty_array($attribute_val_r)) { $HTTP_VARS[$fieldname] = $attribute_val_r; } } else { $attribute_val = fetch_attribute_val($old_item_r['item_id'], $old_item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']); if (strlen($attribute_val) > 0) { $HTTP_VARS[$fieldname] = $attribute_val; } } } } } db_free_result($results); } return $HTTP_VARS; }
function get_row_export_column_form(&$exportPlugin, $HTTP_VARS) { global $PHP_SELF; $buffer .= "\n<form method=\"POST\" action=\"{$PHP_SELF}\">"; $buffer .= "\n<input type=\"hidden\" name=\"op\" value=\"export\">"; $buffer .= "\n<input type=\"hidden\" name=\"owner_id\" value=\"" . $HTTP_VARS['owner_id'] . "\">"; $buffer .= "\n<input type=\"hidden\" name=\"s_item_type\" value=\"" . $HTTP_VARS['s_item_type'] . "\">"; $buffer .= "\n<input type=\"hidden\" name=\"plugin\" value=\"" . $HTTP_VARS['plugin'] . "\">"; $buffer .= "\n<ul class=\"checkboxGridOptionsVertical\">"; $buffer .= "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"export_columns[item_id]\" value=\"Y\">" . get_opendb_lang_var('item_id') . "</li>"; $buffer .= "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"export_columns[instance_no]\" value=\"Y\">" . get_opendb_lang_var('instance_no') . "</li>"; $buffer .= "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"export_columns[owner_id]\" value=\"Y\">" . get_opendb_lang_var('owner_id') . "</li>"; $buffer .= "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"export_columns[item_id]\" value=\"Y\"" . (strlen($HTTP_VARS['owner_id']) == 0 ? ' CHECKED' : '') . ">" . get_opendb_lang_var('item_id') . "</li>"; $buffer .= "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"export_columns[s_item_type]\" value=\"Y\">" . get_opendb_lang_var('s_item_type') . "</li>"; if (strlen($HTTP_VARS['s_item_type']) > 0) { $results = fetch_item_attribute_type_rs($HTTP_VARS['s_item_type']); if ($results) { while ($item_attribute_type_r = db_fetch_assoc($results)) { // Only legal s_field_type's - ignore ITEM_ID!!! if (strlen($item_attribute_type_r['s_field_type']) == 0 || $item_attribute_type_r['s_field_type'] == 'CATEGORY' || $item_attribute_type_r['s_field_type'] == 'TITLE' || $item_attribute_type_r['s_field_type'] == 'DURATION' || $item_attribute_type_r['s_field_type'] == 'STATUSTYPE' || $item_attribute_type_r['s_field_type'] == 'STATUSCMNT' || $item_attribute_type_r['s_field_type'] == 'IMAGE') { $buffer .= '<li><input type="checkbox" class="checkbox" name="export_columns[' . get_field_name($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']) . ']" value="Y"'; // work out what columns to have checked by default. if ($item_attribute_type_r['s_field_type'] == 'TITLE' || $item_attribute_type_r['s_field_type'] == 'IMAGE' || strlen($item_attribute_type_r['s_field_type']) == 0 && strcasecmp(ifempty($item_attribute_type_r['display_type'], $item_attribute_type_r['input_type']), "hidden") !== 0) { $buffer .= ' CHECKED'; } $buffer .= '>' . $item_attribute_type_r['prompt'] . "</li>"; } } db_free_result($results); } } else { $buffer .= "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"export_columns[title]\" value=\"Y\">" . get_opendb_lang_var('title') . "</li>"; } if (method_exists($exportPlugin, 'prompt_header') || method_exists($exportPlugin, 'data_header')) { $buffer .= "\n<li id=\"include-header\"><input type=\"checkbox\" class=\"checkbox\" name=\"include_header\" value=\"Y\" CHECKED>" . get_opendb_lang_var('include_header') . "</li>"; } $buffer .= "</ul>"; $buffer .= "\n<ul class=\"actionButtons\">"; $buffer .= "\n<li><input type=\"button\" class=\"button\" value=\"" . get_opendb_lang_var('check_all') . "\" onClick=\"setCheckboxes(this.form, 'export_columns', true);\"></li>" . "\n<li><input type=\"button\" class=\"button\" value=\"" . get_opendb_lang_var('uncheck_all') . "\" onClick=\"setCheckboxes(this.form, 'export_columns', false);\"></li>" . "\n<li><input type=\"reset\" class=\"reset\" value=\"" . get_opendb_lang_var('reset') . "\"></li>" . "\n<li class=\"submitButton\"><input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('export_items') . "\"></li>" . "</ul>"; $buffer .= '</form>'; return $buffer; }
/** * The $site_plugin_attributes_r will consist of array entries, each identified by a * alphakey. The value may in fact be another array and this has to be handled * appropriately. */ function get_expanded_and_mapped_site_plugin_item_variables_r($site_type, $s_item_type, $site_item_attributes_r) { $query = "SELECT variable, s_attribute_type, lookup_attribute_val_restrict_ind " . "FROM s_site_plugin_s_attribute_type_map " . "WHERE site_type = '" . $site_type . "' "; $query .= "AND (s_item_type = '*' OR s_item_type = '" . $s_item_type . "') AND "; $query .= "(s_item_type_group = '*' "; $item_type_group_arr = fetch_item_type_groups_for_item_type_r($s_item_type); if (is_array($item_type_group_arr)) { $query .= "OR s_item_type_group IN (" . format_sql_in_clause($item_type_group_arr) . ")) "; } else { $query .= ") "; } $query .= "ORDER BY variable, s_attribute_type"; $new_attributes_r = array(); // cache this, so we can check if lookup_attribute_val_restrict_ind = 'Y' $lookup_attribute_val_restrict_ind = array(); $mapped_attributes_r = array(); $results = db_query($query); if ($results && db_num_rows($results) > 0) { $variable = NULL; while ($attribute_type_map_r = db_fetch_assoc($results)) { $value = NULL; $variable = $attribute_type_map_r['variable']; if (isset($site_item_attributes_r[$variable])) { $value = $site_item_attributes_r[$variable]; // at least one direct mapping - title should not be flagged - as there is requirement for multiple mappings if ($variable != 'title') { $mapped_attributes_r[] = $variable; } } $key = strtolower($attribute_type_map_r['s_attribute_type']); if ($value !== NULL) { if (isset($new_attributes_r[$key])) { if (!is_array($new_attributes_r[$key])) { $new_attributes_r[$key] = array($new_attributes_r[$key]); } if (is_array($value)) { $new_attributes_r[$key] = array_merge($new_attributes_r[$key], $value); } else { $new_attributes_r[$key][] = $value; } } else { $new_attributes_r[$key] = $value; } } if ($attribute_type_map_r['lookup_attribute_val_restrict_ind'] == 'Y') { $lookup_attribute_val_restrict_ind_r[$key] = 'Y'; } } db_free_result($results); } // now for any variables that do not have a mapping, add them to the $new_attributes_r reset($site_item_attributes_r); while (list($key, $value) = @each($site_item_attributes_r)) { $key = strtolower($key); if (isset($new_attributes_r[$key])) { $oldValue = NULL; // we want the direct mapping attributes first. if (is_array($new_attributes_r[$key])) { $oldValue = $new_attributes_r[$key]; } else { $oldValue[] = $new_attributes_r[$key]; } unset($new_attributes_r[$key]); if (is_array($value)) { $new_attributes_r[$key] = $value; } else { $new_attributes_r[$key][] = $value; } while (list(, $value) = each($oldValue)) { if (!in_array($value, $new_attributes_r[$key])) { $new_attributes_r[$key][] = $value; } } } else { if (!in_array($key, $mapped_attributes_r)) { $new_attributes_r[$key] = $value; } } } $site_item_attributes_r = NULL; // now we need to check to see if any lookup mappings exist for each // of the attribute values, and update the $value's appropriately. reset($new_attributes_r); while (list($key, $value) = @each($new_attributes_r)) { // temporary UPPER so we can work with actual s_attribute_type records in database $s_attribute_type = strtoupper($key); if (is_lookup_attribute_type($s_attribute_type)) { $values_r = NULL; // if a lookup attribute type, we want to make sure that the $value's // are all arrays anyway, so lets do that check each time. if (is_array($value)) { $values_r = $value; } else { $values_r[] = $value; } $results = fetch_site_plugin_s_attribute_type_lookup_map_rs($site_type, $s_attribute_type); if ($results) { $found_entries_r = array(); $new_values_r = array(); while ($lookup_map_r = db_fetch_assoc($results)) { for ($i = 0; $i < count($values_r); $i++) { if (strcasecmp($values_r[$i], $lookup_map_r['value']) === 0) { $found_entries_r[] = $values_r[$i]; if (!in_array($lookup_map_r['lookup_attribute_val'], $new_values_r)) { $new_values_r[] = $lookup_map_r['lookup_attribute_val']; } } } } db_free_result($results); // now process all back into $values_r for ($i = 0; $i < count($values_r); $i++) { if (!in_array($values_r[$i], $found_entries_r) && !in_array($values_r[$i], $new_values_r)) { $new_values_r[] = $values_r[$i]; } } $values_r = $new_values_r; } //if($results) // now reassign back. $site_item_attributes_r[strtolower($s_attribute_type)] = $values_r; } else { // the next process prefers arrays to deal with, even if single element $site_item_attributes_r[strtolower($s_attribute_type)] = $value; } } // // now that we have expanded mappings, we need to map to s_item_attribute_type order number mappings // $new_attributes_r = $site_item_attributes_r; $site_item_attributes_r = NULL; // now we want to expand the $new_attributes_r, so we have a set of // variables that include the order_no $fieldname type format. $results = fetch_item_attribute_type_rs($s_item_type, NULL, 's_attribute_type'); if ($results) { // this will be set if array encountered, but not lookup value. $processing_s_attribute_type = FALSE; while ($attribute_type_r = db_fetch_assoc($results)) { $variable = strtolower($attribute_type_r['s_attribute_type']); if (isset($new_attributes_r[$variable])) { $fieldname = get_field_name($attribute_type_r['s_attribute_type'], $attribute_type_r['order_no']); if (is_not_empty_array($new_attributes_r[$variable])) { // TODO: Consider adding values not found in the lookup table to the s_attribute_type_lookup. if (is_lookup_attribute_type($attribute_type_r['s_attribute_type'])) { $lookup_attribute_val_restrict_ind = $lookup_attribute_val_restrict_ind_r[strtolower($attribute_type_r['s_attribute_type'])]; // here is where we want some sanity checking of the options $value_r = $new_attributes_r[$variable]; $lookup_value_r = array(); for ($i = 0; $i < count($value_r); $i++) { $raw_value = trim($value_r[$i]); if (strlen($raw_value) > 0) { $value = fetch_attribute_type_lookup_value($attribute_type_r['s_attribute_type'], $raw_value); if ($value !== FALSE) { $lookup_value_r[] = $value; } else { if ($lookup_attribute_val_restrict_ind != 'Y') { // do not include if restricted to lookup values $lookup_value_r[] = $raw_value; } } } } $site_item_attributes_r[$fieldname] = array_unique($lookup_value_r); } else { // This indicates we have a repeated s_attribute_type, and so should act appropriately. if ($processing_s_attribute_type != NULL && $attribute_type_r['s_attribute_type'] == $processing_s_attribute_type) { $site_item_attributes_r[$fieldname] = $new_attributes_r[$variable][0]; // remove it array_splice($new_attributes_r[$variable], 0, 1); } else { if (count($new_attributes_r[$variable]) > 1) { // this is the first occurence of the s_attribute_type, so lets see if its repeated at least once. if (is_numeric(fetch_s_item_attribute_type_next_order_no($s_item_type, $attribute_type_r['s_attribute_type'], $attribute_type_r['order_no']))) { $site_item_attributes_r[$fieldname] = $new_attributes_r[$variable][0]; // remove it array_splice($new_attributes_r[$variable], 0, 1); $processing_s_attribute_type = $attribute_type_r['s_attribute_type']; } else { // otherwise just copy the whole thing. $site_item_attributes_r[$fieldname] = $new_attributes_r[$variable]; unset($new_attributes_r[$variable]); } } else { $site_item_attributes_r[$fieldname] = $new_attributes_r[$variable][0]; unset($new_attributes_r[$variable]); } } } } else { if (!is_array($new_attributes_r[$variable])) { $site_item_attributes_r[$fieldname] = $new_attributes_r[$variable]; unset($new_attributes_r[$variable]); } } } else { if ($attribute_type_r['s_field_type'] == 'TITLE' && isset($new_attributes_r['title'])) { // in case developer forgot to setup title mapping. $fieldname = get_field_name($attribute_type_r['s_attribute_type'], $attribute_type_r['order_no']); $site_item_attributes_r[$fieldname] = $new_attributes_r['title']; } } } //while db_free_result($results); } return $site_item_attributes_r; }
/** */ function get_row_column_mappings_table($s_item_type, $owner_id, $header_row, $field_column_r, $field_default_r, $field_initcap_r) { $buffer = "\n<table>"; $buffer .= "\n<tr class=\"navbar\"><th></th>" . "<th>" . get_opendb_lang_var('field') . "</th>" . "<th>" . get_opendb_lang_var('default') . "</th>" . "<th> " . get_opendb_lang_var('initcap') . "</th></tr>"; // If the prompt for this field, matches any of the $tokens, then select that token. if (!is_numeric($field_column_r['s_item_type'])) { for ($i = 0; $i < count($header_row); $i++) { if ($header_row[$i] == 's_item_type' || $header_row[$i] == get_opendb_lang_var('s_item_type')) { $field_column_r['s_item_type'] = $i; break; } } } // If your data includes the item_type, then specify the column, so we // can ignore records that are not of the chosen item_type. $buffer .= "\n<tr>" . "<th class=\"prompt\" scope=\"row\">" . get_opendb_lang_var('s_item_type') . "</th>" . "<td class=\"data fieldColumn\">" . get_column_select_block("field_column[s_item_type]", $header_row, $field_column_r['s_item_type']) . "</td>" . "<td class=\"data defaultColumn\"> </td>" . "<td class=\"data initcapColumn\"> </td>" . "</tr>"; // --------- Now the main input fields start.... $results = fetch_item_attribute_type_rs($s_item_type); if ($results) { while ($item_attribute_type_r = db_fetch_assoc($results)) { // purely readonly if ($item_attribute_type_r['s_field_type'] !== 'ITEM_ID') { $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']); if ($item_attribute_type_r['s_field_type'] == 'STATUSTYPE') { $lookup_results = fetch_newitem_status_type_rs(); $default_field = build_select("field_default[{$fieldname}]", $lookup_results, $field_default_r[$fieldname], FALSE); // do not include 'None' option $initcap_field = NULL; // No initcap for these types of fields. } else { if ($item_attribute_type_r['input_type'] !== "textarea" && $item_attribute_type_r['input_type'] !== "url") { // Check if any lookup values for this field. $lookup_results = fetch_attribute_type_lookup_rs($item_attribute_type_r['s_attribute_type'], 'order_no, value ASC'); if ($lookup_results) { $default_field = build_select("field_default[{$fieldname}]", $lookup_results, $field_default_r[$fieldname]); $initcap_field = NULL; // No initcap for these types of fields. } else { //use normal input field. if ($item_attribute_type_r['multi_attribute_ind'] == 'Y') { $item_attribute_type_r['multi_attribute_ind'] = 'N'; } $default_field = get_item_input_field("field_default[{$fieldname}]", $item_attribute_type_r, NULL, $field_default_r[$fieldname], FALSE); if ($item_attribute_type_r['input_type'] === 'text') { $initcap_field = get_input_field("field_initcap[{$fieldname}]", NULL, NULL, "checkbox(true,false,)", "N", ifempty($field_initcap_r[$fieldname], get_opendb_config_var('import', 'row_import_default_initcap_checked') ? "true" : "false"), FALSE); } else { //Only for text fields. $initcap_field = NULL; } } } else { $field = NULL; $default_field = NULL; $initcap_field = NULL; } } // If the prompt for this field, matches any of the $tokens, then select that token. if (!is_numeric($field_column_r[$fieldname])) { for ($i = 0; $i < count($header_row); $i++) { // A direct export from CSV Export, so lets match the columns for you. if ($header_row[$i] == $fieldname || $header_row[$i] == $item_attribute_type_r['prompt'] || $item_attribute_type_r['s_field_type'] == 'CATEGORY' && $header_row[$i] == 'Genre') { $field_column_r[$fieldname] = $i; break; } } } $buffer .= "\n<tr>" . "<th class=\"prompt\" scope=\"row\">" . $item_attribute_type_r['prompt'] . "</th>" . "<td class=\"data fieldColumn\">" . get_column_select_block("field_column[{$fieldname}]", $header_row, $field_column_r[$fieldname]) . "</td>" . "<td class=\"data defaultColumn\">" . $default_field . "</td>" . "<td class=\"data initcapColumn\">" . $initcap_field . "</td>" . "</tr>"; } //if($item_attribute_type_r['s_field_type'] !== 'ITEM_ID') } //while db_free_result($results); } //if($results) $buffer .= "\n</table>"; return $buffer; }
echo "<li id=\"menu-reviews\" onclick=\"return activateTab('reviews')\">" . get_opendb_lang_var('review(s)') . "</li>"; } echo "</ul>"; echo "<div id=\"tab-content\">"; echo "<div class=\"tabContent\" id=\"details\">"; if (get_opendb_config_var('item_review', 'enable') !== FALSE) { $average = fetch_review_rating($item_r['item_id']); if ($average !== FALSE) { echo "<p class=\"rating\">"; echo get_opendb_lang_var('rating') . ": "; $attribute_type_r = fetch_attribute_type_r('S_RATING'); echo get_display_field($attribute_type_r['s_attribute_type'], NULL, 'review()', $average, FALSE); echo "</p>"; } } $results = fetch_item_attribute_type_rs($item_r['s_item_type'], 'not_instance_field_types'); if ($results) { echo "<table>"; while ($item_attribute_type_r = db_fetch_assoc($results)) { if (has_role_permission($item_attribute_type_r['view_perm'])) { $display_type = trim($item_attribute_type_r['display_type']); if ($HTTP_VARS['mode'] == 'printable' && $item_attribute_type_r['printable_ind'] != 'Y' || strlen($display_type) == 0 && $item_attribute_type_r['input_type'] == 'hidden') { // We allow the get_display_field to handle hidden variable, in case at some stage // we might want to change the functionality of 'hidden' to something other than ignore. $display_type = 'hidden'; } if ($item_attribute_type_r['s_field_type'] == 'ITEM_ID') { $value = $item_r['item_id']; } else { if ($item_attribute_type_r['s_field_type'] == 'UPDATE_ON') { $value = $item_r['update_on'];
function encode_search_javascript_arrays(&$item_type_rs, &$arrayOfUniqueCategories, &$item_attribute_type_rs) { $buffer = ""; $arrayOfCategoryTypes = array(); $arrayOfUniqueAttributes = array(); $itemTypeBlock = ""; $attrTypeSelect = ""; $jsArrayOfAttributes = ""; $jsArrayOfAttributesCount = 0; $itemresults = fetch_item_type_rs(); while ($item_type_r = db_fetch_assoc($itemresults)) { $results = fetch_item_attribute_type_rs($item_type_r['s_item_type'], NULL, 'prompt'); // For the case where we have a s_item_type with no attributes associated with it! if ($results) { while ($item_attribute_type_r = db_fetch_assoc($results)) { // Do not include any attributes which do not exist as item attributes if ($item_attribute_type_r['s_field_type'] != 'TITLE' && $item_attribute_type_r['s_field_type'] != 'DURATION' && $item_attribute_type_r['s_field_type'] != 'STATUSTYPE' && $item_attribute_type_r['s_field_type'] != 'STATUSCMNT' && $item_attribute_type_r['s_field_type'] != 'ITEM_ID') { // Only unique attributes should be added to attribute options object. if (!is_array($arrayOfUniqueAttributes) || !in_array($item_attribute_type_r['s_attribute_type'], $arrayOfUniqueAttributes)) { // This array, is only so we can make sure that we have unique attributes only! $arrayOfUniqueAttributes[] = $item_attribute_type_r['s_attribute_type']; $jsArrayOfUniqueAttributes .= "\narrayOfAttributes[{$jsArrayOfAttributesCount}] = new LookupAttribute(\"\",\"" . $item_attribute_type_r['s_attribute_type'] . "\",\"" . $item_attribute_type_r['s_attribute_type'] . " - " . $item_attribute_type_r['description'] . "\");"; $item_attribute_type_rs[] = $item_attribute_type_r; } $jsArrayOfAttributes .= "\narrayOfAttributes[{$jsArrayOfAttributesCount}] = new LookupAttribute(\"" . $item_type_r['s_item_type'] . "\",\"" . $item_attribute_type_r['s_attribute_type'] . "\",\"" . $item_attribute_type_r['s_attribute_type'] . " - " . $item_attribute_type_r['description'] . "\");"; $jsArrayOfAttributesCount++; } } } // Get the category_attribute_type for this item_type $category_attribute_type = fetch_sfieldtype_item_attribute_type($item_type_r['s_item_type'], 'CATEGORY'); // We need this list further down, to work out which of the lookup items are actually categories. $arrayOfCategoryTypes[] = $category_attribute_type; $item_type_rs[] = $item_type_r; } // Give us the whole s_attribute_type_lookup table, whoo baby... $jsArrayOfLookupValues = ""; $jsArrayOfLookupValuesCount = 0; $attresults = fetch_attribute_type_lookup_rs(NULL, 's_attribute_type ASC'); while ($attribute_type_r = db_fetch_assoc($attresults)) { if ($attribute_type_r['s_field_type'] != 'ADDRESS' && $attribute_type_r['s_field_type'] != 'S_RATING') { if (in_array($attribute_type_r['s_attribute_type'], $arrayOfCategoryTypes) && (!is_array($arrayOfUniqueCategories) || !in_array($attribute_type_r['value'], $arrayOfUniqueCategories))) { $arrayOfUniqueCategories[$attribute_type_r['value']] = $attribute_type_r['display']; } $jsArrayOfLookupValues .= "\narrayOfLookupValues[{$jsArrayOfLookupValuesCount}] = new LookupAttribute(\"" . $attribute_type_r['s_attribute_type'] . "\",\"" . $attribute_type_r['value'] . "\",\"" . $attribute_type_r['display'] . "\");"; $jsArrayOfLookupValuesCount++; } } $buffer .= "\n\narrayOfLookupValues = new Array({$jsArrayOfLookupValuesCount});"; $buffer .= $jsArrayOfLookupValues; $buffer .= "\n\narrayOfAttributes = new Array({$jsArrayOfAttributesCount});"; $buffer .= $jsArrayOfAttributes; $arrayOfUniqueCategoryValues = ""; $arrayOfUniqueCatValuesCount = 0; // Now sort all values into alphabetical order! if (is_array($arrayOfUniqueCategories)) { asort($arrayOfUniqueCategories); reset($arrayOfUniqueCategories); while (list($value, $display) = each($arrayOfUniqueCategories)) { $arrayOfUniqueCatValues .= "\narrayOfUniqueCatValues[{$arrayOfUniqueCatValuesCount}] = new LookupAttribute('',\"{$value}\",\"{$display}\");"; $arrayOfUniqueCatValuesCount++; } } // Now wrap and return return "\n<script language=\"JavaScript\">\n<!-- // hide from stupid browsers\n" . $buffer . "\n// -->\n</script>\n"; }
function get_edit_item_instance_form($op, $item_r, $status_type_r, $HTTP_VARS) { $formContents = "<div class=\"tabContentHidden\" id=\"instance_info\">"; $formContents .= get_related_item_search_script(); $results = fetch_item_attribute_type_rs($item_r['s_item_type'], 'instance_field_types'); if ($results) { $formContents .= "<h3>" . get_opendb_lang_var('instance_info') . "</h3>"; $formContents .= "\n<table>"; if (($op == 'edit' || $op == 'refresh') && $status_type_r['change_owner_ind'] == 'Y') { $formContents .= format_field(get_opendb_lang_var('owner'), "\n<select name=\"owner_id\">" . custom_select('owner_id', fetch_user_rs(PERM_ITEM_OWNER, INCLUDE_ROLE_PERMISSIONS, INCLUDE_CURRENT_USER, EXCLUDE_DEACTIVATED_USER, 'user_id', 'ASC'), '%fullname% (%user_id%)', 'NA', ifempty($HTTP_VARS['owner_id'], $item_r['owner_id']), 'user_id') . "\n</select>"); } if ($op == 'newinstance' || $op == 'clone_item') { $item_r['s_status_type'] = NULL; $item_r['status_comment'] = NULL; $item_r['borrow_duration'] = NULL; } while ($item_attribute_type_r = db_fetch_assoc($results)) { if ($item_attribute_type_r['s_field_type'] == 'STATUSTYPE') { $status_type = ifempty(filter_item_input_field($item_attribute_type_r, $HTTP_VARS['s_status_type']), $item_r['s_status_type']); if ($op == 'new' || $op == 'site' || $op == 'newinstance' || $op == 'clone_item') { $lookup_results = fetch_newitem_status_type_rs(); } else { // If item has borrowed records, then no s_status_type with borrow_ind == 'X' should be included. $lookup_results = fetch_update_status_type_rs($status_type); } if ($lookup_results && db_num_rows($lookup_results) > 0) { $formContents .= format_field($item_attribute_type_r['prompt'], radio_grid('s_status_type', $lookup_results, '%img%', 'VERTICAL', $status_type)); // value } } else { if ($item_attribute_type_r['s_field_type'] == 'STATUSCMNT') { $status_comment = ifempty(filter_item_input_field($item_attribute_type_r, $HTTP_VARS['status_comment']), $item_r['status_comment']); $formContents .= get_item_input_field('status_comment', $item_attribute_type_r, NULL, $status_comment); } else { if ($item_attribute_type_r['s_field_type'] == 'DURATION') { $borrow_duration = ifempty(filter_item_input_field($item_attribute_type_r, $HTTP_VARS['borrow_duration']), $item_r['borrow_duration']); // The S_DURATION lookup list will most likely include an 'Undefined' option, that equates // to an empty string. So for Updates, we want to allow for a match, by forcing any NULL // value to a empty string. The reason why we do this, is because the Borrow Duration was // probably set to 'Undefined', but because this equated to an empty string, the field was // never updated. if ($op != 'new' && $op != 'site') { if ($borrow_duration === NULL) { $borrow_duration = ''; } } $formContents .= get_item_input_field('borrow_duration', $item_attribute_type_r, NULL, $borrow_duration); } } } } //while db_free_result($results); $formContents .= "\n</table>"; } if (get_opendb_config_var('item_input', 'related_item_support') !== FALSE) { $formContents .= "<h3>" . get_opendb_lang_var('add_related_parent') . "</h3>"; $formContents .= "\n<table>"; $formContents .= format_field(get_opendb_lang_var('parent_item_filter'), '<input type="text" name="parent_item_filter" id="parent_item_filter">'); $formContents .= format_field(get_opendb_lang_var('parent_item'), format_item_parents_select($HTTP_VARS, $item_r, '%parent_only%')); $formContents .= "\n</table>"; $relatedItems = get_related_items_listing($item_r, $HTTP_VARS, RELATED_PARENTS_MODE); if ($relatedItems != NULL) { $formContents .= "<h3>" . get_opendb_lang_var('related_parent_item(s)') . "</h3>"; $formContents .= $relatedItems; } } $formContents .= "</div>"; return $formContents; }
function fetch_sfieldtype_item_attribute_type_r($s_item_type, $s_field_type) { $results = fetch_item_attribute_type_rs($s_item_type, $s_field_type); if ($results) { $record_r = db_fetch_assoc($results); db_free_result($results); return $record_r; } //else return FALSE; }
function handleImport($include_header_row, $s_item_type) { // skip the header row if appropriate. if ($this->importPlugin->is_header_row() !== TRUE || $include_header_row !== TRUE) { $this->importPlugin->read_header($this->fileHandler, $this->_error); } while (!$this->fileHandler->isEof() && $this->itemImportHandler->isError() != TRUE && ($read_row_r = $this->importPlugin->read_row($this->fileHandler, $this->_error)) !== FALSE) { // ensure we have a array that is not empty, or empty except for first element, which is empty. // Either no s_item_type restriction applies, or the s_item_type column is the same as // the current s_item_type we are processing. if (is_not_empty_array($read_row_r) && (count($read_row_r) > 1 || strlen($read_row_r[0]) > 0) && (!is_numeric($this->field_column_r['s_item_type']) || strlen($read_row_r[$this->field_column_r['s_item_type']]) == 0 || strcasecmp($read_row_r[$this->field_column_r['s_item_type']], $s_item_type) === 0)) { $this->itemImportHandler->startItem($s_item_type); // Now do the title. $title_attr_type_r = fetch_sfieldtype_item_attribute_type_r($s_item_type, 'TITLE'); $title = $this->get_field_value(get_field_name($title_attr_type_r['s_attribute_type'], $title_attr_type_r['order_no']), NULL, $read_row_r); $this->itemImportHandler->setTitle($title); $results = fetch_item_attribute_type_rs($s_item_type, NULL, FALSE); if ($results) { while ($item_attribute_type_r = db_fetch_assoc($results)) { // these field types are references to item_instance values, and not true attribute types. if ($item_attribute_type_r['s_field_type'] != 'TITLE' && $item_attribute_type_r['s_field_type'] != 'STATUSTYPE' && $item_attribute_type_r['s_field_type'] != 'STATUSCMNT' && $item_attribute_type_r['s_field_type'] != 'DURATION' && $item_attribute_type_r['s_field_type'] != 'ITEM_ID') { $value = $this->get_field_value(get_field_name($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']), $item_attribute_type_r['s_attribute_type'], $read_row_r); if (strlen($value) > 0) { if ($item_attribute_type_r['lookup_attribute_ind'] == 'Y' || $item_attribute_type_r['multi_attribute_ind'] == 'Y') { // row based are comma delimited. $values_r = trim_explode(',', $value); } else { $values_r = $value; } $this->itemImportHandler->addAttribute($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no'], $values_r); } //if(strlen($value)>0) } } db_free_result($results); } //if($results) $status_attr_type_r = fetch_sfieldtype_item_attribute_type_r($s_item_type, 'STATUSTYPE'); $s_status_type = $this->get_field_value(get_field_name($status_attr_type_r['s_attribute_type'], $status_attr_type_r['order_no']), $status_attr_type_r['s_attribute_type'], $read_row_r); $status_cmnt_attr_type_r = fetch_sfieldtype_item_attribute_type_r($s_item_type, 'STATUSCMNT'); $status_comment = $this->get_field_value(get_field_name($status_cmnt_attr_type_r['s_attribute_type'], $status_cmnt_attr_type_r['order_no']), $status_cmnt_attr_type_r['s_attribute_type'], $read_row_r); $duration_attr_type_r = fetch_sfieldtype_item_attribute_type_r($s_item_type, 'DURATION'); $borrow_duration = $this->get_field_value(get_field_name($duration_attr_type_r['s_attribute_type'], $duration_attr_type_r['order_no']), $duration_attr_type_r['s_attribute_type'], $read_row_r); $this->itemImportHandler->startItemInstance(); $this->itemImportHandler->setInstanceStatusType($s_status_type); $this->itemImportHandler->setInstanceStatusComment($status_comment); $this->itemImportHandler->setInstanceBorrowDuration($borrow_duration); $this->itemImportHandler->endItemInstance(); $this->itemImportHandler->endItem(); } } if ($this->itemImportHandler->isError()) { // copy the first error in $itemImportHandlerErrors =& $this->itemImportHandler->getRawErrors(); if (is_array($itemImportHandlerErrors)) { $this->_error = $itemImportHandlerErrors[0]['error']; } return FALSE; } else { return TRUE; } }