public function deleteSection($sectionName, BOL_QuestionSection &$moveQuestionsToSection = null) { if ($sectionName === null || mb_strlen($sectionName) === 0) { return false; } $section = $this->sectionDao->findBySectionName($sectionName); if ($section !== null) { if (empty($moveQuestionsToSection)) { $moveQuestionsToSection = $this->findNearestSection($section); } $nextSectionName = $moveQuestionsToSection->name; } else { return false; } $questions = $this->questionDao->findQuestionsBySectionNameList(array($sectionName)); $nextSectionName = isset($moveQuestionsToSection) ? $moveQuestionsToSection->name : null; $lastOrder = $this->questionDao->findLastQuestionOrder($nextSectionName); if ($lastOrder === null) { $lastOrder = 0; } foreach ($questions as $key => $question) { $questions[$key]->sectionName = $nextSectionName; $questions[$key]->sortOrder = ++$lastOrder; } if (count($questions) > 0) { $this->questionDao->batchReplace($questions); } $key = BOL_LanguageService::getInstance()->findKey(self::QUESTION_LANG_PREFIX, $this->getQuestionLangKeyName(self::LANG_KEY_TYPE_QUESTION_SECTION, $sectionName)); if ($key !== null) { BOL_LanguageService::getInstance()->deleteKey($key->id); } $this->sectionDao->deleteById($section->id); $this->updateQuestionsEditStamp(); return true; }