/** * Standard import function. Note that this is designed for a very popular phpBB mod, and will exit silently if the mod hasn't been installed. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_post_files($db, $table_prefix, $file_base) { global $STRICT_FILE; require_code('attachments2'); require_code('attachments3'); $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'attachments', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('post_files', strval($row['attachment_id']))) { continue; } $post_id = $db->query_value_null_ok('posts', 'post_id', array('attachment_id' => $row['attachment_id'])); $post_row = array(); if (!is_null($post_id)) { $post_id = import_id_remap_get('post', $post_id); $post_row = $GLOBALS['FORUM_DB']->query_select('f_posts p LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON p.p_post=t.id', array('p_time', 'text_original', 'p_poster', 'p_post'), array('p.id' => $post_id), '', 1); } if (!array_key_exists(0, $post_row)) { import_id_remap_put('post_files', strval($row['attachment_id']), 1); continue; // Orphaned post } $post = $post_row[0]['text_original']; $lang_id = $post_row[0]['p_post']; $member_id = import_id_remap_get('member', strval($row['user_id']), true); if (is_null($member_id)) { $member_id = $post_row[0]['p_poster']; } $url = $this->data_to_disk($row['file_contents'], $row['file_name'], 'attachments', false); $thumb_url = ''; $a_id = $GLOBALS['SITE_DB']->query_insert('attachments', array('a_member_id' => $member_id, 'a_file_size' => strlen($row['file_contents']), 'a_url' => $url, 'a_thumb_url' => $thumb_url, 'a_original_filename' => $row['file_name'], 'a_num_downloads' => $row['downloads'], 'a_last_downloaded_time' => NULL, 'a_add_time' => strtotime($row['upload_date']), 'a_description' => ''), true); $GLOBALS['SITE_DB']->query_insert('attachment_refs', array('r_referer_type' => 'ocf_post', 'r_referer_id' => $post_id, 'a_id' => $a_id)); $post .= "\n\n" . '[attachment=""]' . strval($a_id) . '[/attachment]'; ocf_over_msn(); update_lang_comcode_attachments($lang_id, $post, 'ocf_post', strval($post_id)); ocf_over_local(); import_id_remap_put('post_files', strval($row['attachment_id']), 1); } $row_start += 200; } while (count($rows) > 0); }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_post_files($db, $table_prefix, $file_base) { global $STRICT_FILE; require_code('attachments2'); require_code('attachments3'); $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'attachments a JOIN ' . $table_prefix . 'messages m ON a.id_msg=m.id_msg WHERE a.id_msg<>0' . (can_arbitrary_groupby() ? ' GROUP BY id_attach' : ''), 200, $row_start); $rows = remove_duplicate_rows($rows, 'id_attach'); foreach ($rows as $row) { if (substr($row['filename'], -5) == 'thumb') { continue; } if (import_check_if_imported('post_files', strval($row['id_attach']))) { continue; } $post_id = import_id_remap_get('post', strval($row['id_msg'])); $post_row = $GLOBALS['FORUM_DB']->query_select('f_posts p LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON p.p_post=t.id', array('p_time', 'text_original', 'p_poster', 'p_post'), array('p.id' => $post_id), '', 1); if (!array_key_exists(0, $post_row)) { import_id_remap_put('post_files', strval($row['id_attach']), 1); continue; // Orphaned post } $post = $post_row[0]['text_original']; $lang_id = $post_row[0]['p_post']; $member_id = $post_row[0]['p_poster']; $ext = '.' . $row['fileext']; $filename = $row['id_attach'] . '_' . $row['file_hash']; $url = $this->data_to_disk('', $filename, 'attachments', $db, $table_prefix, $row['filename'], $file_base, $row['id_attach'], $ext); $a_id = $GLOBALS['SITE_DB']->query_insert('attachments', array('a_member_id' => $member_id, 'a_file_size' => $row['size'], 'a_url' => $url, 'a_thumb_url' => $url, 'a_original_filename' => $row['filename'], 'a_num_downloads' => $row['downloads'], 'a_last_downloaded_time' => NULL, 'a_add_time' => $row['poster_time'], 'a_description' => ''), true); $GLOBALS['SITE_DB']->query_insert('attachment_refs', array('r_referer_type' => 'ocf_post', 'r_referer_id' => strval($post_id), 'a_id' => $a_id)); $post .= "\n\n" . '[attachment]' . strval($a_id) . '[/attachment]'; update_lang_comcode_attachments($lang_id, $post, 'ocf_post', strval($post_id)); import_id_remap_put('post_files', strval($row['id_attach']), 1); } $row_start += 200; } while (count($rows) > 0); }
/** * Edit a CEDI page * * @param AUTO_LINK The page ID * @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 SHORT_TEXT Meta keywords * @param LONG_TEXT Meta description * @param ?MEMBER The member doing the action (NULL: current member) */ function cedi_edit_page($id, $title, $description, $notes, $hide_posts, $meta_keywords, $meta_description, $member = NULL) { if (is_null($member)) { $member = get_member(); } $pages = $GLOBALS['SITE_DB']->query_select('seedy_pages', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $pages)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $page = $pages[0]; $_description = $page['description']; $_title = $page['title']; $GLOBALS['SITE_DB']->query_update('seedy_children', array('title' => $title), array('title' => get_translated_text($_title), 'child_id' => $id)); require_code('attachments2'); require_code('attachments3'); $GLOBALS['SITE_DB']->query_update('seedy_pages', array('hide_posts' => $hide_posts, 'description' => update_lang_comcode_attachments($_description, $description, 'cedi_page', strval($id), NULL, true), 'notes' => $notes, 'title' => lang_remap($_title, $title)), array('id' => $id), '', 1); $GLOBALS['SITE_DB']->query_insert('seedy_changes', array('the_action' => 'CEDI_EDIT_PAGE', 'the_page' => $id, 'date_and_time' => time(), 'ip' => get_ip_address(), 'the_user' => $member)); require_code('seo2'); seo_meta_set_for_explicit('seedy_page', strval($id), $meta_keywords, $meta_description); dispatch_cedi_page_notification($id, 'EDIT'); }
/** * Standard import function. Note that this is designed for a very popular phpBB mod, and will exit silently if the mod hasn't been installed. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_post_files($db, $table_prefix, $file_base) { global $STRICT_FILE; require_code('attachments2'); require_code('attachments3'); $options = $db->query('SELECT * FROM ' . $table_prefix . 'attachments_config WHERE ' . db_string_equal_to('config_name', 'upload_dir') . ' OR ' . db_string_equal_to('config_name', 'max_attachments') . ' OR ' . db_string_equal_to('config_name', 'use_gd2'), NULL, NULL, true); if (is_null($options)) { return; } $upload_dir = $options[0]['config_value']; $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'attachments a LEFT JOIN ' . $table_prefix . 'attachments_desc d ON a.attach_id=d.attach_id ORDER BY attach_id', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('post_files', strval($row['attach_id']))) { continue; } if ($row['post_id'] == 0) { $post_id = import_id_remap_get('pt', strval($row['privmsgs_id'])); } else { $post_id = import_id_remap_get('post', strval($row['post_id'])); } $post_row = $GLOBALS['FORUM_DB']->query_select('f_posts p LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON p.p_post=t.id', array('p_time', 'text_original', 'p_poster', 'p_post'), array('p.id' => $post_id), '', 1); if (!array_key_exists(0, $post_row)) { import_id_remap_put('post_files', strval($row['attach_id']), 1); continue; // Orphaned post } $post = $post_row[0]['text_original']; $lang_id = $post_row[0]['p_post']; $member_id = import_id_remap_get('member', strval($row['user_id_1']), true); if (is_null($member_id)) { $member_id = $post_row[0]['p_poster']; } $source_path = $file_base . '/' . $upload_dir . '/' . $row['physical_filename']; $new_filename = find_derivative_filename('attachments', $row['physical_filename']); $target_path = get_custom_file_base() . '/uploads/attachments/' . $new_filename; if (@rename($source_path, $target_path)) { sync_file($target_path); $url = 'uploads/attachments/' . urlencode($new_filename); $thumb_url = ''; $a_id = $GLOBALS['SITE_DB']->query_insert('attachments', array('a_member_id' => $member_id, 'a_file_size' => $row['filesize'], 'a_url' => $url, 'a_thumb_url' => $thumb_url, 'a_original_filename' => $row['real_filename'], 'a_num_downloads' => $row['download_count'], 'a_last_downloaded_time' => NULL, 'a_add_time' => $row['filetime'], 'a_description' => ''), true); $GLOBALS['SITE_DB']->query_insert('attachment_refs', array('r_referer_type' => 'ocf_post', 'r_referer_id' => strval($post_id), 'a_id' => $a_id)); $post .= "\n\n" . '[attachment="' . $row['comment'] . '"]' . strval($a_id) . '[/attachment]'; ocf_over_msn(); update_lang_comcode_attachments($lang_id, $post, 'ocf_post', strval($post_id)); ocf_over_local(); } import_id_remap_put('post_files', strval($row['attach_id']), 1); } $row_start += 200; } while (count($rows) > 0); }
/** * Edit a news entry. * * @param AUTO_LINK The ID of the news to edit * @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) * @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: do not change) * @param SHORT_TEXT Meta keywords * @param LONG_TEXT Meta description * @param ?URLPATH URL to the image for the news entry (blank: use cat image) (NULL: don't delete existing) * @param ?TIME Recorded add time (NULL: leave alone) */ function edit_news($id, $title, $news, $author, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $news_article, $main_news_category, $news_category, $meta_keywords, $meta_description, $image, $time = NULL) { $rows = $GLOBALS['SITE_DB']->query_select('news', array('title', 'news', 'news_article', 'submitter'), array('id' => $id), '', 1); $_title = $rows[0]['title']; $_news = $rows[0]['news']; $_news_article = $rows[0]['news_article']; require_code('urls2'); suggest_new_idmoniker_for('news', 'view', strval($id), $title); require_code('attachments2'); require_code('attachments3'); if (!addon_installed('unvalidated')) { $validated = 1; } require_code('submit'); $just_validated = !content_validated('news', strval($id)) && $validated == 1; if ($just_validated) { send_content_validated_notification('news', strval($id)); } $map = array('news_category' => $main_news_category, 'news_article' => update_lang_comcode_attachments($_news_article, $news_article, 'news', strval($id), NULL, false, $rows[0]['submitter']), 'edit_date' => time(), 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'validated' => $validated, 'title' => lang_remap_comcode($_title, $title), 'news' => lang_remap_comcode($_news, $news), 'author' => $author); if (!is_null($time)) { $map['date_and_time'] = $time; } if (!is_null($image)) { $map['news_image'] = $image; require_code('files2'); delete_upload('uploads/grepimages', 'news', 'news_image', 'id', $id, $image); } /*$news_categories=$news_category[0]; foreach ($news_category as $key=>$value) { if($key>0) $news_categories.=','.$value; }*/ if (!is_null($news_category)) { $GLOBALS['SITE_DB']->query_delete('news_category_entries', array('news_entry' => $id)); foreach ($news_category as $value) { $GLOBALS['SITE_DB']->query_insert('news_category_entries', array('news_entry' => $id, 'news_entry_category' => $value)); } } log_it('EDIT_NEWS', strval($id), $title); $GLOBALS['SITE_DB']->query_update('news', $map, array('id' => $id), '', 1); $self_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $id), get_module_zone('news'), NULL, false, false, true); if ($just_validated) { dispatch_news_notification($id, $title, $main_news_category); } require_code('seo2'); seo_meta_set_for_explicit('news', strval($id), $meta_keywords, $meta_description); decache('main_news'); decache('side_news'); decache('side_news_archive'); decache('bottom_news'); if ($validated == 1 && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'news', strval($main_news_category))) { $_ping_url = str_replace('{url}', urlencode(get_base_url()), str_replace('{rss}', urlencode(find_script('backend')), str_replace('{title}', urlencode(get_site_name()), get_option('ping_url')))); $ping_urls = explode(',', $_ping_url); foreach ($ping_urls as $ping_url) { $ping_url = trim($ping_url); if ($ping_url != '') { http_download_file($ping_url, NULL, false); } } } require_code('feedback'); update_spacer_post($allow_comments != 0, 'news', strval($id), $self_url, $title, get_value('comment_forum__news')); }
/** * Edit a calendar event. * * @param AUTO_LINK The ID of the event * @param ?AUTO_LINK The event type (NULL: default) * @param SHORT_TEXT The recurrence code * @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 SHORT_TEXT Meta keywords * @param LONG_TEXT Meta description * @param BINARY Whether the download has been validated * @param BINARY Whether the download may be rated * @param SHORT_INTEGER Whether comments are allowed (0=no, 1=yes, 2=review style) * @param BINARY Whether the download may be trackbacked * @param LONG_TEXT Hidden notes pertaining to the download */ function edit_calendar_event($id, $type, $recurrence, $recurrences, $seg_recurrences, $title, $content, $priority, $is_public, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, $timezone, $do_timezone_conv, $meta_keywords, $meta_description, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes) { $myrows = $GLOBALS['SITE_DB']->query_select('calendar_events', array('e_title', 'e_content', 'e_submitter'), array('id' => $id), '', 1); $myrow = $myrows[0]; require_code('urls2'); suggest_new_idmoniker_for('calendar', 'view', strval($id), $title); require_code('seo2'); seo_meta_set_for_explicit('event', strval($id), $meta_keywords, $meta_description); require_code('attachments2'); require_code('attachments3'); if (!addon_installed('unvalidated')) { $validated = 1; } require_code('submit'); $just_validated = !content_validated('event', strval($id)) && $validated == 1; if ($just_validated) { send_content_validated_notification('event', strval($id)); } $GLOBALS['SITE_DB']->query_update('calendar_events', array('e_title' => lang_remap($myrow['e_title'], $title), 'e_content' => update_lang_comcode_attachments($myrow['e_content'], $content, 'calendar', strval($id), NULL, false, $myrow['e_submitter']), 'e_edit_date' => time(), '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), array('id' => $id), '', 1); $self_url = build_url(array('page' => 'calendar', 'type' => 'view', 'id' => $id), get_module_zone('calendar'), NULL, false, false, true); if ($just_validated) { require_lang('calendar'); require_code('notifications'); $subject = do_lang('CALENDAR_EVENT_NOTIFICATION_MAIL_SUBJECT', get_site_name(), strip_comcode($title)); $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); } decache('side_calendar'); require_code('feedback'); update_spacer_post($allow_comments != 0, 'events', strval($id), $self_url, $title, get_value('comment_forum__calendar')); log_it('EDIT_CALENDAR_EVENT', strval($id), $title); }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_post_files($db, $table_prefix, $file_base) { global $STRICT_FILE; require_code('attachments2'); require_code('attachments3'); require_code('images'); $row_start = 0; $select = either_param('importer') == 'ipb1' ? 'pid,attach_id,attach_file,attach_hits,post_date' : 'pid,post_date'; $rows = array(); do { $rows = $db->query('SELECT ' . $select . ' FROM ' . $table_prefix . 'posts ORDER BY pid', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('post_files', strval($row['pid']))) { continue; } $post_id = import_id_remap_get('post', strval($row['pid']), true); if (is_null($post_id)) { continue; } $post_row = $GLOBALS['FORUM_DB']->query_select('f_posts p LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON p.p_post=t.id', array('p_time', 'text_original', 'p_poster', 'p_post'), array('p.id' => $post_id), '', 1); if (!array_key_exists(0, $post_row)) { import_id_remap_put('post_files', strval($row['pid']), 1); continue; // Orphaned post } $post = $post_row[0]['text_original']; $lang_id = $post_row[0]['p_post']; $member_id = import_id_remap_get('member', $post_row[0]['p_poster']); $post_date = $post_row[0]['p_time']; if (either_param('importer') == 'ipb1') { $has_attachment = false; if ($row['attach_id'] != '') { $target_path = get_custom_file_base() . '/uploads/attachments/' . $row['attach_id']; if (file_exists(get_custom_file_base() . '/uploads/attachments/' . $row['attach_id']) || @rename($file_base . '/uploads/' . $row['attach_id'], $target_path)) { $url = 'uploads/attachments/' . $row['attach_id']; sync_file($url); $thumb_url = ''; if (is_image($target_path)) { /* require_code('images'); $thumb_url='uploads/attachments_thumbs/'.$row['attach_id']; convert_image($url,$thumb_url,-1,-1,intval(get_option('thumb_width')),false,NULL,true);*/ } $_a_id = $GLOBALS['SITE_DB']->query_insert('attachments', array('a_member_id' => $member_id, 'a_file_size' => @filesize($target_path), 'a_url' => $url, 'a_thumb_url' => $thumb_url, 'a_original_filename' => $row['attach_file'], 'a_num_downloads' => $row['attach_hits'], 'a_last_downloaded_time' => NULL, 'a_add_time' => $row['post_date'], 'a_description' => ''), true); $has_attachment = true; } else { if ($STRICT_FILE) { warn_exit(do_lang_tempcode('MISSING_ATTACHMENT', $row['attach_location'])); } } } } else { if (either_param('importer') == 'ipb1') { $attachments = $db->query('SELECT * FROM ' . $table_prefix . 'attachments WHERE attach_pid=' . strval($row['pid']) . ' AND attach_approved=1'); } else { $attachments = $db->query('SELECT * FROM ' . $table_prefix . 'attachments WHERE attach_rel_id=' . strval($row['pid']) . ' AND ' . db_string_equal_to('attach_rel_module', 'post')); } $i = 0; $a_id = array(); foreach ($attachments as $attachment) { $target_path = get_custom_file_base() . '/uploads/attachments/' . $attachment['attach_location']; if (file_exists(get_custom_file_base() . '/uploads/attachments/' . $attachment['attach_location']) || @rename($file_base . '/uploads/' . $attachment['attach_location'], $target_path)) { $url = 'uploads/attachments/' . $attachment['attach_location']; sync_file($url); $thumb_url = ''; if (is_image($target_path)) { /* require_code('images'); $thumb_url='uploads/attachments_thumbs/'.$attachment['attach_location']; convert_image($url,$thumb_url,-1,-1,intval(get_option('thumb_width')),false,NULL,true);*/ } $a_id[$i] = $GLOBALS['SITE_DB']->query_insert('attachments', array('a_member_id' => $member_id, 'a_file_size' => $attachment['attach_filesize'], 'a_url' => $url, 'a_thumb_url' => $thumb_url, 'a_original_filename' => $attachment['attach_file'], 'a_num_downloads' => $attachment['attach_hits'], 'a_last_downloaded_time' => NULL, 'a_add_time' => $post_date, 'a_description' => ''), true); $has_attachment = true; } else { if ($STRICT_FILE) { warn_exit(do_lang_tempcode('MISSING_ATTACHMENT', $attachment['attach_location'])); } } $i++; } } if (either_param('importer') == 'ipb1') { if ($has_attachment) { $GLOBALS['SITE_DB']->query_insert('attachment_refs', array('r_referer_type' => 'ocf_post', 'r_referer_id' => strval($post_id), 'a_id' => $_a_id)); $post .= "\n\n" . '[attachment]' . strval($_a_id) . '[/attachment]'; ocf_over_msn(); update_lang_comcode_attachments($lang_id, $post, 'ocf_post', strval($post_id)); ocf_over_local(); } } elseif (count($a_id) != 0) { $i = 0; foreach ($attachments as $attachment) { if (array_key_exists($i, $a_id)) { $GLOBALS['SITE_DB']->query_insert('attachment_refs', array('r_referer_type' => 'ocf_post', 'r_referer_id' => strval($post_id), 'a_id' => $a_id[$i])); $post .= "\n\n" . '[attachment]' . $a_id[$i] . '[/attachment]'; } $i++; } ocf_over_msn(); update_lang_comcode_attachments($lang_id, $post, 'ocf_post', strval($post_id)); ocf_over_local(); } import_id_remap_put('post_files', strval($row['pid']), 1); } $row_start += 200; } while (count($rows) > 0); }
/** * Edit a member's signature, and check validity. * * @param LONG_TEXT The new signature. * @param ?MEMBER The member (NULL: the current member). */ function ocf_member_choose_signature($new_signature, $member_id = NULL) { if (is_null($member_id)) { $member_id = get_member(); } $max_sig_length = ocf_get_member_best_group_property($member_id, 'max_sig_length_comcode'); if (ocp_mb_strlen($new_signature) > $max_sig_length) { warn_exit(make_string_tempcode(escape_html(do_lang('SIGNATURE_TOO_BIG')))); } $_signature = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_signature'); if (get_translated_text($_signature) == $new_signature) { return; } require_code('attachments2'); require_code('attachments3'); $GLOBALS['FORUM_DB']->query_update('f_members', array('m_signature' => update_lang_comcode_attachments($_signature, $new_signature, 'ocf_signature', strval($member_id), $GLOBALS['FORUM_DB'], false, $member_id)), array('id' => $member_id), '', 1); require_code('notifications'); dispatch_notification('ocf_choose_signature', NULL, do_lang('CHOOSE_SIGNATURE_SUBJECT', $GLOBALS['FORUM_DRIVER']->get_username($member_id), NULL, NULL, get_lang($member_id)), do_lang('CHOOSE_SIGNATURE_BODY', $new_signature, $GLOBALS['FORUM_DRIVER']->get_username($member_id), NULL, get_lang($member_id))); // Decache from run-time cache unset($GLOBALS['FORUM_DRIVER']->MEMBER_ROWS_CACHED[$member_id]); unset($GLOBALS['MEMBER_CACHE_FIELD_MAPPINGS'][$member_id]); }
/** * Edit a post. * * @param AUTO_LINK The ID of the post that we're editing. * @param BINARY Whether the post is validated. * @param SHORT_TEXT The title of the post (may be blank). * @param LONG_TEXT The post. * @param BINARY Whether to skip showing the posters signature in the post. * @param BINARY Whether the post is marked emphasised. * @param ?MEMBER The member that this post is intended solely for (NULL: none). * @param boolean Whether to show the post as edited. * @param boolean Whether to mark the topic as unread by those previous having read this post. * @param LONG_TEXT The reason for this action. * @param boolean Whether to check permissions. * @return AUTO_LINK The ID of the topic (whilst this could be known without calling this function, as we've gone to effort and grabbed it from the DB, it might turn out useful for something). */ function ocf_edit_post($post_id, $validated, $title, $post, $skip_sig, $is_emphasised, $intended_solely_for, $show_as_edited, $mark_as_unread, $reason, $check_perms = true) { $post_info = $GLOBALS['FORUM_DB']->query_select('f_posts', array('p_topic_id', 'p_time', 'p_post', 'p_poster', 'p_cache_forum_id'), array('id' => $post_id)); if (!array_key_exists(0, $post_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $_postdetails = $post_info[0]['p_post']; $post_owner = $post_info[0]['p_poster']; $forum_id = $post_info[0]['p_cache_forum_id']; $topic_id = $post_info[0]['p_topic_id']; $update = array(); require_code('ocf_posts_action'); require_code('ocf_posts'); ocf_check_post($post); if ($check_perms) { if (!ocf_may_edit_post_by($post_owner, $forum_id)) { access_denied('I_ERROR'); } } if (is_null($validated) || $validated == 1) { if (!is_null($forum_id) && !has_specific_permission(get_member(), 'bypass_validation_lowrange_content', 'topics', array('forums', $forum_id))) { $validated = 0; } else { $validated = 1; } if ($mark_as_unread) { // $topic_info=$GLOBALS['FORUM_DB']->query_select('f_topics',array('t_cache_last_time'),array('id'=>$topic_id),'',1); // $seven_days_ago=time()-60*60*24*intval(get_option('post_history_days')); Can't be conditional, as we need the vforums to update, and they depend on t_cache_last_time. We can't just update t_cache_last_time for consistency // if ($topic_info[0]['t_cache_last_time']<$seven_days_ago) $GLOBALS['FORUM_DB']->query_update('f_topics', array('t_cache_last_time' => time(), 't_cache_last_post_id' => $post_id, 't_cache_last_title' => $title, 't_cache_last_username' => $GLOBALS['FORUM_DRIVER']->get_username($post_owner), 't_cache_last_member_id' => $post_owner), array('id' => $topic_id), '', 1); // $update['p_time']=time(); Not viable- would reorder topic. $GLOBALS['FORUM_DB']->query_delete('f_read_logs', array('l_topic_id' => $topic_id)); } } $edit_time = time(); // Save in history $GLOBALS['FORUM_DB']->query_insert('f_post_history', array('h_create_date_and_time' => $post_info[0]['p_time'], 'h_action_date_and_time' => $edit_time, 'h_owner_member_id' => $post_owner, 'h_alterer_member_id' => get_member(), 'h_post_id' => $post_id, 'h_topic_id' => $topic_id, 'h_before' => get_translated_text($_postdetails, $GLOBALS['FORUM_DB']), 'h_action' => 'EDIT_POST')); require_code('attachments2'); require_code('attachments3'); if (!addon_installed('unvalidated')) { $validated = 1; } $update = array_merge($update, array('p_title' => $title, 'p_post' => update_lang_comcode_attachments($_postdetails, $post, 'ocf_post', strval($post_id), $GLOBALS['FORUM_DB'], false, $post_owner), 'p_is_emphasised' => $is_emphasised, 'p_intended_solely_for' => $intended_solely_for, 'p_validated' => $validated, 'p_skip_sig' => $skip_sig)); if ($show_as_edited) { $update['p_last_edit_time'] = $edit_time; $update['p_last_edit_by'] = get_member(); } else { $update['p_last_edit_time'] = NULL; $update['p_last_edit_by'] = NULL; } $GLOBALS['FORUM_DB']->query_update('f_posts', $update, array('id' => $post_id), '', 1); // Update topic cacheing $info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_cache_first_post_id', 't_cache_first_title'), array('id' => $topic_id), '', 1); if (array_key_exists(0, $info) && $info[0]['t_cache_first_post_id'] == $post_id && $info[0]['t_cache_first_title'] != $title) { require_code('urls2'); suggest_new_idmoniker_for('topicview', 'misc', strval($topic_id), $title); $GLOBALS['FORUM_DB']->query_update('f_topics', array('t_cache_first_title' => $title), array('id' => $topic_id), '', 1); } require_code('ocf_general_action2'); ocf_mod_log_it('EDIT_POST', strval($post_id), $title, $reason); if (!is_null($forum_id)) { ocf_decache_ocp_blocks($forum_id); } return $topic_id; // We may want this }
/** * Edit the specified catalogue entry * * @param AUTO_LINK The ID of the entry being edited * @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 ?SHORT_TEXT Meta keywords for this resource (NULL: do not edit) * @param ?LONG_TEXT Meta description for this resource (NULL: do not edit) */ function actual_edit_catalogue_entry($id, $category_id, $validated, $notes, $allow_rating, $allow_comments, $allow_trackbacks, $map, $meta_keywords = '', $meta_description = '') { $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); $original_submitter = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'ce_submitter', array('id' => $id)); $old_category_id = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'cc_id', array('id' => $id)); if (!addon_installed('unvalidated')) { $validated = 1; } require_code('submit'); $was_validated = content_validated('catalogue_entry', strval($id)); $just_validated = !$was_validated && $validated == 1; if ($just_validated) { send_content_validated_notification('catalogue_entry', strval($id)); } $GLOBALS['SITE_DB']->query_update('catalogue_entries', array('ce_edit_date' => time(), 'cc_id' => $category_id, 'ce_validated' => $validated, 'notes' => $notes, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks), array('id' => $id), '', 1); require_code('fields'); $title = NULL; foreach ($map as $field_id => $val) { if (is_null($title)) { $title = $val; } $type = $fields[$field_id]; $ob = get_fields_hook($type); list(, , $sup_table_name) = $ob->get_field_value_row_bits($_fields[$field_id]); if (substr($sup_table_name, -6) == '_trans') { $_val = $GLOBALS['SITE_DB']->query_value_null_ok('catalogue_efv_' . $sup_table_name, 'cv_value', array('cf_id' => $field_id, 'ce_id' => $id)); if (is_null($_val)) { $_val = insert_lang_comcode($val, 3); } else { if ($type == 'posting_field') { require_code('attachments2'); require_code('attachments3'); $_val = update_lang_comcode_attachments($_val, $val, 'catalogue_entry', strval($id), NULL, false, $original_submitter); } else { $_val = lang_remap_comcode($_val, $val); } } $GLOBALS['SITE_DB']->query_update('catalogue_efv_' . $sup_table_name, array('cv_value' => $_val), array('cf_id' => $field_id, 'ce_id' => $id), '', 1); } else { if ($sup_table_name == 'float') { $smap = array('cv_value' => is_null($val) || $val == '' ? NULL : floatval($val)); } elseif ($sup_table_name == 'integer') { $smap = array('cv_value' => is_null($val) || $val == '' ? NULL : intval($val)); } else { $smap = array('cv_value' => $val); } $GLOBALS['SITE_DB']->query_update('catalogue_efv_' . $sup_table_name, $smap, array('cf_id' => $field_id, 'ce_id' => $id), '', 1); } } require_code('urls2'); suggest_new_idmoniker_for('catalogues', 'entry', strval($id), strip_comcode($title)); require_code('seo2'); seo_meta_set_for_explicit('catalogue_entry', strval($id), $meta_keywords, $meta_description); $self_url = build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $id), get_module_zone('catalogues'), NULL, false, false, true); if ($category_id != $old_category_id || $was_validated != ($validated == 1)) { calculate_category_child_count_cache($category_id); if ($category_id != $old_category_id) { calculate_category_child_count_cache($old_category_id); } } decache('main_cc_embed'); decache('main_recent_cc_entries'); if ($catalogue_name[0] != '_') { log_it('EDIT_CATALOGUE_ENTRY', strval($id), $title); if ($just_validated) { require_lang('catalogues'); require_code('notifications'); $subject = do_lang('CATALOGUE_ENTRY_NOTIFICATION_MAIL_SUBJECT', get_site_name(), strip_comcode($title), array($catalogue_title)); $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); } } require_code('feedback'); update_spacer_post($allow_comments != 0, 'catalogues', strval($id), $self_url, $title, get_value('comment_forum__catalogues__' . $catalogue_name)); }