コード例 #1
0
 private function check_constraints()
 {
     if (empty($this->userData)) {
         return false;
     }
     $enable_expired_login = BSettings::get_instance()->get_value('enable-expired-account-login', '');
     $can_login = true;
     if ($this->userData->account_state == 'inactive') {
         $this->lastStatusMsg = BUtils::_('Account is inactive.');
         $can_login = false;
     } else {
         if ($this->userData->account_state == 'pending') {
             $this->lastStatusMsg = BUtils::_('Account is pending.');
             $can_login = false;
         } else {
             if ($this->userData->account_state == 'expired' && empty($enable_expired_login)) {
                 $this->lastStatusMsg = BUtils::_('Account has expired.');
                 $can_login = false;
             }
         }
     }
     if (!$can_login) {
         $this->isLoggedIn = false;
         $this->userData = null;
         return false;
     }
     if (BUtils::is_subscription_expired($this->userData)) {
         if ($this->userData->account_state == 'active') {
             global $wpdb;
             $wpdb->update($wpdb->prefix . 'swpm_members_tbl', array('account_state' => 'expired'), array('member_id' => $this->userData->member_id), array('%s'), array('%d'));
         }
         if (empty($enable_expired_login)) {
             $this->lastStatusMsg = BUtils::_('Account has expired.');
             $this->isLoggedIn = false;
             $this->userData = null;
             return false;
         }
     }
     $this->permitted = BPermission::get_instance($this->userData->membership_level);
     $this->lastStatusMsg = BUtils::_("You are logged in as:") . $this->userData->user_name;
     $this->isLoggedIn = true;
     return true;
 }