@Route(
"/{forum}/category",
name="claro_forum_categories",
defaults={"page"=1}
)
@Template("ClarolineForumBundle::index.html.twig")

@param Forum $forum
@param User $user
547311
public function openAction(Forum $forum)
    {
        $em = $this->getDoctrine()->getManager();
        $this->checkAccess($forum);
        $categories = $em->getRepository('ClarolineForumBundle:Forum')->findCategories($forum);
        $user = $this->tokenStorage->getToken()->getUser();
        $hasSubscribed = $user === 'anon.' ?
            false :
            $this->manager->hasSubscribed($user, $forum);
        $isModerator = $this->authorization->isGranted(
            'moderate',
            new ResourceCollection(array($forum->getResourceNode()))
        ) && $user !== 'anon.';

        return array(
            'search' => null,
            '_resource' => $forum,
            'isModerator' => $isModerator,
            'categories' => $categories,
            'hasSubscribed' => $hasSubscribed,
            'workspace' => $forum->getResourceNode()->getWorkspace()
        );
    }
1337051
private function get_exported_discussion(stdClass $user) : array {
        $discussionexporter = $this->exporterfactory->get_discussion_exporter(
            $user,
            $this->forum,
            $this->discussion,
            $this->get_groups_available_in_forum()
        );

        return (array) $discussionexporter->export($this->renderer);
    }
921447
def add_topic(request, forum_slug=None):
    
    forum = Forum.objects.get(slug=forum_slug)
    form  = AddTopicForm(request.POST or None, request.FILES or None, initial={'forum': forum})

    current_time   = time.time()
    user           = request.user

    if form.is_valid():
        instance = form.save(commit=False)
        instance.forum           = forum
        instance.name            = strip_tags(instance.name)
        instance.slug            = slugify(instance.name)
        instance.user            = user
        instance.author          = user.display_name
        instance.lastpost_author = user.display_name
        instance.created_int     = current_time
        instance.modified_int    = current_time
        instance.save()

        # and now add the child post
        post = Post(
            topic            = instance,
            text             = request.POST['text'],
            user             = user,
            post_date_int    = current_time
        )
        if request.FILES:
            post.image = request.FILES['image']
        post.save()

        return HttpResponseRedirect("/forum/%s/?new_topic=%s" % (forum_slug, instance.id))

    return render(request, 'fretboard/add_edit.html', {
        'form': form,
        'form_title': 'Add a topic',
        'FORUM_BASE_NAME': FORUM_BASE_NAME
    })
1203886
private function get_detailed_discussion_list_renderer(
        forum_entity $forum,
        string $template
    ) : discussion_list_renderer {

        $capabilitymanager = $this->managerfactory->get_capability_manager($forum);
        $rendererbase = $this->rendererbase;
        $notifications = [];

        return new discussion_list_renderer(
            $forum,
            $rendererbase,
            $this->legacydatamapperfactory,
            $this->exporterfactory,
            $this->vaultfactory,
            $this->builderfactory,
            $capabilitymanager,
            $this->urlfactory,
            $template,
            $notifications,
            function($discussions, $user, $forum) use ($capabilitymanager) {
                $exportedpostsbuilder = $this->builderfactory->get_exported_posts_builder();
                $discussionentries = [];
                $postentries = [];
                foreach ($discussions as $discussion) {
                    $discussionentries[] = $discussion->get_discussion();
                    $discussionentriesids[] = $discussion->get_discussion()->get_id();
                    $postentries[] = $discussion->get_first_post();
                }

                $exportedposts['posts'] = $exportedpostsbuilder->build(
                    $user,
                    [$forum],
                    $discussionentries,
                    $postentries
                );

                $postvault = $this->vaultfactory->get_post_vault();
                $canseeanyprivatereply = $capabilitymanager->can_view_any_private_reply($user);
                $discussionrepliescount = $postvault->get_reply_count_for_discussion_ids(
                        $user,
                        $discussionentriesids,
                        $canseeanyprivatereply
                    );

                array_walk($exportedposts['posts'], function($post) use ($discussionrepliescount) {
                    $post->discussionrepliescount = $discussionrepliescount[$post->discussionid] ?? 0;
                    // TODO: Find a better solution due to language differences when defining the singular and plural form.
                    $post->isreplyplural = $post->discussionrepliescount != 1 ? true : false;
                });

                $exportedposts['state']['hasdiscussions'] = $exportedposts['posts'] ? true : false;

                return $exportedposts;
            }
        );
    }
549203
public function show(User $user)
    {
        $this->authorize(UsersPolicy::PERMISSION_SHOW);

        $user->load(['roles', 'roles.permissions']);

        $this->setTitle($title = trans('auth::users.titles.user-details'));
        $this->addBreadcrumb($title);

        return $this->view('admin.users.show', compact('user'));
    }
585324
def editpermissions_user_view(self, request, user_id, forum_id=None):
        
        user_model = get_user_model()
        user = get_object_or_404(user_model, pk=user_id)
        forum = get_object_or_404(Forum, pk=forum_id) if forum_id else None

        # Set up the context
        context = self.get_forum_perms_base_context(request, forum)
        context['forum'] = forum
        context['title'] = '{} - {}'.format(_('Forum permissions'), user)
        context['form'] = self._get_permissions_form(
            request, UserForumPermission, {'forum': forum, 'user': user},
        )

        return render(request, self.editpermissions_user_view_template_name, context)
105119
public function outputUserInfo(User $user, OutputInterface $output)
    {
        $output->writeln([
            '  ID: <info>'.$user->getId().'</info>',
            '  eMail: <info>'.$user->getEmail().'</info>',
            '  API-Key: <info>'.$user->getApiKey().'</info>',
        ]);
    }
285220
public function disableGlobalNotificationsAction(Forum $forum)
    {
        $collection = new ResourceCollection(array($forum->getResourceNode()));

        if (!$this->authorization->isGranted('MODERATE', $collection)) {
            throw new AccessDeniedException($collection->getErrorsForDisplay());
        }

        $this->manager->disableGlobalNotifications($forum);

        return new RedirectResponse(
            $this->generateUrl('claro_forum_categories', array('forum' => $forum->getId()))
        );
    }
1354252
public function index()
    {
        // Check if the user is able to create forums.
        if (!$this->canCreateForums()) {
            return redirect()->route('laravel-forum.index');
        }

        $data = $this->buildData();

        $data['counts'] = [
            'forum' => (new Forum)->getCount(),
            'category' => (new ForumCategory)->getCount(),
            'post' => (new ForumPost)->getCount(),
            'reply' => (new ForumReply)->getCount(),
        ];

        return view('laravel-forum::admin/index', $data);
    }
981117
def forum_list_filter(self, qs, user):
        
        # Any superuser should see all the forums
        if user.is_superuser:
            return qs

        # Check whether the forums can be viewed by the given user
        forums_to_hide = self._get_hidden_forum_ids(qs, user)

        return qs.exclude(id__in=forums_to_hide)
938490
public static function view_forum_discussion($discussionid) {
        global $DB, $CFG, $USER;
        require_once($CFG->dirroot . "/mod/forum/lib.php");

        $params = self::validate_parameters(self::view_forum_discussion_parameters(),
                                            array(
                                                'discussionid' => $discussionid
                                            ));
        $warnings = array();

        $discussion = $DB->get_record('forum_discussions', array('id' => $params['discussionid']), '*', MUST_EXIST);
        $forum = $DB->get_record('forum', array('id' => $discussion->forum), '*', MUST_EXIST);
        list($course, $cm) = get_course_and_cm_from_instance($forum, 'forum');

        // Validate the module context. It checks everything that affects the module visibility (including groupings, etc..).
        $modcontext = context_module::instance($cm->id);
        self::validate_context($modcontext);

        require_capability('mod/forum:viewdiscussion', $modcontext, null, true, 'noviewdiscussionspermission', 'forum');

        // Call the forum/lib API.
        forum_discussion_view($modcontext, $forum, $discussion);

        // Mark as read if required.
        if (!$CFG->forum_usermarksread && forum_tp_is_tracked($forum)) {
            forum_tp_mark_discussion_read($USER, $discussion->id);
        }

        $result = array();
        $result['status'] = true;
        $result['warnings'] = $warnings;
        return $result;
    }
698865
public function bulletinWidgetAction(User $user)
    {

        $totauxMatieres = $this->totauxManager->getTotalPeriodesMatiere($user);
        $periodes = $this->periodeRepo->findAll();

        $matCeb = array("Français", "Math", "Néerlandais", "Histoire", "Géographie", "Sciences");
        $cebWithPoints = array();
        $nocebWithPoints = array();

        foreach ($totauxMatieres as $matiereId => $datas) {
            $matiereName = $datas['name'];

            if (in_array($matiereName, $matCeb)) {
                $cebWithPoints[$matiereId] = $datas;
            } else {
                $nocebWithPoints[$matiereId] = $datas;
            }
        }
        $params = array(
            'user' => $user,
            'totauxMatieresCeb' => $cebWithPoints,
            'totauxMatieresNoCeb' => $nocebWithPoints,
            'periodes' => $periodes
        );

        return $this->render('LaurentBulletinBundle::BulletinWidget.html.twig', $params);
    }
27973
public static function start($title, User $user)
    {
        $discussion = new static;

        $discussion->title = $title;
        $discussion->created_at = Carbon::now();
        $discussion->user_id = $user->id;

        $discussion->setRelation('user', $user);

        $discussion->raise(new Started($discussion));

        return $discussion;
    }
102347
public function activateGlobalNotificationsAction(Forum $forum)
    {
        $collection = new ResourceCollection(array($forum->getResourceNode()));

        if (!$this->authorization->isGranted('MODERATE', $collection)) {
            throw new AccessDeniedException($collection->getErrorsForDisplay());
        }

        $this->manager->activateGlobalNotifications($forum);

        return new RedirectResponse(
            $this->generateUrl('claro_forum_categories', array('forum' => $forum->getId()))
        );
    }
456551
public function setPersonalWorkspace(User $user, $model = null)
    {
        $locale = $this->platformConfigHandler->getParameter('locale_language');
        $this->translator->setLocale($locale);
        $created = $this->workspaceManager->getWorkspaceByCode($user->getUsername());

        if (count($created) > 0) {
            $code = $user->getUsername() . '~' . uniqid();
        } else {
            $code = $user->getUsername();
        }

        $personalWorkspaceName = $this->translator->trans('personal_workspace', array(), 'platform') . ' - ' . $user->getUsername();

        if (!$model) {
            $config = Configuration::fromTemplate($this->personalWsTemplateFile);
            $config->setWorkspaceName($personalWorkspaceName);
            $config->setWorkspaceCode($code);
            $workspace = $this->transfertManager->createWorkspace($config, $user, true);
        } else {
            $workspace = $this->workspaceManager->createWorkspaceFromModel(
                $model,
                $user,
                $personalWorkspaceName,
                $user->getUsername(),
                '',
                false,
                false,
                false,
                $errors
            );
        }

        //add "my public documents" folder
        $resourceManager = $this->container->get('claroline.manager.resource_manager');
        $resourceManager->addPublicFileDirectory($workspace);
        $workspace->setIsPersonal(true);
        $user->setPersonalWorkspace($workspace);
        $this->objectManager->persist($user);
        $this->objectManager->flush();
    }
522222
public function findPlatformRoles(User $user)
    {
        $dql = "
            SELECT r FROM Claroline\CoreBundle\Entity\Role r
            JOIN r.users u
            WHERE u.id = {$user->getId()} AND r.type = ".Role::PLATFORM_ROLE;
        $query = $this->_em->createQuery($dql);

        return $query->getResult();
    }
855176
public function setupOrganization(User $user)
    {
        $guestCreateOrganization = false;
        $invitationHash = $this->session->get('newInvitation', false);

        if ($guestCreateOrganization || $invitationHash == false) {
            $organization = $this->createOrganization($user);
        }

        if ($invitationHash) {
            $organization = $this->processInvitationByHash($user, $invitationHash);
        }

        return $organization;
    }