OK,
Here's my hack to do the following:
1) create checkboxes so that an editor can notify their superior that they have edited an article. This is a little down and dirty & should be a method in the model I suppose. You could then have a config item to say within admin what user groups might be notified.
components/com_flexicontent/views/items/tmpl/form.php, about line 413 add the following:
Code:
<?php
/***ECM get the usertype to use it to determine if to show the notify checkboxes **/
$user =& JFactory::getUser();
$usertype = $user->usertype;
?>
<?php if($usertype =="Editor" || $usertype =="Author") :?>
<fieldset class="flexi-publishers"><legend>Notify a publisher</legend>
<?php
/**ECM get the users who might be notified of content change **/
$db =& JFactory::getDBO();
$sql = "SELECT username FROM #__users WHERE usertype = 'Publisher' OR usertype = 'Manager' OR usertype = 'Administrator' OR usertype = 'Super Administrator'";
$db->setQuery( $sql );
$rows = $db->loadObjectList();
if($rows){
echo('<!--bof reviewers-list--><div id="reviewers-list"><ul>');
foreach($rows as $row) {
$uname = $row->username;
$user = JFactory::getUser($uname);
echo '<li style="display:inline; font-size:smaller;"> <input type="checkbox" name="reviewers" id="reviewers" value="'.$user->email.'" class="required validate-checkbox"> ' .$user->name. ' </li>';
}
echo('</ul></div><!--eof reviewers-list-->');
}
?>
</fieldset>
<?php endif; ?>
You'll also need to add some javascript about line 208. This populates the reviewers
Code:
//get a list of reviewers : ECM
var reviewers = [];
$$('#reviewers-list input[name=reviewers]:checked').each(function(e) { reviewers.push(e.value); });
2) when the item is saved, the selected reviewers are sent an email with a link to the content:
components/com_flexicontent/controller.php
Code:
//ECM
$post['reviewers'] = JRequest::getVar('reviewers');
gets the reviewers, about line 206.
Then within the save function, we add a call to email the reviewers like so:
Code:
$test = $post['reviewers'];
if($test !== null || !empty($test) ){
FlexicontentController::emailPublishers($post['reviewers'],$post['title'], $post['id']);
}
......
/***
* Emails link to new/updated article to recipient Publisher(s)
* @reviewers - recipients of email
* @$title - the title of the article
* @id - the id of the article
*
* @author ECM
*/
function emailPublishers($reviewers, $title, $id){
$mailSender =& JFactory::getMailer();
$recipient = $reviewers;
if(strpos($recipient,";") !== null){
$recipients = explode(";",$recipient);
foreach ($recipients as $recipient){
$mailSender->addRecipient($recipient);
}
}elseif(strpos($recipient,",") !== null){
$recipients = explode(",",$recipient);
foreach ($recipients as $recipient){
$mailSender->addRecipient($recipient);
}
}else{
$mailSender->addRecipient($recipient);
}
$mailSender->setSubject(JText::_('Intranet Content Review') . " " . $title);
$mailbody = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"';
$mailbody .= '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
$mailbody .= '<html><head><title>Intranet Content Review</title></head><body><div>';
$mailbody .= '<strong>' .JText::_('Content Changed:') ."</strong><br />";
$mailbody .= '<strong>' .JText::_('Title:') . "</strong> " .$title. "<br />" .JText::_('Article Id') ."" .$id ."<br /> ";
$link = JURI::base();
$stub = "index.php?option=com_flexicontent&view=items&id=" . $id;
$mailbody .= "<a href='$link$stub'>".JText::_('Click Here to Edit/Approve these changes')."<br />";
$mailbody .="You may have to log in to see the proposed changes.";
$mailbody .="</div></body></html>";
$mailSender->setBody($mailbody);
$mailSender->IsHTML(true);
//get the from address for SMTP
$mail_from = JApplication::getCfg('mailfrom');
$from_name = JApplication::getCfg('fromname');
if(JMailHelper::isEmailAddress($mail_from) === true){
$from_address = array( $mail_from, $from_name );
$mailSender->setSender( $from_address );
}
if (!$mailSender->Send())
{
JError::raiseWarning(500,JText::_('EMAIL_ERROR'));
}
}
That's about it. Its been tested & works but you're experience may differ!
My aim was to enable Publishers to review edits from the front end but couldn't get that to work. Instead, we've decided to have Managers review content changes from within admin.
Regards,