Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

Bulk upload of user pictures Based on .../admin/uploaduser.php and .../lib/gdlib.php

Copyright: (C) 2007 Inaki Arenaza
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 252 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 admin/tool/uploaduser/picture_form.php

Defines 4 functions


Functions that are not part of a class:

my_mktempdir($dir, $prefix='')   X-Ref
Create a unique temporary directory with a given prefix name,
inside a given directory, with given permissions. Return the
full path to the newly created temp directory.

param: string $dir where to create the temp directory.
param: string $prefix prefix for the temp directory name (default '')
return: string The full path to the temp directory.

process_directory($dir, $userfield, $overwrite, &$results)   X-Ref
Recursively process a directory, picking regular files and feeding
them to process_file().

param: string $dir the full path of the directory to process
param: string $userfield the prefix_user table field to use to
param: bool $overwrite overwrite existing picture or not.
param: array $results (by reference) accumulated statistics of
return: nothing

process_file($file, $userfield, $overwrite)   X-Ref
Given the full path of a file, try to find the user the file
corresponds to and assign him/her this file as his/her picture.
Make extensive checks to make sure we don't open any security holes
and report back any success/error.

param: string $file the full path of the file to process
param: string $userfield the prefix_user table field to use to
param: bool $overwrite overwrite existing picture or not.
return: integer either PIX_FILE_UPDATED, PIX_FILE_ERROR or

my_save_profile_image($id, $originalfile)   X-Ref
Try to save the given file (specified by its full path) as the
picture for the user with the given id.

param: integer $id the internal id of the user to assign the
param: string $originalfile the full path of the picture file.
return: mixed new unique revision number or false if not saved