Reference #97 #99

Closed
opened 2017-06-10 22:53:12 +00:00 by mwweb · 0 comments
mwweb commented 2017-06-10 22:53:12 +00:00 (Migrated from github.com)

I was actually looking at a way of having the permissions preset upon install.

I found, and modified, the script below that, when placed in PHP Postflight for the component, presets the permissions on install. The user installing would only need to set the permissions in the component if they wanted to change them.

I'm drawing a blank right now on how, exactly, to implement something like this as part of the compile process within JCB automatically. But, as a thought, in JCB you already set your permissions in each of the admin views, which generates the admin/access.xml file. If we worked out a way to extend the permissions section to allow setting the the permission, but also the group and access levels, then all of the needed parameters would be in place to generate the below code dynamically.

This is just a thought:

                // $type (install, update or discover_install)
                if ($type == 'install') {
                        $db = JFactory::getDBO();
                        $query = $db->getQuery(true);
                        $query->update($db->quoteName('#__assets'));
                        $defaults = '{"site.agent.access":{"1":1},"site.agents.access":{"1":1},"site.cities.access":{"1":1},"site.companies.access":{"1":1},"site.countries.access":{"1":1},"site.categories.access":{"1":1},"site.properties.access":{"1":1},"site.states.access":{"1":1},"site.city.access":{"1":1},"site.company.access":{"1":1},"site.country.access":{"1":1},"site.favorites.access":{"1":1},"site.featured.access":{"1":1},"site.hotsheet.access":{"1":1},"site.openhouses.access":{"1":1},"site.property.access":{"1":1},"site.category.access":{"1":1},"site.state.access":{"1":1},"site.transactiontype.access":{"1":1},"core.create":{"2":1},"core.delete":{"2":1},"core.edit":{"3":1},"core.edit.state":{"3":1},"core.edit.own":{"2":1},"core.edit.created_by":{"2":1},"core.edit.created":{"2":1}}'; // JSON format for the parameters, see PHP serialize()
                        $query->set($db->quoteName('rules') . ' = ' . $db->quote($defaults));
                        $query->where($db->quoteName('name') . ' = ' . $db->quote('com_mostwantedrealestate'));
                        $db->setQuery($query);
                        $db->query();
				}

I've tested this several times with my component, and it works beautifully.

I was actually looking at a way of having the permissions preset upon install. I found, and modified, the script below that, when placed in PHP Postflight for the component, presets the permissions on install. The user installing would only need to set the permissions in the component if they wanted to change them. I'm drawing a blank right now on how, exactly, to implement something like this as part of the compile process within JCB automatically. But, as a thought, in JCB you already set your permissions in each of the admin views, which generates the admin/access.xml file. If we worked out a way to extend the permissions section to allow setting the the permission, but also the group and access levels, then all of the needed parameters would be in place to generate the below code dynamically. This is just a thought: ``` // $type (install, update or discover_install) if ($type == 'install') { $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->update($db->quoteName('#__assets')); $defaults = '{"site.agent.access":{"1":1},"site.agents.access":{"1":1},"site.cities.access":{"1":1},"site.companies.access":{"1":1},"site.countries.access":{"1":1},"site.categories.access":{"1":1},"site.properties.access":{"1":1},"site.states.access":{"1":1},"site.city.access":{"1":1},"site.company.access":{"1":1},"site.country.access":{"1":1},"site.favorites.access":{"1":1},"site.featured.access":{"1":1},"site.hotsheet.access":{"1":1},"site.openhouses.access":{"1":1},"site.property.access":{"1":1},"site.category.access":{"1":1},"site.state.access":{"1":1},"site.transactiontype.access":{"1":1},"core.create":{"2":1},"core.delete":{"2":1},"core.edit":{"3":1},"core.edit.state":{"3":1},"core.edit.own":{"2":1},"core.edit.created_by":{"2":1},"core.edit.created":{"2":1}}'; // JSON format for the parameters, see PHP serialize() $query->set($db->quoteName('rules') . ' = ' . $db->quote($defaults)); $query->where($db->quoteName('name') . ' = ' . $db->quote('com_mostwantedrealestate')); $db->setQuery($query); $db->query(); } ``` I've tested this several times with my component, and it works beautifully.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#99
No description provided.