Exemplo n.º 1
0
 function check_positive_groups($posts)
 {
     global $wp_query, $M_options, $bp;
     $component = bp_current_component();
     if (count($posts) > 1) {
         return $posts;
     }
     if (!empty($component) && $component == 'groups') {
         // we may be on a restricted post so check the URL and redirect if needed
         // If we aren't on a group then return
         if ($bp->groups->current_group == 0) {
             return $posts;
         }
         $redirect = false;
         $url = '';
         $exclude = array();
         if (!empty($M_options['registration_page'])) {
             $exclude[] = get_permalink((int) $M_options['registration_page']);
             $exclude[] = untrailingslashit(get_permalink((int) $M_options['registration_page']));
         }
         if (!empty($M_options['account_page'])) {
             $exclude[] = get_permalink((int) $M_options['account_page']);
             $exclude[] = untrailingslashit(get_permalink((int) $M_options['account_page']));
         }
         if (!empty($M_options['nocontent_page'])) {
             $exclude[] = get_permalink((int) $M_options['nocontent_page']);
             $exclude[] = untrailingslashit(get_permalink((int) $M_options['nocontent_page']));
         }
         if (!empty($wp_query->query_vars['protectedfile']) && !$forceviewing) {
             $exclude[] = $host;
             $exclude[] = untrailingslashit($host);
         }
         $url = '';
         if (is_ssl()) {
             $url = "https://";
         } else {
             $url = "http://";
         }
         $url .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
         if (in_array(strtolower($url), $exclude)) {
             return $posts;
         }
         // we have the current page / url - get the groups selected
         $group_id = $this->get_group();
         if ($group_id) {
             $group = new M_Urlgroup($group_id);
             if (!$group->url_matches($url)) {
                 $redirect = true;
             }
         }
         if ($redirect === true && !empty($M_options['nocontent_page'])) {
             // we need to redirect
             $this->redirect();
         } else {
             return $posts;
         }
     }
     return $posts;
 }
Exemplo n.º 2
0
 function negative_check_request($wp)
 {
     $redirect = false;
     $host = '';
     if (is_ssl()) {
         $host = "https://";
     } else {
         $host = "http://";
     }
     $host .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $exclude = array();
     if (!empty($M_options['registration_page'])) {
         $exclude[] = get_permalink((int) $M_options['registration_page']);
         $exclude[] = untrailingslashit(get_permalink((int) $M_options['registration_page']));
     }
     if (!empty($M_options['account_page'])) {
         $exclude[] = get_permalink((int) $M_options['account_page']);
         $exclude[] = untrailingslashit(get_permalink((int) $M_options['account_page']));
     }
     if (!empty($M_options['nocontent_page'])) {
         $exclude[] = get_permalink((int) $M_options['nocontent_page']);
         $exclude[] = untrailingslashit(get_permalink((int) $M_options['nocontent_page']));
     }
     if (!empty($wp_query->query_vars['protectedfile']) && !$forceviewing) {
         $exclude[] = $host;
         $exclude[] = untrailingslashit($host);
     }
     // we have the current page / url - get the groups selected
     foreach ((array) $this->data as $group_id) {
         $group = new M_Urlgroup($group_id);
         if ($group->url_matches($host) && !in_array(strtolower($host), $exclude)) {
             $redirect = true;
         }
     }
     if ($redirect === true) {
         // we need to redirect
         $this->redirect();
     }
 }