Displays user administration tool.

@DI\Observe("administration_tool_user_management")

@param OpenAdministrationToolEvent $event
513779
public function onDisplayTool(OpenAdministrationToolEvent $event)
    {
        $content = $this->templating->render(
            'ClarolineCoreBundle:administration:users.html.twig', [
                // todo : put it in the async load of form
                'parameters' => $this->parametersSerializer->serialize(),
                'profile' => $this->profileSerializer->serialize(),
                'platformRoles' => $this->finder->search('Claroline\CoreBundle\Entity\Role', [
                    'filters' => ['type' => Role::PLATFORM_ROLE],
                ]),
            ]
        );

        $event->setResponse(new Response($content));
        $event->stopPropagation();
    }
240669
public function onPostActivate(PostActivateEvent $event): void
    {
        $user = $event->getUser();

        $this->ezUserAccountKeyRepository->removeByUserId($user->id);
        $this->ngUserSettingRepository->activateUser($user->id);

        $this->mailHelper
            ->sendMail(
                [$user->email => $this->getUserName($user)],
                'ngsite.user.welcome.subject',
                $this->configResolver->getParameter('template.user.mail.welcome', 'ngsite'),
                [
                    'user' => $user,
                ]
            );
    }
743295
public function authorizeRequest(Event $event)
    {
        /* @var \Guzzle\Service\Command\CommandInterface $command */
        $command = $event['command'];

        $request = $command->getRequest();
        $request->setAuth($this->apiKey);
    }
446593
public function onDispatch(MvcEvent $event)
    {
        /* @var $service \BjyAuthorize\Service\Authorize */
        $service    = $this->serviceLocator->get('BjyAuthorize\Service\Authorize');
        $match      = $event->getRouteMatch();
        $controller = $match->getParam('controller');
        $action     = $match->getParam('action');
        $request    = $event->getRequest();
        $method     = $request instanceof HttpRequest ? strtolower($request->getMethod()) : null;

        $authorized = $service->isAllowed($this->getResourceName($controller))
            || $service->isAllowed($this->getResourceName($controller, $action))
            || ($method && $service->isAllowed($this->getResourceName($controller, $method)));

        if ($authorized) {
            return;
        }

        $event->setError(static::ERROR);
        $event->setParam('identity', $service->getIdentity());
        $event->setParam('controller', $controller);
        $event->setParam('action', $action);

        $errorMessage = sprintf("You are not authorized to access %s:%s", $controller, $action);
        $event->setParam('exception', new UnAuthorizedException($errorMessage));

        /* @var $app \Zend\Mvc\ApplicationInterface */
        $app = $event->getTarget();
        $app->getEventManager()->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $event);
    }
988103
@EventHandler
    public void handle(PermissionRevokedEvent event) {
        commandAuthorizationRepository.remove(event.getChargingStationId().getId(), event.getUserIdentity().getId(), event.getCommandClass());
    }
724543
public static function setPermissionsChmod(Event $event)
	{
		$http_user = self::getHttpdUser($event);
		foreach (self::getWritableDirs($event) as $path) {
			self::ChmodPermissionsSetter($event, $http_user, $path, 'dir');
		}
		foreach (self::getWritableFiles($event) as $path) {
			self::ChmodPermissionsSetter($event, $http_user, $path, 'file');
		}
	}
189665
public function onDisplayDesktop(DisplayToolEvent $event)
    {
        $currentUser = $this->tokenStorage->getToken()->getUser();

        $allTabs = $this->finder->search(HomeTab::class, [
            'filters' => ['user' => $currentUser->getUuid()],
        ]);

        // Order tabs. We want :
        //   - Administration tabs to be at first
        //   - Tabs to be ordered by position
        // For this, we separate administration tabs and user ones, order them by position
        // and then concat all tabs with admin in first (I don't have a easier solution to achieve this)

        $adminTabs = [];
        $userTabs = [];
        foreach ($allTabs['data'] as $tab) {
            if (!empty($tab)) {
                // we use the define position for array keys for easier sort
                if (HomeTab::TYPE_ADMIN_DESKTOP === $tab['type']) {
                    $adminTabs[$tab['position']] = $tab;
                } else {
                    $userTabs[$tab['position']] = $tab;
                }
            }
        }

        // order tabs by position
        ksort($adminTabs);
        ksort($userTabs);

        // generate the final list of tabs
        $orderedTabs = array_merge(array_values($adminTabs), array_values($userTabs));

        // we rewrite tab position because an admin and a user tab may have the same position
        foreach ($orderedTabs as $index => &$tab) {
            $tab['position'] = $index;
        }

        $content = $this->templating->render(
            'ClarolineCoreBundle:tool:home.html.twig', [
                'editable' => true,
                'context' => [
                    'type' => Widget::CONTEXT_DESKTOP,
                ],
                'tabs' => $orderedTabs,
            ]
        );

        $event->setContent($content);
        $event->stopPropagation();
    }
616818
public static function message_viewed(\core\event\message_viewed $event) {
        global $DB;

        $userid = $event->userid;
        $messageid = $event->other['messageid'];

        $DB->delete_records('message_email_messages', ['useridto' => $userid, 'messageid' => $messageid]);
    }
318898
public function onDisplayDesktopAgenda(DisplayToolEvent $event)
    {
        $em = $this->container->get('doctrine.orm.entity_manager');
        $usr = $this->tokenStorage->getToken()->getUser();
        $listEventsDesktop = $em->getRepository('ClarolineAgendaBundle:Event')->findDesktop($usr, true);
        $listEvents = $em->getRepository('ClarolineAgendaBundle:Event')->findByUser($usr, false);
        $filters = [];
        $editableWorkspaces = [0 => true];

        foreach ($listEvents as $agendaEvent) {
            $workspaceId = $agendaEvent->getWorkspace()->getUuid();
            $filters[$workspaceId] = $agendaEvent->getWorkspace()->getName();
            $editableWorkspaces[$workspaceId] = $this->authorization->isGranted(
                ['agenda_', 'edit'],
                $agendaEvent->getWorkspace()
            );
        }

        if (count($listEventsDesktop) > 0) {
            $filters[0] = $this->container->get('translator')->trans('desktop', [], 'platform');
        }

        $content = $this->templating->render(
            'ClarolineAgendaBundle:tool:agenda.html.twig',
            [
                'filters' => $filters,
                'editableWorkspaces' => $editableWorkspaces,
            ]
        );

        $event->setContent($content);
    }
1308119
public function indexAction()
    {
        $tools = $this->toolManager->getAdminToolsByRoles($this->tokenStorage->getToken()->getRoles());

        if (count($tools) === 0) {
            throw new AccessDeniedException();
        }

        return $this->redirect($this->generateUrl('claro_admin_open_tool', array('toolName' => $tools[0]->getName())));
    }
752118
public function setDefaultUser(ConsoleCommandEvent $event)
    {
        $command = $event->getCommand();

        if ($command instanceof AdminCliCommand) {
            $user = $this->userManager->getDefaultClarolineAdmin();
            $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
            $this->tokenStorage->setToken($token);
        }
    }
447112
public function onDisplayWorkspace(DisplayToolEvent $event)
    {
        $workspace = $event->getWorkspace();

        $content = $this->templating->render(
            'ClarolineCoreBundle:workspace:logs.html.twig', [
                'workspace' => $workspace,
                'actions' => $this->eventManager->getEventsForApiFilter(LogGenericEvent::DISPLAYED_WORKSPACE),
            ]
        );

        $event->setContent($content);
        $event->stopPropagation();
    }
722487
@EventHandler
    public void handle(PermissionGrantedEvent event) {
        commandAuthorizationRepository.createOrUpdate(event.getChargingStationId().getId(), event.getUserIdentity().getId(), event.getCommandClass());
    }
586086
public function handle(LogoutEvent $event)
    {
        $this->track(Settings::TYPEID_LOGOUT, $event->user->id, 10, null, $event->user->id);
    }
490047
public function handle(GetResponseEvent $event): void
    {
        if ($this->isEnabled()) {
            $hostRole = $this->getHostRole($event);

            if (null !== $hostRole) {
                $this->sidManager->addSpecialRole($hostRole);
            }
        }
    }
1183498
def manage_admins():
    """"""
    build = g.build

    # Do not show cached data
    db.session.add(build)
    db.session.refresh(build)

    add_form = forms.AddAdminForm()
    if add_form.validate_on_submit():

        invitation_user_id = '%s:%s' % (
            models.User.EMAIL_INVITATION, add_form.email_address.data)

        invitation_user = models.User.query.get(invitation_user_id)
        if not invitation_user:
            invitation_user = models.User(
                id=invitation_user_id,
                email_address=add_form.email_address.data)
            db.session.add(invitation_user)

        db.session.add(build)
        db.session.add(invitation_user)
        db.session.refresh(build, lockmode='update')

        build.owners.append(invitation_user)
        save_admin_log(build, invited_new_admin=True,
                       message=invitation_user.email_address)

        db.session.commit()

        logging.info('Added user=%r as owner to build_id=%r',
                     invitation_user.id, build.id)
        return redirect(url_for('manage_admins', build_id=build.id))

    add_form.build_id.data = build.id

    revoke_form_list = []
    for user in build.owners:
        form = forms.RemoveAdminForm()
        form.user_id.data = user.id
        form.build_id.data = build.id
        form.revoke.data = True
        revoke_form_list.append((user, form))

    return render_template(
        'view_admins.html',
        build=build,
        add_form=add_form,
        revoke_form_list=revoke_form_list)
61739
public function addRoleToToolAction(AdminTool $tool, Role $role)
    {
        $this->toolManager->addRoleToAdminTool($tool, $role);

        return new Response('success');
    }