Show latest unapproved verion on front end

More
12 years 11 months ago #15695 by freshwebservices
Hi,
I have a situation where frontend Editors can edit content but only frontend Publishers are allowed to approve content.

I've written a little hack that allows an editor to send a notification email to a chosen Publisher when they save content.

However, when the Publisher views the content they are seeing the last approved version rather than the very latest/unapproved version.

Is there a way that I can construct the url in the Publisher's notification email that will load the latest version (possibly already loaded in the (JCE) editor)?

My code to build the url is as follows:
Code:
$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.";

Thanks,
Ps - I need this working asap!

www.freshwebservices.com -> Leicester web design

Please Log in or Create an account to join the conversation.

More
12 years 11 months ago #15698 by micker
great information !
could share this system after finished ?
try to contact
flexicontent.org/forum/index.php ... memberlist
or
flexicontent.org/forum/index.php ... memberlist
to help you regards

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

More
12 years 11 months ago #15700 by freshwebservices
Hi micker,
Yes, I'll post my hack when/if I can get it to work properly.

However, its not really following best practices - I'm sure it could be abstracted & made more extensible/flexible, etc.

Regards,

www.freshwebservices.com -> Leicester web design

Please Log in or Create an account to join the conversation.

More
12 years 11 months ago #15701 by micker
this feature was realy appreciead !
thanks for your works

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

More
12 years 11 months ago #15802 by freshwebservices
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">&nbsp;' .$user->name. '&nbsp;</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,

www.freshwebservices.com -> Leicester web design

Please Log in or Create an account to join the conversation.

More
12 years 11 months ago #15805 by micker
great i send this to manu !

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.295 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline