From e39a3d1eb65b26afd30a87008ec99be6283ccf12 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 Oct 2022 18:06:43 +0000 Subject: [PATCH] HASTAC changes --- Config/Schema/schema.xml | 1 + ...manitiesCommonsIdpEnrollerCoPetitionsController.php | 10 ++++++---- Lib/lang.php | 2 ++ Model/HumanitiesCommonsIdpEnroller.php | 7 ++++++- .../check_eligibility.ctp | 7 +++---- View/HumanitiesCommonsIdpEnrollers/fields.inc | 9 +++++++++ 6 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Config/Schema/schema.xml b/Config/Schema/schema.xml index 83e8ea3..8fa8799 100644 --- a/Config/Schema/schema.xml +++ b/Config/Schema/schema.xml @@ -40,6 +40,7 @@ + diff --git a/Controller/HumanitiesCommonsIdpEnrollerCoPetitionsController.php b/Controller/HumanitiesCommonsIdpEnrollerCoPetitionsController.php index f8cf44f..dc7b27c 100644 --- a/Controller/HumanitiesCommonsIdpEnrollerCoPetitionsController.php +++ b/Controller/HumanitiesCommonsIdpEnrollerCoPetitionsController.php @@ -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')); @@ -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']) ) { @@ -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'])); + } } /** @@ -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')); diff --git a/Lib/lang.php b/Lib/lang.php index 2a187b7..28bbe1d 100644 --- a/Lib/lang.php +++ b/Lib/lang.php @@ -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', diff --git a/Model/HumanitiesCommonsIdpEnroller.php b/Model/HumanitiesCommonsIdpEnroller.php index 516566d..49bd4dd 100644 --- a/Model/HumanitiesCommonsIdpEnroller.php +++ b/Model/HumanitiesCommonsIdpEnroller.php @@ -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 + ), ); /** diff --git a/View/HumanitiesCommonsIdpEnrollerCoPetitions/check_eligibility.ctp b/View/HumanitiesCommonsIdpEnrollerCoPetitions/check_eligibility.ctp index c9e1527..56934fd 100644 --- a/View/HumanitiesCommonsIdpEnrollerCoPetitions/check_eligibility.ctp +++ b/View/HumanitiesCommonsIdpEnrollerCoPetitions/check_eligibility.ctp @@ -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)); ?>