function __construct()
 {
     parent::__construct(array('singular' => BUtils::_('Membership Level'), 'plural' => BUtils::_('Membership Levels'), 'ajax' => false));
     $this->category = array();
     $selected = filter_input(INPUT_POST, 'membership_level_id');
     $this->selected_level_id = empty($selected) ? 1 : $selected;
     $this->category = $this->selected_level_id == 1 ? BProtection::get_instance() : BPermission::get_instance($this->selected_level_id);
 }
 public function can_i_read_comment($id)
 {
     $this->lastError = '';
     $protected = BProtection::get_instance();
     if (!$protected->is_protected_comment($id)) {
         return true;
     }
     $auth = BAuth::get_instance();
     if (!$auth->is_logged_in()) {
         $this->lastError = apply_filters('swpm_not_logged_in_comment_msg', BUtils::_("You need to login to view this content. ") . BSettings::get_instance()->get_login_link());
         return false;
     }
     if ($auth->is_expired_account()) {
         $error_msg = '<div class="swpm-account-expired-msg swpm-yellow-box">' . BUtils::_('Your account has expired. Please renew your account to gain access to this content.') . '</div>';
         $this->lastError = apply_filters('swpm_account_expired_msg', $error_msg);
         return false;
     }
     $perms = BPermission::get_instance($auth->get('membership_level'));
     if ($perms->is_permitted_comment($id)) {
         return true;
     }
     $this->lastError = apply_filters('swpm_restricted_comment_msg', '<div class="swpm-no-access-msg">' . BUtils::_("This content is not permitted for your membership level.") . '</div>');
     return false;
 }
 public static function get_instance()
 {
     self::$_this = empty(self::$_this) ? new BProtection() : self::$_this;
     return self::$_this;
 }
示例#4
0
 private function __construct()
 {
     $this->isLoggedIn = false;
     $this->userData = null;
     $this->protected = BProtection::get_instance();
 }