Skip to Content.
Sympa Menu

comanage-dev - [comanage-dev] r586 - in registry/trunk/app: Controller Lib Model View/CoEnrollmentAttributes

Subject: COmanage Developers List

List archive

[comanage-dev] r586 - in registry/trunk/app: Controller Lib Model View/CoEnrollmentAttributes


Chronological Thread 
  • From:
  • To:
  • Subject: [comanage-dev] r586 - in registry/trunk/app: Controller Lib Model View/CoEnrollmentAttributes
  • Date: Fri, 6 Sep 2013 23:52:56 -0400

Author: benno
Date: 2013-09-06 23:52:56 -0400 (Fri, 06 Sep 2013)
New Revision: 586

Modified:
registry/trunk/app/Controller/CoEnrollmentAttributesController.php
registry/trunk/app/Lib/lang.php
registry/trunk/app/Model/CoEnrollmentAttribute.php
registry/trunk/app/Model/CoPetition.php
registry/trunk/app/View/CoEnrollmentAttributes/fields.inc
Log:
Add support for CO Group membership as enrollment flow attribute (CO-653)

Modified: registry/trunk/app/Controller/CoEnrollmentAttributesController.php
===================================================================
--- registry/trunk/app/Controller/CoEnrollmentAttributesController.php
2013-09-05 23:25:54 UTC (rev 585)
+++ registry/trunk/app/Controller/CoEnrollmentAttributesController.php
2013-09-07 03:52:56 UTC (rev 586)
@@ -132,6 +132,20 @@
// 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));
}
}


Modified: registry/trunk/app/Lib/lang.php
===================================================================
--- registry/trunk/app/Lib/lang.php 2013-09-05 23:25:54 UTC (rev 585)
+++ registry/trunk/app/Lib/lang.php 2013-09-07 03:52:56 UTC (rev 586)
@@ -532,6 +532,7 @@
'fd.enrollee' => 'Enrollee',
'fd.false' => 'False',
'fd.group.desc.adm' => '%1$s Administrators',
+ 'fd.group.grmem' => 'Group Member',
'fd.group.mem' => 'Member',
'fd.group.memin' => 'membership in "%1$s"',
'fd.group.own' => 'Owner',

Modified: registry/trunk/app/Model/CoEnrollmentAttribute.php
===================================================================
--- registry/trunk/app/Model/CoEnrollmentAttribute.php 2013-09-05 23:25:54
UTC (rev 585)
+++ registry/trunk/app/Model/CoEnrollmentAttribute.php 2013-09-07 03:52:56
UTC (rev 586)
@@ -128,7 +128,12 @@

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')
. ")";
-
+
+ // (2a) Group Memberships are Multi valued CO Person attributes, but
have all sorts
+ // of special logic around them so they get their own code (code=g)
+
+ $ret['g:co_group_member'] = _txt('fd.group.grmem') . " (" .
_txt('ct.co_people.1') . ")";
+
// (3) Multi valued CO Person Role attributes (code=m)

foreach(array_keys($cm_texts[ $cm_lang ]['en.contact.phone']) as $k)
@@ -489,7 +494,6 @@
$attr['default'] = 0;
break;
}
-
} else {
// Label
$attr['group'] = $efAttr['CoEnrollmentAttribute']['label'];
@@ -523,6 +527,66 @@
$attrs[] = $attr;
}
}
+ } elseif($attrCode == 'g') {
+ // Group Membership requires a bit of specialness. Basically, we'll
manually
+ // contruct the $attrs entry.
+
+ $attr = array();
+ $attr['id'] = $efAttr['CoEnrollmentAttribute']['id'];
+ $attr['attribute'] = $efAttr['CoEnrollmentAttribute']['attribute'];
+ $attr['required'] = $efAttr['CoEnrollmentAttribute']['required'];
+ $attr['hidden'] = false;
+ $attr['label'] = $efAttr['CoEnrollmentAttribute']['label'];
+ $attr['description'] =
$efAttr['CoEnrollmentAttribute']['description'];
+ $attr['model'] = "EnrolleeCoPerson.CoGroupMember." .
$efAttr['CoEnrollmentAttribute']['id'];
+ $attr['field'] = "co_group_id";
+ if(!empty($efAttr['CoEnrollmentAttributeDefault'][0]['value'])) {
+ $attr['default'] =
$efAttr['CoEnrollmentAttributeDefault'][0]['value'];
+ }
+ $attr['modifiable'] =
$efAttr['CoEnrollmentAttributeDefault'][0]['modifiable'];
+ $attr['validate']['rule'][0] = 'inList';
+
+ // Pull the set of groups for the select
+ $args = array();
+ $args['conditions']['co_id'] = $efAttr['CoEnrollmentFlow']['co_id'];
+ $args['fields'] = array('CoGroup.id', 'CoGroup.name');
+ $args['contain'] = false;
+
+ $attr['select'] = $this->CoEnrollmentFlow->Co->CoGroup->find('list',
$args);
+
+ $attrs[] = $attr;
+
+ // Inject hidden attributes to specify membership
+
+ $attr = array();
+ $attr['id'] = $efAttr['CoEnrollmentAttribute']['id'];
+ $attr['attribute'] = $efAttr['CoEnrollmentAttribute']['attribute'];
+ $attr['hidden'] = true;
+ $attr['default'] = true;
+ $attr['model'] = "EnrolleeCoPerson.CoGroupMember." .
$efAttr['CoEnrollmentAttribute']['id'];
+ $attr['field'] = "member";
+
+ $attrs[] = $attr;
+
+ // and ownership
+
+ $attr['default'] = 0;
+ $attr['field'] = "owner";
+
+ $attrs[] = $attr;
+
+ // Inject a hidden attribute to link this attribute back to its
definition.
+
+ $attr = array();
+
+ $attr['id'] = $efAttr['CoEnrollmentAttribute']['id'];
+ $attr['attribute'] = $efAttr['CoEnrollmentAttribute']['attribute'];
+ $attr['hidden'] = true;
+ $attr['default'] = $attr['id'];
+ $attr['model'] = "EnrolleeCoPerson.CoGroupMember." .
$efAttr['CoEnrollmentAttribute']['id'];
+ $attr['field'] = "co_enrollment_attribute_id";
+
+ $attrs[] = $attr;
} else {
throw new RuntimeException("Unknown attribute code: " . $attrCode);
}

Modified: registry/trunk/app/Model/CoPetition.php
===================================================================
--- registry/trunk/app/Model/CoPetition.php 2013-09-05 23:25:54 UTC (rev
585)
+++ registry/trunk/app/Model/CoPetition.php 2013-09-07 03:52:56 UTC (rev
586)
@@ -1437,7 +1437,11 @@
// missing) related models.
$errFields = $this->$primaryModel->$model->invalidFields();

- if(!empty($errFields)) {
+ if(!empty($errFields)
+ // If the only error is co_person_id, ignore it since
saveAssociated
+ // will automatically key the record
+ && (count(array_keys($errFields)) > 1
+ || !isset($errFields['co_person_id']))) {
// These errors are going to get attached to $this->model by
default, which means when
// the petition re-renders, FormHelper won't display them.
They need to be attached to
// $this->$primaryModel, keyed as though they were validated
along with $primaryModel.

Modified: registry/trunk/app/View/CoEnrollmentAttributes/fields.inc
===================================================================
--- registry/trunk/app/View/CoEnrollmentAttributes/fields.inc 2013-09-05
23:25:54 UTC (rev 585)
+++ registry/trunk/app/View/CoEnrollmentAttributes/fields.inc 2013-09-07
03:52:56 UTC (rev 586)
@@ -71,7 +71,7 @@
var curattr =
document.getElementById('CoEnrollmentAttributeAttribute').value;
var attrtype = curattr[0];

- if(attrtype == "r" || attrtype == "o" || attrtype == "x") {
+ if(attrtype == "r" || attrtype == "o" || attrtype == "x" || attrtype ==
"g") {
$("#attr_def_div").show("slide", { "direction" : "up" });

// Adjust the gadgets shown
@@ -80,6 +80,7 @@
$("#attr_def_val_affil_div").hide();
$("#attr_def_val_cou_div").hide();
$("#attr_def_val_date_div").hide();
+ $("#attr_def_val_group_div").hide();
$("#attr_def_val_sponsor_div").hide();

var curval =
document.getElementById('CoEnrollmentAttributeDefault0Value').value;
@@ -127,6 +128,10 @@
}

$("#attr_def_val_date_div").show("fade");
+ } else if(curattrcode == "g") {
+ // Set current value before showing
+ document.getElementById('def_group_val').value = curval;
+ $("#attr_def_val_group_div").show("fade");
} else {
$("#attr_def_val_div").show();
}
@@ -385,6 +390,18 @@
<br />
<?php endif; ?>
</div>
+ <div id="attr_def_val_group_div">
+ <?php if($e): ?>
+ <select name="def_group_val"
+ id="def_group_val"
+ onchange="set_attr_def_value('def_group_val')">
+ <option value=""></option>
+ <?php foreach(array_keys($vv_groups) as $k): ?>
+ <option value="<?php print Sanitize::html($k); ?>"><?php
print Sanitize::html($vv_groups[$k]); ?></option>
+ <?php endforeach; ?>
+ </select>
+ <?php endif; ?>
+ </div>
<div id="attr_def_val_sponsor_div">
<?php if($e): ?>
<select name="def_sponsor_val"



  • [comanage-dev] r586 - in registry/trunk/app: Controller Lib Model View/CoEnrollmentAttributes, svnlog, 09/06/2013

Archive powered by MHonArc 2.6.16.

Top of Page