コード例 #1
0
 protected function getMenuItems()
 {
     $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'));
         return $items;
     }
     return null;
 }
コード例 #2
0
 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()
 {
     $marketingList = MarketingListTestHelper::createMarketingListByName('MarketingListName 01', 'MarketingListDescription 01');
     $this->runControllerShouldResultInAccessFailureAndGetContent('marketingLists/default');
     $this->runControllerShouldResultInAccessFailureAndGetContent('marketingLists/default/index');
     $this->runControllerShouldResultInAccessFailureAndGetContent('marketingLists/default/list');
     $this->runControllerShouldResultInAccessFailureAndGetContent('marketingLists/default/create');
     $this->setGetArray(array('id' => $marketingList->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('marketingLists/default/edit');
     $this->runControllerShouldResultInAccessFailureAndGetContent('marketingLists/default/details');
     $this->runControllerShouldResultInAccessFailureAndGetContent('marketingLists/default/getInfoToCopyToCampaign');
     $this->setGetArray(array('term' => 'inexistant'));
     $this->runControllerShouldResultInAccessFailureAndGetContent('marketingLists/default/autoComplete');
     $this->setGetArray(array('modalTransferInformation' => array('sourceIdFieldId' => 'Campaign_marketingList_id', 'sourceNameFieldId' => 'Campaign_marketingList_name', 'modalId' => 'modalContainer-edit-form')));
     $this->runControllerShouldResultInAccessFailureAndGetContent('marketingLists/default/modalList');
     $this->resetGetArray();
     $this->user->setRight('MarketingListsModule', MarketingListsModule::getAccessRight());
     $this->assertTrue($this->user->save());
     $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default');
     $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/index');
     $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/list');
     $this->setGetArray(array('term' => 'inexistant'));
     $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/autoComplete');
     $this->setGetArray(array('id' => $marketingList->id));
     $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/getInfoToCopyToCampaign');
     $this->setGetArray(array('modalTransferInformation' => array('sourceIdFieldId' => 'Campaign_marketingList_id', 'sourceNameFieldId' => 'Campaign_marketingList_name', 'modalId' => 'modalContainer-edit-form')));
     $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/modalList');
     $this->setGetArray(array('id' => $marketingList->id));
     $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/details');
     $this->assertContains('<p>To manage Marketing Lists you must have access to either contacts' . ' or leads. Contact the CRM administrator about this issue.</p>', $content);
     $this->resetGetArray();
     $this->user->setRight('MarketingListsModule', MarketingListsModule::getCreateRight());
     $this->assertTrue($this->user->save());
     $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/create');
     $this->assertContains('<p>To manage Marketing Lists you must have access to either contacts' . ' or leads. Contact the CRM administrator about this issue.</p>', $content);
     $this->user->setRight('ContactsModule', ContactsModule::getAccessRight());
     $this->user->setRight('LeadsModule', LeadsModule::getAccessRight());
     $this->assertTrue($this->user->save());
     $this->setGetArray(array('id' => $marketingList->id));
     $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/details');
     $this->assertNotContains('<p>To manage Marketing Lists you must have access to either contacts' . ' or leads. Contact the CRM administrator about this issue.</p>', $content);
     $this->resetGetArray();
     $this->user->setRight('MarketingListsModule', MarketingListsModule::getCreateRight());
     $this->assertTrue($this->user->save());
     $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/create');
     $this->assertNotContains('<p>To manage Marketing Lists you must have access to either contacts' . ' or leads. Contact the CRM administrator about this issue.</p>', $content);
     $this->setGetArray(array('id' => $marketingList->id));
     $this->runControllerWithNoExceptionsAndGetContent('marketingLists/default/edit');
     $this->user->setRight('MarketingListsModule', MarketingListsModule::getDeleteRight());
     $this->assertTrue($this->user->save());
     $this->runControllerWithRedirectExceptionAndGetUrl('marketingLists/default/delete');
     $this->setGetArray(array('id' => static::$listOwnedBySuper->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('marketingLists/default/edit');
     $this->runControllerShouldResultInAccessFailureAndGetContent('marketingLists/default/details');
     $this->runControllerShouldResultInAccessFailureAndGetContent('marketingLists/default/delete');
 }