public function getMenuItems()
 {
     $items = array();
     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_WORKFLOW)));
         return $items;
     }
     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');
 }
 public function render()
 {
     $items = array();
     if (RightsUtil::doesUserHaveAllowByRightName('WorkflowsModule', WorkflowsModule::getCreateRight(), Yii::app()->user->userModel)) {
         $items[] = array('label' => Zurmo::t('WorkflowsModule', 'Create Workflow'), 'url' => Yii::app()->createUrl('workflows/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_WORKFLOW)));
     }
     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' => 'MashableInboxCreateDropdown'), 'items' => array($menuItems)));
         $cClipWidget->endClip();
         return $cClipWidget->getController()->clips['ActionMenu'];
     }
     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()
 {
     $emailTemplate = EmailTemplateTestHelper::createEmailTemplateByName(EmailTemplate::TYPE_CONTACT, 'Test Subject Regular 01', 'Contact', 'Test Name Regular 01', 'Test HtmlContent Regular 01', 'Test TextContent Regular 01');
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default');
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/index');
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/listForMarketing');
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/listForWorkflow');
     $this->setGetArray(array('type' => EmailTemplate::TYPE_CONTACT));
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/create');
     $this->setGetArray(array('id' => $emailTemplate->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/edit');
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/details');
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/delete');
     $this->resetGetArray();
     $this->user->setRight('EmailTemplatesModule', EmailTemplatesModule::getAccessRight());
     $this->assertTrue($this->user->save());
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default');
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/index');
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/listForMarketing');
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/listForWorkflow');
     $this->setGetArray(array('id' => $emailTemplate->id));
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/details');
     $this->resetGetArray();
     $this->user->setRight('EmailTemplatesModule', EmailTemplatesModule::getCreateRight());
     $this->assertTrue($this->user->save());
     $this->setGetArray(array('type' => EmailTemplate::TYPE_CONTACT));
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/create');
     $this->setGetArray(array('type' => EmailTemplate::TYPE_WORKFLOW));
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/create');
     $this->setGetArray(array('id' => $emailTemplate->id));
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/edit');
     $this->user->setRight('EmailTemplatesModule', EmailTemplatesModule::getDeleteRight());
     $this->assertTrue($this->user->save());
     $this->runControllerWithRedirectExceptionAndGetUrl('emailTemplates/default/delete');
     $this->setGetArray(array('id' => static::$templateOwnedBySuper->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/edit');
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/details');
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/delete');
 }
 protected function resolveConfirmAlertInHtmlOptions($htmlOptions)
 {
     $htmlOptions['confirm'] = Zurmo::t('Default', 'Are you sure you want to delete this {modelLabel}?', array('{modelLabel}' => EmailTemplatesModule::getModuleLabelByTypeAndLanguage('SingularLowerCase')));
     return $htmlOptions;
 }