i've already tryied with the onUserLogout (i'm on 2.5) event with enqueueMessage(),JError::raiseWarning both no luck at all, user logged out but no message showed
instead using Jerror::raiseError the message is showed but the user is not logged out
Does it have to be a personalized message or can it be general? I realize that since the app->logout probably wipes the session it forgets any enqueued messages and resets the application. You could try to redirect the user to a generic "You were logged out because of this" page.
kl. 07:01:35 UTC+2 søndag 29. juli 2012 skrev alikon følgende:
> i've already tryied with the onUserLogout (i'm on 2.5) event > with enqueueMessage(),JError::raiseWarning
> both no luck at all, user logged out but no message showed
> instead using Jerror::raiseError the message is showed but the user is > not logged out
your solution could be acceptable (Do you mean to redirect to an article ?) even if need some extra work on extension configuration, it needs another parameter the article id it was better something like this: $app->logout('loggedout for reason: '.$reason)
I agree with TDZWeb. The plugin method is the best solution; you just need to make it work. Bear in mind that the plugins must return success or the logout sequence will fail. In fact, the entire plugin chain must succeed for the login/logout to be successful. Is your plugin event handler returning a success value? To test this, just disable your plugin and see if you can logout again.
I think $app->enqueMessage only displays when followed by a redirect, e.g., $app->redirect(url, msg)
El sábado, 28 de julio de 2012 02:04:33 UTC-4, alikon escribió:
I was thinking about this problem and I had an idea along the lines of TDZWeb. Instead of logging the user out and redirecting them to a content page or other generic page, maybe you can redirect the user to another page for further processing. For example, look at this code:
After the application logs the user out and the page reloads, the message queue gets wiped out. So, how about instead set an extra variable in your redirect. Use this extra variable to determine the message you want to display to the end user. Then in your view.html.php file for the mymessagequeue view, add some code like this:
$myvar = JRequest::getInt('myvar'); switch($myvar){ case 1: $mymessage = "MESSAGE 1"; break; case 2: $mymessage = "MESSAGE 2"; break; case 3: $mymessage = "MESSAGE 3"; break;
Here the user is redirected twice after logout. The first time the user is redirected the application's message queue and user session are cleared out. The second time the user is redirected, a message is set for the guest user and the message queue should retain it.
I don't think you would need a custom component. You could try to redirect to an article with:
$app->logout();
$app->redirect(JRoute::_('index.php?option=com_content&view=article&id=ARTI CLE ID'));
I sometimes make an 'invisible' system menu (not assigned to any module) with individual articles (often in a category I call 'System') that I use for similar purposes, ie. display system messages. That way you can get prettier/more sensible urls and breadcrumbs.
If you want to have a conditional message you must do something to bridge the logout. It seems to me that subtextproductions 's suggestion is the easiest way to do that. Maybe its time to do the component tutorial? It should have everything you need :)
http://docs.joomla.org/Developing_a_Model-View-Controller_(MVC)_Compo...
kl. 07:26:29 UTC+2 torsdag 2. august 2012 skrev alikon følgende:
If you had a system plugin you could concievably use it to detect
request URL params for yourself and set the message in the guest
session after the logout however you're perhaps in a worse situation
than if you had a component because it'll add a load to every page
load in the site. The component is perhaps the best way with the
architecture we have right now.
On Thu, Aug 2, 2012 at 3:03 AM, TDZWeb <webmas...@tdzwebdesign.no> wrote:
> I don't think you would need a custom component. You could try to redirect
> to an article with:
> $app->logout();
> $app->redirect(JRoute::_('index.php?option=com_content&view=article&id=ARTI CLE
> ID'));
> I sometimes make an 'invisible' system menu (not assigned to any module)
> with individual articles (often in a category I call 'System') that I use
> for similar purposes, ie. display system messages. That way you can get
> prettier/more sensible urls and breadcrumbs.
> If you want to have a conditional message you must do something to bridge
> the logout. It seems to me that subtextproductions 's suggestion is the
> easiest way to do that. Maybe its time to do the component tutorial? It
> should have everything you need :)
> http://docs.joomla.org/Developing_a_Model-View-Controller_(MVC)_Compo...
> kl. 07:26:29 UTC+2 torsdag 2. august 2012 skrev alikon følgende:
> To post to this group, send an email to joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
1. use an article (com_content) for redirect the message 2. use a component (com_custom) for redirect the message 3. detect request URL params for yourself and set the message in the guest session after the logout
the first need some webmaster work could be not suitable for a good extension
the second seems more userfriedly for the end user, more work for developer
the third is the most interesting for me cause i don't know how to code it, can you help me explaining a bit more this
The logic still holds true even if you aren't using a component. You can use a plugin to accomplish the exact same goal. The point is that you have to redirect twice. The first time you redirect, all session information is destroyed, so you can't count on any information stored by the User. You need to pass a variable through the URL, that's how information gets passed from page to page when you don't have sessions to fall back on. Then, you need a second script to process the variable you set in the URL. By the way, logout always looks for a variable named "return" in the global $_REQUEST, and expects it to be a base64 encoded URL. If you use this, you don't even have to handle the initial redirect, it will just happen automatically.
For example, at some point in your code, for whatever reason you have decided to logout the user. This is what your code should look like for the actual logout:
// SET THE RETURN VARIABLE IN GLOBAL REQUEST BEFORE YOU LOG OUT THE USER JRequest::setVar('return', base64_encode('index.php?special_condition='.$x)); $app->logout();
After the logout is fired, the system will automatically redirect the user to the URL specified by 'return' in the $_REQUEST. Now, instead of a User plugin, this should be a system plugin, because it will fire every time the page is loaded. We are going to use the onAfterInitialise event because it will give us everything we need but it will take place before any page rendering:
function onAfterInitialise(){ $some_condition = JRequest::getInt('special_condition', 0, 'GET'); switch($some_condition){ case 1: $message = "MESSAGE 1"; break; case 2: $message = "MESSAGE 2"; break; case 3: $message = "MESSAGE 3"; break; default: // DO NOTHING BECAUSE THE SPECIAL CONDITION ISN'T SET return true; } // IF THE MESSAGE WAS SET, REDIRECT AND APPEND THE MESSAGE $app = JFactory::getApplication(); $app->redirect('index.php', $message);
"By the way, logout always looks for a variable named "return" in the global $_REQUEST, and expects it to be a base64 encoded URL. If you use this, you don't even have to handle the initial redirect, it will just happen automatically. "
This is very useful. I can see making a custom logout plugin myself. Brillant and thx :)
kl. 21:40:15 UTC+2 torsdag 2. august 2012 skrev subtextproductions følgende:
> The logic still holds true even if you aren't using a component. You can > use a plugin to accomplish the exact same goal. The point is that you have > to redirect twice. The first time you redirect, all session information is > destroyed, so you can't count on any information stored by the User. You > need to pass a variable through the URL, that's how information gets passed > from page to page when you don't have sessions to fall back on. Then, you > need a second script to process the variable you set in the URL. By the > way, logout always looks for a variable named "return" in the global > $_REQUEST, and expects it to be a base64 encoded URL. If you use this, you > don't even have to handle the initial redirect, it will just happen > automatically.
> For example, at some point in your code, for whatever reason you have > decided to logout the user. This is what your code should look like for the > actual logout:
> // SET THE RETURN VARIABLE IN GLOBAL REQUEST BEFORE YOU LOG OUT THE USER
> JRequest::setVar('return', > base64_encode('index.php?special_condition='.$x));
> $app->logout();
> After the logout is fired, the system will automatically redirect the user > to the URL specified by 'return' in the $_REQUEST. Now, instead of a User > plugin, this should be a system plugin, because it will fire every time the > page is loaded. We are going to use the onAfterInitialise event because it > will give us everything we need but it will take place before any page > rendering:
> function onAfterInitialise(){
> $some_condition = JRequest::getInt('special_condition', 0, 'GET');
> switch($some_condition){
> case 1:
> $message = "MESSAGE 1";
> break;
> case 2:
> $message = "MESSAGE 2";
> break;
> case 3:
> $message = "MESSAGE 3";
> break;
> default:
> // DO NOTHING BECAUSE THE SPECIAL CONDITION ISN'T SET
> return true;
> }
> // IF THE MESSAGE WAS SET, REDIRECT AND APPEND THE MESSAGE
> $app = JFactory::getApplication();
> $app->redirect('index.php', $message);
> }