/**
  * Save Options Form
  */
 public function save($con = null)
 {
     foreach ($this->getValues() as $option => $value) {
         if (in_array($option, self::$IGNORE_OPTIONS)) {
             continue;
         }
         OptionPeer::updateOption($option, $value);
     }
 }
	protected function doClean($values)
	{
		$username = isset($values[$this->getOption('username')])?$values[$this->getOption('username')]:null;
		$password = isset($values[$this->getOption('password')])?$values[$this->getOption('password')]:null;
		
		if(($username != OptionPeer::retrieveOption('ADMIN_USERNAME')) || (md5($password) != OptionPeer::retrieveOption('ADMIN_PASSWORD'))) 
			throw new sfValidatorError($this,'invalid');
		
		// login user
		sfContext::getInstance()->getUser()->signIn();
		return $values;
	}
echo $payment->getReference();
?>
<br/> 
Jotag: <?php 
echo $payment->getTag() ? $payment->getTag()->getJotag() : $payment->getJotag();
?>
<br/> 
Duration: <?php 
echo $payment->getDuration();
?>
 <?php 
echo PaymentPeer::getYearString($payment->getDuration(), false);
?>
<br/>
Order Total: <?php 
echo sprintf(OptionPeer::retrieveOption('CURRENCY_FORMAT'), $payment->getAmount());
?>
<br/> 
User: <?php 
echo $payment->getUser();
?>
<br/>
User Email: <?php 
echo $payment->getUser()->getPrimaryEmail();
?>
<br/> 
Reason: <?php 
if ($reason == 'CANCELLED') {
    ?>
 Tried to process a cancelled order, please verify payment on PayPal<?php 
} elseif ($reason == 'AMMOUNT') {
 public function executeUpdateCredit($request)
 {
     $user = $this->getUser()->getSubscriber();
     $user->setCredits(OptionPeer::retrieveOption('BONUS_INVITE_CREDIT'));
     $user->save();
 }
Beispiel #5
0
<?php

require_once dirname(__FILE__) . '/../config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
// initialize instance
sfContext::createInstance($configuration);
// set default TIMEZONE
$tz = OptionPeer::retrieveOption('TIMEZONE');
if ($tz) {
    date_default_timezone_set($tz);
}
// load URL helper
sfLoader::loadHelpers('Url');
sfConfig::set('sf_relative_url_root', sfConfig::get('app_general_base_url'));
$c = new Criteria();
$expiration_age = OptionPeer::retrieveOption('BUY_DELETE_AFTER') * 24 * 3600;
$c->add(TagPeer::VALID_UNTIL, time() - $expiration_age, Criteria::LESS_EQUAL);
$c->add(TagPeer::STATUS, TagPeer::ST_EXPIRED);
$c->add(TagPeer::IS_PRIMARY, false);
$tags = TagPeer::doSelect($c);
if ($tags) {
    foreach ($tags as $tag) {
        $interesteds = $tag->getInteresteds();
        $jotag = $tag->getJotag();
        $tag->deleteFromUser();
        Mailer::sendEmail($tag->getUser()->getPrimaryEmail(), 'deletedJotag', array('jotag' => $tag, 'jotag_name' => $jotag), $tag->getUser()->getPreferedLanguage());
        if ($interesteds) {
            foreach ($interesteds as $interested) {
                // notify interested users that this jotag is available again
                Mailer::sendEmail($interested->getUser()->getPrimaryEmail(), 'interestNotifyInterested', array('user' => $interested->getUser(), 'jotag' => $interested->getJotag()), $interested->getUser()->getPreferedLanguage());
            }
			<?php 
    } else {
        ?>
				<?php 
        echo __("Your credits was successfully redeemed. Your new JoTAG (%jotag%) is already available on your account", array("%jotag%" => $jotag->getJotag()));
        ?>
			<?php 
    }
    ?>
		</div>
		<?php 
    if ($user->canReceiveCredits()) {
        ?>
			<p align="center">
				<b><?php 
        echo __("Tell your friends about your personalized JoTAG and we will expand duration of your new JoTAG in %count% days for each friend that signs up!", array("%count%" => OptionPeer::retrieveOption('BONUS_ACCEPT_CREDIT') * OptionPeer::retrieveOption('BONUS_DAYS_PER_CREDIT')));
        ?>
</b><br/><br/>
				<?php 
        echo button_to(__('Invite friends'), '@invite');
        ?>
 <?php 
        echo button_to(__('Not now'), '@account');
        ?>
			</p>
		<?php 
    } else {
        ?>
			<p align="center"><?php 
        echo button_to(__('Return to My Account'), '@account');
        ?>
<?php

require_once dirname(__FILE__) . '/../config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
// initialize instance
sfContext::createInstance($configuration);
// set default TIMEZONE
$tz = OptionPeer::retrieveOption('TIMEZONE');
if ($tz) {
    date_default_timezone_set($tz);
}
$c = new Criteria();
$expiration_age = OptionPeer::retrieveOption('INVITE_AGE') * 24 * 3600;
$c->add(InvitePeer::CREATED_AT, time() - $expiration_age, Criteria::LESS_EQUAL);
InvitePeer::doDelete($c);
Dear <?php 
echo $owner;
?>
,
Your invite was accepted by <?php 
echo $user;
?>
!
<?php 
if ($credits) {
    ?>
You received <?php 
    echo $credits * OptionPeer::retrieveOption('BONUS_DAYS_PER_CREDIT');
    ?>
 free days in credits!
<?php 
}
<?php

require_once dirname(__FILE__) . '/../config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
// initialize instance
sfContext::createInstance($configuration);
// set default TIMEZONE
$tz = OptionPeer::retrieveOption('TIMEZONE');
if ($tz) {
    date_default_timezone_set($tz);
}
$c = new Criteria();
$expiration_age = OptionPeer::retrieveOption('BUY_NEW_ORDER_LIFETIME');
$c->add(PaymentPeer::CREATED_AT, time() - $expiration_age, Criteria::LESS_EQUAL);
$c->add(PaymentPeer::STATUS, PaymentPeer::ST_NEW);
$payments = PaymentPeer::doSelect($c);
if ($payments) {
    foreach ((array) $payments as $payment) {
        $payment->setStatus(PaymentPeer::ST_CANCELLED);
        $payment->save();
    }
}
echo __("Password");
?>
:</strong><span>*******</span><span class="actions"><?php 
echo link_to(__('change password'), '@password');
?>
</span></p>
						
				</div>
				<div class="section">
					<h2>Jotags</h2>
					
					<?php 
if ($user->getCredits()) {
    ?>
						<div class="notification"><?php 
    echo __("You have %count% days in credits to get a free JoTAG.", array("%count%" => $user->getCredits() * OptionPeer::retrieveOption('BONUS_DAYS_PER_CREDIT')));
    ?>
 <?php 
    echo link_to(__('Get it Now!'), '@buy');
    ?>
</div> 
					<?php 
}
?>

					<?php 
foreach ($user->getValidTags() as $jotag) {
    ?>
						<p>
							<strong><?php 
    echo esc_entities($jotag->getJotag());
Beispiel #11
0
<?php

if (@$email["first_name"] || @$email["last_name"]) {
    ?>
Dear <?php 
    echo trim($email["first_name"] . " " . $email["last_name"]);
    ?>
,<?php 
}
?>

You were invited joint JoTAG by your friend <?php 
echo $user;
?>
! Click the following link and complete your registration and receive <?php 
echo OptionPeer::retrieveOption('BONUS_INVITE_CREDIT') * OptionPeer::retrieveOption('BONUS_DAYS_PER_CREDIT');
?>
 free days to get a personalized JoTAG:
<?php 
echo url_for('@signup_invite?invite_id=' . $invite->getId(), true);
?>

<?php 
if ($invite->getInviteTagsJoinTag()) {
    ?>

<?php 
    echo $user;
    ?>
's JoTAGs:
<?php 
<p>Dear <?php 
echo $user;
?>
,</p>
<p>Welcome to JoTAG. Please confirm you account clicking on the following link:</p>
<p><?php 
echo link_to(url_for('@confirm_email?confirm_code=' . $email->getConfirmCode(), true), '@confirm_email?confirm_code=' . $email->getConfirmCode(), array("absolute" => true));
?>
</p>
<?php 
if ($user->getCredits()) {
    ?>
	<p>You have <?php 
    echo $user->getCredits() * OptionPeer::retrieveOption('BONUS_DAYS_PER_CREDIT');
    ?>
 free days to get a personalized JoTAG</p> 
<?php 
}
 public function executeIPN($request)
 {
     // rebuild post parameters to send back to paypal
     $req = "";
     foreach ($_POST as $var => $value) {
         $req .= "&{$var}=" . urlencode(stripslashes($value));
     }
     // get transaction info
     $paymentStatus = $request->getParameter('payment_status');
     $transNum = $request->getParameter('txn_id');
     $type = $request->getParameter('custom');
     $paymentId = $request->getParameter('invoice');
     $totalAmount = $request->getParameter('mc_gross');
     $test_ipn = $request->getParameter('test_ipn');
     if ($test_ipn && OptionPeer::retrieveOption('PAYPAL_MODE') == 'L') {
         die('fail');
     }
     // we are NOT in sandbox
     // send back to paypal
     $ch = @curl_init();
     @curl_setopt($ch, CURLOPT_POST, 1);
     @curl_setopt($ch, CURLOPT_URL, OptionPeer::retrieveOption('PAYPAL_MODE') != 'L' ? "https://www.sandbox.paypal.com/cgi-bin/webscr" : "https://www.paypal.com/cgi-bin/webscr");
     @curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=_notify-validate" . $req);
     @curl_setopt($ch, CURLOPT_TIMEOUT, 20);
     @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     $result = @curl_exec($ch);
     @curl_close($ch);
     if ($result != "VERIFIED") {
         //can't verify the POST information, most likely fraudulent so exit.
         die('fail');
     }
     // locate payment
     $payment = PaymentPeer::getFromField(PaymentPeer::ID, $paymentId);
     if (!$payment || !in_array($payment->getStatus(), array(PaymentPeer::ST_NEW, PaymentPeer::ST_PENDING))) {
         // tried to process an already paid order, or a cancelled one.. if not paid, alert
         // staff
         if ($payment && $payment->getStatus() != PaymentPeer::ST_PAID) {
             Mailer::sendEmail(OptionPeer::retrieveOption('ADMIN_EMAIL'), 'paymentError', array('payment' => $payment, 'reason' => 'CANCELLED'));
         }
         die('fail');
     }
     // check if transNum is UNIQUE
     $c = new Criteria();
     $c->add(PaymentPeer::REFERENCE, $transNum);
     $c->add(PaymentPeer::METHOD, PaymentPeer::PT_PAYPAL);
     $p = PaymentPeer::doSelectOne($c);
     if ($p && $p->getId() != $payment->getId()) {
         die('fail');
     }
     // duplicated transaction
     $payment->setMethod(PaymentPeer::PT_PAYPAL);
     $payment->setReference($transNum);
     //    if($type == "RENEW") $payment->setType(PaymentPeer::PT_RENEW);
     //    else $payment->setType(PaymentPeer::PT_NEW);
     switch ($paymentStatus) {
         case "Completed":
             // check if value matches
             if ((double) $payment->getAmount() != (double) $totalAmount) {
                 $payment->setStatus(PaymentPeer::ST_ERROR_NOTIFY);
                 $payment->save();
             } else {
                 if (!$payment->getTag()) {
                     $jotag = new Tag();
                     $jotag->setJotag($payment->getJotag());
                     $jotag->setStatus(TagPeer::ST_NEW);
                     $jotag->setUser($payment->getUser());
                     $jotag->setIsPrimary(false);
                 } else {
                     $jotag = $payment->getTag();
                 }
                 // calculate new expiration date
                 $jotag->setValidUntil($jotag->calcNewDate($payment->getDuration()));
                 // try to save new jotag
                 try {
                     $jotag->setStatus(TagPeer::ST_ACTIVE);
                     $jotag->save();
                 } catch (PropelException $e) {
                     // failed to save  jotag, probably due to duplicated jotag (race condition)
                     // we must mark it as ERROR and contact user
                     $payment->setStatus(PaymentPeer::ST_ERROR_NOTIFY);
                     $jotag = null;
                 }
                 if ($jotag) {
                     // everything OK
                     $payment->setTag($jotag);
                     $payment->setJotag('');
                     $payment->setStatus(PaymentPeer::ST_PAID);
                     // remove from interest list
                     $payment->getUser()->delInterest($jotag->getJotag());
                 }
                 $payment->save();
             }
             // send emails
             if ($payment->getStatus() == PaymentPeer::ST_PAID) {
                 // payment processed, notify customer
                 Mailer::sendEmail($payment->getUser()->getPrimaryEmail(), 'paymentConfirmation', array('payment' => $payment), $payment->getUser()->getPreferedLanguage());
             } else {
                 // payment processed, but there was an error creating/updating JoTAG, notify merchant
                 $reason = (double) $payment->getAmount() != (double) $totalAmount ? 'AMMOUNT' : 'DBERROR';
                 Mailer::sendEmail(OptionPeer::retrieveOption('ADMIN_EMAIL'), 'paymentError', array('payment' => $payment, 'reason' => $reason));
             }
             break;
         case "Pending":
             $payment->setStatus(PaymentPeer::ST_PENDING);
             $payment->save();
             break;
         case "Failed":
             $payment->setStatus(PaymentPeer::ST_FAILED);
             $payment->save();
             break;
     }
     return sfView::HEADER_ONLY;
 }
Beispiel #14
0
?>
</b></p>
		<?php 
if (TagPeer::isAvailable($search_jotag)) {
    ?>
			<?php 
    if ($sf_user->isAuthenticated()) {
        ?>
				<p><b><?php 
        echo __("This JoTAG can be yours! Just click <a href=\"%link%\">here</a> to get it for you.", array("%link%" => url_for('@buy_step2?jotag=' . $sf_request->getParameter('search'))));
        ?>
				<?php 
        if ($sf_user->getSubscriber()->getCredits()) {
            ?>
					<?php 
            echo __("You can have this JoTAG for %count% days for free.", array("%count%" => $sf_user->getSubscriber()->getCredits() * OptionPeer::retrieveOption('BONUS_DAYS_PER_CREDIT')));
            ?>
				<?php 
        } else {
            ?>
 
				<?php 
        }
        ?>
				</b></p>
			<?php 
    } else {
        ?>
				<p><b><?php 
        echo __("This JoTAG can be yours! Just click <a href=\"%link%\">here</a> to signup.", array("%link%" => url_for('@signup')));
        ?>
    ?>
 days.</p>
<p>Renew your JoTAG today, clicking <?php 
    echo link_to('here', url_for('@buy_step2?jotag=' . $jotag->getJotag(), true));
    ?>
</p>
<?php 
} else {
    ?>
<p>Your personalized JoTAG - <?php 
    echo $jotag->getJotag();
    ?>
 - expired <?php 
    echo abs($days);
    ?>
 ago.</p>
<p>Don't lose your JoTAG, click <?php 
    echo link_to('here', url_for('@buy_step2?jotag=' . $jotag->getJotag(), true));
    ?>
 to renew it now!</p>
<p>If you don't want to receive this email anymore, just click <?php 
    echo link_to('here', url_for('@cancel_jotag?jotag=' . $jotag->getJotag(), true));
    ?>
</p>
<br/>
<p><i>PS: You JoTAG will be made available to all users <?php 
    echo OptionPeer::retrieveOption('BUY_DELETE_AFTER');
    ?>
 days after expiration date!</i></p>
<?php 
}
sfLoader::loadHelpers('Url');
sfConfig::set('sf_relative_url_root', sfConfig::get('app_general_base_url'));
// set expired tags as EXPIRED
$con = Propel::getConnection(TagPeer::DATABASE_NAME);
try {
    $con->begin();
    $query = sprintf("UPDATE %s SET %s = %d WHERE %s <= ? AND %s = %d AND %s = 0", TagPeer::TABLE_NAME, TagPeer::STATUS, TagPeer::ST_EXPIRED, TagPeer::VALID_UNTIL, TagPeer::STATUS, TagPeer::ST_ACTIVE, TagPeer::IS_PRIMARY);
    $stmt = $con->prepareStatement($query);
    $stmt->setString(1, strftime("%Y-%m-%d 00:00:00"));
    $stmt->executeQuery();
    $con->commit();
} catch (Exception $e) {
    $con->rollback();
    throw $e;
}
$alert_days = explode(",", OptionPeer::retrieveOption('BUY_EXPIRE_ALERTS'));
$today = getdate();
foreach ($alert_days as $day) {
    // build range
    $start = strftime('%Y-%m-%d %H:%M:%S', mktime(0, 0, 0, $today['mon'], $today['mday'] + $day, $today['year']));
    $end = strftime('%Y-%m-%d %H:%M:%S', mktime(0, 0, 0, $today['mon'], $today['mday'] + $day + 1, $today['year']));
    // fetch jotags
    $c = new Criteria();
    $c->add(TagPeer::IS_PRIMARY, false);
    if ($day > 0) {
        $c->add(TagPeer::STATUS, TagPeer::ST_ACTIVE);
    } else {
        $c->add(TagPeer::STATUS, TagPeer::ST_EXPIRED);
    }
    $c->add(TagPeer::VALID_UNTIL, $start, Criteria::GREATER_EQUAL);
    $c->addAnd(TagPeer::VALID_UNTIL, $end, Criteria::LESS_THAN);
		  	</tr>
		    <tr>
		      <td colspan="2">
				<form id="frmSend2PayPal" action="<?php 
    if (OptionPeer::retrieveOption('PAYPAL_MODE') != 'L') {
        ?>
https://www.sandbox.paypal.com/cgi-bin/webscr<?php 
    } else {
        ?>
https://www.paypal.com/cgi-bin/webscr<?php 
    }
    ?>
" method="post" id="frmPaypal">
					<input type="hidden" name="cmd" value="_xclick" />
					<input type="hidden" name="business" value="<?php 
    echo OptionPeer::retrieveOption('PAYPAL_ACCOUNT');
    ?>
" />
					<?php 
    if ($jotag_object) {
        ?>
						<input type="hidden" name="custom" value="RENEW" />
						<input type="hidden" name="item_name" value="<?php 
        echo format_number_choice("[1]Personalized JoTAG - Extra %count% year|[1,+Inf]Personalized JoTAG - Extra %count% years", array("%count%" => $payment->getDuration()), $form["duration"]->getValue());
        ?>
 (<?php 
        echo $payment->getTag()->getJotag();
        ?>
)" />
					<?php 
    } else {
require_once dirname(__FILE__) . '/../config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
// initialize instance
sfContext::createInstance($configuration);
// set default TIMEZONE
$tz = OptionPeer::retrieveOption('TIMEZONE');
if ($tz) {
    date_default_timezone_set($tz);
}
// load URL helper
sfLoader::loadHelpers('Url');
sfConfig::set('sf_relative_url_root', sfConfig::get('app_general_base_url'));
// get last time it was executed
$last_run = OptionPeer::retrieveOption("NOTIFY_TAG_CHANGES_LAST_RUN");
$this_run = time();
OptionPeer::updateOption("NOTIFY_TAG_CHANGES_LAST_RUN", $this_run);
if (!$last_run) {
    exit;
}
// this is the very first time we run, just mark last run time
// convert to SQL standard
$last_run_sql = date('Y-m-d H:i:s', $last_run);
$this_run_sql = date('Y-m-d H:i:s', $this_run);
// get all changed info
$changed_objects = array();
foreach (ContactPeer::$CONTACT_CLASSES as $class) {
    // build criteria
    $c = new Criteria();
    $c->add(eval("return {$class}Peer::UPDATED_AT;"), $last_run_sql, Criteria::GREATER_THAN);
    $c->addAnd(eval("return {$class}Peer::UPDATED_AT;"), $this_run_sql, Criteria::LESS_EQUAL);
    $c->addAnd(BookmarkPeer::USER_ID, null, Criteria::ISNOTNULL);