Esempio n. 1
0
 public function ajaxResponder()
 {
     if (!OW::getAuthorization()->isUserAuthorized(OW::getUser()->getId(), 'admin') || empty($_POST["command"]) || !OW::getRequest()->isAjax()) {
         throw new Redirect404Exception();
     }
     $command = (string) $_POST["command"];
     switch ($command) {
         case 'deleteQuestion':
             $questionId = (int) $_POST['questionId'];
             $question = $this->questionService->findQuestionById($questionId);
             if (empty($question)) {
                 echo json_encode(array('result' => false));
                 exit;
             }
             $parent = null;
             if (!empty($question->parent)) {
                 $parent = $this->questionService->findQuestionByName($question->parent);
             }
             if ($question->base == 1 || !$question->removable || !empty($parent)) {
                 echo json_encode(array('result' => false));
                 exit;
             }
             $childList = $this->questionService->findQuestionChildren($question->name);
             $deleteList = array();
             $deleteQuestionNameList = array();
             foreach ($childList as $child) {
                 $deleteList[] = $child->id;
                 $deleteQuestionNameList[$child->name] = $child->name;
             }
             if (!empty($deleteList)) {
                 $this->questionService->deleteQuestion($deleteList);
             }
             if ($this->questionService->deleteQuestion(array((int) $_POST['questionId']))) {
                 echo json_encode(array('result' => "success", 'message' => OW::getLanguage()->text('admin', 'questions_question_was_deleted'), 'deleteList' => $deleteQuestionNameList));
                 exit;
             }
             echo json_encode(array('result' => false));
             exit;
             break;
         case 'findNearestSection':
             $sectionName = $_POST['sectionName'];
             if (!empty($sectionName)) {
                 $section = $this->questionService->findSectionBySectionName($sectionName);
                 if (empty($section)) {
                     echo json_encode(array('result' => false));
                     exit;
                 }
                 $nearSection = $this->questionService->findNearestSection($section);
                 if (empty($nearSection)) {
                     echo json_encode(array('result' => false));
                     exit;
                 }
                 echo json_encode(array('result' => "success", 'message' => OW::getLanguage()->text('admin', 'questions_delete_section_confirmation_with_move_questions', array('sectionName' => BOL_QuestionService::getInstance()->getSectionLang($nearSection->name)))));
                 exit;
             }
             echo json_encode(array('result' => false));
             exit;
             break;
         case 'deleteSection':
             if (!empty($_POST['sectionName']) && mb_strlen($_POST['sectionName']) > 0) {
                 /*@var $nearSection BOL_QuestionSection*/
                 $nearSection = $this->questionService->findSectionBySectionName($_POST['sectionName']);
                 $moveQuestionsToSection = null;
                 if (!empty($nearSection) && $nearSection->isDeletable && $this->questionService->deleteSection(htmlspecialchars($_POST['sectionName']), $moveQuestionsToSection)) {
                     $result = array('result' => "success", 'message' => OW::getLanguage()->text('admin', 'questions_section_was_deleted'));
                     if (!empty($moveQuestionsToSection)) {
                         $result['moveTo'] = $moveQuestionsToSection->name;
                     }
                     echo json_encode($result);
                     exit;
                 }
             }
             echo json_encode(array('result' => "false"));
             exit;
             break;
         case 'DeleteQuestionValue':
             $result = false;
             $questionId = htmlspecialchars($_POST["questionId"]);
             $question = $this->questionService->findQuestionById($questionId);
             $value = (int) $_POST["value"];
             if (empty($question) || empty($value) && $value !== 0) {
                 echo json_encode(array('result' => $result));
                 return;
             }
             if ($this->questionService->deleteQuestionValue($question->name, $value)) {
                 $result = true;
             }
             echo json_encode(array('result' => $result));
             break;
         case 'deleteAccountType':
             if (!empty($_POST['accountType']) && mb_strlen($_POST['accountType']) > 0) {
                 $accountTypes = $this->questionService->findAllAccountTypes();
                 $accountTypeList = array();
                 foreach ($accountTypes as $key => $account) {
                     if ($account->name != $_POST['accountType']) {
                         $accountTypeList[$account->name] = $account->name;
                     }
                 }
                 if (empty($accountTypeList)) {
                     echo json_encode(array('result' => "false", 'message' => OW::getLanguage()->text('admin', 'questions_cant_delete_last_account_type')));
                     exit;
                 } else {
                     if ($this->questionService->deleteAccountType($_POST['accountType'])) {
                         echo json_encode(array('result' => "success", 'message' => OW::getLanguage()->text('admin', 'questions_account_type_was_deleted')));
                         exit;
                     }
                 }
             }
             echo json_encode(array('result' => "false"));
             exit;
             break;
         case 'AddQuestionValues':
             $result = false;
             $questionId = (int) $_POST["questionId"];
             $question = $this->questionService->findQuestionById($questionId);
             $values = !empty($_POST["values"]) && is_array($_POST["values"]) ? $_POST["values"] : array();
             if (empty($question) || empty($values)) {
                 echo json_encode(array('result' => $result));
                 return;
             }
             if ($this->questionService->updateQuestionValues($question, $values)) {
                 $result = true;
             }
             echo json_encode(array('result' => $result));
             break;
         case 'AddAccountType':
             $result = false;
             $name = htmlspecialchars($_POST["accountTypeName"]);
             $roleId = (int) $_POST["role"];
             $accountType = new BOL_QuestionAccountType();
             $accountType->name = $name;
             $accountType->roleId = $roleId;
             $form = new ADMIN_CLASS_AddAccountTypeForm($accountType);
             $result = false;
             if ($form->isValid($_POST)) {
                 $result = $form->process($_POST);
             }
             echo json_encode(array('result' => $result, 'accountTypeName' => $name, 'roleId' => $roleId));
             break;
         case 'sortAccountType':
             $sortAccountType = json_decode($_POST['accountTypeList'], true);
             $result = false;
             if (isset($sortAccountType) && is_array($sortAccountType) && count($sortAccountType) > 0) {
                 $result = $this->questionService->reOrderAccountType($sortAccountType);
             }
             echo json_encode(array('result' => $result));
             break;
         case 'sortQuestions':
             $sectionName = htmlspecialchars($_POST['sectionName']);
             $sectionQuestionOrder = json_decode($_POST['questionOrder'], true);
             $check = true;
             if (!isset($sectionName)) {
                 $check = false;
             }
             if (!isset($sectionQuestionOrder) || !is_array($sectionQuestionOrder) || !count($sectionQuestionOrder) > 0) {
                 $check = false;
             }
             if ($sectionName === 'no_section') {
                 $sectionName = null;
             }
             $result = false;
             if ($check) {
                 $result = $this->questionService->reOrderQuestion($sectionName, $sectionQuestionOrder);
             }
             echo json_encode(array('result' => $result));
             break;
         case 'sortSection':
             $sectionOrder = json_decode($_POST['sectionOrder'], true);
             if (!isset($sectionOrder) || !is_array($sectionOrder) || !count($sectionOrder) > 0) {
                 return false;
             }
             $result = $this->questionService->reOrderSection($sectionOrder);
             echo json_encode(array('result' => $result));
             break;
         case 'questionPages':
             $question = $_POST['question'];
             $required = $_POST['required'] == 'true';
             $onJoin = $_POST['onJoin'] == 'true';
             $onEdit = $_POST['onEdit'] == 'true';
             $onView = $_POST['onView'] == 'true';
             $onSearch = $_POST['onSearch'] == 'true';
             $changed = !empty($_POST['changed']) ? $_POST['changed'] : null;
             if (empty($question)) {
                 echo json_encode(array('result' => false));
                 exit;
             }
             $questionDto = $this->questionService->findQuestionByName($question);
             if (!empty($questionDto)) {
                 $disableActionList = BOL_QuestionService::getInstance()->getQuestionDisableActionList($questionDto);
                 switch ($changed) {
                     case 'required':
                         if (!$disableActionList['disable_required']) {
                             $questionDto->required = $required;
                         }
                         break;
                     case 'onJoin':
                         if (!$disableActionList['disable_on_join']) {
                             $questionDto->onJoin = $onJoin;
                         }
                         break;
                     case 'onEdit':
                         if (!$disableActionList['disable_on_edit']) {
                             $questionDto->onEdit = $onEdit;
                         }
                         break;
                     case 'onSearch':
                         if (!$disableActionList['disable_on_search']) {
                             $questionDto->onSearch = $onSearch;
                         }
                         break;
                     case 'onView':
                         if (!$disableActionList['disable_on_view']) {
                             $questionDto->onView = $onView;
                         }
                         break;
                     default:
                         if (!$disableActionList['disable_required']) {
                             $questionDto->required = $required;
                         }
                         if (!$disableActionList['disable_on_join']) {
                             $questionDto->onJoin = $onJoin;
                         }
                         if (!$disableActionList['disable_on_edit']) {
                             $questionDto->onEdit = $onEdit;
                         }
                         if (!$disableActionList['disable_on_view']) {
                             $questionDto->onView = $onView;
                         }
                         if (!$disableActionList['disable_on_search']) {
                             $questionDto->onSearch = $onSearch;
                         }
                         break;
                 }
             }
             $this->questionService->saveOrUpdateQuestion($questionDto);
             echo json_encode(json_encode(array('result' => true)));
             break;
         case 'questionAccountTypes':
             $question = $_POST['question'];
             $data = $_POST['data'];
             if (empty($question) || empty($data)) {
                 echo json_encode(array('result' => false));
                 exit;
             }
             $questionDto = $this->questionService->findQuestionByName($question);
             if (!empty($questionDto)) {
                 $disableActionList = BOL_QuestionService::getInstance()->getQuestionDisableActionList($questionDto);
                 if (!$disableActionList['disable_account_type']) {
                     $add = array();
                     $delete = array();
                     foreach ($data as $accountType => $value) {
                         if ($value === "true") {
                             $add[] = $accountType;
                         } else {
                             $delete[] = $accountType;
                         }
                     }
                     if (!empty($delete)) {
                         BOL_QuestionService::getInstance()->deleteQuestionToAccountType($questionDto->name, $delete);
                     }
                     if (!empty($add)) {
                         BOL_QuestionService::getInstance()->addQuestionToAccountType($questionDto->name, $add);
                     }
                 }
             }
             echo json_encode(json_encode(array('result' => true)));
             break;
         case 'addSection':
             if (empty($_POST['section_name'])) {
                 echo json_encode(array('result' => false, 'message' => ''));
                 exit;
             }
             $sectionName = $_POST['section_name'];
             $questionSection = new BOL_QuestionSection();
             $questionSection->name = md5(uniqid());
             $questionSection->sortOrder = $this->questionService->findLastSectionOrder() + 1;
             $this->questionService->saveOrUpdateSection($questionSection);
             BOL_LanguageService::getInstance()->addOrUpdateValue(OW::getLanguage()->getCurrentId(), 'base', 'questions_section_' . $questionSection->name . '_label', htmlspecialchars($sectionName));
             if (OW::getDbo()->getAffectedRows() > 0) {
                 echo json_encode(array('result' => true, 'message' => OW::getLanguage()->text('admin', 'questions_section_was_added')));
             }
             break;
         case 'addQuestion':
             /* @var $form ADMIN_CLASS_AddQuestionForm */
             $form = OW::getClassInstance('ADMIN_CLASS_AddQuestionForm', 'qst_add_form', '');
             $form->process();
             break;
         case 'editQuestion':
             if (empty($_POST['questionId'])) {
                 echo json_encode(array('result' => false, 'errors' => array(), 'message' => OW::getLanguage()->text('admin', 'questions_not_found')));
                 exit;
             }
             $question = BOL_QuestionService::getInstance()->findQuestionById($_POST['questionId']);
             if (empty($question) || !$question instanceof BOL_Question) {
                 echo json_encode(array('result' => false, 'errors' => array(), 'message' => OW::getLanguage()->text('admin', 'questions_not_found')));
                 exit;
             }
             $form = OW::getClassInstance('ADMIN_CLASS_EditQuestionForm', 'qst_edit_form', '');
             $form->loadQuestionData($question);
             $form->process();
             break;
         default:
     }
     exit;
 }
Esempio n. 2
0
 public function edit($params)
 {
     if (!isset($params['questionId'])) {
         throw new Redirect404Exception();
     }
     $questionId = (int) @$params['questionId'];
     if (empty($questionId)) {
         throw new Redirect404Exception();
     }
     $this->addContentMenu();
     $this->contentMenu->getElement('qst_index')->setActive(true);
     $editQuestion = $this->questionService->findQuestionById($questionId);
     $parent = $editQuestion->parent;
     $parentIsset = false;
     if (!empty($parent)) {
         $parentDto = $this->questionService->findQuestionByName($parent);
         $parentIsset = !empty($parentDto) ? true : false;
         if ($parentIsset) {
             $this->assign('parentUrl', OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'edit', array("questionId" => $parentDto->id)));
             $this->assign('parentLabel', $this->questionService->getQuestionLang($parentDto->name));
         }
     }
     $this->assign('parentIsset', $parentIsset);
     if ($editQuestion === null) {
         throw new Redirect404Exception();
     }
     $this->assign('question', $editQuestion);
     //$editQuestionToAccountType = $this->questionService->findAccountTypeByQuestionName( $editQuestion->name );
     // get available account types from DB
     /* @var BOL_QuestionService $this->questionService */
     $accountTypes = $this->questionService->findAllAccountTypes();
     $serviceLang = BOL_LanguageService::getInstance();
     $language = OW::getLanguage();
     $currentLanguageId = OW::getLanguage()->getCurrentId();
     $accounts = array(BOL_QuestionService::ALL_ACCOUNT_TYPES => $language->text('base', 'questions_account_type_all'));
     /* @var $value BOL_QuestionAccount */
     foreach ($accountTypes as $value) {
         $accounts[$value->name] = $language->text('base', 'questions_account_type_' . $value->name);
     }
     $sections = $this->questionService->findAllSections();
     // need to hide sections select box
     if (empty($section)) {
         $this->assign('no_sections', true);
     }
     $sectionsArray = array();
     /* @var $section BOL_QuestionSection */
     foreach ($sections as $section) {
         $sectionsArray[$section->name] = $language->text('base', 'questions_section_' . $section->name . '_label');
     }
     $presentations = array();
     $presentationsLabel = array();
     $presentationList = $this->questionService->getPresentations();
     if ($editQuestion->name != 'password') {
         unset($presentationList[BOL_QuestionService::QUESTION_PRESENTATION_PASSWORD]);
     }
     foreach ($presentationList as $presentationKey => $presentation) {
         if ($presentationList[$editQuestion->presentation] == $presentation) {
             $presentations[$presentationKey] = $presentationKey;
             //TODO add langs with presentation labels
             $presentationsLabel[$presentationKey] = $language->text('base', 'questions_question_presentation_' . $presentationKey . '_label');
         }
     }
     $presentation = $editQuestion->presentation;
     if (OW::getSession()->isKeySet(self::EDIT_QUESTION_SESSION_VAR)) {
         $session = OW::getSession()->get(self::EDIT_QUESTION_SESSION_VAR);
         if (isset($session['qst_answer_type']) && isset($presentations[$session['qst_answer_type']])) {
             $presentation = $presentations[$session['qst_answer_type']];
         }
     }
     if (isset($_POST['qst_answer_type']) && isset($presentations[$_POST['qst_answer_type']])) {
         $presentation = $presentations[$_POST['qst_answer_type']];
     }
     //$this->addForm(new LanguageValueEditForm( 'base', 'questions_question_' . ($editQuestion->id) . '_label', $this ) );
     //--  -------------------------------------
     //--  add question values form creating
     //--  -------------------------------------
     $questionValues = $this->questionService->findQuestionValues($editQuestion->name);
     $this->assign('questionValues', $questionValues);
     //add field values form
     $addQuestionValuesForm = new AddValuesForm($questionId);
     $addQuestionValuesForm->setAction($this->ajaxResponderUrl);
     $this->addForm($addQuestionValuesForm);
     //--  -------------------------------------
     //--  edit field form creating
     //--  -------------------------------------
     $editForm = new Form('qst_edit_form');
     $editForm->setId('qst_edit_form');
     $disableActionList = array('disable_account_type' => false, 'disable_answer_type' => false, 'disable_presentation' => false, 'disable_column_count' => false, 'disable_display_config' => false, 'disable_required' => false, 'disable_on_join' => false, 'disable_on_view' => false, 'disable_on_search' => false, 'disable_on_edit' => false);
     $event = new OW_Event('admin.disable_fields_on_edit_profile_question', array('questionDto' => $editQuestion), $disableActionList);
     OW::getEventManager()->trigger($event);
     $disableActionList = $event->getData();
     if (count($accountTypes) > 1) {
         $qstAccountType = new Selectbox('qst_account_type');
         $qstAccountType->setLabel($language->text('admin', 'questions_for_account_type_label'));
         $qstAccountType->setDescription($language->text('admin', 'questions_for_account_type_description'));
         $qstAccountType->setOptions($accounts);
         $qstAccountType->setValue(BOL_QuestionService::ALL_ACCOUNT_TYPES);
         $qstAccountType->setHasInvitation(false);
         if ($editQuestion->accountTypeName !== null) {
             $qstAccountType->setValue($editQuestion->accountTypeName);
         }
         if ($editQuestion->base == 1) {
             $qstAccountType->addAttribute('disabled', 'disabled');
         } else {
             if ($disableActionList['disable_account_type']) {
                 $qstAnswerType->setRequired(false);
                 $qstAccountType->addAttribute('disabled', 'disabled');
             }
         }
         $editForm->addElement($qstAccountType);
     }
     if (!empty($sectionsArray)) {
         $qstSection = new Selectbox('qst_section');
         $qstSection->setLabel($language->text('admin', 'questions_question_section_label'));
         $qstSection->setOptions($sectionsArray);
         $qstSection->setValue($editQuestion->sectionName);
         $qstSection->setHasInvitation(false);
         $editForm->addElement($qstSection);
     }
     $qstAnswerType = new Selectbox('qst_answer_type');
     $qstAnswerType->setLabel($language->text('admin', 'questions_answer_type_label'));
     $qstAnswerType->addAttribute('class', $qstAnswerType->getName());
     $qstAnswerType->setOptions($presentationsLabel);
     $qstAnswerType->setValue($presentation);
     $qstAnswerType->setRequired();
     $qstAnswerType->setHasInvitation(false);
     if ($parentIsset) {
         $qstAnswerType->setValue($parentDto->columnCount);
         $qstAnswerType->addAttribute('disabled', 'disabled');
     }
     if ((int) $editQuestion->base === 1 || count($presentations) <= 1 || $parentIsset || $disableActionList['disable_answer_type']) {
         $qstAnswerType->setRequired(false);
         $qstAnswerType->addAttribute('disabled', 'disabled');
     }
     $editForm->addElement($qstAnswerType);
     $columnCountPresentation = array(BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX, BOL_QuestionService::QUESTION_PRESENTATION_RADIO);
     if (in_array($presentation, $columnCountPresentation)) {
         $qstColumnCount = new Selectbox('qst_column_count');
         $qstColumnCount->addAttribute('class', $qstColumnCount->getName());
         $qstColumnCount->setLabel($language->text('admin', 'questions_columns_count_label'));
         $qstColumnCount->setRequired();
         $qstColumnCount->setOptions($this->qstColumnCountValues);
         $qstColumnCount->setValue($editQuestion->columnCount);
         $parentIsset = !empty($parentDto) ? true : false;
         if ($parentIsset) {
             $qstColumnCount->setValue($parentDto->columnCount);
             $qstColumnCount->addAttribute('disabled', 'disabled');
             $qstColumnCount->setRequired(false);
         } else {
             if ($disableActionList['disable_column_count']) {
                 $qstAnswerType->setRequired(false);
                 $qstAnswerType->addAttribute('disabled', 'disabled');
             }
         }
         $editForm->addElement($qstColumnCount);
     }
     $presentationConfigList = BOL_QuestionService::getInstance()->getConfigList($presentation);
     $presentationConfigValues = json_decode($editQuestion->custom, true);
     if ($editQuestion->name !== 'joinStamp' && !$disableActionList['disable_display_config']) {
         foreach ($presentationConfigList as $config) {
             $className = $config->presentationClass;
             /* @var $qstConfig OW_FormElement */
             $qstConfig = new $className($config->name);
             $qstConfig->setLabel($language->text('admin', 'questions_config_' . $config->name . '_label'));
             if (!empty($config->description)) {
                 $qstConfig->setDescription($config->description);
             }
             if (isset($presentationConfigValues[$config->name])) {
                 $qstConfig->setValue($presentationConfigValues[$config->name]);
             }
             $editForm->addElement($qstConfig);
         }
     }
     $qstRequired = new CheckboxField('qst_required');
     $qstRequired->setLabel($language->text('admin', 'questions_required_label'));
     $qstRequired->setDescription($language->text('admin', 'questions_required_description'));
     $qstRequired->setValue((bool) $editQuestion->required);
     if ((int) $editQuestion->base === 1 || $disableActionList['disable_required']) {
         $qstRequired->addAttribute('disabled', 'disabled');
     }
     $editForm->addElement($qstRequired);
     $qstOnSignUp = new CheckboxField('qst_on_sign_up');
     $qstOnSignUp->setLabel($language->text('admin', 'questions_on_sing_up_label'));
     $qstOnSignUp->setDescription($language->text('admin', 'questions_on_sing_up_description'));
     $qstOnSignUp->setValue((bool) $editQuestion->onJoin);
     if ((int) $editQuestion->base === 1 || $disableActionList['disable_on_join']) {
         $qstOnSignUp->addAttribute('disabled', 'disabled');
     }
     $editForm->addElement($qstOnSignUp);
     $qstOnEdit = new CheckboxField('qst_on_edit');
     $qstOnEdit->setLabel($language->text('admin', 'questions_on_edit_label'));
     $qstOnEdit->setDescription($language->text('admin', 'questions_on_edit_description'));
     $qstOnEdit->setValue((bool) $editQuestion->onEdit);
     $description = $language->text('admin', 'questions_on_edit_description');
     if ($editQuestion->name === 'username') {
         $qstOnEdit->setDescription($language->text('admin', 'questions_on_edit_description') . "<br/><br/>" . $language->text('admin', 'questions_edit_username_warning'));
     } else {
         if ((int) $editQuestion->base === 1 || $disableActionList['disable_on_edit']) {
             $qstOnEdit->addAttribute('disabled', 'disabled');
         }
     }
     $editForm->addElement($qstOnEdit);
     $qstOnView = new CheckboxField('qst_on_view');
     $qstOnView->setLabel($language->text('admin', 'questions_on_view_label'));
     $qstOnView->setDescription($language->text('admin', 'questions_on_view_description'));
     $qstOnView->setValue((bool) $editQuestion->onView);
     if ((int) $editQuestion->base === 1 && $editQuestion->name !== 'joinStamp' || $disableActionList['disable_on_view']) {
         $qstOnView->addAttribute('disabled', 'disabled');
     }
     $editForm->addElement($qstOnView);
     $qstOnSearch = new CheckboxField('qst_on_search');
     $qstOnSearch->setLabel($language->text('admin', 'questions_on_search_label'));
     $qstOnSearch->setDescription($language->text('admin', 'questions_on_search_description'));
     $qstOnSearch->setValue((bool) $editQuestion->onSearch);
     if ((int) $editQuestion->base === 1 && $editQuestion->name != 'username' || $parentIsset || $disableActionList['disable_on_search']) {
         $qstOnSearch->addAttribute('disabled', 'disabled');
     }
     $editForm->addElement($qstOnSearch);
     $qstSubmit = new Submit('qst_submit');
     $qstSubmit->addAttribute('class', 'ow_button ow_ic_save');
     $qstSubmit->setValue($language->text('admin', 'btn_label_edit'));
     $editForm->addElement($qstSubmit);
     if (OW::getSession()->isKeySet(self::EDIT_QUESTION_SESSION_VAR)) {
         $editForm->setValues(OW::getSession()->get(self::EDIT_QUESTION_SESSION_VAR));
         OW::getSession()->delete(self::EDIT_QUESTION_SESSION_VAR);
     }
     $this->addForm($editForm);
     if (OW_Request::getInstance()->isPost()) {
         if ((isset($_POST['qst_submit_and_add']) || isset($_POST['qst_submit'])) && $editForm->isValid($_POST)) {
             OW::getSession()->delete(self::EDIT_QUESTION_SESSION_VAR);
             $updated = false;
             $data = $editForm->getValues();
             $elements = $editForm->getElements();
             foreach ($elements as $element) {
                 if (!$element->getAttribute('disabled')) {
                     switch ($element->getName()) {
                         case 'qst_required':
                             $editQuestion->required = isset($_POST['qst_required']) ? 1 : 0;
                             break;
                         case 'qst_on_sign_up':
                             $editQuestion->onJoin = isset($_POST['qst_on_sign_up']) ? 1 : 0;
                             break;
                         case 'qst_on_edit':
                             $editQuestion->onEdit = isset($_POST['qst_on_edit']) ? 1 : 0;
                             break;
                         case 'qst_on_search':
                             $editQuestion->onSearch = isset($_POST['qst_on_search']) ? 1 : 0;
                             break;
                         case 'qst_on_view':
                             $editQuestion->onView = isset($_POST['qst_on_view']) ? 1 : 0;
                             break;
                         case 'qst_answer_type':
                             $editQuestion->presentation = htmlspecialchars($data['qst_answer_type']);
                             break;
                         case 'qst_column_count':
                             $editQuestion->columnCount = htmlspecialchars($data['qst_column_count']);
                             break;
                         case 'qst_section':
                             if (!empty($data['qst_section'])) {
                                 $section = $this->questionService->findSectionBySectionName(htmlspecialchars(trim($data['qst_section'])));
                                 $sectionName = null;
                                 if (isset($section)) {
                                     $sectionName = $section->name;
                                 }
                                 if ($editQuestion->sectionName !== $sectionName) {
                                     $editQuestion->sectionName = $sectionName;
                                     $editQuestion->sortOrder = (int) BOL_QuestionService::getInstance()->findLastQuestionOrder($editQuestion->sectionName) + 1;
                                 }
                             }
                             break;
                         case 'qst_account_type':
                             if ($data['qst_account_type'] !== null) {
                                 $editQuestion->accountTypeName = htmlspecialchars(trim($data['qst_account_type']));
                                 if ($editQuestion->accountTypeName === BOL_QuestionService::ALL_ACCOUNT_TYPES) {
                                     $editQuestion->accountTypeName = null;
                                 }
                             }
                             break;
                     }
                 }
             }
             if (!$disableActionList['disable_display_config']) {
                 // save question configs
                 $configs = array();
                 foreach ($presentationConfigList as $config) {
                     if (isset($data[$config->name])) {
                         $configs[$config->name] = $data[$config->name];
                     }
                 }
                 $editQuestion->custom = json_encode($configs);
             }
             $this->questionService->saveOrUpdateQuestion($editQuestion);
             if (OW::getDbo()->getAffectedRows() > 0) {
                 $updated = true;
                 $list = $this->questionService->findQuestionChildren($editQuestion->name);
                 /* @var BOL_Question $child */
                 foreach ($list as $child) {
                     $child->columnCount = $editQuestion->columnCount;
                     $this->questionService->saveOrUpdateQuestion($child);
                 }
             }
             //update question values sort
             if (isset($_POST['question_values_order'])) {
                 $valuesOrder = json_decode($_POST['question_values_order'], true);
                 if (isset($valuesOrder) && count($valuesOrder) > 0 && is_array($valuesOrder)) {
                     foreach ($questionValues as $questionValue) {
                         if (isset($valuesOrder[$questionValue->value])) {
                             $questionValue->sortOrder = (int) $valuesOrder[$questionValue->value];
                         }
                         $this->questionService->saveOrUpdateQuestionValue($questionValue);
                         if (OW::getDbo()->getAffectedRows() > 0) {
                             $updated = true;
                         }
                     }
                 }
             }
             if ($updated) {
                 OW::getFeedback()->info($language->text('admin', 'questions_update_question_message'));
             } else {
                 OW::getFeedback()->info($language->text('admin', 'questions_question_was_not_updated_message'));
             }
             //exit;
             $this->redirect(OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'index'));
         }
         $editForm->setValues($_POST);
         OW::getSession()->set(self::EDIT_QUESTION_SESSION_VAR, $_POST);
         //OW::getFeedback()->error($language->text('admin', 'questions_question_was_not_updated_message'));
         $this->redirect();
     }
     $types = array();
     foreach ($this->questionService->getPresentations() as $presentation => $type) {
         if ($type === 'select') {
             $types[] = $presentation;
         }
     }
     $questionLabel = $this->questionService->getQuestionLang($editQuestion->name);
     $questionDescription = $this->questionService->getQuestionDescriptionLang($editQuestion->name);
     $noValue = $language->text('admin', 'questions_empty_lang_value');
     $questionLabel = mb_strlen(trim($questionLabel)) == 0 || $questionLabel == '&nbsp;' ? $noValue : $questionLabel;
     $questionDescription = mb_strlen(trim($questionDescription)) == 0 || $questionDescription == '&nbsp;' ? $noValue : $questionDescription;
     $this->assign('questionLabel', $questionLabel);
     $this->assign('questionDescription', $questionDescription);
     $language->addKeyForJs('admin', 'questions_empty_lang_value');
     $language->addKeyForJs('admin', 'questions_edit_question_name_title');
     $language->addKeyForJs('admin', 'questions_edit_question_description_title');
     $language->addKeyForJs('admin', 'questions_edit_question_value_title');
     $language->addKeyForJs('admin', 'questions_edit_delete_value_confirm_message');
     $fields = array();
     foreach ($editForm->getElements() as $element) {
         if (!$element instanceof HiddenField) {
             $fields[$element->getName()] = $element->getName();
         }
     }
     $this->assign('formData', $fields);
     $script = '
                 window.editQuestion = new editQuestion(' . json_encode(array('types' => $types, 'ajaxResponderUrl' => $this->ajaxResponderUrl)) . ');
                 ';
     OW::getDocument()->addOnloadScript($script);
     $jsDir = OW::getPluginManager()->getPlugin("admin")->getStaticJsUrl();
     $baseJsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
     OW::getDocument()->addScript($jsDir . "questions.js");
     OW::getDocument()->addScript($baseJsDir . "jquery-ui.min.js");
 }