/** * Get a Type selector dropdown. * * @since 1.9 */ function bp_docs_folder_type_selector($args = array()) { $r = wp_parse_args($args, array('selected' => 'global', 'echo' => true, 'include_all_groups' => true, 'id' => 'new-folder-type', 'name' => 'new-folder-type')); // todo: user/me if ($r['include_all_groups'] || is_numeric($r['selected'])) { if ($r['include_all_groups']) { $group_id = null; } else { $group_id = $r['selected']; } $group_selector = bp_docs_associated_group_dropdown(array('options_only' => true, 'selected' => $r['selected'], 'echo' => false, 'null_option' => false, 'include' => $group_id)); } $type_selector = '<select name="' . esc_attr($r['name']) . '" id="' . esc_attr($r['id']) . '" class="folder-type">'; $type_selector .= '<option ' . selected($r['selected'], 'global', false) . ' value="global">' . __('Global', 'bp-docs') . '</option>'; $type_selector .= '<option ' . selected($r['selected'], 'me', false) . ' value="me">' . __('Personal', 'bp-docs') . '</option>'; if (isset($group_selector)) { $type_selector .= '<optgroup label="' . __('Group-specific', 'bp-docs') . '">'; $type_selector .= $group_selector; $type_selector .= '</optgroup>'; } $type_selector .= '</select>'; $type_selector = apply_filters('bp_docs_folder_type_selector', $type_selector, $r); if (false === $r['echo']) { return $type_selector; } else { echo $type_selector; } }
/** * Outputs the markup for the Associated Group settings section * * @since 1.2 */ function bp_docs_doc_associated_group_markup() { global $groups_template; $old_gt = $groups_template; // First, try to set the preselected group by looking at the URL params $selected_group_slug = isset($_GET['group']) ? $_GET['group'] : ''; // Support for BP Group Hierarchy if (false !== ($slash = strrpos($selected_group_slug, '/'))) { $selected_group_slug = substr($selected_group_slug, $slash + 1); } $selected_group = BP_Groups_Group::get_id_from_slug($selected_group_slug); if ($selected_group && !current_user_can('bp_docs_associate_with_group', $selected_group)) { $selected_group = 0; } // If the selected group is still 0, see if there's something in the db if (!$selected_group && is_singular()) { $selected_group = bp_docs_get_associated_group_id(get_the_ID()); } // Last check: if this is a second attempt at a newly created Doc, // there may be a previously submitted value if (empty($selected_group) && !empty(buddypress()->bp_docs->submitted_data->associated_group_id)) { $selected_group = buddypress()->bp_docs->submitted_data->associated_group_id; } $selected_group = intval($selected_group); ?> <tr> <td class="desc-column"> <label for="associated_group_id"><?php _e('Which group should this Doc be associated with?', 'bp-docs'); ?> </label> <span class="description"><?php _e('(Optional) Note that the Access settings available for this Doc may be limited by the privacy settings of the group you choose.', 'bp-docs'); ?> </span> </td> <td class="content-column"> <?php bp_docs_associated_group_dropdown(array('name' => 'associated_group_id', 'id' => 'associated_group_id', 'selected' => $selected_group)); ?> <div id="associated_group_summary"> <?php bp_docs_associated_group_summary(); ?> </div> </td> </tr> <?php $groups_template = $old_gt; }