Skip to Content.
Sympa Menu

comanage-dev - [comanage-dev] r274 - in registry/trunk/app: Config/Schema Controller Lib Model View/CoPeople View/CoPetitions View/Layouts View/Pages View/Standard

Subject: COmanage Developers List

List archive

[comanage-dev] r274 - in registry/trunk/app: Config/Schema Controller Lib Model View/CoPeople View/CoPetitions View/Layouts View/Pages View/Standard


Chronological Thread 
  • From:
  • To:
  • Subject: [comanage-dev] r274 - in registry/trunk/app: Config/Schema Controller Lib Model View/CoPeople View/CoPetitions View/Layouts View/Pages View/Standard
  • Date: Mon, 2 Apr 2012 10:48:17 -0400

Author: benno
Date: 2012-04-02 10:48:17 -0400 (Mon, 02 Apr 2012)
New Revision: 274

Added:
registry/trunk/app/View/CoPetitions/index.ctp
registry/trunk/app/View/CoPetitions/view.ctp
Modified:
registry/trunk/app/Config/Schema/schema.xml
registry/trunk/app/Controller/CoPetitionsController.php
registry/trunk/app/Lib/enum.php
registry/trunk/app/Lib/lang.php
registry/trunk/app/Model/CoEnrollmentAttribute.php
registry/trunk/app/Model/CoExtendedAttribute.php
registry/trunk/app/Model/CoPetition.php
registry/trunk/app/View/CoPeople/fields.inc
registry/trunk/app/View/CoPeople/index.ctp
registry/trunk/app/View/CoPetitions/fields.inc
registry/trunk/app/View/Layouts/default.ctp
registry/trunk/app/View/Pages/home.ctp
registry/trunk/app/View/Standard/view.ctp
Log:
Partial commit to view petitions (CO-208)

Modified: registry/trunk/app/Config/Schema/schema.xml
===================================================================
--- registry/trunk/app/Config/Schema/schema.xml 2012-04-02 14:45:46 UTC (rev
273)
+++ registry/trunk/app/Config/Schema/schema.xml 2012-04-02 14:48:17 UTC (rev
274)
@@ -590,7 +590,9 @@
<notnull />
<constraint>REFERENCES cm_co_enrollment_attributes(id)</constraint>
</field>
+ <field name="attribute" type="C" size="80" />
<field name="value" type="C" size="160" />
+ <field name="attribute_foreign_key" type="I" />
<field name="created" type="T" />
<field name="modified" type="T" />


Modified: registry/trunk/app/Controller/CoPetitionsController.php
===================================================================
--- registry/trunk/app/Controller/CoPetitionsController.php 2012-04-02
14:45:46 UTC (rev 273)
+++ registry/trunk/app/Controller/CoPetitionsController.php 2012-04-02
14:48:17 UTC (rev 274)
@@ -25,9 +25,11 @@
App::uses("StandardController", "Controller");

class CoPetitionsController extends StandardController {
- var $name = "CoPetitions";
+ public $name = "CoPetitions";

- var $paginate = array(
+ public $helpers = array('Time');
+
+ public $paginate = array(
'limit' => 25,
'order' => array(
'modified' => 'asc'
@@ -37,6 +39,20 @@
// This controller needs a CO to be set
public $requires_co = true;

+ // For rendering views, we need more information than just the various ID
numbers
+ // stored in a petition.
+ public $view_contains = array(
+ 'ApproverCoPerson' => 'Name',
+ 'EnrolleeCoPerson' => 'Name',
+ 'PetitionerCoPerson' => 'Name',
+ 'SponsorCoPerson' => 'Name',
+ 'CoPetitionHistoryRecord' => array(
+ 'ActorCoPerson' => array(
+ 'Name'
+ )
+ )
+ );
+
/**
* Add a CO Petition.
* - precondition: Model specific attributes in $this->request->data
(optional)
@@ -139,6 +155,8 @@
// so Cake doesn't get confused with attaching Names (to the Org
Identity
// vs the CO Person).

+ $orgData = array();
+
$this->loadModel('CmpEnrollmentConfiguration');

if($this->CmpEnrollmentConfiguration->orgIdentitiesFromCOEF()) {
@@ -176,6 +194,7 @@

// Next, populate a CO Person and CO Person Role, statuses = pending.

+ $coData = array();
$coData['EnrolleeCoPerson'] = $this->request->data['EnrolleeCoPerson'];
$coData['EnrolleeCoPerson']['co_id'] = $this->cur_co['Co']['id'];
$coData['EnrolleeCoPerson']['status'] = StatusEnum::Pending;
@@ -196,6 +215,7 @@
$fail = true;
}

+ $coRoleData = array();
$coRoleData['EnrolleeCoPersonRole'] =
$this->request->data['EnrolleeCoPersonRole'];
$coRoleData['EnrolleeCoPersonRole']['status'] = StatusEnum::Pending;
$coRoleData['EnrolleeCoPersonRole']['co_person_id'] = $coPersonID;
@@ -220,7 +240,9 @@
// the data we save in the various saveAll() calls so the appropriate
fields
// are highlighted at once.

- if(!$this->CoPetition->EnrolleeCoPersonRole->saveAll($coRoleData)) {
+ if($this->CoPetition->EnrolleeCoPersonRole->saveAll($coRoleData)) {
+ $coPersonRoleID = $this->CoPetition->EnrolleeCoPersonRole->id;
+ } else {
// We need to fold any extended attribute validation errors into the
CO Person Role
// validation errors in order for FormHandler to be able to see them.

@@ -237,29 +259,276 @@
$fail = true;
}

+ // From here, if any save fails it's probably a coding error since
there are no
+ // form fields that need validation. (We're using data from above, for
the most
+ // part). As such, if $fail gets set to true at any point, we don't
need to
+ // continue save()ing data.
+
// Create a CO Org Identity Link

+ $coOrgLink = array();
$coOrgLink['CoOrgIdentityLink']['org_identity_id'] = $orgIdentityID;
$coOrgLink['CoOrgIdentityLink']['co_person_id'] = $coPersonID;

-
if($this->CoPetition->EnrolleeCoPerson->CoOrgIdentityLink->save($coOrgLink)) {
- // XXX Assemble the Petition, status = pending. We have most of the
identifiers
+
if(!$this->CoPetition->EnrolleeCoPerson->CoOrgIdentityLink->save($coOrgLink))
{
+ $fail = true;
+ }
+
+ $coPetitionID = null;
+
+ if(!$fail) {
+ // Assemble the Petition, status = pending. We have most of the
identifiers
// we need from the above saves.

- // Figure out the petitioner person ID. As of now, it as the
authenticated
+ $coPetitionData = array();
+ $coPetitionData['CoPetition']['co_enrollment_flow_id'] =
$this->enrollmentFlowID();
+ $coPetitionData['CoPetition']['co_id'] = $this->cur_co['Co']['id'];
+
+ if(isset($coRoleData['EnrolleeCoPersonRole']['cou_id'])) {
+ $coPetitionData['CoPetition']['cou_id'] =
$coRoleData['EnrolleeCoPersonRole']['cou_id'];
+ }
+
+ $coPetitionData['CoPetition']['enrollee_org_identity_id'] =
$orgIdentityID;
+ $coPetitionData['CoPetition']['enrollee_co_person_id'] = $coPersonID;
+ $coPetitionData['CoPetition']['enrollee_co_person_role_id'] =
$coPersonRoleID;
+
+ // Figure out the petitioner person ID. As of now, it is the
authenticated
// person completing the form. This could be NULL if a CMP admin who
is not
// a member of the CO initiates the petition.

$petitioner = $this->Session->read('Auth.User.co_person_id');

- // XXX Store a copy of the attributes in co_petition_attributes.
+ $coPetitionData['CoPetition']['petitioner_co_person_id'] =
$petitioner;
+ $coPetitionData['CoPetition']['status'] = StatusEnum::Pending;

- // XXX Add a co_petition_history_record.
- } else {
- $fail = true;
+ if($this->CoPetition->save($coPetitionData)) {
+ $coPetitionID = $this->CoPetition->id;
+ } else {
+ $fail = true;
+ }
}

+ // Store a copy of the attributes in co_petition_attributes.
+
if(!$fail) {
+ // In order to do this, we need to walk through the various
submitted attributes
+ // and "flatten" them into a format suitable for this table. Start
with org data.
+
+ $petitionAttrs = array();
+
+ // Pull a mapping of attributes to attribute IDs
+
+ $mArgs = array();
+ $mArgs['conditions']['CoEnrollmentAttribute.co_enrollment_flow_id']
= $this->enrollmentFlowID();
+ $mArgs['fields'] = array('CoEnrollmentAttribute.attribute',
'CoEnrollmentAttribute.id');
+ $attrIDs =
$this->CoPetition->CoEnrollmentFlow->CoEnrollmentAttribute->find("list",
$mArgs);
+
+ if(isset($orgData['EnrolleeOrgIdentity'])) {
+ foreach(array_keys($orgData['EnrolleeOrgIdentity']) as $a) {
+ // We need to find the attribute ID for this attribute. If not
found, we'll
+ // skip it (since it's probably something like co_id that we
don't need to
+ // store here).
+
+ if(isset($attrIDs['o:'.$a])
+ && isset($orgData['EnrolleeOrgIdentity'][$a])
+ && $orgData['EnrolleeOrgIdentity'][$a] != '') {
+ $petitionAttrs['CoPetitionAttribute'][] = array(
+ 'co_petition_id' => $coPetitionID,
+ 'co_enrollment_attribute_id' => $attrIDs['o:'.$a],
+ 'attribute' => $a,
+ 'value' => $orgData['EnrolleeOrgIdentity'][$a]
+ );
+ }
+ }
+
+ foreach(array_keys($orgData) as $m) {
+ // Loop through the related models, which may or may not be
hasMany.
+
+ if($m == 'EnrolleeOrgIdentity')
+ continue;
+
+ if(isset($orgData[$m]['co_enrollment_attribute_id'])) {
+ // hasOne
+
+ foreach(array_keys($orgData[$m]) as $a) {
+ if($a != 'co_enrollment_attribute_id'
+ && isset($orgData[$m][$a])
+ && $orgData[$m][$a] != '') {
+ $petitionAttrs['CoPetitionAttribute'][] = array(
+ 'co_petition_id' => $coPetitionID,
+ 'co_enrollment_attribute_id' =>
$orgData[$m]['co_enrollment_attribute_id'],
+ 'attribute' => $a,
+ 'value' => $orgData[$m][$a]
+ );
+ }
+ }
+ } else {
+ // hasMany
+
+ foreach(array_keys($orgData[$m]) as $i) {
+ foreach(array_keys($orgData[$m][$i]) as $a) {
+ if($a != 'co_enrollment_attribute_id'
+ && isset($orgData[$m][$i][$a])
+ && $orgData[$m][$i][$a] != '') {
+ $petitionAttrs['CoPetitionAttribute'][] = array(
+ 'co_petition_id' => $coPetitionID,
+ 'co_enrollment_attribute_id' =>
$orgData[$m][$i]['co_enrollment_attribute_id'],
+ 'attribute' => $a,
+ 'value' => $orgData[$m][$i][$a]
+ );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // CO Person doesn't currently have any direct attributes that we
track.
+ // Move on to related model attributes.
+
+ foreach(array_keys($coData) as $m) {
+ // Loop through the related models, which may or may not be
hasMany.
+
+ if($m == 'EnrolleeCoPerson')
+ continue;
+
+ if(isset($coData[$m]['co_enrollment_attribute_id'])) {
+ // hasOne
+
+ foreach(array_keys($coData[$m]) as $a) {
+ if($a != 'co_enrollment_attribute_id'
+ && isset($coData[$m][$a])
+ && $coData[$m][$a] != '') {
+ $petitionAttrs['CoPetitionAttribute'][] = array(
+ 'co_petition_id' => $coPetitionID,
+ 'co_enrollment_attribute_id' =>
$coData[$m]['co_enrollment_attribute_id'],
+ 'attribute' => $a,
+ 'value' => $coData[$m][$a]
+ );
+ }
+ }
+ } else {
+ // hasMany
+
+ foreach(array_keys($coData[$m]) as $i) {
+ foreach(array_keys($coData[$m][$i]) as $a) {
+ if($a != 'co_enrollment_attribute_id'
+ && isset($coData[$m][$i][$a])
+ && $coData[$m][$i][$a] != '') {
+ $petitionAttrs['CoPetitionAttribute'][] = array(
+ 'co_petition_id' => $coPetitionID,
+ 'co_enrollment_attribute_id' =>
$coData[$m][$i]['co_enrollment_attribute_id'],
+ 'attribute' => $a,
+ 'value' => $coData[$m][$i][$a]
+ );
+ }
+ }
+ }
+ }
+ }
+
+ // Finally, CO Person Role data
+
+ if(isset($coRoleData['EnrolleeCoPersonRole'])) {
+ foreach(array_keys($coRoleData['EnrolleeCoPersonRole']) as $a) {
+ // We need to find the attribute ID for this attribute. If not
found, we'll
+ // skip it (since it's probably something like co_id that we
don't need to
+ // store here).
+
+ if(isset($attrIDs['r:'.$a])
+ && isset($coRoleData['EnrolleeCoPersonRole'][$a])
+ && $coRoleData['EnrolleeCoPersonRole'][$a] != '') {
+ $petitionAttrs['CoPetitionAttribute'][] = array(
+ 'co_petition_id' => $coPetitionID,
+ 'co_enrollment_attribute_id' => $attrIDs['r:'.$a],
+ 'attribute' => $a,
+ 'value' => $coRoleData['EnrolleeCoPersonRole'][$a]
+ );
+ }
+ }
+
+ foreach(array_keys($coRoleData) as $m) {
+ // Loop through the related models, which may or may not be
hasMany.
+
+ if($m == 'EnrolleeCoPersonRole')
+ continue;
+
+ if(isset($coRoleData[$m]['co_enrollment_attribute_id'])) {
+ // hasOne
+
+ foreach(array_keys($coRoleData[$m]) as $a) {
+ if($a != 'co_enrollment_attribute_id'
+ && isset($coRoleData[$m][$a])
+ && $coRoleData[$m][$a] != '') {
+ $petitionAttrs['CoPetitionAttribute'][] = array(
+ 'co_petition_id' => $coPetitionID,
+ 'co_enrollment_attribute_id' =>
$coRoleData[$m]['co_enrollment_attribute_id'],
+ 'attribute' => $a,
+ 'value' => $coRoleData[$m][$a]
+ );
+ }
+ }
+ } elseif(preg_match('/Co[0-9]+PersonExtendedAttribute/', $m)) {
+ // Extended Attribute
+
+ foreach(array_keys($coRoleData[$m]) as $a) {
+ // We need to find the attribute ID for this attribute.
+
+ if(isset($attrIDs['x:'.$a])
+ && isset($coRoleData[$m][$a])
+ && $coRoleData[$m][$a] != '') {
+ $petitionAttrs['CoPetitionAttribute'][] = array(
+ 'co_petition_id' => $coPetitionID,
+ 'co_enrollment_attribute_id' => $attrIDs['x:'.$a],
+ 'attribute' => $a,
+ 'value' => $coRoleData[$m][$a]
+ );
+ }
+ }
+ } else {
+ // hasMany
+
+ foreach(array_keys($coRoleData[$m]) as $i) {
+ foreach(array_keys($coRoleData[$m][$i]) as $a) {
+ if($a != 'co_enrollment_attribute_id'
+ && isset($coRoleData[$m][$i][$a])
+ && $coRoleData[$m][$i][$a] != '') {
+ $petitionAttrs['CoPetitionAttribute'][] = array(
+ 'co_petition_id' => $coPetitionID,
+ 'co_enrollment_attribute_id' =>
$coRoleData[$m][$i]['co_enrollment_attribute_id'],
+ 'attribute' => $a,
+ 'value' => $coRoleData[$m][$i][$a]
+ );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Finally, try to save. Note that saveMany doesn't expect the Model
name as an array
+ // component, unlike all the other saves.
+
+
if(!$this->CoPetition->CoPetitionAttribute->saveMany($petitionAttrs['CoPetitionAttribute']))
{
+ $fail = true;
+ }
+ }
+
+ // Add a co_petition_history_record.
+
+ if(!$fail) {
+ $coPetitionHistoryData = array();
+ $coPetitionHistoryData['CoPetitionHistoryRecord']['co_petition_id']
= $coPetitionID;
+
$coPetitionHistoryData['CoPetitionHistoryRecord']['actor_co_person_id'] =
$petitioner;
+ $coPetitionHistoryData['CoPetitionHistoryRecord']['action'] =
PetitionActionEnum::Created;
+ $coPetitionHistoryData['CoPetitionHistoryRecord']['comment'] =
_txt('rs.pt.create');
+
+
if(!$this->CoPetition->CoPetitionHistoryRecord->save($coPetitionHistoryData))
{
+ $fail = true;
+ }
+ }
+
+ if(!$fail) {
$dbc->commit($this);

$this->Session->setFlash(_txt('rs.pt.create'), '', array(),
'success');
@@ -313,12 +582,30 @@
// Set the enrollment flow ID to make it easier to carry forward
through failed submissions
$this->set('co_enrollment_flow_id', $this->enrollmentFlowID());

- if(($this->action == 'add' || $this->action == 'edit')
- && $this->request->is('get')) {
+ if(($this->action == 'add' || $this->action == 'edit' || $this->action
== 'view')
+ && $this->request->is('get')) {
// If we processed a post, this will have already been set.
$this->set('co_enrollment_attributes',

$this->CoPetition->CoEnrollmentFlow->CoEnrollmentAttribute->enrollmentFlowAttributes($this->enrollmentFlowID()));
}
+
+ if(($this->action == 'edit' || $this->action == 'view')
+ && $this->request->is('get')) {
+ // This information is already embedded in $co_petitions, but it's
easier for the
+ // views to access it this way. Also, arguably $co_petitions needs
some trimming
+ // via containable.
+
+ $vArgs = array();
+ $vArgs['conditions']['CoPetitionAttribute.co_petition_id'] =
$this->CoPetition->id;
+ $vArgs['fields'] = array(
+ 'CoPetitionAttribute.attribute',
+ 'CoPetitionAttribute.value',
+ 'CoPetitionAttribute.co_enrollment_attribute_id'
+ );
+ $vAttrs = $this->CoPetition->CoPetitionAttribute->find("list",
$vArgs);
+
+ $this->set('co_petition_attribute_values', $vAttrs);
+ }
}

parent::beforeRender();

Modified: registry/trunk/app/Lib/enum.php
===================================================================
--- registry/trunk/app/Lib/enum.php 2012-04-02 14:45:46 UTC (rev 273)
+++ registry/trunk/app/Lib/enum.php 2012-04-02 14:48:17 UTC (rev 274)
@@ -171,6 +171,14 @@
const White = 'W';
}

+class PetitionActionEnum
+{
+ const Approved = 'PY';
+ const Created = 'PC';
+ const Declined = 'PX';
+ const Denied = 'PN';
+}
+
class RequiredEnum
{
const Required = 1;

Modified: registry/trunk/app/Lib/lang.php
===================================================================
--- registry/trunk/app/Lib/lang.php 2012-04-02 14:45:46 UTC (rev 273)
+++ registry/trunk/app/Lib/lang.php 2012-04-02 14:48:17 UTC (rev 274)
@@ -244,7 +244,9 @@
'er.orgp.unpool' => 'Failed to unpool organizational identities',

// Fields
+ 'fd.action' => 'Action',
'fd.actions' => 'Actions',
+ 'fd.actor' => 'Actor',
'fd.address' => 'Address',
// The next set must be named fd.model.validation-field
'fd.address.country' => 'Country',
@@ -256,14 +258,18 @@
'fd.admin' => 'Administrator',
'fd.affiliation' => 'Affiliation',
'fd.an.desc' => 'Alphanumeric characters only',
+ 'fd.approver' => 'Approver',
'fd.attribute' => 'Attribute',
'fd.attr.ldap' => 'LDAP Name',
'fd.attr.saml' => 'SAML Name',
'fd.attrs.cop' => 'Person Attributes',
'fd.attrs.copr' => 'Role Attributes',
'fd.attrs.org' => 'Organizational Attributes',
+ 'fd.attrs.pet' => 'Petition Attributes',
'fd.closed' => 'Closed',
+ 'fd.comment' => 'Comment',
'fd.cou' => 'COU',
+ 'fd.created' => 'Created',
// Demographics fields
'fd.de.persid' => 'Person ID',
'fd.de.gender' => 'Gender',
@@ -317,12 +323,14 @@
// (End enrollment configuration fields)
// This must be named fd.model.validation-field
'fd.email_address.mail' => 'Email',
+ 'fd.enrollee' => 'Enrollee',
'fd.false' => 'False',
'fd.group.desc.adm' => '%1$s Administrators',
'fd.group.mem' => 'Member',
'fd.group.memin' => 'membership in "%1$s"',
'fd.group.own' => 'Owner',
'fd.groups' => 'Groups',
+ 'fd.history.pt' => 'Petition History',
// The next set must be named fd.model.validation-field
'fd.identifier.identifier' => 'Identifier',
'fd.identifier.login' => 'Login',
@@ -330,6 +338,7 @@
'fd.ids' => 'Identifiers',
'fd.index' => 'Index',
'fd.members' => 'Members',
+ 'fd.modified' => 'Modified',
'fd.name' => 'Name',
'fd.name.d' => 'Display Name',
'fd.name.h.desc' => '(Dr, Hon, etc)',
@@ -347,6 +356,7 @@
'fd.ou' => 'Department',
'fd.parent' => 'Parent COU',
'fd.perms' => 'Permissions',
+ 'fd.petitioner' => 'Petitioner',
'fd.req' => '* denotes required field',
'fd.required' => 'Required',
'fd.roles' => 'Roles',
@@ -356,6 +366,7 @@
'fd.status' => 'Status',
// This must be named fd.model.validation-field
'fd.telephone_number.number' => 'Phone',
+ 'fd.timestamp' => 'Timestamp',
'fd.title' => 'Title',
'fd.true' => 'True',
'fd.type' => 'Type',
@@ -397,6 +408,7 @@
'op.login' => 'Login',
'op.logout' => 'Logout',
'op.ok' => 'OK',
+ 'op.petition' => 'Petition',
'op.proceed.ok' => 'Are you sure you wish to proceed?',
'op.remove' => 'Remove',
'op.save' => 'Save',

Modified: registry/trunk/app/Model/CoEnrollmentAttribute.php
===================================================================
--- registry/trunk/app/Model/CoEnrollmentAttribute.php 2012-04-02 14:45:46
UTC (rev 273)
+++ registry/trunk/app/Model/CoEnrollmentAttribute.php 2012-04-02 14:48:17
UTC (rev 274)
@@ -123,7 +123,7 @@
$extAttrs =
$this->CoEnrollmentFlow->Co->CoExtendedAttribute->findAllByCoId($coid);

foreach($extAttrs as $e)
- $ret['x:' . $e['CoExtendedAttribute']['id'] . ':' .
$e['CoExtendedAttribute']['name']] =
$e['CoExtendedAttribute']['display_name'];
+ $ret['x:' . $e['CoExtendedAttribute']['name']] =
$e['CoExtendedAttribute']['display_name'];

$cmpEnrollmentConfiguration =
ClassRegistry::init('CmpEnrollmentConfiguration');

@@ -182,11 +182,6 @@
// See availableAttributes() for the various codes
$attrCode = array_shift($a);

- if($attrCode == 'x') {
- // Extended Attribute ID, needed to pull metadata about the extended
attribute
- $attrId = array_shift($a);
- }
-
// attribute name (as per availableAttributes)
$attrName = array_shift($a);

@@ -283,7 +278,7 @@
} else {
// Extended attributes

- $attr['validate'] = $attrModel->validationRules($attrId);
+ $attr['validate'] =
$attrModel->validationRules($efAttr['CoEnrollmentFlow']['co_id'], $attrName);
}

// Single valued attributes don't have types, so we can ignore
$attrType

Modified: registry/trunk/app/Model/CoExtendedAttribute.php
===================================================================
--- registry/trunk/app/Model/CoExtendedAttribute.php 2012-04-02 14:45:46
UTC (rev 273)
+++ registry/trunk/app/Model/CoExtendedAttribute.php 2012-04-02 14:48:17
UTC (rev 274)
@@ -69,16 +69,17 @@
* Dynamically assemble validation rules for an extended attribute.
*
* @since COmanage Registry v0.5
- * @param integer ID of Extended Attribute
+ * @param integer CO ID of attribute
+ * @param integer Name of Extended Attribute
* @return Array Validation rules, in the standard Cake format
*/

- public function validationRules($id) {
+ public function validationRules($coId, $name) {
$ret = array();

// Pull the type of the attribute and put together a suitable array

- $extAttr = $this->findById($id);
+ $extAttr = $this->findByCoIdAndName($coId, $name);

if($extAttr) {
switch($extAttr['CoExtendedAttribute']['type']) {

Modified: registry/trunk/app/Model/CoPetition.php
===================================================================
--- registry/trunk/app/Model/CoPetition.php 2012-04-02 14:45:46 UTC (rev
273)
+++ registry/trunk/app/Model/CoPetition.php 2012-04-02 14:48:17 UTC (rev
274)
@@ -29,6 +29,9 @@
// Current schema version for API
public $version = "1.0";

+ // Add behaviors
+ public $actsAs = array('Containable');
+
// Association rules from this model to other models
public $belongsTo = array(
"ApproverCoPerson" => array(
@@ -60,16 +63,18 @@

public $hasMany = array(
// A CO Petition has zero or more CO Petition Attributes
- "CoPetitionAttribute",
+ "CoPetitionAttribute" => array('dependent' => true),
// A CO Petition has zero or more CO Petition History Records
- "CoPetitionHistoryRecords"
+ "CoPetitionHistoryRecord" => array('dependent' => true)
);

// Default display field for cake generated views
- public $displayField = "id";
+ public $displayField = "CoPetition.id";

// Default ordering for find operations
- public $order = array("id");
+// XXX CO-296 Toss default order? id will be ambiguous in some queries, but
CoPetition.id
+// breaks delete cascading since the model may be aliased to (eg)
CoPetitionApprover.
+// public $order = array("id");

// Validation rules for table elements
public $validate = array(

Modified: registry/trunk/app/View/CoPeople/fields.inc
===================================================================
--- registry/trunk/app/View/CoPeople/fields.inc 2012-04-02 14:45:46 UTC (rev
273)
+++ registry/trunk/app/View/CoPeople/fields.inc 2012-04-02 14:48:17 UTC (rev
274)
@@ -422,6 +422,17 @@
// Currently, users can self-edit some role level
attributes,
// so give them an edit button, too.

+ if($permissions['enroll']
+ && $r['status'] == StatusEnum::Pending) {
+ print $this->Html->link(_txt('op.petition'),
+ array('controller' =>
'co_petitions',
+ 'action' => 'view',
+
$r['CoPetition'][0]['id'],
+ 'co' =>
$r['CoPetition'][0]['co_id'],
+ 'coef' =>
$r['CoPetition'][0]['co_enrollment_flow_id']),
+ array('class' =>
'petitionbutton'));
+ }
+
if($permissions['edit'])
echo $this->Html->link(_txt('op.edit'),
array('controller' =>
'co_person_roles', 'action' => 'edit', $r['id'], 'co' => $cur_co['Co']['id']),

Modified: registry/trunk/app/View/CoPeople/index.ctp
===================================================================
--- registry/trunk/app/View/CoPeople/index.ctp 2012-04-02 14:45:46 UTC (rev
273)
+++ registry/trunk/app/View/CoPeople/index.ctp 2012-04-02 14:48:17 UTC (rev
274)
@@ -89,18 +89,37 @@
<?php
foreach ($p['CoPersonRole'] as $pr) {
if($myPerson) {
- echo $this->Html->link(_txt('op.edit'),
- array('controller' =>
'co_person_roles',
- 'action' =>
($permissions['edit'] ? "edit" : "view"),
- $pr['id'],
- 'co' => $cur_co['Co']['id']),
- array('class' => 'editbutton'));
-
- echo $this->Html->link($pr['title'],
- array('controller' =>
'co_person_roles',
- 'action' =>
($permissions['edit'] ? "edit" : "view"),
- $pr['id'],
- 'co' => $cur_co['Co']['id']));
+ if($permissions['enroll']
+ && $pr['status'] == StatusEnum::Pending
+ && !empty($pr['CoPetition'])) {
+ print $this->Html->link(_txt('op.petition'),
+ array('controller' => 'co_petitions',
+ 'action' => 'view',
+ $pr['CoPetition'][0]['id'],
+ 'co' =>
$pr['CoPetition'][0]['co_id'],
+ 'coef' =>
$pr['CoPetition'][0]['co_enrollment_flow_id']),
+ array('class' => 'petitionbutton'));
+
+ print $this->Html->link($pr['title'],
+ array('controller' => 'co_petitions',
+ 'action' => 'view',
+ $pr['CoPetition'][0]['id'],
+ 'co' =>
$pr['CoPetition'][0]['co_id'],
+ 'coef' =>
$pr['CoPetition'][0]['co_enrollment_flow_id']));
+ } else {
+ print $this->Html->link(_txt('op.edit'),
+ array('controller' =>
'co_person_roles',
+ 'action' =>
($permissions['edit'] ? "edit" : "view"),
+ $pr['id'],
+ 'co' => $cur_co['Co']['id']),
+ array('class' => 'editbutton'));
+
+ print $this->Html->link($pr['title'],
+ array('controller' =>
'co_person_roles',
+ 'action' =>
($permissions['edit'] ? "edit" : "view"),
+ $pr['id'],
+ 'co' => $cur_co['Co']['id']));
+ }
}
else
print $pr['title'];
@@ -130,9 +149,12 @@
// Can't delete a CO Person if they have any roles
if(empty($p['CoPersonRole']) && $permissions['delete'])
echo '<button class="deletebutton" title="' .
_txt('op.delete') . '" onclick="javascript:js_confirm_delete(\'' .
_jtxt(Sanitize::html(generateCn($p['Name']))) . '\', \'' .
$this->Html->url(array('controller' => 'co_people', 'action' => 'delete',
$p['CoPerson']['id'], 'co' => $cur_co['Co']['id'])) . '\')";>' .
_txt('op.delete') . '</button>' . "\n";
-
- if($permissions['invite'] && ($p['CoPerson']['status'] != 'A' &&
$p['CoPerson']['status'] != 'D'))
- echo '<button class="invitebutton" title="' .
_txt('op.inv.resend') . '" onclick="javascript:js_confirm_reinvite(\'' .
_jtxt(Sanitize::html(generateCn($p['Name']))) . '\', \'' .
$this->Html->url(array('controller' => 'co_invites', 'action' => 'send',
'copersonid' => $p['CoPerson']['id'], 'co' => $cur_co['Co']['id'])) .
'\')";>' . _txt('op.inv.resend') . '</button>' . "\n";
+
+ if($permissions['invite']
+ && ($p['CoPerson']['status'] != StatusEnum::Active
+ && $p['CoPerson']['status'] != StatusEnum::Deleted)) {
+ print '<button class="invitebutton" title="' .
_txt('op.inv.resend') . '" onclick="javascript:js_confirm_reinvite(\'' .
_jtxt(Sanitize::html(generateCn($p['Name']))) . '\', \'' .
$this->Html->url(array('controller' => 'co_invites', 'action' => 'send',
'copersonid' => $p['CoPerson']['id'], 'co' => $cur_co['Co']['id'])) .
'\')";>' . _txt('op.inv.resend') . '</button>' . "\n";
+ }
}
?>
<?php ; ?>

Modified: registry/trunk/app/View/CoPetitions/fields.inc
===================================================================
--- registry/trunk/app/View/CoPetitions/fields.inc 2012-04-02 14:45:46
UTC (rev 273)
+++ registry/trunk/app/View/CoPetitions/fields.inc 2012-04-02 14:48:17
UTC (rev 274)
@@ -64,14 +64,66 @@
// completed according to a configuration, not according to a model. This
is a
// lot of logic to embed in a view file, and plausibly this code should be
// refactored at some point.
-
- // Start by enumerating over all attributes defined for the enrollment flow
- // associated with this petition.
-
- // We do a series of <?php tags because we can't mix and match embedded
tag styles
?>
-<table id="<?php echo $this->action; ?>_co_petition" class="ui-widget">
+
+<h2 class="ui-state-default"><?php print _txt('ct.co_petitions.1'); ?></h2>
+
+<table id="<?php print $this->action; ?>_co_petition" class="ui-widget">
<tbody>
+ <tr class="line<?php print ($l % 2); $l++; ?>">
+ <th><?php print _txt('fd.status'); ?></th>
+ <td><?php print _txt('en.status', null,
$co_petitions[0]['CoPetition']['status']); ?></td>
+ </tr>
+ <tr class="line<?php print ($l % 2); $l++; ?>">
+ <th><?php print _txt('fd.petitioner'); ?></th>
+ <td>
+ <?php
+ if(isset($co_petitions[0]['PetitionerCoPerson']['Name'])) {
+ print generateCn($co_petitions[0]['PetitionerCoPerson']['Name']);
+ }
+ ?>
+ </td>
+ </tr>
+ <tr class="line<?php print ($l % 2); $l++; ?>">
+ <th><?php print _txt('fd.sponsor'); ?></th>
+ <td>
+ <?php
+ if(isset($co_petitions[0]['SponsorCoPerson']['Name'])) {
+ print generateCn($co_petitions[0]['SponsorCoPerson']['Name']);
+ }
+ ?>
+ </td>
+ </tr>
+ <tr class="line<?php print ($l % 2); $l++; ?>">
+ <th><?php print _txt('fd.approver'); ?></th>
+ <td>
+ <?php
+ if(isset($co_petitions[0]['ApproverCoPerson']['Name'])) {
+ print generateCn($co_petitions[0]['ApproverCoPerson']['Name']);
+ }
+ ?>
+ </td>
+ </tr>
+ <tr class="line<?php print ($l % 2); $l++; ?>">
+ <th><?php print _txt('fd.created'); ?></th>
+ <td><?php print
$this->Time->nice($co_petitions[0]['CoPetition']['created']); ?></td>
+ </tr>
+ <tr class="line<?php print ($l % 2); $l++; ?>">
+ <th><?php print _txt('fd.modified'); ?></th>
+ <td><?php print
$this->Time->nice($co_petitions[0]['CoPetition']['modified']); ?></td>
+ </tr>
+ </tbody>
+</table>
+
+<?php
+ // Enumerate over all attributes defined for the enrollment flow
associated with this petition.
+ // We do a series of <?php tags because we can't mix and match embedded
tag styles.
+?>
+
+<h2 class="ui-state-default"><?php print _txt('fd.attrs.pet'); ?></h2>
+
+<table id="<?php print $this->action; ?>_co_petition_attrs"
class="ui-widget">
+ <tbody>
<?php foreach ($co_enrollment_attributes as $ea): ?>
<?php $fieldName = $ea['model'] . '.' . $ea['field']; ?>
<?php if($ea['hidden']): ?>
@@ -82,7 +134,7 @@
<?php
// Emit the label for this field

- print $ea['label'];
+ print "<b>" . $ea['label'] . "</b>";

if($ea['required']) {
print "<font class=\"required\">*</font>\n";
@@ -147,10 +199,21 @@

print "\n";
} else {
- // Just emit the current value for this attribute
+ // Just emit the current value for this attribute, if set

- // if $ruleType == 'inList'
- //print $cm_texts[ $cm_lang ]['en.affil'][
$co_person_roles[0]['CoPersonRole']['affiliation']];
+ if(isset($co_petition_attribute_values[ $ea['id'] ][
$ea['field'] ])) {
+ switch($ruleType) {
+ case 'inList':
+ print $ea['select'][ $co_petition_attribute_values[
$ea['id'] ][ $ea['field'] ]];
+ break;
+ case 'validateTimestamp':
+ print $this->Time->nice($co_petition_attribute_values[
$ea['id'] ][ $ea['field'] ]);
+ break;
+ default:
+ print $co_petition_attribute_values[ $ea['id'] ][
$ea['field'] ];
+ break;
+ }
+ }
}
?>
</td>
@@ -170,3 +233,25 @@
</tr>
</tbody>
</table>
+
+<h2 class="ui-state-default"><?php print _txt('fd.history.pt'); ?></h2>
+
+<table id="<?php print $this->action; ?>_co_petition_attrs"
class="ui-widget">
+ <tbody>
+ <tr>
+ <th class="ui-state-default"><?php print _txt('fd.action'); ?></th>
+ <th class="ui-state-default"><?php print _txt('fd.actor'); ?></th>
+ <th class="ui-state-default"><?php print _txt('fd.comment'); ?></th>
+ <th class="ui-state-default"><?php print _txt('fd.timestamp'); ?></th>
+ </tr>
+
+ <?php foreach ($co_petitions[0]['CoPetitionHistoryRecord'] as $hr): ?>
+ <tr class="line<?php print ($l % 2); $l++; ?>">
+ <td><?php print $hr['action']; ?></td>
+ <td><?php print generateCn($hr['ActorCoPerson']['Name']); ?></td>
+ <td><?php print $hr['comment']; ?></td>
+ <td><?php print $this->Time->nice($hr['created']); ?></td>
+ </tr>
+ <?php endforeach; // CoPetitionHistoryRecord ?>
+ </tbody>
+</table>


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

Modified: registry/trunk/app/View/Layouts/default.ctp
===================================================================
--- registry/trunk/app/View/Layouts/default.ctp 2012-04-02 14:45:46 UTC (rev
273)
+++ registry/trunk/app/View/Layouts/default.ctp 2012-04-02 14:48:17 UTC (rev
274)
@@ -200,7 +200,14 @@
primary: 'ui-icon-circle-triangle-e'
},
});
-
+
+ $(".petitionbutton").button({
+ icons: {
+ primary: 'ui-icon-script'
+ },
+ text: false
+ });
+
// Datepickers

$(".datepicker").datepicker({

Modified: registry/trunk/app/View/Pages/home.ctp
===================================================================
--- registry/trunk/app/View/Pages/home.ctp 2012-04-02 14:45:46 UTC (rev
273)
+++ registry/trunk/app/View/Pages/home.ctp 2012-04-02 14:48:17 UTC (rev
274)
@@ -122,6 +122,13 @@
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",

Modified: registry/trunk/app/View/Standard/view.ctp
===================================================================
--- registry/trunk/app/View/Standard/view.ctp 2012-04-02 14:45:46 UTC (rev
273)
+++ registry/trunk/app/View/Standard/view.ctp 2012-04-02 14:48:17 UTC (rev
274)
@@ -33,12 +33,16 @@
// Figure out a heading
$h = "";

+ // XXX This should probably get refactored into the models
if(isset($d[0]['Name']))
$h = _txt('op.view-a', array(Sanitize::html(generateCn($d[0]['Name']))));
elseif(isset($d[0]['CoPerson']['Name']))
$h = _txt('op.view-a',
array(Sanitize::html(generateCn($d[0]['CoPerson']['Name'])))) . " (" .
_txt('co') . ")";
elseif(isset($d[0]['OrgIdentity']['Name']))
- $h = _txt('op.view-a',
array(Sanitize::html(generateCn($d[0]['OrgIdentity']['Name'])))) . " (" .
_txt('co') . ")";
+ $h = _txt('op.view-a',
array(Sanitize::html(generateCn($d[0]['OrgIdentity']['Name'])))) . " (" .
_txt('org') . ")";
+ // For CO Petitions
+ elseif(isset($d[0]['EnrolleeCoPerson']['Name']))
+ $h = _txt('op.view-a',
array(Sanitize::html(generateCn($d[0]['EnrolleeCoPerson']['Name'])))) . " ("
. _txt('co') . ")";
// CO Person Role rendering gets some info from co_people
elseif(isset($co_people[0]['Name']))
$h = _txt('op.view-a',
array(Sanitize::html(generateCn($co_people[0]['Name']))));



  • [comanage-dev] r274 - in registry/trunk/app: Config/Schema Controller Lib Model View/CoPeople View/CoPetitions View/Layouts View/Pages View/Standard, svnlog, 04/02/2012

Archive powered by MHonArc 2.6.16.

Top of Page