function bp_groups_template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $populate_extras ) { global $bp; $this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : $page; $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; if ( 'invites' == $type ) { $this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page ); } else if ( 'single-group' == $type ) { $group = new stdClass; $group->group_id = BP_Groups_Group::get_id_from_slug($slug); $this->groups = array( $group ); } else { $this->groups = groups_get_groups( array( 'type' => $type, 'per_page' => $this->pag_num, 'page' =>$this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) ); } if ( 'invites' == $type ) { $this->total_group_count = (int)$this->groups['total']; $this->group_count = (int)$this->groups['total']; $this->groups = $this->groups['groups']; } else if ( 'single-group' == $type ) { $this->single_group = true; $this->total_group_count = 1; $this->group_count = 1; } else { if ( !$max || $max >= (int)$this->groups['total'] ) { $this->total_group_count = (int)$this->groups['total']; } else { $this->total_group_count = (int)$max; } $this->groups = $this->groups['groups']; if ( $max ) { if ( $max >= count($this->groups) ) { $this->group_count = count( $this->groups ); } else { $this->group_count = (int)$max; } } else { $this->group_count = count( $this->groups ); } } // Build pagination links if ( (int)$this->total_group_count && (int)$this->pag_num ) { $this->pag_links = paginate_links( array( 'base' => add_query_arg( array( 'grpage' => '%#%', 'num' => $this->pag_num, 's' => $search_terms, 'sortby' => $this->sort_by, 'order' => $this->order ) ), 'format' => '', 'total' => ceil( (int)$this->total_group_count / (int)$this->pag_num ), 'current' => $this->pag_page, 'prev_text' => '←', 'next_text' => '→', 'mid_size' => 1 ) ); } }
function __construct($args = array()) { // Backward compatibility with old method of passing arguments if (!is_array($args) || func_num_args() > 1) { _deprecated_argument(__METHOD__, '1.7', sprintf(__('Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress'), __METHOD__, __FILE__)); $old_args_keys = array(0 => 'user_id', 1 => 'type', 2 => 'page', 3 => 'per_page', 4 => 'max', 5 => 'slug', 6 => 'search_terms', 7 => 'populate_extras', 8 => 'include', 9 => 'exclude', 10 => 'show_hidden', 11 => 'page_arg'); $func_args = func_get_args(); $args = bp_core_parse_args_array($old_args_keys, $func_args); } $defaults = array('type' => 'active', 'page' => 1, 'per_page' => 20, 'max' => false, 'show_hidden' => false, 'page_arg' => 'grpage', 'user_id' => 0, 'slug' => false, 'include' => false, 'exclude' => false, 'search_terms' => '', 'meta_query' => false, 'populate_extras' => true, 'update_meta_cache' => true); $r = wp_parse_args($args, $defaults); extract($r); $this->pag_page = isset($_REQUEST[$page_arg]) ? intval($_REQUEST[$page_arg]) : $page; $this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page; if (bp_current_user_can('bp_moderate') || is_user_logged_in() && $user_id == bp_loggedin_user_id()) { $show_hidden = true; } if ('invites' == $type) { $this->groups = groups_get_invites_for_user($user_id, $this->pag_num, $this->pag_page, $exclude); } else { if ('single-group' == $type) { $this->single_group = true; if (groups_get_current_group()) { $group = groups_get_current_group(); } else { $group = groups_get_group(array('group_id' => BP_Groups_Group::get_id_from_slug($r['slug']), 'populate_extras' => $r['populate_extras'])); } // backwards compatibility - the 'group_id' variable is not part of the // BP_Groups_Group object, but we add it here for devs doing checks against it // // @see https://buddypress.trac.wordpress.org/changeset/3540 // // this is subject to removal in a future release; devs should check against // $group->id instead $group->group_id = $group->id; $this->groups = array($group); } else { $this->groups = groups_get_groups(array('type' => $type, 'order' => $order, 'orderby' => $orderby, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'meta_query' => $meta_query, 'include' => $include, 'exclude' => $exclude, 'populate_extras' => $populate_extras, 'update_meta_cache' => $update_meta_cache, 'show_hidden' => $show_hidden)); } } if ('invites' == $type) { $this->total_group_count = (int) $this->groups['total']; $this->group_count = (int) $this->groups['total']; $this->groups = $this->groups['groups']; } else { if ('single-group' == $type) { if (empty($group->id)) { $this->total_group_count = 0; $this->group_count = 0; } else { $this->total_group_count = 1; $this->group_count = 1; } } else { if (empty($max) || $max >= (int) $this->groups['total']) { $this->total_group_count = (int) $this->groups['total']; } else { $this->total_group_count = (int) $max; } $this->groups = $this->groups['groups']; if (!empty($max)) { if ($max >= count($this->groups)) { $this->group_count = count($this->groups); } else { $this->group_count = (int) $max; } } else { $this->group_count = count($this->groups); } } } // Build pagination links if ((int) $this->total_group_count && (int) $this->pag_num) { $this->pag_links = paginate_links(array('base' => add_query_arg(array($page_arg => '%#%', 'num' => $this->pag_num, 's' => $search_terms, 'sortby' => $this->sort_by, 'order' => $this->order)), 'format' => '', 'total' => ceil((int) $this->total_group_count / (int) $this->pag_num), 'current' => $this->pag_page, 'prev_text' => _x('←', 'Group pagination previous text', 'buddypress'), 'next_text' => _x('→', 'Group pagination next text', 'buddypress'), 'mid_size' => 1)); } }
/** * Render the content for deposits/item/new. */ function humcore_deposit_form() { if (!empty($_POST)) { $deposit_id = humcore_deposit_file(); if ($deposit_id) { $review_url = sprintf('/deposits/item/%1$s/review/', $deposit_id); wp_redirect($review_url); exit; } } if (!humcore_check_externals()) { echo '<h3>New <em>CORE</em> Deposit</h3>'; echo "<p>We're so sorry, but one of the components of <em>CORE</em> is currently down and it can't accept deposits just now. We're working on it (and we're delighted that you want to share your work) so please come back and try again later.</p>"; $wp_referer = wp_get_referer(); printf('<a href="%1$s" class="button white" style="line-height: 1.2em;">Go Back</a>', !empty($wp_referer) && !strpos($wp_referer, 'item/new') ? $wp_referer : '/deposits/'); return; } $current_group_id = ''; preg_match('~.*?/groups/(.*[^/]?)/deposits/~i', wp_get_referer(), $slug_match); if (!empty($slug_match)) { $current_group_id = BP_Groups_Group::get_id_from_slug($slug_match[1]); } $user_id = bp_loggedin_user_id(); $user_firstname = get_the_author_meta('first_name', $user_id); $user_lastname = get_the_author_meta('last_name', $user_id); ?> <script type="text/javascript"> var MyAjax = { ajaxurl : '<?php echo esc_url(admin_url('admin-ajax.php')); ?> ', flash_swf_url : '<?php echo esc_url(includes_url('/js/plupload/Moxie.swf')); ?> ', silverlight_xap_url : '<?php echo esc_url(includes_url('/js/plupload/Moxie.xap')); ?> ', _ajax_nonce : '<?php echo esc_attr(wp_create_nonce('file-upload')); ?> ', }; </script> <h3>New CORE Deposit</h3> <div id="filelist">Your browser doesn't have Flash, Silverlight or HTML5 support.</div> <div id="progressbar"> <div id="indicator"></div> </div> <div id="console">Select the file you wish to upload and deposit. *</div> <div id="container"> <button id="pickfile">Select File</button> <!-- <button id="uploadfile">Upload</button> --> <?php $wp_referer = wp_get_referer(); printf('<a href="%1$s" class="button white" style="line-height: 1.2em;">Cancel</a>', !empty($wp_referer) && !strpos($wp_referer, 'item/new') ? $wp_referer : '/deposits/'); ?> </div> <script type='text/javascript' src='/js/retrieveDOI.js'></script> <form id="deposit-form" class="standard-form" method="post" action="" enctype="multipart/form-data"> <input type="hidden" name="action" id="action" value="deposit_file" /> <?php wp_nonce_field('new_core_deposit', 'new_core_deposit_nonce'); ?> <input type="hidden" name="selected_temp_name" id="selected_temp_name" value="<?php if (!empty($_POST['selected_temp_name'])) { echo sanitize_text_field($_POST['selected_temp_name']); } ?> " /> <input type="hidden" name="selected_file_name" id="selected_file_name" value="<?php if (!empty($_POST['selected_file_name'])) { echo sanitize_text_field($_POST['selected_file_name']); } ?> " /> <input type="hidden" name="selected_file_type" id="selected_file_type" value="<?php if (!empty($_POST['selected_file_type'])) { echo sanitize_text_field($_POST['selected_file_type']); } ?> " /> <input type="hidden" name="selected_file_size" id="selected_file_size" value="<?php if (!empty($_POST['selected_file_type'])) { echo sanitize_text_field($_POST['selected_file_size']); } ?> " /> <div id="deposit-metadata-entries"> <div id="deposit-title-entry"> <label for="deposit-title">Title</label> <input type="text" id="deposit-title-unchanged" name="deposit-title-unchanged" size="75" class="long" value="<?php if (!empty($_POST['deposit-title-unchanged'])) { echo wp_kses(stripslashes($_POST['deposit-title-unchanged']), array('b' => array(), 'em' => array(), 'strong' => array())); } ?> " /> <span class="description">*</span> </div> <p> <div id="deposit-genre-entry"> <label for="deposit-genre">Item Type</label> <select name="deposit-genre" id="deposit-genre" class="js-basic-single-required" data-placeholder="Select an item type"> <option class="level-0" value=""></option> <?php $genre_list = humcore_deposits_genre_list(); $posted_genre = ''; if (!empty($_POST['deposit-genre'])) { $posted_genre = sanitize_text_field($_POST['deposit-genre']); } foreach ($genre_list as $genre_key => $genre_value) { printf(' <option class="level-0" %1$s value="%2$s">%3$s</option>' . "\n", $genre_key == $posted_genre ? 'selected="selected"' : '', $genre_key, $genre_value); } ?> </select> <span class="description">*</span> </div> </p> <div id="deposit-conference-title-entry"> <label for="deposit-conference-title-entry-list">Conference Title</label> <input type="text" name="deposit-conference-title" size="75" class="text" value="<?php if (!empty($_POST['deposit-conference-title'])) { echo sanitize_text_field($_POST['deposit-conference-title']); } ?> " /> </div> <div id="deposit-organization-entry"> <label for="deposit-organization-entry-list">Conference Host Organization</label> <input type="text" name="deposit-organization" size="60" class="text" value="<?php if (!empty($_POST['deposit-organization'])) { echo sanitize_text_field($_POST['deposit-organization']); } ?> " /> </div> <div id="deposit-institution-entry"> <label for="deposit-institution-entry-list">Name of Institution</label> <input type="text" name="deposit-institution" size="60" class="text" value="<?php if (!empty($_POST['deposit-institution'])) { echo sanitize_text_field($_POST['deposit-institution']); } ?> " /> </div> <p> <div id="deposit-abstract-entry"> <label for="deposit-abstract">Description or Abstract</label> <textarea class="abstract_area" rows="12" autocomplete="off" cols="80" name="deposit-abstract-unchanged" id="deposit-abstract-unchanged"><?php if (!empty($_POST['deposit-abstract-unchanged'])) { echo wp_kses(stripslashes($_POST['deposit-abstract-unchanged']), array('b' => array(), 'em' => array(), 'strong' => array())); } ?> </textarea> <span class="description">*</span> <div class="character-count"></div> </div> </p> <p> <div id="deposit-on-behalf-flag-entry"> <?php $committee_list = humcore_deposits_user_committee_list(bp_loggedin_user_id()); $committee_list = ''; //disable for now if (empty($committee_list)) { ?> <input type="hidden" name="deposit-on-behalf-flag" id="deposit-on-behalf-flag" value="" /> <?php } else { ?> <label for="deposit-on-behalf-flag-list">Depositor</label> <span class="description">Is this deposit being made on behalf of a committee?</span> <input type="radio" name="deposit-on-behalf-flag" value="yes" <?php if (!empty($_POST['deposit-on-behalf-flag'])) { checked(sanitize_text_field($_POST['deposit-on-behalf-flag']), 'yes'); } ?> >Yes <input type="radio" name="deposit-on-behalf-flag" value="no" <?php if (!empty($_POST['deposit-on-behalf-flag'])) { checked(sanitize_text_field($_POST['deposit-on-behalf-flag']), 'no'); } else { echo 'checked="checked"'; } ?> >No <?php } ?> </div> </p> <p> <div id="deposit-other-authors-entry"> <label for="deposit-other-authors-entry-list">Authors</label> <span class="description">Add any authors in addition to yourself.</span> <ul id="deposit-other-authors-entry-list"> <li> <table id="deposit-other-authors-entry-table"><tbody> <tr><td class="noBorderTop" style="width:205px;"> First Name </td><td class="noBorderTop" style="width:205px;"> Last Name </td><td class="noBorderTop"> </td><td class="noBorderTop"> </td></tr> <tr><td class="borderTop" style="width:205px;"> <?php echo esc_html($user_firstname); ?> </td><td class="borderTop" style="width:205px;"> <?php echo esc_html($user_lastname); ?> </td><td class="borderTop"> <input type="button" id="deposit-insert-other-author-button" class="button add_author" value="Add Another"> </td></tr> <?php if (!empty($_POST['deposit-other-authors-first-name']) && !empty($_POST['deposit-other-authors-last-name'])) { $other_authors = array_map(function ($first_name, $last_name) { return array('first_name' => sanitize_text_field($first_name), 'last_name' => sanitize_text_field($last_name)); }, $_POST['deposit-other-authors-first-name'], $_POST['deposit-other-authors-last-name']); foreach ($other_authors as $author_array) { if (!empty($author_array['first_name']) && !empty($author_array['last_name'])) { ?> <tr><td class="borderTop" style="width:205px;"> <input type="text" name="deposit-other-authors-first-name[]" class="text" value="<?php echo $author_array['first_name']; ?> " /> </td><td class="borderTop" style="width:205px;"> <input type="text" name="deposit-other-authors-last-name[]" class="text deposit-other-authors-last-name" value="<?php echo $author_array['last_name']; ?> " /> </td><td class="borderTop"> </td></tr> <?php } } } ?> </tbody></table> </li> </ul> </div> </p> <p> <div id="deposit-committee-entry"> <?php if (empty($committee_list)) { ?> <input type="hidden" name="deposit-committee" id="deposit-committee" value="" /> <?php } else { ?> <label for="deposit-committee">Committee</label> <select name="deposit-committee" id="deposit-committee" class="js-basic-single-optional" data-placeholder="Select committee"> <option class="level-0" selected value=""></option> <?php $posted_committee = ''; if (!empty($_POST['deposit-committee'])) { $posted_committee = sanitize_text_field($_POST['deposit-committee']); } foreach ($committee_list as $committee_key => $committee_value) { printf(' <option class="level-1" %1$s value="%2$s">%3$s</option>' . "\n", $committee_key == $posted_committee ? 'selected="selected"' : '', $committee_key, $committee_value); } ?> </select> <?php } ?> </div> </p> <p> <div id="deposit-subject-entry"> <label for="deposit-subject">Subjects</label> <span class="description">Assign up to five subject fields to your item.<br />Please let us know if you would like to <a href="mailto:commons@mla.org?subject=CORE" target="_blank">suggest additional subject fields</a>.</span><br /> <select name="deposit-subject[]" id="deposit-subject[]" class="js-basic-multiple" multiple="multiple" data-placeholder="Select subjects"> <?php $subject_list = humcore_deposits_subject_list(); $posted_subject_list = array(); if (!empty($_POST['deposit-subject'])) { $posted_subject_list = array_map('sanitize_text_field', $_POST['deposit-subject']); } foreach ($subject_list as $subject_key => $subject_value) { printf(' <option class="level-1" %1$s value="%2$s">%3$s</option>' . "\n", in_array($subject_key, $posted_subject_list) ? 'selected="selected"' : '', $subject_key, $subject_value); } ?> </select> </div> </p> <p> <div id="deposit-group-entry"> <label for="deposit-group">Forums</label> <span class="description">Share this item with up to five <em>MLA Commons</em> forums.</span><br /> <select name="deposit-group[]" id="deposit-group[]" class="js-basic-multiple" multiple="multiple" data-placeholder="Select forums"> <?php $group_list = humcore_deposits_group_list(); $posted_group_list = array(); if (!empty($_POST['deposit-group'])) { $posted_group_list = array_map('sanitize_text_field', $_POST['deposit-group']); } foreach ($group_list as $group_key => $group_value) { printf(' <option class="level-1" %1$s value="%2$s">%3$s</option>' . "\n", $current_group_id == $group_key || in_array($group_key, $posted_group_list) ? 'selected="selected"' : '', $group_key, $group_value); } ?> </select> </div> </p> <p> <div id="deposit-keyword-entry"> <label for="deposit-keyword">Tags</label> <span class="description">Enter up to five tags to further categorize this item.</span><br /> <select name="deposit-keyword[]" id="deposit-keyword[]" class="js-basic-multiple-tags" multiple="multiple" data-placeholder="Enter tags"> <?php $keyword_list = humcore_deposits_keyword_list(); $posted_keyword_list = array(); if (!empty($_POST['deposit-keyword'])) { $posted_keyword_list = array_map('sanitize_text_field', $_POST['deposit-keyword']); } foreach ($keyword_list as $keyword_key => $keyword_value) { printf(' <option class="level-1" %1$s value="%2$s">%3$s</option>' . "\n", in_array($keyword_key, $posted_keyword_list) ? 'selected="selected"' : '', $keyword_key, $keyword_value); } ?> </select> </div> </p> <p> <div id="deposit-resource-type-entry"> <label for="deposit-resource-type">File Type</label> <select name="deposit-resource-type" id="deposit-resource-type" class="js-basic-single-optional" data-placeholder="Select a file type" data-allowClear="true"> <option class="level-0" selected value=""></option> <?php $resource_type_list = humcore_deposits_resource_type_list(); $posted_resource_type = ''; if (!empty($_POST['deposit-resource-type'])) { $posted_resource_type = sanitize_text_field($_POST['deposit-resource-type']); } foreach ($resource_type_list as $resource_key => $resource_value) { printf(' <option class="level-0" %1$s value="%2$s">%3$s</option>' . "\n", $resource_key == $posted_resource_type ? 'selected="selected"' : '', $resource_key, $resource_value); } ?> </select> </div> </p> <p> <div id="deposit-notes-entry"> <label for="deposit-notes">Notes or Background</label> <span class="description">Any additional information about your item?</span><br /> <textarea name="deposit-notes-unchanged" class="the-notes" id="deposit-notes-unchanged"><?php if (!empty($_POST['deposit-notes-unchanged'])) { echo wp_kses(stripslashes($_POST['deposit-notes-unchanged']), array('b' => array(), 'em' => array(), 'strong' => array())); } ?> </textarea> <div class="character-count"></div> </div> </p> <p> <div id="deposit-license-type-entry"> <label for="deposit-license-type">Creative Commons License</label> <span class="description">By default, and in accordance with section 2 of the <em>MLA Commons</em> terms of service, no one may reuse this content in any way. Should you wish to allow others to distribute, display, modify, or otherwise reuse your content, please attribute it with the appropriate Creative Commons license from the drop-down menu below. See <a onclick="target='_blank'" href="http://creativecommons.org/licenses/">this page</a> for more information about the different types of Creative Commons licenses.</span><br /><br /> <select name="deposit-license-type" id="deposit-license-type" class="js-basic-single-required"> <?php $license_type_list = humcore_deposits_license_type_list(); $posted_license_type = ''; if (!empty($_POST['deposit-license-type'])) { $posted_license_type = sanitize_text_field($_POST['deposit-license-type']); } foreach ($license_type_list as $license_key => $license_value) { printf(' <option class="level-1" %1$s value="%2$s">%3$s</option>' . "\n", $license_key == $posted_license_type ? 'selected="selected"' : '', $license_key, $license_value); } ?> </select> <span class="description">*</span> </div> </p> <p> <div id="deposit-publication-type-entry"> <label for="deposit-publication-type">Published?</label> <span class="description">Check journal or publisher open access policies at <a onclick="target='_blank'" href="http://www.sherpa.ac.uk/romeo/">SHERPA/RoMEO</a> for previously published work.</span><br /><br /> <input type="radio" name="deposit-publication-type" value="book" <?php if (!empty($_POST['deposit-publication-type'])) { checked(sanitize_text_field($_POST['deposit-publication-type']), 'book'); } ?> >Book <input type="radio" name="deposit-publication-type" value="journal-article" <?php if (!empty($_POST['deposit-publication-type'])) { checked(sanitize_text_field($_POST['deposit-publication-type']), 'journal-article'); } ?> >Journal <input type="radio" name="deposit-publication-type" value="conference-proceeding" <?php if (!empty($_POST['deposit-publication-type'])) { checked(sanitize_text_field($_POST['deposit-publication-type']), 'conference-proceeding'); } ?> >Conference proceeding <input type="radio" name="deposit-publication-type" value="none" <?php if (!empty($_POST['deposit-publication-type'])) { checked(sanitize_text_field($_POST['deposit-publication-type']), 'none'); } else { echo 'checked="checked"'; } ?> >Not published </div> </p> <div id="deposit-book-entries"> <div id="deposit-book-doi-entry"> <label for="deposit-book-doi">Publisher DOI</label> <input type="text" id="deposit-book-doi" name="deposit-book-doi" class="long" value="<?php if (!empty($_POST['deposit-book-doi'])) { echo sanitize_text_field($_POST['deposit-book-doi']); } ?> " /> </div> <div id="deposit-book-publisher-entry"> <label for="deposit-book-publisher">Publisher</label> <input type="text" id="deposit-book-publisher" name="deposit-book-publisher" size="40" class="long" value="<?php if (!empty($_POST['deposit-book-publisher'])) { echo sanitize_text_field($_POST['deposit-book-publisher']); } ?> " /> </div> <div id="deposit-book-publish-date-entry"> <label for="deposit-book-publish-date">Pub Date</label> <input type="text" id="deposit-book-publish-date" name="deposit-book-publish-date" class="text" value="<?php if (!empty($_POST['deposit-book-publish-date'])) { echo sanitize_text_field($_POST['deposit-book-publish-date']); } ?> " /> </div> <div id="deposit-book-title-entry"> <label for="deposit-book-title">Book Title</label> <input type="text" id="deposit-book-title" name="deposit-book-title" size="60" class="long" value="<?php if (!empty($_POST['deposit-book-title'])) { echo sanitize_text_field($_POST['deposit-book-title']); } ?> " /> </div> <div id="deposit-book-author-entry"> <label for="deposit-book-author">Book Author or Editor</label> <input type="text" id="deposit-book-author" name="deposit-book-author" class="long" value="<?php if (!empty($_POST['deposit-book-author'])) { echo sanitize_text_field($_POST['deposit-book-author']); } ?> " /> </div> <div id="deposit-book-chapter-entry"> <label for="deposit-book-chapter">Chapter</label> <input type="text" id="deposit-book-chapter" name="deposit-book-chapter" class="text" value="<?php if (!empty($_POST['deposit-book-chapter'])) { echo sanitize_text_field($_POST['deposit-book-chapter']); } ?> " /> </div> <div id="deposit-book-pages-entry"> <label for="deposit-book-start-page"><span>Start Page</span> <input type="text" id="deposit-book-start-page" name="deposit-book-start-page" size="5" class="text" value="<?php if (!empty($_POST['deposit-book-start-page'])) { echo sanitize_text_field($_POST['deposit-book-start-page']); } ?> " /> </label> <label for="deposit-book-end-page"><span>End Page</span> <input type="text" id="deposit-book-end-page" name="deposit-book-end-page" size="5" class="text" value="<?php if (!empty($_POST['deposit-book-end-page'])) { echo sanitize_text_field($_POST['deposit-book-end-page']); } ?> " /> </label> <br style='clear:both'> </div> <div id="deposit-book-isbn-entry"> <label for="deposit-book-isbn">ISBN</label> <input type="text" id="deposit-book-isbn" name="deposit-book-isbn" class="text" value="<?php if (!empty($_POST['deposit-book-isbn'])) { echo sanitize_text_field($_POST['deposit-book-isbn']); } ?> " /> </div> </div> <div id="deposit-journal-entries"> <div id="deposit-journal-doi-entry"> <label for="deposit-journal-doi">Publisher DOI</label> <input type="text" id="deposit-journal-doi" name="deposit-journal-doi" class="long" value="<?php if (!empty($_POST['deposit-journal-doi'])) { echo sanitize_text_field($_POST['deposit-journal-doi']); } ?> " /> </div> <div id="deposit-journal-publisher-entry"> <label for="deposit-journal-publisher">Publisher</label> <input type="text" id="deposit-journal-publisher" name="deposit-journal-publisher" size="40" class="long" value="<?php if (!empty($_POST['deposit-journal-publisher'])) { echo sanitize_text_field($_POST['deposit-journal-publisher']); } ?> " /> </div> <div id="deposit-journal-publish-date-entry"> <label for="deposit-journal-publish-date">Pub Date</label> <input type="text" id="deposit-journal-publish-date" name="deposit-journal-publish-date" class="text" value="<?php if (!empty($_POST['deposit-journal-publish-date'])) { echo sanitize_text_field($_POST['deposit-journal-publish-date']); } ?> " /> </div> <div id="deposit-journal-title-entry"> <label for="deposit-journal-title">Journal Title</label> <input type="text" id="deposit-journal-title" name="deposit-journal-title" size="75" class="long" value="<?php if (!empty($_POST['deposit-journal-title'])) { echo sanitize_text_field($_POST['deposit-journal-title']); } ?> " /> </div> <div id="deposit-journal-volume-entry"> <label for="deposit-journal-volume"><span>Volume</span> <input type="text" id="deposit-journal-volume" name="deposit-journal-volume" class="text" value="<?php if (!empty($_POST['deposit-journal-volume'])) { echo sanitize_text_field($_POST['deposit-journal-volume']); } ?> " /> </label> <label for="deposit-journal-issue"><span>Issue</span> <input type="text" id="deposit-journal-issue" name="deposit-journal-issue" class="text" value="<?php if (!empty($_POST['deposit-journal-volume'])) { echo sanitize_text_field($_POST['deposit-journal-volume']); } ?> " /> </label> <br style='clear:both'> </div> <div id="deposit-journal-pages-entry"> <label for="deposit-journal-start-page"><span>Start Page</span> <input type="text" id="deposit-journal-start-page" name="deposit-journal-start-page" size="5" class="text" value="<?php if (!empty($_POST['deposit-journal-start-page'])) { echo sanitize_text_field($_POST['deposit-journal-start-page']); } ?> " /> </label> <label for="deposit-journal-end-page"><span>End Page</span> <input type="text" id="deposit-journal-end-page" name="deposit-journal-end-page" size="5" class="text" value="<?php if (!empty($_POST['deposit-journal-start-page'])) { echo sanitize_text_field($_POST['deposit-journal-start-page']); } ?> " /> </label> <br style='clear:both'> </div> <div id="deposit-journal-issn-entry"> <label for="deposit-journal-issn">ISSN</label> <input type="text" id="deposit-journal-issn" name="deposit-journal-issn" class="text" value="<?php if (!empty($_POST['deposit-journal-issn'])) { echo sanitize_text_field($_POST['deposit-journal-issn']); } ?> " /> </div> </div> <div id="deposit-conference-proceedings"> <div id="deposit-proceeding-doi-entry"> <label for="deposit-proceeding-doi">Publisher DOI</label> <input type="text" id="deposit-proceeding-doi" name="deposit-proceeding-doi" class="long" value="<?php if (!empty($_POST['deposit-proceeding-doi'])) { echo sanitize_text_field($_POST['deposit-proceeding-doi']); } ?> " /> </div> <div id="deposit-proceeding-publisher-entry"> <label for="deposit-proceeding-publisher">Publisher</label> <input type="text" id="deposit-proceeding-publisher" name="deposit-proceeding-publisher" size="40" class="long" value="<?php if (!empty($_POST['deposit-proceeding-publisher'])) { echo sanitize_text_field($_POST['deposit-proceeding-publisher']); } ?> " /> </div> <div id="deposit-proceeding-publish-date-entry"> <label for="deposit-proceeding-publish-date">Pub Date</label> <input type="text" id="deposit-proceeding-publish-date" name="deposit-proceeding-publish-date" class="text" value="<?php if (!empty($_POST['deposit-proceeding-publish-date'])) { echo sanitize_text_field($_POST['deposit-proceeding-publish-date']); } ?> " /> </div> <div id="deposit-proceeding-title-entry"> <label for="deposit-proceeding-title">Proceeding Title</label> <input type="text" id="deposit-proceeding-title" name="deposit-proceeding-title" size="75" class="long" value="<?php if (!empty($_POST['deposit-proceeding-title'])) { echo sanitize_text_field($_POST['deposit-proceeding-title']); } ?> " /> </div> <div id="deposit-proceeding-pages-entry"> <label for="deposit-proceeding-start-page"><span>Start Page</span> <input type="text" id="deposit-proceeding-start-page" name="deposit-proceeding-start-page" size="5" class="text" value="<?php if (!empty($_POST['deposit-proceeding-start-page'])) { echo sanitize_text_field($_POST['deposit-proceeding-start-page']); } ?> " /> </label> <label for="deposit-proceeding-end-page"><span>End Page</span> <input type="text" id="deposit-proceeding-end-page" name="deposit-proceeding-end-page" size="5" class="text" value="<?php if (!empty($_POST['deposit-proceeding-start-page'])) { echo sanitize_text_field($_POST['deposit-proceeding-start-page']); } ?> " /> </label> <br style='clear:both'> </div> </div> <div id="deposit-non-published-entries"> <div id="deposit-non-published-date-entry"> <label for="deposit-non-published-date">Date of Creation</label> <input type="text" id="deposit-non-published-date" name="deposit-non-published-date" class="text" value="<?php if (!empty($_POST['deposit-non-published-date'])) { echo sanitize_text_field($_POST['deposit-non-published-date']); } ?> " /> </div> </div> <input id="submit" name="submit" type="submit" value="Deposit" /> <?php $wp_referer = wp_get_referer(); printf('<a href="%1$s" class="button white">Cancel</a>', !empty($wp_referer) && !strpos($wp_referer, 'item/new') ? $wp_referer : '/deposits/'); ?> </div> </form> <br /><span class="description">Required fields are marked *.</span><br /> <br /> <?php }
function __construct($user_id, $type, $page, $per_page, $max, $slug, $search_terms, $populate_extras, $include = false, $exclude = false, $show_hidden = false) { global $bp; $this->pag_page = isset($_REQUEST['grpage']) ? intval($_REQUEST['grpage']) : $page; $this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page; if (bp_current_user_can('bp_moderate') || is_user_logged_in() && $user_id == bp_loggedin_user_id()) { $show_hidden = true; } if ('invites' == $type) { $this->groups = groups_get_invites_for_user($user_id, $this->pag_num, $this->pag_page, $exclude); } else { if ('single-group' == $type) { $group = new stdClass(); $group->group_id = BP_Groups_Group::get_id_from_slug($slug); $this->groups = array($group); } else { $this->groups = groups_get_groups(array('type' => $type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'include' => $include, 'exclude' => $exclude, 'populate_extras' => $populate_extras, 'show_hidden' => $show_hidden)); } } if ('invites' == $type) { $this->total_group_count = (int) $this->groups['total']; $this->group_count = (int) $this->groups['total']; $this->groups = $this->groups['groups']; } else { if ('single-group' == $type) { $this->single_group = true; $this->total_group_count = 1; $this->group_count = 1; } else { if (empty($max) || $max >= (int) $this->groups['total']) { $this->total_group_count = (int) $this->groups['total']; } else { $this->total_group_count = (int) $max; } $this->groups = $this->groups['groups']; if (!empty($max)) { if ($max >= count($this->groups)) { $this->group_count = count($this->groups); } else { $this->group_count = (int) $max; } } else { $this->group_count = count($this->groups); } } } // Build pagination links if ((int) $this->total_group_count && (int) $this->pag_num) { $this->pag_links = paginate_links(array('base' => add_query_arg(array('grpage' => '%#%', 'num' => $this->pag_num, 's' => $search_terms, 'sortby' => $this->sort_by, 'order' => $this->order)), 'format' => '', 'total' => ceil((int) $this->total_group_count / (int) $this->pag_num), 'current' => $this->pag_page, 'prev_text' => _x('←', 'Group pagination previous text', 'buddypress'), 'next_text' => _x('→', 'Group pagination next text', 'buddypress'), 'mid_size' => 1)); } }
public static function get_access_options($options, $settings_field, $doc_id = 0, $group_id = 0) { if (!$group_id) { $group_id = bp_docs_get_associated_group_id($doc_id); } // If this is the Doc creation page, check to see whether a // group id has been passed somewhere if (empty($group_id)) { if (isset($_POST['associated_group_id'])) { $group_id = intval($_POST['associated_group_id']); } else { if (isset($_GET['associated_group_id'])) { $group_id = intval($_GET['associated_group_id']); } else { if (isset($_GET['group'])) { $maybe_group = BP_Groups_Group::get_id_from_slug($_GET['group']); if ($maybe_group) { $group_id = $maybe_group; } } } } } if ($group_id && current_user_can('bp_docs_associate_with_group', $group_id)) { $group = groups_get_group(array('group_id' => intval($group_id))); $options[40] = array('name' => 'group-members', 'label' => sprintf(__('Members of %s', 'bp-docs'), $group->name)); // "Admins and mods" setting only available to admins and mods // Otherwise users end up locking themselves out $group_settings = bp_docs_get_group_settings($group_id); $is_admin = groups_is_user_admin(bp_loggedin_user_id(), $group_id); $is_mod = groups_is_user_mod(bp_loggedin_user_id(), $group_id); if ($is_admin || $is_mod) { $options[50] = array('name' => 'admins-mods', 'label' => sprintf(__('Admins and mods of %s', 'bp-docs'), $group->name)); } // Group-associated docs should have the edit/post // permissions limited to group-members by default. If // the group is non-public, set the other permissions // to group-members as well if ('public' != $group->status || in_array($settings_field, array('edit', 'post_comments'))) { // First, unset existing defaults foreach ($options as &$option) { $option['default'] = 0; } $options[40]['default'] = 1; } } return $options; }
/** * figure out the current used buddypress group_id * * @since 0.1 * @access public * @returns int $group_id */ public function bd_docs_get_current_group_id() { $group_id = false; if (bp_docs_is_bp_docs_page() && NULL !== bp_docs_get_current_doc()) { $group_id = bp_docs_get_associated_group_id(get_the_ID()); } else { $path = $_SERVER['REQUEST_URI']; $p_arr = explode('/', $path); if (isset($p_arr[1]) && $p_arr[1] == bp_get_groups_root_slug()) { $slug = $p_arr[2]; $group_id = BP_Groups_Group::get_id_from_slug($slug); } else { $u = parse_url(wp_get_referer()); $path = $u['path']; $p_arr = explode('/', $path); if (isset($p_arr[1]) && $p_arr[1] == bp_get_groups_root_slug()) { $slug = $p_arr[2]; $group_id = BP_Groups_Group::get_id_from_slug($slug); } } } return $group_id; }
/** * Display a summary of the associated group * * @since 1.2 * * @param int $group_id */ function bp_docs_associated_group_summary($group_id = 0) { $html = ''; if (!$group_id) { if (isset($_GET['group'])) { $group_slug = $_GET['group']; $group_id = BP_Groups_Group::get_id_from_slug($group_slug); } else { $doc_id = is_singular() ? get_the_ID() : 0; $group_id = bp_docs_get_associated_group_id($doc_id); } } $group_id = intval($group_id); if ($group_id) { $group = groups_get_group('group_id=' . $group_id); if (!empty($group->name)) { $group_link = esc_url(bp_get_group_permalink($group)); $group_avatar = bp_core_fetch_avatar(array('item_id' => $group_id, 'object' => 'group', 'type' => 'thumb', 'width' => '40', 'height' => '40')); $group_member_count = sprintf(1 == $group->total_member_count ? __('%s member', 'bp-docs') : __('%s members', 'bp-docs'), intval($group->total_member_count)); switch ($group->status) { case 'public': $group_type_string = __('Public Group', 'bp-docs'); break; case 'private': $group_type_string = __('Private Group', 'bp-docs'); break; case 'hidden': $group_type_string = __('Hidden Group', 'bp-docs'); break; default: $group_type_string = ''; break; } $html .= '<a href="' . $group_link . '">' . $group_avatar . '</a>'; $html .= '<div class="item">'; $html .= '<a href="' . $group_link . '">' . esc_html($group->name) . '</a>'; $html .= '<div class="meta">' . $group_type_string . ' / ' . $group_member_count . '</div>'; $html .= '</div>'; } } echo $html; }
/** * Add the meta box to the edit page. * * @since 1.9 */ function bp_docs_folders_meta_box() { $doc_id = get_the_ID(); $associated_group_id = bp_is_active('groups') ? bp_docs_get_associated_group_id($doc_id) : 0; if (!$associated_group_id && isset($_GET['group'])) { $group_id = BP_Groups_Group::get_id_from_slug(urldecode($_GET['group'])); if (current_user_can('bp_docs_associate_with_group', $group_id)) { $associated_group_id = $group_id; } } // On the Create screen, respect the 'folder' $_GET param if (bp_docs_is_doc_create()) { $folder_id = bp_docs_get_current_folder_id(); } else { $folder_id = bp_docs_get_doc_folder($doc_id); } ?> <div id="doc-folders" class="doc-meta-box"> <div class="toggleable <?php bp_docs_toggleable_open_or_closed_class(); ?> "> <p id="folders-toggle-edit" class="toggle-switch"> <span class="hide-if-js toggle-link-no-js"><?php _e('Folders', 'bp-docs'); ?> </span> <a class="hide-if-no-js toggle-link" id="folders-toggle-link" href="#"><span class="show-pane plus-or-minus"></span><span class="toggle-title"><?php _e('Folders', 'bp-docs'); ?> </span></a> </p> <div class="toggle-content"> <table class="toggle-table" id="toggle-table-tags"> <tr> <td class="desc-column"> <label for="bp_docs_tag"><?php _e('Select a folder for this Doc.', 'bp-docs'); ?> </label> </td> <td> <div class="existing-or-new-selector"> <input type="radio" name="existing-or-new-folder" id="use-existing-folder" value="existing" checked="checked" /> <label for="use-existing-folder" class="radio-label"><?php _e('Use an existing folder', 'bp-docs'); ?> </label><br /> <div class="selector-content"> <?php bp_docs_folder_selector(array('name' => 'bp-docs-folder', 'id' => 'bp-docs-folder', 'group_id' => $associated_group_id, 'selected' => $folder_id)); ?> </div> </div> <div class="existing-or-new-selector" id="new-folder-block"> <input type="radio" name="existing-or-new-folder" id="create-new-folder" value="new" /> <label for="create-new-folder" class="radio-label"><?php _e('Create a new folder', 'bp-docs'); ?> </label> <div class="selector-content"> <?php bp_docs_create_new_folder_markup(array('group_id' => $associated_group_id, 'selected' => $associated_group_id)); ?> </div><!-- .selector-content --> </div> </td> </tr> </table> </div> </div> </div> <?php }
public static function get_access_options($options, $settings_field, $doc_id = 0, $group_id = 0) { if (!$group_id) { $group_id = bp_docs_get_associated_group_id($doc_id); } // If this is the Doc creation page, check to see whether a // group id has been passed somewhere if (empty($group_id)) { if (isset($_POST['associated_group_id'])) { $group_id = intval($_POST['associated_group_id']); } else { if (isset($_GET['associated_group_id'])) { $group_id = intval($_GET['associated_group_id']); } else { if (isset($_GET['group'])) { $maybe_group = BP_Groups_Group::get_id_from_slug($_GET['group']); if ($maybe_group) { $group_id = $maybe_group; } } } } } $can_associate = self::user_can_associate_doc_with_group(bp_loggedin_user_id(), $group_id); if ($can_associate) { $group = groups_get_group('group_id=' . intval($group_id)); $options[40] = array('name' => 'group-members', 'label' => sprintf(__('Members of %s', 'bp-docs'), $group->name)); $options[50] = array('name' => 'admins-mods', 'label' => sprintf(__('Admins and mods of %s', 'bp-docs'), $group->name)); // Group-associated docs should have the edit/post // permissions limited to group-members by default. If // the group is non-public, set the other permissions // to group-members as well // First, unset existing defaults foreach ($options as &$option) { $option['default'] = 0; } // Now, set new defaults if ('public' != $group->status || in_array($settings_field, array('edit', 'post-comments'))) { $options[40]['default'] = 1; } } return $options; }
/** * Override the group slug in permalinks with a group's full path */ function bp_group_hierarchy_fixup_permalink($permalink) { global $bp; $group_slug = substr($permalink, strlen($bp->root_domain . '/' . bp_get_groups_root_slug() . '/'), -1); if (strpos($group_slug, '/')) { return $permalink; } $group_id = BP_Groups_Group::get_id_from_slug($group_slug); if ($group_id) { $group_path = BP_Groups_Hierarchy::get_path($group_id); return str_replace('/' . $group_slug . '/', '/' . $group_path . '/', $permalink); } return $permalink; }
function bp_groups_user_groups_template($user_id, $type, $per_page, $max, $slug, $filter) { global $bp; if (!$user_id) { $user_id = $bp->displayed_user->id; } $this->pag_page = isset($_REQUEST['grpage']) ? intval($_REQUEST['grpage']) : 1; $this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page; switch ($type) { case 'recently-joined': $this->groups = groups_get_recently_joined_for_user($user_id, $this->pag_num, $this->pag_page, $filter); break; case 'popular': $this->groups = groups_get_most_popular_for_user($user_id, $this->pag_num, $this->pag_page, $filter); break; case 'admin-of': $this->groups = groups_get_user_is_admin_of($user_id, $this->pag_num, $this->pag_page, $filter); break; case 'mod-of': $this->groups = groups_get_user_is_mod_of($user_id, $this->pag_num, $this->pag_page, $filter); break; case 'alphabetical': $this->groups = groups_get_alphabetically_for_user($user_id, $this->pag_num, $this->pag_page, $filter); break; case 'invites': $this->groups = groups_get_invites_for_user(); break; case 'single-group': $group = new stdClass(); $group->group_id = BP_Groups_Group::get_id_from_slug($slug); $this->groups = array($group); break; case 'active': default: $this->groups = groups_get_recently_active_for_user($user_id, $this->pag_num, $this->pag_page, $filter); break; } if ('invites' == $type) { $this->total_group_count = count($this->groups); $this->group_count = count($this->groups); } else { if ('single-group' == $type) { $this->single_group = true; $this->total_group_count = 1; $this->group_count = 1; } else { if (!$max) { $this->total_group_count = (int) $this->groups['total']; } else { $this->total_group_count = (int) $max; } $this->groups = $this->groups['groups']; if ($max) { if ($max >= count($this->groups)) { $this->group_count = count($this->groups); } else { $this->group_count = (int) $max; } } else { $this->group_count = count($this->groups); } } } $this->pag_links = paginate_links(array('base' => add_query_arg(array('grpage' => '%#%', 'num' => $this->pag_num, 's' => $_REQUEST['s'], 'sortby' => $this->sort_by, 'order' => $this->order)), 'format' => '', 'total' => ceil($this->total_group_count / $this->pag_num), 'current' => $this->pag_page, 'prev_text' => '«', 'next_text' => '»', 'mid_size' => 1)); }