This looks a bit too difficult.
I wish that name display and linking where done by a library function.
At the moment, the function that returns the name of the user is "fullname" in moodlelip.php
function fullname($user, $override=false)
This function returns the name of the user in the order specified by the site settings (eg. family-name>given-name, given-name>family-name, given-name) unless "override" is set, in which case *both* names are returned even if the site settings are set to return only the given (first) name.
In other words moodle has a flag to specify a 'super non-anonymous mode' (override), but no flag to specify anonymous mode.
In order to add anonymity the flag "override" could be made non-bolean, or a second flag could be added.
function fullname($user, $override=false, $anonymous=false)
But there is a second problem in that often names are linked to the users's profile. This is done at each an every point in the code, with lines like this
<a target=\"_blank\" href=\"$CFG->wwwroot/user/view.php?id=$userfrom->id&course=$course->id\">$by->name</a>";
Its seems rather redundant.
The function that displays user pictures is a little more sophisticated. This function, in lib/weblib.php
function print_user_picture($userid, $courseid, $picture, $size=0, $returnstring=false, $link=true, $target=''")
The flags include
1) Anonymity as the $picture flag. If the $picture is false then the function returns the yellow smiley. In fact the flag "$picture" is an "$non-anonymous" flag.
2) linking or non-linking of the user's picture to the user profile, the $link flag
It is interesting that Moodle allows for anonymity of images and not anonymity of name. The flag to allow pictorial anonimity, "$picture," is not even given a default value (of true).
While there is nothing to allow fullname to return "anonymous," in the case of pictures on the contrary, one has to specify "not-anonymous" ($picture=true) every time one calls this function.
It seems that, from an ethos of Moodle point of view, it is reasonable to request that ones picture is not displayed, but anyone that does not want their name displayed is a cad, and there should be no provision made for them.
Perhaps difference in the treatment of names and images is perhaps a result of "logocentrism." Logocentrism refers to a Western emphasis upon words over other information, especially images.
To reduce redundance and make moodle less logocentric it would be cool if fullname were equipped with the same flags as print_user_picture.
So it seems it would be nice if there were a function
function linkfullname($user, $course, $override=false, $anonymous=false)
function linkfullname($user, $course, $override="null")
where $override might take the values, "null" (display the name as given in the course settings) "anonymous" (display "anonymous") or "disclosure" (display the first and second name no matter what the course settings are.
The principle is simple but the my programming skills are pauce. (I thought that pauce was a word)