Skip to content

Commit

Permalink
PLAT-8424: allow creation of free trial sub partner only if one wasnt…
Browse files Browse the repository at this point in the history
… created before
  • Loading branch information
inbal-ben-david committed Jan 17, 2018
1 parent 3868e0a commit dd6a62b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
17 changes: 17 additions & 0 deletions alpha/apps/kaltura/lib/myPartnerRegistration.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,23 @@ public function initNewPartner($partner_name , $contact, $email, $ID_is_for, $SD
{
throw new SignupException("Invalid password for user with email [$email].", SignupException::EMAIL_ALREADY_EXISTS );
}

if(myPartnerUtils::isPartnerCreatedAsMonitoredFreeTrial($partner))
{
$partnerPackage = $partner->getPartnerPackage();
if ($this->partnerParentId)
{
$parentPartner = PartnerPeer::retrieveByPK($this->partnerParentId);
$partnerPackage = $parentPartner->getPartnerPackage();
}

if($partnerPackage == PartnerPackages::PARTNER_PACKAGE_FREE)
{
$result = myPartnerUtils::retrieveActivePartnerByEmailAndPackage ($partner, PartnerPackages::PARTNER_PACKAGE_FREE);
if($result)
throw new SignupException("Free Trial user with email [$email] already exists in system.", SignupException::EMAIL_ALREADY_EXISTS);
}
}
}


Expand Down
18 changes: 18 additions & 0 deletions alpha/apps/kaltura/lib/myPartnerUtils.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2084,4 +2084,22 @@ public static function isPartnerCreatedAsMonitoredFreeTrial($partner)
return true;
return false;
}

/**
* retrieve all the partners in status active with specific admin email and package type
*
* @param partner $partner
* @param $package
* @return array
*/
public static function retrieveActivePartnerByEmailAndPackage ($partner, $package)
{
$c = new Criteria();
$c->add(PartnerPeer::ADMIN_EMAIL, $partner->getAdminEmail());
$c->add(PartnerPeer::PARTNER_PACKAGE, $package);
$c->add(PartnerPeer::STATUS, KalturaPartnerStatus::ACTIVE);
$result = PartnerPeer::doSelect($c);
return $result;
}

}

0 comments on commit dd6a62b

Please sign in to comment.