/** * Standard aed_module edit actualiser. * * @param ID_TEXT The entry being edited */ function edit_actualisation($_id) { require_code('catalogues2'); $id = intval($_id); $category_id = post_param_integer('category_id', INTEGER_MAGIC_NULL); $validated = post_param_integer('validated', fractional_edit() ? INTEGER_MAGIC_NULL : 0); $notes = post_param('notes', STRING_MAGIC_NULL); $allow_rating = post_param_integer('allow_rating', fractional_edit() ? INTEGER_MAGIC_NULL : 0); $allow_comments = post_param_integer('allow_comments', fractional_edit() ? INTEGER_MAGIC_NULL : 0); $allow_trackbacks = post_param_integer('allow_trackbacks', fractional_edit() ? INTEGER_MAGIC_NULL : 0); $catalogue_name = $GLOBALS['SITE_DB']->query_value_null_ok('catalogue_categories', 'c_name', array('id' => $category_id)); if (is_null($catalogue_name)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $map = $this->get_set_field_map($catalogue_name, $id); if ($validated == 1 && $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'ce_validated', array('id' => $id)) == 0) { if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'catalogues') && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'catalogues_catalogue', $catalogue_name) && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'catalogues_category', strval($category_id))) { $submitter = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'ce_submitter', array('id' => $id)); $map_copy = $map; $title = array_shift($map_copy); $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => $catalogue_name))); syndicate_described_activity($submitter != get_member() ? 'calendar:ACTIVITY_VALIDATE_CATALOGUE_GENERIC' : 'catalogues:ACTIVITY_CATALOGUE_GENERIC_ADD', $catalogue_title, $title, '', '_SEARCH:catalogues:entry:' . strval($id), '', '', 'catalogues', 1, NULL); } } actual_edit_catalogue_entry($id, $category_id, $validated, $notes, $allow_rating, $allow_comments, $allow_trackbacks, $map, post_param('meta_keywords', STRING_MAGIC_NULL), post_param('meta_description', STRING_MAGIC_NULL)); $this->donext_category_id = $category_id; $this->donext_catalogue_name = $catalogue_name; }
function _create_catalogue_subtree($fields, $first_cat, $catalogue_name, $root_cat, $full_tree, $node, $tree_pos) { if (!array_key_exists('children', $node)) { $node['children'] = array(); } // Bottom level $id = _create_catalogue_position($catalogue_name, $tree_pos, $root_cat, $node['details'], $full_tree); $node['details']['l_min_latitude'] = $node['details']['l_latitude']; $node['details']['l_max_latitude'] = $node['details']['l_latitude']; $node['details']['l_min_longitude'] = $node['details']['l_longitude']; $node['details']['l_max_longitude'] = $node['details']['l_longitude']; foreach ($node['children'] as $name => $child) { if (!array_key_exists('details', $child)) { $child['details'] = array('l_latitude' => NULL, 'l_longitude' => NULL); } $child = _create_catalogue_subtree($fields, $first_cat, $catalogue_name, $root_cat, $full_tree, $child, array_merge($tree_pos, array($name))); $node['children'][$name] = $child; // If updated // Work out latitude/longitude bounding boxes if (!is_null($child['details']['l_min_latitude']) && (is_null($node['details']['l_min_latitude']) || $child['details']['l_min_latitude'] < $node['details']['l_min_latitude'])) { $node['details']['l_min_latitude'] = $child['details']['l_min_latitude']; } if (!is_null($child['details']['l_max_latitude']) && (is_null($node['details']['l_max_latitude']) || $child['details']['l_max_latitude'] > $node['details']['l_max_latitude'])) { $node['details']['l_max_latitude'] = $child['details']['l_max_latitude']; } if (!is_null($child['details']['l_min_longitude']) && (is_null($node['details']['l_min_longitude']) || $child['details']['l_min_longitude'] < $node['details']['l_min_longitude'])) { $node['details']['l_min_longitude'] = $child['details']['l_min_longitude']; } if (!is_null($child['details']['l_max_longitude']) && (is_null($node['details']['l_max_longitude']) || $child['details']['l_max_longitude'] > $node['details']['l_max_longitude'])) { $node['details']['l_max_longitude'] = $child['details']['l_max_longitude']; } } if (is_null($node['details']['l_latitude'])) { $node['details']['l_latitude'] = ($node['details']['l_min_latitude'] + $node['details']['l_max_latitude']) / 2; } if (is_null($node['details']['l_longitude'])) { $node['details']['l_longitude'] = ($node['details']['l_min_longitude'] + $node['details']['l_max_longitude']) / 2; } // Save into category: bounding box, and own latitude/longitude if specified $map = array($fields[0]['id'] => float_to_raw_string($node['details']['l_latitude']), $fields[1]['id'] => float_to_raw_string($node['details']['l_longitude']), $fields[2]['id'] => float_to_raw_string($node['details']['l_min_latitude']), $fields[3]['id'] => float_to_raw_string($node['details']['l_max_latitude']), $fields[4]['id'] => float_to_raw_string($node['details']['l_min_longitude']), $fields[5]['id'] => float_to_raw_string($node['details']['l_max_longitude'])); $existing = get_bound_content_entry('catalogue_category', strval($id)); if (!is_null($existing)) { actual_edit_catalogue_entry($existing, $first_cat, 1, '', 0, 0, 0, $map); } else { $catalogue_entry_id = actual_add_catalogue_entry($first_cat, 1, '', 0, 0, 0, $map); $GLOBALS['SITE_DB']->query_insert('catalogue_entry_linkage', array('catalogue_entry_id' => $catalogue_entry_id, 'content_type' => 'catalogue_category', 'content_id' => strval($id))); } return $node; }
/** * Save custom fields to a content item. * * @param ID_TEXT Award hook codename * @param ID_TEXT Content entry ID */ function save_form_custom_fields($content_type, $id) { if (fractional_edit()) { return; } $existing = get_bound_content_entry($content_type, $id); require_code('catalogues'); // Get field values $fields = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => '_' . $content_type), 'ORDER BY cf_order'); $map = array(); require_code('fields'); foreach ($fields as $field) { $ob = get_fields_hook($field['cf_type']); list(, , $storage_type) = $ob->get_field_value_row_bits($field); $value = $ob->inputted_to_field_value(!is_null($existing), $field, 'uploads/catalogues', is_null($existing) ? NULL : _get_catalogue_entry_field($field['id'], $existing, $storage_type)); $map[$field['id']] = $value; } $first_cat = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'MIN(id)', array('c_name' => '_' . $content_type)); require_code('catalogues2'); if (!is_null($existing)) { actual_edit_catalogue_entry($existing, $first_cat, 1, '', 0, 0, 0, $map); } else { $catalogue_entry_id = actual_add_catalogue_entry($first_cat, 1, '', 0, 0, 0, $map); $GLOBALS['SITE_DB']->query_insert('catalogue_entry_linkage', array('catalogue_entry_id' => $catalogue_entry_id, 'content_type' => $content_type, 'content_id' => $id)); } }