comanage-dev - [comanage-dev] r574 - in registry/trunk/app: Config/Schema Lib Model View/CoEnrollmentFlows
Subject: COmanage Developers List
List archive
[comanage-dev] r574 - in registry/trunk/app: Config/Schema Lib Model View/CoEnrollmentFlows
Chronological Thread
- From:
- To:
- Subject: [comanage-dev] r574 - in registry/trunk/app: Config/Schema Lib Model View/CoEnrollmentFlows
- Date: Thu, 8 Aug 2013 09:08:17 -0400
Author: benno
Date: 2013-08-08 09:08:17 -0400 (Thu, 08 Aug 2013)
New Revision: 574
Modified:
registry/trunk/app/Config/Schema/schema.xml
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:
Configurable email content per Enrollment Flow (CO-565)
Modified: registry/trunk/app/Config/Schema/schema.xml
===================================================================
--- registry/trunk/app/Config/Schema/schema.xml 2013-08-08 12:31:17 UTC (rev
573)
+++ registry/trunk/app/Config/Schema/schema.xml 2013-08-08 13:08:17 UTC (rev
574)
@@ -543,9 +543,11 @@
<field name="notify_on_provision" type="C" size="128" />
<field name="notify_on_active" type="C" size="128" />
<field name="status" type="C" size="2" />
+ <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="created" type="T" />
<field name="modified" type="T" />
- <field name="notify_from" type="C" size="256" />
<index name="co_enrollment_flows_i1">
<col>co_id</col>
Modified: registry/trunk/app/Lib/lang.php
===================================================================
--- registry/trunk/app/Lib/lang.php 2013-08-08 12:31:17 UTC (rev 573)
+++ registry/trunk/app/Lib/lang.php 2013-08-08 13:08:17 UTC (rev 574)
@@ -108,7 +108,12 @@
// Email Messages
'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.',
+ 'em.invite.body.ef' => 'You have been invited to join (@CO_NAME).
+Please click the link below to accept or decline.
+
+(@INVITE_URL)',
'em.invite.ok' => 'Invitation has been emailed to %1$s',
'em.invite.footer' => 'This email was sent using %1$s.',
@@ -440,7 +445,7 @@
'fd.ef.cf.cmp' => 'Platform Enrollment Configuration',
'fd.ef.coef' => 'Enable Attributes Via CO Enrollment Flow',
'fd.ef.coef.desc' => 'If enabled, allow organizational identity attributes
to be collected via forms during CO enrollment flows (these attributes will
be less authoritative than those obtained via LDAP or SAML)',
- 'fd.ef.efn' => 'From Address for Notifications',
+ 'fd.ef.efn' => 'From Address For Notifications',
'fd.ef.efn.desc' => 'Email address notifications will come from',
'fd.ef.epx' => 'Early Provisioning Executable',
'fd.ef.epx.desc' => '(Need for this TBD)',
@@ -464,6 +469,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.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',
Modified: registry/trunk/app/Model/CoEnrollmentFlow.php
===================================================================
--- registry/trunk/app/Model/CoEnrollmentFlow.php 2013-08-08 12:31:17
UTC (rev 573)
+++ registry/trunk/app/Model/CoEnrollmentFlow.php 2013-08-08 13:08:17
UTC (rev 574)
@@ -103,12 +103,13 @@
'approval_required' => array(
'rule' => array('boolean')
),
- 'confirm_email' => array(
+ 'verify_email' => array(
'rule' => array('boolean')
),
'require_authn' => array(
'rule' => array('boolean')
),
+ /*
'notify_on_early_provision' => array(
'rule' => 'email',
'required' => false,
@@ -123,7 +124,22 @@
'rule' => 'email',
'required' => false,
'allowEmpty' => true
+ ),*/
+ 'notify_from' => array(
+ 'rule' => 'email',
+ 'required' => false,
+ 'allowEmpty' => true
),
+ 'verification_subject' => array(
+ 'rule' => 'notEmpty',
+ 'required' => true,
+ 'allowEmpty' => false
+ ),
+ 'verification_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-08-08 12:31:17 UTC (rev
573)
+++ registry/trunk/app/Model/CoInvite.php 2013-08-08 13:08:17 UTC (rev
574)
@@ -79,7 +79,7 @@
* @throws RuntimeException
*/
- function processReply($inviteId, $confirm, $loginIdentifier=null) {
+ public function processReply($inviteId, $confirm, $loginIdentifier=null) {
$args = array();
$args['conditions']['CoInvite.invitation'] = $inviteId;
@@ -233,6 +233,26 @@
}
/**
+ * Process a message template, replacing parameters with respective values.
+ * Note this function is for configured templates (ie: those loaded from
the
+ * database) and not for Cake templates (ie: those loaded from
View/Emails).
+ *
+ * @since COmanage Registry v0.8.2
+ * @param String Template text
+ * @param Array Array of View Variables, used to replace parameters
+ * @return String Processed template
+ */
+
+ protected function processTemplate($template, $viewVars) {
+ $searchKeys = array("(@CO_NAME)",
+ "(@INVITE_URL)");
+ $replaceVals = array($viewVars['co_name'],
+ Router::url(array('controller' => 'co_invites',
'action' => 'reply', $viewVars['invite_id']), true));
+
+ return str_replace($searchKeys, $replaceVals, $template);
+ }
+
+ /**
* Create and send an invitation. Any existing invitation for the CO
Person will be removed.
*
* @since COmanage Registry v0.7
@@ -241,12 +261,14 @@
* @param Integer CO Person ID of actor sending the invite
* @param String Email Address to send the invite to
* @param String Email Address to send the invite from
- * @param String CO Name (to pass into invite)
+ * @param String CO Name (to pass into invite)
+ * @param String Subject text (for configured templates stored in the
database)
+ * @param String Template text (for configured templates stored in the
database)
* @return Integer CO Invitation ID
* @throws RuntimeException
*/
- function send($coPersonId, $orgIdentityID, $actorPersonId, $toEmail,
$fromEmail=null, $coName) {
+ public function send($coPersonId, $orgIdentityID, $actorPersonId,
$toEmail, $fromEmail=null, $coName, $subject=null, $template=null) {
// Toss any prior invitations for $coPersonId to $toEmail
$this->deleteAll(array('co_person_id' => $coPersonId,
@@ -273,11 +295,26 @@
$viewVariables['co_name'] = $coName;
try {
- $email->template('coinvite', 'basic')
- ->emailFormat('text')
- ->to($toEmail)
- ->viewVars($viewVariables)
- ->subject(_txt('em.invite.subject', array($coName)));
+ if($template) {
+ if($subject) {
+ $msgSubject = $this->processTemplate($subject, $viewVariables);
+ } else {
+ $msgSubject = _txt('em.invite.subject', array($coName));
+ }
+
+ $msgBody = $this->processTemplate($template, $viewVariables);
+
+ $email->emailFormat('text')
+ ->to($toEmail)
+ ->subject($msgSubject)
+ ->message($msgBody);
+ } else {
+ $email->template('coinvite', 'basic')
+ ->emailFormat('text')
+ ->to($toEmail)
+ ->viewVars($viewVariables)
+ ->subject(_txt('em.invite.subject', array($coName)));
+ }
// If this enrollment has a default email address set, use it,
otherwise leave in the default for the site.
if($fromEmail) {
Modified: registry/trunk/app/Model/CoPetition.php
===================================================================
--- registry/trunk/app/Model/CoPetition.php 2013-08-08 12:31:17 UTC (rev
573)
+++ registry/trunk/app/Model/CoPetition.php 2013-08-08 13:08:17 UTC (rev
574)
@@ -442,11 +442,13 @@
// we should copy to the CO Person.
foreach(array('EmailAddress', 'Identifier', 'Name') as $m) {
- foreach(array_keys($orgData[$m]) as $a) {
- // $a will be the co_enrollment_attribute:id, so we can tell
different
- // addresses apart
- if(isset($copyAttrs[$a])) {
- $coData[$m][$a] = $orgData[$m][$a];
+ if(!empty($orgData[$m])) {
+ foreach(array_keys($orgData[$m]) as $a) {
+ // $a will be the co_enrollment_attribute:id, so we can tell
different
+ // addresses apart
+ if(isset($copyAttrs[$a])) {
+ $coData[$m][$a] = $orgData[$m][$a];
+ }
}
}
}
@@ -524,11 +526,13 @@
// we should copy to the CO Person Role.
foreach(array('Address', 'TelephoneNumber') as $m) {
- foreach(array_keys($orgData[$m]) as $a) {
- // $a will be the co_enrollment_attribute:id, so we can tell
different
- // addresses apart
- if(isset($copyAttrs[$a])) {
- $coRoleData[$m][$a] = $orgData[$m][$a];
+ if(!empty($orgData[$m])) {
+ foreach(array_keys($orgData[$m]) as $a) {
+ // $a will be the co_enrollment_attribute:id, so we can tell
different
+ // addresses apart
+ if(isset($copyAttrs[$a])) {
+ $coRoleData[$m][$a] = $orgData[$m][$a];
+ }
}
}
}
@@ -854,6 +858,12 @@
$notifyFrom = $this->CoEnrollmentFlow->field('notify_from',
array('CoEnrollmentFlow.id' => $enrollmentFlowID));
+ $subjectTemplate =
$this->CoEnrollmentFlow->field('verification_subject',
+
array('CoEnrollmentFlow.id' => $enrollmentFlowID));
+
+ $bodyTemplate = $this->CoEnrollmentFlow->field('verification_body',
+
array('CoEnrollmentFlow.id' => $enrollmentFlowID));
+
$coName = $this->Co->field('name', array('Co.id' => $coId));
$coInviteId = $this->CoInvite->send($coPersonID,
@@ -861,7 +871,9 @@
$petitionerId,
$toEmail,
$notifyFrom,
- $coName);
+ $coName,
+ $subjectTemplate,
+ $bodyTemplate);
// Add the invite ID to the petition record
Modified: registry/trunk/app/View/CoEnrollmentFlows/fields.inc
===================================================================
--- registry/trunk/app/View/CoEnrollmentFlows/fields.inc 2013-08-08
12:31:17 UTC (rev 573)
+++ registry/trunk/app/View/CoEnrollmentFlows/fields.inc 2013-08-08
13:08:17 UTC (rev 574)
@@ -259,15 +259,16 @@
:
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['require_authn']));
?>
</td>
</tr>
+<!--
<tr class="line2">
<td>
<b><?php print _txt('fd.ef.epx'); ?></b><br />
<font class="desc"><?php print _txt('fd.ef.epx.desc'); ?></font>
</td>
<td>
- <?php print ($e
+ <?php /*print ($e
? $this->Form->input('early_provisioning_exec')
- :
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['early_provisioning_exec']));
?>
+ :
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['early_provisioning_exec']));*/
?>
</td>
</tr>
<tr class="line1">
@@ -276,9 +277,9 @@
<font class="desc"><?php print _txt('fd.ef.px.desc'); ?></font>
</td>
<td>
- <?php print ($e
+ <?php /*print ($e
? $this->Form->input('provisioning_exec')
- :
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['provisioning_exec']));
?>
+ :
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['provisioning_exec']));
*/?>
</td>
</tr>
<tr class="line2">
@@ -287,9 +288,9 @@
<font class="desc"><?php print _txt('fd.ef.noep.desc'); ?></font>
</td>
<td>
- <?php print ($e
+ <?php /*print ($e
? $this->Form->input('notify_on_early_provision')
- :
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['notify_on_early_provision']));
?>
+ :
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['notify_on_early_provision']));*/
?>
</td>
</tr>
<tr class="line1">
@@ -298,9 +299,9 @@
<font class="desc"><?php print _txt('fd.ef.nop.desc'); ?></font>
</td>
<td>
- <?php print ($e
+ <?php /*print ($e
? $this->Form->input('notify_on_provision')
- :
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['notify_on_provision']));
?>
+ :
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['notify_on_provision']));*/
?>
</td>
</tr>
<tr class="line2">
@@ -309,11 +310,12 @@
<font class="desc"><?php print _txt('fd.ef.noa.desc'); ?></font>
</td>
<td>
- <?php print ($e
+ <?php /*print ($e
? $this->Form->input('notify_on_active')
- :
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['notify_on_active']));
?>
+ :
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['notify_on_active']));*/
?>
</td>
</tr>
+-->
<tr class="line1">
<td>
<b><?php print _txt('fd.ef.efn'); ?></b><br />
@@ -325,6 +327,30 @@
:
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['notify_from']));
?>
</td>
</tr>
+ <tr class="line2">
+ <td>
+ <b><?php print _txt('fd.ef.vsub'); ?></b><br />
+ <font class="desc"><?php print _txt('fd.ef.vsub.desc'); ?></font>
+ </td>
+ <td>
+ <?php print ($e
+ ? $this->Form->input('verification_subject',
+ array('default' =>
_txt('em.invite.subject.ef')))
+ :
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['verification_subject']));
?>
+ </td>
+ </tr>
+ <tr class="line1">
+ <td>
+ <b><?php print _txt('fd.ef.vbody'); ?></b><br />
+ <font class="desc"><?php print _txt('fd.ef.vbody.desc'); ?></font>
+ </td>
+ <td>
+ <?php print ($e
+ ? $this->Form->input('verification_body',
+ array('default' =>
_txt('em.invite.body.ef')))
+ :
Sanitize::html($co_enrollment_flows[0]['CoEnrollmentFlow']['verification_body']));
?>
+ </td>
+ </tr>
</tbody>
</table>
<?php
- [comanage-dev] r574 - in registry/trunk/app: Config/Schema Lib Model View/CoEnrollmentFlows, svnlog, 08/08/2013
Archive powered by MHonArc 2.6.16.