public function findQuestionsForAccountType($accountType)
 {
     $sql = ' SELECT `question`.*  FROM  ' . BOL_QuestionDao::getInstance()->getTableName() . ' as `question`
                 INNER JOIN ' . $this->getTableName() . ' as `atq` ON ( `atq`.`questionName` = `question`.`name` )
                 INNER JOIN ' . BOL_QuestionAccountTypeDao::getInstance()->getTableName() . ' as `account` ON ( `account`.`name` = `atq`.`accountType` )
             WHERE  `atq`.`accountType` = :accountType ';
     return $this->dbo->queryForObjectList($sql, BOL_QuestionDao::getInstance()->getDtoClassName(), array('accountType' => $accountType));
 }
예제 #2
0
 public function addRoleByAccountType(BOL_QuestionAccountType $accountType)
 {
     if (empty($accountType)) {
         return;
     }
     $sql = " REPLACE INTO `" . BOL_AuthorizationUserRoleDao::getInstance()->getTableName() . "` ( `userId`, `roleId` ) " . "SELECT u.id, :role FROM " . BOL_UserDao::getInstance()->getTableName() . " u " . " INNER JOIN " . BOL_QuestionAccountTypeDao::getInstance()->getTableName() . " `accountType` ON ( accountType.name = u.accountType ) " . " WHERE  u.accountType = :account ";
     $this->dbo->query($sql, array('account' => $accountType->name, 'role' => $accountType->roleId));
 }
예제 #3
0
 /**
  * @param $userId
  * @return int
  */
 public function getUserAccountTypeId($userId)
 {
     if (!$userId) {
         return null;
     }
     $user = BOL_UserService::getInstance()->findUserById($userId);
     if (!$user) {
         return null;
     }
     $accTypeName = $user->getAccountType();
     $accTypeList = BOL_QuestionAccountTypeDao::getInstance()->findAccountTypeByNameList(array($accTypeName));
     $accountTypeId = isset($accTypeList[0]) ? $accTypeList[0]->id : null;
     return $accountTypeId;
 }
 /**
  * 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);
 }
예제 #5
0
 public function findViewQuestionsForAccountType($accountType)
 {
     if ($accountType === null) {
         return array();
     }
     $accountTypeName = trim($accountType);
     $sql = " SELECT `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                    LEFT JOIN  " . BOL_QuestionAccountTypeDao::getInstance()->getTableName() . " as `account`  ON( `account`.`name` = `question`.`accountTypeName` )\n\n                    WHERE ( `account`.`name` IS NULL OR `question`.`accountTypeName` = :accountTypeName OR :accountTypeName = 'all' )\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));
 }