There are a number of groups, each maintain their own records. View; Edit: and Delete are all set to Owner.
There are also a few editors who edit the complete database. View; Edit: and Delete are set to All. If the editors update an entry the ownership remains with the original group. But if they create a record the editor group own the record.
Is it possible for the editor group to be able to set/re-set the owner.
There is a bulk change but that is only for the Admin.
Regards Barry
change record owner non-admin
- baudwalker
- Veteran Member
- Posts: 188
- Joined: 2015-02-03 08:08
- Location: Bellingen NSW Australia
Re: change record owner non-admin
Sure. You can use AppGini's
set_record_owner()
function in PHP.Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
- baudwalker
- Veteran Member
- Posts: 188
- Joined: 2015-02-03 08:08
- Location: Bellingen NSW Australia
Re: change record owner non-admin
OK, Thank you. I will attempt to implement that somehow.
regards Barry
regards Barry
- baudwalker
- Veteran Member
- Posts: 188
- Joined: 2015-02-03 08:08
- Location: Bellingen NSW Australia
Re: change record owner non-admin
Hi Jan,
I can't see how the " AppGini's set_record_owner()" can do as I want. My interpretation is that it forces the registration of a predetermined owner to that file.
What I require is a way that a group, other than the admin, can use the function "mass_change_owner" from within the "more drop down" without sharing all the admin rights.
Barry
I can't see how the " AppGini's set_record_owner()" can do as I want. My interpretation is that it forces the registration of a predetermined owner to that file.
What I require is a way that a group, other than the admin, can use the function "mass_change_owner" from within the "more drop down" without sharing all the admin rights.
Barry
Re: change record owner non-admin
Yes, it is possible by usingIs it possible for the editor group to be able to set/re-set the owner.
set_record_owner()
-function in a server side PHP script.You can create a custom "mass_change" function (AKA Batch Action) according to the docs here:... a group, other than the admin, can use the function "mass_change_owner" from within the "more drop down
https://bigprof.com/appgini/help/advanc ... ch-actions
In your serverside code use
set_record_owner()
-function according to your needs.Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
- baudwalker
- Veteran Member
- Posts: 188
- Joined: 2015-02-03 08:08
- Location: Bellingen NSW Australia
Re: change record owner non-admin
Thanks Jan,
I will take a look at your suggestions.
I just thought there may have been a way of extending the existing "change owner" for the admin to and extra group. save reinventing the wheel so to speak.
Regards Barry
I will take a look at your suggestions.
I just thought there may have been a way of extending the existing "change owner" for the admin to and extra group. save reinventing the wheel so to speak.
Regards Barry
- baudwalker
- Veteran Member
- Posts: 188
- Joined: 2015-02-03 08:08
- Location: Bellingen NSW Australia
Re: change record owner non-admin
I an attempting to implement the admin batch action for changing ownership of one or several records. in the hooks/tablename.php I have added the following, and restrict it to a specific group.
This calls the function "mass_change_owner" from common.js.
All goes well. The title appears in the more dropdown only for the specific group. When the title is selected the modal pops up and looks exactly the same as it does with the admin, but it is not populated with the group/user information.
what am I missing?
Code: Select all
function Members_batch_actions(&$args){
$mi = getMemberInfo();
if(in_array($mi['group'], array('editor'))){
return array(
array(
'title' => 'Change Owner',
'function' => 'mass_change_owner',
'icon' => 'glyphicon glyphicon-user'
)
);
}
All goes well. The title appears in the more dropdown only for the specific group. When the title is selected the modal pops up and looks exactly the same as it does with the admin, but it is not populated with the group/user information.
what am I missing?
Re: change record owner non-admin
Hi,
you cannot use the mass_change_owner as a normal user. This requires admin privileges .
So what you can do is to create your own mass_change_owner for the user.
As you did already in your code. Change
Now lets add the own my_mass_change_owner function.
1, copy the code from the mass_change_owner function within the common.js to the hooks/Members-tv.js file.
2, rename the mass_change_owner function to my_mass_change_owner
within this code in the hooks/Members-tv.js file:
3, search for admin/pageEditOwnership.php in the update_record function (around line 58) and replace it with hooks/MypageEditOwnership.php
4, search for admin/getUsers.php in the populate_new_owner_dropdown function (around line 128) and replace it with hooks/MygetUsers.php
5, copy the admin/getUsers.php file to hooks/MygetUsers.php
6, edit hooks/MygetUsers.php and replace require("{$curr_dir}/incCommon.php"); with require("{$curr_dir}/../lib.php");
7, copy the admin/pageEditOwnership.php file to hooks/MypageEditOwnership.php
8, edit hooks/MypageEditOwnership.php and replace require("{$currDir}/incCommon.php"); with require("{$currDir}/../lib.php");
Now you should be able to use the new feature.
WARNING: This is a quick fix and you may need to add additional security in order to prevent unwanted people to call your new functions.
you cannot use the mass_change_owner as a normal user. This requires admin privileges .
So what you can do is to create your own mass_change_owner for the user.
As you did already in your code. Change
Code: Select all
return array(
array(
'title' => 'Change Owner',
'function' => 'my_mass_change_owner', // <---changed to my_mass_change_owner
'icon' => 'glyphicon glyphicon-user'
)
);
1, copy the code from the mass_change_owner function within the common.js to the hooks/Members-tv.js file.
2, rename the mass_change_owner function to my_mass_change_owner
within this code in the hooks/Members-tv.js file:
3, search for admin/pageEditOwnership.php in the update_record function (around line 58) and replace it with hooks/MypageEditOwnership.php
4, search for admin/getUsers.php in the populate_new_owner_dropdown function (around line 128) and replace it with hooks/MygetUsers.php
5, copy the admin/getUsers.php file to hooks/MygetUsers.php
6, edit hooks/MygetUsers.php and replace require("{$curr_dir}/incCommon.php"); with require("{$curr_dir}/../lib.php");
7, copy the admin/pageEditOwnership.php file to hooks/MypageEditOwnership.php
8, edit hooks/MypageEditOwnership.php and replace require("{$currDir}/incCommon.php"); with require("{$currDir}/../lib.php");
Now you should be able to use the new feature.
WARNING: This is a quick fix and you may need to add additional security in order to prevent unwanted people to call your new functions.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
- baudwalker
- Veteran Member
- Posts: 188
- Joined: 2015-02-03 08:08
- Location: Bellingen NSW Australia
Re: change record owner non-admin
Works perfectly thank you.
I did copy and rename the files but I did not change incCommon.php to ../lib.php.
Thanks to you and Jan for taking the time to point my in the correct direction.
Barry
I did copy and rename the files but I did not change incCommon.php to ../lib.php.
Thanks to you and Jan for taking the time to point my in the correct direction.
Barry
- baudwalker
- Veteran Member
- Posts: 188
- Joined: 2015-02-03 08:08
- Location: Bellingen NSW Australia
Re: change record owner non-admin
These two arrays work separately (ONE & TWO) or together (Three) but with (FOUR) I get the error "unexpected 'if' (T_IF) in ..."
What am I doing wrong in FOUR please?
Barry
ONE
TWO
THREE
FOUR
What am I doing wrong in FOUR please?
Barry
ONE
Code: Select all
function Members_batch_actions(&$args){
$mi = getMemberInfo();
if(in_array($mi['group'], array('editor'))){
return array(
array(
'title' => 'Change Owner',
'function' => 'mass_change_owner',
'icon' => 'glyphicon glyphicon-user'
)
);
}
Code: Select all
function Members_batch_actions(&$args){
return array(
array(
'title'=> 'Renew Membership Year',
'function' => 'renew_membership_year',
'icon' => 'check',
)
);
}
Code: Select all
function Members_batch_actions(&$args){
return array(
array(
'title'=> 'Renew Membership Year',
'function' => 'renew_membership_year',
'icon' => 'check',
),
array(
'title' => 'Change Owner',
'function' => 'my_mass_change_owner',
'icon' => 'glyphicon glyphicon-user',
)
);
}
Code: Select all
function Members_batch_actions(&$args){
return array(
array(
'title'=> 'Renew Membership Year',
'function' => 'renew_membership_year',
'icon' => 'check',
),
($mi = getMemberInfo()
if(in_array($mi['group'], array('editor'))){
array(
'title' => 'Change Owner',
'function' => 'my_mass_change_owner',
'icon' => 'glyphicon glyphicon-user',
)
}
);
}
- baudwalker
- Veteran Member
- Posts: 188
- Joined: 2015-02-03 08:08
- Location: Bellingen NSW Australia
Re: change record owner non-admin
OK got it working
Code: Select all
function Members_batch_actions(&$args){
$mi = getMemberInfo();
if(in_array($mi['group'], array('editor'))){
return array(
array(
'title'=> 'Renew Membership Year',
'function' => 'renew_membership_year',
'icon' => 'check',
),
array(
'title' => 'Change Owner',
'function' => 'my_mass_change_owner',
'icon' => 'glyphicon glyphicon-user',
)
);
}else{
return array(
array(
'title'=> 'Renew Membership Year',
'function' => 'renew_membership_year',
'icon' => 'check',
)
);
}
}