protected function getMenuItems() { $items = array(); if (RightsUtil::doesUserHaveAllowByRightName('CampaignsModule', CampaignsModule::getCreateRight(), Yii::app()->user->userModel)) { $items[] = array('label' => Zurmo::t('CampaignsModule', 'Create Campaign'), 'url' => Yii::app()->createUrl('campaigns/default/create')); return $items; } return null; }
public function render() { $items = array(); if (RightsUtil::doesUserHaveAllowByRightName('MarketingListsModule', MarketingListsModule::getCreateRight(), Yii::app()->user->userModel)) { $items[] = array('label' => Zurmo::t('MarketingListsModule', 'Create List'), 'url' => Yii::app()->createUrl('marketingLists/default/create')); } if (RightsUtil::doesUserHaveAllowByRightName('EmailTemplatesModule', EmailTemplatesModule::getCreateRight(), Yii::app()->user->userModel)) { $items[] = array('label' => Zurmo::t('EmailTemplatesModule', 'Create Template'), 'url' => Yii::app()->createUrl('emailTemplates/default/create', array('type' => EmailTemplate::TYPE_CONTACT))); } if (RightsUtil::doesUserHaveAllowByRightName('CampaignsModule', CampaignsModule::getCreateRight(), Yii::app()->user->userModel)) { $items[] = array('label' => Zurmo::t('CampaignsModule', 'Create Campaign'), 'url' => Yii::app()->createUrl('campaigns/default/create')); } if (!empty($items)) { $menuItems = array('label' => $this->getLabel(), 'url' => null, 'items' => $items); $cClipWidget = new CClipWidget(); $cClipWidget->beginClip("ActionMenu"); $cClipWidget->widget('application.core.widgets.MbMenu', array('htmlOptions' => array('id' => get_class($this)), 'items' => array($menuItems))); $cClipWidget->endClip(); return $cClipWidget->getController()->clips['ActionMenu']; } return null; }
public function testRegularUserAllDefaultControllerActions() { MarketingListTestHelper::createMarketingListByName('MarketingListName02', 'MarketingList Description', 'first', '*****@*****.**'); $campaign = CampaignTestHelper::createCampaign('campaign02', 'campaign subject 02', 'text content for campaign 02', 'html content for campaign 02', 'fromCampaign', '*****@*****.**'); $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default'); $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/index'); $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/list'); $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/create'); $this->setGetArray(array('id' => $campaign->id)); $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/edit'); $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/details'); $this->resetGetArray(); $this->user->setRight('CampaignsModule', CampaignsModule::getAccessRight()); $this->assertTrue($this->user->save()); $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default'); $this->assertContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content); $this->user->setRight('MarketingListsModule', MarketingListsModule::getAccessRight()); $this->user->setRight('EmailTemplatesModule', EmailTemplatesModule::getAccessRight()); $this->assertTrue($this->user->save()); $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default'); $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content); $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/index'); $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content); $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list'); $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content); $this->setGetArray(array('id' => $campaign->id)); $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/details'); $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content); $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/details'); $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content); $this->resetGetArray(); $this->user->setRight('CampaignsModule', CampaignsModule::getCreateRight()); $this->assertTrue($this->user->save()); $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/create'); $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content); $this->setGetArray(array('id' => $campaign->id)); $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/details'); $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content); $this->resetGetArray(); $this->user->setRight('CampaignsModule', CampaignsModule::getCreateRight()); $this->assertTrue($this->user->save()); $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/create'); $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content); $this->setGetArray(array('id' => $campaign->id)); $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/edit'); $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content); $this->user->setRight('CampaignsModule', CampaignsModule::getDeleteRight()); $this->assertTrue($this->user->save()); $this->runControllerWithRedirectExceptionAndGetUrl('campaigns/default/delete'); $this->setGetArray(array('id' => static::$campaignOwnedBySuper->id)); $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/edit'); $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/details'); $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/delete'); }