/** * Check a post would be valid. * * @param LONG_TEXT The post. * @param ?AUTO_LINK The ID of the topic the post would be in (NULL: don't check with regard to any particular topic). * @param ?MEMBER The poster (NULL: current member). * @return ?array Row of the existing post if a double post (single row map-element in a list of rows) (NULL: not a double post). */ function ocf_check_post($post, $topic_id = NULL, $poster = NULL) { if (is_null($poster)) { $poster = get_member(); } require_code('comcode_check'); check_comcode($post, NULL, false, NULL, true); if (strlen($post) == 0) { warn_exit(do_lang_tempcode('POST_TOO_SHORT')); } require_code('ocf_groups'); if (strlen($post) > ocf_get_member_best_group_property($poster, 'max_post_length_comcode')) { warn_exit(make_string_tempcode(escape_html(do_lang('_POST_TOO_LONG')))); } if (!is_null($topic_id)) { if (running_script('stress_test_loader')) { return NULL; } // Check this isn't the same as the last post here $last_posts = $GLOBALS['FORUM_DB']->query_select('f_posts', array('p_post', 'p_poster', 'p_ip_address'), array('p_topic_id' => $topic_id), 'ORDER BY p_time DESC,id DESC', 1); if (array_key_exists(0, $last_posts)) { if ($last_posts[0]['p_poster'] == $GLOBALS['OCF_DRIVER']->get_guest_id() && get_ip_address() != $last_posts[0]['p_ip_address']) { $last_posts[0]['p_poster'] = -1; } if ($last_posts[0]['p_poster'] == $poster && get_translated_text($last_posts[0]['p_post'], $GLOBALS['FORUM_DB']) == $post && get_param_integer('keep_debug_notifications', 0) != 1) { warn_exit(do_lang_tempcode('DOUBLE_POST_PREVENTED')); } } return $last_posts; } return NULL; }
/** * Add a calendar event. * * @param AUTO_LINK The event type * @param SHORT_TEXT The recurrence code (set to 'none' for no recurrences: blank means infinite and will basically time-out ocPortal) * @param ?integer The number of recurrences (NULL: none/infinite) * @param BINARY Whether to segregate the comment-topics/rating/trackbacks per-recurrence * @param SHORT_TEXT The title of the event * @param LONG_TEXT The full text describing the event * @param integer The priority * @range 1 5 * @param BINARY Whether it is a public event * @param ?integer The year the event starts at (NULL: default) * @param ?integer The month the event starts at (NULL: default) * @param ?integer The day the event starts at (NULL: default) * @param ?integer The hour the event starts at (NULL: default) * @param ?integer The minute the event starts at (NULL: default) * @param ?integer The year the event ends at (NULL: not a multi day event) * @param ?integer The month the event ends at (NULL: not a multi day event) * @param ?integer The day the event ends at (NULL: not a multi day event) * @param ?integer The hour the event ends at (NULL: not a multi day event) * @param ?integer The minute the event ends at (NULL: not a multi day event) * @param ?ID_TEXT The timezone for the event (NULL: current user's timezone) * @param BINARY Whether the time should be presented in the viewer's own timezone * @param BINARY Whether the event has been validated * @param BINARY Whether the event may be rated * @param SHORT_INTEGER Whether comments are allowed (0=no, 1=yes, 2=review style) * @param BINARY Whether the event may be trackbacked * @param LONG_TEXT Hidden notes pertaining to the download * @param ?MEMBER The event submitter (NULL: current member) * @param integer The number of views so far * @param ?TIME The add time (NULL: now) * @param ?TIME The edit time (NULL: never) * @param ?AUTO_LINK Force an ID (NULL: don't force an ID) * @return AUTO_LINK The ID of the event */ function add_calendar_event($type, $recurrence, $recurrences, $seg_recurrences, $title, $content, $priority, $is_public, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year = NULL, $end_month = NULL, $end_day = NULL, $end_hour = NULL, $end_minute = NULL, $timezone = NULL, $do_timezone_conv = 1, $validated = 1, $allow_rating = 1, $allow_comments = 1, $allow_trackbacks = 1, $notes = '', $submitter = NULL, $views = 0, $add_date = NULL, $edit_date = NULL, $id = NULL) { if (is_null($submitter)) { $submitter = get_member(); } if (is_null($add_date)) { $add_date = time(); } if (is_null($timezone)) { $timezone = get_users_timezone(); } require_code('comcode_check'); check_comcode($content, NULL, false, NULL, true); if (!addon_installed('unvalidated')) { $validated = 1; } $map = array('e_submitter' => $submitter, 'e_views' => $views, 'e_title' => insert_lang($title, 2), 'e_content' => 0, 'e_add_date' => $add_date, 'e_edit_date' => $edit_date, 'e_recurrence' => $recurrence, 'e_recurrences' => $recurrences, 'e_seg_recurrences' => $seg_recurrences, 'e_start_year' => $start_year, 'e_start_month' => $start_month, 'e_start_day' => $start_day, 'e_start_hour' => $start_hour, 'e_start_minute' => $start_minute, 'e_end_year' => $end_year, 'e_end_month' => $end_month, 'e_end_day' => $end_day, 'e_end_hour' => $end_hour, 'e_end_minute' => $end_minute, 'e_timezone' => $timezone, 'e_do_timezone_conv' => $do_timezone_conv, 'e_is_public' => $is_public, 'e_priority' => $priority, 'e_type' => $type, 'validated' => $validated, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes); if (!is_null($id)) { $map['id'] = $id; } $id = $GLOBALS['SITE_DB']->query_insert('calendar_events', $map, true); require_code('attachments2'); $GLOBALS['SITE_DB']->query_update('calendar_events', array('e_content' => insert_lang_comcode_attachments(3, $content, 'calendar', strval($id))), array('id' => $id), '', 1); require_code('seo2'); seo_meta_set_for_implicit('event', strval($id), array($title, $content), $content); decache('side_calendar'); if ($validated == 1) { require_lang('calendar'); require_code('notifications'); $subject = do_lang('CALENDAR_EVENT_NOTIFICATION_MAIL_SUBJECT', get_site_name(), strip_comcode($title)); $self_url = build_url(array('page' => 'calendar', 'type' => 'view', 'id' => $id), get_module_zone('calendar'), NULL, false, false, true); $mail = do_lang('CALENDAR_EVENT_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($title), array($self_url->evaluate())); dispatch_notification('calendar_event', strval($type), $subject, $mail); } log_it('ADD_CALENDAR_EVENT', strval($id), $title); return $id; }
/** * Add a CEDI page * * @param SHORT_TEXT The page title * @param LONG_TEXT The page description * @param LONG_TEXT Hidden notes pertaining to the page * @param BINARY Whether to hide the posts on the page by default * @param ?MEMBER The member doing the action (NULL: current member) * @return AUTO_LINK The page ID */ function cedi_add_page($title, $description, $notes, $hide_posts, $member = NULL) { if (is_null($member)) { $member = get_member(); } require_code('comcode_check'); check_comcode($description, NULL, false, NULL, true); if ($description != '') { $id = $GLOBALS['SITE_DB']->query_insert('seedy_pages', array('submitter' => $member, 'hide_posts' => $hide_posts, 'seedy_views' => 0, 'notes' => $notes, 'description' => 0, 'title' => insert_lang($title, 2), 'add_date' => time()), true); require_code('attachments2'); $GLOBALS['SITE_DB']->query_update('seedy_pages', array('description' => insert_lang_comcode_attachments(2, $description, 'cedi_page', strval($id), NULL, false, $member)), array('id' => $id), '', 1); } else { $id = $GLOBALS['SITE_DB']->query_insert('seedy_pages', array('submitter' => $member, 'hide_posts' => $hide_posts, 'seedy_views' => 0, 'notes' => $notes, 'description' => insert_lang($description, 2), 'title' => insert_lang($title, 2), 'add_date' => time()), true); } update_stat('num_seedy_pages', 1); $GLOBALS['SITE_DB']->query_insert('seedy_changes', array('the_action' => 'CEDI_ADD_PAGE', 'the_page' => $id, 'date_and_time' => time(), 'ip' => get_ip_address(), 'the_user' => $member)); require_code('seo2'); seo_meta_set_for_implicit('seedy_page', strval($id), array($title, $description), $description); dispatch_cedi_page_notification($id, 'ADD'); return $id; }
/** * Makes a post in the specified forum, in the specified topic according to the given specifications. If the topic doesn't exist, it is created along with a spacer-post. * Spacer posts exist in order to allow staff to delete the first true post in a topic. Without spacers, this would not be possible with most forum systems. They also serve to provide meta information on the topic that cannot be encoded in the title (such as a link to the content being commented upon). * * @param object Link to the real forum driver * @param SHORT_TEXT The forum name * @param SHORT_TEXT The topic identifier (usually <content-type>_<content-id>) * @param MEMBER The member ID * @param LONG_TEXT The post title * @param LONG_TEXT The post content in Comcode format * @param string The topic title; must be same as content title if this is for a comment topic * @param string This is put together with the topic identifier to make a more-human-readable topic title or topic description (hopefully the latter and a $content_title title, but only if the forum supports descriptions) * @param ?URLPATH URL to the content (NULL: do not make spacer post) * @param ?TIME The post time (NULL: use current time) * @param ?IP The post IP address (NULL: use current members IP address) * @param ?BINARY Whether the post is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). This only works with the OCF driver. * @param ?BINARY Whether the topic is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). This only works with the OCF driver. * @param boolean Whether to skip post checks * @param SHORT_TEXT The name of the poster * @param ?AUTO_LINK ID of post being replied to (NULL: N/A) * @param boolean Whether the reply is only visible to staff * @param ?ID_TEXT DO NOT send notifications to: The notification code (NULL: no restriction) * @param ?SHORT_TEXT DO NOT send notifications to: The category within the notification code (NULL: none / no restriction) * @return array Topic ID (may be NULL), and whether a hidden post has been made */ function _helper_make_post_forum_topic($this_ref, $forum_name, $topic_identifier, $member_id, $post_title, $post, $content_title, $topic_identifier_encapsulation_prefix, $content_url, $time, $ip, $validated, $topic_validated, $skip_post_checks, $poster_name_if_guest, $parent_id, $staff_only, $no_notify_for__notification_code, $no_notify_for__code_category) { if (is_null($time)) { $time = time(); } if (is_null($ip)) { $ip = get_ip_address(); } require_code('comcode_check'); check_comcode($post, NULL, false, NULL, true); require_code('ocf_topics'); require_code('ocf_posts'); //require_code('ocf_forums'); require_lang('ocf'); require_code('ocf_posts_action'); require_code('ocf_posts_action2'); if (!is_integer($forum_name)) { $forum_id = $this_ref->forum_id_from_name($forum_name); if (is_null($forum_id)) { warn_exit(do_lang_tempcode('MISSING_FORUM', escape_html($forum_name))); } } else { $forum_id = (int) $forum_name; } $topic_id = $this_ref->find_topic_id_for_topic_identifier($forum_name, $topic_identifier); $update_caching = false; $support_attachments = false; if (!running_script('stress_test_loader') && get_page_name() != 'admin_import') { $update_caching = true; $support_attachments = true; } if (is_null($topic_id)) { $is_starter = true; require_code('ocf_topics_action'); $topic_id = ocf_make_topic($forum_id, $topic_identifier_encapsulation_prefix . ': #' . $topic_identifier, '', $topic_validated, 1, 0, 0, 0, NULL, NULL, false, 0, NULL, $content_url); if (strpos($topic_identifier, ':') !== false) { // Sync comment_posted ones to also monitor the forum ones; no need for opposite way as comment ones already trigger forum ones $start = 0; $max = 300; require_code('notifications'); $ob = _get_notification_ob_for_code('comment_posted'); do { list($members, $possibly_has_more) = $ob->list_members_who_have_enabled('comment_posted', $topic_identifier, NULL, $start, $max); foreach ($members as $to_member_id => $setting) { enable_notifications('ocf_topic', strval($topic_id), $to_member_id); } $start += $max; } while ($possibly_has_more); } // Make spacer post if (!is_null($content_url)) { $spacer_title = $content_title; $home_link = hyperlink($content_url, escape_html($content_title)); $spacer_post = '[semihtml]' . do_lang('SPACER_POST', $home_link->evaluate(), '', '', get_site_default_lang()) . '[/semihtml]'; ocf_make_post($topic_id, $spacer_title, $spacer_post, 0, true, 1, 0, do_lang('SYSTEM'), $ip, $time, db_get_first_id(), NULL, NULL, NULL, false, $update_caching, $forum_id, $support_attachments, $content_title, 0, NULL, false, false, false, false); $is_starter = false; } $is_new = true; } else { $is_starter = false; $is_new = false; } $GLOBALS['LAST_TOPIC_ID'] = $topic_id; $GLOBALS['LAST_TOPIC_IS_NEW'] = $is_new; if ($post == '') { return array(NULL, false); } ocf_check_post($post, $topic_id, $member_id); $poster_name = $poster_name_if_guest; if ($poster_name == '') { $poster_name = $this_ref->get_username($member_id); } $post_id = ocf_make_post($topic_id, $post_title, $post, 0, $is_starter, $validated, 0, $poster_name, $ip, $time, $member_id, $staff_only ? $GLOBALS['FORUM_DRIVER']->get_guest_id() : NULL, NULL, NULL, false, $update_caching, $forum_id, $support_attachments, $content_title, 0, NULL, false, $skip_post_checks, false, false, $parent_id); $GLOBALS['LAST_POST_ID'] = $post_id; if ($is_new) { // Broken cache now for the rest of this page view - fix by flushing global $TOPIC_IDENTIFIERS_TO_IDS; $TOPIC_IDENTIFIERS_TO_IDS = array(); } // Send out notifications $_url = build_url(array('page' => 'topicview', 'type' => 'findpost', 'id' => $post_id), 'forum', NULL, false, false, true, 'post_' . strval($post_id)); $url = $_url->evaluate(); ocf_send_topic_notification($url, $topic_id, $forum_id, $member_id, $is_new, $post, $content_title, NULL, false, $no_notify_for__notification_code, $no_notify_for__code_category); $is_hidden = false; if (!running_script('stress_test_loader') && get_page_name() != 'admin_import') { $validated_actual = $this_ref->connection->query_value('f_posts', 'p_validated', array('id' => $post_id)); if ($validated_actual == 0) { require_code('site'); attach_message(do_lang_tempcode('SUBMIT_UNVALIDATED'), 'inform'); $is_hidden = true; } } return array($topic_id, $is_hidden); }
/** * Adds a news entry to the database, and send out the news to any RSS cloud listeners. * * @param SHORT_TEXT The news title * @param LONG_TEXT The news summary (or if not an article, the full news) * @param ?ID_TEXT The news author (possibly, a link to an existing author in the system, but does not need to be) (NULL: current username) * @param BINARY Whether the news has been validated * @param BINARY Whether the news may be rated * @param SHORT_INTEGER Whether comments are allowed (0=no, 1=yes, 2=review style) * @param BINARY Whether the news may have trackbacks * @param LONG_TEXT Notes for the news * @param LONG_TEXT The news entry (blank means no entry) * @param ?AUTO_LINK The primary news category (NULL: personal) * @param ?array The IDs of the news categories that this is in (NULL: none) * @param ?TIME The time of submission (NULL: now) * @param ?MEMBER The news submitter (NULL: current member) * @param integer The number of views the article has had * @param ?TIME The edit date (NULL: never) * @param ?AUTO_LINK Force an ID (NULL: don't force an ID) * @param URLPATH URL to the image for the news entry (blank: use cat image) * @return AUTO_LINK The ID of the news just added */ function add_news($title, $news, $author = NULL, $validated = 1, $allow_rating = 1, $allow_comments = 1, $allow_trackbacks = 1, $notes = '', $news_article = '', $main_news_category = NULL, $news_category = NULL, $time = NULL, $submitter = NULL, $views = 0, $edit_date = NULL, $id = NULL, $image = '') { if (is_null($author)) { $author = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); } if (is_null($news_category)) { $news_category = array(); } if (is_null($time)) { $time = time(); } if (is_null($submitter)) { $submitter = get_member(); } $already_created_personal_category = false; require_code('comcode_check'); check_comcode($news_article, NULL, false, NULL, true); if (is_null($main_news_category)) { $main_news_category_id = $GLOBALS['SITE_DB']->query_value_null_ok('news_categories', 'id', array('nc_owner' => $submitter)); if (is_null($main_news_category_id)) { if (!has_specific_permission(get_member(), 'have_personal_category', 'cms_news')) { fatal_exit(do_lang_tempcode('INTERNAL_ERROR')); } $p_nc_title = insert_lang(do_lang('MEMBER_CATEGORY', $GLOBALS['FORUM_DRIVER']->get_username($submitter)), 2); $main_news_category_id = $GLOBALS['SITE_DB']->query_insert('news_categories', array('nc_title' => $p_nc_title, 'nc_img' => 'newscats/community', 'notes' => '', 'nc_owner' => $submitter), true); $already_created_personal_category = true; $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); foreach (array_keys($groups) as $group_id) { $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'news', 'category_name' => strval($main_news_category_id), 'group_id' => $group_id)); } } } else { $main_news_category_id = $main_news_category; } if (!addon_installed('unvalidated')) { $validated = 1; } $map = array('news_image' => $image, 'edit_date' => $edit_date, 'news_category' => $main_news_category_id, 'news_views' => $views, 'news_article' => 0, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'submitter' => $submitter, 'validated' => $validated, 'date_and_time' => $time, 'title' => insert_lang_comcode($title, 1), 'news' => insert_lang_comcode($news, 1), 'author' => $author); if (!is_null($id)) { $map['id'] = $id; } $id = $GLOBALS['SITE_DB']->query_insert('news', $map, true); if (!is_null($news_category)) { $news_category = array_unique($news_category); foreach ($news_category as $value) { if (is_null($value) && !$already_created_personal_category) { $p_nc_title = insert_lang(do_lang('MEMBER_CATEGORY', $GLOBALS['FORUM_DRIVER']->get_username($submitter)), 2); $news_category_id = $GLOBALS['SITE_DB']->query_insert('news_categories', array('nc_title' => $p_nc_title, 'nc_img' => 'newscats/community', 'notes' => '', 'nc_owner' => $submitter), true); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); foreach (array_keys($groups) as $group_id) { $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'news', 'category_name' => strval($news_category_id), 'group_id' => $group_id)); } } else { $news_category_id = $value; } if (is_null($news_category_id)) { continue; } // Double selected $GLOBALS['SITE_DB']->query_insert('news_category_entries', array('news_entry' => $id, 'news_entry_category' => $news_category_id)); } } require_code('attachments2'); $map = array('news_article' => insert_lang_comcode_attachments(2, $news_article, 'news', strval($id))); $GLOBALS['SITE_DB']->query_update('news', $map, array('id' => $id), '', 1); log_it('ADD_NEWS', strval($id), $title); if (function_exists('xmlrpc_encode')) { if (function_exists('set_time_limit')) { @set_time_limit(0); } // Send out on RSS cloud $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'news_rss_cloud WHERE register_time<' . strval(time() - 25 * 60 * 60)); $start = 0; do { $listeners = $GLOBALS['SITE_DB']->query_select('news_rss_cloud', array('*'), NULL, '', 100, $start); foreach ($listeners as $listener) { $data = $listener['watching_channel']; if ($listener['rem_protocol'] == 'xml-rpc') { $request = xmlrpc_encode_request($listener['rem_procedure'], $data); $length = strlen($request); $_length = strval($length); $packet = <<<END POST /{$listener['rem_path']} HTTP/1.0 Host: {$listener['rem_ip']} Content-Type: text/xml Content-length: {$_length} {$request} END; } $errno = 0; $errstr = ''; $mysock = @fsockopen($listener['rem_ip'], $listener['rem_port'], $errno, $errstr, 6.0); if ($mysock !== false) { @fwrite($mysock, $packet); @fclose($mysock); } $start += 100; } } while (array_key_exists(0, $listeners)); } require_code('seo2'); seo_meta_set_for_implicit('news', strval($id), array($title, $news == '' ? $news_article : $news), $news == '' ? $news_article : $news); // News article could be used, but it's probably better to go for the summary only to avoid crap if ($validated == 1) { decache('main_news'); decache('side_news'); decache('side_news_archive'); decache('bottom_news'); dispatch_news_notification($id, $title, $main_news_category_id); } if ($validated == 1 && get_option('site_closed') == '0' && ocp_srv('HTTP_HOST') != '127.0.0.1' && ocp_srv('HTTP_HOST') != 'localhost' && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'news', strval($main_news_category_id))) { $_ping_url = str_replace('{url}', urlencode(get_base_url()), str_replace('{rss}', urlencode(find_script('backend') . '?type=rss&mode=news'), str_replace('{title}', urlencode(get_site_name()), get_option('ping_url')))); $ping_urls = explode(chr(10), $_ping_url); foreach ($ping_urls as $ping_url) { $ping_url = trim($ping_url); if ($ping_url != '') { http_download_file($ping_url, NULL, false); } } } return $id; }
/** * Adds an entry to the specified catalogue. * * @param AUTO_LINK The ID of the category that the entry is in * @param BINARY Whether the entry has been validated * @param LONG_TEXT Hidden notes pertaining to the entry * @param BINARY Whether the entry may be rated * @param SHORT_INTEGER Whether comments are allowed (0=no, 1=yes, 2=review style) * @param BINARY Whether the entry may be trackbacked * @param array A map of field IDs, to values, that defines the entries settings * @param ?TIME The time the entry was added (NULL: now) * @param ?MEMBER The entries submitter (NULL: current user) * @param ?TIME The edit time (NULL: never) * @param integer The number of views * @param ?AUTO_LINK Force an ID (NULL: don't force an ID) * @return AUTO_LINK The ID of the newly added entry */ function actual_add_catalogue_entry($category_id, $validated, $notes, $allow_rating, $allow_comments, $allow_trackbacks, $map, $time = NULL, $submitter = NULL, $edit_date = NULL, $views = 0, $id = NULL) { if (is_null($time)) { $time = time(); } if (is_null($submitter)) { $submitter = get_member(); } $catalogue_name = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'c_name', array('id' => $category_id)); $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => $catalogue_name))); $_fields = list_to_map('id', $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('id', 'cf_type'), array('c_name' => $catalogue_name))); $fields = collapse_2d_complexity('id', 'cf_type', $_fields); require_code('comcode_check'); require_code('fields'); if (!addon_installed('unvalidated')) { $validated = 1; } $imap = array('c_name' => $catalogue_name, 'ce_edit_date' => $edit_date, 'cc_id' => $category_id, 'ce_last_moved' => time(), 'ce_submitter' => $submitter, 'ce_add_date' => $time, 'ce_views' => $views, 'ce_views_prior' => $views, 'ce_validated' => $validated, 'notes' => $notes, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks); if (!is_null($id)) { $imap['id'] = $id; } $val = mixed(); foreach ($map as $field_id => $val) { $type = $fields[$field_id]; $ob = get_fields_hook($type); list($raw_type) = $ob->get_field_value_row_bits($_fields[$field_id]); if (strpos($raw_type, '_trans') !== false) { check_comcode($val); } } $id = $GLOBALS['SITE_DB']->query_insert('catalogue_entries', $imap, true); $title = NULL; foreach ($map as $field_id => $val) { if ($val == STRING_MAGIC_NULL) { $val = ''; } if (is_null($title)) { $title = $val; } $type = $fields[$field_id]; $ob = get_fields_hook($type); list($raw_type, , $sup_table_name) = $ob->get_field_value_row_bits($_fields[$field_id]); if (strpos($raw_type, '_trans') !== false) { if ($type == 'posting_field') { require_code('attachments2'); $val = insert_lang_comcode_attachments(3, $val, 'catalogue_entry', strval($id)); } else { $val = insert_lang_comcode($val, 3); } } if ($sup_table_name == 'short') { $val = substr($val, 0, 255); } if ($sup_table_name == 'float') { $smap = array('cf_id' => $field_id, 'ce_id' => $id, 'cv_value' => is_null($val) || $val == '' ? NULL : floatval($val)); } elseif ($sup_table_name == 'integer') { $smap = array('cf_id' => $field_id, 'ce_id' => $id, 'cv_value' => is_null($val) || $val == '' ? NULL : intval($val)); } elseif ($sup_table_name == 'short') { $smap = array('cf_id' => $field_id, 'ce_id' => $id, 'cv_value' => substr($val, 0, 255)); } else { $smap = array('cf_id' => $field_id, 'ce_id' => $id, 'cv_value' => $val); } $GLOBALS['SITE_DB']->query_insert('catalogue_efv_' . $sup_table_name, $smap); } require_code('seo2'); seo_meta_set_for_implicit('catalogue_entry', strval($id), $map, ''); calculate_category_child_count_cache($category_id); if ($catalogue_name[0] != '_') { if ($validated == 1) { require_lang('catalogues'); require_code('notifications'); $subject = do_lang('CATALOGUE_ENTRY_NOTIFICATION_MAIL_SUBJECT', get_site_name(), strip_comcode($title), array($catalogue_title)); $self_url = build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $id), get_module_zone('catalogues'), NULL, false, false, true); $mail = do_lang('CATALOGUE_ENTRY_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape(strip_comcode($title)), array(comcode_escape($self_url->evaluate()), comcode_escape($catalogue_title))); dispatch_notification('catalogue_entry__' . $catalogue_name, strval($id), $subject, $mail); } log_it('ADD_CATALOGUE_ENTRY', strval($id), $title); } decache('main_cc_embed'); decache('main_recent_cc_entries'); return $id; }