public function actionDecline($id) { if (!($model = Invite::model()->findByPk($id)) || !in_array($model->status, [Invite::INVITE_CREATE, Invite::INVITE_ACCEPT])) { throw new CHttpException(404); } if ($model->status == Invite::INVITE_CREATE) { $mail = new YiiMailer(); $mail->setView('invite/decline'); $mail->setFrom(isset(Yii::app()->params->YiiMailer->Username) ? Yii::app()->params->YiiMailer->Username : Yii::app()->params->adminEmail, 'Система управления учебным расписанием'); $mail->setTo($model->email); $mail->setSubject('Заявка на создание'); $mail->send(); if (!$mail->send()) { Yii::app()->user->setFlash('error', 'Ошибка при отправке письма'); $this->redirect(['index']); } } $model->status = Invite::INVITE_DECLINE; if ($model->save()) { Yii::app()->user->setFlash('success', 'Заявка успешно отклонена'); } else { Yii::app()->user->setFlash('error', 'Ошибка при смене статуса'); } $this->redirect(['index']); }
/** * Activation user account */ public function actionActivation() { $email = $_GET['email']; $activkey = $_GET['activkey']; if ($email && $activkey) { $find = User::model()->notsafe()->findByAttributes(array('email' => $email)); if (isset($find) && $find->status) { $this->autoLogin($find->username); // update user_id in invite table Invite::model()->updateNewUser($find); // account already active Yii::app()->user->setFlash('success', 'Congratulations! Your account is now active. Please follow the directions below to set up your location.'); $this->redirect('/userlocation/locate'); // $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("Your account is active."))); } elseif (isset($find->activkey) && $find->activkey == $activkey) { $find->activkey = UserModule::encrypting(microtime()); $find->status = 1; $find->save(); $this->autoLogin($find->username); // direct to autolocate with activation message Yii::app()->user->setFlash('success', 'Congratulations! Your account is now active. Please follow the directions below to set up your location.'); $this->redirect('/userlocation/locate'); // $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("Your account is activated."))); } else { $this->render('/user/message', array('title' => UserModule::t("User activation"), 'content' => UserModule::t("Incorrect activation URL. Please email support@geogram.com if you need assistance."))); } } else { $this->render('/user/message', array('title' => UserModule::t("User activation"), 'content' => UserModule::t("Incorrect activation URL. Please email support@geogram.com if you need assistance."))); } }
public function safeUp() { $this->addColumn('{{invite}}', 'hash', 'varchar(32) DEFAULT NULL'); foreach (Invite::model()->findAll() as $invite) { $invite->setAttribute('hash', md5($invite->email . $invite->group_number . uniqid())); $invite->save(); } }
/** * Валидация инвайта при регистрации */ public function inviteCheck($attribute) { if (Invite::model()->count('invite=:invite', array(':invite' => $this->invite)) == 0) { $message = strtr('Данный {attribute} не существует', array('{attribute}' => $this->getAttributeLabel($attribute))); $this->addError($attribute, $message); } if (Invite::model()->count('invite=:invite AND id_user_used != 0', array(':invite' => $this->invite)) != 0) { $message = strtr('Данный {attribute} уже был использован', array('{attribute}' => $this->getAttributeLabel($attribute))); $this->addError($attribute, $message); } }
public function actionInvite($hash, $type = 1) { if (!in_array($type, [1, 2])) { throw new CHttpException(404, 'Данный тип не существует'); } if ($type == 1) { $invite = GroupInvite::model()->with('group')->findByAttributes(['status' => GroupInvite::INVITE_CREATE, 'hash' => $hash]); } elseif ($type == 2) { $invite = Invite::model()->findByAttributes(['status' => Invite::INVITE_ACCEPT, 'hash' => $hash]); } if (!isset($invite)) { throw new CHttpException(404, 'Данное приглашение не найдено или было отменено'); } $model = new Users(); if (Yii::app()->request->isPostRequest) { $user = Yii::app()->request->getParam('Users'); $model->setAttributes($user); $model->setAttributes(['email' => $invite->email, 'password' => md5($user['password'])]); if ($model->save()) { Yii::app()->authManager->assign('user', $model->id); $user_identity = new UserIdentity($model->username, $model->password); $user_identity->authenticate(); Yii::app()->user->login($user_identity, 60 * 60 * 24 * 7); switch ($type) { case 1: $invite->setAttribute('status', GroupInvite::INVITE_ACCEPT); $invite->save(); $group_member = new GroupMember(); $group_member->setAttributes(['group_id' => $invite->group_id, 'user_id' => $model->id]); $group_member->save(); break; case 2: $invite->setAttribute('status', Invite::INVITE_USED); $invite->save(false); $group = new Group(); $group->setAttributes(['number' => $invite->group_number, 'owner_id' => $model->id]); $group->save(); } $this->redirect(['site/dashboard']); } } $this->render('invite', ['model' => $model]); }
public function removeDupes() { $Invites = $this->getDupeInvites(); if (sizeof($Invites)) { print 'Found ' . count($Invites) . ' to delete' . "\n"; foreach ($Invites as $inviteArray) { $Invite = Invite::model()->findByPk($inviteArray['id']); if (is_null($Invite)) { print 'ERROR - Invite ' . $inviteArray['id'] . ' not found' . "\n"; } else { $Invite->delete(); $this->totalInvitesDeleted++; } } $this->loopCount++; $this->removeDupes(); // recurse } }
public function removeDupes() { $Invites = $this->getDupeInvites(); if (sizeof($Invites)) { print 'Found ' . count($Invites) . ' to delete' . "\n"; foreach ($Invites as $inviteArray) { $Invite = Invite::model()->findByPk($inviteArray['id']); if (is_null($Invite)) { print 'ERROR - Invite ' . $inviteArray['id'] . ' not found' . "\n"; } else { print 'Invite to delete: ' . $Invite->id . "\n"; // Only delete invites from campaigns that have not been sent if (in_array($inviteArray['campaignStatus'], array(Campaign::STATUS_NOT_RUN, Campaign::STATUS_QUEUED))) { // Also make sure we don't delete Invites that have been sent if ($Invite->status == Invite::STATUS_UNSENT) { $Invite->delete(); $this->totalInvitesDeleted++; } } } } } }
public function actionInviteUnsubscribe() { // campaign_id -> used to send the invite // campaign_hash -> used to check the id isn't manipulated // invite_id -> use to store the invite row // invite_hash_partial -> used to store the first 8 characters of the much longer 40 char invite hash // match the invite to a contact? $Invite = Invite::model()->find(array('condition' => 'id = :invite_id AND SUBSTR(hash,1,8) = :invite_hash_partial', 'params' => array(':invite_id' => $_GET['invite_id'], ':invite_hash_partial' => $_GET['invite_hash_partial']))); // matches an invite if (is_null($Invite) || ($Invite->campaign->id !== $_GET['campaign_id'] || $Invite->campaign->hash !== $_GET['campaign_hash'])) { $this->layout = 'vanilla'; $this->pageTitle = '404 not found'; $this->render('unsubscribed', array('title' => 'We couldn\'t find that.', 'message' => 'We weren\'t able to find the page you were looking for. Sorry about that.')); Yii::app()->end(); } $Store2Contact = Store2Contact::model()->with(array('store' => array('with' => array('organisation'))))->findByPk($Invite->store2contact_id); if (is_null($Store2Contact)) { $this->layout = 'vanilla'; $this->pageTitle = '404 not found'; $this->render('unsubscribed', array('title' => 'We couldn\'t find that.', 'message' => 'We weren\'t able to find the page you were looking for. Sorry about that.')); Yii::app()->end(); } // check for existing suppression row. Should only be one row per campaign $SuppressionList = SuppressionList::model()->findByAttributes(array('store2contact_id' => $Store2Contact->id, 'campaign_id' => $Invite->campaign_id)); // add a suppression row if (is_null($SuppressionList)) { $NewSuppressionList = new SuppressionList(); // Warehouse ID is null because we only want to supress from this single org... $NewSuppressionList->warehouse_id = null; // ... which represented by a single Store row $NewSuppressionList->store_id = $Store2Contact->store_id; $NewSuppressionList->store2contact_id = $Store2Contact->id; $NewSuppressionList->campaign_id = $Invite->campaign_id; $NewSuppressionList->type = SuppressionList::TYPE_UNSUBSCRIBE; if (!$NewSuppressionList->save()) { var_dump($NewSuppressionList->errors); exit; } } // show the success message page $this->layout = 'vanilla'; $this->pageTitle = 'You have been unsubscribed'; $this->render('unsubscribed', array('title' => 'You\'ve unsubscribed successfully.', 'message' => 'We\'re registered your unsubscribe request. You may still receive already queued email correspondance from ' . $Store2Contact->store->organisation->title . '.')); Yii::app()->end(); }
public function run($args) { exit('Use no.2 command'); ini_set('memory_limit', '4G'); $start = microtime(true); print "\n\n"; print 'Running email de-duperer' . "\n\n"; sleep(1); $QueuedCampaigns = Campaign::model()->findAll(array("condition" => "processing = 0 AND status = :status", "params" => array(":status" => Campaign::STATUS_QUEUED))); $totalInvitesDeleted = 0; $invitesDeleted = []; print sizeof($QueuedCampaigns) . ' campaigns to process' . "\n\n"; foreach ($QueuedCampaigns as $QueuedCampaign) { print 'Looking up Campaign ' . $QueuedCampaign->id . "...\n"; $Invites = Invite::model()->with('store')->findAll(array('condition' => 'query_id != :qid', 'params' => array(':qid' => $QueuedCampaign->query_id))); $previouslyInvited = array(); print 'Building invite array...' . "\n"; foreach ($Invites as $k => $Invite) { $previouslyInvited[] = $Invite->store->email; if ($k % 1000 == 0) { print '.'; } } unset($Invites); sleep(1); print " DONE!\n\n"; sleep(1); print sizeof($previouslyInvited) . ' previously invited contacts' . "\n"; // Dupecheck this campaign $results = Invite::model()->with("store")->findAll(array('condition' => 'campaign_id = :campaign_id', 'params' => array(':campaign_id' => $QueuedCampaign->id))); print sizeof($results) . ' contacts in this invite campaign' . "\n"; $emails = []; if (sizeof($results)) { foreach ($results as $Invite) { $emails[$Invite->id] = $Invite->store->email; } } unset($results); // LOCAL DUPES /* print 'Finding duplicates within this campaign' . "\n"; sleep(1); $arrayCountValues = array_count_values($emails); $localDuplicates = 0; foreach($arrayCountValues as $arrayCount) { if($arrayCount > 1) { $localDuplicates++; } } print 'Duplicates local to this campaign: ' . $localDuplicates . "\n\n"; */ // Global dupes print 'Finding duplicates in entire invite set' . "\n"; $arrayIntersect = array_intersect($emails, $previouslyInvited); unset($previouslyInvited); print 'Dupes found: ' . sizeof($arrayIntersect) . "\n"; foreach ($arrayIntersect as $inviteID => $dupeEmail) { //print 'Deleting duplicate Invite ID: ' . $inviteID . ' for ' . $dupeEmail . "\n"; // $InviteToDelete = Invite::model()->findByPk($inviteID); // $InviteToDelete->delete(); if (!in_array($inviteID, $invitesDeleted)) { $totalInvitesDeleted++; $invitesDeleted[] = $inviteID; } } print "\n\n\n"; print 'COMPLETE' . "\n"; print "\n\n\n"; unset($emails); unset($arrayIntersect); } print 'Total invites deleted: ' . $totalInvitesDeleted . "\n\n"; $RemainingInvites = Invite::model()->count(array('condition' => "date > '2015-01-01' AND status = 0")); print 'Invites remaining to be sent: ' . $RemainingInvites . "\n\n"; print 'Peak memory usage: ' . memory_get_peak_usage(true) / 1024 / 1024 . "MB\n\n\n"; $end = microtime(true); print 'Script ran in ' . round($end - $start, 4) . ' seconds' . "\n\n"; // Alternate with SQL $Invites = Yii::app()->db->createCommand("\n\t\t\n\t\tSELECT i.id, s.email, count(s.email) AS c FROM invite i\n\n\t\tLEFT JOIN store s ON i.store_id = s.id\n\t\t\n\t\tWHERE i.date > '2015-01-01'\n\t\t\n\t\tGROUP BY s.email HAVING c > 1\n\t\t\n\t\t")->queryAll(); print 'Invites to remove using SQL query: ' . sizeof($Invites) . "\n\n"; }
public function actionEdit() { if ((int) $_GET['campaign_id']) { // existing sent invite $Campaign = Campaign::model()->findByPk($_GET['campaign_id']); if (is_null($Campaign)) { throw new CHttpException(404, 'Not found'); } $Query = $Campaign->query; } else { throw new CHttpException(404, 'Page not found.'); } if ((int) $Campaign->status !== Campaign::STATUS_NOT_RUN) { // Redirect to view $this->redirect(array('invite/view', 'campaign_id' => $Campaign->id)); exit; } if (isset($_POST['delete'])) { // Delete all invite rows which match this campaign $InviteRows = Invite::model()->findAll(array('condition' => 'campaign_id = :cid AND status = :status', 'params' => array(':cid' => $Campaign->id, ':status' => Invite::STATUS_UNSENT))); foreach ($InviteRows as $InviteRow) { $InviteRow->delete(); } // Now delete the query and campaign $Campaign->query->delete(); $Campaign->delete(); $this->redirect(array('invite/index')); } // Set scenario for validation $Campaign->scenario = 'inviteEdit'; if (isset($_POST['Campaign'])) { // Mass assign the form values to the Campaign Object. $Campaign->attributes = $_POST['Campaign']; if ($Campaign->save()) { Yii::app()->user->setFlash('success', 'Invite ' . $Campaign->name . ' email content saved'); $this->refresh(); } } $this->breadcrumbs = array('Invites' => array('index'), $Campaign->name); $this->render('invite', array('Campaign' => $Campaign, 'Query' => $Query, 'results' => $results)); }
public function send($Campaign) { //exit(); $configs = Yii::app()->db->createCommand("SELECT * FROM `config` WHERE `key` IN ('host', 'https')")->queryAll(); if (sizeof($configs) < 2) { throw new CException("\n\n\n===\nDomain or HTTPS config not yet set. View any admin area page in a browser to remedy this.\n===\n\n"); } foreach ($configs as $config) { $params[$config['key']] = $config['value']; } // Load contacts for this invite from the invite table // They'll be marked with this campaign ID, and status=0 - unsent $Invite = Invite::model(); $transaction = $Invite->dbConnection->beginTransaction(); try { $InviteRows = $Invite->with("store")->findAll(array("condition" => "campaign_id = :campaign_id AND processing = 0 AND status = :status", "params" => array(":campaign_id" => $Campaign->id, ":status" => Invite::STATUS_UNSENT))); $inviteIDs = []; foreach ($InviteRows as $Invite) { $inviteIDs[] = $Invite->id; } $command = Yii::app()->db->createCommand(); $command->update('invite', array("processing" => 1), array('in', 'id', $inviteIDs)); $transaction->commit(); } catch (Exception $e) { $transaction->rollback(); throw $e; } set_time_limit(0); // Load all organisations, we'll need their info $Organisations = Organisation::model()->findAll(array('condition' => 'id IN (1,2,3,4,5,6,7,8,9)', 'index' => 'id')); // Group by organisation $orgContacts = array(); foreach ($InviteRows as $Invite) { $orgContacts[$Invite->organisation_id][] = $Invite; } // Chunk these into arrays of up to 1000 contacts per organisation - this is the Mailgun limit $chunkedOrgContacts = array(); foreach ($orgContacts as $orgID => $contactArray) { $chunkedOrgContacts[$orgID] = array_chunk($orgContacts[$orgID], 1000); } // Parse the email content, replace tags with the Mailgun recipient params $parsedContent = $this->parseEmailContent($Campaign->invite_email_subject, $Campaign->invite_email_body, array('first_name' => '%recipient.first_name%', 'last_name' => '%recipient.last_name%', 'invite_url' => '%recipient.invite_url%', 'unsubscribe_url' => '%recipient.unsubscribe_url%')); // Debug / counter vars $sentCount = 0; $campaignSuccess = false; $toEmails = []; Yii::import('application.extensions.*'); foreach ($chunkedOrgContacts as $orgID => $orgChunks) { // Only set real email info if we're on production server // Let's not send emails to everyone in Newcastle before we're live... if (ENVIRONMENT === 'PRODUCTION' || ENVIRONMENT === 'PHOENIX') { // Get the correct email domain for the organisation in question $fromEmailDomain = $Organisations[$orgID]->email_domain; $fromEmailAddress = $Organisations[$orgID]->email_address; $fromEmailName = $Organisations[$orgID]->title; } else { $fromEmailDomain = Yii::app()->params['insiderEmailDomain']; $fromEmailAddress = 'email@' . $fromEmailDomain; $fromEmailName = $Organisations[$orgID]->title; } $mailgunApi = new MailgunApi($fromEmailDomain, Yii::app()->params['mailgun']['key']); $message = $mailgunApi->newMessage(); $message->setFrom($fromEmailAddress, $fromEmailName); $message->setSubject($parsedContent['subject']); $message->addTag('Invite'); // Tag with invite so it can be filtered in Mailgun admin if (ENVIRONMENT !== 'PRODUCTION') { $message->addTag('Test'); } /* TEST MODE */ //$message->enableTestMode(); // Now loop the contacts, which are in chunks (arrays) of up to 1000 foreach ($orgChunks as $upTo1000Invites) { //start transaction? try { $transaction = $Invite->dbConnection->beginTransaction(); $invite1000IDs = []; //reset the to fields $message->resetTo(); // Add all the contacts in this chunk, there could be up to 1000 of 'em foreach ($upTo1000Invites as $Invite) { $invite1000IDs[] = $Invite->id; if (strlen($Invite->store->email)) { $Store2Contact = Store2Contact::model()->findByPk($Invite->store2contact_id); if (!is_null($Store2Contact)) { // Check values match if ($Store2Contact->contact_warehouse_id === $Invite->contact_warehouse_id && $Store2Contact->store_id === $Invite->store_id) { // Also save the date they were invited to Store2Contact so we can query it easily $Store2Contact->most_recent_invite_date = date('Y-m-d H:i:s'); $Store2Contact->save(true, array('most_recent_invite_date')); unset($Store2Contact); // Now create the invitation link to pass into the email template $inviteURL = ($params['https'] === 1 ? 'https://' : 'http://') . $params['host'] . '/accession/invite/' . $Invite->hash; // Only set real email info if we're on production server // Let's not send emails to everyone in Newcastle before we're live... if (ENVIRONMENT === 'PRODUCTION') { $toEmail = $Invite->store->email; } else { $toEmail = '*****@*****.**'; } $unsubscribeUrl = $Invite->unsubscribeUrl; // Check first name $firstName = $Invite->store->first_name; if (!strlen(trim($firstName))) { $firstName = 'friend'; } // Add the recipient to the message object, including the params unique for them $message->addTo($toEmail, $Invite->store->first_name . ' ' . $Invite->store->last_name, array('first_name' => $firstName, 'last_name' => $Invite->store->last_name, 'invite_url' => $inviteURL, 'unsubscribe_url' => $unsubscribeUrl)); //$toEmails[] = 'Email: ' . $toEmail . " - " . $contact['first_name'] . ' ' . $lastName . '('.$fromEmailName.')' . "\n\n"; // Increment the counter $sentCount++; } else { $contactInfo = print_r($contact, true); mail('*****@*****.**', 'Invite attempted but store2contact row did not match contact found in query', $contactInfo); } } else { $contactInfo = print_r($contact, true); mail('*****@*****.**', 'Invite attempted but store2contact could not be found', $contactInfo); } } else { $contactInfo = print_r($contact, true); mail('*****@*****.**', 'Invite attempted with no email address', $contactInfo); } } // foreach upTo1000Invites } catch (Exception $e) { $transaction->rollback(); $campaignSuccess = false; } // Now we have the data for our 1000 contacts set up, render the template for the organisation $Controller = new Controller('foo'); $renderedView = $Controller->renderInternal(Yii::app()->basePath . '/views/mail/organisation-templates/' . $Organisations[$orgID]->email_template . ".php", array('body' => $parsedContent['body']), true); $message->setHtml($renderedView); // SEND THE MESSAGE if (sizeof($message->getTo())) { try { $response = $message->send(); $command = Yii::app()->db->createCommand(); $command->update('invite', array("status" => Invite::STATUS_SENT, "processing" => 0), array('in', 'id', $invite1000IDs)); $transaction->commit(); $campaignSuccess = true; } catch (Exception $e) { print $e->getMessage(); // mailgun returned an error - we rollback the transaction and remove the number of failed ids from the sent count // consider mainatining a fail count?? $sentCount -= count($invite1000IDs); $command = Yii::app()->db->createCommand(); $command->update('invite', array("status" => Invite::STATUS_MAILGUN_ERROR, "processing" => 0), array('in', 'id', $invite1000IDs)); $transaction->commit(); $msg = print_r($e, true); $msg .= print_r($message, true); mail('*****@*****.**', 'Mailgun error', $msg); } } } // end of org 1000 chunk } // foreach organisations if ($campaignSuccess) { $Campaign->status = Campaign::STATUS_HAS_BEEN_RUN; } else { $Campaign->status = Campaign::STATUS_ERROR_SEND; } $Campaign->save(true, array("status")); }
public function actionStepOne() { $this->inAccession = true; // Have we arrived here with an accession hash, allowing us to track this contact through accession? if (isset($_GET['accessionhash'])) { $Accession = $this->getAccessionRecord(); $this->checkStep($Accession, 1); } else { $Accession = new Accession(); $Accession->step = 1; } $this->pageTitle = 'Welcome to ' . Yii::app()->name . ' | Step One | Accession'; if (isset($_POST['Accession'])) { if ($_POST['Accession']['terms_agreed'] === '1') { // Accession hash will be null if they've signed up from the public link if (is_null($Accession->accession_hash)) { $Accession->accession_hash = sha1(rand(1, 99999) . microtime(true)); } // TERMS ARE AGREED! We're good to go. Set up all the models $Accession->terms_agreed = date('Y-m-d H:i:s'); if (!$Accession->save()) { print_r($Accession->errors); exit; } // Now they've agreed terms, update the invite (if they had one) if ($Accession->invite_id) { $Invite = Invite::model()->findByPk($Accession->invite_id); if (!is_null($Invite)) { $Invite->status = Invite::STATUS_ACCEPTED; $Invite->save(true, array('status')); } } $new = false; // If it's a new contact coming to the list, we just have a blank row // If they've come via an invite then we copy their Store row if (is_null($Accession->original_store2contact_id)) { // This contact is new $Store = new Store(); // Create a new warehouse row $Warehouse = new Warehouse(); $Warehouse->save(); // Set the warehouse id to the accession model $Accession->warehouse_id = $Warehouse->id; $Accession->save(true, array('warehouse_id')); $new = true; } else { // This contact came from an invite // Grab their previous data $Store2Contact = Store2Contact::model()->findByPk($Accession->original_store2contact_id); // Get the contact's warehouse_id - this identifies them uniquely, even if they have multiple instances in Store $Warehouse = Warehouse::model()->findByPk($Store2Contact->contact_warehouse_id); $ExistingStore = Store::model()->findByPk($Store2Contact->store_id); // Now make a new store to duplicate their info to $Store = new Store(); $Store->attributes = $ExistingStore->attributes; $Store->id = null; } // Set the org ID to THE LIST $Store->origin_organisation_id = 10; // Try to save the Store if (!$Store->save()) { print 'Store errors:<br>'; print_r($Store->errors); exit; } // Also create a new Store2Contact row $Store2Contact = new Store2Contact(); $Store2Contact->store_id = $Store->id; $Store2Contact->contact_warehouse_id = $Warehouse->id; $Store2Contact->origin_id = 10; if (!$Store2Contact->save()) { print 'Store2Contact errors:<br>'; print_r($Store2Contact->errors); exit; } // Now also save the new Store2Contact ID to Accession $Accession->store2contact_id = $Store2Contact->id; if ($new) { $Accession->original_store2contact_id = $Store2Contact->id; } } if ($Accession->save(true, array('terms_agreed', 'store2contact_id', 'original_store2contact_id'))) { $this->updateStep($Accession, 1); $this->redirect(array('accession/stepTwo', 'accessionhash' => $Accession->accession_hash)); } } $this->render('step1', array('Accession' => $Accession, 'progress' => 1)); }
</em></h1> </div> <?php $this->renderPartial('_tabs_before_send', array('Campaign' => $Campaign)); ?> <?php if (sizeof($results) > 1000) { ?> <div class="alert alert-danger">This invite has over 1000 recipients so they cannot be displayed here.</div> <?php } else { $Invites = Invite::model()->with('store')->findAll(array('condition' => 'query_id != :qid', 'params' => array(':qid' => $Campaign->query_id))); $previouslyInvited = array(); foreach ($Invites as $Invite) { $previouslyInvited[$Invite->id] = $Invite->store->email; } // Dupecheck $emails = []; if (sizeof($results)) { foreach ($results as $Invite) { $emails[$Invite->id] = $Invite->store->email; } } $arrayIntersect = array_intersect($emails, $previouslyInvited); foreach ($arrayIntersect as $inviteID => $email) { if ($inviteID == 58418) { foreach ($previouslyInvited as $previousInviteID => $previouslyInvitedContact) {
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Invite the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Invite::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }