/** * Returns an instance of class (singleton pattern implementation). * * @return BOL_QuestionToAccountTypeDao */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
public function findMatchQuestionsForUser($userId) { if ($userId === null) { return array(); } if (!OW::getPluginManager()->isPluginActive('skadate')) { return array(); } $genderAccTypes = SKADATE_BOL_AccountTypeToGenderService::getInstance()->findAll(); $lookingForValue = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array('match_sex')); $lookingForValues = array(); foreach ($genderAccTypes as $type) { if ($lookingForValue[$userId]['match_sex'] & $type->genderValue) { $lookingForValues[] = $type->genderValue; } } if (empty($lookingForValues)) { return array(); } $lookingForValues = $this->dbo->mergeInClause($lookingForValues); $sql = " SELECT DISTINCT `question`.* FROM `" . BOL_QuestionDao::getInstance()->getTableName() . "` as `question`\n\n LEFT JOIN `" . BOL_QuestionSectionDao::getInstance()->getTableName() . "` as `section`\n ON ( `question`.`sectionName` = `section`.`name` AND `question`.`sectionName` != '' AND `question`.`sectionName` IS NOT NULL )\n\n LEFT JOIN " . BOL_QuestionToAccountTypeDao::getInstance()->getTableName() . " as `qta` ON ( `question`.`parent` = `qta`.`questionName` )\n\n LEFT JOIN `" . SKADATE_BOL_AccountTypeToGenderDao::getInstance()->getTableName() . "` as `atg` ON (`qta`.`accountType` = `atg`.`accountType`)\n\n WHERE `question`.`sectionName`='about_my_match' AND `atg`.`genderValue` IN ( {$lookingForValues} )\n\n ORDER BY IF( `section`.`name` IS NULL, 0, 1 ), `section`.`sortOrder`, `question`.`sortOrder` "; return $this->dbo->queryForList($sql); }
public function findViewQuestionsForAccountType($accountType) { if ($accountType === null) { return array(); } $accountTypeName = trim($accountType); $sql = " SELECT DISTINCT `question`.* FROM `" . $this->getTableName() . "` as `question`\n\n LEFT JOIN `" . BOL_QuestionSectionDao::getInstance()->getTableName() . "` as `section`\n ON ( `question`.`sectionName` = `section`.`name` AND `question`.`sectionName` != '' AND `question`.`sectionName` IS NOT NULL )\n\n INNER JOIN " . BOL_QuestionToAccountTypeDao::getInstance()->getTableName() . " as `qta` ON( `question`.`name` = `qta`.`questionName` )\n\n WHERE ( `qta`.`accountType` = :accountTypeName OR :accountTypeName = 'all' ) AND ( `section`.isHidden IS NULL OR `section`.isHidden = 0 )\n AND `question`.`onView` = '1'\n ORDER BY IF( `section`.`name` IS NULL, 0, 1 ), `section`.`sortOrder`, `question`.`sortOrder` "; return $this->dbo->queryForList($sql, array('accountTypeName' => $accountTypeName)); }
public function findCountExlusiveQuestionForAccount($accountType) { $sql = ' SELECT COUNT( `questions`.`id` ) AS `questionCount` FROM ' . BOL_QuestionDao::getInstance()->getTableName() . ' as `questions` INNER JOIN ' . BOL_QuestionToAccountTypeDao::getInstance()->getTableName() . ' as `qta` ON( `questions`.`name` = `qta`.`questionName` ) WHERE `qta`.`accountType` = :accountType '; return $this->dbo->queryForColumn($sql, array('accountType' => $accountType)); }
/** * Constructor. * */ private function __construct() { $this->questionsBOL['base'] = array(); $this->questionsBOL['notBase'] = array(); $this->questionDao = BOL_QuestionDao::getInstance(); $this->valueDao = BOL_QuestionValueDao::getInstance(); $this->dataDao = BOL_QuestionDataDao::getInstance(); $this->sectionDao = BOL_QuestionSectionDao::getInstance(); $this->accountDao = BOL_QuestionAccountTypeDao::getInstance(); $this->accountToQuestionDao = BOL_QuestionToAccountTypeDao::getInstance(); $this->userService = BOL_UserService::getInstance(); $this->questionConfigDao = BOL_QuestionConfigDao::getInstance(); // all available presentations are hardcoded here $this->presentations = array(self::QUESTION_PRESENTATION_TEXT => self::QUESTION_VALUE_TYPE_TEXT, self::QUESTION_PRESENTATION_SELECT => self::QUESTION_VALUE_TYPE_SELECT, self::QUESTION_PRESENTATION_TEXTAREA => self::QUESTION_VALUE_TYPE_TEXT, self::QUESTION_PRESENTATION_CHECKBOX => self::QUESTION_VALUE_TYPE_BOOLEAN, self::QUESTION_PRESENTATION_RADIO => self::QUESTION_VALUE_TYPE_SELECT, self::QUESTION_PRESENTATION_MULTICHECKBOX => self::QUESTION_VALUE_TYPE_MULTISELECT, self::QUESTION_PRESENTATION_DATE => self::QUESTION_VALUE_TYPE_DATETIME, self::QUESTION_PRESENTATION_BIRTHDATE => self::QUESTION_VALUE_TYPE_DATETIME, self::QUESTION_PRESENTATION_AGE => self::QUESTION_VALUE_TYPE_DATETIME, self::QUESTION_PRESENTATION_RANGE => self::QUESTION_VALUE_TYPE_TEXT, self::QUESTION_PRESENTATION_URL => self::QUESTION_VALUE_TYPE_TEXT, self::QUESTION_PRESENTATION_PASSWORD => self::QUESTION_VALUE_TYPE_TEXT); }