/** * Method for testing creating a simple notification for the current user. */ public function actionGenerateManageSubscriptionHash() { if (!Group::isUserASuperAdministrator(Yii::app()->user->userModel)) { throw new NotSupportedException(); } $contact = RandomDataUtil::getRandomValueFromArray(Contact::getAll()); $personId = $contact->getClassId('Person'); $marketingList = RandomDataUtil::getRandomValueFromArray(MarketingList::getAll()); $marketingListId = $marketingList->id; $model = RandomDataUtil::getRandomValueFromArray(CampaignItem::getAll()); $modelId = $model->id; $modelType = get_class($model); $hash = GlobalMarketingFooterUtil::resolveHash($personId, $marketingListId, $modelId, $modelType, false); echo 'index.php/marketingLists/external/manageSubscriptions?hash=' . $hash; }
/** * @depends testOptOutAction */ public function testSubscribeActionAfterOptOutActionDisableOptOut() { $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); $marketingList = MarketingList::getByName('marketingList 04'); $this->assertNotEmpty($marketingList); $marketingList = $marketingList[0]; $marketingListId = $marketingList->id; $contact = Contact::getByName('contact 05 contact 05son'); $this->assertNotEmpty($contact); $contact = $contact[0]; $this->assertEquals(1, $contact->primaryEmail->optOut); $personId = $contact->getClassId('Person'); $member = MarketingListMember::getByMarketingListIdContactIdAndUnsubscribed($marketingList->id, $contact->id, 1); $this->assertNotEmpty($member); Yii::app()->user->userModel = null; $hash = GlobalMarketingFooterUtil::resolveHash($personId, $marketingListId, 1, 'AutoresponderItem', false); $this->setGetArray(array('hash' => $hash)); @$this->runControllerWithRedirectExceptionAndGetUrl($this->subscribeUrl); $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl); $this->assertContains('<td>marketingList 01</td>', $content); $this->assertContains('<td>marketingList 03</td>', $content); $this->assertContains('marketingLists/external/subscribe?hash=', $content); $this->assertContains('id="marketingListsManage' . 'SubscriptionListView-toggleUnsubscribed_', $content); $this->assertContains('id="marketingListsManage' . 'SubscriptionListView-toggleUnsubscribed_', $content); $this->assertContains('type="radio" name="marketingListsManage' . 'SubscriptionListView-toggleUnsubscribed_', $content); $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' . $marketingListId . '_0" checked="checked" type="radio" name="marketingListsManage' . 'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content); $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); $contact = Contact::getByName('contact 05 contact 05son'); $this->assertNotEmpty($contact); $contact = $contact[0]; $this->assertEquals(0, $contact->primaryEmail->optOut); }
public function testUnsubscribeActionToPublicMarketingListByGuestFromExternalController() { $personId = static::$contact->getClassId('Person'); Yii::app()->user->userModel = null; $hash = GlobalMarketingFooterUtil::resolveHash($personId, static::$marketingList->id, 0, 'AutoresponderItem', false); $this->setGetArray(array('hash' => $hash)); $content = $this->runControllerWithNoExceptionsAndGetContent($this->externalManageSubscriptionsUrl); $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' . static::$marketingList->id . '_0" checked="checked" type="radio" name="marketingListsManage' . 'SubscriptionListView-toggleUnsubscribed_' . static::$marketingList->id, $content); $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' . static::$marketingList->id . '_1" type="radio" name="marketingListsManage' . 'SubscriptionListView-toggleUnsubscribed_' . static::$marketingList->id, $content); @$this->runControllerWithRedirectExceptionAndGetUrl($this->externalUnsubscribeUrl); $content = $this->runControllerWithNoExceptionsAndGetContent($this->externalManageSubscriptionsUrl); $this->assertNotEmpty($content); $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' . static::$marketingList->id . '_0" type="radio" name="marketingListsManage' . 'SubscriptionListView-toggleUnsubscribed_' . static::$marketingList->id, $content); $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' . static::$marketingList->id . '_1" checked="checked" type="radio" name="marketingListsManage' . 'SubscriptionListView-toggleUnsubscribed_' . static::$marketingList->id, $content); $this->assertEquals(1, MarketingListMember::getCount()); }
protected function renderToggleSubscriptionSwitch($marketingListId, $subscribed) { $template = ZurmoHtml::tag('div', array('class' => 'switch-state clearfix'), '{input}{label}'); $createNewActivity = false; if ($marketingListId == $this->sourceMarketingListId) { $createNewActivity = true; } $hash = GlobalMarketingFooterUtil::resolveHash($this->personId, $marketingListId, $this->modelId, $this->modelType, $createNewActivity); $subscribeUrl = $this->getSubscribeUrlByHash($hash); $unsubscribeUrl = $this->getUnsubscribeUrlByHash($hash); $checkedValue = $subscribeUrl; if (!$subscribed) { $checkedValue = $unsubscribeUrl; } $baseId = static::TOGGLE_UNSUBSCRIPTION_LINK_CLASS . '_' . $marketingListId; $content = ZurmoHTML::radioButtonList($baseId, $checkedValue, self::getDropDownArray($subscribeUrl, $unsubscribeUrl), array('separator' => '', 'template' => $template)); return ZurmoHtml::tag('div', array('class' => 'switch'), $content); }