Exemple #1
0
 /**
  * @param string $moderationName
  *
  * @param string $contentName
  * @param int    $contentId
  *
  * @return \Illuminate\View\View
  */
 public function renderModerationButton($moderationName, $contentName, $contentId)
 {
     $moderation = $this->moderationRegistry->get($moderationName);
     if ($moderation && $this->permissionChecker->hasPermission('user', null, $moderation->getPermissionName())) {
         return view('partials.moderation.moderation_button', ['moderation' => $moderation, 'content_name' => $contentName, 'content_id' => $contentId]);
     }
 }
Exemple #2
0
 /**
  * @return \MyBB\Core\Moderation\ModerationInterface[]
  */
 public function moderations()
 {
     $moderations = $this->moderations->getForContent(new Post());
     $decorated = [];
     $presenter = $this->app->make('autopresenter');
     foreach ($moderations as $moderation) {
         $decorated[] = $presenter->decorate($moderation);
     }
     return $decorated;
 }
 /**
  * @return string
  */
 public function description()
 {
     $moderation = $this->moderationRegistry->get($this->getWrappedObject()->moderation);
     $moderation = $this->presenterDecorator->decorate($moderation);
     $content = $this->getContentForSubjects($this->getWrappedObject()->subjects()->get()->all());
     if ($this->getWrappedObject()->is_reverse) {
         $description = $moderation->reverseDescribe($content, $this->getSourceFromLog($this->getWrappedObject()), $this->getDestinationFromLog($this->getWrappedObject()));
     } else {
         $description = $moderation->describe($content, $this->getSourceFromLog($this->getWrappedObject()), $this->getDestinationFromLog($this->getWrappedObject()));
     }
     return $this->getUserProfileLink($this->getWrappedObject()->user) . ' ' . $description;
 }
 public function testGetForContentReturnsSomeForSomeSupportedContent()
 {
     $moderation1 = Mockery::mock('MyBB\\Core\\Moderation\\ModerationInterface');
     $moderation1->shouldReceive('getKey')->withNoArgs()->andReturn('key1');
     $moderation1->shouldReceive('visible')->with('content')->andReturn(true);
     $moderation2 = Mockery::mock('MyBB\\Core\\Moderation\\ModerationInterface');
     $moderation2->shouldReceive('getKey')->withNoArgs()->andReturn('key2');
     $moderation2->shouldReceive('visible')->with('content')->andReturn(false);
     $registry = new ModerationRegistry();
     $registry->addModeration($moderation1);
     $registry->addModeration($moderation2);
     $moderations = $registry->getForContent('content');
     static::assertCount(1, $moderations);
     static::assertContains($moderation1, $moderations);
 }
 /**
  * @param string $name
  *
  * @return ModerationInterface
  */
 public function getModerationByName($name)
 {
     return $this->moderationRegistry->get($name);
 }