예제 #1
0
파일: news.php 프로젝트: erico-deh/ocPortal
/**
 * Edit a news category.
 *
 * @param  AUTO_LINK			The news category to edit
 * @param  ?SHORT_TEXT		The title (NULL: keep as-is)
 * @param  ?SHORT_TEXT		The image (NULL: keep as-is)
 * @param  ?LONG_TEXT		The notes (NULL: keep as-is)
 * @param  ?MEMBER			The owner (NULL: public)
*/
function edit_news_category($id, $title, $img, $notes, $owner = NULL)
{
    $myrows = $GLOBALS['SITE_DB']->query_select('news_categories', array('nc_title', 'nc_img', 'notes'), 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('news', 'misc', strval($id), $title);
    log_it('EDIT_NEWS_CATEGORY', strval($id), $title);
    if (is_null($title)) {
        $title = get_translated_text($myrow['nc_title']);
    }
    if (is_null($img)) {
        $img = $myrow['nc_img'];
    }
    if (is_null($notes)) {
        $notes = $myrow['notes'];
    }
    $GLOBALS['SITE_DB']->query_update('news_categories', array('nc_title' => lang_remap($myrow['nc_title'], $title), 'nc_img' => $img, 'notes' => $notes, 'nc_owner' => $owner), array('id' => $id), '', 1);
    require_code('themes2');
    tidy_theme_img_code($img, $myrow['nc_img'], 'news_categories', 'nc_img');
    decache('main_news');
    decache('side_news');
    decache('side_news_archive');
    decache('bottom_news');
    decache('side_news_categories');
}
예제 #2
0
/**
 * Edit a ticket type, keeping the integer ID the same.
 *
 * @param  integer			The old ticket type
 * @param  ?SHORT_TEXT		The new ticket type (NULL: do not change)
 * @param  BINARY				Whether guest e-mail addresses are mandatory for new tickets
 * @param  BINARY				Whether the FAQ should be searched before submitting a new ticket
 */
function edit_ticket_type($old_ticket_type, $new_ticket_type, $guest_emails_mandatory, $search_faq)
{
    $GLOBALS['SITE_DB']->query_update('ticket_types', array('guest_emails_mandatory' => $guest_emails_mandatory, 'search_faq' => $search_faq), array('ticket_type' => $old_ticket_type), '', 1);
    if (!is_null($new_ticket_type)) {
        lang_remap($old_ticket_type, $new_ticket_type);
    }
    log_it('EDIT_TICKET_TYPE', strval($old_ticket_type));
}
예제 #3
0
/**
 * Edit a multi moderation.
 *
 * @param  AUTO_LINK		The ID of the multi moderation we are editing.
 * @param  SHORT_TEXT	The name of the multi moderation.
 * @param  LONG_TEXT		The default post text to add when applying (may be blank).
 * @param  ?AUTO_LINK	The forum to move the topic when applying (NULL: do not move).
 * @param  ?BINARY		The pin state after applying (NULL: unchanged).
 * @param  ?BINARY		The sink state after applying (NULL: unchanged).
 * @param  ?BINARY		The open state after applying (NULL: unchanged).
 * @param  SHORT_TEXT 	The forum multi code for where this multi moderation may be applied.
 * @param  SHORT_TEXT 	The title suffix.
 */
function ocf_edit_multi_moderation($id, $name, $post_text, $move_to, $pin_state, $sink_state, $open_state, $forum_multi_code, $title_suffix)
{
    $_name = $GLOBALS['FORUM_DB']->query_value('f_multi_moderations', 'mm_name', array('id' => $id));
    if ($move_to == -1) {
        $move_to = NULL;
    }
    if ($pin_state == -1) {
        $pin_state = NULL;
    }
    if ($open_state == -1) {
        $open_state = NULL;
    }
    if ($sink_state == -1) {
        $sink_state = NULL;
    }
    $GLOBALS['FORUM_DB']->query_update('f_multi_moderations', array('mm_name' => lang_remap($_name, $name, $GLOBALS['FORUM_DB']), 'mm_post_text' => $post_text, 'mm_move_to' => $move_to, 'mm_pin_state' => $pin_state, 'mm_sink_state' => $sink_state, 'mm_open_state' => $open_state, 'mm_forum_multi_code' => $forum_multi_code, 'mm_title_suffix' => $title_suffix), array('id' => $id), '', 1);
    log_it('EDIT_MULTI_MODERATION', strval($id), $name);
}
예제 #4
0
 /**
  * Standard modular run function for setting features from the setup wizard.
  */
 function set_fields()
 {
     if (get_forum_type() != 'ocf') {
         return;
     }
     $dbs_back = $GLOBALS['NO_DB_SCOPE_CHECK'];
     $GLOBALS['NO_DB_SCOPE_CHECK'] = true;
     require_lang('ocf');
     if (post_param_integer('have_default_rank_set', 0) == 0) {
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('f_groups', 'id', array('id' => db_get_first_id() + 8));
         if (!is_null($test)) {
             $promotion_target = ocf_get_group_property(db_get_first_id() + 8, 'promotion_target');
             if (!is_null($promotion_target)) {
                 $GLOBALS['SITE_DB']->query_update('f_groups', array('g_promotion_target' => NULL, 'g_promotion_threshold' => NULL, 'g_rank_image' => ''), array('id' => db_get_first_id() + 8), '', 1);
                 for ($i = db_get_first_id() + 4; $i < db_get_first_id() + 8; $i++) {
                     require_code('ocf_groups_action');
                     require_code('ocf_groups_action2');
                     ocf_delete_group($i);
                 }
             }
             $_name = ocf_get_group_property(db_get_first_id() + 8, 'name');
             if (is_integer($_name)) {
                 lang_remap($_name, do_lang('MEMBER'));
             }
         }
     }
     if (post_param_integer('have_default_full_emoticon_set', 0) == 0) {
         $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'f_emoticons WHERE e_code<>\':P\' AND e_code<>\';)\' AND e_code<>\':)\' AND e_code<>\':)\' AND e_code<>\':\\\'(\'');
     }
     if (post_param_integer('have_default_cpf_set', 0) == 0) {
         $fields = array('im_aim', 'im_msn', 'im_yahoo', 'im_skype', 'interests', 'location', 'occupation');
         foreach ($fields as $field) {
             $test = $GLOBALS['SITE_DB']->query_value_null_ok('f_custom_fields f LEFT JOIN ' . get_table_prefix() . 'translate t ON t.id=f.cf_name', 'f.id', array('text_original' => do_lang('DEFAULT_CPF_' . $field . '_NAME')));
             if (!is_null($test)) {
                 require_code('ocf_members_action');
                 require_code('ocf_members_action2');
                 ocf_delete_custom_field($test);
             }
         }
     }
     $GLOBALS['NO_DB_SCOPE_CHECK'] = $dbs_back;
 }
예제 #5
0
/**
 * Edit a zone.
 *
 * @param  ID_TEXT		The current name of the zone
 * @param  SHORT_TEXT	The zone title
 * @param  ID_TEXT		The zones default page
 * @param  SHORT_TEXT	The header text
 * @param  ID_TEXT		The theme
 * @param  BINARY			Whether the zone is wide
 * @param  BINARY			Whether the zone requires a session for pages to be used
 * @param  BINARY			Whether the zone in displayed in the menu coded into some themes
 * @param  ID_TEXT		The new name of the zone
 */
function actual_edit_zone($zone, $title, $default_page, $header_text, $theme, $wide, $require_session, $displayed_in_menu, $new_zone)
{
    if ($zone != $new_zone) {
        require_code('type_validation');
        if (!is_alphanumeric($new_zone, true)) {
            warn_exit(do_lang_tempcode('BAD_CODENAME'));
        }
        if (get_file_base() != get_custom_file_base()) {
            warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
        }
        // Check doesn't already exist
        $test = $GLOBALS['SITE_DB']->query_value_null_ok('zones', 'zone_header_text', array('zone_name' => $new_zone));
        if (!is_null($test)) {
            warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($new_zone)));
        }
        require_code('abstract_file_manager');
        force_have_afm_details();
        afm_move($zone, $new_zone);
    }
    $_header_text = $GLOBALS['SITE_DB']->query_value('zones', 'zone_header_text', array('zone_name' => $zone));
    $_title = $GLOBALS['SITE_DB']->query_value('zones', 'zone_title', array('zone_name' => $zone));
    $GLOBALS['SITE_DB']->query_update('zones', array('zone_name' => $new_zone, 'zone_title' => lang_remap($_title, $title), 'zone_default_page' => $default_page, 'zone_header_text' => lang_remap($_header_text, $header_text), 'zone_theme' => $theme, 'zone_wide' => $wide, 'zone_require_session' => $require_session, 'zone_displayed_in_menu' => $displayed_in_menu), array('zone_name' => $zone), '', 1);
    if ($new_zone != $zone) {
        actual_rename_zone_lite($zone, $new_zone, true);
        $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => $new_zone), array('i_url' => $zone), '', 1);
    }
    // If we're in this zone, update the theme
    global $ZONE;
    if ($ZONE['zone_name'] == $zone) {
        $ZONE['theme'] = $theme;
    }
    decache('side_zone_jump');
    decache('side_stored_menu');
    decache('main_sitemap');
    persistant_cache_delete(array('ZONE', $zone));
    persistant_cache_delete('ALL_ZONES');
    log_it('EDIT_ZONE', $zone);
}
예제 #6
0
파일: seo2.php 프로젝트: erico-deh/ocPortal
/**
 * Explictly sets the meta information for the specified resource.
 *
 * @param  ID_TEXT		The type of resource (e.g. download)
 * @param  ID_TEXT		The ID of the resource
 * @param  SHORT_TEXT	The keywords to use
 * @param  SHORT_TEXT	The description to use
 */
function seo_meta_set_for_explicit($type, $id, $keywords, $description)
{
    if ($description == STRING_MAGIC_NULL) {
        return;
    }
    if ($keywords == STRING_MAGIC_NULL) {
        return;
    }
    $description = str_replace(chr(10), ' ', $description);
    $rows = $GLOBALS['SITE_DB']->query_select('seo_meta', array('meta_keywords', 'meta_description'), array('meta_for_type' => $type, 'meta_for_id' => $id), '', 1);
    if (array_key_exists(0, $rows)) {
        lang_remap($rows[0]['meta_keywords'], $keywords);
        lang_remap($rows[0]['meta_description'], $description);
    } else {
        $GLOBALS['SITE_DB']->query_insert('seo_meta', array('meta_for_type' => $type, 'meta_for_id' => $id, 'meta_keywords' => insert_lang($keywords, 2), 'meta_description' => insert_lang($description, 2)));
    }
    if (function_exists('decache')) {
        decache('side_tag_cloud');
    }
    if (function_exists('persistant_cache_delete')) {
        persistant_cache_delete(array('seo', $type, $id));
    }
}
예제 #7
0
/**
 * Edit an award type
 *
 * @param  AUTO_LINK		The ID
 * @param  SHORT_TEXT	The title
 * @param  LONG_TEXT		The description
 * @param  integer		How many points are given to the awardee
 * @param  ID_TEXT		The content type the award type is for
 * @param  BINARY			Whether to not show the awardee when displaying this award
 * @param  integer		The approximate time in hours between awards (e.g. 168 for a week)
 */
function edit_award_type($id, $title, $description, $points, $content_type, $hide_awardee, $update_time_hours)
{
    $_title = $GLOBALS['SITE_DB']->query_value_null_ok('award_types', 'a_title', array('id' => $id));
    if (is_null($_title)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    $_description = $GLOBALS['SITE_DB']->query_value('award_types', 'a_description', array('id' => $id));
    $GLOBALS['SITE_DB']->query_update('award_types', array('a_title' => lang_remap_comcode($_title, $title), 'a_description' => lang_remap($_description, $description), 'a_points' => $points, 'a_content_type' => filter_naughty_harsh($content_type), 'a_hide_awardee' => $hide_awardee, 'a_update_time_hours' => $update_time_hours), array('id' => $id));
    log_it('EDIT_AWARD_TYPE', strval($id), $title);
}
예제 #8
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'));
}
예제 #9
0
파일: cedi.php 프로젝트: erico-deh/ocPortal
/**
 * Edit a CEDI page
 *
 * @param  AUTO_LINK		The page ID
 * @param  SHORT_TEXT	The page title
 * @param  LONG_TEXT		The page description
 * @param  LONG_TEXT		Hidden notes pertaining to the page
 * @param  BINARY			Whether to hide the posts on the page by default
 * @param  SHORT_TEXT	Meta keywords
 * @param  LONG_TEXT		Meta description
 * @param  ?MEMBER		The member doing the action (NULL: current member)
 */
function cedi_edit_page($id, $title, $description, $notes, $hide_posts, $meta_keywords, $meta_description, $member = NULL)
{
    if (is_null($member)) {
        $member = get_member();
    }
    $pages = $GLOBALS['SITE_DB']->query_select('seedy_pages', array('*'), array('id' => $id), '', 1);
    if (!array_key_exists(0, $pages)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    $page = $pages[0];
    $_description = $page['description'];
    $_title = $page['title'];
    $GLOBALS['SITE_DB']->query_update('seedy_children', array('title' => $title), array('title' => get_translated_text($_title), 'child_id' => $id));
    require_code('attachments2');
    require_code('attachments3');
    $GLOBALS['SITE_DB']->query_update('seedy_pages', array('hide_posts' => $hide_posts, 'description' => update_lang_comcode_attachments($_description, $description, 'cedi_page', strval($id), NULL, true), 'notes' => $notes, 'title' => lang_remap($_title, $title)), array('id' => $id), '', 1);
    $GLOBALS['SITE_DB']->query_insert('seedy_changes', array('the_action' => 'CEDI_EDIT_PAGE', 'the_page' => $id, 'date_and_time' => time(), 'ip' => get_ip_address(), 'the_user' => $member));
    require_code('seo2');
    seo_meta_set_for_explicit('seedy_page', strval($id), $meta_keywords, $meta_description);
    dispatch_cedi_page_notification($id, 'EDIT');
}
예제 #10
0
/**
 * Edit a Welcome E-mail.
 *
 * @param  AUTO_LINK		The ID
 * @param  SHORT_TEXT	A name for the Welcome E-mail
 * @param  SHORT_TEXT	The subject of the Welcome E-mail
 * @param  LONG_TEXT		The message body of the Welcome E-mail
 * @param  integer		The number of hours before sending the e-mail
 * @param  ?AUTO_LINK	What newsletter to send out to instead of members (NULL: none)
 */
function ocf_edit_welcome_email($id, $name, $subject, $text, $send_time, $newsletter)
{
    $_subject = $GLOBALS['SITE_DB']->query_value('f_welcome_emails', 'w_subject', array('id' => $id));
    $_text = $GLOBALS['SITE_DB']->query_value('f_welcome_emails', 'w_text', array('id' => $id));
    $GLOBALS['SITE_DB']->query_update('f_welcome_emails', array('w_name' => $name, 'w_newsletter' => $newsletter, 'w_subject' => lang_remap($_subject, $subject), 'w_text' => lang_remap($_text, $text), 'w_send_time' => $send_time), array('id' => $id), '', 1);
    log_it('EDIT_WELCOME_EMAIL', strval($id), get_translated_text($_subject));
}
예제 #11
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);
}
예제 #12
0
/**
 * Edit a menu item.
 *
 * @param  AUTO_LINK		The ID of the menu item to edit.
 * @param  SHORT_TEXT	The name of the menu to add the item to.
 * @param  integer		The relative order of this item on the menu.
 * @param  ?AUTO_LINK	The menu item ID of the parent branch of the menu item (NULL: is on root).
 * @param  SHORT_TEXT	The caption.
 * @param  SHORT_TEXT	The URL (in entry point form).
 * @param  BINARY			Whether people who may not view the entry point do not see the link.
 * @param  SHORT_TEXT	Match-keys to identify what pages the item is shown on.
 * @param  BINARY			Whether it is an expanded branch.
 * @param  BINARY			Whether the link will open in a new window.
 * @param  SHORT_TEXT	The tooltip (blank: none).
 */
function edit_menu_item($id, $menu, $order, $parent, $caption, $url, $check_permissions, $page_only, $expanded, $new_window, $caption_long)
{
    $_caption = $GLOBALS['SITE_DB']->query_value('menu_items', 'i_caption', array('id' => $id));
    $_caption_long = $GLOBALS['SITE_DB']->query_value('menu_items', 'i_caption_long', array('id' => $id));
    $GLOBALS['SITE_DB']->query_update('menu_items', array('i_menu' => $menu, 'i_order' => $order, 'i_parent' => $parent, 'i_caption' => lang_remap($_caption, $caption), 'i_caption_long' => lang_remap($_caption_long, $caption_long), 'i_url' => $url, 'i_check_permissions' => $check_permissions, 'i_page_only' => $page_only, 'i_expanded' => $expanded, 'i_new_window' => $new_window), array('id' => $id), '', 1);
    log_it('EDIT_MENU_ITEM', strval($id), $caption);
}
예제 #13
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     // A lot of "peripheral architectural" tables are defined here. Central ones are defined in the installer -- as they need to be installed before any module.
     // This is always the first module to be installed.
     if ($upgrade_from < 3 && !is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('seo_meta', array('id' => '*AUTO', 'meta_for_type' => 'ID_TEXT', 'meta_for_id' => 'ID_TEXT', 'meta_keywords' => 'LONG_TRANS', 'meta_description' => 'LONG_TRANS'));
         $GLOBALS['SITE_DB']->create_index('seo_meta', 'alt_key', array('meta_for_type', 'meta_for_id'));
         $GLOBALS['SITE_DB']->create_index('seo_meta', 'ftjoin_keywords', array('meta_keywords'));
     }
     if ($upgrade_from < 4 && !is_null($upgrade_from)) {
         // The sessions table isn't defined in this module... this is a throwback from before upgrader.php was fully developed
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'session_confirmed', 'BINARY', 0);
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'cache_username', 'SHORT_TEXT');
         $GLOBALS['SITE_DB']->create_table('https_pages', array('https_page_name' => '*ID_TEXT'));
         $GLOBALS['SITE_DB']->create_table('attachments', array('id' => '*AUTO', 'a_member_id' => 'USER', 'a_file_size' => '?INTEGER', 'a_url' => 'URLPATH', 'a_description' => 'SHORT_TEXT', 'a_thumb_url' => 'SHORT_TEXT', 'a_original_filename' => 'SHORT_TEXT', 'a_num_downloads' => 'INTEGER', 'a_last_downloaded_time' => '?INTEGER', 'a_add_time' => 'INTEGER'));
         $GLOBALS['SITE_DB']->create_index('attachments', 'a_add_time', array('a_member_id', 'a_add_time'));
         $GLOBALS['SITE_DB']->create_table('attachment_refs', array('id' => '*AUTO', 'r_referer_type' => 'ID_TEXT', 'r_referer_id' => 'ID_TEXT', 'a_id' => 'INTEGER'));
     }
     if ($upgrade_from < 4 || is_null($upgrade_from)) {
         add_specific_permission('_COMCODE', 'reuse_others_attachments', true);
     }
     if ($upgrade_from < 5 || is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('menu_items', array('id' => '*AUTO', 'i_menu' => 'ID_TEXT', 'i_order' => 'INTEGER', 'i_parent' => '?AUTO_LINK', 'i_caption' => 'SHORT_TRANS', 'i_caption_long' => 'SHORT_TRANS', 'i_url' => 'SHORT_TEXT', 'i_check_permissions' => 'BINARY', 'i_expanded' => 'BINARY', 'i_new_window' => 'BINARY', 'i_page_only' => 'ID_TEXT', 'i_theme_img_code' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('menu_items', 'menu_extraction', array('i_menu'));
         $GLOBALS['SITE_DB']->create_table('trackbacks', array('id' => '*AUTO', 'trackback_for_type' => 'ID_TEXT', 'trackback_for_id' => 'ID_TEXT', 'trackback_ip' => 'IP', 'trackback_time' => 'TIME', 'trackback_url' => 'SHORT_TEXT', 'trackback_title' => 'SHORT_TEXT', 'trackback_excerpt' => 'LONG_TEXT', 'trackback_name' => 'SHORT_TEXT'));
         $GLOBALS['SITE_DB']->create_index('trackbacks', 'trackback_for_type', array('trackback_for_type'));
         $GLOBALS['SITE_DB']->create_index('trackbacks', 'trackback_for_id', array('trackback_for_id'));
         $GLOBALS['SITE_DB']->create_index('trackbacks', 'trackback_time', array('trackback_time'));
         $GLOBALS['SITE_DB']->create_table('security_images', array('si_session_id' => '*INTEGER', 'si_time' => 'TIME', 'si_code' => 'INTEGER'));
         $GLOBALS['SITE_DB']->create_index('security_images', 'si_time', array('si_time'));
         $GLOBALS['SITE_DB']->create_table('member_tracking', array('mt_member_id' => '*USER', 'mt_cache_username' => 'ID_TEXT', 'mt_time' => '*TIME', 'mt_page' => '*ID_TEXT', 'mt_type' => '*ID_TEXT', 'mt_id' => '*ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('member_tracking', 'mt_page', array('mt_page'));
         $GLOBALS['SITE_DB']->create_index('member_tracking', 'mt_id', array('mt_page', 'mt_id', 'mt_type'));
         $GLOBALS['SITE_DB']->create_table('cache_on', array('cached_for' => '*ID_TEXT', 'cache_on' => 'LONG_TEXT', 'cache_ttl' => 'INTEGER'));
     }
     if ($upgrade_from < 6 && !is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->add_table_field('config', 'shared_hosting_restricted', 'BINARY', 0);
         $GLOBALS['SITE_DB']->add_table_field('zones', 'zone_title', 'SHORT_TRANS', '');
         $rows = $GLOBALS['SITE_DB']->query_select('zones', array('zone_name', 'zone_title'));
         foreach ($rows as $row) {
             $zone = $row['zone_name'];
             $st = $row['zone_title'];
             $_zone = ucfirst($zone);
             switch ($zone) {
                 case 'docs':
                     $_zone = do_lang('GUIDES');
                     break;
                 case 'forum':
                     $_zone = do_lang('SECTION_FORUMS');
                     break;
                 case '':
                     $_zone = do_lang('_WELCOME');
                     break;
                 case 'site':
                     $_zone = do_lang('SITE');
                     break;
                 case 'cms':
                     $_zone = do_lang('CMS');
                     break;
                 case 'collaboration':
                     $_zone = do_lang('collaboration');
                     break;
                 case 'adminzone':
                     $_zone = do_lang('ADMIN_ZONE');
                     break;
             }
             $_lang2 = do_lang('ZONE_' . $zone, NULL, NULL, NULL, NULL, false);
             if (!is_null($_lang2)) {
                 $_zone = $_lang2;
             }
             lang_remap($st, $_zone);
         }
     }
     if ($upgrade_from < 7 && !is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->add_table_field('gsp', 'the_page', 'ID_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('gsp', 'module_the_name', 'ID_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('gsp', 'category_name', 'ID_TEXT');
         $GLOBALS['SITE_DB']->change_primary_key('gsp', array('group_id', 'specific_permission', 'the_page', 'module_the_name', 'category_name'));
         $GLOBALS['SITE_DB']->add_table_field('gsp', 'the_value', 'BINARY');
         $GLOBALS['SITE_DB']->query_update('gsp', array('the_value' => 1));
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'session_invisible', 'BINARY');
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'the_zone', 'ID_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'the_page', 'ID_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'the_type', 'ID_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'the_id', 'ID_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'the_title', 'SHORT_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('menu_items', 'i_caption_long', 'SHORT_TRANS');
         $GLOBALS['SITE_DB']->add_table_field('attachments', 'a_description', 'SHORT_TEXT');
         $GLOBALS['SITE_DB']->alter_table_field('attachments', 'a_url', 'URLPATH');
         $GLOBALS['SITE_DB']->query('UPDATE ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'menu_items SET i_url=replace(i_url,\':type=gui\',\':type=misc\')');
         $GLOBALS['SITE_DB']->query('UPDATE ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'menu_items SET i_url=replace(i_url,\':type=choose\',\':type=misc\')');
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:seedy_page:type=misc'), array('i_url' => '_SEARCH:seedy_page:type=page'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:staff:type=misc'), array('i_url' => '_SEARCH:staff:type=directory'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:points:type=misc'), array('i_url' => '_SEARCH:points:type=search'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:members:type=misc'), array('i_url' => '_SEARCH:members:type=directory'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:galleries:type=misc'), array('i_url' => '_SEARCH:galleries:type=list'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:downloads:type=misc'), array('i_url' => '_SEARCH:downloads:type=cat'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:catalogues:type=misc'), array('i_url' => '_SEARCH:catalogues:type=list'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:calendar:type=misc'), array('i_url' => '_SEARCH:calendar:type=calendar'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:news:type=misc'), array('i_url' => '_SEARCH:news:type=list'), '', 1);
     }
     if ($upgrade_from < 7 || is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('validated_once', array('hash' => '*MD5'));
         $GLOBALS['SITE_DB']->create_table('edit_pings', array('id' => '*AUTO', 'the_page' => 'ID_TEXT', 'the_type' => 'ID_TEXT', 'the_id' => 'ID_TEXT', 'the_time' => 'TIME', 'the_member' => 'USER'));
         $GLOBALS['SITE_DB']->create_table('translate_history', array('id' => '*AUTO', 'lang_id' => 'AUTO_LINK', 'language' => '*LANGUAGE_NAME', 'text_original' => 'LONG_TEXT', 'broken' => 'BINARY', 'action_member' => 'USER', 'action_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_table('long_values', array('the_name' => '*ID_TEXT', 'the_value' => 'LONG_TEXT', 'date_and_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_table('tutorial_links', array('the_name' => '*ID_TEXT', 'the_value' => 'LONG_TEXT'));
     }
     if ($upgrade_from < 9 && !is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->add_table_field('zones', 'zone_displayed_in_menu', 'BINARY', 1);
         $GLOBALS['SITE_DB']->add_table_field('config', 'c_set', 'BINARY', 1);
         $options = $GLOBALS['SITE_DB']->query_select('config', array('the_name'), array('config_value' => NULL));
         foreach ($options as $o) {
             $GLOBALS['SITE_DB']->query_update('config', array('config_value' => '', 'c_set' => 0), array('the_name' => $o['the_name']), '', 1);
         }
         $GLOBALS['SITE_DB']->add_table_field('config', 'c_data', 'SHORT_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('menu_items', 'i_theme_img_code', 'ID_TEXT');
     }
     if ($upgrade_from < 8 || is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('msp', array('active_until' => '*TIME', 'member_id' => '*INTEGER', 'specific_permission' => '*ID_TEXT', 'the_page' => '*ID_TEXT', 'module_the_name' => '*ID_TEXT', 'category_name' => '*ID_TEXT', 'the_value' => 'BINARY'));
         $GLOBALS['SITE_DB']->create_index('msp', 'mspname', array('specific_permission', 'the_page', 'module_the_name', 'category_name'));
         $GLOBALS['SITE_DB']->create_index('msp', 'mspmember_id', array('member_id'));
         $GLOBALS['SITE_DB']->create_table('member_zone_access', array('active_until' => '*TIME', 'zone_name' => '*ID_TEXT', 'member_id' => '*USER'));
         $GLOBALS['SITE_DB']->create_index('member_zone_access', 'mzazone_name', array('zone_name'));
         $GLOBALS['SITE_DB']->create_index('member_zone_access', 'mzamember_id', array('member_id'));
         $GLOBALS['SITE_DB']->create_table('member_page_access', array('active_until' => '*TIME', 'page_name' => '*ID_TEXT', 'zone_name' => '*ID_TEXT', 'member_id' => '*USER'));
         $GLOBALS['SITE_DB']->create_index('member_page_access', 'mzaname', array('page_name', 'zone_name'));
         $GLOBALS['SITE_DB']->create_index('member_page_access', 'mzamember_id', array('member_id'));
         $GLOBALS['SITE_DB']->create_table('member_category_access', array('active_until' => '*TIME', 'module_the_name' => '*ID_TEXT', 'category_name' => '*ID_TEXT', 'member_id' => '*USER'));
         $GLOBALS['SITE_DB']->create_index('member_category_access', 'mcaname', array('module_the_name', 'category_name'));
         $GLOBALS['SITE_DB']->create_index('member_category_access', 'mcamember_id', array('member_id'));
     }
     if ($upgrade_from < 9 || is_null($upgrade_from)) {
         /*$GLOBALS['SITE_DB']->create_table('confirmed_mobiles',array(
         			'm_phone_number'=>'*SHORT_TEXT',
         			'm_member_id'=>'USER',
         			'm_time'=>'TIME',
         			'm_confirm_code'=>'IP'
         		));*/
         /*$GLOBALS['SITE_DB']->create_index('confirmed_mobiles','confirmed_numbers',array('m_confirm_code'));*/
         add_specific_permission('STAFF_ACTIONS', 'assume_any_member', false, true);
         $GLOBALS['SITE_DB']->create_table('autosave', array('id' => '*AUTO', 'a_member_id' => 'USER', 'a_key' => 'LONG_TEXT', 'a_value' => 'LONG_TEXT', 'a_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_index('autosave', 'myautosaves', array('a_member_id'));
         $GLOBALS['SITE_DB']->create_table('messages_to_render', array('id' => '*AUTO', 'r_session_id' => 'AUTO_LINK', 'r_message' => 'LONG_TEXT', 'r_type' => 'ID_TEXT', 'r_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_index('messages_to_render', 'forsession', array('r_session_id'));
         $GLOBALS['SITE_DB']->create_table('url_title_cache', array('id' => '*AUTO', 't_url' => 'URLPATH', 't_title' => 'SHORT_TEXT'));
     }
     if ($upgrade_from < 10 && !is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'db_meta SET m_type=\'SHORT_INTEGER\' WHERE m_name LIKE \'' . db_encode_like('%allow\\_comments') . '\'');
     }
     if ($upgrade_from < 10 || is_null($upgrade_from)) {
         add_config_option('URL_MONIKERS_ENABLED', 'url_monikers_enabled', 'tick', 'return \'1\';', 'SITE', 'ADVANCED');
         $GLOBALS['SITE_DB']->create_table('url_id_monikers', array('id' => '*AUTO', 'm_resource_page' => 'ID_TEXT', 'm_resource_type' => 'ID_TEXT', 'm_resource_id' => 'ID_TEXT', 'm_moniker' => 'SHORT_TEXT', 'm_deprecated' => 'BINARY'));
         $GLOBALS['SITE_DB']->create_index('url_id_monikers', 'uim_pagelink', array('m_resource_page', 'm_resource_type', 'm_resource_id'));
         $GLOBALS['SITE_DB']->create_index('url_id_monikers', 'uim_moniker', array('m_moniker'));
         $GLOBALS['SITE_DB']->create_table('review_supplement', array('r_post_id' => '*AUTO_LINK', 'r_rating_type' => '*ID_TEXT', 'r_rating' => 'SHORT_INTEGER', 'r_topic_id' => 'AUTO_LINK', 'r_rating_for_id' => 'ID_TEXT', 'r_rating_for_type' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('review_supplement', 'rating_for_id', array('r_rating_for_id'));
         // TODO: Move these into sms addon_registry hook, once these hooks support installation
         $GLOBALS['SITE_DB']->create_table('sms_log', array('id' => '*AUTO', 's_member_id' => 'USER', 's_time' => 'TIME', 's_trigger_ip' => 'IP'));
         $GLOBALS['SITE_DB']->create_index('sms_log', 'sms_log_for', array('s_member_id', 's_time'));
         $GLOBALS['SITE_DB']->create_index('sms_log', 'sms_trigger_ip', array('s_trigger_ip'));
         require_lang('ocf');
         $GLOBALS['FORUM_DRIVER']->install_create_custom_field('mobile_phone_number', 20, 1, 0, 1, 0, do_lang('SPECIAL_CPF__ocp_mobile_phone_number_DESCRIPTION'), 'short_text');
         add_specific_permission('GENERAL_SETTINGS', 'use_sms', false);
         add_specific_permission('GENERAL_SETTINGS', 'sms_higher_limit', false);
         add_specific_permission('GENERAL_SETTINGS', 'sms_higher_trigger_limit', false);
         $GLOBALS['SITE_DB']->create_table('logged_mail_messages', array('id' => '*AUTO', 'm_subject' => 'LONG_TEXT', 'm_message' => 'LONG_TEXT', 'm_to_email' => 'LONG_TEXT', 'm_to_name' => 'LONG_TEXT', 'm_from_email' => 'SHORT_TEXT', 'm_from_name' => 'SHORT_TEXT', 'm_priority' => 'SHORT_INTEGER', 'm_attachments' => 'LONG_TEXT', 'm_no_cc' => 'BINARY', 'm_as' => 'USER', 'm_as_admin' => 'BINARY', 'm_in_html' => 'BINARY', 'm_date_and_time' => 'TIME', 'm_member_id' => 'USER', 'm_url' => 'LONG_TEXT', 'm_queued' => 'BINARY', 'm_template' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('logged_mail_messages', 'recentmessages', array('m_date_and_time'));
         $GLOBALS['SITE_DB']->create_index('logged_mail_messages', 'queued', array('m_queued'));
         $GLOBALS['SITE_DB']->create_table('link_tracker', array('id' => '*AUTO', 'c_date_and_time' => 'TIME', 'c_member_id' => 'USER', 'c_ip_address' => 'IP', 'c_url' => 'URLPATH'));
         $GLOBALS['SITE_DB']->create_index('url_title_cache', 't_url', array('t_url'));
         $GLOBALS['SITE_DB']->create_table('incoming_uploads', array('id' => '*AUTO', 'i_submitter' => 'USER', 'i_date_and_time' => 'TIME', 'i_orig_filename' => 'URLPATH', 'i_save_url' => 'URLPATH'));
     }
     if ($upgrade_from < 11 && !is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'comcode_pages SET p_submitter=2 WHERE p_submitter=' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()));
     }
     if (is_null($upgrade_from) || $upgrade_from < 12) {
         $GLOBALS['SITE_DB']->drop_if_exists('cache');
         $GLOBALS['SITE_DB']->create_table('cache', array('cached_for' => '*ID_TEXT', 'identifier' => '*MINIID_TEXT', 'the_value' => 'LONG_TEXT', 'date_and_time' => 'TIME', 'the_theme' => '*ID_TEXT', 'lang' => '*LANGUAGE_NAME', 'langs_required' => 'LONG_TEXT'));
         $GLOBALS['SITE_DB']->create_index('cache', 'cached_ford', array('date_and_time'));
         $GLOBALS['SITE_DB']->create_index('cache', 'cached_fore', array('cached_for'));
         $GLOBALS['SITE_DB']->create_index('cache', 'cached_forf', array('lang'));
         $GLOBALS['SITE_DB']->create_index('cache', 'cached_forg', array('identifier'));
         $GLOBALS['SITE_DB']->create_index('cache', 'cached_forh', array('the_theme'));
     }
     if (is_null($upgrade_from) || $upgrade_from < 13) {
         if (!$GLOBALS['SITE_DB']->table_exists('f_group_member_timeouts')) {
             $GLOBALS['SITE_DB']->create_table('f_group_member_timeouts', array('member_id' => '*USER', 'group_id' => '*GROUP', 'timeout' => 'TIME'));
         }
     }
     if (!is_null($upgrade_from) && $upgrade_from < 13) {
         if (substr(get_db_type(), 0, 5) == 'mysql') {
             $GLOBALS['SITE_DB']->create_index('translate', 'equiv_lang', array('text_original(4)'));
             $GLOBALS['SITE_DB']->create_index('translate', 'decache', array('text_parsed(2)'));
         }
     }
     if (!is_null($upgrade_from) && $upgrade_from >= 10 && $upgrade_from < 14) {
         $GLOBALS['SITE_DB']->drop_if_exists('tracking');
         $GLOBALS['SITE_DB']->add_table_field('logged_mail_messages', 'm_template', 'ID_TEXT');
     }
     if (!is_null($upgrade_from) && $upgrade_from == 14) {
         $GLOBALS['SITE_DB']->alter_table_field('digestives_tin', 'd_from_member_id', '?USER');
     }
     if (is_null($upgrade_from) || $upgrade_from < 14) {
         $GLOBALS['SITE_DB']->create_table('temp_block_permissions', array('id' => '*AUTO', 'p_session_id' => 'AUTO_LINK', 'p_block_constraints' => 'LONG_TEXT', 'p_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_table('cron_caching_requests', array('id' => '*AUTO', 'c_codename' => 'ID_TEXT', 'c_map' => 'LONG_TEXT', 'c_timezone' => 'ID_TEXT', 'c_is_bot' => 'BINARY', 'c_in_panel' => 'BINARY', 'c_interlock' => 'BINARY', 'c_store_as_tempcode' => 'BINARY', 'c_lang' => 'LANGUAGE_NAME', 'c_theme' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('cron_caching_requests', 'c_compound', array('c_codename', 'c_theme', 'c_lang', 'c_timezone'));
         $GLOBALS['SITE_DB']->create_index('cron_caching_requests', 'c_is_bot', array('c_is_bot'));
         $GLOBALS['SITE_DB']->create_index('cron_caching_requests', 'c_in_panel', array('c_in_panel'));
         $GLOBALS['SITE_DB']->create_index('cron_caching_requests', 'c_interlock', array('c_interlock'));
         $GLOBALS['SITE_DB']->create_index('cron_caching_requests', 'c_store_as_tempcode', array('c_store_as_tempcode'));
         $GLOBALS['SITE_DB']->create_table('notifications_enabled', array('id' => '*AUTO', 'l_member_id' => 'USER', 'l_notification_code' => 'ID_TEXT', 'l_code_category' => 'SHORT_TEXT', 'l_setting' => 'INTEGER'));
         $GLOBALS['SITE_DB']->create_index('notifications_enabled', 'l_member_id', array('l_member_id', 'l_notification_code'));
         $GLOBALS['SITE_DB']->create_index('notifications_enabled', 'l_code_category', array('l_code_category'));
         $GLOBALS['SITE_DB']->create_table('digestives_tin', array('id' => '*AUTO', 'd_subject' => 'LONG_TEXT', 'd_message' => 'LONG_TEXT', 'd_from_member_id' => '?USER', 'd_to_member_id' => 'USER', 'd_priority' => 'SHORT_INTEGER', 'd_no_cc' => 'BINARY', 'd_date_and_time' => 'TIME', 'd_notification_code' => 'ID_TEXT', 'd_code_category' => 'SHORT_TEXT', 'd_frequency' => 'INTEGER'));
         $GLOBALS['SITE_DB']->create_index('digestives_tin', 'd_date_and_time', array('d_date_and_time'));
         $GLOBALS['SITE_DB']->create_index('digestives_tin', 'd_frequency', array('d_frequency'));
         $GLOBALS['SITE_DB']->create_index('digestives_tin', 'd_to_member_id', array('d_to_member_id'));
         $GLOBALS['SITE_DB']->create_table('digestives_consumed', array('c_member_id' => '*USER', 'c_frequency' => '*INTEGER', 'c_time' => 'TIME'));
     }
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('rating', array('id' => '*AUTO', 'rating_for_type' => 'ID_TEXT', 'rating_for_id' => 'ID_TEXT', 'rating_member' => 'USER', 'rating_ip' => 'IP', 'rating_time' => 'TIME', 'rating' => 'SHORT_INTEGER'));
         $GLOBALS['SITE_DB']->create_index('rating', 'alt_key', array('rating_for_type', 'rating_for_id'));
         $GLOBALS['SITE_DB']->create_index('rating', 'rating_for_id', array('rating_for_id'));
     }
 }
예제 #14
0
 /**
  * Standard pointstore item configuration save function.
  */
 function save_config()
 {
     $i = 0;
     $rows = list_to_map('id', $GLOBALS['SITE_DB']->query_select('pstore_customs', array('*')));
     while (array_key_exists('custom_' . strval($i), $_POST)) {
         $id = post_param_integer('custom_' . strval($i));
         $title = post_param('custom_title_' . strval($i));
         $description = post_param('custom_description_' . strval($i));
         $enabled = post_param_integer('custom_enabled_' . strval($i), 0);
         $cost = post_param_integer('custom_cost_' . strval($i));
         $one_per_member = post_param_integer('custom_one_per_member_' . strval($i), 0);
         $delete = post_param_integer('delete_custom_' . strval($i), 0);
         $_title = $rows[$id]['c_title'];
         $_description = $rows[$id]['c_description'];
         if ($delete == 1) {
             delete_lang($_title);
             delete_lang($_description);
             $GLOBALS['SITE_DB']->query_delete('pstore_customs', array('id' => $id), '', 1);
         } else {
             $GLOBALS['SITE_DB']->query_update('pstore_customs', array('c_title' => lang_remap($_title, $title), 'c_description' => lang_remap($_description, $description), 'c_enabled' => $enabled, 'c_cost' => $cost, 'c_one_per_member' => $one_per_member), array('id' => $id), '', 1);
         }
         $i++;
     }
     $title = post_param('custom_title', NULL);
     if (!is_null($title)) {
         $description = post_param('custom_description');
         $enabled = post_param_integer('custom_enabled', 0);
         $cost = post_param_integer('custom_cost');
         $one_per_member = post_param_integer('custom_one_per_member', 0);
         $GLOBALS['SITE_DB']->query_insert('pstore_customs', array('c_title' => insert_lang($title, 2), 'c_description' => insert_lang($description, 2), 'c_enabled' => $enabled, 'c_cost' => $cost, 'c_one_per_member' => $one_per_member));
     }
 }
예제 #15
0
/**
 * Edit a usergroup subscription.
 *
 * @param  AUTO_LINK		The ID
 * @param  SHORT_TEXT	The title
 * @param  LONG_TEXT		The description
 * @param  SHORT_TEXT	The cost
 * @param  integer		The length
 * @param  SHORT_TEXT	The units for the length
 * @set    y m d w
 * @param  ?GROUP			The usergroup that purchasing gains membership to (NULL: super members)
 * @param  BINARY			Whether this is applied to primary usergroup membership
 * @param  BINARY			Whether this is currently enabled
 * @param  ?LONG_TEXT	The text of the e-mail to send out when a subscription is start (NULL: default)
 * @param  ?LONG_TEXT	The text of the e-mail to send out when a subscription is ended (NULL: default)
 * @param  ?LONG_TEXT	The text of the e-mail to send out when a subscription cannot be renewed because the subproduct is gone (NULL: default)
 */
function edit_usergroup_subscription($id, $title, $description, $cost, $length, $length_units, $group_id, $uses_primary, $enabled, $mail_start, $mail_end, $mail_uhoh)
{
    $dbs_bak = $GLOBALS['NO_DB_SCOPE_CHECK'];
    $GLOBALS['NO_DB_SCOPE_CHECK'] = true;
    $rows = $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_select('f_usergroup_subs', array('*'), array('id' => $id), '', 1);
    if (!array_key_exists(0, $rows)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    $myrow = $rows[0];
    // If usergroup has changed, do a move
    if ($myrow['s_group_id'] != $group_id) {
        require_code('ocf_groups_action');
        require_code('ocf_groups_action2');
        $product = 'USERGROUP' . strval($id);
        $subscriptions = $GLOBALS['SITE_DB']->query_select('subscriptions', array('*'), array('s_type_code' => $product));
        foreach ($subscriptions as $sub) {
            $member_id = $sub['s_member_id'];
            if (get_value('unofficial_ecommerce') == '1' && get_forum_type() != 'ocf') {
                $GLOBALS['FORUM_DB']->remove_member_from_group($member_id, $group_id);
                $GLOBALS['FORUM_DB']->add_member_to_group($member_id, $group_id);
            } else {
                $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_delete('f_group_members', array('gm_group_id' => $group_id, 'gm_member_id' => $member_id), '', 1);
                ocf_add_member_to_group($member_id, $group_id);
            }
        }
    }
    $_title = $myrow['s_title'];
    $_description = $myrow['s_description'];
    $_mail_start = $myrow['s_mail_start'];
    $_mail_end = $myrow['s_mail_end'];
    $_mail_uhoh = $myrow['s_mail_uhoh'];
    $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_update('f_usergroup_subs', array('s_title' => lang_remap($_title, $title, $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']), 's_description' => lang_remap($_description, $description, $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']), 's_cost' => $cost, 's_length' => $length, 's_length_units' => $length_units, 's_group_id' => $group_id, 's_uses_primary' => $uses_primary, 's_enabled' => $enabled, 's_mail_start' => lang_remap($_mail_start, $mail_start, $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']), 's_mail_end' => lang_remap($_mail_end, $mail_end, $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']), 's_mail_uhoh' => lang_remap($_mail_uhoh, $mail_uhoh, $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB'])), array('id' => $id), '', 1);
    log_it('EDIT_USERGROUP_SUBSCRIPTION', strval($id), $title);
    $GLOBALS['NO_DB_SCOPE_CHECK'] = $dbs_bak;
}
예제 #16
0
/**
 * Edit a custom profile field.
 *
 * @param  AUTO_LINK  	The ID of the custom profile field.
 * @param  SHORT_TEXT 	Name of the field.
 * @param  SHORT_TEXT 	Description of the field.
 * @param  LONG_TEXT  	The default value for the field.
 * @param  BINARY			Whether the field is publicly viewable.
 * @param  BINARY			Whether the field is viewable by the owner.
 * @param  BINARY			Whether the field may be set by the owner.
 * @param  BINARY			Whether the field should be encrypted.
 * @param  BINARY			Whether the field is to be shown on the join form
 * @param  BINARY			Whether this field is shown in posts and places where member details are highlighted (such as an image in a member gallery).
 * @param  BINARY			Whether this field is shown in preview places, such as in the teaser for a member gallery.
 * @param  integer		The order of this field relative to other fields.
 * @param  LONG_TEXT		The usergroups that this field is confined to (comma-separated list).
 * @param  ID_TEXT		The type of the field.
 * @set    short_text long_text short_trans long_trans integer upload picture url list tick float
 * @param  BINARY			Whether it is required that every member have this field filled in.
 */
function ocf_edit_custom_field($id, $name, $description, $default, $public_view, $owner_view, $owner_set, $encrypted, $required, $show_in_posts, $show_in_post_previews, $order, $only_group, $type, $show_on_join_form)
{
    $dbs_back = $GLOBALS['NO_DB_SCOPE_CHECK'];
    $GLOBALS['NO_DB_SCOPE_CHECK'] = true;
    if ($only_group == '-1') {
        $only_group = '';
    }
    $info = $GLOBALS['FORUM_DB']->query_select('f_custom_fields', array('cf_name', 'cf_description'), array('id' => $id), '', 1);
    $_name = $info[0]['cf_name'];
    $_description = $info[0]['cf_description'];
    $map = array('cf_name' => lang_remap($_name, $name, $GLOBALS['FORUM_DB']), 'cf_description' => lang_remap($_description, $description, $GLOBALS['FORUM_DB']), 'cf_default' => $default, 'cf_public_view' => $public_view, 'cf_owner_view' => $owner_view, 'cf_owner_set' => $owner_set, 'cf_required' => $required, 'cf_show_in_posts' => $show_in_posts, 'cf_show_in_post_previews' => $show_in_post_previews, 'cf_order' => $order, 'cf_only_group' => $only_group, 'cf_type' => $type, 'cf_show_on_join_form' => $show_on_join_form);
    $GLOBALS['FORUM_DB']->query_update('f_custom_fields', $map, array('id' => $id), '', 1);
    list($_type, $index) = get_cpf_storage_for($type);
    require_code('database_action');
    $GLOBALS['FORUM_DB']->delete_index_if_exists('f_member_custom_fields', 'mcf' . strval($id));
    $GLOBALS['FORUM_DB']->delete_index_if_exists('f_member_custom_fields', '#mcf_ft_' . strval($id));
    $indices_count = $GLOBALS['FORUM_DB']->query_value('db_meta_indices', 'COUNT(*)', array('i_table' => 'f_member_custom_fields'));
    if ($indices_count < 60) {
        if ($index) {
            if ($_type != 'LONG_TEXT') {
                $GLOBALS['FORUM_DB']->create_index('f_member_custom_fields', 'mcf' . strval($id), array('field_' . strval($id)), 'mf_member_id');
            }
            if (strpos($_type, '_TEXT') !== false) {
                $GLOBALS['FORUM_DB']->create_index('f_member_custom_fields', '#mcf_ft_' . strval($id), array('field_' . strval($id)), 'mf_member_id');
            }
        } elseif (strpos($type, 'trans') !== false || $type == 'posting_field') {
            $GLOBALS['FORUM_DB']->create_index('f_member_custom_fields', 'mcf' . strval($id), array('field_' . strval($id)), 'mf_member_id');
            // For joins
        }
    }
    log_it('EDIT_CUSTOM_PROFILE_FIELD', strval($id), $name);
    $GLOBALS['NO_DB_SCOPE_CHECK'] = $dbs_back;
}
예제 #17
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);
}
예제 #18
0
 /**
  * UI for a setup wizard step (done).
  *
  * @return tempcode		The UI
  */
 function step10()
 {
     $title = get_page_title('SETUP_WIZARD_STEP', true, array(integer_format(10), integer_format(10)));
     $GLOBALS['NO_QUERY_LIMIT'] = true;
     require_code('abstract_file_manager');
     force_have_afm_details();
     if (function_exists('set_time_limit')) {
         @set_time_limit(600);
     }
     require_code('config2');
     require_code('menus2');
     require_code('themes2');
     require_lang('zones');
     $header_text = post_param('header_text');
     $name = post_param('site_name');
     $theme = substr(preg_replace('#[^A-Za-z\\d]#', '_', $name), 0, 40);
     $installprofile = post_param('installprofile', '');
     if ($installprofile != '') {
         // Simplify down to a single menu
         foreach (array('main_community', 'main_content', 'main_features', 'main_website', 'root_website') as $merge_item) {
             $GLOBALS['SITE_DB']->query_update('menu_items', array('i_menu' => 'site'), array('i_menu' => $merge_item));
         }
         $duplicates = $GLOBALS['SITE_DB']->query_select('menu_items', array('id', 'COUNT(*) AS cnt'), array('i_menu' => 'site'), 'GROUP BY i_url');
         foreach ($duplicates as $duplicate) {
             if ($duplicate['cnt'] > 1) {
                 delete_menu_item($duplicate['id']);
             }
         }
         delete_menu_item_simple('site:');
         // Remove panel_top
         if (addon_installed('redirects_editor')) {
             $GLOBALS['SITE_DB']->query_delete('redirects', array('r_to_page' => 'panel_top'));
         }
         $fullpath = get_custom_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/panel_top.txt';
         if (file_exists($fullpath)) {
             @copy($fullpath, $fullpath . '.' . strval(time()));
         }
         $myfile = @fopen($fullpath, 'wt');
         if ($myfile !== false) {
             fwrite($myfile, '');
             fclose($myfile);
             fix_permissions($fullpath);
             sync_file($fullpath);
         }
         // Run any specific code for the profile
         $object = mixed();
         if (is_file(get_file_base() . '/sources/hooks/modules/admin_setupwizard_installprofiles/' . $installprofile . '.php') || is_file(get_file_base() . '/sources_custom/hooks/modules/admin_setupwizard_installprofiles/' . $installprofile . '.php')) {
             require_code('hooks/modules/admin_setupwizard_installprofiles/' . $installprofile);
             $object = object_factory('Hook_admin_setupwizard_installprofiles_' . $installprofile, true);
         }
         if (!is_null($object)) {
             $object->install_code();
             $installprofileblocks = $object->default_blocks();
         } else {
             $installprofileblocks = array();
         }
     } else {
         $installprofileblocks = array();
     }
     if (post_param_integer('skip_8', 0) == 0 && function_exists('imagecreatefromstring') && addon_installed('themewizard')) {
         require_code('themewizard');
         // Make theme
         global $IMG_CODES;
         $old_img_codes_site = $GLOBALS['SITE_DB']->query_select('theme_images', array('id', 'path'), array('theme' => $GLOBALS['FORUM_DRIVER']->get_theme(), 'lang' => user_lang()));
         if (!file_exists(get_custom_file_base() . '/themes/' . $theme)) {
             make_theme($theme, 'default', 'equations', post_param('seed_hex'), true, post_param_integer('dark', 0) == 1);
         }
         foreach (array($theme, 'default') as $logo_save_theme) {
             $logo = generate_logo($name, $header_text, false, $logo_save_theme, 'logo-template');
             $path = 'themes/' . $logo_save_theme . '/images_custom/-logo.png';
             @imagepng($logo, get_custom_file_base() . '/' . $path) or intelligent_write_error($path);
             actual_edit_theme_image('logo/-logo', $logo_save_theme, get_site_default_lang(), 'logo/-logo', $path, true);
             if (addon_installed('collaboration_zone')) {
                 actual_edit_theme_image('logo/collaboration-logo', $logo_save_theme, get_site_default_lang(), 'logo/collaboration-logo', $path, true);
             }
             imagedestroy($logo);
             $logo = generate_logo($name, $header_text, false, $logo_save_theme, 'trimmed-logo-template');
             $path = 'themes/' . $logo_save_theme . '/images_custom/trimmed-logo.png';
             @imagepng($logo, get_custom_file_base() . '/' . $path) or intelligent_write_error($path);
             actual_edit_theme_image('logo/trimmed-logo', $logo_save_theme, get_site_default_lang(), 'logo/trimmed-logo', $path, true);
             imagedestroy($logo);
         }
         $myfile = fopen(get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/theme.ini', 'wt');
         fwrite($myfile, 'title=' . $name . chr(10));
         fwrite($myfile, 'description=' . do_lang('NA') . chr(10));
         if (fwrite($myfile, 'author=ocPortal' . chr(10)) == 0) {
             warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
         }
         fclose($myfile);
         sync_file(get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/theme.ini');
         $IMG_CODES['site'] = $old_img_codes_site;
         // Just so it renders with the old theme
     }
     // Set options
     if (post_param_integer('skip_3', 0) == 0) {
         set_option('site_name', $name);
         set_option('copyright', 'Copyright &copy; ' . $name . ' ' . date('Y'));
         set_option('description', post_param('description'));
         set_option('site_scope', post_param('site_scope'));
         set_option('copyright', post_param('copyright'));
         set_option('staff_address', post_param('staff_address'));
         set_option('keywords', post_param('keywords'));
         set_option('google_analytics', post_param('google_analytics'));
         set_option('fixed_width', post_param('fixed_width', '0'));
         $a = $GLOBALS['SITE_DB']->query_value('zones', 'zone_header_text', array('zone_name' => ''));
         lang_remap($a, $header_text);
         $b = $GLOBALS['SITE_DB']->query_value_null_ok('zones', 'zone_header_text', array('zone_name' => 'site'));
         if (!is_null($b)) {
             lang_remap($b, $header_text);
         }
     }
     if (post_param_integer('skip_9', 0) == 0) {
         set_option('site_closed', strval(post_param_integer('site_closed', 0)));
         set_option('closed', post_param('closed', ''));
     }
     // Set addons
     if (post_param_integer('skip_4', 0) == 0 && get_file_base() == get_custom_file_base()) {
         require_lang('addons');
         require_code('addons');
         $addons_installed = find_installed_addons();
         $uninstalling = array();
         foreach ($addons_installed as $addon_row) {
             if (post_param_integer('addon_' . $addon_row['addon_name'], 0) == 0) {
                 $uninstalling[$addon_row['addon_name']] = $addon_row;
             }
         }
         if (!file_exists(get_file_base() . '/.svn')) {
             do {
                 $cnt = count($uninstalling);
                 foreach ($addons_installed as $addon_row) {
                     if (array_key_exists($addon_row['addon_name'], $uninstalling)) {
                         $addon_row += read_addon_info($addon_row['addon_name']);
                         $addon_row['addon_author'] = '';
                         // Fudge, to stop it dying on warnings for official addons
                         // Check dependencies
                         $dependencies = $addon_row['addon_dependencies_on_this'];
                         foreach (array_keys($uninstalling) as $d) {
                             if (in_array($d, $dependencies)) {
                                 // Can mark this dependency as irrelevant, as we are uninstalling the addon for it anyway
                                 unset($dependencies[array_search($d, $dependencies)]);
                             }
                         }
                         if (count($dependencies) != 0) {
                             unset($uninstalling[$addon_row['addon_name']]);
                         }
                     }
                 }
             } while ($cnt != count($uninstalling));
             // Dependency chains can be complex, so loop until we're stopped finding anything changing
             foreach ($uninstalling as $addon_row) {
                 // Archive it off to exports/addons
                 if ($addon_row['addon_files'] != '') {
                     $file = preg_replace('#^[\\_\\.\\-]#', 'x', preg_replace('#[^\\w\\.\\-]#', '_', $addon_row['addon_name'])) . '.tar';
                     create_addon($file, explode(chr(10), $addon_row['addon_files']), $addon_row['addon_name'], implode(',', $addon_row['addon_incompatibilities']), implode(',', $addon_row['addon_dependencies']), $addon_row['addon_author'], $addon_row['addon_organisation'], $addon_row['addon_version'], $addon_row['addon_description'], 'imports/addons');
                 }
                 uninstall_addon($addon_row['addon_name']);
             }
         }
     }
     // Set features
     if (post_param_integer('skip_5', 0) == 0) {
         $hooks = find_all_hooks('modules', 'admin_setupwizard');
         foreach (array_keys($hooks) as $hook) {
             if (post_param_integer('addon_' . $hook, 0) == 1) {
                 $path = get_file_base() . '/sources_custom/modules/systems/admin_setupwizard/' . filter_naughty_harsh($hook) . '.php';
                 if (!file_exists($path)) {
                     $path = get_file_base() . '/sources/hooks/modules/admin_setupwizard/' . filter_naughty_harsh($hook) . '.php';
                 }
                 $_hook_bits = extract_module_functions($path, array('set_fields'));
                 if (is_array($_hook_bits[0])) {
                     call_user_func_array($_hook_bits[0][0], $_hook_bits[0][1]);
                 } else {
                     @eval($_hook_bits[0]);
                 }
             }
         }
         set_option('show_content_tagging', post_param('show_content_tagging', '0'));
         set_option('show_content_tagging_inline', post_param('show_content_tagging_inline', '0'));
         set_option('show_screen_actions', post_param('show_screen_actions', '0'));
     }
     // Zone structure
     $collapse_zones = post_param_integer('collapse_user_zones', 0) == 1;
     if (post_param_integer('skip_5', 0) == 0) {
         require_code('config2');
         set_option('collapse_user_zones', strval($collapse_zones));
         /*if (addon_installed('redirects_editor')) Old method
         		{
         			if ($collapse_zones)
         			{
         				$test=$GLOBALS['SITE_DB']->query_value_null_ok('redirects','r_from_page',array('r_from_page'=>'panel_left','r_from_zone'=>'site'));
         				if (is_null($test)) $GLOBALS['SITE_DB']->query_insert('redirects',array('r_from_page'=>'panel_left','r_from_zone'=>'site','r_to_page'=>'panel_left','r_to_zone'=>'','r_is_transparent'=>1));
         				$test=$GLOBALS['SITE_DB']->query_value_null_ok('redirects','r_from_page',array('r_from_page'=>'panel_right','r_from_zone'=>'site'));
         				if (is_null($test)) $GLOBALS['SITE_DB']->query_insert('redirects',array('r_from_page'=>'panel_right','r_from_zone'=>'site','r_to_page'=>'panel_right','r_to_zone'=>'','r_is_transparent'=>1));
         				$test=$GLOBALS['SITE_DB']->query_value_null_ok('redirects','r_from_page',array('r_from_page'=>'start','r_from_zone'=>'site'));
         				if (is_null($test)) $GLOBALS['SITE_DB']->query_insert('redirects',array('r_from_page'=>'start','r_from_zone'=>'site','r_to_page'=>'start','r_to_zone'=>'','r_is_transparent'=>1));
         			} else
         			{
         				$GLOBALS['SITE_DB']->query_delete('redirects',array('r_from_page'=>'panel_left','r_from_zone'=>'site','r_to_page'=>'panel_left','r_to_zone'=>''),'',1);
         				$GLOBALS['SITE_DB']->query_delete('redirects',array('r_from_page'=>'panel_right','r_from_zone'=>'site','r_to_page'=>'panel_right','r_to_zone'=>''),'',1);
         				$GLOBALS['SITE_DB']->query_delete('redirects',array('r_from_page'=>'start','r_from_zone'=>'site','r_to_page'=>'start','r_to_zone'=>''),'',1);
         			}
         		}*/
         if (post_param_integer('guest_zone_access', 0) == 1) {
             $guest_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($GLOBALS['FORUM_DRIVER']->get_guest_id());
             $test = $GLOBALS['SITE_DB']->query_value_null_ok('group_zone_access', 'zone_name', array('zone_name' => 'site', 'group_id' => $guest_groups[0]));
             if (is_null($test)) {
                 $GLOBALS['SITE_DB']->query_insert('group_zone_access', array('zone_name' => 'site', 'group_id' => $guest_groups[0]));
             }
         }
     }
     // Rules
     if (post_param_integer('skip_7', 0) == 0) {
         $fullpath = get_custom_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/rules.txt';
         if (file_exists($fullpath)) {
             @copy($fullpath, $fullpath . '.' . strval(time()));
             fix_permissions($fullpath . '.' . strval(time()));
             sync_file($fullpath . '.' . strval(time()));
         }
         $myfile = @fopen($fullpath, 'wt') or intelligent_write_error(get_custom_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/rules.txt');
         $rf = $this->get_rules_file(post_param('rules'));
         if (fwrite($myfile, $rf) < strlen($rf)) {
             warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
         }
         fclose($myfile);
         fix_permissions($fullpath);
         sync_file($fullpath);
     }
     $block_options = mixed();
     if ($installprofile != '' && !is_null($object)) {
         $block_options = $object->block_options();
     }
     // Blocks
     if (post_param_integer('skip_6', 0) == 0) {
         require_code('setupwizard');
         $page_structure = _get_zone_pages($installprofileblocks, $block_options, $collapse_zones, $installprofile);
         foreach ($page_structure as $zone => $zone_pages) {
             // Start
             $fullpath = get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . get_site_default_lang() . '/start.txt';
             if (file_exists($fullpath)) {
                 @copy($fullpath, $fullpath . '.' . strval(time()));
             }
             $myfile = @fopen($fullpath, 'wt') or intelligent_write_error($fullpath);
             if ($myfile !== false) {
                 if ($zone_pages['start'] != '') {
                     if (fwrite($myfile, $zone_pages['start']) == 0) {
                         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                     }
                 }
                 fclose($myfile);
                 fix_permissions($fullpath);
                 sync_file($fullpath);
             }
             // Left
             $fullpath = get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . get_site_default_lang() . '/panel_left.txt';
             if (file_exists($fullpath)) {
                 @copy($fullpath, $fullpath . '.' . strval(time()));
             }
             $myfile = @fopen($fullpath, 'wt');
             if ($myfile !== false) {
                 if ($zone_pages['left'] != '') {
                     if (fwrite($myfile, $zone_pages['left']) == 0) {
                         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                     }
                 }
                 fclose($myfile);
                 fix_permissions($fullpath);
                 sync_file($fullpath);
             }
             // Right
             $fullpath = get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . get_site_default_lang() . '/panel_right.txt';
             if (file_exists($fullpath)) {
                 @copy($fullpath, $fullpath . '.' . strval(time()));
             }
             $myfile = fopen($fullpath, 'wt');
             if ($myfile !== false) {
                 if ($zone_pages['right'] != '') {
                     if (fwrite($myfile, $zone_pages['right']) == 0) {
                         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                     }
                 }
                 fclose($myfile);
                 fix_permissions($fullpath);
                 sync_file($fullpath);
             }
         }
     }
     // We're done
     set_value('setup_wizard_completed', '1');
     // Clear some cacheing
     require_code('view_modes');
     require_code('zones3');
     erase_comcode_page_cache();
     erase_tempcode_cache();
     //persistant_cache_delete('OPTIONS');  Done by set_option
     persistant_cache_empty();
     erase_cached_templates();
     //breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang_tempcode('START'))));
     //breadcrumb_set_self(do_lang_tempcode('SETUP_WIZARD_STEP',integer_format(10),integer_format(10)));
     $url = build_url(array('page' => '_SELF', 'type' => 'step11'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
예제 #19
0
 /**
  * Add a menu item from details in POST.
  *
  * @param  ID_TEXT		The name of the menu the item is on
  * @param  integer		The ID of the menu item (i.e. what it is referenced as in POST)
  * @param  array			The map of IDs on the menu (ID=>parent)
  * @param  ?integer		The ID of the parent branch (NULL: no parent)
  * @param  array			The map of menu id=>string language IDs employed by items before the edit
  * @param  integer		The order this branch has in the editor (and due to linearly moving through, the number of branches shown assembled ready)
  */
 function add_menu_item($menu, $id, &$ids, $parent, &$old_menu_bits, &$order)
 {
     // Load in details of menu item
     $caption = post_param('caption_' . strval($id), '');
     // Default needed to workaround Opera problem
     $caption_long = post_param('caption_long_' . strval($id), '');
     // Default needed to workaround Opera problem
     $page_only = post_param('match_tags_' . strval($id), '');
     // Default needed to workaround Opera problem
     $theme_img_code = post_param('theme_img_code_' . strval($id), '');
     // Default needed to workaround Opera problem
     $check_permissions = post_param_integer('check_perms_' . strval($id), 0);
     $branch_type = post_param('branch_type_' . strval($id), 'branch_plus');
     // Default needed to workaround Opera problem
     if ($branch_type == 'branch_plus') {
         $expanded = 1;
     } else {
         $expanded = 0;
     }
     $new_window = post_param_integer('new_window_' . strval($id), 0);
     /*		if ($branch_type=='page')
     		{*/
     $url = post_param('url_' . strval($id), '');
     // See if we can tidy it back to a page-link
     if (preg_match('#^\\w+$#', $url) != 0) {
         $url = ':' . $url;
     }
     // So users do not have to think about zones
     $page_link = url_to_pagelink($url, true);
     if ($page_link != '') {
         $url = $page_link;
     } elseif (strpos($url, ':') === false) {
         $url = fixup_protocolless_urls($url);
     }
     //		} else $url='';
     $menu_save_map = array('i_menu' => $menu, 'i_order' => $order, 'i_parent' => $parent, 'i_url' => $url, 'i_check_permissions' => $check_permissions, 'i_expanded' => $expanded, 'i_new_window' => $new_window, 'i_page_only' => $page_only, 'i_theme_img_code' => $theme_img_code);
     // Save
     if (array_key_exists($id, $old_menu_bits)) {
         $lang_code = $old_menu_bits[$id]['i_caption'];
         $lang_code_2 = $old_menu_bits[$id]['i_caption_long'];
         $menu_save_map += array('i_caption' => $lang_code, 'i_caption_long' => $lang_code_2);
         unset($old_menu_bits[$id]);
         $insert_id = $id;
         $GLOBALS['SITE_DB']->query_update('menu_items', $menu_save_map, array('id' => $id));
         lang_remap($lang_code, $caption);
         lang_remap($lang_code_2, $caption_long);
     } else {
         $lang_code = insert_lang($caption, 1);
         $lang_code_2 = insert_lang($caption_long, 1);
         $menu_save_map += array('i_caption' => $lang_code, 'i_caption_long' => $lang_code_2);
         $insert_id = $GLOBALS['SITE_DB']->query_insert('menu_items', $menu_save_map, true);
     }
     // Menu item children
     $my_kids = array();
     foreach ($ids as $new_id => $child_parent) {
         if (strval($id) == $child_parent) {
             $my_kids[] = $new_id;
         }
     }
     foreach ($my_kids as $new_id) {
         $this->add_menu_item($menu, $new_id, $ids, $insert_id, $old_menu_bits, $order);
         $order++;
     }
 }
예제 #20
0
파일: lang.php 프로젝트: erico-deh/ocPortal
/**
 * Remap the specified comcode language id, and return the id again - the id isn't changed.
 *
 * @param  integer		The language entries id
 * @param  string			The text to remap to
 * @param  ?object		The database connection to use (NULL: standard site connection)
 * @param  ?string		The special identifier for this lang code on the page it will be displayed on; this is used to provide an explicit binding between languaged elements and greater templated areas (NULL: none)
 * @param  ?MEMBER		The member performing the change (NULL: current member)
 * @param  boolean		Whether to generate Comcode as arbitrary admin
 * @return integer		The language entries id
 */
function lang_remap_comcode($id, $text, $connection = NULL, $pass_id = NULL, $source_member = NULL, $as_admin = false)
{
    if (is_null($connection)) {
        $connection = $GLOBALS['SITE_DB'];
    }
    return lang_remap($id, $text, $connection, true, $pass_id, $source_member, $as_admin);
}
예제 #21
0
 /**
  * The actualiser to set match-key access.
  *
  * @return tempcode		The UI
  */
 function set_keys_access()
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/matchkeysecurity';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_permissions';
     $title = get_page_title('PAGE_MATCH_KEY_ACCESS');
     // Delete to cleanup
     $GLOBALS['SITE_DB']->query('DELETE FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'group_page_access WHERE page_name LIKE \'' . db_encode_like('%:%') . '\'');
     $mkeylang = collapse_2d_complexity('id', 'k_message', $GLOBALS['SITE_DB']->query_select('match_key_messages', array('id', 'k_message')));
     $GLOBALS['SITE_DB']->query_delete('match_key_messages');
     $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
     foreach ($_POST as $key => $val) {
         if (get_magic_quotes_gpc()) {
             $val = stripslashes($val);
         }
         // See if we can tidy it back to a page-link (assuming it's not one already)
         $page_link = url_to_pagelink($val, true);
         if ($page_link != '') {
             $val = $page_link;
         }
         if (substr($key, 0, 4) == 'key_' && $val != '') {
             foreach (array_keys($groups) as $gid) {
                 if (post_param_integer('p_' . substr($key, 4) . '__' . strval($gid), 0) == 1) {
                     $GLOBALS['SITE_DB']->query_insert('group_page_access', array('zone_name' => '/', 'page_name' => $val, 'group_id' => $gid));
                 }
             }
         }
         if (substr($key, 0, 5) == 'mkey_' && $val != '') {
             $id = substr($key, 5);
             if (substr($id, 0, 4) == 'new_' || !array_key_exists(intval($id), $mkeylang)) {
                 $GLOBALS['SITE_DB']->query_insert('match_key_messages', array('k_message' => insert_lang(post_param('msg_' . $id), 2), 'k_match_key' => $val));
             } else {
                 $GLOBALS['SITE_DB']->query_insert('match_key_messages', array('k_message' => lang_remap($mkeylang[intval($id)], post_param('msg_' . $id)), 'k_match_key' => $val));
                 unset($mkeylang[intval($id)]);
             }
         }
     }
     foreach ($mkeylang as $lid) {
         delete_lang($lid);
     }
     decache('main_sitemap');
     breadcrumb_set_parents(array(array('_SELF:_SELF:keys', do_lang_tempcode('PAGE_MATCH_KEY_ACCESS'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     // Show it worked / Refresh
     $url = build_url(array('page' => '_SELF', 'type' => 'keys'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
예제 #22
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);
}
예제 #23
0
 /**
  * Standard aed_module edit actualiser.
  *
  * @param  ID_TEXT		The entry being edited
  */
 function edit_actualisation($id)
 {
     $tag = post_param('tag');
     require_code('type_validation');
     if (!is_alphanumeric($tag, true)) {
         warn_exit(do_lang_tempcode('BAD_CODENAME'));
     }
     global $VALID_COMCODE_TAGS;
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('custom_comcode', 'tag_tag', array('tag_tag' => $tag));
     if ($id == $tag) {
         $test = NULL;
     }
     if (array_key_exists($tag, $VALID_COMCODE_TAGS) || !is_null($test)) {
         warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($tag)));
     }
     $old = $GLOBALS['SITE_DB']->query_select('custom_comcode', array('tag_title', 'tag_description'), array('tag_tag' => $id), '', 1);
     if (!array_key_exists(0, $old)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $_title = $old[0]['tag_title'];
     $_description = $old[0]['tag_description'];
     $GLOBALS['SITE_DB']->query_update('custom_comcode', array('tag_tag' => $tag, 'tag_title' => lang_remap($_title, post_param('title')), 'tag_description' => lang_remap($_description, post_param('description')), 'tag_replace' => post_param('replace'), 'tag_example' => post_param('example'), 'tag_parameters' => post_param('parameters'), 'tag_enabled' => post_param_integer('enabled', 0), 'tag_dangerous_tag' => post_param_integer('dangerous_tag', 0), 'tag_block_tag' => post_param_integer('block_tag', 0), 'tag_textual_tag' => post_param_integer('textual_tag', 0)), array('tag_tag' => $id), '', 1);
     $this->new_id = $tag;
     log_it('EDIT_' . $this->lang_type, $id);
 }
예제 #24
0
/**
 * Set a configuration option with the specified values.
 *
 * @param  ID_TEXT		The name of the value
 * @param  LONG_TEXT		The value
 * @param  ?ID_TEXT		The type of the option. This is normally ommited, but to save a DB lookup, may be passed through (NULL: work out the type)
 * @set    float integer tick line text transline transtext list date forum category usergroup
 * @param  ?LONG_TEXT	The current value of the config option (NULL: unknown). This is just for efficiency for remapping language config options.
 */
function set_option($name, $value, $type = NULL, $current_value = NULL)
{
    global $OPTIONS;
    if (is_null($type)) {
        global $GET_OPTION_LOOP;
        if ($GET_OPTION_LOOP != 1) {
            get_option($name);
        }
        // Ensure it's installed
        $type = $OPTIONS[$name]['the_type'];
        //$type=$GLOBALS['SITE_DB']->query_value('config','the_type',array('the_name'=>$name));
    }
    if ($type == 'transline' || $type == 'transtext') {
        //		$current_value=$GLOBALS['SITE_DB']->query_value('config','config_value',array('the_name'=>$name));
        if (array_key_exists('c_set', $OPTIONS[$name]) && $OPTIONS[$name]['c_set'] == 0) {
            $GLOBALS['SITE_DB']->query_update('config', array('config_value' => strval(insert_lang($value, 1)), 'c_set' => 1), array('the_name' => $name), '', 1);
        } else {
            $current_value = $OPTIONS[$name]['config_value'];
            if (!is_null($current_value)) {
                // Should never happen, but might during upgrading
                lang_remap(intval($current_value), $value);
            }
        }
    } else {
        $map = array('config_value' => $value);
        if (array_key_exists('c_set', $OPTIONS[$name])) {
            $map['c_set'] = 1;
        }
        $GLOBALS['SITE_DB']->query_update('config', $map, array('the_name' => $name), '', 1);
        $OPTIONS[$name]['config_value'] = $value;
    }
    $OPTIONS[$name]['config_value_translated'] = $value;
    if (function_exists('log_it')) {
        require_lang('config');
        log_it('CONFIGURATION', $name, $value);
    }
    if (function_exists('persistant_cache_delete')) {
        persistant_cache_delete('OPTIONS');
    }
}
예제 #25
0
        if (preg_match('#^catalogue\\_(existing|new)\\_(\\d*)$#', $key, $matches) != 0) {
            $catalogue = post_param('catalogue_' . $matches[1] . '_' . $matches[2], '');
            $days = post_param('days_' . $matches[1] . '_' . $matches[2], '');
            $label = post_param('label_' . $matches[1] . '_' . $matches[2], '');
            $price = post_param('price_' . $matches[1] . '_' . $matches[2], '');
            if ($catalogue != '' && $days != '' && $label != '' && $price != '') {
                if ($matches[1] == 'existing') {
                    $_label = $GLOBALS['SITE_DB']->query_value_null_ok('classifieds_prices', 'c_label', array('id' => intval($matches[2])));
                    if (is_null($_label)) {
                        $matches[1] = 'new';
                    }
                    // Was lost, so add as new
                }
                if ($matches[1] == 'existing') {
                    // Edit
                    $GLOBALS['SITE_DB']->query_update('classifieds_prices', array('c_catalogue_name' => $catalogue, 'c_days' => intval($days), 'c_label' => lang_remap($_label, $label), 'c_price' => floatval($price)), array('id' => intval($matches[2])), '', 1);
                } else {
                    // Add
                    $GLOBALS['SITE_DB']->query_insert('classifieds_prices', array('c_catalogue_name' => $catalogue, 'c_days' => intval($days), 'c_label' => insert_lang($label, 2), 'c_price' => floatval($price)));
                }
            } else {
                if ($matches[1] == 'existing') {
                    // Delete
                    $GLOBALS['SITE_DB']->query_delete('classifieds_prices', array('id' => intval($matches[2])), '', 1);
                }
            }
        }
    }
    attach_message(do_lang_tempcode('SUCCESS', 'inform'));
}
$title = get_page_title('CLASSIFIEDS');
예제 #26
0
/**
 * Edit a newsletter.
 *
 * @param  AUTO_LINK		The ID
 * @param  SHORT_TEXT	The title
 * @param  LONG_TEXT		The description
 */
function edit_newsletter($id, $title, $description)
{
    $_title = $GLOBALS['SITE_DB']->query_value('newsletters', 'title', array('id' => $id));
    $_description = $GLOBALS['SITE_DB']->query_value('newsletters', 'description', array('id' => $id));
    $GLOBALS['SITE_DB']->query_update('newsletters', array('title' => lang_remap($_title, $title), 'description' => lang_remap($_description, $description)), array('id' => $id), '', 1);
    log_it('EDIT_NEWSLETTER', strval($id), $_title);
}
예제 #27
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'));
}
예제 #28
0
 /**
  * The actualiser for managing the CEDI children of a page.
  *
  * @return tempcode	The UI.
  */
 function _edit_tree()
 {
     $_title = get_page_title('CEDI_EDIT_TREE');
     $_id = get_param_cedi_chain('id');
     $id = $_id[0];
     if (!has_category_access(get_member(), 'seedy_page', strval($id))) {
         access_denied('CATEGORY_ACCESS');
     }
     $childlinks = post_param('children');
     $member = get_member();
     check_specific_permission('seedy_manage_tree', array('seedy_page', $id));
     $hide_posts = $GLOBALS['SITE_DB']->query_value('seedy_pages', 'hide_posts', array('id' => $id));
     if (substr($childlinks, -1, 1) != "\n" && strlen($childlinks) > 0) {
         $childlinks .= "\n";
     }
     $no_children = substr_count($childlinks, "\n");
     if ($no_children > 300) {
         warn_exit(do_lang_tempcode('TOO_MANY_CEDI_CHILDREN'));
     }
     $start = 0;
     $GLOBALS['SITE_DB']->query_delete('seedy_children', array('parent_id' => $id));
     require_code('seo2');
     for ($i = 0; $i < $no_children; $i++) {
         $length = strpos($childlinks, chr(10), $start) - $start;
         $newlink = str_replace(chr(10), '', str_replace(chr(13), '', substr($childlinks, $start, $length)));
         if ($newlink != '') {
             // Find ID and title
             $q_pos = strpos($newlink, '!');
             $child_id_on_start = $q_pos !== false && $q_pos > 0 && is_numeric(substr($newlink, 0, $q_pos));
             if ($child_id_on_start) {
                 $title = substr($newlink, $q_pos + 1);
                 $child_id = intval(substr($newlink, 0, $q_pos));
                 $title_id = $GLOBALS['SITE_DB']->query_value_null_ok('seedy_pages', 'title', array('id' => $child_id));
                 if (is_null($title_id)) {
                     continue;
                 }
                 if ($title == '') {
                     $title = get_translated_text($title_id);
                 } else {
                     if (get_translated_text($title_id) != $title) {
                         $GLOBALS['SITE_DB']->query_update('seedy_pages', array('title' => lang_remap($title_id, $title)), array('id' => $child_id), '', 1);
                     }
                 }
             } else {
                 $title = $newlink;
                 $child_id = cedi_add_page($title, '', '', $hide_posts);
                 $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
                 $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
                 foreach (array_keys($groups) as $group_id) {
                     if (in_array($group_id, $admin_groups)) {
                         continue;
                     }
                     $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'seedy_page', 'category_name' => strval($child_id), 'group_id' => $group_id));
                 }
             }
             $GLOBALS['SITE_DB']->query_delete('seedy_children', array('parent_id' => $id, 'child_id' => $child_id), '', 1);
             // Just in case it was repeated
             $GLOBALS['SITE_DB']->query_insert('seedy_children', array('parent_id' => $id, 'child_id' => $child_id, 'the_order' => $i, 'title' => $title));
         }
         $start = $start + $length + 1;
     }
     $GLOBALS['SITE_DB']->query_insert('seedy_changes', array('the_action' => 'CEDI_EDIT_TREE', 'the_page' => $id, 'date_and_time' => time(), 'ip' => get_ip_address(), 'the_user' => $member));
     // Show it worked / Refresh
     $url = get_param('redirect');
     return redirect_screen($_title, $url, do_lang_tempcode('SUCCESS'));
 }
예제 #29
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);
}
예제 #30
0
파일: quiz.php 프로젝트: erico-deh/ocPortal
/**
 * 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);
}