Skip to content

Commit

Permalink
MDL-29029 move user upload to admin tools
Browse files Browse the repository at this point in the history
AMOS BEGIN
 MOV [uploadpictures,core_admin],[uploadpictures,tool_uploaduser]
 MOV [uploadpictures_help,core_admin],[uploadpictures_help,tool_uploaduser]
 MOV [uploadusers,core_admin],[uploadusers,tool_uploaduser]
 MOV [uploadusers_help,core_admin],[uploadusers_help,tool_uploaduser]
 MOV [uploaduserspreview,core_admin],[uploaduserspreview,tool_uploaduser]
 MOV [uploadusersresult,core_admin],[uploadusersresult,tool_uploaduser]
 MOV [uucsvline,core_admin],[uucsvline,tool_uploaduser]
 MOV [userrenamed,core_admin],[userrenamed,tool_uploaduser]
 MOV [useraccountupdated,core_admin],[useraccountupdated,tool_uploaduser]
 MOV [useraccountuptodate,core_admin],[useraccountuptodate,tool_uploaduser]
 MOV [userdeleted,core_admin],[userdeleted,tool_uploaduser]
 MOV [uupasswordcron,core_admin],[uupasswordcron,tool_uploaduser]
 MOV [userscreated,core_admin],[userscreated,tool_uploaduser]
 MOV [usersupdated,core_admin],[usersupdated,tool_uploaduser]
 MOV [usersdeleted,core_admin],[usersdeleted,tool_uploaduser]
 MOV [deleteerrors,core_admin],[deleteerrors,tool_uploaduser]
 MOV [usersrenamed,core_admin],[usersrenamed,tool_uploaduser]
 MOV [renameerrors,core_admin],[renameerrors,tool_uploaduser]
 MOV [usersskipped,core_admin],[usersskipped,tool_uploaduser]
 MOV [usersweakpassword,core_admin],[usersweakpassword,tool_uploaduser]
 MOV [errors,core_admin],[errors,tool_uploaduser]
 MOV [csvdelimiter,core_admin],[csvdelimiter,tool_uploaduser]
 MOV [encoding,core_admin],[encoding,tool_uploaduser]
 MOV [rowpreviewnum,core_admin],[rowpreviewnum,tool_uploaduser]
 MOV [uuoptype_addinc,core_admin],[uuoptype_addinc,tool_uploaduser]
 MOV [uuoptype_addnew,core_admin],[uuoptype_addnew,tool_uploaduser]
 MOV [uuoptype_addupdate,core_admin],[uuoptype_addupdate,tool_uploaduser]
 MOV [uuoptype_update,core_admin],[uuoptype_update,tool_uploaduser]
 MOV [uuoptype,core_admin],[uuoptype,tool_uploaduser]
 MOV [uupasswordnew,core_admin],[uupasswordnew,tool_uploaduser]
 MOV [uupasswordold,core_admin],[uupasswordold,tool_uploaduser]
 MOV [nochanges,core_admin],[nochanges,tool_uploaduser]
 MOV [uuupdateall,core_admin],[uuupdateall,tool_uploaduser]
 MOV [uuupdatefromfile,core_admin],[uuupdatefromfile,tool_uploaduser]
 MOV [uuupdatemissing,core_admin],[uuupdatemissing,tool_uploaduser]
 MOV [uuupdatetype,core_admin],[uuupdatetype,tool_uploaduser]
 MOV [allowrenames,core_admin],[allowrenames,tool_uploaduser]
 MOV [allowdeletes,core_admin],[allowdeletes,tool_uploaduser]
 MOV [uunoemailduplicates,core_admin],[uunoemailduplicates,tool_uploaduser]
 MOV [uustandardusernames,core_admin],[uustandardusernames,tool_uploaduser]
 MOV [uubulk,core_admin],[uubulk,tool_uploaduser]
 MOV [uubulkall,core_admin],[uubulkall,tool_uploaduser]
 MOV [uubulknew,core_admin],[uubulknew,tool_uploaduser]
 MOV [uubulkupdated,core_admin],[uubulkupdated,tool_uploaduser]
 MOV [uulegacy1role,core_admin],[uulegacy1role,tool_uploaduser]
 MOV [uulegacy2role,core_admin],[uulegacy2role,tool_uploaduser]
 MOV [uulegacy3role,core_admin],[uulegacy3role,tool_uploaduser]
 MOV [defaultvalues,core_admin],[defaultvalues,tool_uploaduser]
 MOV [uuusernametemplate,core_admin],[uuusernametemplate,tool_uploaduser]
 MOV [requiredtemplate,core_admin],[requiredtemplate,tool_uploaduser]
 MOV [uploadpicture_baduserfield,core_admin],[uploadpicture_baduserfield,tool_uploaduser]
 MOV [uploadpicture_cannotmovezip,core_admin],[uploadpicture_cannotmovezip,tool_uploaduser]
 MOV [uploadpicture_cannotprocessdir,core_admin],[uploadpicture_cannotprocessdir,tool_uploaduser]
 MOV [uploadpicture_cannotsave,core_admin],[uploadpicture_cannotsave,tool_uploaduser]
 MOV [uploadpicture_cannotunzip,core_admin],[uploadpicture_cannotunzip,tool_uploaduser]
 MOV [uploadpicture_invalidfilename,core_admin],[uploadpicture_invalidfilename,tool_uploaduser]
 MOV [uploadpicture_overwrite,core_admin],[uploadpicture_overwrite,tool_uploaduser]
 MOV [uploadpicture_userfield,core_admin],[uploadpicture_userfield,tool_uploaduser]
 MOV [uploadpicture_usernotfound,core_admin],[uploadpicture_usernotfound,tool_uploaduser]
 MOV [uploadpicture_userskipped,core_admin],[uploadpicture_userskipped,tool_uploaduser]
 MOV [uploadpicture_userupdated,core_admin],[uploadpicture_userupdated,tool_uploaduser]
AMOS END
  • Loading branch information
skodak committed Sep 18, 2011
1 parent 0715e3d commit ce15d56
Show file tree
Hide file tree
Showing 12 changed files with 316 additions and 211 deletions.
3 changes: 0 additions & 3 deletions admin/settings/users.php
Expand Up @@ -6,7 +6,6 @@
$ADMIN->add('users', new admin_category('roles', get_string('permissions', 'role')));

if ($hassiteconfig
or has_capability('moodle/site:uploadusers', $systemcontext)
or has_capability('moodle/user:create', $systemcontext)
or has_capability('moodle/user:update', $systemcontext)
or has_capability('moodle/user:delete', $systemcontext)
Expand All @@ -25,8 +24,6 @@
$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', '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')));

Expand Down
52 changes: 26 additions & 26 deletions admin/uploaduser.php → admin/tool/uploaduser/index.php
Expand Up @@ -17,20 +17,20 @@
/**
* Bulk user registration script from a comma separated file
*
* @package core
* @subpackage admin
* @package tool
* @subpackage uploaduser
* @copyright 2004 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

require('../config.php');
require('../../../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/csvlib.class.php');
require_once($CFG->dirroot.'/user/profile/lib.php');
require_once($CFG->dirroot.'/group/lib.php');
require_once($CFG->dirroot.'/cohort/lib.php');
require_once('uploaduserlib.php');
require_once('uploaduser_form.php');
require_once('locallib.php');
require_once('user_form.php');

$iid = optional_param('iid', '', PARAM_INT);
$previewrows = optional_param('previewrows', 10, PARAM_INT);
Expand All @@ -39,27 +39,27 @@
raise_memory_limit(MEMORY_HUGE);

require_login();
admin_externalpage_setup('uploadusers');
admin_externalpage_setup('tooluploaduser');
require_capability('moodle/site:uploadusers', get_context_instance(CONTEXT_SYSTEM));

$struserrenamed = get_string('userrenamed', 'admin');
$struserrenamed = get_string('userrenamed', 'tool_uploaduser');
$strusernotrenamedexists = get_string('usernotrenamedexists', 'error');
$strusernotrenamedmissing = get_string('usernotrenamedmissing', 'error');
$strusernotrenamedoff = get_string('usernotrenamedoff', 'error');
$strusernotrenamedadmin = get_string('usernotrenamedadmin', 'error');

$struserupdated = get_string('useraccountupdated', 'admin');
$struserupdated = get_string('useraccountupdated', 'tool_uploaduser');
$strusernotupdated = get_string('usernotupdatederror', 'error');
$strusernotupdatednotexists = get_string('usernotupdatednotexists', 'error');
$strusernotupdatedadmin = get_string('usernotupdatedadmin', 'error');

$struseruptodate = get_string('useraccountuptodate', 'admin');
$struseruptodate = get_string('useraccountuptodate', 'tool_uploaduser');

$struseradded = get_string('newuser');
$strusernotadded = get_string('usernotaddedregistered', 'error');
$strusernotaddederror = get_string('usernotaddederror', 'error');

$struserdeleted = get_string('userdeleted', 'admin');
$struserdeleted = get_string('userdeleted', 'tool_uploaduser');
$strusernotdeletederror = get_string('usernotdeletederror', 'error');
$strusernotdeletedmissing = get_string('usernotdeletedmissing', 'error');
$strusernotdeletedoff = get_string('usernotdeletedoff', 'error');
Expand All @@ -73,7 +73,7 @@
$strinvalidpasswordpolicy = get_string('invalidpasswordpolicy', 'error');
$errorstr = get_string('error');

$returnurl = new moodle_url('/admin/uploaduser.php');
$returnurl = new moodle_url('/admin/tool/uploaduser/index.php');
$bulknurl = new moodle_url('/admin/user/user_bulk.php');

$today = time();
Expand Down Expand Up @@ -124,7 +124,7 @@
} else {
echo $OUTPUT->header();

echo $OUTPUT->heading_with_help(get_string('uploadusers', 'admin'), 'uploadusers', 'admin');
echo $OUTPUT->heading_with_help(get_string('uploadusers', 'tool_uploaduser'), 'uploadusers', 'tool_uploaduser');

$mform1->display();
echo $OUTPUT->footer();
Expand All @@ -145,7 +145,7 @@
} else if ($formdata = $mform2->get_data()) {
// Print the header
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('uploadusersresult', 'admin'));
echo $OUTPUT->heading(get_string('uploadusersresult', 'tool_uploaduser'));

$optype = $formdata->uutype;

Expand Down Expand Up @@ -647,7 +647,7 @@
if ($createpasswords) {
$user->password = 'to be generated';
$upt->track('password', '', 'normal', false);
$upt->track('password', get_string('uupasswordcron', 'admin'), 'warning', false);
$upt->track('password', get_string('uupasswordcron', 'tool_uploaduser'), 'warning', false);
} else {
$upt->track('password', '', 'normal', false);
$upt->track('password', get_string('missingfield', 'error', 'password'), 'error');
Expand Down Expand Up @@ -889,24 +889,24 @@
echo $OUTPUT->box_start('boxwidthnarrow boxaligncenter generalbox', 'uploadresults');
echo '<p>';
if ($optype != UU_USER_UPDATE) {
echo get_string('userscreated', 'admin').': '.$usersnew.'<br />';
echo get_string('userscreated', 'tool_uploaduser').': '.$usersnew.'<br />';
}
if ($optype == UU_USER_UPDATE or $optype == UU_USER_ADD_UPDATE) {
echo get_string('usersupdated', 'admin').': '.$usersupdated.'<br />';
echo get_string('usersupdated', 'tool_uploaduser').': '.$usersupdated.'<br />';
}
if ($allowdeletes) {
echo get_string('usersdeleted', 'admin').': '.$deletes.'<br />';
echo get_string('deleteerrors', 'admin').': '.$deleteerrors.'<br />';
echo get_string('usersdeleted', 'tool_uploaduser').': '.$deletes.'<br />';
echo get_string('deleteerrors', 'tool_uploaduser').': '.$deleteerrors.'<br />';
}
if ($allowrenames) {
echo get_string('usersrenamed', 'admin').': '.$renames.'<br />';
echo get_string('renameerrors', 'admin').': '.$renameerrors.'<br />';
echo get_string('usersrenamed', 'tool_uploaduser').': '.$renames.'<br />';
echo get_string('renameerrors', 'tool_uploaduser').': '.$renameerrors.'<br />';
}
if ($usersskipped) {
echo get_string('usersskipped', 'admin').': '.$usersskipped.'<br />';
echo get_string('usersskipped', 'tool_uploaduser').': '.$usersskipped.'<br />';
}
echo get_string('usersweakpassword', 'admin').': '.$weakpasswords.'<br />';
echo get_string('errors', 'admin').': '.$userserrors.'</p>';
echo get_string('usersweakpassword', 'tool_uploaduser').': '.$weakpasswords.'<br />';
echo get_string('errors', 'tool_uploaduser').': '.$userserrors.'</p>';
echo $OUTPUT->box_end();

if ($bulk) {
Expand All @@ -921,7 +921,7 @@
// Print the header
echo $OUTPUT->header();

echo $OUTPUT->heading(get_string('uploaduserspreview', 'admin'));
echo $OUTPUT->heading(get_string('uploaduserspreview', 'tool_uploaduser'));

// NOTE: this is JUST csv processing preview, we must not prevent import from here if there is something in the file!!
// this was intended for validation of csv formatting and encoding, not filtering the data!!!!
Expand Down Expand Up @@ -980,11 +980,11 @@
$table->id = "uupreview";
$table->attributes['class'] = 'generaltable';
$table->tablealign = 'center';
$table->summary = get_string('uploaduserspreview', 'admin');
$table->summary = get_string('uploaduserspreview', 'tool_uploaduser');
$table->head = array();
$table->data = $data;

$table->head[] = get_string('uucsvline', 'admin');
$table->head[] = get_string('uucsvline', 'tool_uploaduser');
foreach ($filecolumns as $column) {
$table->head[] = $column;
}
Expand Down
92 changes: 92 additions & 0 deletions admin/tool/uploaduser/lang/en/tool_uploaduser.php
@@ -0,0 +1,92 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Strings for component 'tool_uploaduser', language 'en', branch 'MOODLE_22_STABLE'
*
* @package tool
* @subpackage uploaduser
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['allowdeletes'] = 'Allow deletes';
$string['allowrenames'] = 'Allow renames';
$string['csvdelimiter'] = 'CSV delimiter';
$string['defaultvalues'] = 'Default values';
$string['deleteerrors'] = 'Delete errors';
$string['encoding'] = 'Encoding';
$string['errors'] = 'Errors';
$string['nochanges'] = 'No changes';
$string['pluginname'] = 'User upload';
$string['renameerrors'] = 'Rename errors';
$string['requiredtemplate'] = 'Required. You may use template syntax here (%l = lastname, %f = firstname, %u = username). See help for details and examples.';
$string['rowpreviewnum'] = 'Preview rows';
$string['uploadpicture_baduserfield'] = 'The user attribute specified is not valid. Please, try again.';
$string['uploadpicture_cannotmovezip'] = 'Cannot move zip file to temporary directory.';
$string['uploadpicture_cannotprocessdir'] = 'Cannot process unzipped files.';
$string['uploadpicture_cannotsave'] = 'Cannot save picture for user {$a}. Check original picture file.';
$string['uploadpicture_cannotunzip'] = 'Cannot unzip pictures file.';
$string['uploadpicture_invalidfilename'] = 'Picture file {$a} has invalid characters in its name. Skipping.';
$string['uploadpicture_overwrite'] = 'Overwrite existing user pictures?';
$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['uploadpictures'] = 'Upload user pictures';
$string['uploadpictures_help'] = 'User pictures can be uploaded as a zip file of image files. The image files should be named chosen-user-attribute.extension, for example user1234.jpg for a user with username user1234.';
$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['uploaduserspreview'] = 'Upload users preview';
$string['uploadusersresult'] = 'Upload users results';
$string['useraccountupdated'] = 'User updated';
$string['useraccountuptodate'] = 'User up-to-date';
$string['userdeleted'] = 'User deleted';
$string['userrenamed'] = 'User renamed';
$string['userscreated'] = 'Users created';
$string['usersdeleted'] = 'Users deleted';
$string['usersrenamed'] = 'Users renamed';
$string['usersskipped'] = 'Users skipped';
$string['usersupdated'] = 'Users updated';
$string['usersweakpassword'] = 'Users having a weak password';
$string['uubulk'] = 'Select for bulk operations';
$string['uubulkall'] = 'All users';
$string['uubulknew'] = 'New users';
$string['uubulkupdated'] = 'Updated users';
$string['uucsvline'] = 'CSV line';
$string['uulegacy1role'] = '(Original Student) typeN=1';
$string['uulegacy2role'] = '(Original Teacher) typeN=2';
$string['uulegacy3role'] = '(Original Non-editing teacher) typeN=3';
$string['uunoemailduplicates'] = 'Prevent email address duplicates';
$string['uuoptype'] = 'Upload type';
$string['uuoptype_addinc'] = 'Add all, append number to usernames if needed';
$string['uuoptype_addnew'] = 'Add new only, skip existing users';
$string['uuoptype_addupdate'] = 'Add new and update existing users';
$string['uuoptype_update'] = 'Update existing users only';
$string['uupasswordcron'] = 'Generated in cron';
$string['uupasswordnew'] = 'New user password';
$string['uupasswordold'] = 'Existing user password';
$string['uustandardusernames'] = 'Standardise usernames';
$string['uuupdateall'] = 'Override with file and defaults';
$string['uuupdatefromfile'] = 'Override with file';
$string['uuupdatemissing'] = 'Fill in missing from file and defaults';
$string['uuupdatetype'] = 'Existing user details';
$string['uuusernametemplate'] = 'Username template';
Expand Up @@ -17,8 +17,8 @@
/**
* Bulk user registration functions
*
* @package core
* @subpackage admin
* @package tool
* @subpackage uploaduser
* @copyright 2004 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
Expand Down Expand Up @@ -64,10 +64,10 @@ class uu_progress_tracker {
*/
public function start() {
$ci = 0;
echo '<table id="uuresults" class="generaltable boxaligncenter flexible-wrap" summary="'.get_string('uploadusersresult', 'admin').'">';
echo '<table id="uuresults" class="generaltable boxaligncenter flexible-wrap" summary="'.get_string('uploadusersresult', 'tool_uploaduser').'">';
echo '<tr class="heading r0">';
echo '<th class="header c'.$ci++.'" scope="col">'.get_string('status').'</th>';
echo '<th class="header c'.$ci++.'" scope="col">'.get_string('uucsvline', 'admin').'</th>';
echo '<th class="header c'.$ci++.'" scope="col">'.get_string('uucsvline', 'tool_uploaduser').'</th>';
echo '<th class="header c'.$ci++.'" scope="col">ID</th>';
echo '<th class="header c'.$ci++.'" scope="col">'.get_string('username').'</th>';
echo '<th class="header c'.$ci++.'" scope="col">'.get_string('firstname').'</th>';
Expand Down

0 comments on commit ce15d56

Please sign in to comment.