<commit_before><?php

namespace Oro\Bundle\UserBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

use Oro\Bundle\UserBundle\Entity\User;
use Oro\Bundle\UserBundle\Entity\UserManager;

class ProfileController extends Controller
{
    /**
     * @Route("/show/{id}", name="oro_user_show", requirements={"id"="\d+"})
     * @Template
     */
    public function showAction(User $user)
    {
        return array(
            'user' => $user,
        );
    }

    /**
     * Create user form
     *
     * @Route("/create", name="oro_user_create")
     * @Template("OroUserBundle:Profile:edit.html.twig")
     */
    public function createAction()
    {
        $user = $this->getManager()->createFlexible();

        return $this->editAction($user);
    }

    /**
     * Edit user form
     *
     * @Route("/edit/{id}", name="oro_user_edit", requirements={"id"="\d+"}, defaults={"id"=0})
     * @Template
     */
    public function editAction(User $entity)
    {
        if ($this->get('oro_user.form.handler.profile')->process($entity)) {
            $this->get('session')->getFlashBag()->add('success', 'User successfully saved');

            return $this->redirect($this->generateUrl('oro_user_index'));
        }

        return array(
            'form' => $this->get('oro_user.form.profile')->createView(),
        );
    }

   /**
    * @Route("/remove/{id}", name="oro_user_remove", requirements={"id"="\d+"})
    */
    public function removeAction(User $entity)
    {
        $this->getManager()->deleteUser($entity);
        $this->get('session')->getFlashBag()->add('success', 'User successfully removed');

        return $this->redirect($this->generateUrl('oro_user_index'));
    }

    /**
     * @Route("/{page}/{limit}", name="oro_user_index", requirements={"page"="\d+","limit"="\d+"}, defaults={"page"=1,"limit"=20})
     * @Template
     */
    public function indexAction($page, $limit)
    {
        return array(
            'pager' => $this->get('knp_paginator')->paginate(
                $this->getManager()->getListQuery(),
                (int) $page,
                (int) $limit
            ),
        );
    }

    /**
     * @return UserManager
     */
    protected function getManager()
    {
        return $this->get('oro_user.manager');
    }
}
<commit_msg>BAP-206: User Account Edit. Added ACL check for profile actions.<commit_after><?php

namespace Oro\Bundle\UserBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

use Oro\Bundle\UserBundle\Annotation\Acl;
use Oro\Bundle\UserBundle\Entity\User;
use Oro\Bundle\UserBundle\Entity\UserManager;

/**
 * @Acl(
 *      id="oro_user_profile",
 *      name="Profile controller",
 *      description="Profile manipulation",
 *      parent="oro_user"
 * )
 */
class ProfileController extends Controller
{
    /**
     * @Route("/show/{id}", name="oro_user_show", requirements={"id"="\d+"})
     * @Template
     * @Acl(
     *      id="oro_user_profile_show",
     *      name="View user profile",
     *      description="View user profile",
     *      parent="oro_user_profile"
     * )
     */
    public function showAction(User $user)
    {
        return array(
            'user' => $user,
        );
    }

    /**
     * Create user form
     *
     * @Route("/create", name="oro_user_create")
     * @Template("OroUserBundle:Profile:edit.html.twig")
     * @Acl(
     *      id="oro_user_profile_create",
     *      name="Create user profile",
     *      description="Create user profile",
     *      parent="oro_user_profile"
     * )
     */
    public function createAction()
    {
        $user = $this->getManager()->createFlexible();

        return $this->editAction($user);
    }

    /**
     * Edit user form
     *
     * @Route("/edit/{id}", name="oro_user_edit", requirements={"id"="\d+"}, defaults={"id"=0})
     * @Template
     * @Acl(
     *      id="oro_user_profile_edit",
     *      name="Edit user profile",
     *      description="Edit user profile",
     *      parent="oro_user_profile"
     * )
     */
    public function editAction(User $entity)
    {
        if ($this->get('oro_user.form.handler.profile')->process($entity)) {
            $this->get('session')->getFlashBag()->add('success', 'User successfully saved');

            return $this->redirect($this->generateUrl('oro_user_index'));
        }

        return array(
            'form' => $this->get('oro_user.form.profile')->createView(),
        );
    }

    /**
     * @Route("/remove/{id}", name="oro_user_remove", requirements={"id"="\d+"})
     * @Acl(
     *      id="oro_user_profile_remove",
     *      name="Remove user profile",
     *      description="Remove user profile",
     *      parent="oro_user_profile"
     * )
     */
    public function removeAction(User $entity)
    {
        $this->getManager()->deleteUser($entity);
        $this->get('session')->getFlashBag()->add('success', 'User successfully removed');

        return $this->redirect($this->generateUrl('oro_user_index'));
    }

    /**
     * @Route("/{page}/{limit}", name="oro_user_index", requirements={"page"="\d+","limit"="\d+"}, defaults={"page"=1,"limit"=20})
     * @Template
     * @Acl(
     *      id="oro_user_profile_list",
     *      name="View list of user profiles",
     *      description="View list of user profiles",
     *      parent="oro_user_profile"
     * )
     */
    public function indexAction($page, $limit)
    {
        return array(
            'pager' => $this->get('knp_paginator')->paginate(
                $this->getManager()->getListQuery(),
                (int) $page,
                (int) $limit
            ),
        );
    }

    /**
     * @return UserManager
     */
    protected function getManager()
    {
        return $this->get('oro_user.manager');
    }
}

{'fraction_non_alphanumeric': 0.17325676784249386, 'fraction_numerical': 0.001804757998359311, 'mean_word_length': 2.481439177612793, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4869562', 'n_tokens_mistral': 1861, 'n_tokens_neox': 1815, 'n_words': 277}