Exemple #1
0
/**
 * Adds a category that is specifed in the POST array
 * returns the HTML for a new list item to insert at the end
 * of the current category list
 */
function bp_group_documents_add_category()
{
    global $bp;
    $category_name = $_POST['category'];
    $parent_id = BP_Group_Documents_Template::get_parent_category_id();
    if (!term_exists($category_name, 'group-documents-category', $parent_id)) {
        $new_term = wp_insert_term($category_name, 'group-documents-category', array('parent' => $parent_id));
    }
    $output = "<li id='category-{$new_term['term_id']}'><strong>{$category_name}</strong>";
    $term_id = $new_term['term_id'];
    $edit_link = wp_nonce_url('?edit=' . $term_id, 'group-documents-category-edit');
    $delete_link = wp_nonce_url('?delete=' . $term_id, 'group-documents-category-delete');
    $output .= '&nbsp; <a class="group-documents-category-edit" href="' . $edit_link . '">Edit</a>';
    $output .= ' | <a class="group-documents-category-delete" href="' . $delete_link . '">Delete</a>';
    $output .= '</li>';
    die($output);
}
Exemple #2
0
function bp_group_documents_display_content()
{
    global $bp;
    //instanciating the template will do the heavy lifting with all the superglobal variables
    $template = new BP_Group_Documents_Template();
    ?>

	<div id="bp-group-documents">

	<?php 
    do_action('template_notices');
    ?>

	<?php 
    //-----------------------------------------------------------------------LIST VIEW--
    ?>

	<?php 
    if ($template->document_list && count($template->document_list >= 1)) {
        ?>

		<?php 
        if (get_option('bp_group_documents_use_categories')) {
            ?>
		<div id="bp-group-documents-categories">
			<form id="bp-group-documents-category-form" method="get" action="<?php 
            echo $template->action_link;
            ?>
">
			 &nbsp; <?php 
            echo __('Category:', 'bp-group-documents');
            ?>
			<select name="category">
				<option value="" ><?php 
            echo __('All', 'bp-group-documents');
            ?>
</option>
				<?php 
            foreach ($template->get_group_categories() as $category) {
                ?>
				<option value="<?php 
                echo $category->term_id;
                ?>
" <?php 
                if ($template->category == $category->term_id) {
                    echo 'selected="selected"';
                }
                ?>
><?php 
                echo $category->name;
                ?>
</option>
				<?php 
            }
            ?>
			</select>
			<input type="submit" class="button" value="<?php 
            echo __('Go', 'bp-group-documents');
            ?>
" />
			</form>
		</div>
		<?php 
        }
        ?>

		<div id="bp-group-documents-sorting">
			<form id="bp-group-documents-sort-form" method="get" action="<?php 
        echo $template->action_link;
        ?>
">
			<?php 
        _e('Order by:', 'bp-group-documents');
        ?>
			<select name="order">
				<option value="newest" <?php 
        if ('newest' == $template->order) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        _e('Newest', 'bp-group-documents');
        ?>
</option>
				<option value="alpha" <?php 
        if ('alpha' == $template->order) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        _e('Alphabetical', 'bp-group-documents');
        ?>
</option>
				<option value="popular" <?php 
        if ('popular' == $template->order) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        _e('Most Popular', 'bp-group-documents');
        ?>
</option>
			</select>
			<input type="submit" class="button" value="<?php 
        _e('Go', 'bp-group-documents');
        ?>
" />
			</form>
		</div>


		<?php 
        if ('1.1' != substr(BP_VERSION, 0, 3)) {
            ?>
		<h3><?php 
            _e('Document List', 'bp-group-documents');
            ?>
</h3>
		<?php 
        }
        ?>


		<div class="pagination no-ajax">
			<div id="group-documents-page-count" class="pag-count">
				<?php 
        $template->pagination_count();
        ?>
			</div>
		<?php 
        if ($template->show_pagination()) {
            ?>
			<div id="group-documents-page-links" class="pagination-links">
				<?php 
            $template->pagination_links();
            ?>
			</div>
		<?php 
        }
        ?>
		</div>

		<?php 
        if ('1.1' == substr(BP_VERSION, 0, 3)) {
            ?>
			<ul id="forum-topic-list" class="item-list">
		<?php 
        } else {
            ?>
			<ul id="bp-group-documents-list" class="item-list">
		<?php 
        }
        ?>

		<?php 
        //loop through each document and display content along with admin options
        $count = 0;
        foreach ($template->document_list as $document_params) {
            $document = new BP_Group_Documents($document_params['id'], $document_params);
            ?>

			<li <?php 
            if (++$count % 2) {
                echo 'class="alt"';
            }
            ?>
 >
			<?php 
            if (get_option('bp_group_documents_display_icons')) {
                $document->icon();
            }
            ?>

			<a class="group-documents-title" id="group-document-link-<?php 
            echo $document->id;
            ?>
" href="<?php 
            $document->url();
            ?>
" target="_blank"><?php 
            echo $document->name;
            ?>

			<?php 
            if (get_option('bp_group_documents_display_file_size')) {
                echo ' <span class="group-documents-filesize">(' . get_file_size($document) . ')</span>';
            }
            ?>
</a> &nbsp;
			
			<span class="group-documents-meta"><?php 
            printf(__('Uploaded by %s on %s', 'bp-group-documents'), bp_core_get_userlink($document->user_id), date(get_option('date_format'), $document->created_ts));
            ?>
</span>

			<?php 
            if (BP_GROUP_DOCUMENTS_SHOW_DESCRIPTIONS && $document->description) {
                echo '<br /><span class="group-documents-description">' . nl2br($document->description) . '</span>';
            }
            //show edit and delete options if user is privileged
            echo '<div class="admin-links">';
            if ($document->current_user_can('edit')) {
                $edit_link = wp_nonce_url($template->action_link . 'edit/' . $document->id, 'group-documents-edit-link');
                echo "<a href='{$edit_link}'>" . __('Edit', 'bp-group-documents') . "</a> | ";
            }
            if ($document->current_user_can('delete')) {
                $delete_link = wp_nonce_url($template->action_link . 'delete/' . $document->id, 'group-documents-delete-link');
                echo "<a href='{$delete_link}' id='bp-group-documents-delete'>" . __('Delete', 'bp-group-documents') . "</a>";
            }
            echo '</div>';
            echo '</li>';
        }
        ?>
		</ul>

	<?php 
    } else {
        ?>
	<div id="message" class="info">
		<p><?php 
        _e('There have been no documents uploaded for this group', 'bp-group-documents');
        ?>
</p>
	</div>

	<?php 
    }
    ?>
	<div class="spacer">&nbsp;</div>

	<?php 
    //-------------------------------------------------------------------DETAIL VIEW--
    ?>

	<?php 
    if ($template->show_detail) {
        ?>

	<?php 
        if ($template->operation == 'add') {
            ?>
	<div id="bp-group-documents-upload-new">
	<?php 
        } else {
            ?>
	<div id="bp-group-documents-edit">
	<?php 
        }
        ?>

	<h3><?php 
        echo $template->header;
        ?>
</h3>

	<form method="post" id="bp-group-documents-form" class="standard-form" action="<?php 
        echo $template->action_link;
        ?>
" enctype="multipart/form-data" />
	<input type="hidden" name="bp_group_documents_operation" value="<?php 
        echo $template->operation;
        ?>
" />
	<input type="hidden" name="bp_group_documents_id" value="<?php 
        echo $template->id;
        ?>
" />

		<?php 
        if ($template->operation == 'add') {
            ?>

		<input type="hidden" name="MAX_FILE_SIZE" value="<?php 
            echo return_bytes(ini_get('post_max_size'));
            ?>
"
		<label><?php 
            _e('Choose File:', 'bp-group-documents');
            ?>
</label>
		<input type="file" name="bp_group_documents_file" class="bp-group-documents-file" />
		<?php 
        }
        ?>

		<?php 
        if (BP_GROUP_DOCUMENTS_FEATURED) {
            ?>
		<label class="bp-group-documents-featured-label"><input type="checkbox" name="bp_group_documents_featured" class="bp-group-documents-featured" value="1" <?php 
            if ($template->featured) {
                echo 'checked="checked"';
            }
            ?>
 > <?php 
            _e('Featured Document', 'bp-group-documents');
            ?>
</label>
		<?php 
        }
        ?>

		<div id="document-detail-clear" class="clear"></div>
		<div class="document-info">
		<label><?php 
        _e('Display Name:', 'bp-group-documents');
        ?>
</label>
		<input type="text" name="bp_group_documents_name" id="bp-group-documents-name" value="<?php 
        echo $template->name;
        ?>
" />
		<?php 
        if (BP_GROUP_DOCUMENTS_SHOW_DESCRIPTIONS) {
            ?>
		<label><?php 
            _e('Description:', 'bp-group-documents');
            ?>
</label>
		<textarea name="bp_group_documents_description" id="bp-group-documents-description"><?php 
            echo $template->description;
            ?>
</textarea>
		<?php 
        }
        ?>
		<label></label>
		<input type="submit" class="button" value="<?php 
        _e('Submit', 'bp-group-documents');
        ?>
" />
		</div>

		<?php 
        if (get_option('bp_group_documents_use_categories')) {
            ?>
		<div class="bp-group-documents-category-wrapper">
		<label><?php 
            _e('Category:', 'bp-group-documents');
            ?>
</label>
		<div class="bp-group-documents-category-list">
			<ul>
			<?php 
            foreach ($template->get_group_categories(false) as $category) {
                ?>
				<li><input type="checkbox" name="bp_group_documents_categories[]" value="<?php 
                echo $category->term_id;
                ?>
" <?php 
                if ($template->doc_in_category($category->term_id)) {
                    echo 'checked="checked"';
                }
                ?>
 /><?php 
                echo $category->name;
                ?>
</li>
			<?php 
            }
            ?>
			</ul>
		</div>
		<input type="text" name="bp_group_documents_new_category" class="bp-group-documents-new-category" />
		</div><!-- .bp-group-documents-category-wrapper -->
		<?php 
        }
        ?>

	</form>
	</div><!--end #post-new-topic-->

	<?php 
        if ($template->operation == 'add') {
            ?>
	<a class="button" id="bp-group-documents-upload-button" href="" style="display:none;"><?php 
            _e('Upload a New Document', 'bp-group-documents');
            ?>
</a>
	<?php 
        }
        ?>

	<?php 
    }
    ?>

	</div><!--end #group-documents-->
<?php 
}
/**
 *
 * @version 1.2.2, 3/10/2013, stergatu esc_textarea
 * v2, 21/5/2013, stergatu, added documents categories
 */
function bp_group_documents_display_content()
{
    $bp = buddypress();
    //instanciating the template will do the heavy lifting with all the superglobal variables
    $template = new BP_Group_Documents_Template();
    ?>

        <div id="bp-group-documents">
	<?php 
    do_action('template_notices');
    ?>
        <h3><?php 
    echo get_option('bp_group_documents_nav_page_name') . ' ' . __('List', 'bp-group-documents');
    ?>
</h3>
	    <?php 
    //-----------------------------------------------------------------------LIST VIEW--
    ?>
            <div class="item-list-tabs no-ajax" id="subnav" role="navigation">
		<?php 
    if (get_option('bp_group_documents_use_categories')) {
        ?>
		    <div id="bp-group-documents-categories">
			<form class="standard-form" id="bp-group-documents-category-form" method="get" action="<?php 
        echo $template->action_link;
        ?>
">
				    &nbsp; <?php 
        echo __('Category:', 'bp-group-documents');
        ?>
			    <select name="category">
				<option value="" ><?php 
        echo __('All', 'bp-group-documents');
        ?>
</option>
				<?php 
        foreach ($template->get_group_categories() as $category) {
            ?>
	    			<option value="<?php 
            echo $category->term_id;
            ?>
" <?php 
            if ($template->category == $category->term_id) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo $category->name;
            ?>
</option>
					<?php 
        }
        ?>
				</select>
				<input type="submit" class="button" value="<?php 
        echo __('Go', 'bp-group-documents');
        ?>
" />
			    </form>
			</div>
		    <?php 
    }
    ?>
    		<div id="bp-group-documents-sorting">
		    <form class="standard-form" id="bp-group-documents-sort-form" method="get" action="<?php 
    echo $template->action_link;
    ?>
">
			    <?php 
    _e('Order by:', 'bp-group-documents');
    ?>
    			<select name="order" id="order">
    			    <option value="newest" <?php 
    selected('newest', $template->order);
    ?>
><?php 
    _e('Newest', 'bp-group-documents');
    ?>
</option>
		    <option value="alpha" <?php 
    selected('alpha', $template->order);
    ?>
><?php 
    _e('Alphabetical', 'bp-group-documents');
    ?>
</option>
		    <option value="popular" <?php 
    selected('popular', $template->order);
    ?>
><?php 
    _e('Most Popular', 'bp-group-documents');
    ?>
</option>
		</select>
    		<input type="submit" class="button" value="<?php 
    _e('Go', 'bp-group-documents');
    ?>
" />
    	    </form>
    	</div>

		<?php 
    if ($template->document_list && count($template->document_list >= 1)) {
        ?>
		    <div class="pagination no-ajax">
			<div id="group-documents-page-count" class="pag-count">
			    <?php 
        $template->pagination_count();
        ?>
			</div>
			<?php 
        if ($template->show_pagination()) {
            ?>
	    		<div id="group-documents-page-links" class="pagination-links">
				<?php 
            $template->pagination_links();
            ?>
	    		</div>
			<?php 
        }
        ?>
		    </div>
		<?php 
    }
    ?>

                </div> <!-- // subnav -->
	    <?php 
    if ($template->document_list && count($template->document_list >= 1)) {
        if ('1.1' == substr(BP_VERSION, 0, 3)) {
            ?>
	    	<ul id="forum-topic-list" class="item-list">
		    <?php 
        } else {
            ?>
	    	    <ul id="bp-group-documents-list" class="item-list">
			    <?php 
        }
        //loop through each document and display content along with admin options
        $count = 0;
        foreach ($template->document_list as $document_params) {
            $document = new BP_Group_Documents($document_params['id'], $document_params);
            ?>
	    		<li <?php 
            if (++$count % 2) {
                echo 'class="alt"';
            }
            ?>
 >
				    <?php 
            if (get_option('bp_group_documents_display_icons')) {
                $document->icon();
            }
            ?>
<a class="bp-group-documents-title" id="group-document-link-<?php 
            echo $document->id;
            ?>
" href="<?php 
            $document->url();
            ?>
" target="_blank">
				    <?php 
            echo str_replace("\\", "", esc_html(stripslashes($document->name)));
            ?>
				    <?php 
            if (get_option('bp_group_documents_display_file_size')) {
                echo ' <span class="group-documents-filesize">(' . get_file_size($document) . ')</span>';
            }
            ?>
</a> &nbsp;<div class="bp-group-documents-meta">
				    <?php 
            $document->categories();
            printf(__('Uploaded by %s on %s', 'bp-group-documents'), bp_core_get_userlink($document->user_id), date_i18n(get_option('date_format'), $document->created_ts));
            ?>
.
				    <?php 
            if (get_option('bp_group_documents_display_download_count')) {
                echo ' <span class="group-documents-download-count">' . $document->download_count . __(' downloads since then.', 'bp-group-documents') . '</span>';
            }
            ?>
	    	    			    </div>
					<?php 
            //show edit and delete options if user is privileged
            echo '<div class="admin-links">';
            if ($document->current_user_can('edit')) {
                $edit_link = wp_nonce_url($template->action_link . 'edit/' . $document->id, 'group-documents-edit-link') . '#edit-document-form';
                echo "<a href='{$edit_link}'>" . __('Edit', 'bp-group-documents') . "</a> | ";
            }
            if ($document->current_user_can('delete')) {
                $delete_link = wp_nonce_url($template->action_link . 'delete/' . $document->id, 'group-documents-delete-link');
                echo "<a href='{$delete_link}' class='bp-group-documents-delete'>" . __('Delete', 'bp-group-documents') . "</a>";
            }
            echo '</div>';
            if (BP_GROUP_DOCUMENTS_SHOW_DESCRIPTIONS && $document->description) {
                echo '<span class="group-documents-description">' . wp_kses(stripslashes($document->description), wp_kses_allowed_html('post')) . '</span>';
            }
            //eleni add this in order to display the Addthis button on 3/2/2011
            include_once ABSPATH . 'wp-admin/includes/plugin.php';
            if (is_plugin_active('buddypress-addthis-ls/bp-addthis-ls.php')) {
                echo get_bp_addthis_ls_button($document->get_url(), $document->name);
            }
            //   end eleni add
            echo '</li>';
        }
        ?>
			</ul>

			<?php 
    } else {
        ?>
			    <div id="message" class="info">
				<p><?php 
        if ($template->category > 0) {
            _e('There are no documents in the selected category.', 'bp-group-documents');
        } else {
            _e('There are no documents uploaded for this group.', 'bp-group-documents');
        }
        ?>
</p>
			    </div>



			    <?php 
    }
    //-------------------------------------------------------------------DETAIL VIEW--
    if ($template->show_detail) {
        if ($template->operation == 'add') {
            ?>
	    		    <div id="bp-group-documents-upload-new">
				<?php 
        } else {
            ?>
	    			<div id="bp-group-documents-edit"><a name="edit-document-form"></a>
				    <?php 
        }
        ?>

			<h3><?php 
        echo $template->header;
        ?>
</h3>

			<form method="post" id="bp-group-documents-form" class="standard-form" action="<?php 
        echo $template->action_link;
        ?>
" enctype="multipart/form-data">
				    <input type="hidden" name="bp_group_documents_operation" value="<?php 
        echo $template->operation;
        ?>
" />
				    <input type="hidden" name="bp_group_documents_id" value="<?php 
        echo $template->id;
        ?>
" />
				    <?php 
        if ($template->operation == 'add') {
            ?>
	    			    <input type="hidden" name="MAX_FILE_SIZE" value="<?php 
            echo return_bytes(ini_get('post_max_size'));
            ?>
" />
	    			    <label class="bp-group-documents-file-label"><?php 
            _e('Choose File:', 'bp-group-documents');
            ?>
</label>
	    			    <input type="file" name="bp_group_documents_file" class="bp-group-documents-file" />
	    			    <p class="bp-group-documents-valid-file-formats">
					    <?php 
            $valid_file_formats1 = get_option('bp_group_documents_valid_file_formats');
            _e('Valid File Formats', 'bp-group-documents');
            echo ':<br />' . str_replace(',', ', ', $valid_file_formats1);
            ?>
	    	    			    </p>
				    <?php 
        } else {
            ?>
	    			    <label><?php 
            _e('Document:', 'bp-group-documents');
            ?>
:</label><span><?php 
            echo $template->name;
            ?>
</span>

				    <?php 
        }
        if (BP_GROUP_DOCUMENTS_FEATURED) {
            ?>
	    			    <label class="bp-group-documents-featured-label"><?php 
            _e('Featured Document', 'bp-group-documents');
            ?>
: </label>
	    			    <input type="checkbox" name="bp_group_documents_featured" class="bp-group-documents-featured" value="1" <?php 
            if ($template->featured) {
                echo 'checked="checked"';
            }
            ?>
/>
				    <?php 
        }
        ?>
				    <div id="document-detail-clear" class="clear"></div>
				    <div class="bp-group-documents-document-info">
					<label><?php 
        _e('Display Name:', 'bp-group-documents');
        ?>
</label>
					<input type="text" name="bp_group_documents_name" id="bp-group-documents-name" value="<?php 
        echo $template->name;
        ?>
" />
					<?php 
        if (BP_GROUP_DOCUMENTS_SHOW_DESCRIPTIONS) {
            ?>
	    				<label><?php 
            _e('Description:', 'bp-group-documents');
            ?>
</label>
					    <?php 
            if (BP_GROUP_DOCUMENTS_ALLOW_WP_EDITOR) {
                if (function_exists('wp_editor')) {
                    wp_editor($template->description, 'bp_group_documents_description', array('media_buttons' => false, 'dfw' => false));
                } else {
                    the_editor($template->description, 'bp_group_documents_description', 'bp_group_documents_description', false);
                }
            } else {
                ?>
				<textarea name="bp_group_documents_description" id="bp-group-documents-description" rows="5" cols="100"><?php 
                echo esc_textarea($template->description);
                ?>
</textarea>
					    <?php 
            }
        }
        ?>
			    </div>

				    <?php 
        if (get_option('bp_group_documents_use_categories')) {
            ?>
	    			    <div class="bp-group-documents-category-wrapper">
	    				<label><?php 
            _e('Category:', 'bp-group-documents');
            ?>
</label>
					    <?php 
            $group_categories = $template->get_group_categories(false);
            if (count($group_categories) > 0) {
                ?>
				<div class="bp-group-documents-category-list">
						    <ul>
							<?php 
                foreach ($template->get_group_categories(false) as $category) {
                    ?>
		    					<li><input type="checkbox" name="bp_group_documents_categories[]" value="<?php 
                    echo $category->term_id;
                    ?>
" <?php 
                    if ($template->doc_in_category($category->term_id)) {
                        echo 'checked="checked"';
                    }
                    ?>
 /><?php 
                    echo $category->name;
                    ?>
</li>
							    <?php 
                }
                ?>
						    </ul>
						</div>
					    <?php 
            }
            ?>
	    				<input type="text" name="bp_group_documents_new_category" class="bp-group-documents-new-category" />
	    			    </div><!-- .bp-group-documents-category-wrapper -->
				    <?php 
        }
        ?>
				    <?php 
        wp_nonce_field('bp_group_document_save_' . $template->operation, 'bp_group_document_save');
        ?>
				    <input type="submit" class="button" value="<?php 
        _e('Save', 'bp-group-documents');
        ?>
" />
				</form>
			    </div><!--end #post-new-topic-->

			    <?php 
        if ($template->operation == 'add') {
            ?>
	    		    <a class="button" id="bp-group-documents-upload-button" href="" style="display:none;"><?php 
            _e('Upload a New Document', 'bp-group-documents');
            ?>
</a>
				<?php 
        }
    }
    ?>

		</div><!--end #group-documents-->
		    <?php 
}
function bp_group_documents_group_admin_save()
{
    global $bp;
    do_action('bp_group_documents_group_admin_save');
    $success = false;
    //check if category was updated
    if ($_POST['group_documents_category_edit'] && ctype_digit($_POST['group_documents_category_edit_id']) && term_exists((int) $_POST['group_documents_category_edit_id'], 'group-documents-category')) {
        check_admin_referer('groups-edit-group-documents');
        $success = wp_update_term((int) $_POST['group_documents_category_edit_id'], 'group-documents-category', array('name' => $_POST['group_documents_category_edit']));
    }
    //check if category was deleted
    if (isset($_GET['delete']) && ctype_digit($_GET['delete']) && term_exists((int) $_GET['delete'], 'group-documents-category')) {
        check_admin_referer('group-documents-category-delete');
        $success = wp_delete_term((int) $_GET['delete'], 'group-documents-category');
    }
    //check if new category was added, if so, append to current list
    if ($_POST['bp_group_documents_new_category']) {
        $parent_id = BP_Group_Documents_Template::get_parent_category_id();
        if (!term_exists($_POST['bp_group_documents_new_category'], 'group-documents-category', $parent_id)) {
            $success = wp_insert_term($_POST['bp_group_documents_new_category'], 'group-documents-category', array('parent' => $parent_id));
        }
    }
    //Update whether documents are enabled
    if (isset($_POST['group_documents_documents_disabled']) && ctype_digit($_POST['group_documents_documents_disabled'])) {
        check_admin_referer('groups-edit-group-documents');
        $success = groups_update_groupmeta($bp->groups->current_group->id, 'group_documents_documents_disabled', $_POST['group_documents_documents_disabled']);
    }
    //Update permissions
    $valid_permissions = array('members', 'mods_only');
    if (isset($_POST['group_documents_upload_permission']) && in_array($_POST['group_documents_upload_permission'], $valid_permissions)) {
        check_admin_referer('groups-edit-group-documents');
        $success = $success || groups_update_groupmeta($bp->groups->current_group->id, 'group_documents_upload_permission', $_POST['group_documents_upload_permission']);
    }
    //If something was updated, post a success
    if ($success !== false) {
        bp_core_add_message(__('Settings saved successfully', 'buddypress'));
        bp_core_redirect(bp_get_group_permalink($bp->groups->current_group) . '/admin/' . $bp->group_documents->slug);
    }
}
 /**
  * The routine run after the user clicks Save from your admin tab
  * @version v1.4, 31/10/2013, fix some notices
  * v3,  27/8/2013, fix the messages
  * v2, 21/5/2013, fix the edit and delete category bug, Stergatu Eleni
  * @since 0.5
  */
 function edit_screen_save()
 {
     global $bp;
     do_action('bp_group_documents_group_admin_save');
     $message = false;
     $type = '';
     $parent_id = BP_Group_Documents_Template::get_parent_category_id();
     if (!isset($_POST['save']) && !isset($_POST['addCat']) && !isset($_POST['editCat']) && !isset($_POST['delCat'])) {
         return false;
     }
     check_admin_referer('groups_edit_save_' . $this->slug);
     //check if category was deleted
     if (isset($_POST['group_documents_category_del_id']) && ctype_digit($_POST['group_documents_category_del_id']) && term_exists((int) $_POST['group_documents_category_del_id'], 'group-documents-category')) {
         if (true == wp_delete_term((int) $_POST['group_documents_category_del_id'], 'group-documents-category')) {
             $message = sprintf(__('Group %s category deleted successfully', 'bp-group-documents'), mb_strtolower($this->name));
         }
     } elseif (array_key_exists('group_documents_category_edit', $_POST) && ctype_digit($_POST['group_documents_category_edit_id']) && term_exists((int) $_POST['group_documents_category_edit_id'], 'group-documents-category')) {
         if (term_exists($_POST['group_documents_category_edit'], 'group-documents-category', $parent_id)) {
             $message = sprintf(__('No changes were made. This %s category name is used already', 'bp-group-documents'), mb_strtolower($this->name));
             $type = 'error';
         } else {
             if (true == wp_update_term((int) $_POST['group_documents_category_edit_id'], 'group-documents-category', array('name' => $_POST['group_documents_category_edit']))) {
                 $message = sprintf(__('Group %s category renamed successfully', 'bp-group-documents'), mb_strtolower($this->name));
             }
         }
     } elseif ($_POST['bp_group_documents_new_category']) {
         if (!term_exists($_POST['bp_group_documents_new_category'], 'group-documents-category', $parent_id)) {
             if (true == wp_insert_term($_POST['bp_group_documents_new_category'], 'group-documents-category', array('parent' => $parent_id))) {
                 $message = $_POST['bp_group_documents_new_category'] . ': ' . sprintf(__('New group %s category created', 'bp-group-documents'), mb_strtolower($this->name));
             }
         } else {
             $message = sprintf(__('No changes were made. This %s category name is used already', 'bp-group-documents'), mb_strtolower($this->name));
             $type = 'error';
         }
     } else {
         $valid_permissions = array('members', 'mods_only');
         //check if group upload permision has chanced
         if (isset($_POST['bp_group_documents_upload_permission']) && in_array($_POST['bp_group_documents_upload_permission'], $valid_permissions)) {
             if (true == groups_update_groupmeta($bp->groups->current_group->id, 'bp_group_documents_upload_permission', $_POST['bp_group_documents_upload_permission'])) {
                 $message = __('Upload Permissions changed successfully', 'bp-group-documents');
             }
         }
     }
     /* Post an error/success message to the screen */
     if (!$message) {
         bp_core_add_message(__('No changes were made. Either error or you didn\'t change anything', 'bp-group-documents'), 'error');
     } else {
         bp_core_add_message($message, $type);
     }
     do_action('bp_group_documents_group_admin_after_save');
     bp_core_redirect(bp_get_group_permalink($bp->groups->current_group) . 'admin/' . $this->slug);
 }