]> git.mjollnir.org Git - moodle.git/commit
weblib: print_user()/print_user_picture() optimisations
authormartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:19:35 +0000 (07:19 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:19:35 +0000 (07:19 +0000)
commitaebfa1546edfb5ddeceb8014d6123349c14c98cd
tree75e54d77c587a9dbcda8d87d276c1d5626617cbf
parent1cf2e21b6e0816ddba2b59fa96d7ba178cf63117
weblib: print_user()/print_user_picture() optimisations

print_user_picture() was forcing an unneeded dbquery
if you need an imagealt. And who doesn't need one these days.

So - teach print_user_picture() to take either $userid
_or_ $userobj as the first parameter. If that first
parameter has the fields we need, never touch the db.

In other words, only touch the DB as a last resort.

There is a bit of ugliness in testing whether we have
the fields or not, because these fields are inconsistently
with/without NOT NULL in the DB definitions. So we cannot
use isset() because it barfs on nulls. And we cannot use empty()
because it will match both on "missing key" and ''.

And while at it, silence warnings that we are missing string
for the year(s). Also fixes a missing string bug in really boring
courses that noone's visitied in many years ;-)
lib/weblib.php