"
);
@@ -956,7 +1022,7 @@ class Edit_User extends \NDB_Form
$attribs['disabled'] = true;
}
$group[] = $this->createCheckbox(
- 'permID['.$row['permID'].']',
+ 'permID[' . $row['permID'] . ']',
htmlspecialchars(
$row['label'],
ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5,
@@ -967,7 +1033,12 @@ class Edit_User extends \NDB_Form
$attribs
);
}
- $this->addGroup($group, 'PermID_Group', 'Permissions', "");
+ $this->addGroup(
+ $group,
+ 'PermID_Group',
+ dgettext("user_accounts", "Permissions"),
+ ""
+ );
unset($group);
//getting users name and emails to create checkboxes
@@ -988,14 +1059,14 @@ class Edit_User extends \NDB_Form
'
'
. " "
+ . dgettext('loris', 'Data Supervisors to Email') . " "
. ""
);
$attribs = $this->_isEditingOwnAccount() ? ['disabled' => true] : null;
foreach ($results as $row) {
$group[] = $this->createCheckbox(
- 'supervisorEmail[' . $row['email'] .']',
+ 'supervisorEmail[' . $row['email'] . ']',
htmlspecialchars(
$row['Real_Name'],
ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5,
@@ -1007,7 +1078,12 @@ class Edit_User extends \NDB_Form
);
}
- $this->addGroup($group, 'Supervisors_Group', 'Supervisors', "");
+ $this->addGroup(
+ $group,
+ 'Supervisors_Group',
+ dgettext("user_accounts", "Supervisors"),
+ ""
+ );
unset($group);
if (!$this->isCreatingNewUser()) {
@@ -1072,13 +1148,19 @@ class Edit_User extends \NDB_Form
// Clicked on "UID == email" and specified a UID
if (!empty($values['UserID']) && $values['NA_UserID'] == 'on') {
$errors['UserID_Group']
- = 'You cannot enter a user name '
- . 'if you want it to match the email address';
+ = dgettext(
+ "user_accounts",
+ 'You cannot enter a user name '
+ . 'if you want it to match the email address'
+ );
} elseif (empty($values['UserID']) && $values['NA_UserID'] != 'on') {
// Not clicked on "UID == email" and not specified a UID
$errors['UserID_Group']
- = 'You must enter a user name '
- . 'or choose to make it match the email address';
+ = dgettext(
+ "user_accounts",
+ 'You must enter a user name '
+ . 'or choose to make it match the email address'
+ );
} elseif (!empty($values['UserID'])
|| ($values['NA_UserID'] == 'on' && $values['Email'])
) {
@@ -1096,24 +1178,33 @@ class Edit_User extends \NDB_Form
);
if ($result > 0) {
- $errors['UserID_Group'] = 'The user name already exists';
+ $errors['UserID_Group'] = dgettext(
+ "user_accounts",
+ "The user name already exists"
+ );
}
if (strlen($effectiveUID) > 255) {
- $errors['UserID_Group']
- = 'The user name must not exceed 255 characters';
+ $errors['UserID_Group'] = dgettext(
+ "user_accounts",
+ "The user name must not exceed 255 characters"
+ );
}
// Check that user name does not contain a whitespace character
if (preg_match('/\s/', $effectiveUID)) {
// Note: email addresses can contain comments which themselves
// can contain spaces
if ($values['NA_UserID'] == 'on') {
- $errors['UserID_Group']
- = 'You cannot have the user name match an email address'
- . ' that contains a whitespace character';
+ $errors['UserID_Group'] = dgettext(
+ "user_accounts",
+ "You cannot have the user name match an email address"
+ . " that contains a whitespace character"
+ );
} else {
- $errors['UserID_Group']
- = 'Whitespace characters are not allowed in user names';
+ $errors['UserID_Group'] = dgettext(
+ "user_accounts",
+ "Whitespace characters are not allowed in user names"
+ );
}
}
}
@@ -1130,7 +1221,10 @@ class Edit_User extends \NDB_Form
if ($values['Email'] === $values['Password_hash']
&& $values['Password_hash'] !== ''
) {
- $errors['Password'] = self::PASSWORD_ERROR_IS_EMAIL;
+ $errors['Password'] = dgettext(
+ "user_accounts",
+ "Your password cannot be your email."
+ );
}
// Make sure the user is not using their username as their password.
@@ -1143,7 +1237,10 @@ class Edit_User extends \NDB_Form
|| (!empty($this->identifier)
&& $this->identifier === ($values['Password_hash'] ?? ''))
) {
- $errors['Password'] = self::PASSWORD_ERROR_IS_USER;
+ $errors['Password'] = dgettext(
+ "user_accounts",
+ "Your password cannot be your user name."
+ );
}
if (!is_null($this->identifier)) {
@@ -1160,14 +1257,19 @@ class Edit_User extends \NDB_Form
&& empty($values['Password_hash'])
&& $values['NA_Password'] != 'on'
) {
- $errors['Password']
- = 'Please specify password or click Generate new password';
+ $errors['Password'] = dgettext(
+ "user_accounts",
+ "Please specify password or click Generate new password"
+ );
}
}
// Ensure that the password and confirm password fields match.
// TODO This validation should be done on the front-end instead.
if ($plaintext !== $values['__Confirm']) {
- $errors['Password'] = self::PASSWORD_ERROR_NO_MATCH;
+ $errors['Password'] = dgettext(
+ "user_accounts",
+ "The passwords do not match."
+ );
}
// if password is user-defined, and user wants to change password
@@ -1183,7 +1285,10 @@ class Edit_User extends \NDB_Form
$isPasswordDifferent = \User::factory($this->identifier)
->isPasswordDifferent($decoded);
if (! $isPasswordDifferent) {
- $errors['Password'] = self::PASSWORD_ERROR_NO_CHANGE;
+ $errors['Password'] = dgettext(
+ "user_accounts",
+ "New and old passwords are identical"
+ );
}
} catch (\InvalidArgumentException $e) {
$errors['Password'] = $e->getMessage();
@@ -1195,24 +1300,29 @@ class Edit_User extends \NDB_Form
&& $values['NA_Password'] == "on"
&& $values['SendEmail'] != "on"
) {
- $errors['Email']
- = 'When generating a new password, '
- . 'please notify the user by checking Send email to user box';
+ $errors['Email'] = dgettext(
+ "user_accounts",
+ "When generating a new password, please notify the user by checking"
+ . " 'Send email to user' box"
+ );
}
if (isset($values['NA_Password'])
&& $values['NA_Password'] == 'on'
&& $plaintext != ''
) {
- $errors['Password'] = 'You must leave the password field empty '
- . 'if you want the system to generate one for you';
+ $errors['Password'] = dgettext(
+ "user_accounts",
+ "You must leave the password field empty if you want the system to"
+ . " generate one for you"
+ );
}
if (is_null($this->identifier)
&& (!isset($values['NA_Password']) || $values['NA_Password'] != 'on')
&& empty($plaintext)
) {
- $errors['Password'] = 'Password is required';
+ $errors['Password'] = dgettext("user_accounts", "Password is required");
}
//======================================
@@ -1226,13 +1336,18 @@ class Edit_User extends \NDB_Form
$errors['Email'] = $emailError;
} elseif ($this->isCreatingNewUser()) {
if ($values['Email'] != $values['__ConfirmEmail']) {
- $errors['__ConfirmEmail'] = 'Email and confirmed email '
- . ' do not match';
+ $errors['__ConfirmEmail'] = dgettext(
+ "user_accounts",
+ "Email and confirmed email do not match"
+ );
}
}
} else {
// No email entered: error
- $errors['Email'] = 'You must enter an email address';
+ $errors['Email'] = dgettext(
+ "user_accounts",
+ "You must enter an email address"
+ );
}
//======================================
@@ -1240,8 +1355,10 @@ class Edit_User extends \NDB_Form
//======================================
// Ensure that at least one site is selected
if (empty($values['CenterIDs'])) {
- $errors['sites_group'] = "You must select at least one " .
- "site/affiliation";
+ $errors['sites_group'] = dgettext(
+ "user_accounts",
+ "You must select at least one site/affiliation"
+ );
}
//======================================
@@ -1249,8 +1366,10 @@ class Edit_User extends \NDB_Form
//======================================
// Ensure that at least one site is selected
if (empty($values['ProjectIDs'])) {
- $errors['projects_group'] = "You must select at least one " .
- "project/affiliation";
+ $errors['projects_group'] = dgettext(
+ "user_accounts",
+ "You must select at least one project/affiliation"
+ );
}
//======================================
@@ -1259,22 +1378,28 @@ class Edit_User extends \NDB_Form
if ($editor->hasPermission('examiner_multisite')) {
if ($values['examiner_sites'] ?? null) {
if ($values['examiner_radiologist'] == '') {
- $errors['examiner_group'] = "Please specify if examiner " .
- "is a radiologist";
-
+ $errors['examiner_group'] = dgettext(
+ "user_accounts",
+ "Please specify if examiner is a radiologist"
+ );
}
if ($values['examiner_radiologist'] !== ''
&& $values['examiner_pending'] == ''
) {
- $errors['examiner_group'] = "Please set pending " .
- "approval Yes or No";
+ $errors['examiner_group'] = dgettext(
+ "user_accounts",
+ "Please set pending approval Yes or No"
+ );
}
} elseif ($values['examiner_radiologist'] !== ''
|| $values['examiner_pending'] ?? '' !== ''
) {
- $errors['examiner_sites'] = "Please select at least one examiner
- site or clear the 'Examiner status' fields below (i.e.
- 'Radiologist' and 'Pending Approval').";
+ $errors['examiner_sites'] = dgettext(
+ "user_accounts",
+ "Please select at least one examiner site or clear the "
+ . "'Examiner status' fields below "
+ . "(i.e. 'Radiologist' and 'Pending Approval')."
+ );
}
}
@@ -1289,9 +1414,11 @@ class Edit_User extends \NDB_Form
if (($values['active_to'] != null)
&& ($values['active_from'] > $values['active_to'])
) {
- $errors['active_timeWindows']
- = 'Please notice that the "Active from"
- date should be lesser or equal to the "Active to" date.';
+ $errors['active_timeWindows'] = dgettext(
+ "user_accounts",
+ "Please notice that the \"Active from\" date should be"
+ . " lesser or equal to the \"Active to\" date."
+ );
}
return $errors;
}
@@ -1311,11 +1438,14 @@ class Edit_User extends \NDB_Form
// Although some of these characters are legal in emails, due to the
// current HTML escaping method, it is better to reject email
// addresses containing them
- return 'Email address can not contain any the following '.
- 'characters: <, >, & and "';
+ return dgettext(
+ 'loris',
+ 'Email address cannot contain any of the following characters: '
+ . '<, >, &, and "'
+ );
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
// If email not syntactically valid
- return "Invalid email address";
+ return dgettext('loris', 'Invalid email address');
}
// check email address' uniqueness
@@ -1329,7 +1459,10 @@ class Edit_User extends \NDB_Form
// Email already exists in database
if ($result > 0) {
- return self::EMAIL_NOT_UNIQUE;
+ return dgettext(
+ "user_accounts",
+ "This email address is already in use"
+ );
}
return null;
diff --git a/modules/user_accounts/php/user_accounts.class.inc b/modules/user_accounts/php/user_accounts.class.inc
index e12c6ac9722..e2abf3de32d 100644
--- a/modules/user_accounts/php/user_accounts.class.inc
+++ b/modules/user_accounts/php/user_accounts.class.inc
@@ -11,6 +11,7 @@
* @license Loris license
* @link https://www.github.com/aces/Loris/
*/
+
namespace LORIS\user_accounts;
/**
@@ -40,7 +41,7 @@ class User_Accounts extends \DataFrameworkMenu
*
* @return boolean
*/
- function _hasAccess(\User $user) : bool
+ function _hasAccess(\User $user): bool
{
return $user->hasAnyPermission(self::PERMISSIONS);
}
@@ -51,7 +52,7 @@ class User_Accounts extends \DataFrameworkMenu
*
* @return ?array of permissions or null
*/
- public function allSitePermissionNames() : ?array
+ public function allSitePermissionNames(): ?array
{
return ['user_accounts_multisite'];
}
@@ -62,7 +63,7 @@ class User_Accounts extends \DataFrameworkMenu
*
* @return bool true
*/
- public function useProjectFilter() : bool
+ public function useProjectFilter(): bool
{
return true;
}
@@ -72,11 +73,11 @@ class User_Accounts extends \DataFrameworkMenu
*
* @return array
*/
- protected function getFieldOptions() : array
+ protected function getFieldOptions(): array
{
$yesNoOptions = [
- 'Y' => 'Yes',
- 'N' => 'No',
+ 'Y' => dgettext("loris", "Yes"),
+ 'N' => dgettext("loris", "No"),
];
return [
@@ -92,7 +93,7 @@ class User_Accounts extends \DataFrameworkMenu
*
* @return \Loris\Data\Provisioner
*/
- public function getBaseDataProvisioner() : \LORIS\Data\Provisioner
+ public function getBaseDataProvisioner(): \LORIS\Data\Provisioner
{
return new UserAccountRowProvisioner($this->loris);
}
@@ -113,4 +114,3 @@ class User_Accounts extends \DataFrameworkMenu
);
}
}
-
diff --git a/modules/user_accounts/templates/form_edit_user.tpl b/modules/user_accounts/templates/form_edit_user.tpl
index 74f97a53ff3..1040474b460 100644
--- a/modules/user_accounts/templates/form_edit_user.tpl
+++ b/modules/user_accounts/templates/form_edit_user.tpl
@@ -2,28 +2,28 @@