Skip to Content.
Sympa Menu

comanage-dev - [comanage-dev] r581 - in registry/trunk/app: Config/Schema Controller Lib Model View/CmpEnrollmentConfigurations View/OrgIdentities

Subject: COmanage Developers List

List archive

[comanage-dev] r581 - in registry/trunk/app: Config/Schema Controller Lib Model View/CmpEnrollmentConfigurations View/OrgIdentities


Chronological Thread 
  • From:
  • To:
  • Subject: [comanage-dev] r581 - in registry/trunk/app: Config/Schema Controller Lib Model View/CmpEnrollmentConfigurations View/OrgIdentities
  • Date: Wed, 28 Aug 2013 20:07:34 -0400

Author: benno
Date: 2013-08-28 20:07:34 -0400 (Wed, 28 Aug 2013)
New Revision: 581

Modified:
registry/trunk/app/Config/Schema/schema.xml
registry/trunk/app/Controller/CmpEnrollmentConfigurationsController.php
registry/trunk/app/Controller/CoPetitionsController.php
registry/trunk/app/Controller/OrgIdentitiesController.php
registry/trunk/app/Lib/lang.php
registry/trunk/app/Model/CmpEnrollmentAttribute.php
registry/trunk/app/Model/CmpEnrollmentConfiguration.php
registry/trunk/app/Model/CoEnrollmentAttribute.php
registry/trunk/app/View/CmpEnrollmentConfigurations/fields.inc
registry/trunk/app/View/OrgIdentities/fields.inc
Log:
Provision org identity attributes from env variables (CO-311)

Modified: registry/trunk/app/Config/Schema/schema.xml
===================================================================
--- registry/trunk/app/Config/Schema/schema.xml 2013-08-28 10:29:51 UTC (rev
580)
+++ registry/trunk/app/Config/Schema/schema.xml 2013-08-29 00:07:34 UTC (rev
581)
@@ -516,6 +516,12 @@
<index name="co_cmp_enrollment_attributes_i1">
<col>cmp_enrollment_configuration_id</col>
</index>
+ <index name="co_cmp_enrollment_attributes_i2">
+ <col>cmp_enrollment_configuration_id</col>
+ <col>attribute</col>
+ <col>type</col>
+ <unique />
+ </index>
</table>

<table name="co_enrollment_flows">

Modified:
registry/trunk/app/Controller/CmpEnrollmentConfigurationsController.php
===================================================================
--- registry/trunk/app/Controller/CmpEnrollmentConfigurationsController.php
2013-08-28 10:29:51 UTC (rev 580)
+++ registry/trunk/app/Controller/CmpEnrollmentConfigurationsController.php
2013-08-29 00:07:34 UTC (rev 581)
@@ -42,7 +42,7 @@
/**
* Callback after controller methods are invoked but before views are
rendered.
* - precondition: Request Handler component has set $this->request
- * - postcondition: Set $cmp_ef_attribute_order
+ * - postcondition: Set $vv_availableAttributes
*
* @since COmanage Registry v0.3
*/
@@ -50,7 +50,9 @@
function beforeRender() {
// Set the list of attribute order for the view to render

- $this->set('cmp_ef_attribute_order',
$this->CmpEnrollmentConfiguration->getStandardAttributeOrder());
+ $this->set('vv_availableAttributes',
+
$this->CmpEnrollmentConfiguration->CmpEnrollmentAttribute->availableAttributes());
+
parent::beforeRender();
}

@@ -165,6 +167,7 @@

if(empty($ef))
{
+ // XXX move to Model
// Not found, create it

$ef['CmpEnrollmentConfiguration'] = array(
@@ -190,243 +193,6 @@
$fid = $ef['CmpEnrollmentConfiguration']['id'];
}

- // Check for default CMP Enrollment Configuration Attributes. This may
or may not be
- // the ideal place to do this.
-
- function defined_attribute($attrs, $attr, $type=null)
- {
- // A local helper function to determine if $attr is already defined in
$attrs
-
- foreach(array_keys($attrs) as $k)
- {
- if($attrs[$k]['CmpEnrollmentAttribute']['attribute'] == $attr)
- {
- if(!defined($type)
- || (defined($attrs[$k]['CmpEnrollmentAttribute']['type'])
- && $attrs[$k]['CmpEnrollmentAttribute']['type'] == $type))
- return(true);
- }
- }
-
- return(false);
- }
-
- // It'd be nice to used find('list'), but we don't have a unique key
other than 'id'.
- // (There can be multiple rows with the same 'attribute' but different
'type'.)
- // The attributes in this list need to be kept in sync with the model
(getStandardAttributeOrder).
-
- $attrs =
$this->CmpEnrollmentConfiguration->CmpEnrollmentAttribute->findAllByCmpEnrollmentConfigurationId($fid);
-
- $newattrs = array();
-
- if(!defined_attribute($attrs, 'names:honorific', NameEnum::Official))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'names:honorific',
- 'type' => NameEnum::Official,
- 'required' => RequiredEnum::Optional
- );
- }
-
- if(!defined_attribute($attrs, 'names:given', NameEnum::Official))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'names:given',
- 'type' => NameEnum::Official,
- 'required' => RequiredEnum::Required,
- 'ldap_name' => 'givenName',
- 'saml_name' => 'givenName'
- );
- }
-
- if(!defined_attribute($attrs, 'names:middle', NameEnum::Official))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'names:middle',
- 'type' => NameEnum::Official,
- 'required' => RequiredEnum::Optional
- );
- }
-
- if(!defined_attribute($attrs, 'names:family', NameEnum::Official))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'names:family',
- 'type' => NameEnum::Official,
- 'required' => RequiredEnum::Optional,
- 'ldap_name' => 'sn',
- 'saml_name' => 'sn'
- );
- }
-
- if(!defined_attribute($attrs, 'names:suffix', NameEnum::Official))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'names:suffix',
- 'type' => NameEnum::Official,
- 'required' => RequiredEnum::Optional
- );
- }
-
- if(!defined_attribute($attrs, 'affiliation'))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'affiliation',
- 'required' => RequiredEnum::Optional,
- 'ldap_name' => 'edu_person_affiliation',
- 'saml_name' => 'edu_person_affiliation'
- );
- }
-
- if(!defined_attribute($attrs, 'title'))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'title',
- 'required' => RequiredEnum::Optional,
- 'ldap_name' => 'title',
- 'saml_name' => 'title'
- );
- }
-
- if(!defined_attribute($attrs, 'o'))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'o',
- 'required' => RequiredEnum::Optional,
- 'ldap_name' => 'o',
- 'saml_name' => 'o'
- );
- }
-
- if(!defined_attribute($attrs, 'ou'))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'ou',
- 'required' => RequiredEnum::Optional,
- 'ldap_name' => 'ou',
- 'saml_name' => 'ou'
- );
- }
-
- if(!defined_attribute($attrs, 'identifiers:identifier',
IdentifierEnum::ePPN))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'identifiers:identifier',
- 'type' => IdentifierEnum::ePPN,
- 'required' => RequiredEnum::Required,
- 'ldap_name' => 'eduPersonPrincipalName',
- 'saml_name' => 'eduPersonPrincipalName'
- );
- }
-
- if(!defined_attribute($attrs, 'email_addresses:mail',
ContactEnum::Office))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'email_addresses:mail',
- 'type' => ContactEnum::Office,
- 'required' => RequiredEnum::Required,
- 'ldap_name' => 'mail',
- 'saml_name' => 'mail'
- );
- }
-
- if(!defined_attribute($attrs, 'telephone_numbers:number',
ContactEnum::Office))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'telephone_numbers:number',
- 'type' => ContactEnum::Office,
- 'required' => RequiredEnum::Optional,
- 'ldap_name' => 'telephoneNumber',
- 'saml_name' => 'telephoneNumber'
- );
- }
-
- if(!defined_attribute($attrs, 'addresses:line1', ContactEnum::Office))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'addresses:line1',
- 'type' => ContactEnum::Office,
- 'required' => RequiredEnum::Optional,
- 'ldap_name' => 'street',
- 'saml_name' => 'street'
- );
- }
-
- if(!defined_attribute($attrs, 'addresses:line2', ContactEnum::Office))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'addresses:line2',
- 'type' => ContactEnum::Office,
- 'required' => RequiredEnum::Optional
- );
- }
-
- if(!defined_attribute($attrs, 'addresses:locality', ContactEnum::Office))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'addresses:locality',
- 'type' => ContactEnum::Office,
- 'required' => RequiredEnum::Optional,
- 'ldap_name' => 'l',
- 'saml_name' => 'l'
- );
- }
-
- if(!defined_attribute($attrs, 'addresses:state', ContactEnum::Office))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'addresses:state',
- 'type' => ContactEnum::Office,
- 'required' => RequiredEnum::Optional,
- 'ldap_name' => 'st',
- 'saml_name' => 'st'
- );
- }
-
- if(!defined_attribute($attrs, 'addresses:postal_code',
ContactEnum::Office))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'addresses:postal_code',
- 'type' => ContactEnum::Office,
- 'required' => RequiredEnum::Optional,
- 'ldap_name' => 'postalCode',
- 'saml_name' => 'postalCode'
- );
- }
-
- if(!defined_attribute($attrs, 'addresses:country', ContactEnum::Office))
- {
- $newattrs[]['CmpEnrollmentAttribute'] = array(
- 'cmp_enrollment_configuration_id' => $fid,
- 'attribute' => 'addresses:country',
- 'type' => ContactEnum::Office,
- 'required' => RequiredEnum::Optional,
- 'ldap_name' => 'c'
- );
- }
-
- if(!empty($newattrs))
- {
-
$this->CmpEnrollmentConfiguration->CmpEnrollmentAttribute->SaveAll($newattrs);
- }
-
// Redirect to the configuration edit page

$this->redirect(array('controller' => 'cmp_enrollment_configurations',

Modified: registry/trunk/app/Controller/CoPetitionsController.php
===================================================================
--- registry/trunk/app/Controller/CoPetitionsController.php 2013-08-28
10:29:51 UTC (rev 580)
+++ registry/trunk/app/Controller/CoPetitionsController.php 2013-08-29
00:07:34 UTC (rev 581)
@@ -224,9 +224,32 @@
}
}

- $this->set('co_enrollment_attributes',
-
$this->CoPetition->CoEnrollmentFlow->CoEnrollmentAttribute->enrollmentFlowAttributes($this->enrollmentFlowID(),
-
$defaultValues));
+ $this->loadModel('CmpEnrollmentConfiguration');
+
+ $envValues = false;
+ $enrollmentAttributes = $this->CoPetition
+ ->CoEnrollmentFlow
+ ->CoEnrollmentAttribute
+
->enrollmentFlowAttributes($this->enrollmentFlowID(),
+
$defaultValues);
+
+ if($this->CmpEnrollmentConfiguration->orgIdentitiesFromCOEF()) {
+ // If enrollment flows can populate org identities, then see if
we're configured
+ // to pull environment variables. If so, for this configuration
they simply
+ // replace modifiable default values.
+
+ $envValues =
$this->CmpEnrollmentConfiguration->enrollmentAttributesFromEnv();
+
+ if($envValues) {
+ $enrollmentAttributes = $this->CoPetition
+ ->CoEnrollmentFlow
+ ->CoEnrollmentAttribute
+
->mapEnvAttributes($enrollmentAttributes,
+ $envValues);
+ }
+ }
+
+ $this->set('co_enrollment_attributes', $enrollmentAttributes);
}

if(($this->action == 'edit' || $this->action == 'view')

Modified: registry/trunk/app/Controller/OrgIdentitiesController.php
===================================================================
--- registry/trunk/app/Controller/OrgIdentitiesController.php 2013-08-28
10:29:51 UTC (rev 580)
+++ registry/trunk/app/Controller/OrgIdentitiesController.php 2013-08-29
00:07:34 UTC (rev 581)
@@ -92,20 +92,6 @@
}

/**
- * Callback after controller methods are invoked but before views are
rendered.
- * - precondition: Request Handler component has set $this->request->params
- * - postcondition: If a CO must be specifed, a named parameter may be set.
- *
- * @since COmanage Registry v0.2
- */
-
- function beforeRender() {
- $this->set('cmp_ef_attribute_order',
$this->CmpEnrollmentConfiguration->getStandardAttributeOrder());
-
- parent::beforeRender();
- }
-
- /**
* Perform any dependency checks required prior to a delete operation.
* - postcondition: Session flash message updated (HTML) or HTTP status
returned (REST)
*

Modified: registry/trunk/app/Lib/lang.php
===================================================================
--- registry/trunk/app/Lib/lang.php 2013-08-28 10:29:51 UTC (rev 580)
+++ registry/trunk/app/Lib/lang.php 2013-08-29 00:07:34 UTC (rev 581)
@@ -393,6 +393,7 @@
'fd.an.desc' => 'Alphanumeric characters only',
'fd.approver' => 'Approver',
'fd.attribute' => 'Attribute',
+ 'fd.attr.env' => 'Environment Variable Name',
'fd.attr.ldap' => 'LDAP Name',
'fd.attr.saml' => 'SAML Name',
'fd.attrs.cop' => 'Person Attributes',
@@ -442,8 +443,7 @@
'fd.ef.authz.desc' => 'Authorization required to execute this enrollment
flow, see <a
href="https://spaces.internet2.edu/display/COmanage/Registry+Enrollment+Flow+Configuration#RegistryEnrollmentFlowConfiguration-EnrollmentAuthorization";>Enrollment
Authorization</a> for details',
'fd.ef.ce' => 'Require Confirmation of Email',
'fd.ef.ce.desc' => 'Confirm email addresses provided by sending a
confirmation URL to the address',
- 'fd.ef.cf.cmp' => 'Platform Enrollment Configuration',
- 'fd.ef.coef' => 'Enable Attributes Via CO Enrollment Flow',
+ 'fd.ef.coef' => 'Enable Organizational Attributes Via CO Enrollment
Flow',
'fd.ef.coef.desc' => 'If enabled, allow organizational identity attributes
to be collected via forms during CO enrollment flows (these attributes will
be less authoritative than those obtained via LDAP or SAML)',
'fd.ef.efn' => 'From Address For Notifications',
'fd.ef.efn.desc' => 'Email address notifications will come from',

Modified: registry/trunk/app/Model/CmpEnrollmentAttribute.php
===================================================================
--- registry/trunk/app/Model/CmpEnrollmentAttribute.php 2013-08-28 10:29:51
UTC (rev 580)
+++ registry/trunk/app/Model/CmpEnrollmentAttribute.php 2013-08-29 00:07:34
UTC (rev 581)
@@ -64,4 +64,157 @@
'allowEmpty' => true
),
);
+
+ /**
+ * Obtain the list of attributes available for loading into an Org
Identity.
+ *
+ * @since COmanage Registry v0.8.2
+ * @return Array Array of available attributes
+ */
+
+ public function availableAttributes() {
+ // Attributes should be listed in the order they are to be rendered in.
+ // The various _name fields are default values that can be overridden.
+ // 'required' applies when Enable Attributes Via CO Enrollment Flow is
false.
+ // Attribute types are forced to Official since they come from an
"official" source.
+
+ $attributes = array(
+ 'names:honorific' => array(
+ 'type' => NameEnum::Official,
+ 'required' => RequiredEnum::Optional,
+ 'label' => _txt('fd.name.honorific'),
+ 'desc' => _txt('fd.name.h.desc'),
+ 'env_name' => '',
+ 'ldap_name' => '',
+ 'saml_name' => ''
+ ),
+ 'names:given' => array(
+ 'type' => NameEnum::Official,
+ 'required' => RequiredEnum::Required,
+ 'label' => _txt('fd.name.given'),
+ 'env_name' => 'CMP_EF_GIVENNAME',
+ 'ldap_name' => 'givenName',
+ 'saml_name' => 'givenName'
+ ),
+ 'names:middle' => array(
+ 'type' => NameEnum::Official,
+ 'required' => RequiredEnum::Optional,
+ 'label' => _txt('fd.name.middle'),
+ 'env_name' => '',
+ 'ldap_name' => '',
+ 'saml_name' => ''
+ ),
+ 'names:family' => array(
+ 'type' => NameEnum::Official,
+ 'required' => RequiredEnum::Optional,
+ 'label' => _txt('fd.name.family'),
+ 'env_name' => 'CMP_EF_SN',
+ 'ldap_name' => 'sn',
+ 'saml_name' => 'sn'
+ ),
+ 'names:suffix' => array(
+ 'type' => NameEnum::Official,
+ 'required' => RequiredEnum::Optional,
+ 'label' => _txt('fd.name.suffix'),
+ 'desc' => _txt('fd.name.s.desc'),
+ 'env_name' => '',
+ 'ldap_name' => '',
+ 'saml_name' => ''
+ ),
+ 'affiliation' => array(
+ 'required' => RequiredEnum::Optional,
+ 'label' => _txt('fd.affiliation'),
+ 'env_name' => 'CMP_EF_AFFILIATION',
+ 'ldap_name' => 'edu_person_affiliation',
+ 'saml_name' => 'edu_person_affiliation'
+ ),
+ 'title' => array(
+ 'required' => RequiredEnum::Optional,
+ 'label' => _txt('fd.title'),
+ 'env_name' => 'CMP_EF_TITLE',
+ 'ldap_name' => 'title',
+ 'saml_name' => 'title'
+ ),
+ 'o' => array(
+ 'required' => RequiredEnum::Optional,
+ 'label' => _txt('fd.o'),
+ 'env_name' => 'CMP_EF_O',
+ 'ldap_name' => 'o',
+ 'saml_name' => 'o'
+ ),
+ 'ou' => array(
+ 'required' => RequiredEnum::Optional,
+ 'label' => _txt('fd.ou'),
+ 'env_name' => 'CMP_EF_OU',
+ 'ldap_name' => 'ou',
+ 'saml_name' => 'ou'
+ ),
+ 'identifiers:identifier' => array(
+ 'type' => IdentifierEnum::ePPN,
+ 'required' => RequiredEnum::Required,
+ 'label' => _txt('en.identifier', null, IdentifierEnum::ePPN),
+ 'env_name' => 'CMP_EF_EPPN',
+ 'ldap_name' => 'eduPersonPrincipalName',
+ 'saml_name' => 'eduPersonPrincipalName'
+ ),
+ 'email_addresses:mail' => array(
+ 'type' => ContactEnum::Office,
+ 'required' => RequiredEnum::Required,
+ 'label' => _txt('fd.email_address.mail'),
+ 'env_name' => 'CMP_EF_MAIL',
+ 'ldap_name' => 'mail',
+ 'saml_name' => 'mail'
+ ),
+ 'telephone_numbers:number' => array(
+ 'type' => ContactEnum::Office,
+ 'required' => RequiredEnum::Optional,
+ 'label' => _txt('fd.telephone_number.number'),
+ 'env_name' => 'CMP_EF_TELEPHONENUMBER',
+ 'ldap_name' => 'telephoneNumber',
+ 'saml_name' => 'telephoneNumber'
+ ),
+ 'addresses:line1' => array(
+ 'type' => ContactEnum::Office,
+ 'required' => RequiredEnum::Optional,
+ 'label' => _txt('fd.address.line1'),
+ 'env_name' => 'CMP_EF_STREET',
+ 'ldap_name' => 'street',
+ 'saml_name' => 'street'
+ ),
+ 'addresses:locality' => array(
+ 'type' => ContactEnum::Office,
+ 'required' => RequiredEnum::Optional,
+ 'label' => _txt('fd.address.locality'),
+ 'env_name' => 'CMP_EF_L',
+ 'ldap_name' => 'l',
+ 'saml_name' => 'l'
+ ),
+ 'addresses:state' => array(
+ 'type' => ContactEnum::Office,
+ 'required' => RequiredEnum::Optional,
+ 'label' => _txt('fd.address.state'),
+ 'env_name' => 'CMP_EF_ST',
+ 'ldap_name' => 'st',
+ 'saml_name' => 'st'
+ ),
+ 'addresses:postal_code' => array(
+ 'type' => ContactEnum::Office,
+ 'required' => RequiredEnum::Optional,
+ 'label' => _txt('fd.address.postal_code'),
+ 'env_name' => 'CMP_EF_POSTALCODE',
+ 'ldap_name' => 'postalCode',
+ 'saml_name' => 'postalCode'
+ ),
+ 'addresses:country' => array(
+ 'type' => ContactEnum::Office,
+ 'label' => _txt('fd.address.country'),
+ 'env_name' => 'CMP_EF_C',
+ 'required' => RequiredEnum::Optional,
+ 'ldap_name' => 'c',
+ 'saml_name' => ''
+ )
+ );
+
+ return $attributes;
+ }
}

Modified: registry/trunk/app/Model/CmpEnrollmentConfiguration.php
===================================================================
--- registry/trunk/app/Model/CmpEnrollmentConfiguration.php 2013-08-28
10:29:51 UTC (rev 580)
+++ registry/trunk/app/Model/CmpEnrollmentConfiguration.php 2013-08-29
00:07:34 UTC (rev 581)
@@ -65,6 +65,29 @@
);

/**
+ * Determine if enrollment attribute values may be obtained from the
environment,
+ * and if so which ones.
+ *
+ * @since COmanage Registry v0.8.2
+ * @return mixed An array of CmpEnrollmentAttributes if enabled, false
otherwise
+ */
+
+ public function enrollmentAttributesFromEnv() {
+ $args = array();
+ $args['conditions']['CmpEnrollmentConfiguration.name'] = 'CMP Enrollment
Configuration';
+ $args['conditions']['CmpEnrollmentConfiguration.status'] =
StatusEnum::Active;
+ $args['contain'][] = 'CmpEnrollmentAttribute';
+
+ $r = $this->find('first', $args);
+
+ if(isset($r['CmpEnrollmentConfiguration']['attrs_from_env'])
+ && $r['CmpEnrollmentConfiguration']['attrs_from_env']) {
+ return $r['CmpEnrollmentAttribute'];
+ }
+
+ return false;
+ }
+ /**
* Find the default (ie: active) CMP Enrollment Configuration for this
platform.
* - precondition: Initial setup (performed by select()) has been
completed.
*
@@ -87,6 +110,7 @@
* @return Array Array of arrays, each of which defines 'attr', 'type',
and 'label'
*/

+// XXX toss this
public function getStandardAttributeOrder($model=null) {
global $cm_lang, $cm_texts;


Modified: registry/trunk/app/Model/CoEnrollmentAttribute.php
===================================================================
--- registry/trunk/app/Model/CoEnrollmentAttribute.php 2013-08-28 10:29:51
UTC (rev 580)
+++ registry/trunk/app/Model/CoEnrollmentAttribute.php 2013-08-29 00:07:34
UTC (rev 581)
@@ -516,4 +516,67 @@

return $attrs;
}
+
+ /**
+ * Map environment variables into enrollment attribute default values.
+ *
+ * @since COmanage Registry v0.8.2
+ * @param Array Array of CO enrollment attributes, as returned by
enrollmentFlowAttributes()
+ * @param Array Array of CMP enrollment attributes, as returned by
CmpEnrollmentConfiguration::enrollmentAttributesFromEnv()
+ * @return Array Array of CO enrollment attributes
+ */
+
+ public function mapEnvAttributes($enrollmentAttributes, $envValues) {
+ // First, map the enrollment attributes by model+field, but only for
those
+ // that we might actually populate (ie: org attributes). We partly have
to
+ // do this because CO Enrollment Attributes and CMP Enrollment Attributes
+ // use different formats in their attribute column (the former does not
+ // include field names while the latter does).
+
+ $eaMap = array();
+
+ for($i = 0;$i < count($enrollmentAttributes);$i++) {
+ $model = explode('.', $enrollmentAttributes[$i]['model'], 2);
+
+ // Only track org identity attributes
+ if($model[0] == "EnrolleeOrgIdentity"
+ // that aren't hidden
+ && !$enrollmentAttributes[$i]['hidden']
+ // and that are modifiable
+ && (!isset($enrollmentAttributes[$i]['modifiable'])
+ || $enrollmentAttributes[$i]['modifiable'])) {
+ $key = "";
+
+ if(!empty($model[1])) {
+ // Inflect the associated model name
+
+ $key = Inflector::pluralize(Inflector::tableize($model[1])) . ":";
+ }
+
+ $key .= $enrollmentAttributes[$i]['field'];
+
+ $eaMap[$key] = $i;
+ }
+ }
+
+ // Now walk through the CMP Enrollment Attributes. If an env_name is
defined,
+ // look for the corresponding CO Enrollment Attribute.
+
+ foreach($envValues as $e) {
+ if(!empty($e['env_name']) && isset($eaMap[ $e['attribute'] ])) {
+ // We don't currently do anything with $e['type']...
+
+ $i = $eaMap[ $e['attribute'] ];
+
+ $enrollmentAttributes[$i]['default'] = getenv($e['env_name']);
+
+ // Make sure the modifiable value is set. If a value was found, we
will
+ // make it not-modifiable.
+
+ $enrollmentAttributes[$i]['modifiable'] =
!(boolean)$enrollmentAttributes[$i]['default'];
+ }
+ }
+
+ return $enrollmentAttributes;
+ }
}

Modified: registry/trunk/app/View/CmpEnrollmentConfigurations/fields.inc
===================================================================
--- registry/trunk/app/View/CmpEnrollmentConfigurations/fields.inc
2013-08-28 10:29:51 UTC (rev 580)
+++ registry/trunk/app/View/CmpEnrollmentConfigurations/fields.inc
2013-08-29 00:07:34 UTC (rev 581)
@@ -2,7 +2,7 @@
/**
* COmanage Registry CMP Enrollment Configuration Fields
*
- * Copyright (C) 2011-12 University Corporation for Advanced Internet
Development, Inc.
+ * Copyright (C) 2011-13 University Corporation for Advanced Internet
Development, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with
* the License. You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* KIND, either express or implied. See the License for the specific
language governing
* permissions and limitations under the License.
*
- * @copyright Copyright (C) 2011-12 University Corporation for Advanced
Internet Development, Inc.
+ * @copyright Copyright (C) 2011-13 University Corporation for Advanced
Internet Development, Inc.
* @link http://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v0.3
@@ -31,6 +31,13 @@

print $this->Form->hidden('name');
print $this->Form->hidden('status');
+
+ // Rekey the current attribute set
+ $currentAttributes = array();
+
+ foreach($cmp_enrollment_configurations[0]['CmpEnrollmentAttribute'] as $a)
{
+ $currentAttributes[ $a['attribute'] ] = $a;
+ }
?>
<script type="text/javascript">
<!-- JS specific to these fields -->
@@ -69,27 +76,24 @@
{
// Enable or disable gadgets according to current state

-// XXX clean this up
- // Treat self_enroll values as a set
-
document.getElementById('CmpEnrollmentConfigurationSelfRequireAuthn').disabled
=
-
!document.getElementById('CmpEnrollmentConfigurationSelfEnroll').checked;
-
- // And treat admin_enroll values as a set
-
document.getElementById('CmpEnrollmentConfigurationAdminConfirmEmail').disabled
=
-
(document.getElementById('CmpEnrollmentConfigurationAdminEnroll').value ==
'N');
-
-
document.getElementById('CmpEnrollmentConfigurationAdminRequireAuthn').disabled
=
-
(document.getElementById('CmpEnrollmentConfigurationAdminEnroll').value ==
'N');
+ // Show the attribute fields, if appropriate
+
if(document.getElementById('CmpEnrollmentConfigurationAttrsFromEnv').checked)
{
+ $("#org_attributes").show('blind');
+ } else {
+ $("#org_attributes").hide('blind');
+ }

-
document.getElementById('CmpEnrollmentConfigurationAttrsFromLdap').disabled =
-
document.getElementById('CmpEnrollmentConfigurationAttrsFromSaml').disabled =
-
((document.getElementById('CmpEnrollmentConfigurationSelfRequireAuthn').disabled
- ||
!document.getElementById('CmpEnrollmentConfigurationSelfRequireAuthn').checked)
- &&
-
(document.getElementById('CmpEnrollmentConfigurationAdminRequireAuthn').disabled
- ||
!document.getElementById('CmpEnrollmentConfigurationAdminRequireAuthn').checked));
+
if(document.getElementById('CmpEnrollmentConfigurationAttrsFromCoef').checked)
{
+ // Required vs optional is set in the enrollment flow
+ $("#edit_cmp_enrollment_attributes td:nth-child(2)").hide('slide');
+ $("#edit_cmp_enrollment_attributes th:nth-child(2)").hide('slide');
+ } else {
+ $("#edit_cmp_enrollment_attributes td:nth-child(2)").show('slide');
+ $("#edit_cmp_enrollment_attributes th:nth-child(2)").show('slide');
+ }

// Make LDAP and SAML attribute colums match the master settings
+ /*
for(i = 0;i < 18;i++)
{

document.getElementById('CmpEnrollmentAttribute'+i+'LdapName').disabled =
@@ -100,6 +104,7 @@

(document.getElementById('CmpEnrollmentConfigurationAttrsFromSaml').disabled
||
!document.getElementById('CmpEnrollmentConfigurationAttrsFromSaml').checked);
}
+ */
}

function on_submit()
@@ -109,11 +114,13 @@
// disabled). Renable these fields (in case they were disabled) to allow
// the form to submit. See CO-350.

+ /*
for(i = 0;i < 18;i++)
{

document.getElementById('CmpEnrollmentAttribute'+i+'LdapName').disabled =
false;

document.getElementById('CmpEnrollmentAttribute'+i+'SamlName').disabled =
false;
}
+ */
}

function js_local_onload()
@@ -121,12 +128,11 @@
// Local (to this view) initializations

pool_check_init_state =
document.getElementById('CmpEnrollmentConfigurationPoolOrgIdentities').checked;
-
+
fields_update_gadgets();
}
</script>
-<div class="accordion">
- <h3><a href="#"><?php print _txt('fd.ef.cf.cmp'); ?></a></h3>
+<div>
<div>
<table id="<?php print $this->action; ?>_cmp_enrollment_configuration"
class="ui-widget">
<tbody>
@@ -137,7 +143,7 @@
</td>
<td>
<?php print ($e
- ? $this->Form->input('attrs_from_ldap',
array('onClick' => 'fields_update_gadgets()'))
+ ? $this->Form->input('attrs_from_ldap',
array('onClick' => 'fields_update_gadgets()', 'disabled' => true))
:
Sanitize::html($cmp_enrollment_configurations[0]['CmpEnrollmentConfiguration']['attrs_from_ldap']));
?>
</td>
</tr>
@@ -148,22 +154,33 @@
</td>
<td>
<?php print ($e
- ? $this->Form->input('attrs_from_saml',
array('onClick' => 'fields_update_gadgets()'))
+ ? $this->Form->input('attrs_from_saml',
array('onClick' => 'fields_update_gadgets()', 'disabled' => true))
:
Sanitize::html($cmp_enrollment_configurations[0]['CmpEnrollmentConfiguration']['attrs_from_saml']));
?>
</td>
</tr>
<tr class="line1">
<td>
+ <b><?php print _txt('fd.ef.env'); ?></b><br />
+ <font class="desc"><?php print _txt('fd.ef.env.desc'); ?></font>
+ </td>
+ <td>
+ <?php print ($e
+ ? $this->Form->input('attrs_from_env',
array('onClick' => 'fields_update_gadgets()'))
+ :
Sanitize::html($cmp_enrollment_configurations[0]['CmpEnrollmentConfiguration']['attrs_from_env']));
?>
+ </td>
+ </tr>
+ <tr class="line2">
+ <td>
<b><?php print _txt('fd.ef.coef'); ?></b><br />
<font class="desc"><?php print _txt('fd.ef.coef.desc'); ?></font>
</td>
<td>
<?php print ($e
- ? $this->Form->input('attrs_from_coef')
+ ? $this->Form->input('attrs_from_coef',
array('onClick' => 'fields_update_gadgets()'))
:
Sanitize::html($cmp_enrollment_configurations[0]['CmpEnrollmentConfiguration']['attrs_from_coef']));
?>
</td>
</tr>
- <tr class="line2">
+ <tr class="line1">
<td>
<b><?php print _txt('fd.ef.pool'); ?></b><br />
<font class="desc"><?php print _txt('fd.ef.pool.desc'); ?></font>
@@ -178,27 +195,89 @@
</table>
</div>

- <h3><a href="#"><?php print _txt('fd.attrs.org'); ?></a></h3>
- <div>
+ <div id="org_attributes" style="display:none">
<table id="<?php print $this->action; ?>_cmp_enrollment_attributes"
class="ui-widget">
<?php
- // $this->data['CmpEnrollmentAttribute'] is sorted by order returned
by the database,
- // but we want to render in a "rational order" (whatever that means)
-
- // We basically need to output almost the same output for each row,
so do so
- // via an array ($cmp_ef_attribute_order, set by the controller) of
the few things that change.
-
$l = 1;
+ $xindex = 0;
?>
<tbody>
<tr>
<th class="ui-state-default"><?php print _txt('fd.attribute');
?></th>
<th class="ui-state-default"><?php print _txt('fd.required');
?></th>
- <th class="ui-state-default"><?php print _txt('fd.attr.ldap');
?></th>
- <th class="ui-state-default"><?php print _txt('fd.attr.saml');
?></th>
+ <th class="ui-state-default"><?php print _txt('fd.attr.env');
?></th>
+ <!-- <th class="ui-state-default"><?php /*print
_txt('fd.attr.ldap');*/ ?></th>
+ <th class="ui-state-default"><?php /*print _txt('fd.attr.saml');*/
?></th>
+ -->
</tr>
- <?php foreach ($cmp_ef_attribute_order as $f): ?>
+ <?php foreach (array_keys($vv_availableAttributes) as $attr): ?>
+ <?php
+ $xprefix = 'CmpEnrollmentAttribute.' . $xindex;
+ $xindex++;
+
+ print $this->Form->hidden($xprefix .
'.cmp_enrollment_configuration_id',
+ array('value' =>
Sanitize::html($cmp_enrollment_configurations[0]['CmpEnrollmentConfiguration']['id'])));
+ print $this->Form->hidden($xprefix . '.attribute',
+ array('value' => $attr));
+
+ if(isset($currentAttributes[$attr]['id'])) {
+ print $this->Form->hidden($xprefix . '.id',
+ array('value' =>
$currentAttributes[$attr]['id']));
+ }
+ ?>
<tr class="line<?php print ($l % 2); $l++; ?>">
+ <td><?php print $vv_availableAttributes[$attr]['label']; ?></td>
+ <td>
+ <?php
+ global $cm_lang, $cm_texts;
+ $attrs = array();
+ $attrs['value'] = (isset($currentAttributes[$attr]['required'])
+ ? ($currentAttributes[$attr]['required'])
+ :
$vv_availableAttributes[$attr]['required']);
+ $attrs['empty'] = false;
+
+ if($e) {
+ print $this->Form->select($xprefix.'.required',
+ $cm_texts[ $cm_lang
]['en.required'],
+ $attrs);
+
+ if($this->Form->isFieldError($xprefix.'.required')) {
+ print $this->Form->error($xprefix.'.required');
+ }
+ } else {
+ print _txt('en.required', null, $attrs['value']);
+ }
+ ?>
+ </td>
+ <td><?php
+ $attrs = array();
+ $attrs['default'] =
$vv_availableAttributes[$attr]['env_name'];
+ $attrs['size'] = '40';
+ if(isset($currentAttributes[$attr]['env_name'])) {
+ $attrs['value'] = $currentAttributes[$attr]['env_name'];
+ }
+
+ print ($e
+ ? $this->Form->input($xprefix . '.env_name', $attrs)
+ :
Sanitize::html($vv_availableAttributes[$attr]['env_name'])); ?>
+ <!--
+ <td><?php /*print ($e
+ ? $this->Form->input($xprefix . '.ldap_name',
+ array('default' =>
$vv_availableAttributes[$attr]['ldap_name'],
+ 'size' => '40'))
+ :
Sanitize::html($vv_availableAttributes[$attr]['env_name']));*/ ?>
+ <td><?php /*print ($e
+ ? $this->Form->input($xprefix . '.saml_name',
+ array('default' =>
$vv_availableAttributes[$attr]['saml_name'],
+ 'size' => '40'))
+ :
Sanitize::html($vv_availableAttributes[$attr]['env_name']));*/ ?>
+ -->
+ </tr>
+ <?php endforeach; ?>
+
+
+ <?php foreach (array() as $f): ?>
+ <tr class="line<?php print ($l % 2); $l++; ?>">
<?php
$a =
find_ef_attribute($this->request->data['CmpEnrollmentAttribute'], $f['attr'],
$f['type']);

@@ -230,14 +309,14 @@
?>
</td>
<td>
- <?php print ($e
+ <?php /*print ($e
?
$this->Form->input('CmpEnrollmentAttribute.'.$a['_index'].'.ldap_name')
- : Sanitize::html($a['ldap_name'])); ?>
+ : Sanitize::html($a['ldap_name']));*/ ?>
</td>
<td>
- <?php print ($e
+ <?php /*print ($e
?
$this->Form->input('CmpEnrollmentAttribute.'.$a['_index'].'.saml_name')
- : Sanitize::html($a['saml_name'])); ?>
+ : Sanitize::html($a['saml_name']));*/ ?>
</td>
</tr>
<?php endforeach; ?>

Modified: registry/trunk/app/View/OrgIdentities/fields.inc
===================================================================
--- registry/trunk/app/View/OrgIdentities/fields.inc 2013-08-28 10:29:51
UTC (rev 580)
+++ registry/trunk/app/View/OrgIdentities/fields.inc 2013-08-29 00:07:34
UTC (rev 581)
@@ -262,91 +262,6 @@
?>
</td>
</tr>
- <?php if(0): ?>
- <?php foreach ($cmp_ef_attribute_order as $f): ?>
- <?php
- // Find this attribute in the CMP enrollment flow configuration
- $a =
find_ef_attribute($cmp_ef_attributes['CmpEnrollmentAttribute'], $f['attr'],
$f['type']);
-
- // Skip this one if not found or not permitted
- if(!$a || $a['required'] == RequiredEnum::NotPermitted)
- continue;
-
- // Convert table:column into usable bits
- if(preg_match('/:/', $f['attr']))
- {
- $attr = preg_split('/:/', $f['attr'], 2);
- $m = Inflector::classify($attr[0]); // names -> Name
-
- // Associated models must be referenced as Model.0.field for
HABTM,
- // or Model.field for HasOne
- if(isset($f['assoc']) && $f['assoc'] != 'hasone')
- $d = '.0.';
- else
- $d = '.';
-
- $fattr = $m.$d.$attr[1];
-
- // Create hidden fields for associated models
-
- if(!isset($emitted[$m]))
- {
- print $this->Form->hidden($m.$d.'id');
- print $this->Form->hidden($m.$d.'type', array('default' =>
$f['type']));
-
- $emitted[$m] = true;
- }
- }
- else
- {
- // Set up matching array
- $attr[0] = 'org_identities';
- $attr[1] = $f['attr'];
- $m = Inflector::classify($attr[0]); // names -> Name
- $fattr = $attr[1];
- }
- ?>
- <tr class="line<?php print ($l % 2); $l++; ?>">
- <td>
- <?php
- print $f['label'];
-
- if($a['required'] == RequiredEnum::Required)
- print '<font class="required">*</font>';
-
- if($e && isset($f['desc']))
- print " " . $f['desc'];
- ?>
- </td>
- <td>
- <?php
- if(isset($f['select']))
- {
- // Render a select element
- $attrs['value'] = (isset($org_identities[0][$m][
$attr[1] ])
- ? $org_identities[0][$m][ $attr[1] ]
- : $f['select']['default']);
- $attrs['empty'] = false;
-
- print ($e ? $this->Form->select($fattr,
- $f['select']['options'],
- $attrs)
- : Sanitize::html($org_identities[0][$m][
$attr[1] ]));
-
- if($this->Form->isFieldError($fattr)) {
- print $this->Form->error($fattr);
- }
- }
- else
- {
- // Use default rendering
- print ($e ? $this->Form->input($fattr) :
Sanitize::html($org_identities[0][$m][ $attr[1] ]));
- }
- ?>
- </td>
- </tr>
- <?php endforeach; ?>
- <?php endif; ?>
</tbody>
</table>
</div>



  • [comanage-dev] r581 - in registry/trunk/app: Config/Schema Controller Lib Model View/CmpEnrollmentConfigurations View/OrgIdentities, svnlog, 08/28/2013

Archive powered by MHonArc 2.6.16.

Top of Page