Skip to content

Instantly share code, notes, and snippets.

@exside
Forked from Mark-H/chunk.html
Created March 2, 2013 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save exside/5073352 to your computer and use it in GitHub Desktop.
Save exside/5073352 to your computer and use it in GitHub Desktop.
<p>Hi there!</p>
<p>The resource [[+pagetitle]] (ID: [[+id]]) has been [[+mode]].</p>
<p>You can login to the manager at www.mysite.com/manager/ to review and if needed publish the resource.</p>
<p>Thank you!</p>
<?php
// untested
// Update these if you have to
$usergroup = 1; // user group ID (1=admin)
$chunkname = 'notificationtpl'; // name of chunk for the email notification
$emailoptions = array(
'from' => $modx->getOption('emailsender'),
'fromName' => 'Resource Notification',
'subject' => 'Nofication of Created or Updated Resource',
'html' => true,
);
// No need to update below (unless I typo-ed)
$placeholders = $resource->toArray();
$placeholders['mode'] = ($mode == 'upd') ? 'updated' : 'created';
$message = $modx->getChunk($chunkname,$placeholders);
$userIds = $modx->getCollection('modUserGroupMember', array('user_group' => $usergroup));
foreach ($userIds as $userId) {
$user = $modx->getObject('modUser',$userId->get('member'));
if ($user) {
$user->sendEmail($message, $emailoptions);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment