diff --git a/Makefile b/Makefile index e55d1e84a5f3c735b4d49fc5aa3fb6d8d7a27450..3b969d8a5c0acaaffbd580cf7d0f54c9b2179bdd 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ BASE=usergroupsfield PLUGINTYPE=plug -ZIPBASE=opentools_cb -VERSION=1.0 +ZIPBASE=opentools_cb2 +VERSION=2.0.0 PLUGINFILES=cb.$(BASE).php cb.$(BASE).xml diff --git a/cb.usergroupsfield.php b/cb.usergroupsfield.php index f7921ccde332691ebe4af60206e3e8d07611315a..a7cf1b370e85f61ad5ab911cb36f60781c8fcb8d 100644 --- a/cb.usergroupsfield.php +++ b/cb.usergroupsfield.php @@ -1,6 +1,6 @@ <?php /** -* Joomla Community Builder User groups Field Type Plugin: plug_cbusergroupsfield +* Joomla Community Builder 2.x User groups Field Type Plugin: plug_cbusergroupsfield * Lets the administrator change the user's joomla groups in the CB profile in the FE. * Based on the CBfield_userparams class of the cb.core.php plugin, copyright (C) Beat, JoomlaJoe, www.joomlapolis.com and various * @version $Id$ @@ -12,9 +12,12 @@ * @final 1.2 */ + /** ensure this file is being included by a parent file */ if ( ! ( defined( '_VALID_CB' ) || defined( '_JEXEC' ) || defined( '_VALID_MOS' ) ) ) { die( 'Direct Access to this location is not allowed.' ); } +use CBLib\Application\Application; + global $_PLUGINS; $_PLUGINS->loadPluginGroup( 'user', array( (int) 1 ) ); $_PLUGINS->registerUserFieldTypes( array( 'usergroupsfield' => 'CBfield_usergroups' ) ); @@ -151,11 +154,12 @@ class CBfield_usergroups extends cbFieldHandler { if ($reason=='search') return null; - $i_am_super_admin = $_CB_framework->acl->amIaSuperAdmin(); - $canModifyUser = CBuser::getMyInstance()->authoriseAction( 'core.edit', 'com_users' ) - || CBuser::getMyInstance()->authoriseAction( 'core.edit.state', 'com_users' ); + $i_am_super_admin = Application::MyUser()->isSuperAdmin(); + // Use only the selected groups, do NOT require the group to have edit rights in the Backend! + $canModifyUser = true/*CBuser::getMyInstance()->authoriseAction( 'core.edit', 'com_users' ) + || CBuser::getMyInstance()->authoriseAction( 'core.edit.state', 'com_users' )*/; - $my_groups = $_CB_framework->acl->getGroupIds($_CB_framework->myId()); + $my_groups = Application::MyUser()->getAuthorisedGroups(false); $i_am_authorized = count(array_intersect($my_groups, $authorized_groups))>0; if ( $i_am_super_admin || ($canModifyUser && $i_am_authorized)) { @@ -203,11 +207,12 @@ class CBfield_usergroups extends cbFieldHandler { global $_CB_framework; - $i_am_super_admin = $_CB_framework->acl->amIaSuperAdmin(); - $canModifyUser = CBuser::getMyInstance()->authoriseAction( 'core.edit', 'com_users' ) - || CBuser::getMyInstance()->authoriseAction( 'core.edit.state', 'com_users' ); + $i_am_super_admin = Application::MyUser()->isSuperAdmin(); + // Use only the selected groups, do NOT require the group to have edit rights in the Backend! + $canModifyUser = true/*CBuser::getMyInstance()->authoriseAction( 'core.edit', 'com_users' ) + || CBuser::getMyInstance()->authoriseAction( 'core.edit.state', 'com_users' )*/; - $my_groups = $_CB_framework->acl->getGroupIds($_CB_framework->myId()); + $my_groups = Application::MyUser()->getAuthorisedGroups(false); $authorized_groups = $this->_explodeCBvalues($field->params->get('moderator_usergroups', '')); $i_am_authorized = count(array_intersect($my_groups, $authorized_groups))>0; diff --git a/cb.usergroupsfield.xml b/cb.usergroupsfield.xml index 61b6fd847064eccd57ed44bc267e7daeac36b0ae..a12c4482b28d13e6649693720c8bbe7bc0ab242f 100644 --- a/cb.usergroupsfield.xml +++ b/cb.usergroupsfield.xml @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> -<cbinstall version="1.0.0" type="plugin" group="user"> +<cbinstall version="1.0" type="plugin" group="user"> <name>CB Usergroups Field</name> - <author>Reiunhold Kainhofer</author> + <author>Reinhold Kainhofer</author> <creationDate>2014-01-09</creationDate> <copyright>(C) 2014 Open Tools, Reinhold Kainhofer</copyright> <license>http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU/GPL version 2 or later</license> <authorEmail>office@open-tools.net</authorEmail> <authorUrl>www.open-tools.net</authorUrl> - <version>1.2</version> + <version>2.0.0</version> <description> A Community Builder field plugin that displays the Joomla groups in the profile and lets administrator modify the groups in the profile. </description> @@ -31,7 +31,7 @@ <param name="restrict_display_selected" type="list" default="1" label="Groups display" description="Select whether the profile entry will display all group memberships or only those of the selected groups above. In any case, only the selected groups can be modified by the moderator."> <option value="0">Show all groups in profile</option> <option value="1">Restrict profile display to selected groups</option> - </param> + </param> </params> </field> </fieldtypes> @@ -45,4 +45,4 @@ </uninstall> <database> </database> -</cbinstall> \ No newline at end of file +</cbinstall> diff --git a/releases/plug_opentools_cb2_usergroupsfield_v2.0.0.zip b/releases/plug_opentools_cb2_usergroupsfield_v2.0.0.zip new file mode 100644 index 0000000000000000000000000000000000000000..0765eb2151e99b7dca1f09f76fd70e2e16159a61 Binary files /dev/null and b/releases/plug_opentools_cb2_usergroupsfield_v2.0.0.zip differ