Skip to content

Commit

Permalink
MBS-9808: Allow tenant manager to confirm/unconfirm terms of use
Browse files Browse the repository at this point in the history
  • Loading branch information
PhMemmel committed Jan 7, 2025
1 parent f568d4c commit 170f08f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
16 changes: 16 additions & 0 deletions classes/form/rights_config_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ class rights_config_form extends \moodleform {
/** @var string Constant for defining the action option "unlocked" for the action {@see self::ACTION_CHANGE_LOCK_STATE}. */
const ACTIONOPTION_CHANGE_LOCK_STATE_UNLOCKED = 'unlocked';

/** @var string Constant for defining the action "change confirm status of terms of use". */
const ACTION_CHANGE_CONFIRM_STATE = 'changeconfirmstate';
/** @var string Constant for defining the action option "confirm" for the action {@see self::ACTION_CHANGE_CONFIRM_STATUS}. */
const ACTIONOPTION_CHANGE_CONFIRM_STATE_CONFIRM = 'confirm';
/** @var string Constant for defining the action option "confirm" for the action {@see self::ACTION_CHANGE_CONFIRM_STATUS}. */
const ACTIONOPTION_CHANGE_CONFIRM_STATE_UNCONFIRM = 'unconfirm';

/**
* Form definition.
*/
Expand All @@ -62,6 +69,7 @@ public function definition() {
[
self::ACTION_ASSIGN_ROLE => get_string('assignrole', 'local_ai_manager'),
self::ACTION_CHANGE_LOCK_STATE => get_string('changelockstate', 'local_ai_manager'),
self::ACTION_CHANGE_CONFIRM_STATE => get_string('changeconfirmstate', 'local_ai_manager'),
]);

$actionselectsgroup[] = $mform->createElement('select', 'role', '', [
Expand All @@ -80,6 +88,14 @@ public function definition() {
);
$mform->hideif('lockstate', 'action', 'neq', self::ACTION_CHANGE_LOCK_STATE);

$actionselectsgroup[] = $mform->createElement('select', 'confirmstate', '',
[
self::ACTIONOPTION_CHANGE_CONFIRM_STATE_CONFIRM => get_string('confirmed', 'local_ai_manager'),
self::ACTIONOPTION_CHANGE_CONFIRM_STATE_UNCONFIRM => get_string('unconfirmed', 'local_ai_manager'),
]
);
$mform->hideif('confirmstate', 'action', 'neq', self::ACTION_CHANGE_CONFIRM_STATE);

$mform->addGroup($actionselectsgroup, 'actiongroup', get_string('executebulkuseractions', 'local_ai_manager') . ':', [' '],
false);

Expand Down
6 changes: 4 additions & 2 deletions lang/en/local_ai_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
$string['basicsettings'] = 'Basic settings';
$string['basicsettingsdesc'] = 'Configure basic settings for the AI manager plugin';
$string['cachedef_googleauth'] = 'Cache for Google OAuth2 access token';
$string['changelockstate'] = 'Change lock state';
$string['changeconfirmstate'] = 'Change confirmation of terms of use';
$string['changelockstate'] = 'Change lock status';
$string['configure_instance'] = 'Configure AI Tool Instances';
$string['configureaitool'] = 'Configure AI tool';
$string['configurepurposes'] = 'Configure the purposes';
Expand Down Expand Up @@ -141,7 +142,7 @@
$string['medium'] = 'medium';
$string['model'] = 'Model';
$string['nodata'] = 'No data to show';
$string['notconfirmed'] = 'Not confirmed';
$string['notconfirmed'] = 'Not accepted';
$string['notselected'] = 'Disabled';
$string['per'] = 'per';
$string['pluginname'] = 'AI Manager';
Expand Down Expand Up @@ -213,6 +214,7 @@
$string['tenantnotallowed'] = 'The feature is globally disabled for your tenant and thus not usable.';
$string['termsofusesetting'] = 'Terms of use';
$string['termsofusesettingdesc'] = 'Here you can add your specific terms of use for the AI manager. These will have to be accepted by the user before he/she will be able to use the AI tools.';
$string['unconfirmed'] = 'not confirmed';
$string['unit_count'] = 'request(s)';
$string['unit_token'] = 'token';
$string['unlock'] = 'Unlock';
Expand Down
3 changes: 3 additions & 0 deletions rights_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
$role = intval($data->role);
$userinfo->set_role($role);
break;
case rights_config_form::ACTION_CHANGE_CONFIRM_STATE:
$userinfo->set_confirmed($data->confirmstate === rights_config_form::ACTIONOPTION_CHANGE_CONFIRM_STATE_CONFIRM);
break;
default:
throw new \coding_exception('Unknown action: ' . $data->action);
}
Expand Down

0 comments on commit 170f08f

Please sign in to comment.