Best practice forum (Archived)

Die Forendiskussion wurde entfernt

 
Dieser Forumsbeitrag wurde entfernt
Wednesday, 11 June 2014, 2:40 AM
Der Inhalt des Forumsbeitrags wurde gelöscht und kann nicht weiter angezeigt werden.
Dieser Forumsbeitrag wurde entfernt
Wednesday, 11 June 2014, 3:25 AM
Der Inhalt des Forumsbeitrags wurde gelöscht und kann nicht weiter angezeigt werden.
? ?
Re: Automatically assigning manager
von ? ? – Wednesday, 11 June 2014, 4:25 PM
 

Well, you could do that, but you would have to remember to update that code after every upgrade. And there's no guarantee it wouldn't have obscure unintended side effects in some scenarios.

Your original idea of a nightly job to fix all the new users was probably better. reportstoid is actually a link to the role_assignments table - when a user is assigned as a manager then you need to assign them as having the staffmanager role in the user context. So for the fields in role_assignments

roleid: the id of the staffmanager role

contextid: from mdl_context, id where contextlevel=30 and instanceid= user id of the subordinate

userid: the manager id (18)

In your case managerpath in pos_assignment is easy, it'll always be /18/x where x is the user id of the subordinate

As long as the pos_assignment and role_assignment records are set up properly most functionality should work OK.

Simon Coggins
Re: Automatically assigning manager
von Simon Coggins – Wednesday, 11 June 2014, 5:04 PM
Gruppe Totara

Rather than trying to hack the table at a low level, you would be better off using the assign_user_position() function. That will handle all the low level stuff like paths and role assignments. You could look at the usage in /user/position.php and write a script that makes use of it.

Simon

 

Dieser Forumsbeitrag wurde entfernt
Tuesday, 17 June 2014, 6:59 AM
Der Inhalt des Forumsbeitrags wurde gelöscht und kann nicht weiter angezeigt werden.