We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Expert advice needed? | Forum

Marcus
Marcus Dec 31 '18

Please help me here folks cant make this work.


Use this code to add a question to join page:



$section =  new BOL_QuestionSection();
$section->name = 'test';
$section->sortOrder = BOL_QuestionService::getInstance()->findLastSectionOrder() + 1;

BOL_QuestionService::getInstance()->saveOrUpdateSection($section);

$question = new BOL_Question();
$question->removable = 0;
$question->presentation = BOL_QuestionService::QUESTION_PRESENTATION_SELECT;
$question->type = BOL_QuestionService::QUESTION_VALUE_TYPE_SELECT;
$question->onEdit = 1;
$question->onJoin = 1;
$question->onSearch = 1;
$question->onView = 1;
$question->sectionName = 'test';
$question->name = 'test_place';
$question->sortOrder = 0;

$build = OW::getConfig()->getValue('base', 'soft_build');

if ( $build >= 7157 )
{
    $question->parent = '';
}

BOL_QuestionService::getInstance()->saveOrUpdateQuestion($question);


// -- add location question to all account types
$accountTypeList = BOL_QuestionService::getInstance()->findAllAccountTypes();

$list = array();

foreach( $accountTypeList as $accauntType )
{
    /* @var $accauntType BOL_QuestionAccountType */
    $list[$accauntType->name] = $accauntType->name;
}

BOL_QuestionService::getInstance()->addQuestionListToAccountTypeList(array('test_place'), $list);

// ----------------------------------------------

$sectionLang = BOL_QuestionService::getInstance()->getQuestionLangKeyName(BOL_QuestionService::LANG_KEY_TYPE_QUESTION_SECTION, $section->name);
$questionLang = BOL_QuestionService::getInstance()->getQuestionLangKeyName(BOL_QuestionService::LANG_KEY_TYPE_QUESTION_LABEL, $question->name);
$descriptionLang = BOL_QuestionService::getInstance()->getQuestionLangKeyName(BOL_QuestionService::LANG_KEY_TYPE_QUESTION_DESCRIPTION, $question->name);

$defaultLanguage = BOL_LanguageService::getInstance()->findByTag('en');

if ( !empty($defaultLanguage) )
{
    try
    {
        BOL_LanguageService::getInstance()->addValue($defaultLanguage->id, 'base', $sectionLang, 'Test');
    }
    catch( Exception $ex )
    {

    }

    try
    {
         BOL_LanguageService::getInstance()->addValue($defaultLanguage->id, 'base', $questionLang, 'Test');
    }
    catch( Exception $ex )
    {

    }

    try
    {
         BOL_LanguageService::getInstance()->addValue($defaultLanguage->id, 'base', $descriptionLang, '');
    }
    catch( Exception $ex )
    {

    }
}





if ( !OW::getConfig()->configExists('test_place', 'cache') )
{
    OW::getConfig()->addConfig('test_place', 'cache', '');
}


 install.php


From event_handler.php


Trying to find the question in the list but it doesn't show why?



function questionsFieldInit( OW_Event $event )
    {
        $params = $event->getParams();

}


OW::getEventManager()->bind('base.questions_field_init', array($this, 'questionsFieldInit'));


Why is my question not showing in the parameters list?????

Mark Smith
Mark Smith Feb 7 '19
I can't help you with that. As long as it's looking some kind of hack.
AppXprt
AppXprt Feb 7 '19
Any errors in httpd log or ow_log?


What testing have you done to ensure execution?

Oxwall Germany Club
Oxwall Germany Feb 8 '19
Topic was moved from General Questions.