Best practice forum (Archived)

Position link on user My Profile settings block

 
Amir Elion
Position link on user My Profile settings block
by Amir Elion - Friday, 17 May 2013, 2:13 AM
 

Using Totara 2.4.1

I am trying to make the My Profile Settings >> Positions >> Primary position menu item not appear for regular users.

I've tried removing the permission hierarchy:viewposition from authentucated user role but it still appears.

I have noticed the Site admin >> Hierarchies >> Positions >> Settings, and have unchecked Secondary and Aspirational position, so these do not appear, but do not want to uncheck primary as the help text says: "When no options are selected, the position functionality will be disabled completely."

I simply want to disallow this page view from users and to not show that settings menu item for them.

Suggestions?

Thanks,

Amir

me
Re: Position link on user My Profile settings block
by George Angus - Sunday, 19 May 2013, 8:51 PM
Group Totara

Hi Amir,

You have to comment out some code for this:

/lib/navigationlib.php

Comment out line 4063-4103

4063         //Add positions links
4064         $canview = false;
4065         if (!empty($USER->id) && ($user->id == $USER->id)) {
4066             // Can view own profile
4067             $canview = true;
4068         }
4069         elseif (has_capability('moodle/user:viewdetails', $coursecontext)) {
4070             $canview = true;
4071         }
4072         elseif (has_capability('moodle/user:viewdetails', $usercontext)) {
4073             $canview = true;
4074         }
4075
4076         $positionsenabled = get_config('totara_hierarchy', 'positionsenabled');
4077         if ($canview && $positionsenabled) {
4078             $posbaseargs['user'] = $user->id;
4079
4080             $enabled_positions = explode(',', $positionsenabled);
4081             // Get default enabled position type
4082             global $POSITION_CODES;
4083             foreach ($POSITION_CODES as $ptype => $poscode) {
4084                 if (in_array($poscode, $enabled_positions)) {
4085                     $dtype = $ptype;
4086                     break;
4087                 }
4088             }
4089             $url = new moodle_url('/user/positions.php', array_merge($posbaseargs, array('type' => $dtype)));
4090
4091             // Link to users Positions page
4092             $positions = $usersetting->add(get_string('positions', 'totara_hierarchy'), null, self::TYPE_CONTAINER);
4093
4094             require_once($CFG->dirroot . '/totara/hierarchy/prefix/position/lib.php');
4095             global $POSITION_TYPES;
4096
4097             foreach ($POSITION_TYPES as $pcode => $ptype) {
4098                 if (in_array($pcode, $enabled_positions)) {
4099                     $url = new moodle_url('/user/positions.php', array_merge($posbaseargs, array('type' => $ptype)));
4100                     $positions->add(get_string('type' . $ptype, 'totara_hierarchy'), $url, self::TYPE_USER);
4101                 }
4102             }
4103         }

 

Should do the trick!

cheers,

 

George.

Amir Elion
Re: Position link on user My Profile settings block
by Amir Elion - Sunday, 19 May 2013, 9:32 PM
 

Hi George

Thanks for the info.

However looking forward obviously a setting or at least a capability would be much preferred and more in line for stabdard approach. Most Moodle/Totara features and capabilities are handled in such a way as far as I know.

May I suggest that as a small feature request?

Thanks.

Amir

me
Re: Position link on user My Profile settings block
by George Angus - Sunday, 19 May 2013, 9:45 PM
Group Totara

Hi Amir,

Yip - Ill put one in toute suite.

cheers,

George.

Oleg Demeshev
Re: Position link on user My Profile settings block
by Oleg Demeshev - Tuesday, 21 May 2013, 9:14 PM
Group Totara

Hi Amir,

Not sure if it will help, but can you try to do the following steps:

"Site administrator" > "Users" > "Permissions" > "Define roles". Under "Manage roles" tab (first one), click on a role which you would like to change, for example "Authenticated user" link and than "Edit". Search for these setting: "View a position" and uncheck it and "Save".

Let me know if helps or not. It works for me, for my "Authenticated user".

Kind regards

Oleg

Amir Elion
Re: Position link on user My Profile settings block
by Amir Elion - Tuesday, 21 May 2013, 10:08 PM
 

Hi Oleg.

Thanks for helping out. I think I did try that, at least if I can trust what I myself wrote in the original post, but I'll give it another go just to be sure and report back.

Amir

Amir Elion
Re: Position link on user My Profile settings block
by Amir Elion - Tuesday, 21 May 2013, 10:27 PM
 

I just tried again and the link still appears for the user on the block and they can click and see their position.

Can anyone help verify it is not some local setting I got wrong?

Thanks

Amir

Oleg Demeshev
Re: Position link on user My Profile settings block
by Oleg Demeshev - Thursday, 23 May 2013, 3:09 PM
Group Totara

Hi Amir,

There was a bug in the system and I fixed it. With next release it should fix it. Are you using "Purge all caches" after the changes?

Kind regards

Oleg

Amir Elion
Re: Position link on user My Profile settings block
by Amir Elion - Thursday, 23 May 2013, 10:11 PM
 

Hi Oleg.

I did not implement any code changes only changed role definitions and admin settings so normally purge caches would not be needed. At any rate I did purge caches so it isn't that

I will wait for the next Totara release then. 

Thanks

Amir