function __Construct($user, $dictionary)
 {
     parent::__Construct(get_class());
     $success = false;
     $message = '';
     $subscriptionId = null;
     if (HTTP::IsPost()) {
         $emailAddress = Params::Get('emailAddress');
         $listReference = Params::Get('listReference');
         $source = Params::Get('source', self::DEFAULT_SOURCE);
         if (!Util::ValidateEmail($emailAddress)) {
             $message = 'INVALID EMAIL ADDRESS';
         } else {
             //get list
             $emailList = EmailList::FromReference(Application::PARTNER_CODE, $listReference);
             if (is_null($emailList)) {
                 $message = "INVALID EMAIL LIST [" . $listReference . "]";
             } else {
                 $success = $emailList->subscribe($source, $emailAddress, $user->getId(), $dictionary->getCode(), $message);
             }
             //send welcome email
             if ($success) {
                 //load subscription back up for id
                 $subscription = Subscription::FromEmail($emailList->getId(), $emailAddress);
                 $subscriptionId = $subscription->getId();
                 //load template
                 if ($listReference == 'consumer') {
                     $templateRef = 'subscribe-consumer';
                 } else {
                     $templateRef = 'subscribe-provider';
                 }
                 //TODO: support multiple language emails (just need to deal with inheritance)
                 $template = EmsTemplate::FromReference(Application::PARTNER_CODE, $templateRef, 'EN');
                 //send email
                 Application::SendEmail($template->getFromEmailAddress(), $template->getFromName(), $template->getReplyToEmailAddress(), $emailAddress, $template->getSubject(), $template->getContent(), ContentType::HTML);
             }
         }
     } else {
         $message = "NO DATA POSTED";
     }
     //done
     $this->jsonData = array('success' => $success, 'subscriptionId' => $subscriptionId, 'message' => $message);
 }
示例#2
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      EmailList $value A EmailList object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(EmailList $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
示例#3
0
 /**
  * Declares an association between this object and a EmailList object.
  *
  * @param      EmailList $v
  * @return     EmailListPerson The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setEmailList(EmailList $v = null)
 {
     if ($v === null) {
         $this->setListId(NULL);
     } else {
         $this->setListId($v->getId());
     }
     $this->aEmailList = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the EmailList object, it will not be re-added.
     if ($v !== null) {
         $v->addEmailListPerson($this);
     }
     return $this;
 }
 * @author Artem Demchenkov <*****@*****.**>
 * @version 0.0.3
 *
 *
 *
 *
 * Result of choosing table and delimiter
 */
//var_dump($fromCsv);exit;
if ($error == 1) {
    // first error: Delimiter can not be empty
    echo "<span class='importCsvError'>" . Yii::t('importcsvModule.importcsv', 'Error') . ": " . Yii::t('importcsvModule.importcsv', 'Fields Delimiter can not be empty') . "</span>";
} elseif ($error == 0) {
    //making options width csv columns for $csvKey
    Yii::import('application.models.*');
    $conLists = EmailList::model()->findAll();
    //var_dump($conLists);exit;
    $lengthCsv = sizeof($fromCsv);
    $optionsContent4 = '<option value=\\"\\"></option>';
    for ($i = 0; $i < $lengthCsv; $i++) {
        $valOpt = $i + 1;
        $selected4 = $paramsArray['csvKey'] == $valOpt ? 'selected=\\"selected\\"' : '';
        $optionsContent4 = $optionsContent4 . '<option value=\\"' . $valOpt . '\\" ' . $selected4 . '>' . trim($fromCsv[$i]) . '</option>';
    }
    $optionsContent4 = trim($optionsContent4);
    //making options width table rows for $tableKey
    $length = sizeof($tableColumns);
    $optionsContent2 = '<option value=\\"\\"></option>';
    $optionsContent3 = '<option value=\\"\\"></option>';
    for ($i = 0; $i < $length; $i++) {
        $valOpt2 = $i + 1;