Hi,
I recently posted a similar topic, but Ive made some progress so I have updated this to the appropriate category.
So, I have a new module (LiveStream) that I would like to use the existing Poll module to automatically create a new poll.
I need to accomplished two things:
1) Create a new poll when the "Add room" form is submitted.
- I have a simple "if" statement that will only run if the LiveStream modules Add form is successfully submitted. If the form successfully submits the statement will run a custom function from the BxPollModule.php file ("autocreatepoll"). *This custom function is the same as the original createpoll function that is found in that file at line 2062, but Im working on modifications to create the predefine question and answers. The function is explained in # 2...
2) Give the newly created poll a predefined question and answers.
- I created a custom function call autocreatepoll, which is based on the original createpoll function of the BxPollModule.php file.
For the modifications, I want to create a predefined question and answers for the new poll whenever the form is successfully submitted. This is what I have so far...
function autocreatePoll($sPollQuestion, $sPollAnswers, $iCommentGroupValue, $iVoteGroupValue, $sCategory, $iViewGroupValue)
{
// Predefined function arguments
$sPollQuestion = 'How would you rate this?';
$sPollAnswers = array (1, 2, 3, 4, 5); // For standard rating from 1 to 5
$iCommentGroupValue = 3;
$iVoteGroupValue = 3;
$sCategory = 'Videos';
$iViewGroupValue = 3;
// Everything below is unchanged
// check membership;
if(!$this -> isPollCreateAlowed($this -> aPollSettings['member_id'], true) ) {
return;
}
// ** init some needed variables ;
$aPoolInfo = array();
if ( !$sPollQuestion or !$sPollAnswers ) {
$this -> sActionAnswer = MsgBox(POLL_EMPTY_FIELDS);
}
else {
$aPoolInfo = array
(
'owner_id' => $this -> aPollSettings['member_id'],
'question' => $sPollQuestion,
'answers' => $sPollAnswers,
'results' => $sPollResults,
'tags' => $sTags,
'allow_comment' => $iCommentGroupValue,
'allow_vote' => $iVoteGroupValue,
'category' => $sCategory,
'allow_view' => $iViewGroupValue
);
$iResponse = $this -> _oDb -> createPoll($aPoolInfo, $this -> aPollSettings['admin_mode']);
$iLastPoll = $this -> _oDb -> lastId();
// define the action number ;
switch($iResponse) {
case '0':
$this -> sActionAnswer = MsgBox(POLL_NOT_ALLOW);
break;
case '1' :
$this -> sActionAnswer = MsgBox(POLL_CREATED);
// create system event
$oZ = new BxDolAlerts('bx_poll', 'add', $iLastPoll);
$oZ->alert();
$oTag = new BxDolTags();
$oTag -> reparseObjTags('bx_poll', $iLastPoll);
$oCateg = new BxDolCategories();
$oCateg->reparseObjTags('bx_poll', $iLastPoll);
break;
case '2' :
$this -> sActionAnswer = MsgBox(POLL_MAX_REACHED);
break;
}
}
}
Can someone more experienced with Dolphin modules please help me. Thanks a lot