Firefox PHP

Servey mod for 5.1.x - need help with development

Posted by M@AATW 
All files from this thread

File Name File Size   Posted by Date  
survey.zip 4.1 KB open | download M@AATW 02/10/2006 Read message
survey.php 8.2 KB open | download jgarbers 04/17/2006 Read message
survey.php 8.5 KB open | download M@AATW 04/18/2006 Read message
Servey mod for 5.1.x - need help with development
February 10, 2006 07:24AM
Trying to develop this old mod so that it's compatable for 5.1.x and future versions of Phorum.

I changed PHORUM_POST to PHORUM_POSTING in 'servey.php' to get it working, as per the 'Poll module' = [www.phorum.org]
and the basis of itis now compatable with 5.1.x

But I encountered a problem: when someone attempts to answer the Servey questions, the page displays:

Missing parameter "mode" in request

after clicking the submit button.

I've attached the reworked version so far. Can someone else try to take a look?
Attachments:
open | download - survey.zip (4.1 KB)
Re: Servey mod for 5.1.x - need help with development
February 13, 2006 09:12AM
Still no luck whatsoever with this so far. Has anyone tried it? Have any ideas?

Thanks
Re: Servey mod for 5.1.x - need help with development
February 14, 2006 12:42PM
The fix is on the last post of the poll module thread.

Please, do not start new threads for topics that already exist.

--
Amilcar Lucas
www.kdevelop.org webmaster
Re: Servey mod for 5.1.x - need help with development
February 14, 2006 02:42PM
No it's not.

I think I know where the fix for the poll mod is, because it was me that fixed it.

This is something different, it's the servey mod redone to work with 5.1.x, - as I said, it now almost works, but I need a little help with it. The fix that worked for the poll mod alone will not make this one work, thus the new topic on it, complete with the file that I've adapted so far.



Edited 1 time(s). Last edit at 02/14/2006 02:44PM by M@AATW.
Re: Servey mod for 5.1.x - need help with development
February 14, 2006 04:51PM
he's right, posting surveys is possible by the POSTING_URL fix
but answering to them is impossible due to the new posting system which wants a "mode" input and a submit button named finish ..and others things that i havent found yet cos' i cant get it to work ...



Edited 1 time(s). Last edit at 02/14/2006 04:52PM by philop.
Re: Servey mod for 5.1.x - need help with development
February 15, 2006 04:59AM
I beleive this is the area that needs to be looked at - this is the bit that happens AFTER a new servey has been posted. The problem comes when someone tries to REPLY to a servey. It doesn't seem to insert the data into a new reply message.

I think this the bit of code in 'servey.php' which handles this:

===================================================

// We get here when someone submits a survey
// Input: $_POST["message_id"], $_POST["surveyans"]
// hook: pre_post
function mod_survey_receive_survey($message) {
GLOBAL $PHORUM;

if(isset($_POST['surveyans'])) {
// get the survey info
$survey_id = $message["thread"];
$survey_message=phorum_db_get_message($survey_id);

if (is_array($survey_message["meta"]["mod_survey"]["questions"])) {
$pre_q = isset($PHORUM["mod_survey"]["pre_question"]) ? $PHORUM["mod_survey"]["pre_question"] : MOD_SURVEY_PRE_QUESTION_DEFAULT;
$post_q = isset($PHORUM["mod_survey"]["post_question"]) ? $PHORUM["mod_survey"]["post_question"] : MOD_SURVEY_POST_QUESTION_DEFAULT;
$pre_a = isset($PHORUM["mod_survey"]["pre_answer"]) ? $PHORUM["mod_survey"]["pre_answer"] : MOD_SURVEY_PRE_ANSWER_DEFAULT;
$post_a = isset($PHORUM["mod_survey"]["post_answer"]) ? $PHORUM["mod_survey"]["post_answer"] : MOD_SURVEY_POST_ANSWER_DEFAULT;
$no_answer_txt = isset($PHORUM["mod_survey"]["no_answer_txt"]) ? $PHORUM["mod_survey"]["no_answer_txt"] : "(no answer)";
foreach ($survey_message["meta"]["mod_survey"]["questions"] AS $qkey => $qval) {
if ($_POST['surveyans'][$qkey]=='') {
$_POST['surveyans'][$qkey] = $no_answer_txt;
}
// undo the htmlspecialchars for the question, since it's going
// to be applied again when phorum posts
$qval = str_replace('&', '&', $qval);
$qval = str_replace('"', '"', $qval);
$qval = str_replace(''', "'", $qval);
$qval = str_replace('&lt;', '<', $qval);
$qval = str_replace('&gt;', '>', $qval);

$newbody .= "$pre_q$qval$post_q\n\n" . $pre_a . $_POST['surveyans'][$qkey] . "$post_a\n\n";
}
if ($_POST["extrabody"]) {
$message[body] = $_POST["extrabody"];
}
$message[body] = $newbody . $message[body];
}
else {
// the user tried to answer the survey while previewing the survey...
phorum_redirect_by_url($PHORUM['DATA']['NEWSURVEYURL']);
exit;
}
}
return $message;
}

=====================================================================
Re: Servey mod for 5.1.x - need help with development
March 12, 2006 02:02PM
I now believe this has to do with a missing statement:


$mode = "reply";

but I'm not sure where this should go, or indeed if I'm right...can someone with more knowledge please help out!

Would it be possible to copy the 'submit' button code from posting_messageform.tpl into this script to get it to work?



Edited 1 time(s). Last edit at 03/12/2006 02:04PM by M@AATW.
Re: Servey mod for 5.1.x - need help with development
April 06, 2006 10:42AM
Bump...I see there's a few people working on the Poll module now. Any help with this one please!!?!?!
Re: Servey mod for 5.1.x - need help with development
April 17, 2006 05:23PM
I've been trying to figure this one out too, and reached about the same place you guys have. I got my variant of survey.php using the PHORUM_POSTING_URL as well, and set a hidden "mode" field in the form to try to get mode=post to make posting.php happy, but no luck beyond that. I know nothing of Phorum internals, but it appears that the pre_post callback in the survey module isn't getting called... presumably because it isn't posting the way that posting.php wants it. I'll post here if I get anywhere...
Re: Servey mod for 5.1.x - need help with development
April 17, 2006 06:07PM
Okay, I think I have something working, but caveat emptor... here's a survey.php that APPEARS to have what it takes to work with 5.1.x. Other than changing to PHORUM_POSTING_URL, the key differences are in the hidden posted fields used when posting a survey response:

- hidden field "mode" gets passed as "reply"
- hidden field "finish" gets passed as "Y" (or anything nonblank as far as I can tell)
- hidden field "message_id" needs to be 0, or the new logic treats it as an edit rather than a reply

Let me know if these changes -- or variants thereon -- work for you folks, or at least get you past a speed bump or two.
Attachments:
open | download - survey.php (8.2 KB)
Sorry, only registered users may post in this forum.

Click here to login