Skip to Content.
Sympa Menu

comanage-dev - [comanage-dev] r307 - in registry/trunk/app: Config Config/Schema Controller Lib Model View View/CoExtendedTypes View/CoExtendedTypes/json View/CoExtendedTypes/xml View/CoPeople View/Elements View/Identifiers View/OrgIdentities View/Pages

Subject: COmanage Developers List

List archive

[comanage-dev] r307 - in registry/trunk/app: Config Config/Schema Controller Lib Model View View/CoExtendedTypes View/CoExtendedTypes/json View/CoExtendedTypes/xml View/CoPeople View/Elements View/Identifiers View/OrgIdentities View/Pages


Chronological Thread 
  • From:
  • To:
  • Subject: [comanage-dev] r307 - in registry/trunk/app: Config Config/Schema Controller Lib Model View View/CoExtendedTypes View/CoExtendedTypes/json View/CoExtendedTypes/xml View/CoPeople View/Elements View/Identifiers View/OrgIdentities View/Pages
  • Date: Thu, 5 Jul 2012 18:34:57 -0400

Author: benno
Date: 2012-07-05 18:34:57 -0400 (Thu, 05 Jul 2012)
New Revision: 307

Added:
registry/trunk/app/Controller/CoExtendedTypesController.php
registry/trunk/app/Model/CoExtendedType.php
registry/trunk/app/View/CoExtendedTypes/
registry/trunk/app/View/CoExtendedTypes/add.ctp
registry/trunk/app/View/CoExtendedTypes/edit.ctp
registry/trunk/app/View/CoExtendedTypes/fields.inc
registry/trunk/app/View/CoExtendedTypes/index.ctp
registry/trunk/app/View/CoExtendedTypes/json/
registry/trunk/app/View/CoExtendedTypes/json/add.ctp
registry/trunk/app/View/CoExtendedTypes/json/delete.ctp
registry/trunk/app/View/CoExtendedTypes/json/edit.ctp
registry/trunk/app/View/CoExtendedTypes/json/index.ctp
registry/trunk/app/View/CoExtendedTypes/json/view.ctp
registry/trunk/app/View/CoExtendedTypes/view.ctp
registry/trunk/app/View/CoExtendedTypes/xml/
registry/trunk/app/View/CoExtendedTypes/xml/add.ctp
registry/trunk/app/View/CoExtendedTypes/xml/delete.ctp
registry/trunk/app/View/CoExtendedTypes/xml/edit.ctp
registry/trunk/app/View/CoExtendedTypes/xml/index.ctp
registry/trunk/app/View/CoExtendedTypes/xml/view.ctp
Modified:
registry/trunk/app/Config/Schema/schema.xml
registry/trunk/app/Config/routes.php
registry/trunk/app/Controller/AppController.php
registry/trunk/app/Controller/IdentifiersController.php
registry/trunk/app/Controller/PagesController.php
registry/trunk/app/Lib/enum.php
registry/trunk/app/Lib/lang.php
registry/trunk/app/Model/AppModel.php
registry/trunk/app/Model/CoEnrollmentAttribute.php
registry/trunk/app/Model/CoPetition.php
registry/trunk/app/Model/Identifier.php
registry/trunk/app/View/CoPeople/fields.inc
registry/trunk/app/View/Elements/dropMenu.ctp
registry/trunk/app/View/Identifiers/fields.inc
registry/trunk/app/View/Identifiers/index.ctp
registry/trunk/app/View/OrgIdentities/fields.inc
registry/trunk/app/View/Pages/home.ctp
Log:
Extended Types (CO-362)

Modified: registry/trunk/app/Config/Schema/schema.xml
===================================================================
--- registry/trunk/app/Config/Schema/schema.xml 2012-07-05 22:19:41 UTC (rev
306)
+++ registry/trunk/app/Config/Schema/schema.xml 2012-07-05 22:34:57 UTC (rev
307)
@@ -5,7 +5,7 @@
Version: $Revision$
Date: $Date$

- Copyright (C) 2010-2011 University Corporation for Advanced Internet
Development, Inc.
+ Copyright (C) 2010-2012 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
@@ -231,13 +231,39 @@
</index>
</table>

+ <table name="co_extended_types">
+ <field name="id" type="I">
+ <key />
+ <autoincrement />
+ </field>
+ <field name="co_id" type="I">
+ <notnull />
+ <constraint>REFERENCES cm_cos(id)</constraint>
+ </field>
+ <field name="attribute" type="C" size="32" />
+ <field name="name" type="C" size="32" />
+ <field name="display_name" type="C" size="64" />
+ <field name="status" type="C" size="2" />
+
+ <index name="co_extended_types_i1">
+ <col>co_id</col>
+ <col>attribute</col>
+ </index>
+
+ <index name="co_extended_types_i2">
+ <col>co_id</col>
+ <col>attribute</col>
+ <col>name</col>
+ </index>
+ </table>
+
<table name="identifiers">
<field name="id" type="I">
<key />
<autoincrement />
</field>
<field name="identifier" type="C" size="256" />
- <field name="type" type="C" size="2" />
+ <field name="type" type="C" size="32" />
<field name="login" type="L" />
<field name="co_person_id" type="I">
<constraint>REFERENCES cm_co_people(id)</constraint>
@@ -247,6 +273,12 @@
</field>
<field name="created" type="T" />
<field name="modified" type="T" />
+
+ <index name="identifiers_i1">
+ <col>identifier</col>
+ <col>type</col>
+ <col>co_person_id</col>
+ </index>
</table>

<table name="co_invites">

Modified: registry/trunk/app/Config/routes.php
===================================================================
--- registry/trunk/app/Config/routes.php 2012-07-05 22:19:41 UTC (rev
306)
+++ registry/trunk/app/Config/routes.php 2012-07-05 22:34:57 UTC (rev
307)
@@ -44,6 +44,7 @@
Router::mapResources(array(
'addresses',
'co_extended_attributes',
+ 'co_extended_types',
'co_invites',
'co_groups',
'co_group_members',

Modified: registry/trunk/app/Controller/AppController.php
===================================================================
--- registry/trunk/app/Controller/AppController.php 2012-07-05 22:19:41
UTC (rev 306)
+++ registry/trunk/app/Controller/AppController.php 2012-07-05 22:34:57
UTC (rev 307)
@@ -63,6 +63,7 @@
*
* @since COmanage Registry v0.1
* @throws UnauthorizedException (REST)
+ * @throws InvalidArgumentException
*/

public function beforeFilter() {
@@ -81,29 +82,25 @@

$this->restful = true;
}
-
- if($this->requires_co && !$this->restful) {
- // Before we do anything else, check to see if a CO was provided if
required.
- // (It might impact our authz decisions.) If not, redirect to COs
controller.
+
+ if(!$this->restful) {
+ // Before we do anything else, check to see if a CO was provided.
+ // (It might impact our authz decisions.) Note that some models (eg:
MVPAs)
+ // might specify a CO, but might not. As of v0.6, we no longer
redirect to
+ // cos/select if we don't find a CO but one is required. Instead, we
throw
+ // an error.
+
// We can't check for RESTful here since $this->data isn't set yet for
post data.
-
+
// The CO might be specified as a named parameter "co" or posted as
"Co.id"
// or posted as "Model.co_id".
-
- $coid = -1;

- if(isset($this->params['named']['co']))
- $coid = $this->params['named']['co'];
- elseif(isset($this->request->data['Co']['id']))
- $coid = $this->request->data['Co']['id'];
- elseif(isset($this->request->data[$this->modelClass]['co_id']))
- $coid = $this->request->data[$this->modelClass]['co_id'];
-
+ $coid = $this->parseCOID();
+
if($coid == -1) {
- $this->Session->write('co-select.controller',
$this->params['controller']);
- $this->Session->write('co-select.action', $this->params['action']);
- $this->Session->write('co-select.args',
array_merge($this->params['named'], $this->params['pass']));
- $this->redirect(array('controller' => 'cos', 'action' => 'select'));
+ if($this->requires_co) {
+ throw new InvalidArgumentException(_txt('er.co.specify'));
+ }
} else {
// Retrieve CO Object. If this model doesn't have a direct
relationship, we'll temporarily bind the model

@@ -113,11 +110,16 @@

$this->loadModel('Co');
}
-
+
$this->cur_co = $this->Co->findById($coid);

if(!empty($this->cur_co)) {
$this->set("cur_co", $this->cur_co);
+
+ if(isset($this->Identifier)) {
+ // XXX This is a hack for CO-368 and should not be relied upon.
+ $this->Identifier->coId = $coid;
+ }
} else {
$this->Session->setFlash(_txt('er.co.unk-a', array($coid)), '',
array(), 'error');
$this->redirect(array('controller' => 'cos', 'action' =>
'select'));
@@ -502,10 +504,10 @@
return(false);
}

- // Check if a CO is required that one was specified.
+ // Try to find a CO, even if not required (some models may use it
even if not required).
// Note beforeFilter() may already have found a CO.

- if($this->requires_co && !isset($this->cur_co)) {
+ if(!isset($this->cur_co)) {
$coid = -1;

if(isset($reqdata['CoId']))
@@ -514,39 +516,49 @@
if($coid == -1) {
// The CO might be implied by another attribute

- if(isset($reqdata['CoPersonId'])) {
+ if(isset($reqdata['Person']['Type']) &&
$reqdata['Person']['Type'] == 'CO') {
$this->loadModel('CoPerson');
- $cop = $this->CoPerson->findById($reqdata['CoPersonId']);
+ $cop = $this->CoPerson->findById($reqdata['Person']['Id']);

// We've already pulled the CO data, so just set it rather than
// re-retrieving it below
- if(isset($cop['Co']))
+ if(isset($cop['Co'])) {
$this->cur_co['Co'] = $cop['Co'];
+ $coid = $this->cur_co['Co']['id'];
+ }
}
}

- if(!isset($this->cur_co)) {
- if($coid == -1) {
+ if(!isset($this->cur_co) && $coid != -1) {
+ // Retrieve CO Object.
+
+ if(!isset($this->Co)) {
+ // There might be a CO object under another object (eg:
CoOrgIdentityLink),
+ // but it's easier if we just explicitly load the model
+
+ $this->loadModel('Co');
+ }
+
+ $this->cur_co = $this->Co->findById($coid);
+
+ if(empty($this->cur_co)) {
$this->restResultHeader(403, "CO Does Not Exist");
return(false);
- } else {
- // Retrieve CO Object.
-
- if(!isset($this->Co)) {
- // There might be a CO object under another object (eg:
CoOrgIdentityLink),
- // but it's easier if we just explicitly load the model
-
- $this->loadModel('Co');
- }
-
- $this->cur_co = $this->Co->findById($coid);
-
- if(empty($this->cur_co)) {
- $this->restResultHeader(403, "CO Does Not Exist");
- return(false);
- }
}
}
+
+ if($this->requires_co && !isset($this->cur_co)) {
+ // If a CO is required and we didn't find one, bail
+
+ $this->restResultHeader(403, "CO Does Not Exist");
+ return(false);
+ }
+
+ if(($this->name == 'Identifiers') && isset($this->cur_co)) {
+ // XXX This is a hack for CO-368 and should not be relied upon.
+ $this->loadModel('Identifier');
+ $this->Identifier->coId = $coid;
+ }
}

// Check the expected elements exist in the model (schema).
@@ -903,6 +915,30 @@
}

/**
+ * For Models that accept a CO ID, find the provided CO ID.
+ * - precondition: A coid must be provided in $this->request (params or
data)
+ *
+ * @since COmanage Registry v0.6
+ * @return Integer The CO ID if found, or -1 if not
+ */
+
+ function parseCOID() {
+ // Get a pointer to our model
+ $req = $this->modelClass;
+
+ $coid = -1;
+
+ if(isset($this->params['named']['co']))
+ $coid = $this->params['named']['co'];
+ elseif(isset($this->request->data['Co']['id']))
+ $coid = $this->request->data['Co']['id'];
+ elseif(isset($this->request->data[$req]['co_id']))
+ $coid = $this->request->data[$req]['co_id'];
+
+ return $coid;
+ }
+
+ /**
* For Models that accept a CO Person ID, a CO Person Role ID or an Org
Identity ID,
* find the provided person ID.
* - precondition: A copersonid, copersonroleid, or orgidentityid must be
provided in $this->request (params or data)
@@ -1092,9 +1128,6 @@
// Manage any CO (or COU) population?
$p['menu']['petitions'] = $cmr['admin'] || $cmr['subadmin'];

- // Manage CO extended attributes?
- $p['menu']['extattrs'] = $cmr['admin'];
-
// Manage COU definitions?
$p['menu']['cous'] = $cmr['admin'];


Modified: registry/trunk/app/Controller/IdentifiersController.php
===================================================================
--- registry/trunk/app/Controller/IdentifiersController.php 2012-07-05
22:19:41 UTC (rev 306)
+++ registry/trunk/app/Controller/IdentifiersController.php 2012-07-05
22:34:57 UTC (rev 307)
@@ -37,6 +37,22 @@
);

/**
+ * Callback before other controller methods are invoked or views are
rendered.
+ * - postcondition: Redirect may be issued
+ *
+ * @since COmanage Registry v0.6
+ */
+
+ function beforeFilter() {
+ parent::beforeFilter();
+
+ // Identifier supports Extended Types. Figure out what types are defined
+ // in order for the views to render properly.
+
+ $this->set('identifier_types',
$this->Identifier->types($this->cur_co['Co']['id']));
+ }
+
+ /**
* Perform any dependency checks required prior to a write (add/edit)
operation.
* This method is intended to be overridden by model-specific controllers.
* - postcondition: Session flash message updated (HTML) or HTTP status
returned (REST)

Modified: registry/trunk/app/Controller/PagesController.php
===================================================================
--- registry/trunk/app/Controller/PagesController.php 2012-07-05 22:19:41
UTC (rev 306)
+++ registry/trunk/app/Controller/PagesController.php 2012-07-05 22:34:57
UTC (rev 307)
@@ -119,6 +119,9 @@
// Manage CO extended attributes?
$p['menu']['extattrs'] = $cmr['admin'];

+ // Manage CO extended typees?
+ $p['menu']['exttypes'] = $cmr['admin'];
+
// Manage COU definitions?
$p['menu']['cous'] = $cmr['admin'];


Modified: registry/trunk/app/Lib/enum.php
===================================================================
--- registry/trunk/app/Lib/enum.php 2012-07-05 22:19:41 UTC (rev 306)
+++ registry/trunk/app/Lib/enum.php 2012-07-05 22:34:57 UTC (rev 307)
@@ -117,27 +117,11 @@

class IdentifierEnum
{
- const ePPN = 'EP';
- const ePTID = 'ET';
- const Mail = 'M';
- const OpenID = 'OP';
- const UID = 'U';
- /*
- public $from_api = array(
- "ePPN" => ePPN,
- "ePTID" => ePTID,
- "Mail" => Mail,
- "OpenID" => OpenID,
- "UID" => UID
- );
-
- public $to_api = array(
- ePPN => "ePPN",
- ePTID => "ePTID",
- Mail => "Mail",
- OpenID => "OpenID",
- UID => "UID"
- );*/
+ const ePPN = 'eppn';
+ const ePTID = 'eptid';
+ const Mail = 'mail';
+ const OpenID = 'openid';
+ const UID = 'uid';
}

class NameEnum
@@ -297,19 +281,19 @@
*/

$identifier_t = array(
- 'EP' => 'ePPN',
- 'ET' => 'ePTID',
- 'M' => 'Mail',
- 'OP' => 'OpenID',
- 'U' => 'UID'
+ 'eppn' => 'ePPN',
+ 'eptid' => 'ePTID',
+ 'mail' => 'Mail',
+ 'openid' => 'OpenID',
+ 'uid' => 'UID'
);

$identifier_ti = array(
- 'ePPN' => 'EP',
- 'ePTID' => 'ET',
- 'Mail' => 'M',
- 'OpenID' => 'OP',
- 'UID' => 'U'
+ 'ePPN' => 'eppn',
+ 'ePTID' => 'eptid',
+ 'Mail' => 'mail',
+ 'OpenID' => 'openid',
+ 'UID' => 'uid'
);

$name_t = array(

Modified: registry/trunk/app/Lib/lang.php
===================================================================
--- registry/trunk/app/Lib/lang.php 2012-07-05 22:19:41 UTC (rev 306)
+++ registry/trunk/app/Lib/lang.php 2012-07-05 22:34:57 UTC (rev 307)
@@ -63,6 +63,8 @@
'ct.co_enrollment_flows.pl' => 'CO Enrollment Flows',
'ct.co_extended_attributes.1' => 'Extended Attribute',
'ct.co_extended_attributes.pl' => 'Extended Attributes',
+ 'ct.co_extended_types.1' => 'Extended Type',
+ 'ct.co_extended_types.pl' => 'Extended Types',
'ct.co_group_members.1' => 'Group Member',
'ct.co_group_members.pl' => 'Group Members',
'ct.co_groups.1' => 'Group',
@@ -194,6 +196,7 @@
'er.co.exists' => 'A CO named "%1$s" already exists',
'er.co.gr.admin' => 'CO created, but failed to create initial admin group',
'er.co.none' => 'No COs found (did you run setup.php?)',
+ 'er.co.specify' => 'No CO Specified',
'er.co.unk' => 'Unknown CO',
'er.co.unk-a' => 'Unknown CO "%1$s"',
'er.coef.unk' => 'Unknown CO Enrollment Flow',
@@ -223,6 +226,9 @@
'er.ea.table' => 'Failed to create CO Extended Attribute table',
'er.ea.table.d' => 'Failed to drop CO Extended Attribute table',
'er.efcf.init' => 'Failed to set up initial CMP Enrollment
Configuration',
+ 'er.et.default' => 'Failed to add default types',
+ 'er.et.exists' => 'An extended type named "%1$s" already exists',
+ 'er.et.inuse' => 'The extended type "%1$s" is in use by at least one
attribute within this CO and cannot be removed.',
'er.fields' => 'Please recheck your submission',
'er.gr.exists' => 'A group named "%1$s" already exists within the CO',
'er.gr.init' => 'Group created, but failed to set initial
owner/member',
@@ -246,6 +252,8 @@
'er.orgp.unk-a' => 'Unknown Org Identity "%1$s"',
'er.orgp.unpool' => 'Failed to unpool organizational identities',
'er.unknown' => 'Unknown value "%1$s"',
+
+ 'et.default' => 'There are no Extended Types currently defined for
this attribute. The default types are currently in use. When you create a new
Extended Type, the default types will automatically be added to this list.',

// Fields
'fd.action' => 'Action',
@@ -291,6 +299,7 @@
'fd.ea.label.desc' => 'The label to be displayed when prompting for this
attribute as part of the enrollment process',
'fd.ea.order' => 'Order',
'fd.ea.order.desc' => 'The order in which this attribute will be presented
(leave blank to append at the end of the current attributes)',
+ 'fd.et.forattr' => 'For Attribute',
'fd.ef.ae' => 'Enable Administrator Enrollment',
'fd.ef.ae.desc' => 'If enabled, allow the specified type(s) of
administrators to enroll organizational identities to the platform',
'fd.ef.aea' => 'Require Authentication For Administrator Enrollment',
@@ -466,7 +475,7 @@
* @param string Index of message to render
* @param array Substitutions for variables within localized text
* @param integer If <key> represents an array, the index of the
corresponding message
- * @return void
+ * @return string Localized text
*/

function _txt($key, $vars=null, $index=null)

Modified: registry/trunk/app/Model/AppModel.php
===================================================================
--- registry/trunk/app/Model/AppModel.php 2012-07-05 22:19:41 UTC (rev
306)
+++ registry/trunk/app/Model/AppModel.php 2012-07-05 22:34:57 UTC (rev
307)
@@ -33,6 +33,35 @@
*/
class AppModel extends Model {
/**
+ * For models that support Extended Types, obtain the default types.
+ *
+ * @since COmanage Registry v0.6
+ * @return Array Default types as key/value pair of name and localized
display_name
+ */
+
+ public function defaultTypes() {
+ // We currently assume there is only one type and it is called "type".
This may
+ // not always be true.
+
+ $ret = null;
+
+ if(isset($this->validate['type']['rule'])
+ && is_array($this->validate['type']['rule'])
+ && $this->validate['type']['rule'][0] == 'validateExtendedType'
+ && is_array($this->validate['type']['rule'][1])) {
+ // Figure out which language key to use. Note 'en' is the prefix for
'enum'
+ // and NOT an abbreviation for 'english'.
+ $langKey = 'en.' . Inflector::underscore($this->name);
+
+ foreach($this->validate['type']['rule'][1] as $name) {
+ $ret[$name] = _txt($langKey, null, $name);
+ }
+ }
+
+ return $ret;
+ }
+
+ /**
* Filter a model's related data according, removing optional related
models that
* weren't provided, and pulling the model up a level to prepare it for
save().
*
@@ -118,14 +147,14 @@
// attributes are empty, consider the attribute to be not
provided for
// validation purposes. (If any was provided, consider the
attribute to
// be provided, and let validation determine if everything is
OK.)
-
+
foreach(array_keys($this->$eAttrName->validate) as $eAttrField) {
// We check both required and notEmpty, since we're currently
transitioning from the former
- // to the latter. We skip 'type' since it's a required field
and the petition-generated
+ // to the latter. We skip 'type' and 'status' since it's a
required field and the petition-generated
// forms generally provide it, but it's not an indication if a
field is actually being
// filled in.

- if($eAttrField == 'type')
+ if($eAttrField == 'type' || $eAttrField == 'status')
continue;

if((isset($this->$eAttrName->validate[$eAttrField]['required'])
@@ -168,6 +197,78 @@
}

/**
+ * For models that support Extended Types, obtain the valid types for the
specified CO.
+ *
+ * @since COmanage Registry v0.6
+ * @param CO ID
+ * @return Array Defined types (including defaults if no extended types)
in key/value form suitable for select buttons.
+ */
+
+ function types($coId) {
+ $ret = array();
+
+ $CoExtendedType = ClassRegistry::init('CoExtendedType');
+
+ $extTypes = $CoExtendedType->active($this->coId, $this->name, 'all');
+
+ if(!empty($extTypes)) {
+ foreach($extTypes as $t) {
+ $ret[ $t['CoExtendedType']['name'] ] =
$t['CoExtendedType']['display_name'];
+ }
+ } else {
+ // Use the default set
+
+ $ret = $this->defaultTypes();
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Determine if a string is a valid extended type.
+ *
+ * @since COmanage Registry v0.6
+ * @param array Array of fields to validate
+ * @param array Array of default values, if no extended types are defined
+ * @return boolean True if all field strings parses to a valid timestamp,
false otherwise
+ */
+
+ function validateExtendedType($a, $d) {
+ // First obtain active extended types, if any.
+
+ $extTypes = array();
+
+ // We need access to the CO ID to know what types are valid, but we
don't have it since
+ // $cur_co is attached to the controller and not the model (and we don't
directly call
+ // validation -- that's done in the core of Cake). As an interim hack,
beforeFilter
+ // or checkRestPost will set the CO ID for us. However, the better
approach (possible with
+ // Cake 2.2) is to generate a dynamic validation rule is the controller,
using the current
+ // CO as an argument. See CO-368.
+
+ if(isset($this->coId)) {
+ $CoExtendedType = ClassRegistry::init('CoExtendedType');
+
+ $extTypes = $CoExtendedType->active($this->coId, $this->name);
+ }
+ // else some models can be used with Org Identities (ie: MVPA
controllers). When used
+ // with org identities, we currently don't support extended types.
+
+ if(empty($extTypes)) {
+ // Use the default values
+
+ $extTypes = $d;
+ }
+
+ foreach(array_keys($a) as $f) {
+ if(!isset($extTypes[ $a[$f] ])) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
* Determine if a string represents a valid timestamp. This function is
intended
* to be used as a validation rule.
*

Modified: registry/trunk/app/Model/CoEnrollmentAttribute.php
===================================================================
--- registry/trunk/app/Model/CoEnrollmentAttribute.php 2012-07-05 22:19:41
UTC (rev 306)
+++ registry/trunk/app/Model/CoEnrollmentAttribute.php 2012-07-05 22:34:57
UTC (rev 307)
@@ -104,9 +104,13 @@
foreach(array_keys($cm_texts[ $cm_lang ]['en.name']) as $k)
$ret['p:name:'.$k] = _txt('fd.name') . " (" . $cm_texts[ $cm_lang
]['en.name'][$k] . ", " . _txt('ct.co_people.1') . ")";

- foreach(array_keys($cm_texts[ $cm_lang ]['en.identifier']) as $k)
- $ret['p:identifier:'.$k] = _txt('fd.identifier.identifier') . " (" .
$cm_texts[ $cm_lang ]['en.identifier'][$k] . ", " . _txt('ct.co_people.1') .
")";
+ // Identifier types can be extended, and so require a bit of work to
assemble
+ $coExtendedType = ClassRegistry::init('CoExtendedType');
+ $identifierTypes = $coExtendedType->active($coid, 'Identifier', 'list');

+ foreach(array_keys($identifierTypes) as $k)
+ $ret['p:identifier:'.$k] = _txt('fd.identifier.identifier') . " (" .
$identifierTypes[$k] . ", " . _txt('ct.co_people.1') . ")";
+
foreach(array_keys($cm_texts[ $cm_lang ]['en.contact.mail']) as $k)
$ret['p:email_address:'.$k] = _txt('fd.email_address.mail') . " (" .
$cm_texts[ $cm_lang ]['en.contact.mail'][$k] . ", " . _txt('ct.co_people.1')
. ")";

@@ -370,13 +374,23 @@
&&
!$attrModel->validate[$k]['allowEmpty']);

- // We hide type
- $attr['hidden'] = ($k == 'type' ? 1 : 0);
+ // We hide type and status
+ $attr['hidden'] = ($k == 'type' || $k == 'status' ? 1 : 0);

if($attr['hidden']) {
- // Populate a default value. For now, the only hidden
attribute is type,
- // so we can get away with just using $attrType.
- $attr['default'] = $attrType;
+ // Populate a default value.
+
+ switch($k) {
+ case 'type':
+ // Just use $attrType
+ $attr['default'] = $attrType;
+ break;
+ case 'status':
+ // For now, status is always set to Active
+ $attr['default'] = StatusEnum::Active;
+ break;
+ }
+
} else {
// Label
$attr['label'] = $efAttr['CoEnrollmentAttribute']['label'] .
": " . _txt('fd.' . $attrName . '.' . $k);

Modified: registry/trunk/app/Model/CoPetition.php
===================================================================
--- registry/trunk/app/Model/CoPetition.php 2012-07-05 22:19:41 UTC (rev
306)
+++ registry/trunk/app/Model/CoPetition.php 2012-07-05 22:34:57 UTC (rev
307)
@@ -224,6 +224,23 @@

$this->$m[0]->$m[1]->validate[ $efAttr['field'] ]['required'] =
$efAttr['required'];
$this->$m[0]->$m[1]->validate[ $efAttr['field'] ]['allowEmpty'] =
!$efAttr['required'];
+
+ // Temporary hack for CO-368. When the Petition save writes the
Identifier model, the
+ // Identifier model has no way of receiving the CO ID. So for now we
change the validation
+ // rule for validateExtendedType.
+
+ if(isset($this->$m[0]->$m[1]->validate[ $efAttr['field']
]['rule'][0])
+ && $this->$m[0]->$m[1]->validate[ $efAttr['field'] ]['rule'][0]
== 'validateExtendedType') {
+ // Change rule[0] to inList and rule[1] to the list as returned by
CoExtendedType::active
+
+ $this->$m[0]->$m[1]->validate[ $efAttr['field'] ]['rule'] =
array();
+ $this->$m[0]->$m[1]->validate[ $efAttr['field'] ]['rule'][] =
'inList';
+
+ $coExtendedType = ClassRegistry::init('CoExtendedType');
+ $this->$m[0]->$m[1]->validate[ $efAttr['field'] ]['rule'][] =
array_keys($coExtendedType->active($coId,
+
$m[1],
+
'list'));
+ }
}
}


Modified: registry/trunk/app/Model/Identifier.php
===================================================================
--- registry/trunk/app/Model/Identifier.php 2012-07-05 22:19:41 UTC (rev
306)
+++ registry/trunk/app/Model/Identifier.php 2012-07-05 22:34:57 UTC (rev
307)
@@ -52,11 +52,12 @@
'allowEmpty' => false
),
'type' => array(
- 'rule' => array('inList', array(IdentifierEnum::ePPN,
- IdentifierEnum::ePTID,
- IdentifierEnum::Mail,
- IdentifierEnum::OpenID,
- IdentifierEnum::UID)),
+ 'rule' => array('validateExtendedType',
+ array(IdentifierEnum::ePPN,
+ IdentifierEnum::ePTID,
+ IdentifierEnum::Mail,
+ IdentifierEnum::OpenID,
+ IdentifierEnum::UID)),
'required' => false,
'allowEmpty' => false
),
@@ -77,6 +78,29 @@
// Enum type hints

public $cm_enum_types = array(
- 'type' => 'identifier_t'
+ 'status' => 'status_t'
);
+
+ /**
+ * Check if a given identifier type is in use by any members of a CO.
+ *
+ * @since COmanage Registry v0.6
+ * @param String Type of identifier (any default or extended type may be
specified)
+ * @param Integer CO ID
+ * @return Boolean True if the identifier type is in use, false otherwise
+ */
+
+ public function typeInUse($identifierType, $coId) {
+ $args['conditions']['CoPerson.co_id'] = $coId;
+ $args['conditions']['Identifier.type'] = $identifierType;
+ $args['joins'][0]['table'] = 'co_people';
+ $args['joins'][0]['alias'] = 'CoPerson';
+ $args['joins'][0]['type'] = 'INNER';
+ $args['joins'][0]['conditions'][0] =
'CoPerson.id=Identifier.co_person_id';
+
+ // Need to unbind the related models so Cake generates the right SQL
+ $this->unbindModel(array('belongsTo' => array('CoPerson',
'OrgIdentity')));
+
+ return (boolean)$this->find('count', $args);
+ }
}


Property changes on: registry/trunk/app/View/CoExtendedTypes/add.ctp
___________________________________________________________________
Added: svn:special
+ *


Property changes on: registry/trunk/app/View/CoExtendedTypes/edit.ctp
___________________________________________________________________
Added: svn:special
+ *


Property changes on: registry/trunk/app/View/CoExtendedTypes/json/add.ctp
___________________________________________________________________
Added: svn:special
+ *


Property changes on: registry/trunk/app/View/CoExtendedTypes/json/delete.ctp
___________________________________________________________________
Added: svn:special
+ *


Property changes on: registry/trunk/app/View/CoExtendedTypes/json/edit.ctp
___________________________________________________________________
Added: svn:special
+ *


Property changes on: registry/trunk/app/View/CoExtendedTypes/json/index.ctp
___________________________________________________________________
Added: svn:special
+ *


Property changes on: registry/trunk/app/View/CoExtendedTypes/json/view.ctp
___________________________________________________________________
Added: svn:special
+ *


Property changes on: registry/trunk/app/View/CoExtendedTypes/view.ctp
___________________________________________________________________
Added: svn:special
+ *


Property changes on: registry/trunk/app/View/CoExtendedTypes/xml/add.ctp
___________________________________________________________________
Added: svn:special
+ *


Property changes on: registry/trunk/app/View/CoExtendedTypes/xml/delete.ctp
___________________________________________________________________
Added: svn:special
+ *


Property changes on: registry/trunk/app/View/CoExtendedTypes/xml/edit.ctp
___________________________________________________________________
Added: svn:special
+ *


Property changes on: registry/trunk/app/View/CoExtendedTypes/xml/index.ctp
___________________________________________________________________
Added: svn:special
+ *


Property changes on: registry/trunk/app/View/CoExtendedTypes/xml/view.ctp
___________________________________________________________________
Added: svn:special
+ *

Modified: registry/trunk/app/View/CoPeople/fields.inc
===================================================================
--- registry/trunk/app/View/CoPeople/fields.inc 2012-07-05 22:19:41 UTC (rev
306)
+++ registry/trunk/app/View/CoPeople/fields.inc 2012-07-05 22:34:57 UTC (rev
307)
@@ -207,7 +207,7 @@
array('controller' =>
'identifiers', 'action' => 'edit', $id['id'], 'co' => $cur_co['Co']['id']),
array('class' => 'editbutton')) .
"\n";
echo $this->Html->link($id['identifier'],
array('controller' => 'identifiers', 'action' => 'edit', $id['id'], 'co' =>
$cur_co['Co']['id']));
- echo " (" . _txt('en.identifier', null, $id['type'])
. ")<br />\n";
+ echo " (" . $id['type'] . ")<br />\n";
}
}

@@ -219,7 +219,7 @@
{
if(isset($co_people[0]['Identifier']))
foreach($co_people[0]['Identifier'] as $id)
- echo Sanitize::html($id['identifier']) . " (" .
_txt('en.identifier', null, $id['type']) . ")<br />\n";
+ echo Sanitize::html($id['identifier']) . " (" .
$id['type'] . ")<br />\n";
}
?>
</td>
@@ -228,7 +228,7 @@
<?php
if(isset($org_identities[0]['Identifier']))
foreach($org_identities[0]['Identifier'] as $id)
- echo Sanitize::html($id['identifier']) . " (" .
_txt('en.identifier', null, $id['type']) . ")<br />\n";
+ echo Sanitize::html($id['identifier']) . " (" .
$id['type'] . ")<br />\n";
?>
</td>
<?php endif; ?>

Modified: registry/trunk/app/View/Elements/dropMenu.ctp
===================================================================
--- registry/trunk/app/View/Elements/dropMenu.ctp 2012-07-05 22:19:41
UTC (rev 306)
+++ registry/trunk/app/View/Elements/dropMenu.ctp 2012-07-05 22:34:57
UTC (rev 307)
@@ -90,6 +90,17 @@
print "</li>";
}

+ if(isset($permissions['menu']['exttypes']) &&
$permissions['menu']['exttypes']) {
+ print "<li>";
+ $args = array(
+ 'controller' => 'co_extended_types',
+ 'action' => 'index',
+ 'co' => $menuCoId
+ );
+ print $this->Html->link(_txt('ct.co_extended_types.pl'),
$args);
+ print "</li>";
+ }
+
if(isset($permissions['menu']['coef']) &&
$permissions['menu']['coef']) {
print "<li>";
$args = array(

Modified: registry/trunk/app/View/Identifiers/fields.inc
===================================================================
--- registry/trunk/app/View/Identifiers/fields.inc 2012-07-05 22:19:41
UTC (rev 306)
+++ registry/trunk/app/View/Identifiers/fields.inc 2012-07-05 22:34:57
UTC (rev 307)
@@ -66,20 +66,20 @@
</td>
<td>
<?php
- global $identifier_t;
+ $attrs = array();
$attrs['value'] = (isset($identifiers) ?
$identifiers[0]['Identifier']['type'] : "");
$attrs['empty'] = false;

if($e) {
print $this->Form->select('type',
- $identifier_t,
+ $identifier_types,
$attrs);

if($this->Form->isFieldError('type')) {
print $this->Form->error('type');
}
} else {
- print Sanitize::html($identifier_t[
$identifiers[0]['Identifier']['type'] ]);
+ print $identifiers[0]['Identifier']['type'];
}
?>
</td>

Modified: registry/trunk/app/View/Identifiers/index.ctp
===================================================================
--- registry/trunk/app/View/Identifiers/index.ctp 2012-07-05 22:19:41
UTC (rev 306)
+++ registry/trunk/app/View/Identifiers/index.ctp 2012-07-05 22:34:57
UTC (rev 307)
@@ -57,7 +57,7 @@
?>
</td>
<td>
- <?php echo _txt('en.identifier', null, $a['Identifier']['type']); ?>
+ <?php echo $a['Identifier']['type']; ?>
</td>
<td>
<?php echo ($a['Identifier']['login'] ? _txt('fd.true') :
_txt('fd.false')); ?>

Modified: registry/trunk/app/View/OrgIdentities/fields.inc
===================================================================
--- registry/trunk/app/View/OrgIdentities/fields.inc 2012-07-05 22:19:41
UTC (rev 306)
+++ registry/trunk/app/View/OrgIdentities/fields.inc 2012-07-05 22:34:57
UTC (rev 307)
@@ -208,7 +208,7 @@
'action' =>
'edit',
$id['id'],
'co' =>
($pool_org_identities ? false : $cur_co['Co']['id'])));
- print " (" . _txt('en.identifier', null, $id['type']) .
")<br />\n";
+ print " (" . $id['type'] . ")<br />\n";
}
}

@@ -223,7 +223,7 @@
{
if(isset($org_identities[0]['Identifier']))
foreach($org_identities[0]['Identifier'] as $id)
- print Sanitize::html($id['identifier']) . " (" .
_txt('en.identifier', null, $id['type']) . ")<br />\n";
+ print Sanitize::html($id['identifier']) . " (" . $id['type']
. ")<br />\n";
}
?>
</td>

Modified: registry/trunk/app/View/Pages/home.ctp
===================================================================
--- registry/trunk/app/View/Pages/home.ctp 2012-07-05 22:19:41 UTC (rev
306)
+++ registry/trunk/app/View/Pages/home.ctp 2012-07-05 22:34:57 UTC (rev
307)
@@ -24,163 +24,7 @@
?>

<?php if($this->Session->check('Auth.User')): ?>
-<table id="mainmenu" width="100%">
- <tbody>
- <tr>
- <!-- Person Operations -->
- <td width="33%" valign="top">
- <?php
- $cos = $this->Session->read('Auth.User.cos');
-
- if(isset($permissions['menu']['coprofile']) &&
$permissions['menu']['coprofile'])
- {
- foreach($cos as $co)
- {
- print $this->Html->link("Manage My " . $co['co_name'] . "
Identity",
- array('controller' => 'co_people',
- 'action' => 'edit',
- $co['co_person_id'],
- 'co' => $co['co_id']),
- array('class' => 'menuitembutton'));
- }
- foreach($cos as $co)
- {
- $args = array('controller' => 'co_nsf_demographics',
- 'action' => 'editself',
- 'co' => $co['co_id']);
- $classArgs = array('class' => 'menuitembutton');
- print $this->Html->link("View My Demographics As Known To " .
$co['co_name'],
- $args,
- $classArgs);
- }
- }
-
- if(isset($permissions['menu']['cogroups']) &&
$permissions['menu']['cogroups'])
- {
- print $this->Html->link("View/Edit Groups",
- array('controller' => 'co_groups',
'action' => 'index'),
- array('class' => 'menuitembutton'));
- }
-
- if(isset($permissions['menu']['orgprofile']) &&
$permissions['menu']['orgprofile'])
- {
- // A user can have more than one org identity (keyed to their
COs) if pooling is
- // disabled, so loop through as appropriate.
-
- $orgIdentities =
$this->Session->read('Auth.User.org_identities');
-
- foreach($orgIdentities as $o)
- {
- if(isset($o['co_id']))
- {
- // Figure out the name of the CO
- $coName = '?';
-
- foreach($cos as $co)
- {
- if($co['co_id'] == $o['co_id'])
- {
- $coName = $co['co_name'];
- break;
- }
- }
-
- print $this->Html->link("View My Home Identity As Known To "
. $coName,
- array('controller' =>
'org_identities',
- 'action' => 'view',
- $o['org_id'],
- 'co' => $o['co_id']),
- array('class' => 'menuitembutton'));
- }
- else
- {
- print $this->Html->link("View My Home Identity",
- array('controller' =>
'org_identities',
- 'action' => 'view',
- $o['org_id']),
- array('class' => 'menuitembutton'));
- }
- }
- }
- ?>
- </td>
-
- <!-- CO Operations -->
- <td width="33%" valign="top">
- <?php
- if(isset($permissions['menu']['orgidentities']) &&
$permissions['menu']['orgidentities'])
- {
- print $this->Html->link("Organizational Identities",
- array('controller' => 'org_identities',
'action' => 'index'),
- array('class' => 'menuitembutton'));
- }
-
- if(isset($permissions['menu']['cos']) &&
$permissions['menu']['cos'])
- {
- print $this->Html->link("My Population",
- array('controller' => 'co_people',
'action' => 'index'),
- array('class' => 'menuitembutton'));
- }
-
- if(isset($permissions['menu']['cos']) &&
$permissions['menu']['cos'])
- {
- print $this->Html->link("CO Petitions",
- array('controller' => 'co_petitions',
'action' => 'index'),
- array('class' => 'menuitembutton'));
- }
-
- if(isset($permissions['menu']['extattrs']) &&
$permissions['menu']['extattrs'])
- {
- print $this->Html->link("Extended Attributes",
- array('controller' =>
'co_extended_attributes', 'action' => 'index'),
- array('class' => 'menuitembutton'));
- }
-
- if(isset($permissions['menu']['cous']) &&
$permissions['menu']['cous'])
- {
- print $this->Html->link("COUs",
- array('controller' => 'cous', 'action'
=> 'index'),
- array('class' => 'menuitembutton'));
- }
-
- if(isset($permissions['menu']['coef']) &&
$permissions['menu']['coef'])
- {
- print $this->Html->link("CO Enrollment Configuration",
- array('controller' =>
'co_enrollment_flows', 'action' => 'index'),
- array('class' => 'menuitembutton'));
- }
-
- if(isset($permissions['menu']['co_nsf_demographics']) &&
$permissions['menu']['co_nsf_demographics'])
- {
- print $this->Html->link("NSF Demographics",
- array('controller' =>
'co_nsf_demographics', 'action' => 'index'),
- array('class' => 'menuitembutton'));
- }
- ?>
- </td>
-
- <!-- Platform Operations -->
- <td width="33%" valign="top">
- <?php
- if(isset($permissions['menu']['admin']) &&
$permissions['menu']['admin'])
- {
- print $this->Html->link("COs",
- array('controller' => 'cos', 'action' =>
'index'),
- array('class' => 'menuitembutton'));
-
- print $this->Html->link("Organizations",
- array('controller' => 'organizations',
'action' => 'index'),
- array('class' => 'menuitembutton'));
-
- print $this->Html->link("CMP Enrollment Configuration",
- array('controller' =>
'cmp_enrollment_configurations', 'action' => 'select'),
- array('class' => 'menuitembutton'));
- }
- ?>
- </td>
- </tr>
- </tbody>
-</table>
+<p>Please select an action from the menu.</p>
<?php else: // Authenticated user? ?>
<p>
Welcome to COmanage Registry. Please login.



  • [comanage-dev] r307 - in registry/trunk/app: Config Config/Schema Controller Lib Model View View/CoExtendedTypes View/CoExtendedTypes/json View/CoExtendedTypes/xml View/CoPeople View/Elements View/Identifiers View/OrgIdentities View/Pages, svnlog, 07/05/2012

Archive powered by MHonArc 2.6.16.

Top of Page