Skip to Content.
Sympa Menu

comanage-dev - [comanage-dev] r591 - in registry/trunk/app: Config/Schema Lib Model View/CoEnrollmentFlows

Subject: COmanage Developers List

List archive

[comanage-dev] r591 - in registry/trunk/app: Config/Schema Lib Model View/CoEnrollmentFlows


Chronological Thread 
  • From:
  • To:
  • Subject: [comanage-dev] r591 - in registry/trunk/app: Config/Schema Lib Model View/CoEnrollmentFlows
  • Date: Sun, 15 Sep 2013 18:03:01 -0400

Author: benno
Date: 2013-09-15 18:03:01 -0400 (Sun, 15 Sep 2013)
New Revision: 591

Modified:
registry/trunk/app/Config/Schema/schema.xml
registry/trunk/app/Lib/enum.php
registry/trunk/app/Lib/lang.php
registry/trunk/app/Model/CoEnrollmentFlow.php
registry/trunk/app/Model/CoInvite.php
registry/trunk/app/Model/CoPetition.php
registry/trunk/app/View/CoEnrollmentFlows/fields.inc
Log:
Interim notification on approval of petitions (CO-687)

Modified: registry/trunk/app/Config/Schema/schema.xml
===================================================================
--- registry/trunk/app/Config/Schema/schema.xml 2013-09-12 11:42:30 UTC (rev
590)
+++ registry/trunk/app/Config/Schema/schema.xml 2013-09-15 22:03:01 UTC (rev
591)
@@ -556,6 +556,9 @@
<field name="notify_from" type="C" size="256" />
<field name="verification_subject" type="C" size="256" />
<field name="verification_body" type="X" size="4000" />
+ <field name="notify_on_approval" type="L" />
+ <field name="approval_subject" type="C" size="256" />
+ <field name="approval_body" type="X" size="4000" />
<field name="created" type="T" />
<field name="modified" type="T" />


Modified: registry/trunk/app/Lib/enum.php
===================================================================
--- registry/trunk/app/Lib/enum.php 2013-09-12 11:42:30 UTC (rev 590)
+++ registry/trunk/app/Lib/enum.php 2013-09-15 22:03:01 UTC (rev 591)
@@ -238,6 +238,7 @@
const IdentifiersAssigned = 'IA';
const InviteConfirmed = 'IC';
const InviteSent = 'IS';
+ const NotificationSent = 'NS';
}

// The status of a provisioning plugin

Modified: registry/trunk/app/Lib/lang.php
===================================================================
--- registry/trunk/app/Lib/lang.php 2013-09-12 11:42:30 UTC (rev 590)
+++ registry/trunk/app/Lib/lang.php 2013-09-15 22:03:01 UTC (rev 591)
@@ -107,6 +107,8 @@
'ct.telephone_numbers.pl' => 'Telephone Numbers',

// Email Messages
+ 'em.approval.subject.ef' => 'Petition to join (@CO_NAME) has been
approved',
+ 'em.approval.body.ef' => 'Your petition to join (@CO_NAME) as been
approved. You may now log in to the platform.',
'em.invite.subject' => 'Invitation to join %1$s',
'em.invite.subject.ef' => 'Invitation to join (@CO_NAME)',
'em.invite.body' => 'You have been invited to join %1$s. Please
click the link below to accept or decline.',
@@ -401,6 +403,8 @@
'er.inv.exp' => 'Invitation Expired',
'er.inv.nf' => 'Invitation Not Found',
'er.nd.already' => 'NSF Demographic data already exists for this person',
+ 'er.nt.email' => 'Notification could not be sent because no email
address was found',
+ 'er.nt.send' => 'Notification to %1$s failed (%2$s)',
'er.notfound' => '%1$s "%2$s" Not Found',
'er.notprov' => 'Not Provided',
'er.notprov.id' => '%1$s ID Not Provided',
@@ -484,6 +488,10 @@
'fd.ef.aea.desc' => 'If administrator enrollment is enabled, require
enrollees to authenticate to the platform in order to complete their
enrollment',
'fd.ef.aee' => 'Require Email Confirmation For Administrator
Enrollment',
'fd.ef.aee.desc' => 'If administrator enrollment is enabled, require
enrollees to confirm their email address in order to complete their
enrollment',
+ 'fd.ef.abody' => 'Approval Email Body',
+ 'fd.ef.abody.desc' => 'Body for email message sent after Petition is
approved. Max 4000 characters.',
+ 'fd.ef.asub' => 'Subject For Approval Email',
+ 'fd.ef.asub.desc' => 'Subject line for email message sent after Petition
is approved.',
'fd.ef.appr' => 'Require Approval For Enrollment',
'fd.ef.appr.desc' => 'If administrator approval is required, a member of
the appropriate <tt>admin.approvers</tt> group must approve the enrollment',
'fd.ef.authn' => 'Require Authentication',
@@ -506,6 +514,8 @@
'fd.ef.match.desc' => 'Identity Matching policy for this enrollment flow,
see <a
href="https://spaces.internet2.edu/display/COmanage/Registry+Enrollment+Flow+Configuration#RegistryEnrollmentFlowConfiguration-IdentityMatching";>Identity
Matching</a> for details',
'fd.ef.noa' => 'Notify On Active Status',
'fd.ef.noa.desc' => 'Email address to notify upon status being set to
active',
+ 'fd.ef.noap' => 'Notify On Approved Status',
+ 'fd.ef.noap.desc' => 'Notify enrollee when Petition is approved',
'fd.ef.noep' => 'Notify On Early Provisioning',
'fd.ef.noep.desc' => 'Email address to notify upon execution of early
provisioning',
'fd.ef.nop' => 'Notify On Provisioning',
@@ -520,10 +530,10 @@
'fd.ef.saml.desc' => 'If the enrollee is authenticated via a SAML IdP with
attributes released, examine the SAML assertion for authoritative attributes',
'fd.ef.sea' => 'Require Authentication For Self Enrollment',
'fd.ef.sea.desc' => 'If self enrollment is enabled, require enrollees who
are self-enrolling to authenticate to the platform',
+ 'fd.ef.vbody' => 'Verification Email Body',
+ 'fd.ef.vbody.desc' => 'Body for email message sent as part of verification
step. Max 4000 characters.',
'fd.ef.vsub' => 'Subject For Verification Email',
'fd.ef.vsub.desc' => 'Subject line for email message sent as part of
verification step.',
- 'fd.ef.vbody' => 'Verification Email Body',
- 'fd.ef.vbody.desc' => 'Body for email message sent as part of verification
step. Max 4000 characters.',
// (End enrollment configuration fields)
// This must be named fd.model.validation-field
'fd.email_address.mail' => 'Email',
@@ -705,6 +715,7 @@
'rs.inv.dec-a' => 'Invitation to %1$s declined',
'rs.inv.sent' => 'Invitation sent to %1$s',
'rs.mail.verified' => 'Email Address "%1$s" verified',
+ 'rs.nt.sent' => 'Approval notification sent to %1$s',
'rs.prov-a' => 'Provisioned %1$s',
'rs.prov.ok' => 'Provisioning completed successfully',
'rs.pt.approve' => 'Petition Approved',

Modified: registry/trunk/app/Model/CoEnrollmentFlow.php
===================================================================
--- registry/trunk/app/Model/CoEnrollmentFlow.php 2013-09-12 11:42:30
UTC (rev 590)
+++ registry/trunk/app/Model/CoEnrollmentFlow.php 2013-09-15 22:03:01
UTC (rev 591)
@@ -140,6 +140,19 @@
'required' => true,
'allowEmpty' => false
),
+ 'notify_on_approval' => array(
+ 'rule' => array('boolean')
+ ),
+ 'approval_subject' => array(
+ 'rule' => 'notEmpty',
+ 'required' => true,
+ 'allowEmpty' => false
+ ),
+ 'approval_body' => array(
+ 'rule' => 'notEmpty',
+ 'required' => true,
+ 'allowEmpty' => false
+ ),
'status' => array(
'rule' => array('inList', array(StatusEnum::Active,
StatusEnum::Suspended))

Modified: registry/trunk/app/Model/CoInvite.php
===================================================================
--- registry/trunk/app/Model/CoInvite.php 2013-09-12 11:42:30 UTC (rev
590)
+++ registry/trunk/app/Model/CoInvite.php 2013-09-15 22:03:01 UTC (rev
591)
@@ -243,7 +243,8 @@
* @return String Processed template
*/

- protected function processTemplate($template, $viewVars) {
+ // XXX Revert this to protected when CoPetition::updateStatus gets
refactored
+ public function processTemplate($template, $viewVars) {
$searchKeys = array("(@CO_NAME)",
"(@INVITE_URL)");
$replaceVals = array($viewVars['co_name'],

Modified: registry/trunk/app/Model/CoPetition.php
===================================================================
--- registry/trunk/app/Model/CoPetition.php 2013-09-12 11:42:30 UTC (rev
590)
+++ registry/trunk/app/Model/CoPetition.php 2013-09-15 22:03:01 UTC (rev
591)
@@ -22,6 +22,8 @@
* @version $Id$
*/

+App::uses('CakeEmail', 'Network/Email');
+
class CoPetition extends AppModel {
// Define class name for cake
public $name = "CoPetition";
@@ -1114,12 +1116,13 @@
if(!$fail) {
$petitionAction = null;

- switch($newStatus) {
+ switch($newPetitionStatus) {
case StatusEnum::Approved:
$petitionAction = PetitionActionEnum::Approved;
break;
case StatusEnum::Confirmed:
- $petitionAction = PetitionActionEnum::InviteConfirmed;
+ // We already recorded this history above, so don't do it again
here
+ //$petitionAction = PetitionActionEnum::InviteConfirmed;
break;
case StatusEnum::Denied:
$petitionAction = PetitionActionEnum::Denied;
@@ -1243,6 +1246,98 @@
}
}

+ // Send an approval notification, if configured
+
+ if(!$fail && $newPetitionStatus == StatusEnum::Approved) {
+ $enrollmentFlowID = $this->field('co_enrollment_flow_id');
+
+ $notify = $this->CoEnrollmentFlow->field('notify_on_approval',
+ array('CoEnrollmentFlow.id'
=> $enrollmentFlowID));
+
+ if($notify) {
+ // We'll embed some email logic here (similar to that in
CoInvite), since we don't
+ // have a notification infrastructure yet. This should get
refactored when CO-207
+ // is addressed. (Be sure to remove the reference to
App::uses('CakeEmail'), above.)
+
+ // Which address should we send to? How about the one we sent the
invitation to...
+ // but we can't guarantee access to that since the invitation will
have been
+ // discarded. So we use the same logic as resend(), above.
+
+ $args = array();
+ $args['conditions']['EmailAddress.org_identity_id'] =
$this->field('enrollee_org_identity_id');
+ $args['contain'] = false;
+
+ $email = $this->EnrolleeOrgIdentity->EmailAddress->find('first',
$args);
+
+ if(isset($email['EmailAddress']['mail']) &&
$email['EmailAddress']['mail'] != "") {
+ $toEmail = $email['EmailAddress']['mail'];
+
+ $notifyFrom = $this->CoEnrollmentFlow->field('notify_from',
+
array('CoEnrollmentFlow.id' => $enrollmentFlowID));
+
+ $subjectTemplate =
$this->CoEnrollmentFlow->field('approval_subject',
+
array('CoEnrollmentFlow.id' => $enrollmentFlowID));
+
+ $bodyTemplate = $this->CoEnrollmentFlow->field('approval_body',
+
array('CoEnrollmentFlow.id' => $enrollmentFlowID));
+
+ $coName = $this->Co->field('name', array('Co.id' =>
$this->field('co_id')));
+
+ // Try to send the notification
+
+ $email = new CakeEmail('default');
+
+ $viewVariables = array();
+ $viewVariables['co_name'] = $coName;
+ $viewVariables['invite_id'] = ""; // Only set because
CoInvite::processTemplate requires it
+
+ try {
+ // XXX We use CoInvite's processTemplate, which isn't specific
to CoInvite.
+ // However, that should be refactored as part of the
Notification work
+ // so template processing happens in a more generic location.
+ // Note at that point processTemplate (if it still exists)
should be made
+ // protected again.
+ $msgSubject =
$this->CoInvite->processTemplate($subjectTemplate, $viewVariables);
+ $msgBody = $this->CoInvite->processTemplate($bodyTemplate,
$viewVariables);
+
+ $email->emailFormat('text')
+ ->to($toEmail)
+ ->subject($msgSubject)
+ ->message($msgBody);
+
+ // If this enrollment has a default email address set, use it,
otherwise leave in the default for the site.
+ if(!empty($notifyFrom)) {
+ $email->from($notifyFrom);
+ }
+
+ // Send the email
+ $email->send();
+
+ // And cut a history record
+
+ $this->CoPetitionHistoryRecord->record($id,
+ $actorCoPersonID,
+
PetitionActionEnum::NotificationSent,
+ _txt('rs.nt.sent',
array($toEmail)));
+ } catch(Exception $e) {
+ // We don't want to fail, but we will at least record that
something went wrong
+
+ $this->CoPetitionHistoryRecord->record($id,
+ $actorCoPersonID,
+
PetitionActionEnum::NotificationSent,
+ _txt('er.nt.send',
array($toEmail, $e->getMessage())));
+ }
+ } else {
+ // We don't want to fail, but we will at least record that
something went wrong
+
+ $this->CoPetitionHistoryRecord->record($id,
+ $actorCoPersonID,
+
PetitionActionEnum::NotificationSent,
+ _txt('er.nt.email'));
+ }
+ }
+ }
+
if(!$fail) {
// Commit


Modified: registry/trunk/app/View/CoEnrollmentFlows/fields.inc
===================================================================
--- registry/trunk/app/View/CoEnrollmentFlows/fields.inc 2013-09-12
11:42:30 UTC (rev 590)
+++ registry/trunk/app/View/CoEnrollmentFlows/fields.inc 2013-09-15
22:03:01 UTC (rev 591)
@@ -39,7 +39,6 @@

if($e)
{
-
// Edit button
if($this->action == "edit" && $permissions['edit']){
$sidebarButtons[] = array(
@@ -86,8 +85,21 @@
}
}

+ function fields_update_gadgets() {
+ // Hide or show gadgets according to current state
+
+ if(document.getElementById('CoEnrollmentFlowNotifyOnApproval').checked) {
+ $("#edit_co_enrollment_configuration tr:nth-child(12)").show('fade');
+ $("#edit_co_enrollment_configuration tr:nth-child(13)").show('fade');
+ } else {
+ $("#edit_co_enrollment_configuration tr:nth-child(12)").hide('fade');
+ $("#edit_co_enrollment_configuration tr:nth-child(13)").hide('fade');
+ }
+ }
+
function js_local_onload() {
authz_update_gadgets();
+ fields_update_gadgets();
}
</script>
<table id="<?php print $this->action; ?>_co_enrollment_configuration"
class="ui-widget">
@@ -351,6 +363,42 @@
:
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['verification_body']));
?>
</td>
</tr>
+ <tr class="line2">
+ <td>
+ <b><?php print _txt('fd.ef.noap'); ?></b><br />
+ <font class="desc"><?php print _txt('fd.ef.noap.desc'); ?></font>
+ </td>
+ <td>
+ <?php print ($e
+ ? $this->Form->input('notify_on_approval',
+ array('onChange' =>
'fields_update_gadgets();'))
+ :
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['notify_on_approval']));
?>
+ </td>
+ </tr>
+ <tr class="line1" style="display:none">
+ <td>
+ <b><?php print _txt('fd.ef.asub'); ?></b><br />
+ <font class="desc"><?php print _txt('fd.ef.asub.desc'); ?></font>
+ </td>
+ <td>
+ <?php print ($e
+ ? $this->Form->input('approval_subject',
+ array('default' =>
_txt('em.approval.subject.ef')))
+ :
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['approval_subject']));
?>
+ </td>
+ </tr>
+ <tr class="line2" style="display:none">
+ <td>
+ <b><?php print _txt('fd.ef.abody'); ?></b><br />
+ <font class="desc"><?php print _txt('fd.ef.abody.desc'); ?></font>
+ </td>
+ <td>
+ <?php print ($e
+ ? $this->Form->input('approval_body',
+ array('default' =>
_txt('em.approval.body.ef')))
+ :
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['approval_body']));
?>
+ </td>
+ </tr>
</tbody>
</table>
<?php



  • [comanage-dev] r591 - in registry/trunk/app: Config/Schema Lib Model View/CoEnrollmentFlows, svnlog, 09/15/2013

Archive powered by MHonArc 2.6.16.

Top of Page