/** * Edit a topic. * * @param ?AUTO_LINK The ID of the topic to edit (NULL: Private Topic). * @param ?SHORT_TEXT Description of the topic (NULL: do not change). * @param ?SHORT_TEXT The image code of the emoticon for the topic (NULL: do not change). * @param ?BINARY Whether the topic is validated (NULL: do not change). * @param ?BINARY Whether the topic is open (NULL: do not change). * @param ?BINARY Whether the topic is pinned (NULL: do not change). * @param ?BINARY Whether the topic is sunk (NULL: do not change). * @param ?BINARY Whether the topic is cascading (NULL: do not change). * @param LONG_TEXT The reason for this action. * @param ?string New title for the topic (NULL: do not change). * @param ?SHORT_TEXT Link related to the topic (e.g. link to view a ticket) (NULL: do not change). * @param boolean Whether to check permissions. */ function ocf_edit_topic($topic_id, $description = NULL, $emoticon = NULL, $validated = NULL, $open = NULL, $pinned = NULL, $sunk = NULL, $cascading = NULL, $reason = '', $title = NULL, $description_link = NULL, $check_perms = true) { $info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_pt_from', 't_pt_to', 't_cache_first_member_id', 't_cache_first_title', 't_forum_id', 't_cache_first_post_id'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $name = $info[0]['t_cache_first_title']; $forum_id = $info[0]['t_forum_id']; $update = array(); require_code('ocf_forums'); if ($check_perms) { if (!ocf_may_moderate_forum($forum_id)) { $pinned = 0; $sunk = 0; if ($info[0]['t_cache_first_member_id'] != get_member() || !has_specific_permission(get_member(), 'close_own_topics')) { $open = 1; } $cascading = 0; } if (!($info[0]['t_cache_first_member_id'] == get_member() && has_specific_permission(get_member(), 'close_own_topics'))) { require_code('ocf_topics'); if (!ocf_may_edit_topics_by($forum_id, get_member(), $info[0]['t_cache_first_member_id']) || $info[0]['t_pt_from'] != get_member() && $info[0]['t_pt_to'] != get_member() && !ocf_has_special_pt_access($topic_id) && !has_specific_permission(get_member(), 'view_other_pt') && is_null($forum_id)) { access_denied('I_ERROR'); } } if (!is_null($forum_id) && !has_specific_permission(get_member(), 'bypass_validation_midrange_content', 'topics', array('forums', $forum_id))) { $validated = NULL; } } if (!is_null($title)) { require_code('urls2'); suggest_new_idmoniker_for('topicview', 'misc', strval($topic_id), $title); } if (!is_null($description)) { $update['t_description'] = $description; } if (!is_null($description_link)) { $update['t_description_link'] = $description_link; } if (!is_null($emoticon)) { $update['t_emoticon'] = $emoticon; } if (!addon_installed('unvalidated')) { $validated = 1; } if (!is_null($validated)) { $update['t_validated'] = $validated; } if (!is_null($pinned)) { $update['t_pinned'] = $pinned; } if (!is_null($sunk)) { $update['t_sunk'] = $sunk; } if (!is_null($cascading)) { $update['t_cascading'] = $cascading; } if (!is_null($open)) { $update['t_is_open'] = $open; } if (!is_null($title) && $title != '') { $update['t_cache_first_title'] = $title; $GLOBALS['FORUM_DB']->query_update('f_posts', array('p_title' => $title), array('id' => $info[0]['t_cache_first_post_id']), '', 1); } require_code('submit'); $just_validated = !content_validated('topic', strval($topic_id)) && $validated == 1; if ($just_validated) { send_content_validated_notification('topic', strval($topic_id)); } $GLOBALS['FORUM_DB']->query_update('f_topics', $update, array('id' => $topic_id), '', 1); if (!is_null($title) && $title != '') { require_code('ocf_posts_action2'); ocf_force_update_forum_cacheing($forum_id, 0, 0); } require_code('ocf_general_action2'); ocf_mod_log_it('EDIT_TOPIC', strval($topic_id), $name, $reason); if (!is_null($forum_id)) { require_code('ocf_posts_action'); ocf_decache_ocp_blocks($forum_id); } else { decache('side_ocf_personal_topics'); decache('_new_pp'); } }
/** * Edit a download. * * @param AUTO_LINK The ID of the download to edit * @param AUTO_LINK The ID of the category the download is to be in * @param SHORT_TEXT The name of the download * @param URLPATH The URL to the download * @param LONG_TEXT The description of the download * @param ID_TEXT The author of the download (not necessarily same as the submitter) * @param LONG_TEXT The comments for the download * @param AUTO_LINK The out-mode-id (the ID of a download that this download is an old version of). Often people wonder why this is specified with the old version, and not the opposite with the new version - it is because statistically, we perceive more chance of downloads merging than splitting * @param integer The ordered number of the gallery image to use as the download representative image * @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 * @param SHORT_TEXT The downloads original filename (the URL may be obfuscated) * @param integer The file size of the download (we can't really detect this in real-time for remote URLs) * @param integer The cost of the download that members will have to pay to get it * @param BINARY Whether the submitter gets the points for the download (they are selling it) (otherwise they are just thrown out, which is an alternative model - one of enforcing community point building) * @param ?AUTO_LINK The licence to use (NULL: none) * @param SHORT_TEXT Meta keywords * @param LONG_TEXT Meta description */ function edit_download($id, $category_id, $name, $url, $description, $author, $comments, $out_mode_id, $default_pic, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $original_filename, $file_size, $cost, $submitter_gets_points, $licence, $meta_keywords, $meta_description) { require_code('urls2'); suggest_new_idmoniker_for('downloads', 'view', strval($id), $name); if ($file_size == 0 || url_is_local($url)) { if (url_is_local($url)) { $file_size = filesize(get_custom_file_base() . '/' . rawurldecode($url)); } else { $file_size = @filesize($url) or $file_size = NULL; } } $myrows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('name', 'description', 'comments'), array('id' => $id), '', 1); if (!array_key_exists(0, $myrows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $myrows[0]; require_code('seo2'); seo_meta_set_for_explicit('downloads_download', strval($id), $meta_keywords, $meta_description); require_code('files2'); delete_upload('uploads/downloads', 'download_downloads', 'url', 'id', $id, $url); $met = @ini_get('max_execution_time'); $data_mash = create_data_mash($url, NULL, get_file_extension($original_filename)); if (function_exists('set_time_limit')) { @set_time_limit($met); } if (!addon_installed('unvalidated')) { $validated = 1; } require_code('submit'); $just_validated = !content_validated('download', strval($id)) && $validated == 1; if ($just_validated) { send_content_validated_notification('download', strval($id)); } $map = array('download_data_mash' => $data_mash, 'download_licence' => $licence, 'original_filename' => $original_filename, 'download_submitter_gets_points' => $submitter_gets_points, 'download_cost' => $cost, 'edit_date' => time(), 'file_size' => $file_size, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'name' => lang_remap($myrow['name'], $name), 'description' => lang_remap_comcode($myrow['description'], $description), 'comments' => lang_remap_comcode($myrow['comments'], $comments), 'validated' => $validated, 'category_id' => $category_id, 'url' => $url, 'author' => $author, 'default_pic' => $default_pic, 'out_mode_id' => $out_mode_id); $GLOBALS['SITE_DB']->query_update('download_downloads', $map, array('id' => $id), '', 1); $self_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $id), get_module_zone('downloads'), NULL, false, false, true); if ($just_validated) { require_lang('downloads'); require_code('notifications'); $subject = do_lang('DOWNLOAD_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $name); $mail = do_lang('DOWNLOAD_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($name), array(comcode_escape($self_url->evaluate()))); dispatch_notification('download', strval($category_id), $subject, $mail); } log_it('EDIT_DOWNLOAD', strval($id), get_translated_text($myrow['name'])); if (addon_installed('galleries')) { // Change its gallery require_code('galleries2'); $download_gallery_root = get_option('download_gallery_root'); if (is_null($download_gallery_root)) { $download_gallery_root = 'root'; } $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'parent_id', array('name' => 'download_' . strval($id))); if (!is_null($test)) { edit_gallery('download_' . strval($id), 'download_' . strval($id), do_lang('GALLERY_FOR_DOWNLOAD', $name), '', '', '', $download_gallery_root); } } decache('main_recent_downloads'); decache('main_top_downloads'); decache('main_download_category'); decache('main_download_tease'); require_code('feedback'); update_spacer_post($allow_comments != 0, 'downloads', strval($id), $self_url, $name, get_value('comment_forum__downloads')); }
/** * Edit a video in a specified gallery. * * @param AUTO_LINK The ID of the entry to edit * @param SHORT_TEXT Video title * @param ID_TEXT The gallery name * @param LONG_TEXT The video comments * @param URLPATH The URL to the actual video * @param URLPATH The URL to the thumbnail of the actual video * @param BINARY Whether the video has been validated for display on the site * @param BINARY Whether the video may be rated * @param BINARY Whether the video may be commented upon * @param BINARY Whether the video may be trackbacked * @param LONG_TEXT Hidden notes associated with the video * @param integer The length of the video * @param integer The width of the video * @param integer The height of the video * @param SHORT_TEXT Meta keywords * @param LONG_TEXT Meta description */ function edit_video($id, $title, $cat, $comments, $url, $thumb_url, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $video_length, $video_width, $video_height, $meta_keywords, $meta_description) { require_code('urls2'); suggest_new_idmoniker_for('galleries', 'video', strval($id), $title == '' ? $comments : $title); $_title = $GLOBALS['SITE_DB']->query_value('videos', 'title', array('id' => $id)); $_comments = $GLOBALS['SITE_DB']->query_value('videos', 'comments', array('id' => $id)); require_code('files2'); delete_upload('uploads/galleries', 'videos', 'url', 'id', $id, $url); delete_upload('uploads/galleries_thumbs', 'videos', 'thumb_url', 'id', $id, $thumb_url); require_code('transcoding'); $url = transcode_video($url, 'videos', 'url', NULL, 'video_width', 'video_height'); if (!addon_installed('unvalidated')) { $validated = 1; } require_code('submit'); $just_validated = !content_validated('video', strval($id)) && $validated == 1; if ($just_validated) { send_content_validated_notification('video', strval($id)); } $GLOBALS['SITE_DB']->query_update('videos', array('title' => lang_remap_comcode($_title, $title), 'edit_date' => time(), 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'validated' => $validated, 'cat' => $cat, 'comments' => lang_remap_comcode($_comments, $comments), 'url' => $url, 'thumb_url' => $thumb_url, 'video_length' => $video_length, 'video_width' => $video_width, 'video_height' => $video_height), array('id' => $id), '', 1); $self_url = build_url(array('page' => 'galleries', 'type' => 'video', 'id' => $id), get_module_zone('galleries'), NULL, false, false, true); if ($just_validated) { require_lang('galleries'); require_code('notifications'); $subject = do_lang('VIDEO_NOTIFICATION_MAIL_SUBJECT', get_site_name(), strip_comcode($title)); $mail = do_lang('VIDEO_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($title), array(comcode_escape($self_url->evaluate()))); dispatch_notification('gallery_entry', $cat, $subject, $mail); } log_it('EDIT_VIDEO', strval($id), $title); require_code('seo2'); seo_meta_set_for_explicit('video', strval($id), $meta_keywords, $meta_description); decache('main_gallery_embed'); require_lang('galleries'); require_code('feedback'); update_spacer_post($allow_comments != 0, 'videos', strval($id), $self_url, do_lang('VIEW_VIDEO', '', '', '', get_site_default_lang()), get_value('comment_forum__videos')); }
/** * 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 CEDI post * * @param AUTO_LINK The post ID * @param string The new post * @param BINARY Whether the post will be validated * @param ?MEMBER The member doing the action (NULL: current member) */ function cedi_edit_post($id, $message, $validated, $member = NULL) { if (is_null($member)) { $member = get_member(); } $rows = $GLOBALS['SITE_DB']->query_select('seedy_posts', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; $original_poster = $myrow['the_user']; $page_id = $myrow['page_id']; $_message = $GLOBALS['SITE_DB']->query_value('seedy_posts', 'the_message', array('id' => $id)); require_code('attachments2'); require_code('attachments3'); if (!addon_installed('unvalidated')) { $validated = 1; } require_code('submit'); $just_validated = !content_validated('cedi_post', strval($id)) && $validated == 1; if ($just_validated) { send_content_validated_notification('cedi_post', strval($id)); } $GLOBALS['SITE_DB']->query_update('seedy_posts', array('validated' => $validated, 'edit_date' => time(), 'the_message' => update_lang_comcode_attachments($_message, $message, 'cedi_post', strval($id), NULL, true, $original_poster)), array('id' => $id), '', 1); $GLOBALS['SITE_DB']->query_insert('seedy_changes', array('the_action' => 'CEDI_EDIT_POST', 'the_page' => $page_id, 'ip' => get_ip_address(), 'the_user' => $member, 'date_and_time' => time())); if ($just_validated) { dispatch_cedi_post_notification($id, 'ADD'); } else { dispatch_cedi_post_notification($id, 'EDIT'); } }
/** * 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); }
/** * Edit a banner. * * @param ID_TEXT The current name of the banner * @param ID_TEXT The new name of the banner * @param URLPATH The URL to the banner image * @param SHORT_TEXT The title text for the banner (only used for text banners, and functions as the 'trigger text' if the banner type is shown inline) * @param SHORT_TEXT The caption of the banner * @param ?integer The number of hits the banner may have (NULL: not applicable for this banner type) * @range 0 max * @param URLPATH The URL to the site the banner leads to * @param integer The banners "importance modulus" * @range 1 max * @param LONG_TEXT Any notes associated with the banner * @param SHORT_INTEGER The type of banner (0=permanent, 1=campaign, 2=default) * @set 0 1 2 * @param ?TIME The banner expiry date (NULL: never) * @param MEMBER The banners submitter * @param BINARY Whether the banner has been validated * @param ID_TEXT The banner type (can be anything, where blank means 'normal') */ function edit_banner($old_name, $name, $imgurl, $title_text, $caption, $campaignremaining, $site_url, $importancemodulus, $notes, $the_type, $expiry_date, $submitter, $validated, $b_type) { if ($old_name != $name) { $test = $GLOBALS['SITE_DB']->query_value_null_ok('banners', 'name', array('name' => $name)); if (!is_null($test)) { warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($name))); } } $_caption = $GLOBALS['SITE_DB']->query_value('banners', 'caption', array('name' => $old_name)); if (!has_specific_permission(get_member(), 'bypass_validation_midrange_content', 'cms_banners')) { $validated = 0; } require_code('files2'); delete_upload('uploads/banners', 'banners', 'img_url', 'name', $old_name, $imgurl); log_it('EDIT_BANNER', $name); decache('main_banner_wave'); decache('main_topsites'); if (!addon_installed('unvalidated')) { $validated = 1; } require_code('submit'); $just_validated = !content_validated('banner', $name) && $validated == 1; if ($just_validated) { send_content_validated_notification('banner', $name); } $GLOBALS['SITE_DB']->query_update('banners', array('b_title_text' => $title_text, 'edit_date' => time(), 'expiry_date' => $expiry_date, 'the_type' => $the_type, 'submitter' => $submitter, 'name' => $name, 'img_url' => $imgurl, 'caption' => lang_remap_comcode($_caption, $caption), 'campaign_remaining' => $campaignremaining, 'site_url' => $site_url, 'importance_modulus' => $importancemodulus, 'notes' => $notes, 'validated' => $validated, 'b_type' => $b_type), array('name' => $old_name), '', 1); }
/** * The actualiser to edit a comcode page. * * @return tempcode The UI */ function __ed() { $simple_add = get_param_integer('simple_add', 0) == 1; $title = get_page_title($simple_add ? 'COMCODE_PAGE_ADD' : 'COMCODE_PAGE_EDIT'); $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/comcode_page_edit'; $file = filter_naughty(post_param('file')); $lang = filter_naughty(post_param('lang')); $zone = filter_naughty(post_param('zone')); if (addon_installed('page_management')) { $new_file = filter_naughty(has_actual_page_access(get_member(), 'admin_sitetree') ? post_param('title', $file) : $file); } else { $new_file = filter_naughty($file); } if ($file == '') { $file = $new_file; } require_code('type_validation'); if (!is_alphanumeric($file, true)) { warn_exit(do_lang_tempcode('BAD_CODENAME')); } $fullpath = zone_black_magic_filterer(get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . $lang . '/' . $file . '.txt'); $renaming_page = $new_file != $file; if ($renaming_page) { if (!is_alphanumeric($new_file, true)) { warn_exit(do_lang_tempcode('BAD_CODENAME')); } $langs = find_all_langs(true); $rename_map = array(); $afm_needed = false; // Actually will stay false as we don't allow renaming original-pages at the moment foreach (array_keys($langs) as $lang) { $path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt', true); if (is_file(get_file_base() . '/' . $path)) { $new_path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $new_file . '.txt', true); if (is_file($new_path)) { warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($zone . ':' . $new_file))); } $rename_map[$path] = $new_path; } if (is_file(get_file_base() . '/' . str_replace('/comcode_custom/', '/comcode/', $path))) { $completion_text = do_lang_tempcode('ORIGINAL_PAGE_NO_RENAME'); } } if ($afm_needed) { require_code('abstract_file_manager'); force_have_afm_details(); } } $validated = post_param_integer('validated', 0); if (!has_specific_permission(get_member(), 'bypass_validation_highrange_content')) { $validated = 0; } $parent_page = post_param('parent_page', ''); $show_as_edit = post_param_integer('show_as_edit', 0); $resource_owner = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $file)); check_edit_permission('high', $resource_owner); if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) { $_owner = post_param('owner', $GLOBALS['FORUM_DRIVER']->get_username(get_member())); $owner = $GLOBALS['FORUM_DRIVER']->get_member_from_username($_owner); if (is_null($owner)) { $owner = get_member(); } } else { $owner = get_member(); } if (is_null($resource_owner)) { check_submit_permission('high'); require_code('submit'); give_submit_points('COMCODE_PAGE_ADD'); if (!addon_installed('unvalidated')) { $validated = 1; } $GLOBALS['SITE_DB']->query_insert('comcode_pages', array('the_zone' => $zone, 'the_page' => $file, 'p_parent_page' => $parent_page, 'p_validated' => $validated, 'p_edit_date' => NULL, 'p_add_date' => time(), 'p_submitter' => $owner, 'p_show_as_edit' => 0)); } else { if (!has_actual_page_access(get_member(), $file, $zone)) { access_denied('PAGE_ACCESS'); } require_code('submit'); $just_validated = !content_validated('comcode_page', $zone . ':' . $file) && $validated == 1; if ($just_validated) { send_content_validated_notification('comcode_page', $zone . ':' . $file); } if (!addon_installed('unvalidated')) { $validated = 1; } $GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_parent_page' => $parent_page, 'p_validated' => $validated, 'p_edit_date' => time(), 'p_submitter' => $owner, 'p_show_as_edit' => $show_as_edit), array('the_zone' => $zone, 'the_page' => $file), '', 1); } if ($validated == 0) { require_code('submit'); $edit_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $new_file), '_SELF', NULL, false, false, true); if (addon_installed('unvalidated')) { send_validation_request('COMCODE_PAGE_EDIT', 'comcode_pages', true, $zone . ':' . $new_file, $edit_url); } } $new = post_param('post'); require_code('attachments2'); $_new = do_comcode_attachments($new, 'comcode_page', $zone . ':' . $file); $new = $_new['comcode']; if (!file_exists($fullpath) || $new != file_get_contents($fullpath, FILE_TEXT)) { $myfile = @fopen($fullpath, 'wt'); if ($myfile === false) { intelligent_write_error($fullpath); } final_attachments_from_preview($zone . ':' . $file); if (fwrite($myfile, $new) < strlen($new)) { warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE')); } fclose($myfile); sync_file($fullpath); $file_changed = true; } else { $file_changed = false; } require_code('seo2'); $new_keywords = post_param('meta_keywords', ''); $new_description = post_param('meta_description', ''); if ($new_keywords == '' && $new_description == '') { seo_meta_set_for_implicit('comcode_page', $zone . ':' . $file, array($new), $new); } else { seo_meta_set_for_explicit('comcode_page', $zone . ':' . $file, $new_keywords, $new_description); } $completion_text = $validated == 0 ? do_lang_tempcode('SUBMIT_UNVALIDATED') : do_lang_tempcode('SUCCESS'); // Update cache NO WE CAN'T - THEY'RE MULTI-THEME NOW /* $string_index=$GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages','string_index',array('the_zone'=>$zone,'the_page'=>$file)); if (!is_null($string_index)) { lang_remap_comcode($string_index,$new); } else { $string_index=insert_lang_comcode($new,1,NULL,false,NULL,NULL,false,NULL,NULL,60,true,true); $GLOBALS['SITE_DB']->query_insert('cached_comcode_pages',array('the_zone'=>$zone,'the_page'=>$file,'string_index'=>$string_index)); }*/ require_code('permissions2'); set_page_permissions_from_environment($zone, $file); $caches = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages', array('string_index'), array('the_zone' => $zone, 'the_page' => $file)); $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_zone' => $zone, 'the_page' => $file)); foreach ($caches as $cache) { delete_lang($cache['string_index']); } persistant_cache_empty(); persistant_cache_delete(array('PAGE_INFO')); decache('main_comcode_page_children'); fix_permissions($fullpath); if (is_file($fullpath) && get_option('store_revisions') == '1' && $file_changed) { $time = time(); @copy($fullpath, $fullpath . '.' . strval($time)) or intelligent_write_error($fullpath . '.' . strval($time)); fix_permissions($fullpath . '.' . strval($time)); sync_file($fullpath . '.' . strval($time)); } log_it('COMCODE_PAGE_EDIT', $file, $zone); require_code('autosave'); clear_ocp_autosave(); if ($renaming_page) { $GLOBALS['SITE_DB']->query_delete('comcode_pages', array('the_zone' => $zone, 'the_page' => $new_file), '', 1); $GLOBALS['SITE_DB']->query_update('comcode_pages', array('the_page' => $new_file), array('the_zone' => $zone, 'the_page' => $file), '', 1); $GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_parent_page' => $new_file), array('the_zone' => $zone, 'p_parent_page' => $file)); foreach ($rename_map as $path => $new_path) { if ($afm_needed) { afm_move($path, $new_path); } else { rename(get_custom_file_base() . '/' . $path, get_custom_file_base() . '/' . $new_path); } } if (addon_installed('awards')) { $types = $GLOBALS['SITE_DB']->query_select('award_types', array('id'), array('a_content_type' => 'comcode_page')); foreach ($types as $type) { $GLOBALS['SITE_DB']->query_update('award_archive', array('content_id' => $new_file), array('content_id' => $file, 'a_type_id' => $type['id'])); } } $file = $new_file; } if (post_param_integer('delete', 0) == 1) { unlink(get_custom_file_base() . '/' . $path); } if (addon_installed('awards')) { require_code('awards'); handle_award_setting('comcode_page', $zone . ':' . $file); } decache('main_sitemap'); breadcrumb_set_self(do_lang_tempcode('DONE')); // Look for bad title semantics $_new['html'] = $_new['tempcode']->evaluate(); if (substr($file, 0, 1) != '_' && substr($file, 0, 6) != 'panel_' && trim($_new['html']) != '') { if (strpos($_new['html'], '<h1') === false && strpos($_new['comcode'], '[title]') === false && strpos($_new['comcode'], '[title="1"]') === false) { attach_message(do_lang_tempcode('NO_LEVEL_1_HEADERS'), 'notice'); } $matches = array(); if (strpos($_new['html'], '<h2') === false && preg_match_all('#\\n\\[(b|font|size)\\][^\\.]+\\[/(b|font|size)\\]\\n#', $_new['comcode'], $matches) >= 2) { attach_message(do_lang_tempcode('NO_LEVEL_2_HEADERS'), 'inform'); } } // Show it worked / Refresh $url = post_param('redirect', ''); if ($url != '') { return redirect_screen($title, $url, $completion_text); } return $this->do_next_manager($title, $file, $zone, $completion_text); }
/** * Edit a quiz. * * @param AUTO_LINK The ID * @param SHORT_TEXT The name of the quiz * @param ?integer The number of minutes allowed for completion (NULL: NA) * @param LONG_TEXT The text shown at the start of the quiz * @param LONG_TEXT The text shown at the end of the quiz * @param LONG_TEXT The text shown at the end of the quiz on failure * @param LONG_TEXT Notes * @param integer Percentage correctness required for competition * @param ?TIME The time the quiz is opened (NULL: now) * @param ?TIME The time the quiz is closed (NULL: never) * @param integer The number of winners for this if it is a competition * @param integer The minimum number of hours between attempts * @param ID_TEXT The type * @set SURVEY COMPETITION TEST * @param BINARY Whether this is validated * @param string Text for questions * @param SHORT_TEXT Meta keywords * @param LONG_TEXT Meta description * @param integer The number of points awarded for completing/passing the quiz/test * @param ?AUTO_LINK Newsletter for which a member must be on to enter (NULL: none) */ function edit_quiz($id, $name, $timeout, $start_text, $end_text, $end_text_fail, $notes, $percentage, $open_time, $close_time, $num_winners, $redo_time, $type, $validated, $text, $meta_keywords, $meta_description, $points_for_passing = 0, $tied_newsletter = NULL) { $rows = $GLOBALS['SITE_DB']->query_select('quizzes', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $_name = $rows[0]['q_name']; $_start_text = $rows[0]['q_start_text']; $_end_text = $rows[0]['q_end_text']; $_end_text_fail = $rows[0]['q_end_text_fail']; if (!addon_installed('unvalidated')) { $validated = 1; } require_code('submit'); $just_validated = !content_validated('quiz', strval($id)) && $validated == 1; if ($just_validated) { send_content_validated_notification('quiz', strval($id)); } $GLOBALS['SITE_DB']->query_update('quizzes', array('q_name' => lang_remap($_name, $name), 'q_timeout' => $timeout, 'q_start_text' => lang_remap($_start_text, $start_text), 'q_end_text' => lang_remap($_end_text, $end_text), 'q_end_text_fail' => lang_remap($_end_text_fail, $end_text_fail), 'q_notes' => $notes, 'q_percentage' => $percentage, 'q_open_time' => $open_time, 'q_close_time' => $close_time, 'q_num_winners' => $num_winners, 'q_redo_time' => $redo_time, 'q_type' => $type, 'q_validated' => $validated, 'q_points_for_passing' => $points_for_passing, 'q_tied_newsletter' => $tied_newsletter), array('id' => $id)); handle_quiz_answers($id, $text, $type); require_code('urls2'); suggest_new_idmoniker_for('quiz', 'do', strval($id), $name); require_code('seo2'); seo_meta_set_for_explicit('quiz', strval($id), $meta_keywords, $meta_description); log_it('EDIT_QUIZ', strval($id), $name); }
/** * 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)); }