From 6c7a5df7a3fd0071ba0ef417b051f1f0ff4a1025 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Mon, 17 May 2010 15:16:33 +0000 Subject: [PATCH] MDL-21695 Upload pictures and upload users - strings cleanup and fixing Strings related to users uploading moved into admin.php component. Fixed calling of new help strings. Fixed incorrect strings call. The script also copies instructions from two previous commits as I forgot that the commit must touch some string file to being parsed by amos. AMOS BEGIN HLP uploadusers3.html,[uploadusers_help,core_admin] HLP uploadusers2.html,[uploadusers_help,core_admin] HLP uploadusers.html,[uploadusers_help,core_admin] HLP uploadpictures.html,[uploadpictures_help,core_admin] MOV [uploadusers,core],[uploadusers,core_admin] MOV [uploadusers_help,core],[uploadusers_help,core_admin] HLP cookies.html,[cookiesenabled_help,core] HLP overrides.html,[overridepermissions_help,core_role] HLP permissions.html,[permission_help,core_role] AMOS END --- admin/settings/users.php | 2 +- admin/uploadpicture.php | 4 +- admin/uploaduser.php | 4 +- admin/uploaduser_form.php | 6 +-- lang/en/admin.php | 8 +++ lang/en/error.php | 1 + lang/en/help/uploadpictures.html | 5 -- lang/en/help/uploadusers3.html | 84 -------------------------------- lang/en/moodle.php | 8 --- 9 files changed, 17 insertions(+), 105 deletions(-) delete mode 100644 lang/en/help/uploadpictures.html delete mode 100755 lang/en/help/uploadusers3.html diff --git a/admin/settings/users.php b/admin/settings/users.php index 800d34e7d74..7a934a746ae 100644 --- a/admin/settings/users.php +++ b/admin/settings/users.php @@ -74,7 +74,7 @@ if ($hassiteconfig $ADMIN->add('accounts', new admin_externalpage('editusers', get_string('userlist','admin'), "$CFG->wwwroot/$CFG->admin/user.php", array('moodle/user:update', 'moodle/user:delete'))); $ADMIN->add('accounts', new admin_externalpage('userbulk', get_string('userbulk','admin'), "$CFG->wwwroot/$CFG->admin/user/user_bulk.php", array('moodle/user:update', 'moodle/user:delete'))); $ADMIN->add('accounts', new admin_externalpage('addnewuser', get_string('addnewuser'), "$securewwwroot/user/editadvanced.php?id=-1", 'moodle/user:create')); - $ADMIN->add('accounts', new admin_externalpage('uploadusers', get_string('uploadusers'), "$CFG->wwwroot/$CFG->admin/uploaduser.php", 'moodle/site:uploadusers')); + $ADMIN->add('accounts', new admin_externalpage('uploadusers', get_string('uploadusers', 'admin'), "$CFG->wwwroot/$CFG->admin/uploaduser.php", 'moodle/site:uploadusers')); $ADMIN->add('accounts', new admin_externalpage('uploadpictures', get_string('uploadpictures','admin'), "$CFG->wwwroot/$CFG->admin/uploadpicture.php", 'moodle/site:uploadusers')); $ADMIN->add('accounts', new admin_externalpage('profilefields', get_string('profilefields','admin'), "$CFG->wwwroot/user/profile/index.php", 'moodle/site:config')); $ADMIN->add('accounts', new admin_externalpage('cohorts', get_string('cohorts', 'cohort'), $CFG->wwwroot . '/cohort/index.php', array('moodle/cohort:manage', 'moodle/cohort:view'))); diff --git a/admin/uploadpicture.php b/admin/uploadpicture.php index 9d32896360a..bfdd756feee 100644 --- a/admin/uploadpicture.php +++ b/admin/uploadpicture.php @@ -44,7 +44,7 @@ if (!$adminuser = get_admin()) { $strfile = get_string('file'); $struser = get_string('user'); -$strusersupdated = get_string('usersupdated'); +$strusersupdated = get_string('usersupdated', 'admin'); $struploadpictures = get_string('uploadpictures','admin'); $userfields = array ( @@ -58,7 +58,7 @@ $overwritepicture = optional_param('overwritepicture', 0, PARAM_BOOL); /// Print the header echo $OUTPUT->header(); -echo $OUTPUT->heading_with_help($struploadpictures, 'uploadpictures'); +echo $OUTPUT->heading_with_help($struploadpictures, 'uploadpictures', 'admin'); $mform = new admin_uploadpicture_form(null, $userfields); if ($formdata = $mform->get_data()) { diff --git a/admin/uploaduser.php b/admin/uploaduser.php index 31c8bf61e03..c58c998b061 100755 --- a/admin/uploaduser.php +++ b/admin/uploaduser.php @@ -113,7 +113,7 @@ if (empty($iid)) { } else { echo $OUTPUT->header(); - echo $OUTPUT->heading_with_help(get_string('uploadusers'), 'uploadusers3'); + echo $OUTPUT->heading_with_help(get_string('uploadusers', 'admin'), 'uploadusers', 'admin'); $mform->display(); echo $OUTPUT->footer(); @@ -759,7 +759,7 @@ echo $OUTPUT->header(); /// Print the form -echo $OUTPUT->heading_with_help(get_string('uploaduserspreview', 'admin'), 'uploadusers2'); +echo $OUTPUT->heading(get_string('uploaduserspreview', 'admin')); $cir->init(); diff --git a/admin/uploaduser_form.php b/admin/uploaduser_form.php index d2bd97476c5..892e71804e4 100644 --- a/admin/uploaduser_form.php +++ b/admin/uploaduser_form.php @@ -43,8 +43,8 @@ class admin_uploaduser_form1 extends moodleform { UU_ADD_UPDATE => get_string('uuoptype_addupdate', 'admin'), UU_UPDATE => get_string('uuoptype_update', 'admin')); $mform->addElement('select', 'uutype', get_string('uuoptype', 'admin'), $choices); - - $this->add_action_buttons(false, get_string('uploadusers')); + + $this->add_action_buttons(false, get_string('uploadusers', 'admin')); } } @@ -266,7 +266,7 @@ class admin_uploaduser_form2 extends moodleform { $mform->addElement('hidden', 'uutype'); $mform->setType('uutype', PARAM_INT); - $this->add_action_buttons(true, get_string('uploadusers')); + $this->add_action_buttons(true, get_string('uploadusers', 'admin')); } /** diff --git a/lang/en/admin.php b/lang/en/admin.php index 64246d5b79d..67b1d96d9a0 100755 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -969,6 +969,14 @@ $string['uploadpicture_userfield'] = 'User attribute to use to match pictures:'; $string['uploadpicture_usernotfound'] = 'User with a \'{$a->userfield}\' value of \'{$a->uservalue}\' does not exist. Skipping.'; $string['uploadpicture_userskipped'] = 'Skipping user {$a} (already has a picture).'; $string['uploadpicture_userupdated'] = 'Picture updated for user {$a}.'; +$string['uploadusers'] = 'Upload users'; +$string['uploadusers_help'] = 'Users may be uploaded (and optionally enrolled in courses) via text file. The format of the file should be as follows: + +* Each line of the file contains one record +* Each record is a series of data separated by commas (or other delimiters) +* The first record contains a list of fieldnames defining the format of the rest of the file +* Required fieldnames are username, password, firstname, lastname, email'; +$string['uploadusers_link'] = 'admin/uploaduser'; $string['uploaduserspreview'] = 'Upload users preview'; $string['uploadusersresult'] = 'Upload users results'; $string['upwards'] = 'upwards'; diff --git a/lang/en/error.php b/lang/en/error.php index 589adab5515..8ef615d0639 100755 --- a/lang/en/error.php +++ b/lang/en/error.php @@ -483,6 +483,7 @@ $string['usernotaddedadmin'] = 'Cannot delete admin accounts'; $string['usernotaddederror'] = 'User not added - error'; $string['usernotaddedregistered'] = 'User not added - already registered'; $string['usernotavailable'] = 'The details of this user are not available to you'; +$string['usernotdeletedadmin'] = 'User not deleted - can not delete administrator accounts'; $string['usernotdeletederror'] = 'User not deleted - error'; $string['usernotdeletedmissing'] = 'User not deleted - could not find the username'; $string['usernotdeletedoff'] = 'User not deleted - deleting not allowed'; diff --git a/lang/en/help/uploadpictures.html b/lang/en/help/uploadpictures.html deleted file mode 100644 index d2b67493092..00000000000 --- a/lang/en/help/uploadpictures.html +++ /dev/null @@ -1,5 +0,0 @@ -

Upload user pictures

- -

User pictures can be uploaded as a zip file of image files. The image files should be named chosen-user-attribute.extension. For example, if the chosen user attribute used to match pictures is username and the username is user1234, then the filename would be user1234.jpg.

-

Image types supported include gif, jpg, and png.

-

Image file names are not case sensitive.

\ No newline at end of file diff --git a/lang/en/help/uploadusers3.html b/lang/en/help/uploadusers3.html deleted file mode 100755 index 66ff1a7bd07..00000000000 --- a/lang/en/help/uploadusers3.html +++ /dev/null @@ -1,84 +0,0 @@ -

Upload users

- -

Firstly, note that it is usually not necessary to import users in bulk - to keep your own maintenance work down -you should first explore forms of authentication that do not require manual maintenance, such as connecting to existing external -databases or letting the users create their own accounts. See the Authentication section in the admin menus.

-

If you are sure you want to import multiple user accounts from a text file, then you need to format your text file as follows:

- - -

Here is an example of a valid import file:

-

username, password, firstname, lastname, email, lang, idnumber, maildisplay, course1, group1, type1, enrolperiod1
-jonest, verysecret, Tom, Jones, jonest@someplace.edu, en, 3663737, 1, Intro101, Section 1, 1, 30
-reznort, somesecret, Trent, Reznor, reznort@someplace.edu, en_us, 6736733, 0, Advanced202, Section 3, 3, 90 -

- -

Templates

-

The default values are processed as templates in which the following codes are allowed:

- -

Between the percent sign (%) and any code letter (l, f or u) the following modifiers are allowed:

- - -

For example, if the firstname is John and the lastname is Doe, the following values will be obtained with the specified templates:

- -

Template processing is done only on default values, and not on the values retrieved from the CSV file.

-

In order to create correct Moodle usernames, the username is always converted to lowercase. Moreover, if the "Allow extended characters in usernames" option in the Site policies page is off, characters different to letters, digits, dash (-) and dot (.) are removed. -For example if the firstname is John Jr. and the lastname is Doe, the username %-f_%-l will produce john jr._doe when Allow extended characters in usernames is on, and johnjr.doe when off.

-

When the "New username duplicate handling" setting is set to Append counter, an auto-increment counter will be append to duplicate usernames produced by the template. -For example, if the CSV file contains the users named John Doe, Jane Doe and Jenny Doe without explicit usernames, the default username is %-1f%-l and New username duplicate handling is set to Append counter, then the usernames produced will be jdoe, jdoe2 and jdoe3. -

- -

Updating existing accounts

- -

By default Moodle assumes that you will be creating new user accounts, and skips records where the username matches an existing account. However, if you allow updating, the existing user account will be updated.

- -

When updating existing accounts you can change usernames as well. Set "Allow renames" to Yes and include in your file a field called oldusername.

- -

Warning: any errors updating existing accounts can affect your users badly. Be careful when using the options to update.

- -

Deleting accounts

-

If the deleted field is present, users with value 1 for it will be deleted. In this case, all the fields may be omitted, except for username.

-

Deleting and uploading accounts could be done with a single CSV file. For example, the following file will add the user Tom Jones and delete the user reznort:

-

username, firstname, lastname, deleted
-jonest, Tom, Jones, 0
-reznort, , , 1 -

diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 170404a6930..01c7797d703 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -1763,14 +1763,6 @@ $string['uploadrenamedcollision'] = 'File was renamed from {$a->oldname} to {$a- $string['uploadrenamedchars'] = 'File was renamed from {$a->oldname} to {$a->newname} because of invalid characters.'; $string['uploadserverlimit'] = 'Uploaded file exceeded the maximum size limit set by the server'; $string['uploadthisfile'] = 'Upload this file'; -$string['uploadusers'] = 'Upload users'; -$string['uploadusers_help'] = 'Users may be uploaded (and optionally enrolled in courses) via text file. The format of the file should be as follows: - -* Each line of the file contains one record -* Each record is a series of data separated by commas (or other delimiters) -* The first record contains a list of fieldnames defining the format of the rest of the file -* Required fieldnames are username, password, firstname, lastname, email'; -$string['uploadusers_link'] = 'admin/uploaduser'; $string['url'] = 'URL'; $string['used'] = 'Used'; $string['usedinnplaces'] = 'Used in {$a} places';