Hi,

I am working on a modification for a custom module using the default Poll module in the Boonex Dolphin 7.0 platform.

What I need to do is run a function to create a poll with predefined questions and answers. Now the Poll feature is a built in module that comes with the software...

I want to run the function of the Poll module that is used to create polls (createPoll()) from another module in the software. I think I would have to include a core file from the Poll module in order for this function to work.

Here are the details:

- There are 2 modules (Module 1 = LiveStream, Module 2 = Poll)
- In the LiveStream module I want to run the createPoll funtion from the Poll module whenever a particular "Add room" form from the LiveStream is successfully submitted.
- The "Add room" function is located LiveStream module's main file.
- I would like that whenever this form is successfully submitted (*meaning there are no preexisting form in the enter form name) for a new function based on the original createPoll function to automatically create a predefined poll using that function. The LiveStream form function is actionAddroom()


Recap of what 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.


For references here is...

Link LiveStreamModule.php file: https://gist.github.com/3185963

Link BxPollModule.php file: https://gist.github.com/3185975



This is what I have so far for the BxPollModule.php...

Code:
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