public function setup_nav($main = array(), $sub = array())
 {
     $bp = buddypress();
     $component = 'members';
     $component_id = mpp_get_current_component_id();
     if (!mpp_is_enabled($component, $component_id)) {
         //allow to disable user galleries in case they don't want it
         return false;
     }
     $view_helper = MPP_Gallery_Screens::get_instance();
     // Add 'Gallery' to the user's main navigation
     $main_nav = array('name' => sprintf(__('Gallery <span>%d</span>', 'mediapress'), mpp_get_total_gallery_for_user()), 'slug' => $this->slug, 'position' => 86, 'screen_function' => array($view_helper, 'user_galleries'), 'default_subnav_slug' => 'my-galleries', 'item_css_id' => $this->id);
     if (bp_is_user()) {
         $user_domain = bp_displayed_user_domain();
     } else {
         $user_domain = bp_loggedin_user_domain();
     }
     $gallery_link = trailingslashit($user_domain . $this->slug);
     //with a trailing slash
     // Add the My Gallery nav item
     $sub_nav[] = array('name' => __('My Gallery', 'mediapress'), 'slug' => 'my-galleries', 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array($view_helper, 'my_galleries'), 'position' => 10, 'item_css_id' => 'gallery-my-gallery');
     if (mpp_user_can_create_gallery($component, get_current_user_id())) {
         // Add the Create gallery link to gallery nav
         $sub_nav[] = array('name' => __('Create a Gallery', 'mediapress'), 'slug' => 'create', 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array($view_helper, 'my_galleries'), 'user_has_access' => bp_is_my_profile(), 'position' => 20);
     }
     if (mpp_component_has_type_filters_enabled($component, $component_id)) {
         $i = 10;
         $supported_types = mpp_component_get_supported_types($component);
         foreach ($supported_types as $type) {
             if (!mpp_is_active_type($type)) {
                 continue;
             }
             $type_object = mpp_get_type_object($type);
             $sub_nav[] = array('name' => $type_object->label, 'slug' => 'type/' . $type, 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array($view_helper, 'my_galleries'), 'position' => 20 + $i);
             $i = $i + 10;
             //increment the position
         }
     }
     // Add the Upload link to gallery nav
     /*$sub_nav[] = array(
           'name'				=> __( 'Upload', 'mediapress'),
           'slug'				=> 'upload',
           'parent_url'		=> $gallery_link,
           'parent_slug'		=> $this->slug,
           'screen_function'	=> array( $view_helper, 'upload_media' ),
           'user_has_access'	=> bp_is_my_profile(),
           'position'			=> 30
       );*/
     parent::setup_nav($main_nav, $sub_nav);
     //disallow these names in various lists
     //we have yet to implement it
     $this->forbidden_names = apply_filters('mpp_forbidden_names', array('gallery', 'galleries', 'my-gallery', 'create', 'delete', 'upload', 'add', 'edit', 'admin', 'request', 'upload', 'tags', 'audio', 'video', 'photo'));
     //use this to extend the valid status
     $this->valid_status = apply_filters('mpp_valid_gallery_status', array_keys(mpp_get_active_statuses()));
     do_action('mpp_setup_nav');
     // $bp->gallery->current_gallery->user_has_access
 }
예제 #2
0
 private function add_gallery_views_panel($panel, $component)
 {
     $active_types = $this->active_types;
     $section = $panel->add_section($component . '-gallery-views', sprintf(_x(' %s Gallery Default Views', 'Gallery view section title', 'mediapress'), ucwords($component)));
     $supported_types = mpp_component_get_supported_types($component);
     foreach ($active_types as $key => $type_object) {
         //if the component does not support type, do not add the settings
         if (!empty($supported_types) && !mpp_component_supports_type($component, $key)) {
             continue;
             //if none of the types are enabled, it means, it is the first time and we need not break here
         }
         $registered_views = mpp_get_registered_gallery_views($key);
         $options = array();
         foreach ($registered_views as $view) {
             if (!$view->supports_component($component)) {
                 continue;
             }
             $options[$view->get_id()] = $view->get_name();
         }
         $section->add_field(array('name' => $component . '_' . $key . '_gallery_default_view', 'label' => sprintf(_x('%s Gallery', 'admin gallery  settings', 'mediapress'), ucwords($key)), 'description' => _x('It will be used as the default view. It can be overridden per gallery', 'admin gallery settings', 'mediapress'), 'default' => 'default', 'type' => 'radio', 'options' => $options));
     }
 }
예제 #3
0
function mpp_component_init_type_support($component)
{
    $supported_types = mpp_component_get_supported_types($component);
    foreach ($supported_types as $type) {
        mpp_component_add_type_support($component, $type);
    }
}