User
<?php
// ***************** Testphase-Completed Redirect 307 *********************
$ycom_user = rex_ycom_auth::getUser();
$slice_id = rex_request('order', 'int', 0);
if ($ycom_user && $slice_id > 0)
{
$addon = rex_addon::get('imTportal');
//$message = "<p>Die Testphase wurde für Sie freigeschaltet.</p>";
$message = '<p>'.$addon->i18n('imTportal_message_testphase_failed').'</p>';
$class = 'alert-warning';
$slice = rex_article_slice::getArticleSliceById($slice_id, false, 0);
if ($slice)
{
$user_properties = rex_imtp::getUserProperties($ycom_user, false);
$product = $slice->getValue(14);
if (($product !== null) && ($product !== "") && ($product !== "0"))
{
$product = rex_imtp_purchase::findPurchaseable($product);
}
else $product = null;
if ($product)
{
$testphaseAllowed = false;
if ($slice->getValue(13) == "1")
{
$testphaseAllowed = true;
$user_purchased = rex_imtp_purchase::getPurchase(intval($slice->getValue(14)), $ycom_user);
$testphase = rex_imtp_purchase::getPurchase(intval($slice->getValue(14)), $ycom_user, true);
if ($testphase)
{
$testphaseAllowed = false;
}
if (rex_imtp::checkUserProperty($slice->getValue(14), $user_properties, $ycom_user))
{
$testphaseAllowed = false;
}
if (rex_imtp::isUserAdmin($user_properties, $ycom_user))
{
$testphaseAllowed = false;
}
if ($testphaseAllowed)
{
$result = rex_imtp_purchase::addPurchase(intval($slice->getValue(14)), $ycom_user, true);
if ($result)
{
//$message = "<p>Die Testphase wurde für Sie freigeschaltet.</p>";
$message = '<p>'.$addon->i18n('imTportal_message_testphase_completed').'</p>';
$class = 'alert-success';
// +++ Testphase beginnt
$templateName = "en_email_testphase_aktiviert";
switch(rex_clang::getCurrentId())
{
case 3:
$templateName = "it_email_testphase_aktiviert";
break;
case 1:
$templateName = "de_email_testphase_aktiviert";
break;
}
rex_imtp::sendUserMail($templateName, array("productname"=>$product->getValue('name_'.rex_clang::getCurrentId())), $ycom_user, null);
}
}
}
}
}
}
?>