Giter VIP home page Giter VIP logo

zfcuseradmin's People

Contributors

akrabat avatar danielss89 avatar foaly-nr1 avatar freeaqingme avatar hounddog avatar ksvendsen avatar leup avatar liorcode avatar mischosch avatar olavocneto avatar orlandosanchez avatar step307 avatar vgarvardt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zfcuseradmin's Issues

ZfcUserAdmin created a module under zendframework2

sir, my error below
Fatal error: Uncaught exception 'Zend\Mvc\Router\Exception\InvalidArgumentException' with message 'Missing "type" option' in D:\Program Files\Zend\ZendServer\data\libraries\Zend_Framework_2\2.2.1\library\Zend\Mvc\Router\SimpleRouteStack.php:269 Stack trace: #0 D:\Program Files\Zend\ZendServer\data\libraries\Zend_Framework_2\2.2.1\library\Zend\Mvc\Router\Http\TreeRouteStack.php(159): Zend\Mvc\Router\SimpleRouteStack->routeFromArray(Array) #1 D:\Program Files\Zend\ZendServer\data\libraries\Zend_Framework_2\2.2.1\library\Zend\Mvc\Router\Http\TreeRouteStack.php(113): Zend\Mvc\Router\Http\TreeRouteStack->routeFromArray(Array) #2 D:\Program Files\Zend\ZendServer\data\libraries\Zend_Framework_2\2.2.1\library\Zend\Mvc\Router\SimpleRouteStack.php(140): Zend\Mvc\Router\Http\TreeRouteStack->addRoute('zfcadmin', Array) #3 D:\Program Files\Zend\ZendServer\data\libraries\Zend_Framework_2\2.2.1\library\Zend\Mvc\Router\SimpleRouteStack.php(84): Zend\Mvc\Router\SimpleRouteStack->addRoutes(Array) #4 D:\Program Files\Zend\ZendServer\data\li in D:\Program Files\Zend\ZendServer\data\libraries\Zend_Framework_2\2.2.1\library\Zend\ServiceManager\ServiceManager.php on line 860

Adding form elements extending editForm using event listener creates duplicates

class Module implements FormElementProviderInterface
{
    public function onBootstrap($e)
    {
        $em  = $app->getEventManager()->getSharedManager();

        $em->attach('ZfcUserAdmin\Form\EditUser', 'init', function($e) {
            // $form is a ZfcUser\Form\Register
            $form = $e->getTarget();

            $form->add(array(
                'name' => 'costCenters',
            'type' => 'select',
                'options' => array(
                    'label' => 'Cost centers',
                ),
            ));
        });
    }
}

This creates the costcenters element twice - the second one after the userId element.

This DOES NOT HAPPEN when using the same listener on the ''ZfcUserAdmin\Form\CreateUser** form.

Both forms share the same _form.phtml view.

Closure

We should remove the usage of those closures in services.config.php and make real factories of those

Move form validation from controller to service

UserAdminController validates the form then passes result to service method, making reuse of the account create/edit functionality elsewhere more difficult.

TODO: I made a fix for this here and here but needs to be extended to include createAction, and also needs some tests

404 when trying to open admin root

Hello.

I installed ZfcAdmin - /admin opens defualt admin page (going to implement some kind of dashboard here).

Then I installed ZfcUserAdmin and now /admin gives 404 with default layout, /admin/user gives the same (I think it's predictable as it does not have may_terminate), /admin/user/list opens users list (as it should) and I see Users in admin navigation bar.

I tried commenting out whole router section in module config - /admin index page works fine then, navigation bar has Users section (leads to /admin).

What can be the reason for admin index page stopped working with ZfcUserAdmin enabled?

Column not found: 1054 Unknown column 't0.user_id' in 'where clause'

Installed modules:

array(2) {
  ["modules"] => array(12) {
    [0] => string(18) "ZendDeveloperTools"
    [1] => string(14) "DoctrineModule"
    [2] => string(17) "DoctrineORMModule"
    [3] => string(7) "ZfcBase"
    [4] => string(7) "ZfcUser"
    [5] => string(18) "ZfcUserDoctrineORM"
    [6] => string(7) "ZfcRbac"
    [7] => string(8) "ZfcAdmin"
    [8] => string(12) "ZfcUserAdmin"
    [9] => string(11) "Application"
    [10] => string(9) "TwbBundle"
    [11] => string(11) "ZfcDatagrid"
  }

When trying to edit an user I get the following error:

Column not found: 1054 Unknown column 't0.user_id' in 'where clause'

Caused by the following query:

SELECT t1.username AS username2, t1.email AS email3, t1.display_name AS display_name4, t1.password AS password5, t1.state AS state6, t1.user_id AS user_id7 FROM user t1 WHERE t0.user_id = ?' with params ["17"]:

For some reason the query uses t1 as alias for the user table but then queries on an t0 alias for the user_id.

Missing parameter "userId"

So after:

  1. adding zfcUserAdmin to a project that already had zfcUser up and working
  2. adding "'user_mapper' => 'ZfcUserAdmin\Mapper\UserZendDb'," to the ZfcUserAdmin.global.php file under config/autoload/

I then navigate to MYPROJECT/admin and I see a default Admin page with "Users" link in the navigation - great - click on this and I get:

Zend\Mvc\Router\Exception\InvalidArgumentException

Message: Missing parameter "userId"

Is there a trick to getting this to work? After following your instructions I didn't expect an error of this sort.

Regards,
Brad

Method for updating Entity not designed for using ManyToMany annotation

I am extending my User entity with an attribute using a ManyToMany association.
In my example I use "costCenters" but you can think of it as the already existing "roles" attribute.

User entity:

    /**
     * @var \Doctrine\Common\Collections\Collection
     * @ORM\ManyToMany(targetEntity="Application\Entity\Role")
     * @ORM\JoinTable(name="user_role_linker",
     *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
     *      inverseJoinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id")}
     * )
     */
    protected $roles;

    /**
     * @var \Doctrine\Common\Collections\Collection
     * @ORM\ManyToMany(targetEntity="Application\Entity\CostCenter")
     * @ORM\JoinTable(name="user_costCenter",
     *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="user_id")},
     *      inverseJoinColumns={@ORM\JoinColumn(name="costCenter_id", referencedColumnName="id")}
     * )
     */
    private $costCenters;

    public function getCostCenters() {
        return $this->costCenters;
    }

    public function setCostCenters($costCenters) {
        $this->costCenters = $costCenters;
    }

Extending the form in my _Module.php_:

    public function onBootstrap($e)
    {
        $app = $e->getParam('application');
        // $em is a Zend\EventManager\SharedEventManager
        $em  = $app->getEventManager()->getSharedManager();

        $em->attach('ZfcUserAdmin\Form\EditUser', 'init', function($e) {
            // $form is a ZfcUser\Form\Register
            $form = $e->getTarget();

            $sm = $form->getServiceManager();
            $om = $sm->get('Doctrine\ORM\EntityManager');

            #$form->setHydrator(new \DoctrineORMModule\Stdlib\Hydrator\DoctrineEntity($om, 'Application\Entity\User'));

            $form->add(array(
                'name' => 'costCenters',
                'type' => 'DoctrineModule\Form\Element\ObjectMultiCheckbox',
                'options' => array(
                    'label' => 'Access to costcenters',
                    'object_manager' => $om,
                    'target_class'   => 'Application\Entity\CostCenter',
                    'property'       => 'id',
                ),
            ));
        });
    }

I already inserted some rows in my database and the edit form is populated correctely with these existing costcenters.

When editing and saving I get these warnings / errors:
Warning: spl_object_hash() expects parameter 1 to be object, string given in /vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 1375*

exception 'Doctrine\ORM\ORMException' with message 'Found entity of type on association Application\Entity\User#costCenters, but expecting Application\Entity\CostCenter' in /vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:783

I think the configuration of entities and form are correct. It looks like the method to update the user entity in Service/User.php l. 78 ff. causes a problem:

        // first, process all form fields
        foreach ($data as $key => $value) {
            if ($key == 'password') continue;

            $setter = $this->getAccessorName($key);
            if (method_exists($user, $setter)) call_user_func(array($user, $setter), $value);
        }

My posted value for costCenters will be an array of strings including the IDs.
It looks like the entity manager will ony receive these strings since it doesn't know they have to be "hydrated" to find the related objects / entities.

Normally I would bind the object to Zend_Form and then a hydrator will do this in order to correctely persist the entity, e.g.:

        $id = /*(int)*/ $this->params('id', null);

        $em = $this->getEntityManager();

        $timeDataStatus = $em->find('Application\Entity\TimeDataStatus', $id);

        $formManager = $this->serviceLocator->get('FormElementManager');
        $form    = $formManager->get('CreateTimeDataStatus');
        $form->bind($timeDataStatus);

        $request = $this->getRequest();
        if ($request->isPost()) {
            $form->setData($request->getPost());

            if ($form->isValid()) {
                $em->persist($timeDataStatus);
                $em->flush();
            }
        }

Since saving multiple roles will probably be a use case for future admin forms can we achieve a solution here?

Cant use module

Hello

I can't add this module.
By composer it won't add because it isnt fully registerd by pacagist.(w<hich is because it is just a demo).
ZFC user-afcaAdmin are installed by composer from zf-commons
So added the hole folder to the vendor dir.
added 'ZfcBase',
'ZfcUser',
'ZfcAdmin',
'ZfcUserAdmin' to the modules array in the aplication.config.php in autoload of project.
But i get:
( ! ) Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (ZfcUserAdmin) could not be initialized.' in D:\Dropbox\server\Workspace\testProject\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php on line 189
( ! ) Zend\ModuleManager\Exception\RuntimeException: Module (ZfcUserAdmin) could not be initialized. in D:\Dropbox\server\Workspace\testProject\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php on line 189

'Module (ZfcUserAdmin) could not be initialized.'

Hi,
i've got this error:

Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (ZfcUserAdmin) could not be initialized.'

"minimum-stability": "dev",
"require": {
"danielss89/zfc-user-admin": "dev-master"
},
"repositories": [
{
"type": "package",
"package": {
"version": "dev-master",
"name": "danielss89/zfc-user-admin",
"source": {
"type": "git",
"url": "https://github.com/Danielss89/ZfcUserAdmin.git",
"reference": "master"
}
}
}
]
}

Add package to packagist.org

Just realized that module is not present on packagist.org so it can't be installed automatically with composer. There is fork by joacub, but it's a month old. Now I'misnatlling tha latest version of the module by adding this repository to composer repositories.

Fatal with lastets zfcUser

Got this error when using the latest version of this module and the zfcUser

Catchable fatal error: Argument 1 passed to ZfcUser\Mapper\UserHydrator::__construct() must be an instance of Zend\Crypt\Password\PasswordInterface, none given, called in D:\Dropbox\server\Workspace\True-Life\vendor\danielss89\zfc-user-admin\config\services.config.php on line 92 and defined in D:\Dropbox\server\Workspace\True-Life\vendor\zf-commons\zfc-user\src\ZfcUser\Mapper\UserHydrator.php on line 21

Integrate ReverseForm

I want to suggest integrate ReverseForm for form generation - it will make add/edit user form generation much easier to maintain. The only disadvantage it gives - additional requirement for module installation.

I can handle this issue by myself, but it would be nice if ZfcUserAdmin added this into root project because maintaining branch is not so funny =)

[Question] Created user has no role assigned.

I'm using ZfcAdmin together with BjyAuthorize and ZfcUserDoctrineORM and everything works fine, except when I create a new user, the user is being created, I can login, but the user has no role assigned...

How can I configure ZfcUserAdmin to apply a specified role to newly created/registered users?

custom user mapper

Module.php#74:

if ($mapperClass = 'ZfcUserAdmin\Mapper\UserZendDb') {

shouldn't it rather be

if ($mapperClass == 'ZfcUserAdmin\Mapper\UserZendDb') {

?

Items in paginator

The items in the paginator aren't correct.
In the controller we set them to 100.
But in the view's we work with the number 10.

Maybe an idea is to make it editable the amount by a setting some var in the ZfcUserAdmin.global.php file.
Is this a good idea?

create action

When I go to action create there is form with two input fields for email rather than passwords.
And when I create new user, password in database is not encrypted.

Adding custom form elements with Doctrine mapping / relationships fail

I try to add custom form elements using the module options.

My User entity:

class User implements UserInterface, ProviderInterface
{
    /**
     * @var int
     * @ORM\Id
     * @ORM\Column(name="user_id", type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @var string
     * @ORM\Column(type="string", length=255, unique=true, nullable=true)
     */
    protected $username;

    /**
     * @var string
     * @ORM\Column(type="string", unique=true,  length=255)
     */
    protected $email;

    /**
     * @var string
     * @ORM\Column(name="display_name", type="string", length=50, nullable=true)
     */
    protected $displayName;

    /**
     * @var string
     * @ORM\Column(type="string", length=128)
     */
    protected $password;

    /**
     * @var int
     */
    protected $state;

    /**
     * @var \Doctrine\Common\Collections\Collection
     * @ORM\ManyToMany(targetEntity="Application\Entity\Role")
     * @ORM\JoinTable(name="user_role_linker",
     *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="user_id")},
     *      inverseJoinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="role_id")}
     * )
     */
    protected $roles;

    /**
     * @var \Doctrine\Common\Collections\Collection
     * @ORM\ManyToMany(targetEntity="Application\Entity\CostCenter")
     * @ORM\JoinTable(name="user_costCenter",
     *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="user_id")},
     *      inverseJoinColumns={@ORM\JoinColumn(name="costCenter_id", referencedColumnName="id")}
     * )
     */
    private $costCenters;

    public function __construct()
    {
        $this->roles = new ArrayCollection();
        $this->costCenters = new ArrayCollection();
    }

    /* correct getters and setters */

My module options

    'create_form_elements' => array(
        'Email' => 'email',
        'Cost centers' => 'costCenters'
    ),
    'edit_form_elements' => array(
        'Email' => 'email',
        'Cost centers' => 'costCenters'
    )

The ZfcUserAdmin\Form\CreateUser form correctely creates a text element.

The ZfcUserAdmin\Form\EditUser shows the following error:
Object provided to Escape helper, but flags do not allow recursion

'Module (ZfcUserAdmin) could not be initialized.'

hi
just intalling the module produce the bug : #10

<?php
return array(
    'modules' => array(
            'ZfcBase',
            'ZfcUser',
            'BjyAuthorize',
            'GoalioForgotPassword',
            'PhlyContact',
            'ZfcAdmin',
                // commented otherwise produce a bug
            //'ZfcUserAdmin',
            'Common'
    ),
    'module_listener_options' => array(
        'config_glob_paths'    => array(
            'config/autoload/{,*.}{global,local}.php',
        ),
        'module_paths' => array(
            './module',
            './vendor',
        ),
    ),
);

Class 'ZfcUserDoctrineORM\Mapper\User' not found

After installing, i have error in url http://......../admin/user/list

Fatal error: Class 'ZfcUserDoctrineORM\Mapper\User' not found in ....\vendor\ZfcUserAdmin\src\ZfcUserAdmin\Mapper\UserDoctrine.php on line 8
install:
1.Clone ZfcUserAdmin
2.Clone ZfcAdmin
3.Add modules to config

Am i do anything wrong ?

Routing error

I am getting a routing error after installing this module.

Fatal error: Uncaught exception 'Zend\Mvc\Router\Exception\InvalidArgumentException' with message 'Missing "type" option' . Is this module.config up to date with the latest zf2? The routing portion looks a lot different than what I have seen.

MIssing method 'getUserId'

Hi.

Really appreciate your project!

But got the following error:

Warning: call_user_func() expects parameter 1 to be a valid callback, class 'ZfcUser\Entity\User' does not have a method 'getUserId' in C:\wamp\www\ZendSkeletonApplication\vendor\danielss89\zfc-user-admin\view\zfc-user-admin\user-admin\list.phtml on line 39

The zfcuser user\entity does not provide getUserId.

My Version of zfcUser is 0.0.1.

I extendend the original zfcuser entity with setUserId and getUserId. Worked than.

Dont know if this helps. I am really new to zf2, git and so on.

Thanks.

My plan, instead of changing ZF-Commons / ZfcUser:
Will setup up an own user entity for Danielss89 / ZfcUserAdmin and extend the ZF-Commons / ZfcUser with it.

Custom fields validation messages

This can easily become Wiki material but right now it's a call for help. I added new fields to ZfcUser. One of them is sex. My problem here is with the validation messages. They work just fine but while editing users, manipulating the form's value (I changed it to "s") I got these messages:

    The input was not found in the haystack
    The input does not match against pattern '/^(m|f)$/'
    An invalid sex type was entered

Obviously, I only want to display the third message whenever the input data doesn't match my criteria. Anything else is not user-friendly. Zend's Validation Messages[1] page demonstrates how you can override messages but it doesn't say how you can restrict certain messages or only display what you want. I looked for solutions on the web and I also went to the ZF irc channel, but I didn't find what I needed. How can we output only our validation messages?

[1] http://framework.zend.com/manual/2.0/en/modules/zend.validator.messages.html

Here are the details of my custom field:

module\ZfcUser\src\ZfcUser\Form\Base.php -> __construct:

        $this->add(array(
            'type' => 'radio',
            'name' => 'sex',
            'options' => array(
                'label' => 'Sex',
                'value_options' => array(
                    'm' => ' male',
                    'f' => ' female'
                ),
            ),
        ));

module\ZfcUser\src\ZfcUser\Form\RegisterFilter.php -> __construct:

        $this->add(array(
            'name'       => 'sex',
            'required'   => true,
            'validators' => array(
                array(
                    'name' => 'regex',
                    'options' => array(
                        'pattern' => '/^(m|f)$/'
                    )
                ),
                $this->sexValidator
            ),
        ));

module\ZfcUserAdmin\config\services.config.php -> $filter = new $registerFilter(

                new SexEdit(array(
                    'mapper' => $sm->get('zfcuser_user_mapper'),
                    'key' => 'sex'
                )),

module\ZfcUserAdmin\src\ZfcUserAdmin\Validator\SexEdit.php

namespace ZfcUserAdmin\Validator;

class SexEdit extends \ZfcUser\Validator\AbstractRecord
{
    public function isValid($value)
    {
        $valid = true;

        if (!preg_match("/^(m|f)$/", $value)) {
            $valid = false;
            $this->error(self::ERROR_BAD_SEX);
        }

        return $valid;
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.