Esempio n. 1
0
 /**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return BOL_QuestionValueDao
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Esempio n. 2
0
 public function getList(array $params)
 {
     OW::getDocument()->setHeading(OW::getLanguage()->text('bookmarks', 'list_headint_title'));
     $this->setTemplate(OW::getPluginManager()->getPlugin('bookmarks')->getCtrlViewDir() . 'list.html');
     $userId = OW::getUser()->getId();
     $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? $_GET['page'] : 1;
     $userOnPage = (int) OW::getConfig()->getValue('base', 'users_on_page');
     $first = ($page - 1) * $userOnPage;
     $list = $this->service->findBookmarksUserIdList($userId, $first, $userOnPage, $params['category']);
     $count = $this->service->findBookmarksCount($userId, $params['category']);
     $sexValue = array();
     $userDataList = array();
     $questionService = BOL_QuestionService::getInstance();
     $data = $questionService->getQuestionData($list, array('sex', 'googlemap_location', 'birthdate'));
     foreach (BOL_QuestionValueDao::getInstance()->findQuestionValues('sex') as $sexDto) {
         $sexValue[$sexDto->value] = $questionService->getQuestionValueLang('sex', $sexDto->value);
     }
     foreach ($data as $userId => $user) {
         if (isset($user['birthdate'])) {
             $date = UTIL_DateTime::parseDate($user['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         } else {
             $age = '';
         }
         $userDataList[$userId] = array('info_gender' => !empty($user['sex']) && !empty($sexValue[$user['sex']]) ? $sexValue[$user['sex']] : '' . ' ' . $age, 'location' => !empty($user['googlemap_location']) ? $user['googlemap_location']['address'] : '');
     }
     $this->addComponent('list', OW::getClassInstance('BASE_CMP_Users', $userDataList, array(), $count));
 }
Esempio n. 3
0
 public function __construct($userId, $idList)
 {
     parent::__construct();
     if (!empty($userId) && !empty($idList)) {
         $this->user = BOL_UserService::getInstance()->findUserById($userId);
         $userService = BOL_UserService::getInstance();
         $avatars = BOL_AvatarService::getInstance()->getAvatarsUrlList($idList, 2);
         $sexValue = array();
         $list = array();
         foreach (BOL_QuestionValueDao::getInstance()->findQuestionValues('sex') as $sexDto) {
             $sexValue[$sexDto->value] = BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $sexDto->value);
         }
         $userData = BOL_QuestionService::getInstance()->getQuestionData($idList, array('sex', 'birthdate', 'googlemap_location'));
         foreach ($idList as $userId) {
             $list[$userId]['userUrl'] = $userService->getUserUrl($userId);
             $list[$userId]['displayName'] = $userService->getDisplayName($userId);
             $list[$userId]['avatarUrl'] = $avatars[$userId];
             $list[$userId]['activity'] = UTIL_DateTime::formatDate(BOL_UserService::getInstance()->findUserById($userId)->getActivityStamp());
             if (!empty($userData[$userId]['birthdate'])) {
                 $date = UTIL_DateTime::parseDate($userData[$userId]['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
                 $list[$userId]['age'] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
             }
             if (!empty($userData[$userId]['sex'])) {
                 $list[$userId]['sex'] = $sexValue[$userData[$userId]['sex']];
             }
             if (!empty($userData[$userId]['googlemap_location'])) {
                 $list[$userId]['googlemap_location'] = $userData[$userId]['googlemap_location']['address'];
             }
         }
         $this->assign('userName', BOL_UserService::getInstance()->getDisplayName($this->user->id));
         $this->assign('list', $list);
     } else {
         $this->setVisible(FALSE);
     }
 }
 public function deleteQuestionValue($questionName, $value)
 {
     if ($questionName === null) {
         return;
     }
     $name = trim($questionName);
     $valueId = (int) $value;
     $isDelete = $this->valueDao->deleteQuestionValue($name, $valueId);
     if ($isDelete) {
         $serviceLang = BOL_LanguageService::getInstance();
         $key = $serviceLang->findKey('base', 'questions_question_' . $name . '_value_' . $valueId);
         if ($key !== null) {
             $serviceLang->deleteKey($key->id);
         }
         $this->updateQuestionsEditStamp();
         $event = new OW_Event(self::EVENT_AFTER_DELETE_QUESTION_VALUE, array('questionName' => $questionName, 'value' => $value));
         OW::getEventManager()->trigger($event);
     }
     return $isDelete;
 }
Esempio n. 5
0
 public function deleteQuestion(array $questionIdList)
 {
     if ($questionIdList === null || count($questionIdList) == 0) {
         return false;
     }
     $questionArray = $this->questionDao->findByIdList($questionIdList);
     $questionsNameList = array();
     foreach ($questionArray as $question) {
         if ($question->base == 1 || (int) $question->removable == 0) {
             continue;
         }
         $questionsNameList[] = $question->name;
         $valuesObjects = $this->valueDao->findQuestionValues($question->name);
         $values = array();
         foreach ($valuesObjects as $v) {
             $values[] = $v->value;
         }
         foreach ($values as $value) {
             $key = BOL_LanguageService::getInstance()->findKey(self::QUESTION_LANG_PREFIX, $this->getQuestionLangKeyName(self::LANG_KEY_TYPE_QUESTION_VALUE, $question->name, $value));
             if ($key !== null) {
                 BOL_LanguageService::getInstance()->deleteKey($key->id);
             }
         }
         $key = BOL_LanguageService::getInstance()->findKey(self::QUESTION_LANG_PREFIX, $this->getQuestionLangKeyName(self::LANG_KEY_TYPE_QUESTION_LABEL, $question->name));
         if ($key !== null) {
             BOL_LanguageService::getInstance()->deleteKey($key->id);
         }
         $key = BOL_LanguageService::getInstance()->findKey(self::QUESTION_LANG_PREFIX, $this->getQuestionLangKeyName(self::LANG_KEY_TYPE_QUESTION_DESCRIPTION, $question->name));
         if ($key !== null) {
             BOL_LanguageService::getInstance()->deleteKey($key->id);
         }
         $event = new OW_Event(self::EVENT_ON_QUESTION_DELETE, array('questionName' => $question->name, 'dto' => $question));
         OW::getEventManager()->trigger($event);
         $this->deleteQuestionValues($question->name, $values);
     }
     $this->dataDao->deleteByQuestionNamesList($questionsNameList);
     $this->questionDao->deleteByIdList($questionIdList);
     $this->updateQuestionsEditStamp();
     return (bool) OW::getDbo()->getAffectedRows();
 }