/**
  * Make sure that we respect the Single-Membership rule.
  * This rule is active when the "Multiple-Memberships" Add-on is DISABLED.
  *
  * @since  1.0.0
  *
  * @param  MS_Model_Relationship $new_relationship
  */
 protected function validate_membership_states($new_relationship)
 {
     if (MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_MULTI_MEMBERSHIPS)) {
         // Multiple memberships allowed. No need to check anything.
         return;
     }
     $cancel_these = array(MS_Model_Relationship::STATUS_TRIAL, MS_Model_Relationship::STATUS_ACTIVE, MS_Model_Relationship::STATUS_PENDING);
     $member = $new_relationship->get_member();
     foreach ($member->subscriptions as $subscription) {
         if ($subscription->id === $new_relationship->id) {
             continue;
         }
         if (in_array($subscription->status, $cancel_these)) {
             $subscription->cancel_membership();
         }
     }
 }