/** * Is the current page a single Doc 'read' view? * * By process of elimination. * * @since 1.2 * @return bool */ function bp_docs_is_doc_read() { $is_doc_read = false; if (bp_docs_is_single_doc() && !bp_docs_is_doc_edit() && (!function_exists('bp_docs_is_doc_history') || !bp_docs_is_doc_history())) { $is_doc_read = true; } return apply_filters('bp_docs_is_doc_read', $is_doc_read); }
add_action('init', function () { global $allowedposttags; $allowedposttags['iframe'] = array('src' => array(), 'height' => array(), 'width' => array(), 'frameborder' => array(), 'style' => array()); }); // allow iframes for tinyMCE add_filter('tiny_mce_before_init', function ($a) { $a["extended_valid_elements"] = 'iframe[src|height|width|frameborder]'; return $a; }); /* end allow more html tags to users +++++++++++++++++++++++++++++++++++++++++++++ */ /* move doc permissions output into a tab ++++++++++++++++++++++++++++++++++++++++++++++++ */ remove_action('bp_docs_single_doc_header_fields', 'bp_docs_render_permissions_snapshot'); add_action('bp_docs_header_tabs', function () { ?> <?php if (!bp_docs_is_doc_edit() && !bp_docs_is_doc_history() && is_user_logged_in()) { ?> <li class="permissiontab"> <a href="#rechte" class="rw-doc-permissions-toggle">Zugriffsrechte</a> </li> <?php } ?> <?php }, 999); add_action('bp_docs_before_doc_title', 'rw_bp_docs_render_permissions_snapshot'); function rw_bp_docs_render_permissions_snapshot() { ?> <style> .permissiontab.doc-public{
/** * Are we looking at something that needs docs theme compatability? * * @since 1.3 */ public function is_docs() { // Bail if not looking at the docs component if (!bp_docs_is_docs_component()) { return; } add_filter('bp_get_template_stack', array($this, 'add_plugin_templates_to_stack')); add_filter('bp_get_buddypress_template', array($this, 'query_templates')); if (bp_docs_is_global_directory()) { bp_update_is_directory(true, 'docs'); do_action('bp_docs_screen_index'); add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post')); add_filter('bp_replace_the_content', array($this, 'directory_content')); } else { if (bp_docs_is_existing_doc()) { if (bp_docs_is_doc_history()) { $this->single_content_template = 'docs/single/history'; add_filter('bp_force_comment_status', '__return_false'); } else { if (bp_docs_is_doc_edit()) { $this->single_content_template = 'docs/single/edit'; add_filter('bp_force_comment_status', '__return_false'); } else { $this->single_content_template = 'docs/single/index'; add_filter('bp_docs_allow_comment_section', '__return_false'); } } add_action('bp_template_include_reset_dummy_post_data', array($this, 'single_dummy_post')); add_filter('bp_replace_the_content', array($this, 'single_content')); } else { if (bp_docs_is_doc_create()) { add_action('bp_template_include_reset_dummy_post_data', array($this, 'create_dummy_post')); add_filter('bp_replace_the_content', array($this, 'create_content')); } } } }
/** * Are we looking at something that needs docs theme compatability? * * @since 1.3 */ public function is_docs() { $is_docs = bp_docs_is_docs_component(); if (bp_is_active('groups') && bp_is_group() && bp_is_current_action(buddypress()->bp_docs->slug)) { $is_docs = true; } // Bail if not looking at the docs component if (!$is_docs) { return; } add_filter('bp_get_template_stack', array($this, 'add_plugin_templates_to_stack')); add_filter('bp_get_buddypress_template', array($this, 'query_templates')); add_filter('bp_use_theme_compat_with_current_theme', 'bp_docs_do_theme_compat'); if (bp_docs_is_global_directory() || bp_docs_is_mygroups_directory()) { bp_update_is_directory(true, 'docs'); do_action('bp_docs_screen_index'); add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post')); add_filter('bp_replace_the_content', array($this, 'directory_content')); } else { if (bp_docs_is_existing_doc()) { if (bp_docs_is_doc_history()) { $this->single_content_template = 'docs/single/history'; add_filter('bp_force_comment_status', '__return_false'); } else { if (bp_docs_is_doc_edit()) { $this->single_content_template = 'docs/single/edit'; add_filter('bp_force_comment_status', '__return_false'); } else { $this->single_content_template = 'docs/single/index'; add_filter('bp_docs_allow_comment_section', '__return_false'); // Necessary as of BP 1.9.2 remove_action('bp_replace_the_content', 'bp_theme_compat_toggle_is_page', 9999); } } add_action('bp_template_include_reset_dummy_post_data', array($this, 'single_dummy_post')); add_filter('bp_replace_the_content', array($this, 'single_content')); } else { if (bp_docs_is_doc_create()) { add_action('bp_template_include_reset_dummy_post_data', array($this, 'create_dummy_post')); add_filter('bp_replace_the_content', array($this, 'create_content')); } } } }
/** * Protects group docs from unauthorized access * * @since 1.2 */ function protect_doc_access() { // What is the user trying to do? if (bp_docs_is_doc_read()) { $action = 'bp_docs_read'; } else { if (bp_docs_is_doc_create()) { $action = 'bp_docs_create'; } else { if (bp_docs_is_doc_edit()) { $action = 'bp_docs_edit'; } else { if (bp_docs_is_doc_history()) { $action = 'bp_docs_view_history'; } } } } if (!isset($action)) { return; } if (!current_user_can($action)) { $redirect_to = bp_docs_get_doc_link(); bp_core_no_access(array('mode' => 2, 'redirect' => $redirect_to)); } }
/** * Echo the History header tab. * * This is hooked to bp_docs_header_tabs, so that it only loads if the History addon is * enabled. * * @package BuddyPress Docs * @since 1.1.4 */ function bp_docs_history_tab() { if (current_user_can('bp_docs_view_history')) { ?> <li<?php if (bp_docs_is_doc_history()) { ?> class="current"<?php } ?> > <a href="<?php echo bp_docs_get_doc_link() . BP_DOCS_HISTORY_SLUG; ?> "><?php _e('History', 'bp-docs'); ?> </a> </li> <?php } }
/** * Protects group docs from unauthorized access * * @since 1.2 * @uses bp_docs_current_user_can() This does most of the heavy lifting */ function protect_doc_access() { // What is the user trying to do? if (bp_docs_is_doc_read()) { $action = 'read'; } else { if (bp_docs_is_doc_create()) { $action = 'create'; } else { if (bp_docs_is_doc_edit()) { $action = 'edit'; } else { if (bp_docs_is_doc_history()) { $action = 'view_history'; } } } } if (!isset($action)) { return; } if (!bp_docs_current_user_can($action)) { $redirect_to = wp_get_referer(); if (!$redirect_to || trailingslashit($redirect_to) == trailingslashit(wp_guess_url())) { $redirect_to = bp_get_root_domain(); } switch ($action) { case 'read': $message = __('You are not allowed to read that Doc.', 'bp-docs'); break; case 'create': $message = __('You are not allowed to create Docs.', 'bp-docs'); break; case 'edit': $message = __('You are not allowed to edit that Doc.', 'bp-docs'); break; case 'view_history': $message = __('You are not allowed to view that Doc\'s history.', 'bp-docs'); break; } bp_core_add_message($message, 'error'); bp_core_redirect($redirect_to); } }
<?php global $class; $is_group_single_doc = ''; if (function_exists('bp_docs_is_doc_edit')) { //fix boss code with rw_bp_doc_single_group_id() $is_group_single_doc = (bp_docs_is_doc_edit() || bp_docs_is_doc_read() || bp_docs_is_doc_create() || bp_docs_is_doc_history()) && rw_bp_doc_single_group_id(false); } if ($is_group_single_doc) { $class .= ' group-single'; } ?> <?php // Boxed layout cover if (boss_get_option('boss_cover_profile')) { if (boss_get_option('boss_layout_style') == 'boxed' && (!bp_is_current_component('events') || bp_is_current_component('events') && 'profile' == bp_current_action())) { // show here for boxed and if not Events Manager page or if it is My Profile of Events if (bp_is_user()) { echo buddyboss_cover_photo("user", bp_displayed_user_id()); } } } ?> <?php if (bp_is_current_component('groups') && !bp_is_group() && !bp_is_user()) { ?> <div class="dir-page-entry"> <div class="inner-padding"> <header class="group-header page-header">
<div id="content"> <div class="padder"> <?php do_action('bp_before_single_doc'); ?> <?php if (bp_docs_is_doc_edit() || bp_docs_is_doc_create()) { ?> <?php include bp_docs_locate_template('single/edit.php'); ?> <?php } elseif (bp_docs_is_doc_history()) { ?> <?php include bp_docs_locate_template('single/history.php'); ?> <?php } else { ?> <?php include bp_docs_locate_template('single/index.php'); ?> <?php } ?> <?php
<?php do_action('bp_docs_before_doc_header'); ?> <?php /* Subnavigation on user pages is handled by BP's core functions */ if (!bp_is_user()) { ?> <div class="item-list-tabs no-ajax" id="subnav" role="navigation"> <?php // bp_docs_tabs( bp_docs_current_user_can_create_in_context() ) ?> <?php if (!(bp_docs_is_doc_edit() || bp_docs_is_doc_read() || bp_docs_is_doc_create() || bp_docs_is_doc_history())) { ?> <div class="create_doc" style=""><?php bp_docs_tabs(bp_docs_current_user_can_create_in_context()); ?> </div><?php } ?> </div><!-- .item-list-tabs --> <?php } ?> <?php do_action('bp_docs_before_doc_header_content'); if (bp_docs_is_existing_doc()) { ?>