Skip to content

Commit

Permalink
HASTAC changes
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Oct 7, 2022
1 parent 6fda856 commit e39a3d1
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions Config/Schema/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<field name="ldap_bind_password" type="C" size="64" />
<field name="ldap_basedn" type="C" size="128" />
<field name="hc_idp_scope" type="C" size="64" />
<field name="username_env_variable" type="C" size="256" />
<field name="debug" type="L" />
<field name="created" type="T" />
<field name="modified" type="T" />
Expand Down
10 changes: 6 additions & 4 deletions Controller/HumanitiesCommonsIdpEnrollerCoPetitionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function execute_plugin_checkEligibility($id, $onFinish) {

$args = array();
$args['conditions']['HumanitiesCommonsIdpEnroller.co_enrollment_flow_wedge_id'] = $efwid;
$args['contain'] = false;
$args['contain'] = true;
$config = $this->HumanitiesCommonsIdpEnroller->find('first', $args);
if (empty($config)) {
$this->Flash->set(_txt('er.humanitiescommonsidpenroller.account.noconfig'), array('key' => 'error'));
Expand Down Expand Up @@ -80,7 +80,7 @@ protected function execute_plugin_checkEligibility($id, $onFinish) {

// If the petition already has a username then do not present
// a form and just redirect.
if ($coPetition['CoPetition']['co_enrollment_flow_id'] != '604' ) {
if ($coPetition['CoPetition']['co_enrollment_flow_id'] != '654' ) {
foreach($coPetition['EnrolleeCoPerson']['Identifier'] as $identifier) {
if($identifier['type'] == $config['HumanitiesCommonsIdpEnroller']['username_id_type'] &&
!empty($identifier['identifier']) ) {
Expand Down Expand Up @@ -223,7 +223,9 @@ protected function execute_plugin_checkEligibility($id, $onFinish) {

// GET, fall through to display view
( $debug ? $this->log($logPrefix . "received GET so displaying form to collect username") : null);
$this->set('vv_efwid', $efwid);
if(!empty($config['HumanitiesCommonsIdpEnroller']['username_env_variable'])) {
$this->set('vv_suggested_username', getenv($config['HumanitiesCommonsIdpEnroller']['username_env_variable']));
}
}

/**
Expand All @@ -243,7 +245,7 @@ protected function execute_plugin_selectEnrollee($id, $onFinish) {

$args = array();
$args['conditions']['HumanitiesCommonsIdpEnroller.co_enrollment_flow_wedge_id'] = $efwid;
$args['contain'] = false;
$args['contain'] = true;
$config = $this->HumanitiesCommonsIdpEnroller->find('first', $args);
if (empty($config)) {
$this->Flash->set(_txt('er.humanitiescommonsidpenroller.account.noconfig'), array('key' => 'error'));
Expand Down
2 changes: 2 additions & 0 deletions Lib/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
'pl.humanitiescommonsidpenroller.config.ldap_basedn.desc' => 'Base DN to provision accounts under',
'pl.humanitiescommonsidpenroller.config.hc_idp_scope' => 'Humanities Commons IdP Scope',
'pl.humanitiescommonsidpenroller.config.hc_idp_scope.desc' => 'Scope asserted by the Humanities Commons IdP (hcommons.org)',
'pl.humanitiescommonsidpenroller.config.username_env_variable' => 'Username Environment Variable Default',
'pl.humanitiescommonsidpenroller.config.username_env_variable.desc' => 'Environment variable used to set username default in form',
'pl.humanitiescommonsidpenroller.config.debug' => 'Debug',
'pl.humanitiescommonsidpenroller.config.debug.desc' => 'Toggle for debug mode',
'pl.humanitiescommonsidpenroller.config.menu' => 'HC IdP Enroller Configuration',
Expand Down
7 changes: 6 additions & 1 deletion Model/HumanitiesCommonsIdpEnroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ class HumanitiesCommonsIdpEnroller extends AppModel {
'rule' => 'notBlank',
'required' => true,
'allowEmpty' => false
)
),
'username_env_variable' => array(
'rule' => array('validateInput'),
'required' => false,
'allowEmpty' => true
),
);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
print $this->element("pageTitleAndButtons", $params);

print $this->Form->create(false);
print $this->Form->hidden('CoPetition.co_enrollment_flow_wedge_id', array('default' => $vv_efwid));
?>

<script type="text/javascript">
Expand Down Expand Up @@ -84,9 +83,9 @@
$args['type'] = 'text';
$args['label'] = false;
$args['required'] = 'required';
if( $current_enrollment_flow_cou == 'MSU' ) {
$args['value'] = getenv('netid');
}
if(!empty($vv_suggested_username)) {
$args['value'] = $vv_suggested_username;
}
print $this->Form->input('username', $args);
?>
<span id="username-error" class="field-error"></span>
Expand Down
9 changes: 9 additions & 0 deletions View/HumanitiesCommonsIdpEnrollers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@
<?php print ($e ? $this->Form->input('hc_idp_scope', array('size' => 50)) : Sanitize::html($humanities_commons_idp_enrollers[0]['HumanitiesCommonsIdpEnroller']['hc_idp_scope'])); ?>
</td>
</tr>
<tr class="line<?php print ($l % 2); $l++; ?>">
<td>
<strong class="fieldTitle"><?php print _txt('pl.humanitiescommonsidpenroller.config.username_env_variable'); ?></strong><br />
<font class="desc"><?php print _txt('pl.humanitiescommonsidpenroller.config.username_env_variable.desc'); ?></font>
</td>
<td>
<?php print ($e ? $this->Form->input('username_env_variable', array('size' => 50)) : Sanitize::html($humanities_commons_idp_enrollers[0]['HumanitiesCommonsIdpEnroller']['username_env_variable'])); ?>
</td>
</tr>
<tr class="line<?php print ($l % 2); $l++; ?>">
<td>
<strong class="fieldTitle"><?php print _txt('pl.humanitiescommonsidpenroller.config.debug'); ?></strong><font class="required">*</font><br />
Expand Down

0 comments on commit e39a3d1

Please sign in to comment.