comanage-dev - [comanage-dev] r664 - in registry/trunk/app: Controller Model View/CoGroups View/EmailAddresses
Subject: COmanage Developers List
List archive
[comanage-dev] r664 - in registry/trunk/app: Controller Model View/CoGroups View/EmailAddresses
Chronological Thread
- From:
- To:
- Subject: [comanage-dev] r664 - in registry/trunk/app: Controller Model View/CoGroups View/EmailAddresses
- Date: Sun, 2 Feb 2014 10:06:46 -0500
Author: benno
Date: 2014-02-02 10:06:46 -0500 (Sun, 02 Feb 2014)
New Revision: 664
Modified:
registry/trunk/app/Controller/AppController.php
registry/trunk/app/Controller/CoEnrollmentAttributesController.php
registry/trunk/app/Controller/CoInvitesController.php
registry/trunk/app/Controller/CoNotificationsController.php
registry/trunk/app/Controller/EmailAddressesController.php
registry/trunk/app/Model/CoEnrollmentAttribute.php
registry/trunk/app/Model/CoPetition.php
registry/trunk/app/View/CoGroups/index.ctp
registry/trunk/app/View/EmailAddresses/fields.inc
Log:
Support implied CO ID for CO-620
Modified: registry/trunk/app/Controller/AppController.php
===================================================================
--- registry/trunk/app/Controller/AppController.php 2014-02-01 20:20:14
UTC (rev 663)
+++ registry/trunk/app/Controller/AppController.php 2014-02-02 15:06:46
UTC (rev 664)
@@ -282,7 +282,6 @@
/**
* Determine the CO ID based on some attribute of the request.
- * This method is intended to be overridden by model-specific controllers.
*
* @since COmanage Registry v0.8.4
* @return Integer CO ID, or null if not implemented or not applicable.
@@ -290,6 +289,86 @@
*/
protected function calculateImpliedCoId() {
+ // As a default, we'll see if we can determine the CO in a generic
manner.
+ // Where this doesn't work, individual Controllers can override this
function.
+
+ // Get a pointer to our model
+ $req = $this->modelClass;
+ $model = $this->$req;
+ $modelpl = Inflector::tableize($req);
+
+ if($this->action == 'add' || $this->action == 'select') {
+ // See if what we're adding/selecting is attached to a person
+ $p = $this->parsePersonID();
+
+ if(!empty($p['copersonid'])
+ && (isset($model->CoPerson) || isset($model->Co))) {
+ $CoPerson = (isset($model->CoPerson) ? $model->CoPerson :
$model->Co->CoPerson);
+
+ $coId = $CoPerson->field('co_id', array('id' => $p['copersonid']));
+
+ if($coId) {
+ return $coId;
+ } else {
+ throw new InvalidArgumentException(_txt('er.notfound',
+
array(_txt('ct.co_people.1'),
+
Sanitize::html($p['copersonid']))));
+ }
+ } elseif(!empty($p['copersonroleid']) && isset($model->CoPersonRole)) {
+ $args = array();
+ $args['conditions']['CoPersonRole.id'] = $p['copersonroleid'];
+ $args['joins'][0]['table'] = 'co_person_roles';
+ $args['joins'][0]['alias'] = 'CoPersonRole';
+ $args['joins'][0]['type'] = 'INNER';
+ $args['joins'][0]['conditions'][0] =
'CoPerson.id=CoPersonRole.co_person_id';
+ $args['contain'] = false;
+
+ $obj = $model->CoPersonRole->CoPerson->find('first', $args);
+
+ if(!empty($obj['CoPerson']['co_id'])) {
+ return $obj['CoPerson']['co_id'];
+ } else {
+ throw new InvalidArgumentException(_txt('er.notfound',
+
array(_txt('ct.co_person_roles.1'),
+
Sanitize::html($p['copersonroleid']))));
+ }
+ } elseif(!empty($p['orgidentityid']) && isset($model->OrgIdentity)) {
+ $coId = $model->OrgIdentity->field('co_id', array('id' =>
$p['orgidentityid']));
+
+ if($coId) {
+ return $coId;
+ } else {
+ throw new InvalidArgumentException(_txt('er.notfound',
+
array(_txt('ct.org_identities.1'),
+
Sanitize::html($p['orgidentityid']))));
+ }
+ } elseif(!empty($this->request->params['named']['cogroup']) &&
isset($model->CoGroup)) {
+ // Map the group to a CO
+ $coId = $model->CoGroup->field('co_id', array('id' =>
$this->request->params['named']['cogroup']));
+
+ if($coId) {
+ return $coId;
+ } else {
+ throw new InvalidArgumentException(_txt('er.notfound',
+
array(_txt('ct.co_groups.1'),
+
Sanitize::html($this->request->params['named']['cogroup']))));
+ }
+ }
+ } else {
+ // We need a parameter that is probably an object ID
+
+ if(!empty($this->request->params['pass'][0])) {
+ try {
+ $recordCoId =
$model->findCoForRecord($this->request->params['pass'][0]);
+ }
+ catch(InvalidArgumentException $e) {
+ throw new InvalidArgumentException($e->getMessage());
+ }
+
+ return $recordCoId;
+ }
+ }
+
return null;
}
@@ -1275,20 +1354,33 @@
function parseCOID() {
// Get a pointer to our model
$req = $this->modelClass;
+ $model = $this->$req;
- // First try to look up the CO ID based on the request. This will become
more
- // common as part of CO-620.
+ // First try to look up the CO ID based on the request.
$coid = $this->calculateImpliedCoId();
if(!$coid) {
- 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'];
- else
- $coid = -1;
+ $coid = -1;
+
+ // Only certain actions are permitted to explicitly provide a CO ID
+ if($this->action == 'index'
+ // Add and select operations only when attached directly to a CO
(otherwise we need
+ // to pull the CO ID from the object being attached to, eg co
person)
+ ||
+ (isset($model->Co)
+ && ($this->action == 'select' || $this->action == 'add'))) {
+ if(isset($this->params['named']['co'])) {
+ $coid = $this->params['named']['co'];
+ }
+ // CO ID can be passed via a form submission
+ elseif($this->action != 'index') {
+ if(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;
Modified: registry/trunk/app/Controller/CoEnrollmentAttributesController.php
===================================================================
--- registry/trunk/app/Controller/CoEnrollmentAttributesController.php
2014-02-01 20:20:14 UTC (rev 663)
+++ registry/trunk/app/Controller/CoEnrollmentAttributesController.php
2014-02-02 15:06:46 UTC (rev 664)
@@ -2,7 +2,7 @@
/**
* COmanage Registry CO Enrollment Attributes Controller
*
- * Copyright (C) 2011-13 University Corporation for Advanced Internet
Development, Inc.
+ * Copyright (C) 2011-14 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-13 University Corporation for Advanced
Internet Development, Inc.
+ * @copyright Copyright (C) 2011-14 University Corporation for Advanced
Internet Development, Inc.
* @link http://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v0.3
@@ -96,70 +96,77 @@
// Figure out the CO ID associated with the current enrollment flow.
We'll specifically
// not set $this->cur_co since it will break things like pagination
setup.
- $coefid = -1;
+ $coefid = null;
- if(isset($this->request->params['named']['coef']))
- $coefid = $this->request->params['named']['coef'];
- elseif(isset($this->request->data))
- $coefid =
$this->request->data['CoEnrollmentAttribute']['co_enrollment_flow_id'];
-
- $this->CoEnrollmentAttribute->CoEnrollmentFlow->id = $coefid;
-
- $this->set('vv_coefid', Sanitize::html($coefid));
-
- $coid = $this->CoEnrollmentAttribute->CoEnrollmentFlow->field('co_id');
-
- if(!empty($coid))
- {
- $this->set('vv_coid', $coid);
+ if($this->action == 'add' || $this->action == 'index') {
+ // Accept coefid from the url
- // Assemble the set of available attributes for the view to render
+ $coefid = Sanitize::html($this->request->params['named']['coef']);
+ } elseif(!empty($this->request->params['pass'][0])) {
+ // Map the enrollment flow from the requested object
- $this->set('vv_available_attributes',
$this->CoEnrollmentAttribute->availableAttributes($coid));
+ $coefid = $this->CoEnrollmentAttribute->field('co_enrollment_flow_id',
+ array('id' =>
$this->request->params['pass'][0]));
+ }
+
+ if($coefid) {
+ $this->CoEnrollmentAttribute->CoEnrollmentFlow->id = $coefid;
- // And pull details of extended attributes so views can determine types
+ $this->set('vv_coefid', Sanitize::html($coefid));
- $args = array();
- $args['conditions']['co_id'] = $coid;
- $args['fields'] = array('CoExtendedAttribute.name',
'CoExtendedAttribute.type');
- $args['contain'] = false;
+ $coid = $this->CoEnrollmentAttribute->CoEnrollmentFlow->field('co_id');
- $this->set('vv_ext_attr_types',
-
$this->CoEnrollmentAttribute->CoEnrollmentFlow->Co->CoExtendedAttribute->find('list',
$args));
-
- // Assemble the list of available COUs
-
- $this->set('vv_cous',
$this->CoEnrollmentAttribute->CoEnrollmentFlow->Co->Cou->allCous($coid));
-
- // Assemble the list of available affiliations
-
- $this->set('vv_affiliations', $cm_texts[ $cm_lang ]['en.affil']);
-
- // Assemble the list of available Sponsors
-
- $this->set('vv_sponsors',
$this->CoEnrollmentAttribute->CoEnrollmentFlow->Co->CoPerson->sponsorList($coid));
-
- // Assemble the list of available groups. Note we currently allow any
group to be
- // specified (ie: whether or not it's open). The idea is that an
Enrollment Flow
- // is defined by an admin, who can correctly select a group. However,
it's plausible
- // that we should offer options to filter to open groups, or to a
subset of groups
- // as selected by the administrator (especially for scenarios where
the value is
- // modifiable).
-
- $args = array();
- $args['conditions']['co_id'] = $coid;
- $args['fields'] = array('CoGroup.id', 'CoGroup.name');
- $args['contain'] = false;
-
- $this->set('vv_groups',
$this->CoEnrollmentAttribute->CoEnrollmentFlow->Co->CoGroup->find('list',
$args));
-
- if($this->CmpEnrollmentConfiguration->orgIdentitiesFromCOEF()
- &&
$this->CmpEnrollmentConfiguration->enrollmentAttributesFromEnv()) {
- $this->set('vv_attributes_from_env', true);
+ if(!empty($coid)) {
+ $this->set('vv_coid', $coid);
+
+ // Assemble the set of available attributes for the view to render
+
+ $this->set('vv_available_attributes',
$this->CoEnrollmentAttribute->availableAttributes($coid));
+
+ // And pull details of extended attributes so views can determine
types
+
+ $args = array();
+ $args['conditions']['co_id'] = $coid;
+ $args['fields'] = array('CoExtendedAttribute.name',
'CoExtendedAttribute.type');
+ $args['contain'] = false;
+
+ $this->set('vv_ext_attr_types',
+
$this->CoEnrollmentAttribute->CoEnrollmentFlow->Co->CoExtendedAttribute->find('list',
$args));
+
+ // Assemble the list of available COUs
+
+ $this->set('vv_cous',
$this->CoEnrollmentAttribute->CoEnrollmentFlow->Co->Cou->allCous($coid));
+
+ // Assemble the list of available affiliations
+
+ $this->set('vv_affiliations', $cm_texts[ $cm_lang ]['en.affil']);
+
+ // Assemble the list of available Sponsors
+
+ $this->set('vv_sponsors',
$this->CoEnrollmentAttribute->CoEnrollmentFlow->Co->CoPerson->sponsorList($coid));
+
+ // Assemble the list of available groups. Note we currently allow
any group to be
+ // specified (ie: whether or not it's open). The idea is that an
Enrollment Flow
+ // is defined by an admin, who can correctly select a group.
However, it's plausible
+ // that we should offer options to filter to open groups, or to a
subset of groups
+ // as selected by the administrator (especially for scenarios where
the value is
+ // modifiable).
+
+ $args = array();
+ $args['conditions']['co_id'] = $coid;
+ $args['fields'] = array('CoGroup.id', 'CoGroup.name');
+ $args['contain'] = false;
+
+ $this->set('vv_groups',
$this->CoEnrollmentAttribute->CoEnrollmentFlow->Co->CoGroup->find('list',
$args));
+
+ if($this->CmpEnrollmentConfiguration->orgIdentitiesFromCOEF()
+ &&
$this->CmpEnrollmentConfiguration->enrollmentAttributesFromEnv()) {
+ $this->set('vv_attributes_from_env', true);
+ }
}
}
}
-
+
/**
* Perform any followups following a write operation. Note that if this
* method fails, it must return a warning or REST response, but that the
Modified: registry/trunk/app/Controller/CoInvitesController.php
===================================================================
--- registry/trunk/app/Controller/CoInvitesController.php 2014-02-01
20:20:14 UTC (rev 663)
+++ registry/trunk/app/Controller/CoInvitesController.php 2014-02-02
15:06:46 UTC (rev 664)
@@ -132,9 +132,9 @@
if(!empty($coPerson['CoPerson']['co_id'])) {
return $coPerson['CoPerson']['co_id'];
} else {
- throw InvalidArgumentException(_txt('er.notfound',
- array(_txt('ct.co_invites.1'),
-
Sanitize::html($this->request->params['pass'][0]))));
+ throw new InvalidArgumentException(_txt('er.notfound',
+
array(_txt('ct.co_invites.1'),
+
Sanitize::html($this->request->params['pass'][0]))));
}
}
Modified: registry/trunk/app/Controller/CoNotificationsController.php
===================================================================
--- registry/trunk/app/Controller/CoNotificationsController.php 2014-02-01
20:20:14 UTC (rev 663)
+++ registry/trunk/app/Controller/CoNotificationsController.php 2014-02-02
15:06:46 UTC (rev 664)
@@ -98,9 +98,9 @@
if(!empty($coPerson['SubjectCoPerson']['co_id'])) {
return $coPerson['SubjectCoPerson']['co_id'];
} else {
- throw InvalidArgumentException(_txt('er.notfound',
-
array(_txt('ct.co_notifications.1'),
-
Sanitize::html($this->request->params['pass'][0]))));
+ throw new InvalidArgumentException(_txt('er.notfound',
+
array(_txt('ct.co_notifications.1'),
+
Sanitize::html($this->request->params['pass'][0]))));
}
}
Modified: registry/trunk/app/Controller/EmailAddressesController.php
===================================================================
--- registry/trunk/app/Controller/EmailAddressesController.php 2014-02-01
20:20:14 UTC (rev 663)
+++ registry/trunk/app/Controller/EmailAddressesController.php 2014-02-02
15:06:46 UTC (rev 664)
@@ -136,8 +136,9 @@
// Generate an email verification request?
// This needs to correlate with CoInvitesController.
- $p['verifyEmailAddress'] =
$this->Role->canRequestVerificationOfEmailAddress($roles['copersonid'],
-
$this->request->params['pass'][0]);
+ $p['verifyEmailAddress'] = (!empty($this->request->params['pass'][0])
+ &&
$this->Role->canRequestVerificationOfEmailAddress($roles['copersonid'],
+
$this->request->params['pass'][0]));
// View an existing Email Address?
$p['view'] = ($roles['cmadmin']
Modified: registry/trunk/app/Model/CoEnrollmentAttribute.php
===================================================================
--- registry/trunk/app/Model/CoEnrollmentAttribute.php 2014-02-01 20:20:14
UTC (rev 663)
+++ registry/trunk/app/Model/CoEnrollmentAttribute.php 2014-02-02 15:06:46
UTC (rev 664)
@@ -45,7 +45,7 @@
public $displayField = "label";
// Default ordering for find operations
- public $order = array("label");
+// public $order = array("label");
// Validation rules for table elements
public $validate = array(
Modified: registry/trunk/app/Model/CoPetition.php
===================================================================
--- registry/trunk/app/Model/CoPetition.php 2014-02-01 20:20:14 UTC (rev
663)
+++ registry/trunk/app/Model/CoPetition.php 2014-02-02 15:06:46 UTC (rev
664)
@@ -243,8 +243,6 @@
}
}
- debug("true");
-
return true;
}
Modified: registry/trunk/app/View/CoGroups/index.ctp
===================================================================
--- registry/trunk/app/View/CoGroups/index.ctp 2014-02-01 20:20:14 UTC (rev
663)
+++ registry/trunk/app/View/CoGroups/index.ctp 2014-02-02 15:06:46 UTC (rev
664)
@@ -104,7 +104,7 @@
{
echo $this->Html->link($c['CoGroup']['name'],
array('controller' => 'co_groups',
- 'action' => ($e ? 'edit' : ($v ?
'view' : '')), $c['CoGroup']['id'], 'co' =>
$this->request->params['named']['co']));
+ 'action' => ($e ? 'edit' : ($v ?
'view' : '')), $c['CoGroup']['id'], 'co' => $cur_co['Co']['id']));
}
else
echo Sanitize::html($c['CoGroup']['name']);
Modified: registry/trunk/app/View/EmailAddresses/fields.inc
===================================================================
--- registry/trunk/app/View/EmailAddresses/fields.inc 2014-02-01 20:20:14
UTC (rev 663)
+++ registry/trunk/app/View/EmailAddresses/fields.inc 2014-02-02 15:06:46
UTC (rev 664)
@@ -100,14 +100,16 @@
// For an add, verified is by definition no and can't (currently,
anyway) be set manually.
// This will be caught by $email_addresses being null.
- $url = array(
- 'controller' => 'co_invites',
- 'action' => 'verifyEmailAddress',
- 'email_address_id' => $email_addresses[0]['EmailAddress']['id']
- );
-
- if(!empty($cur_co['Co']['id'])) {
- $url['co'] = $cur_co['Co']['id'];
+ if($this->action != 'add') {
+ $url = array(
+ 'controller' => 'co_invites',
+ 'action' => 'verifyEmailAddress',
+ 'email_address_id' => $email_addresses[0]['EmailAddress']['id']
+ );
+
+ if(!empty($cur_co['Co']['id'])) {
+ $url['co'] = $cur_co['Co']['id'];
+ }
}
print ($isVerified ? _txt('fd.yes') : _txt('fd.no')) . "\n";
- [comanage-dev] r664 - in registry/trunk/app: Controller Model View/CoGroups View/EmailAddresses, svnlog, 02/02/2014
Archive powered by MHonArc 2.6.16.