Ejemplo n.º 1
0
/**
 * Edit a forum.
 *
 * @param  AUTO_LINK		The ID of the forum we are editing.
 * @param  SHORT_TEXT	The name of the forum.
 * @param  SHORT_TEXT	The description for the forum.
 * @param  AUTO_LINK		What forum category the forum will be filed with.
 * @param  ?AUTO_LINK	The ID of the parent forum (NULL: this is the root forum).
 * @param  integer		The position of this forum relative to other forums viewable on the same screen (if parent forum hasn't specified automatic ordering).
 * @param  BINARY			Whether post counts will be incremented if members post in the forum.
 * @param  BINARY			Whether the ordering of subforums is done automatically, alphabetically).
 * @param  LONG_TEXT		The question that is shown for newbies to the forum (blank: none).
 * @param  SHORT_TEXT	The answer to the question (blank: no specific answer.. if there's a 'question', it just requires a click-through).
 * @param  SHORT_TEXT	Either blank for no redirection, the ID of another forum we are mirroring, or a URL to redirect to.
 * @param  ID_TEXT		The order the topics are shown in, by default.
 * @param  BINARY			Whether the forum is threaded.
 * @param  boolean		Whether to force forum rules to be re-agreed to, if they've just been changed.
 */
function ocf_edit_forum($forum_id, $name, $description, $category_id, $new_parent, $position, $post_count_increment, $order_sub_alpha, $intro_question, $intro_answer, $redirection = '', $order = 'last_post', $is_threaded = 0, $reset_intro_acceptance = false)
{
    if ($category_id == -1) {
        $category_id = NULL;
    }
    if ($new_parent == -1) {
        $new_parent = NULL;
    }
    require_code('urls2');
    suggest_new_idmoniker_for('forumview', 'misc', strval($forum_id), $name);
    if (!is_null($category_id) && $category_id != INTEGER_MAGIC_NULL) {
        ocf_ensure_category_exists($category_id);
    }
    if (!is_null($new_parent) && $new_parent != INTEGER_MAGIC_NULL) {
        ocf_ensure_forum_exists($new_parent);
    }
    $forum_info = $GLOBALS['FORUM_DB']->query_select('f_forums', array('*'), array('id' => $forum_id), '', 1);
    if (!array_key_exists(0, $forum_info)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    $old_parent = $forum_info[0]['f_parent_forum'];
    $old_name = $forum_info[0]['f_name'];
    $under_category_id = $new_parent;
    while (!is_null($under_category_id) && $under_category_id != INTEGER_MAGIC_NULL) {
        if ($forum_id == $under_category_id) {
            warn_exit(do_lang_tempcode('FORUM_CANNOT_BE_OWN_PARENT'));
        }
        $under_category_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'f_parent_forum', array('id' => $under_category_id));
    }
    if ($reset_intro_acceptance && trim(get_translated_text($forum_info[0]['f_intro_question'], $GLOBALS['FORUM_DB'])) != trim($intro_question) && $intro_question != STRING_MAGIC_NULL) {
        $GLOBALS['FORUM_DB']->query_delete('f_forum_intro_ip', array('i_forum_id' => $forum_id));
        $GLOBALS['FORUM_DB']->query_delete('f_forum_intro_member', array('i_forum_id' => $forum_id));
    }
    $GLOBALS['FORUM_DB']->query_update('f_forums', array('f_name' => $name, 'f_description' => lang_remap($forum_info[0]['f_description'], $description, $GLOBALS['FORUM_DB']), 'f_category_id' => $category_id, 'f_parent_forum' => $new_parent, 'f_position' => $position, 'f_order_sub_alpha' => $order_sub_alpha, 'f_intro_question' => lang_remap($forum_info[0]['f_intro_question'], $intro_question, $GLOBALS['FORUM_DB']), 'f_intro_answer' => $intro_answer, 'f_post_count_increment' => $post_count_increment, 'f_redirection' => $redirection, 'f_order' => $order, 'f_is_threaded' => $is_threaded), array('id' => $forum_id), '', 1);
    if ($old_name != $name) {
        $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'f_name', array('f_name' => $old_name));
        if (is_null($test)) {
            require_code('config2');
            update_config_option_reference($old_name, $name, 'forum');
        }
    }
    if ($old_parent != $new_parent && $new_parent != INTEGER_MAGIC_NULL) {
        // Recalc stats
        require_code('ocf_posts_action2');
        $num_topics_forum = $forum_info[0]['f_cache_num_topics'];
        // This is valid, because we move all this forums subforums too
        $num_posts_forum = $forum_info[0]['f_cache_num_posts'];
        if (!is_null($old_parent)) {
            ocf_force_update_forum_cacheing($old_parent, -$num_topics_forum, -$num_posts_forum);
        }
        if (!is_null($new_parent)) {
            ocf_force_update_forum_cacheing($new_parent, $num_topics_forum, $num_posts_forum);
        }
    }
    log_it('EDIT_FORUM', strval($forum_id), $name);
}
Ejemplo n.º 2
0
/**
 * Edit an IOTD.
 *
 * @param  AUTO_LINK			The ID of the IOTD to edit
 * @param  SHORT_TEXT		The IOTD title
 * @param  LONG_TEXT			The IOTD caption
 * @param  URLPATH			The URL to the IOTD image
 * @param  URLPATH			The URL to the IOTD thumbnail image
 * @param  BINARY				Whether the IOTD may be rated
 * @param  SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style)
 * @param  BINARY				Whether the IOTD may be trackbacked
 * @param  LONG_TEXT			Notes for the IOTD
 */
function edit_iotd($id, $title, $caption, $thumb_url, $url, $allow_rating, $allow_comments, $allow_trackbacks, $notes)
{
    $_caption = $GLOBALS['SITE_DB']->query_value('iotd', 'caption', array('id' => $id));
    $_title = $GLOBALS['SITE_DB']->query_value('iotd', 'i_title', array('id' => $id));
    require_code('files2');
    delete_upload('uploads/iotds', 'iotd', 'url', 'id', $id, $url);
    delete_upload('uploads/iotds_thumbs', 'iotd', 'thumb_url', 'id', $id, $thumb_url);
    $GLOBALS['SITE_DB']->query_update('iotd', array('i_title' => lang_remap_comcode($_title, $title), 'edit_date' => time(), 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'caption' => lang_remap_comcode($_caption, $caption), 'thumb_url' => $thumb_url, 'url' => $url), array('id' => $id), '', 1);
    require_code('urls2');
    suggest_new_idmoniker_for('iotds', 'view', strval($id), $title);
    log_it('EDIT_IOTD', strval($id), get_translated_text($_caption));
    decache('main_iotd');
    require_code('feedback');
    update_spacer_post($allow_comments != 0, 'videos', strval($id), build_url(array('page' => 'iotds', 'type' => 'view', 'id' => $id), get_module_zone('iotds'), NULL, false, false, true), $title, get_value('comment_forum__iotds'));
}
Ejemplo n.º 3
0
/**
 * Move some topics.
 *
 * @param  AUTO_LINK		The forum the topics are currently in.
 * @param  AUTO_LINK		The forum the topics are being moved to.
 * @param  ?array 		A list of the topic IDs to move (NULL: move all topics from source forum).
 */
function ocf_move_topics($from, $to, $topics = NULL)
{
    if ($from == $to) {
        return;
    }
    // That would be nuts, and interfere with our logic
    require_code('notifications');
    require_code('ocf_topics');
    require_code('ocf_forums_action2');
    $forum_name = ocf_ensure_forum_exists($to);
    if (!ocf_may_moderate_forum($from)) {
        access_denied('I_ERROR');
    }
    $topic_count = 0;
    if (is_null($topics)) {
        if (is_null($from)) {
            access_denied('I_ERROR');
        }
        $all_topics = $GLOBALS['FORUM_DB']->query_select('f_topics', array('id', 't_cache_num_posts', 't_validated'), array('t_forum_id' => $from));
        $or_list = '';
        $post_count = 0;
        $topics = array();
        foreach ($all_topics as $topic_info) {
            $topics[] = $topic_info['id'];
            if ($or_list != '') {
                $or_list .= ' OR ';
            }
            $or_list .= 'id=' . strval((int) $topic_info['id']);
            $post_count += $topic_info['t_cache_num_posts'];
            if ($topic_info['t_validated'] == 1) {
                $topic_count++;
            }
        }
        $GLOBALS['FORUM_DB']->query_update('f_topics', array('t_forum_id' => $to), array('t_forum_id' => $from));
        // Update forum IDs' for posts
        $GLOBALS['FORUM_DB']->query_update('f_posts', array('p_cache_forum_id' => $to), array('p_cache_forum_id' => $from));
        $or_list_2 = str_replace('id', 'p_topic_id', $or_list);
        if ($or_list_2 == '') {
            return;
        }
    } elseif (count($topics) == 1) {
        $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_forum_id', 't_pt_from', 't_pt_to', 't_cache_first_title', 't_cache_num_posts', 't_validated'), array('id' => $topics[0]));
        if (!array_key_exists(0, $topic_info)) {
            warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
        }
        if ($topic_info[0]['t_forum_id'] != $from || $topic_info[0]['t_pt_from'] != get_member() && $topic_info[0]['t_pt_to'] != get_member() && !ocf_has_special_pt_access($topics[0]) && !has_specific_permission(get_member(), 'view_other_pt') && is_null($topic_info[0]['t_forum_id'])) {
            access_denied('I_ERROR');
        }
        if ($topic_info[0]['t_validated'] == 1) {
            $topic_count++;
        }
        $topic_title = $topic_info[0]['t_cache_first_title'];
        $post_count = $topic_info[0]['t_cache_num_posts'];
        $GLOBALS['FORUM_DB']->query_update('f_topics', array('t_pt_from' => NULL, 't_pt_to' => NULL, 't_forum_id' => $to), array('t_forum_id' => $from, 'id' => $topics[0]), '', 1);
        // Extra where constraint for added security
        log_it('MOVE_TOPICS', $topic_title, strval($topics[0]));
        $or_list = 'id=' . strval($topics[0]);
        $or_list_2 = 'p_topic_id=' . strval($topics[0]);
        // Update forum IDs' for posts
        $GLOBALS['FORUM_DB']->query_update('f_posts', array('p_cache_forum_id' => $to), array('p_topic_id' => $topics[0]));
    } else {
        if (count($topics) == 0) {
            return;
        }
        // Nuts, lol
        $or_list = '';
        foreach ($topics as $topic_id) {
            if ($or_list != '') {
                $or_list .= ' OR ';
            }
            $or_list .= 'id=' . strval((int) $topic_id);
            if (is_null($from)) {
                $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_forum_id', 't_pt_from', 't_pt_to'), array('id' => $topic_id));
                if (array_key_exists(0, $topic_info)) {
                    if ($topic_info[0]['t_validated'] == 1) {
                        $topic_count++;
                    }
                    if ($topic_info[0]['t_forum_id'] != $from || $topic_info[0]['t_pt_from'] != get_member() && $topic_info[0]['t_pt_to'] != get_member() && !ocf_has_special_pt_access($topic_id) && !has_specific_permission(get_member(), 'view_other_pt')) {
                        access_denied('I_ERROR');
                    }
                }
            } else {
                $topic_count++;
                // Might not be validated, which means technically we shouldn't do this, but it's low chance, low impact, and the indicator is only a cache thing anyway
            }
        }
        $GLOBALS['FORUM_DB']->query('UPDATE ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics SET t_forum_id=' . strval((int) $to) . ',t_pt_from=NULL,t_pt_to=NULL WHERE t_forum_id' . (is_null($from) ? ' IS NULL' : '=' . strval((int) $from)) . ' AND (' . $or_list . ')');
        log_it('MOVE_TOPICS', do_lang('MULTIPLE'));
        $post_count = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT SUM(t_cache_num_posts) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE ' . $or_list);
        // Update forum IDs' for posts
        $or_list_2 = str_replace('id', 'p_topic_id', $or_list);
        $GLOBALS['FORUM_DB']->query('UPDATE ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts SET p_cache_forum_id=' . strval((int) $to) . ' WHERE ' . $or_list_2);
    }
    require_code('ocf_posts_action2');
    // Update source forum cache view
    if (!is_null($from)) {
        ocf_force_update_forum_cacheing($from, -$topic_count, -$post_count);
    }
    // Update dest forum cache view
    ocf_force_update_forum_cacheing($to, $topic_count, $post_count);
    if (!is_null($from)) {
        // Update member post counts if we've switched between post-count countable forums
        $post_count_info = $GLOBALS['FORUM_DB']->query('SELECT id,f_post_count_increment FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE id=' . strval((int) $from) . ' OR id=' . strval((int) $to), 2);
        if ($post_count_info[0]['id'] == $from) {
            $from_cnt = $post_count_info[0]['f_post_count_increment'];
            $to_cnt = $post_count_info[1]['f_post_count_increment'];
        } else {
            $from_cnt = $post_count_info[1]['f_post_count_increment'];
            $to_cnt = $post_count_info[0]['f_post_count_increment'];
        }
        require_code('ocf_posts_action');
        if ($from_cnt != $to_cnt) {
            $sql = 'SELECT p_poster FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE (' . $or_list_2 . ')';
            if (addon_installed('unvalidated')) {
                $sql .= ' AND p_validated=1';
            }
            $_member_post_counts = collapse_1d_complexity('p_poster', $GLOBALS['FORUM_DB']->query($sql));
            $member_post_counts = array_count_values($_member_post_counts);
            foreach ($member_post_counts as $member_id => $member_post_count) {
                if ($to == 0) {
                    $member_post_count = -$member_post_count;
                }
                ocf_force_update_member_post_count($member_id, $member_post_count);
            }
        }
    }
    require_code('ocf_posts_action');
    if (!is_null($from)) {
        ocf_decache_ocp_blocks($from);
    } else {
        decache('side_ocf_personal_topics');
        decache('_new_pp');
    }
    ocf_decache_ocp_blocks($to, $forum_name);
    if (function_exists('set_time_limit')) {
        @set_time_limit(0);
    }
    $start = 0;
    do {
        $topics2 = $GLOBALS['FORUM_DB']->query('SELECT id,t_cache_first_title,t_cache_last_time FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE ' . $or_list, 100, $start);
        require_code('urls2');
        foreach ($topics2 as $_topic) {
            if ($_topic['t_cache_last_time'] < time() - 60 * 60 * 24 * 14) {
                continue;
            }
            $topic_id = $_topic['id'];
            $topic_title = $_topic['t_cache_first_title'];
            suggest_new_idmoniker_for('topicview', 'misc', strval($topic_id), $topic_title);
            // Now lets inform people tracking the topic that it has moved
            $subject = do_lang('TOPIC_MOVE_MAIL_SUBJECT', get_site_name(), $topic_title);
            $mail = do_lang('TOPIC_MOVE_MAIL', comcode_escape(get_site_name()), comcode_escape($topic_title), array(comcode_escape($forum_name)));
            dispatch_notification('ocf_topic', strval($topic_id), $subject, $mail);
        }
    } while (count($topics2) == 100);
}
Ejemplo n.º 4
0
/**
 * Edit a gallery.
 *
 * @param  ID_TEXT		The old gallery codename (in case we are renaming)
 * @param  ID_TEXT		The gallery codename (maybe the same as the old one)
 * @param  SHORT_TEXT	The full human-readeable name of the gallery
 * @param  LONG_TEXT		The description of the gallery
 * @param  SHORT_TEXT	Teaser text for the gallery
 * @param  LONG_TEXT		Hidden notes associated with the gallery
 * @param  ?ID_TEXT		The parent gallery (NULL: no parent)
 * @param  BINARY			Whether images may be put in this gallery
 * @param  BINARY			Whether videos may be put in this gallery
 * @param  BINARY			Whether the gallery serves as a container for automatically created member galleries
 * @param  BINARY			Whether the gallery uses the flow mode interface
 * @param  URLPATH		The representative image of the gallery (blank: none)
 * @param  URLPATH		Watermark (blank: none)
 * @param  URLPATH		Watermark (blank: none)
 * @param  URLPATH		Watermark (blank: none)
 * @param  URLPATH		Watermark (blank: none)
 * @param  ?SHORT_TEXT	Meta keywords for this resource (NULL: do not edit)
 * @param  ?LONG_TEXT	Meta description for this resource (NULL: do not edit)
 * @param  BINARY			Whether rating are allowed
 * @param  BINARY			Whether comments are allowed
 * @param  ?MEMBER		The gallery owner (NULL: nobody)
 */
function edit_gallery($old_name, $name, $fullname, $description, $teaser, $notes, $parent_id = NULL, $accept_images = 1, $accept_videos = 1, $is_member_synched = 0, $flow_mode_interface = 0, $rep_image = '', $watermark_top_left = '', $watermark_top_right = '', $watermark_bottom_left = '', $watermark_bottom_right = '', $meta_keywords = NULL, $meta_description = NULL, $allow_rating = 1, $allow_comments = 1, $g_owner = NULL)
{
    require_code('urls2');
    suggest_new_idmoniker_for('galleries', 'misc', $name, $fullname);
    $under_category_id = $parent_id;
    while ($under_category_id != '' && $under_category_id != STRING_MAGIC_NULL) {
        if ($name == $under_category_id) {
            warn_exit(do_lang_tempcode('OWN_PARENT_ERROR'));
        }
        $under_category_id = $GLOBALS['SITE_DB']->query_value('galleries', 'parent_id', array('name' => $under_category_id));
    }
    if (is_null($parent_id)) {
        $parent_id = '';
    }
    require_code('seo2');
    if ($old_name != $name) {
        require_code('type_validation');
        if (!is_alphanumeric($name, true)) {
            warn_exit(do_lang_tempcode('BAD_CODENAME'));
        }
        $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => $name));
        if (!is_null($test)) {
            warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($name)));
        }
        seo_meta_erase_storage('gallery', $old_name);
        $GLOBALS['SITE_DB']->query_update('images', array('cat' => $name), array('cat' => $old_name));
        $GLOBALS['SITE_DB']->query_update('videos', array('cat' => $name), array('cat' => $old_name));
        $GLOBALS['SITE_DB']->query_update('galleries', array('parent_id' => $name), array('parent_id' => $old_name));
        if (addon_installed('awards')) {
            $types = $GLOBALS['SITE_DB']->query_select('award_types', array('id'), array('a_content_type' => 'gallery'));
            foreach ($types as $type) {
                $GLOBALS['SITE_DB']->query_update('award_archive', array('content_id' => $name), array('content_id' => $old_name, 'a_type_id' => $type['id']));
            }
        }
    }
    if (!is_null($meta_keywords)) {
        seo_meta_set_for_explicit('gallery', $name, $meta_keywords, $meta_description);
    }
    $myrows = $GLOBALS['SITE_DB']->query_select('galleries', array('fullname', 'description', 'teaser'), array('name' => $old_name), '', 1);
    if (!array_key_exists(0, $myrows)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    $myrow = $myrows[0];
    $map = array('name' => $name, 'notes' => $notes, 'fullname' => lang_remap($myrow['fullname'], $fullname), 'description' => lang_remap_comcode($myrow['description'], $description), 'teaser' => lang_remap_comcode($myrow['teaser'], $teaser), 'parent_id' => $parent_id, 'accept_images' => $accept_images, 'accept_videos' => $accept_videos, 'is_member_synched' => $is_member_synched, 'flow_mode_interface' => $flow_mode_interface, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'g_owner' => $g_owner);
    require_code('files2');
    if (!is_null($rep_image)) {
        $map['rep_image'] = $rep_image;
        delete_upload('uploads/grepimages', 'galleries', 'rep_image', 'name', $old_name, $rep_image);
    }
    if (!is_null($watermark_top_left)) {
        $map['watermark_top_left'] = $watermark_top_left;
        delete_upload('uploads/watermarks', 'galleries', 'watermark_top_left', 'name', $old_name, $watermark_top_left);
    }
    if (!is_null($watermark_top_right)) {
        $map['watermark_top_right'] = $watermark_top_right;
        delete_upload('uploads/watermarks', 'galleries', 'watermark_top_right', 'name', $old_name, $watermark_top_right);
    }
    if (!is_null($watermark_bottom_left)) {
        $map['watermark_bottom_left'] = $watermark_bottom_left;
        delete_upload('uploads/watermarks', 'galleries', 'watermark_bottom_left', 'name', $old_name, $watermark_bottom_left);
    }
    if (!is_null($watermark_bottom_right)) {
        $map['watermark_bottom_right'] = $watermark_bottom_right;
        delete_upload('uploads/watermarks', 'galleries', 'watermark_bottom_right', 'name', $old_name, $watermark_bottom_right);
    }
    $GLOBALS['SITE_DB']->query_update('galleries', $map, array('name' => $old_name), '', 1);
    log_it('EDIT_GALLERY', $name, $fullname);
    $GLOBALS['SITE_DB']->query_update('group_category_access', array('category_name' => $name), array('module_the_name' => 'galleries', 'category_name' => $old_name));
    decache('main_top_galleries');
    decache('main_recent_galleries');
    decache('main_root_galleries');
    decache('side_root_galleries');
    require_code('feedback');
    update_spacer_post($allow_comments != 0, 'galleries', $name, build_url(array('page' => 'galleries', 'type' => 'misc', 'id' => $name), get_module_zone('galleries'), NULL, false, false, true), $fullname, get_value('comment_forum__galleries'));
}
Ejemplo n.º 5
0
/**
 * 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'));
}
Ejemplo n.º 6
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'));
}
Ejemplo n.º 7
0
/**
 * Edit a poll.
 *
 * @param  AUTO_LINK			The ID of the poll to edit
 * @param  SHORT_TEXT		The question
 * @param  SHORT_TEXT		The first choice
 * @range  1 max
 * @param  SHORT_TEXT		The second choice
 * @range  1 max
 * @param  SHORT_TEXT		The third choice (blank means not a choice)
 * @param  SHORT_TEXT		The fourth choice (blank means not a choice)
 * @param  SHORT_TEXT		The fifth choice (blank means not a choice)
 * @param  SHORT_TEXT		The sixth choice (blank means not a choice)
 * @param  SHORT_TEXT		The seventh choice (blank means not a choice)
 * @param  SHORT_TEXT		The eighth choice (blank means not a choice)
 * @param  SHORT_TEXT		The ninth choice (blank means not a choice)
 * @param  SHORT_TEXT		The tenth choice (blank means not a choice)
 * @param  integer			The number of choices
 * @param  BINARY				Whether to allow rating of this poll
 * @param  SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style)
 * @param  BINARY				Whether to allow trackbacking on this poll
 * @param  LONG_TEXT			Notes about this poll
 */
function edit_poll($id, $question, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10, $num_options, $allow_rating, $allow_comments, $allow_trackbacks, $notes)
{
    log_it('EDIT_POLL', strval($id), $question);
    persistant_cache_delete('POLL');
    $rows = $GLOBALS['SITE_DB']->query_select('poll', array('*'), array('id' => $id), '', 1);
    $_question = $rows[0]['question'];
    $_a1 = $rows[0]['option1'];
    $_a2 = $rows[0]['option2'];
    $_a3 = $rows[0]['option3'];
    $_a4 = $rows[0]['option4'];
    $_a5 = $rows[0]['option5'];
    $_a6 = $rows[0]['option6'];
    $_a7 = $rows[0]['option7'];
    $_a8 = $rows[0]['option8'];
    $_a9 = $rows[0]['option9'];
    $_a10 = $rows[0]['option10'];
    $GLOBALS['SITE_DB']->query_update('poll', array('edit_date' => time(), 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'num_options' => $num_options, 'question' => lang_remap_comcode($_question, $question), 'option1' => lang_remap_comcode($_a1, $a1), 'option2' => lang_remap_comcode($_a2, $a2), 'option3' => lang_remap_comcode($_a3, $a3), 'option4' => lang_remap_comcode($_a4, $a4), 'option5' => lang_remap_comcode($_a5, $a5), 'option6' => lang_remap_comcode($_a6, $a6), 'option7' => lang_remap_comcode($_a7, $a7), 'option8' => lang_remap_comcode($_a8, $a8), 'option9' => lang_remap_comcode($_a9, $a9), 'option10' => lang_remap_comcode($_a10, $a10)), array('id' => $id), '', 1);
    decache('main_poll');
    require_code('urls2');
    suggest_new_idmoniker_for('polls', 'view', strval($id), $question);
    require_code('feedback');
    update_spacer_post($allow_comments != 0, 'polls', strval($id), build_url(array('page' => 'polls', 'type' => 'view', 'id' => $id), get_module_zone('polls'), NULL, false, false, true), $question, get_value('comment_forum__polls'));
}
Ejemplo n.º 8
0
/**
 * Called from 'find_id_moniker'. We tried to lookup a moniker, found a hook, but found no stored moniker. So we'll try and autogenerate one.
 *
 * @param  array			The hooks info profile.
 * @param  array			The URL component map (must contain 'page', 'type', and 'id' if this function is to do anything).
 * @return ?string		The moniker ID (NULL: error generating it somehow, can not do it)
 */
function autogenerate_new_url_moniker($ob_info, $url_parts)
{
    $bak = $GLOBALS['NO_DB_SCOPE_CHECK'];
    $GLOBALS['NO_DB_SCOPE_CHECK'] = true;
    $select = array($ob_info['id_field']);
    if (substr($ob_info['title_field'], 0, 5) != 'EVAL:' && substr($ob_info['title_field'], 0, 5) != 'CALL:') {
        $select[] = $ob_info['title_field'];
    }
    if (!is_null($ob_info['parent_category_field'])) {
        $select[] = $ob_info['parent_category_field'];
    }
    $db = substr($ob_info['table'], 0, 2) != 'f_' || get_forum_type() == 'none' ? $GLOBALS['SITE_DB'] : $GLOBALS['FORUM_DB'];
    $_moniker_src = $db->query_select($ob_info['table'], $select, array($ob_info['id_field'] => $ob_info['id_field_numeric'] ? intval($url_parts['id']) : $url_parts['id']));
    $GLOBALS['NO_DB_SCOPE_CHECK'] = $bak;
    if (!array_key_exists(0, $_moniker_src)) {
        return NULL;
    }
    // been deleted?
    if (substr($ob_info['title_field'], 0, 5) == 'EVAL:') {
        $moniker_src = eval(trim(substr($ob_info['title_field'], 5)));
    } elseif (substr($ob_info['title_field'], 0, 5) == 'CALL:') {
        $moniker_src = call_user_func(trim(substr($ob_info['title_field'], 5)), $url_parts);
    } else {
        if ($ob_info['title_field_dereference']) {
            $moniker_src = get_translated_text($_moniker_src[0][$ob_info['title_field']]);
        } else {
            $moniker_src = $_moniker_src[0][$ob_info['title_field']];
        }
    }
    if ($moniker_src == '') {
        $moniker_src = 'untitled';
    }
    return suggest_new_idmoniker_for($url_parts['page'], $url_parts['type'], $url_parts['id'], $moniker_src, true);
}
Ejemplo n.º 9
0
/**
 * Edit a calendar event type.
 *
 * @param  AUTO_LINK			The ID of the event type
 * @param  SHORT_TEXT		The title of the event type
 * @param  ID_TEXT			The theme image code
 * @param  URLPATH			URL to external feed to associate with this event type
 */
function edit_event_type($id, $title, $logo, $external_feed)
{
    $myrows = $GLOBALS['SITE_DB']->query_select('calendar_types', array('t_title', 't_logo'), array('id' => $id), '', 1);
    if (!array_key_exists(0, $myrows)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    $myrow = $myrows[0];
    require_code('urls2');
    suggest_new_idmoniker_for('calendar', 'misc', strval($id), $title);
    $GLOBALS['SITE_DB']->query_update('calendar_types', array('t_title' => lang_remap($myrow['t_title'], $title), 't_logo' => $logo, 't_external_feed' => $external_feed), array('id' => $id), '', 1);
    require_code('themes2');
    tidy_theme_img_code($logo, $myrow['t_logo'], 'calendar_types', 't_logo');
    log_it('EDIT_EVENT_TYPE', strval($id), $title);
}
Ejemplo n.º 10
0
/**
 * Edit a chatroom.
 *
 * @param  AUTO_LINK			The chat room ID
 * @param  SHORT_TEXT		The welcome message
 * @param  SHORT_TEXT		The room name
 * @param  MEMBER				The room owner
 * @param  LONG_TEXT			The comma-separated list of users that may access it (blank: no restriction)
 * @param  LONG_TEXT			The comma-separated list of usergroups that may access it (blank: no restriction)
 * @param  LONG_TEXT			The comma-separated list of users that may NOT access it (blank: no restriction)
 * @param  LONG_TEXT			The comma-separated list of usergroups that may NOT access it (blank: no restriction)
 * @param  LANGUAGE_NAME	The room language
 */
function edit_chatroom($id, $welcome, $roomname, $room_owner, $allow2, $allow2_groups, $disallow2, $disallow2_groups, $roomlang)
{
    $c_welcome = $GLOBALS['SITE_DB']->query_value('chat_rooms', 'c_welcome', array('id' => $id));
    $GLOBALS['SITE_DB']->query_update('chat_rooms', array('c_welcome' => lang_remap($c_welcome, $welcome), 'room_name' => $roomname, 'room_owner' => $room_owner, 'allow_list' => $allow2, 'allow_list_groups' => $allow2_groups, 'disallow_list' => $disallow2, 'disallow_list_groups' => $disallow2_groups, 'room_language' => $roomlang), array('id' => $id), '', 1);
    decache('side_shoutbox');
    require_code('urls2');
    suggest_new_idmoniker_for('chat', 'room', strval($id), $roomname);
    log_it('EDIT_CHATROOM', strval($id), $roomname);
}
Ejemplo n.º 11
0
/**
 * Edit a usergroup.
 *
 * @param  AUTO_LINK		The ID of the usergroup to edit.
 * @param  ?SHORT_TEXT	The name of the usergroup. (NULL: do not change)
 * @param  ?BINARY		Whether members are automatically put into the when they join. (NULL: do not change)
 * @param  ?BINARY		Whether members of this usergroup are all super administrators. (NULL: do not change)
 * @param  ?BINARY		Whether members of this usergroup are all super moderators. (NULL: do not change)
 * @param  ?SHORT_TEXT	The title for primary members of this usergroup that don't have their own title. (NULL: do not change)
 * @param  ?URLPATH		The rank image for this. (NULL: do not change)
 * @param  ?GROUP			The that members of this usergroup get promoted to at point threshold (NULL: no promotion prospects).
 * @param  ?integer		The point threshold for promotion (NULL: no promotion prospects).
 * @param  ?MEMBER		The leader of this usergroup (NULL: none).
 * @param  ?integer		The number of seconds that members of this usergroup must endure between submits (group 'best of' applies). (NULL: do not change)
 * @param  ?integer		The number of seconds that members of this usergroup must endure between accesses (group 'best of' applies). (NULL: do not change)
 * @param  ?integer		The number of megabytes that members of this usergroup may attach per day (group 'best of' applies). (NULL: do not change)
 * @param  ?integer		The number of attachments that members of this usergroup may attach to something (group 'best of' applies). (NULL: do not change)
 * @param  ?integer		The maximum avatar width that members of this usergroup may have (group 'best of' applies). (NULL: do not change)
 * @param  ?integer		The maximum avatar height that members of this usergroup may have (group 'best of' applies). (NULL: do not change)
 * @param  ?integer		The maximum post length that members of this usergroup may make (group 'best of' applies). (NULL: do not change)
 * @param  ?integer		The maximum signature length that members of this usergroup may make (group 'best of' applies). (NULL: do not change)
 * @param  ?integer		The number of gift points that members of this usergroup start with (group 'best of' applies). (NULL: do not change)
 * @param  ?integer		The number of gift points that members of this usergroup get per day (group 'best of' applies). (NULL: do not change)
 * @param  ?BINARY		Whether e-mail confirmation is needed for new IP addresses seen for any member of this usergroup (group 'best of' applies). (NULL: do not change)
 * @param  ?BINARY		Whether the is presented for joining at joining (implies anyone may be in the, but only choosable at joining) (NULL: do not change)
 * @param  ?BINARY		Whether the name and membership of the is hidden (NULL: do not change)
 * @param  ?integer		The display order this will be given, relative to other usergroups. Lower numbered usergroups display before higher numbered usergroups. (NULL: do not change)
 * @param  ?BINARY		Whether the rank image will not be shown for secondary membership (NULL: do not change)
 * @param  ?BINARY		Whether members may join this usergroup without requiring any special permission (NULL: do not change)
 * @param  ?BINARY		Whether this usergroup is a private club. Private clubs may be managed in the CMS zone, and do not have any special permissions - except over their own associated forum. (NULL: do not change)
 */
function ocf_edit_group($group_id, $name, $is_default, $is_super_admin, $is_super_moderator, $title, $rank_image, $promotion_target, $promotion_threshold, $group_leader, $flood_control_submit_secs, $flood_control_access_secs, $max_daily_upload_mb, $max_attachments_per_post, $max_avatar_width, $max_avatar_height, $max_post_length_comcode, $max_sig_length_comcode, $gift_points_base, $gift_points_per_day, $enquire_on_new_ips, $is_presented_at_install, $hidden, $order, $rank_image_pri_only, $open_membership, $is_private_club)
{
    $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_groups g LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON g.g_name=t.id WHERE ' . db_string_equal_to('text_original', $name), 'g.id');
    if (!is_null($test) && $test != $group_id) {
        warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($name)));
    }
    $_group_info = $GLOBALS['FORUM_DB']->query_select('f_groups', array('g_name', 'g_title', 'g_rank_image'), array('id' => $group_id), '', 1);
    if (!array_key_exists(0, $_group_info)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    $_name = $_group_info[0]['g_name'];
    $_title = $_group_info[0]['g_title'];
    $map = array();
    if (!is_null($name)) {
        $map['g_name'] = lang_remap($_name, $name, $GLOBALS['FORUM_DB']);
    }
    if (!is_null($is_default)) {
        $map['g_is_default'] = $is_default;
    }
    if (!is_null($is_presented_at_install)) {
        $map['g_is_presented_at_install'] = $is_presented_at_install;
    }
    if (!is_null($is_super_admin)) {
        $map['g_is_super_admin'] = $is_super_admin;
    }
    if (!is_null($is_super_moderator)) {
        $map['g_is_super_moderator'] = $is_super_moderator;
    }
    $map['g_group_leader'] = $group_leader;
    if (!is_null($title)) {
        $map['g_title'] = lang_remap($_title, $title, $GLOBALS['FORUM_DB']);
    }
    if (addon_installed('points')) {
        $map['g_promotion_target'] = $promotion_target;
        $map['g_promotion_threshold'] = $promotion_threshold;
    }
    if (!is_null($flood_control_submit_secs)) {
        $map['g_flood_control_submit_secs'] = $flood_control_submit_secs;
    }
    if (!is_null($flood_control_access_secs)) {
        $map['g_flood_control_access_secs'] = $flood_control_access_secs;
    }
    if (!is_null($max_daily_upload_mb)) {
        $map['g_max_daily_upload_mb'] = $max_daily_upload_mb;
    }
    if (!is_null($max_attachments_per_post)) {
        $map['g_max_attachments_per_post'] = $max_attachments_per_post;
    }
    if (!is_null($max_avatar_width)) {
        $map['g_max_avatar_width'] = $max_avatar_width;
    }
    if (!is_null($max_avatar_height)) {
        $map['g_max_avatar_height'] = $max_avatar_height;
    }
    if (!is_null($max_post_length_comcode)) {
        $map['g_max_post_length_comcode'] = $max_post_length_comcode;
    }
    if (!is_null($max_sig_length_comcode)) {
        $map['g_max_sig_length_comcode'] = $max_sig_length_comcode;
    }
    if (addon_installed('points')) {
        if (!is_null($gift_points_base)) {
            $map['g_gift_points_base'] = $gift_points_base;
        }
        if (!is_null($gift_points_per_day)) {
            $map['g_gift_points_per_day'] = $gift_points_per_day;
        }
    }
    if (!is_null($enquire_on_new_ips)) {
        $map['g_enquire_on_new_ips'] = $enquire_on_new_ips;
    }
    if (!is_null($rank_image)) {
        $map['g_rank_image'] = $rank_image;
    }
    if (!is_null($hidden)) {
        $map['g_hidden'] = $hidden;
    }
    if (!is_null($order)) {
        $map['g_order'] = $order;
    }
    if (!is_null($rank_image_pri_only)) {
        $map['g_rank_image_pri_only'] = $rank_image_pri_only;
    }
    if (!is_null($open_membership)) {
        $map['g_open_membership'] = $open_membership;
    }
    if (!is_null($is_private_club)) {
        $map['g_is_private_club'] = $is_private_club;
    }
    $GLOBALS['FORUM_DB']->query_update('f_groups', $map, array('id' => $group_id), '', 1);
    require_code('urls2');
    suggest_new_idmoniker_for('groups', 'view', strval($group_id), $name);
    require_code('themes2');
    tidy_theme_img_code($rank_image, $_group_info[0]['g_rank_image'], 'f_groups', 'g_rank_image', $GLOBALS['FORUM_DB']);
    log_it('EDIT_GROUP', strval($group_id), $name);
}
Ejemplo n.º 12
0
/**
 * Edit a member.
 *
 * @param  AUTO_LINK			The ID of the member.
 * @param  ?SHORT_TEXT		The e-mail address. (NULL: don't change)
 * @param  ?BINARY			Whether posts are previewed before they are made. (NULL: don't change)
 * @param  ?integer			Day of date of birth. (NULL: don't change) (-1: deset)
 * @param  ?integer			Month of date of birth. (NULL: don't change) (-1: deset)
 * @param  ?integer			Year of date of birth. (NULL: don't change) (-1: deset)
 * @param  ?ID_TEXT			The member timezone. (NULL: don't change)
 * @param  ?GROUP				The members primary (NULL: don't change).
 * @param  array				A map of custom fields values (field-id=>value).
 * @param  ?ID_TEXT			The members default theme. (NULL: don't change)
 * @param  ?BINARY			Whether the members age may be shown. (NULL: don't change)
 * @param  ?BINARY			Whether the member sees signatures in posts. (NULL: don't change)
 * @param  ?BINARY			Whether the member automatically is enabled for notifications for content they contribute to. (NULL: don't change)
 * @param  ?LANGUAGE_NAME	The members language. (NULL: don't change)
 * @param  ?BINARY			Whether the member allows e-mails via the site. (NULL: don't change)
 * @param  ?BINARY			Whether the member allows e-mails from staff via the site. (NULL: don't change)
 * @param  ?BINARY			Whether the profile has been validated (NULL: do not change this). (NULL: don't change)
 * @param  ?string			The username. (NULL: don't change)
 * @param  ?string			The password. (NULL: don't change)
 * @param  ?BINARY			Whether the member likes to view zones without menus, when a choice is available. (NULL: don't change)
 * @param  ?BINARY			Whether the member username will be highlighted. (NULL: don't change)
 * @param  ?SHORT_TEXT		Usergroups that may PT the member. (NULL: don't change)
 * @param  ?LONG_TEXT		Rules that other members must agree to before they may start a PT with the member. (NULL: don't change)
 * @param  ?TIME				When the member is on probation until (NULL: don't change)
 * @param  ?TIME				When the member joined (NULL: don't change)
 * @param  ?URLPATH			Avatar (NULL: don't change)
 * @param  ?LONG_TEXT		Signature (NULL: don't change)
 * @param  ?BINARY			Banned status (NULL: don't change)
 * @param  ?URLPATH			Photo URL (NULL: don't change)
 * @param  ?URLPATH			URL of thumbnail of photo (NULL: don't change)
 * @param  ?SHORT_TEXT		Password salt (NULL: don't change)
 * @param  ?ID_TEXT			Password compatibility scheme (NULL: don't change)
 * @param  boolean			Whether to skip security checks and most of the change-triggered emails
 */
function ocf_edit_member($member_id, $email_address, $preview_posts, $dob_day, $dob_month, $dob_year, $timezone, $primary_group, $custom_fields, $theme, $reveal_age, $views_signatures, $auto_monitor_contrib_content, $language, $allow_emails, $allow_emails_from_staff, $validated = NULL, $username = NULL, $password = NULL, $zone_wide = 1, $highlighted_name = NULL, $pt_allow = '*', $pt_rules_text = '', $on_probation_until = NULL, $join_time = NULL, $avatar_url = NULL, $signature = NULL, $is_perm_banned = NULL, $photo_url = NULL, $photo_thumb_url = NULL, $salt = NULL, $password_compatibility_scheme = NULL, $skip_checks = false)
{
    require_code('type_validation');
    if (!$skip_checks) {
        $old_email_address = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_email_address');
        if (!is_null($email_address) && ($email_address != '' || $old_email_address != '' && !has_specific_permission(get_member(), 'member_maintenance')) && !is_valid_email_address($email_address)) {
            warn_exit(do_lang_tempcode('_INVALID_EMAIL_ADDRESS', escape_html($email_address)));
        }
    }
    if (!is_null($username) && $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_password_compat_scheme') != 'remote') {
        if (!$skip_checks) {
            ocf_check_name_valid($username, $member_id, $password);
            require_code('urls2');
            suggest_new_idmoniker_for('members', 'view', strval($member_id), $username);
        }
    }
    // Supplement custom field values given with defaults, and check constraints
    $all_fields = ocf_get_all_custom_fields_match($GLOBALS['OCF_DRIVER']->get_members_groups($member_id));
    foreach ($all_fields as $field) {
        $field_id = $field['id'];
        if (array_key_exists($field_id, $custom_fields)) {
            if (!$skip_checks) {
                if ($field['cf_public_view'] == 0 && $member_id != get_member() && !has_specific_permission(get_member(), 'view_any_profile_field')) {
                    access_denied('I_ERROR');
                }
                if ($field['cf_owner_view'] == 0 && $member_id == get_member() && !has_specific_permission(get_member(), 'view_any_profile_field')) {
                    access_denied('I_ERROR');
                }
                if ($field['cf_owner_set'] == 0 && $member_id == get_member() && !has_specific_permission(get_member(), 'view_any_profile_field')) {
                    access_denied('I_ERROR');
                }
            }
        }
    }
    // Set custom profile field values
    $all_fields_types = collapse_2d_complexity('id', 'cf_type', $all_fields);
    $changes = array();
    foreach ($custom_fields as $field => $value) {
        if (!array_key_exists($field, $all_fields_types)) {
            continue;
        }
        // Trying to set a field we're not allowed to (doesn't apply to our group)
        $change = ocf_set_custom_field($member_id, $field, $value, $all_fields_types[$field], true);
        if (!is_null($change)) {
            $changes = array_merge($changes, $change);
        }
    }
    if (count($changes) != 0) {
        $GLOBALS['FORUM_DB']->query_update('f_member_custom_fields', $changes, array('mf_member_id' => $member_id), '', 1);
    }
    $old_primary_group = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_primary_group');
    $_pt_rules_text = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_pt_rules_text');
    $_signature = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_signature');
    $update = array();
    if (!is_null($theme)) {
        $update['m_theme'] = $theme;
    }
    if (!is_null($preview_posts)) {
        $update['m_preview_posts'] = $preview_posts;
    }
    if (!is_null($dob_day)) {
        $update['m_dob_day'] = $dob_day == -1 ? NULL : $dob_day;
    }
    if (!is_null($dob_month)) {
        $update['m_dob_month'] = $dob_month == -1 ? NULL : $dob_month;
    }
    if (!is_null($dob_year)) {
        $update['m_dob_year'] = $dob_year == -1 ? NULL : $dob_year;
    }
    if (!is_null($timezone)) {
        $update['m_timezone_offset'] = $timezone;
    }
    if (!is_null($reveal_age)) {
        $update['m_reveal_age'] = $reveal_age;
    }
    if (!is_null($email_address)) {
        $update['m_email_address'] = $email_address;
    }
    if (!is_null($views_signatures)) {
        $update['m_views_signatures'] = $views_signatures;
    }
    if (!is_null($auto_monitor_contrib_content)) {
        $update['m_auto_monitor_contrib_content'] = $auto_monitor_contrib_content;
    }
    if (!is_null($language)) {
        $update['m_language'] = $language;
    }
    if (!is_null($allow_emails)) {
        $update['m_allow_emails'] = $allow_emails;
    }
    if (!is_null($allow_emails_from_staff)) {
        $update['m_allow_emails_from_staff'] = $allow_emails_from_staff;
    }
    if (!is_null($zone_wide)) {
        $update['m_zone_wide'] = $zone_wide;
    }
    if (!is_null($pt_allow)) {
        $update['m_pt_allow'] = $pt_allow;
    }
    if (!is_null($pt_rules_text)) {
        $update['m_pt_rules_text'] = lang_remap_comcode($_pt_rules_text, $pt_rules_text, $GLOBALS['FORUM_DB']);
    }
    if ($skip_checks || has_specific_permission(get_member(), 'probate_members')) {
        $update['m_on_probation_until'] = $on_probation_until;
    }
    if (!is_null($join_time)) {
        $update['m_join_time'] = $join_time;
    }
    if (!is_null($avatar_url)) {
        $update['m_avatar_url'] = $avatar_url;
    }
    if (!is_null($signature)) {
        $update['m_signature'] = lang_remap_comcode($_signature, $signature, $GLOBALS['FORUM_DB']);
    }
    if (!is_null($is_perm_banned)) {
        $update['m_is_perm_banned'] = $is_perm_banned;
    }
    if (!is_null($photo_url)) {
        $update['m_photo_url'] = $photo_url;
    }
    if (!is_null($photo_thumb_url)) {
        $update['m_photo_thumb_url'] = $photo_thumb_url;
    }
    $old_username = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_username');
    if (!is_null($username) && $username != $old_username && ($skip_checks || has_actual_page_access(get_member(), 'admin_ocf_join') || has_specific_permission($member_id, 'rename_self'))) {
        $update['m_username'] = $username;
        // Reassign personal galleries
        if (addon_installed('galleries')) {
            require_lang('galleries');
            $personal_galleries = $GLOBALS['SITE_DB']->query('SELECT fullname,parent_id FROM ' . get_table_prefix() . 'galleries WHERE name LIKE \'member_' . strval($member_id) . '_%\'');
            foreach ($personal_galleries as $gallery) {
                $parent_title = get_translated_text($GLOBALS['SITE_DB']->query_value('galleries', 'fullname', array('name' => $gallery['parent_id'])));
                if (get_translated_text($gallery['fullname']) == do_lang('PERSONAL_GALLERY_OF', $old_username, $parent_title)) {
                    lang_remap($gallery['fullname'], do_lang('PERSONAL_GALLERY_OF', $username, $parent_title), $GLOBALS['FORUM_DB']);
                }
            }
        }
        require_code('notifications');
        $subject = do_lang('USERNAME_CHANGED_MAIL_SUBJECT', $username, $old_username, NULL, get_lang($member_id));
        $mail = do_lang('USERNAME_CHANGED_MAIL', comcode_escape(get_site_name()), comcode_escape($username), comcode_escape($old_username), get_lang($member_id));
        dispatch_notification('ocf_username_changed', NULL, $subject, $mail, array($member_id));
        $subject = do_lang('STAFF_USERNAME_CHANGED_MAIL_SUBJECT', $username, $old_username, NULL, get_site_default_lang());
        $mail = do_lang('STAFF_USERNAME_CHANGED_MAIL', comcode_escape(get_site_name()), comcode_escape($username), comcode_escape($old_username), get_site_default_lang());
        dispatch_notification('ocf_username_changed_staff', NULL, $subject, $mail);
        // Fix cacheing for usernames
        $to_fix = array('f_forums/f_cache_last_username', 'f_posts/p_poster_name_if_guest', 'f_topics/t_cache_first_username', 'f_topics/t_cache_last_username');
        foreach ($to_fix as $fix) {
            list($table, $field) = explode('/', $fix);
            $GLOBALS['FORUM_DB']->query_update($table, array($field => $username), array($field => $old_username));
        }
    }
    if (!is_null($password)) {
        if (is_null($password_compatibility_scheme) && get_value('no_password_hashing') === '1') {
            $password_compatibility_scheme = 'plain';
            $update['m_password_change_code'] = '';
            $salt = '';
        }
        if (!is_null($salt) || !is_null($password_compatibility_scheme)) {
            if (!is_null($salt)) {
                $update['m_pass_salt'] = $salt;
            }
            if (!is_null($password_compatibility_scheme)) {
                $update['m_password_compat_scheme'] = $password_compatibility_scheme;
            }
            $update['m_pass_hash_salted'] = $password;
        } else {
            $update['m_password_change_code'] = '';
            $salt = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_pass_salt');
            $update['m_pass_hash_salted'] = md5($salt . md5($password));
            $update['m_password_compat_scheme'] = '';
        }
        if (!$skip_checks) {
            $part_b = '';
            if (!has_actual_page_access(get_member(), 'admin_ocf_join')) {
                $part_b = do_lang('PASSWORD_CHANGED_MAIL_BODY_2', get_ip_address());
            }
            $mail = do_lang('PASSWORD_CHANGED_MAIL_BODY', get_site_name(), $part_b, NULL, get_lang($member_id));
            $old_email_address = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_email_address');
            if ($old_email_address != $email_address) {
                $GLOBALS['FORUM_DB']->query_update('f_invites', array('i_email_address' => $old_email_address), array('i_email_address' => $email_address));
            }
            if ($member_id == get_member() || get_value('disable_password_change_mails_for_staff') !== '1') {
                if (get_page_name() != 'admin_ocf_join') {
                    require_code('notifications');
                    dispatch_notification('ocf_password_changed', NULL, do_lang('PASSWORD_CHANGED_MAIL_SUBJECT', NULL, NULL, NULL, get_lang($member_id)), $mail, array($member_id), NULL, 2);
                }
            }
        }
    }
    if (!is_null($validated)) {
        $update['m_validated_email_confirm_code'] = '';
        if (addon_installed('unvalidated')) {
            $update['m_validated'] = $validated;
        }
    }
    if (!is_null($highlighted_name)) {
        $update['m_highlighted_name'] = $highlighted_name;
    }
    if (!is_null($primary_group)) {
        $update['m_primary_group'] = $primary_group;
    }
    $old_validated = $GLOBALS['OCF_DRIVER']->get_member_row_field($member_id, 'm_validated');
    $GLOBALS['FORUM_DB']->query_update('f_members', $update, array('id' => $member_id), '', 1);
    if (get_member() != $member_id) {
        log_it('EDIT_MEMBER_PROFILE', strval($member_id), $username);
    }
    if ($old_validated == 0 && $validated == 1) {
        require_code('mail');
        $_login_url = build_url(array('page' => 'login'), get_module_zone('login'), NULL, false, false, true);
        $login_url = $_login_url->evaluate();
        mail_wrap(do_lang('VALIDATED_MEMBER_SUBJECT', get_site_name(), NULL, get_lang($member_id)), do_lang('MEMBER_VALIDATED', get_site_name(), $username, $login_url, get_lang($member_id)), array($email_address), $username);
    }
    // Decache from run-time cache
    unset($GLOBALS['FORUM_DRIVER']->MEMBER_ROWS_CACHED[$member_id]);
    unset($GLOBALS['MEMBER_CACHE_FIELD_MAPPINGS'][$member_id]);
    unset($GLOBALS['TIMEZONE_MEMBER_CACHE'][$member_id]);
    unset($GLOBALS['USER_NAME_CACHE'][$member_id]);
}
Ejemplo n.º 13
0
/**
 * 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);
}
Ejemplo n.º 14
0
/**
 * 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
}
Ejemplo n.º 15
0
/**
 * 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));
}