cognidox / OTRS-Joomla-Gateway

Provides seamless access to OTRS tickets through Joomla
https://www.cognidox.com/
10 stars 3 forks source link

Reply ticket ajax form does not close when clicking on "Submit" #24

Closed OpenNingia closed 12 years ago

OpenNingia commented 13 years ago

How to reproduce:

What should happen: The squeezebox should close and the ticket reply submitted

What happens instead: The ticket is indeed submitted but the squeezebox is not closed ( you have to close it manually )

Early diagnosys: I see that in the onSuccess callback upon the form.send() method you check some json. However in my case the returned value is not a Json but an XHTML page, that raises an exception and the code stop there ( thus not closing the squeezebox )

vittala commented 13 years ago

Hi

Can you provide the content of the XHTML return that you're seeing from the reply submission.

Regards Vittal

OpenNingia commented 13 years ago

Yes I can :)

here: http://pastebin.com/b6d7HLjh

It looks like the home page of my joomla setup.

this generate an error here: $('otrsReplyForm').send({ onSuccess: function(resp) { console.log(resp);
var obj = Json.evaluate(resp); <<<---- EXCEPTION HERE parent.closeReply(obj.error,document.forms['otrsReplyForm'].elements['formtoken'].value); }, onFailure: function(resp){ alert("<?php echo JText::_('OTRS_ALERT_SUBMISSION_FAILED');?>"); parent.closeReply(null,document.forms['otrsReplyForm'].elements['formtoken'].value);} });

vittala commented 13 years ago

Hi

I suspect what we have here is an interaction in the Javascript causing problems, possibly with one of the modules or plugins you're using on the page. Some things to try:

Regards Vittal

OpenNingia commented 13 years ago

Hi,

thanks for the feedback. I can reproduce this issue on IE7, Firefox 8 and Chrome 17

disabling the JCE MediaBox didn't help

using the Chrome Javascript debugger I see some Errors:

regards,

Daniele

vittala commented 13 years ago

Hi

The 'unsafe header "Connection"' is a mootools problem, but should only be a warning, so probably not the source of this problem. Getting a web page back rather the json is something to check now.

Using Chrome's network debugger, let me know what is shown in the POST request Headers generated when you reply to the ticket. At the same time, check the error logs for the Joomla and OTRS servers, and the OTRS error log itself.

Regards Vittal

OpenNingia commented 13 years ago

Here:

Request Method:POST
Status Code:301 Moved Permanently
Request Headersview source
Accept:text/javascript, text/html, application/xml, text/xml, _/_
Accept-Charset:UTF-8,*;q=0.5
Accept-Encoding:gzip,deflate,sdch
Accept-Language:it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Content-Length:206
Content-type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:c3abe897e96fe479d41216021c49822a=014r6gjqhs6hdidmpljk0t3is1; 4f46b3a5af976d95e1faf41b40261d24=3487476e1733c6e4d31e76ee8a23f453
Host:flrsvspotsdktest.flr.gilbarco.com
Origin:http://flrsvspotsdktest.flr.gilbarco.com
Referer:http://flrsvspotsdktest.flr.gilbarco.com/joomla/index.php?option=com_otrsgateway&task=replyForm&ticketID=19
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.8 (KHTML, like Gecko) Chrome/17.0.942.0 Safari/535.8
X-Requested-With:XMLHttpRequest
Form Dataview URL encoded
ticketID:19
option:com_otrsgateway
task:reply
view:ticket
format:raw
formtoken:1e8c791eab2d1d56665894b4b5864a18
41f29b3c6a8ad08cb41e1a9c6257ff4a:1
priorityID:2
StateID:4
replyText:<p>HOORAY!!!</p>
Response Headersview source
Connection:close
Content-Length:0
Content-Type:text/html; charset=UTF-8
Date:Wed, 30 Nov 2011 11:13:04 GMT
Location:http://flrsvspotsdktest.flr.gilbarco.com/joomla/index.php?option=com_content&view=frontpage&Itemid=1
P3P:CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Server:Apache/2.2.3 (CentOS)
X-Powered-By:PHP/5.1.6

The status code has a strange value

vittala commented 13 years ago

Hi

The return message is a redirect to the homepage rather than the JSON that should be returned. Clearly, the com_otrsgateway module is processing the request (as the data's going into OTRS), but something on your site is hijacking the return data.

Do you have any apache rewrites in use or are you using any SEF components?

Regards Vittal

OpenNingia commented 13 years ago

I've disabled all SEF plugins without success, I'm currently investigate on whenever apache ( or another reverse proxy ) is involved. I'll advise you if this is the case.

vittala commented 13 years ago

I wonder if you're seeing this Joomla issue http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=26889 (although this is for J1.7.1).

Regards Vittal

OpenNingia commented 13 years ago

Maybe but there is somethings that bugs me:

vittala commented 13 years ago

I think this bug was about the language switcher module, as opposed to a specific installed language.

The 301 can either be produced by the webserver, or it can be produced by a Joomla plugin/module modifying the routing of results. Difficult to see what's going on without knowing the exact configuration of Joomla/apache/modules/components/plugins that you're running.

Unfortunately, I suspect the only way to narrow this down is to temporarily disable any extensions to try and see if there's a collision with a specific thing.

Regards Vittal

OpenNingia commented 13 years ago

I have a suspect! Would you try on your system with the "System - Alternate Home" plugin? We don't display our home page until the user is logged so we use that plugin to redirect the user to the home page upon login.

vittala commented 13 years ago

Alternative Home isn't a default Joomla plugin - can you let me know the software publisher and the version you're using - this should be shown on the Extension Manager -> Plugins page.

Regards Vittal

vittala commented 12 years ago

Hi

Try the following to deal with this issue. Edit the two files:

components/com_otrsgateway/views/attachment/view.raw.php
components/com_otrsgateway/views/ticket/view.raw.php

adding "jexit();" after the "parent::display( $tpl );" line:

parent::display( $tpl );
jexit();

Regards Vittal

OpenNingia commented 12 years ago

Hi, sorry for the late :)

we've made a step forward, however now I got a different issue. Look at this image:

http://imm.io/cQ9h

vittala commented 12 years ago

Hi

I think you're running into this PHP bug https://bugs.php.net/bug.php?id=43533

The solution should be to edit components/com_otrsgateway/views/attachment/tmpl/add.php, changing:

 parent.addAttachment( <?php echo escapeshellarg($this->result['error']); ?>,
                       <?php echo escapeshellarg($this->result['id']); ?>,
                       <?php echo escapeshellarg($this->result['name']); ?> );

to:

 parent.addAttachment( <?php echo ($this->result['error'] ? escapeshellarg($this->result['error']) : '""'); ?>,
                       <?php echo ($this->result['id'] ? escapeshellarg($this->result['id']) : '""'); ?>,
                       <?php echo ($this->result['name'] ? escapeshellarg($this->result['name']) : '""'); ?> );

Doing so will ensure the result Javascript parses regardless of the PHP version you're using.

Regards Vittal

vittala commented 12 years ago

Hi

I've just released version 0.9.2 of the component, which should resolve all the issues you've had on this issue. I'll close the issue, feel free to re-open if they're not dealt with.

Regards Vittal