Exemplo n.º 1
0
 public function getList($params)
 {
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $auth = array('photo.view' => $service->getAuthorizationActionStatus('photo', 'view'), 'base.search_users' => $service->getAuthorizationActionStatus('base', 'search_users'));
     $this->assign('auth', $auth);
     if ($auth["base.search_users"]["status"] != BOL_AuthorizationService::STATUS_AVAILABLE) {
         $this->assign("list", array());
         $this->assign("total", 0);
         return;
     }
     $_criteriaList = array_filter($params["criteriaList"]);
     $userId = OW::getUser()->getId();
     $userInfo = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array("sex"));
     $_criteriaList["sex"] = !empty($userInfo[$userId]["sex"]) ? $userInfo[$userId]["sex"] : null;
     $questionList = BOL_QuestionService::getInstance()->findQuestionByNameList(array_keys($_criteriaList));
     $criteriaList = array();
     foreach ($_criteriaList as $questionName => $questionValue) {
         if (empty($questionList[$questionName])) {
             continue;
         }
         $criteriaList[$questionName] = $this->convertQuestionValue($questionList[$questionName]->presentation, $questionValue);
     }
     $idList = OW::getEventManager()->call("usearch.get_user_id_list", array("criterias" => $criteriaList, "limit" => array($params["first"], $params["count"])));
     $idList = empty($idList) ? array() : $idList;
     //$idList = BOL_UserService::getInstance()->findUserIdListByQuestionValues($criteriaList, $params["first"], $params["count"]);
     $total = BOL_UserService::getInstance()->countUsersByQuestionValues($params["criteriaList"]);
     $userData = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, false, false, true, true);
     $questionsData = BOL_QuestionService::getInstance()->getQuestionData($idList, array("googlemap_location", "birthdate"));
     foreach ($questionsData as $userId => $data) {
         $date = UTIL_DateTime::parseDate($data['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
         $userData[$userId]["ages"] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         $userData[$userId]["location"] = empty($data["googlemap_location"]["address"]) ? null : $data["googlemap_location"]["address"];
     }
     $photoList = array();
     $avatarList = array();
     foreach ($idList as $userId) {
         $bigAvatar = SKADATE_BOL_Service::getInstance()->findAvatarByUserId($userId);
         $avatarList[$userId] = $bigAvatar ? SKADATE_BOL_Service::getInstance()->getAvatarUrl($userId, $bigAvatar->hash) : BOL_AvatarService::getInstance()->getAvatarUrl($userId, 2);
         $event = new OW_Event('photo.getMainAlbum', array('userId' => $userId));
         OW::getEventManager()->trigger($event);
         $album = $event->getData();
         $photos = !empty($album['photoList']) ? $album['photoList'] : array();
         foreach ($photos as $photo) {
             $photoList[$userId][] = array("src" => $photo["url"]["main"]);
         }
     }
     $bookmarksList = OW::getEventManager()->call("bookmarks.get_mark_list", array("userId" => OW::getUser()->getId(), "idList" => $idList));
     $bookmarksList = empty($bookmarksList) ? array() : $bookmarksList;
     $list = array();
     foreach ($idList as $userId) {
         $list[] = array("userId" => $userId, "photos" => empty($photoList[$userId]) ? array() : $photoList[$userId], "avatar" => $avatarList[$userId], "name" => empty($userData[$userId]["title"]) ? "" : $userData[$userId]["title"], "label" => $userData[$userId]["label"], "labelColor" => $userData[$userId]["labelColor"], "location" => empty($userData[$userId]["location"]) ? "" : $userData[$userId]["location"], "ages" => $userData[$userId]["ages"], "bookmarked" => !empty($bookmarksList[$userId]));
     }
     $this->assign("list", $list);
     $this->assign("total", $total);
     $allowSendMessage = OW::getPluginManager()->isPluginActive('mailbox');
     $this->assign("actions", array("bookmark" => OW::getPluginManager()->isPluginActive('bookmarks'), "message" => $allowSendMessage, "wink" => OW::getPluginManager()->isPluginActive('winks')));
     BOL_AuthorizationService::getInstance()->trackAction("base", "search_users");
     $mailboxModes = OW::getEventManager()->call('mailbox.get_active_mode_list');
     $this->assign("mailboxModes", empty($mailboxModes) ? array() : $mailboxModes);
 }
Exemplo n.º 2
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);
     }
 }
Exemplo n.º 3
0
 public function getFields($userIdList)
 {
     $fields = array();
     $qs = array();
     $qBdate = BOL_QuestionService::getInstance()->findQuestionByName('birthdate');
     if ($qBdate->onView) {
         $qs[] = 'birthdate';
     }
     $qSex = BOL_QuestionService::getInstance()->findQuestionByName('sex');
     if ($qSex->onView) {
         $qs[] = 'sex';
     }
     $questionList = BOL_QuestionService::getInstance()->getQuestionData($userIdList, $qs);
     foreach ($questionList as $uid => $q) {
         $fields[$uid] = array();
         $age = '';
         if (!empty($q['birthdate'])) {
             $date = UTIL_DateTime::parseDate($q['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         }
         if (!empty($q['sex'])) {
             $fields[$uid][] = array('label' => '', 'value' => BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $q['sex']) . ' ' . $age);
         }
         if (!empty($q['birthdate'])) {
             $dinfo = date_parse($q['birthdate']);
         }
     }
     return $fields;
 }
Exemplo n.º 4
0
 public function onNewsfeedItemRender(OW_Event $event)
 {
     $params = $event->getParams();
     $content = $event->getData();
     if (!empty($params['action']['entityType']) && !empty($params['action']['pluginKey']) && $params['action']['entityType'] == 'birthday' && $params['action']['pluginKey'] == 'birthdays') {
         $html = '<div class="ow_user_list_data"></div>';
         if (!empty($content['birthdate']) && !empty($content['userData'])) {
             $date = UTIL_DateTime::parseDate($content['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $birthdate = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
             if ($date['month'] == intval(date('m'))) {
                 if (intval(date('d')) + 1 == intval($date['day'])) {
                     $birthdate = '<span class="ow_green" style="font-weight: bold; text-transform: uppercase;">' . OW::getLanguage()->text('base', 'date_time_tomorrow') . '</a>';
                 } else {
                     if (intval(date('d')) == intval($date['day'])) {
                         $birthdate = '<span class="ow_green" style="font-weight: bold; text-transform: uppercase;">' . OW::getLanguage()->text('base', 'date_time_today') . '</span>';
                     }
                 }
             }
             $html = '<div class="ow_user_list_data">
                         <a href="' . $content['userData']["url"] . '">' . $content['userData']["title"] . '</a><br><span style="font-weight:normal;" class="ow_small">' . OW::getLanguage()->text('birthdays', 'birthday') . ' ' . $birthdate . '</span>                
                      </div>';
         }
         $userId = $params['action']['entityId'];
         $usersData = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId));
         $content['content'] = '<div class="ow_user_list_picture">' . OW::getThemeManager()->processDecorator('avatar_item', $usersData[$userId]) . '</div>';
         $content['content'] .= $html;
         $content['content'] = '<div class="clearfix">' . $content['content'] . '</div>';
         $content['view'] = array('iconClass' => 'ow_ic_birthday');
         $event->setData($content);
     }
 }
Exemplo n.º 5
0
 protected function getInfoList($userIdList)
 {
     $fields = array();
     $qs = array();
     $qBdate = BOL_QuestionService::getInstance()->findQuestionByName('birthdate');
     if ($qBdate->onView) {
         $qs[] = 'birthdate';
     }
     $qSex = BOL_QuestionService::getInstance()->findQuestionByName('sex');
     if ($qSex->onView) {
         $qs[] = 'sex';
     }
     $questionList = BOL_QuestionService::getInstance()->getQuestionData($userIdList, $qs);
     foreach ($questionList as $uid => $q) {
         $info = array();
         if (!empty($q['sex'])) {
             $info['sex'] = BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $q['sex']);
         }
         if (!empty($q['birthdate'])) {
             $date = UTIL_DateTime::parseDate($q['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
             $info['age'] = $age;
         }
         $fields[$uid] = $info;
     }
     return $fields;
 }
Exemplo n.º 6
0
 public function getAvatarInfo($idList)
 {
     $data = parent::getAvatarInfo($idList);
     $birthdays = BOL_QuestionService::getInstance()->getQuestionData($idList, array('birthdate'));
     foreach ($data as $userId => $item) {
         $yearOld = '';
         if (!empty($birthdays[$userId]['birthdate'])) {
             switch ($this->key) {
                 case 'birthdays_today':
                     $date = UTIL_DateTime::parseDate($birthdays[$userId]['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
                     $yearOld = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']) . " " . OW::getLanguage()->text('base', 'questions_age_year_old');
                     break;
                 case 'birthdays_this_week':
                     $date = UTIL_DateTime::parseDate($birthdays[$userId]['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
                     $yearOld = OW::getLanguage()->text('birthdays', 'birthday') . ' ' . UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']) . " ";
                     break;
             }
         }
         if (!empty($data[$userId]['title'])) {
             $data[$userId]['attrs'] = ' data-birthday="' . (!empty($yearOld) ? $yearOld : '') . '"';
         } else {
             if (!empty($yearOld)) {
                 $data[$userId]['attrs'] = ' data-birthday="' . $yearOld . '"';
             }
         }
     }
     OW::getDocument()->addOnloadScript("\n                \$('*[title]', \$('.birthdays_avatar_list') ).each( function(i, o){\n                    \$(o).off('mouseenter');\n                    \$(o).on('mouseenter', function(){ \n                        var title = \$(this).attr('title');\n                        var birthday = \$(this).data('birthday');\n                        \n                        if ( !birthday )\n                        {\n                            OW.showTip(\$(this), {timeout:200});\n                        }\n                        else if ( !title && birthday )\n                        {\n                            birthday = '<span class=\"ow_small\" style=\"font-weight:normal;\">' + birthday + '</span>';\n                            \n                            OW.showTip(\$(this), {timeout:200, show:birthday});\n                        }\n                        else\n                        {\n                            birthday = '<br><span class=\"ow_small\" style=\"font-weight:normal;\">' + birthday + '</span>';\n                            \n                            OW.showTip(\$(this), {timeout:200, show:title + birthday});\n                        }\n                     });\n                    \$(o).off('mouseleave');\n                    \$(o).on('mouseleave', function(){ OW.hideTip(\$(this)); });\n            });");
     return $data;
 }
Exemplo n.º 7
0
 public function __construct($users, $size, $layout)
 {
     parent::__construct();
     $questionService = BOL_QuestionService::getInstance();
     $userService = BOL_UserService::getInstance();
     $this->uniqId = uniqid('ucl_');
     $idList = $this->fetchIdList($users);
     $qList = $questionService->getQuestionData($idList, array('sex', 'birthdate'));
     $displayNames = $userService->getDisplayNamesForList($idList);
     $urls = $userService->getUserUrlsForList($idList);
     $tplData = array();
     foreach ($idList as $userId) {
         $tplData[$userId] = array();
         $tplData[$userId]['displayName'] = empty($displayNames[$userId]) ? null : $displayNames[$userId];
         $tplData[$userId]['url'] = empty($urls[$userId]) ? null : $urls[$userId];
         $tplData[$userId]['sex'] = empty($qList[$userId]['sex']) || in_array($layout, array(3, 4)) ? null : strtolower(BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $qList[$userId]['sex']));
         $tplData[$userId]['birthdate'] = null;
         if (!empty($qList[$userId]['birthdate']) && in_array($layout, array(1, 3))) {
             $date = UTIL_DateTime::parseDate($qList[$userId]['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
             $tplData[$userId]['birthdate'] = $age;
         }
         $avatar = BOL_AvatarService::getInstance()->getAvatarUrl($userId, 2);
         $tplData[$userId]['thumb'] = $avatar ? $avatar : BOL_AvatarService::getInstance()->getDefaultAvatarUrl(2);
     }
     $sizes = array('small' => 100, 'medium' => 150, 'big' => OW::getConfig()->getValue('base', 'avatar_big_size'));
     $this->assign('list', $tplData);
     $avatarSize = $sizes[$size];
     $this->assign('size', $size);
     $this->assign('uniqId', $this->uniqId);
     OW::getDocument()->addStyleDeclaration('.uc-avatar-size { width: ' . $avatarSize . 'px; height: ' . ($avatarSize + $avatarSize / 10) . 'px; }');
     OW::getDocument()->addStyleDeclaration('.uc-carousel-size { height: ' . ($avatarSize + 50) . 'px; }');
     OW::getDocument()->addStyleDeclaration('.uc-shape-waterWheel .uc-carousel { width: ' . ($avatarSize + 20) . 'px; }');
 }
Exemplo n.º 8
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));
 }
Exemplo n.º 9
0
 public function onNewsfeedItemRender(OW_Event $event)
 {
     $params = $event->getParams();
     $content = $event->getData();
     if (!empty($params['action']['entityType']) && !empty($params['action']['pluginKey']) && $params['action']['entityType'] == 'birthday' && $params['action']['pluginKey'] == 'birthdays') {
         $html = '<div class="ow_user_list_data"></div>';
         if (!empty($content['birthdate']) && !empty($content['userData'])) {
             $date = UTIL_DateTime::parseDate($content['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $birthdate = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
             if ($date['month'] == intval(date('m'))) {
                 if (intval(date('d')) + 1 == intval($date['day'])) {
                     $birthdate = '<span class="ow_green" style="font-weight: bold; text-transform: uppercase;">' . OW::getLanguage()->text('base', 'date_time_tomorrow') . '</a>';
                 } else {
                     if (intval(date('d')) == intval($date['day'])) {
                         $birthdate = '<span class="ow_green" style="font-weight: bold; text-transform: uppercase;">' . OW::getLanguage()->text('base', 'date_time_today') . '</span>';
                     }
                 }
             }
             $html = '<div class="ow_user_list_data">
                         <a href="' . $content['userData']["url"] . '">' . $content['userData']["title"] . '</a><br><span style="font-weight:normal;" class="ow_small">' . OW::getLanguage()->text('birthdays', 'birthday') . ' ' . $birthdate . '</span>                
                      </div>';
         }
         $content['content'] .= $html;
         $content['content'] = '<div class="clearfix">' . $content['content'] . '</div>';
         $event->setData($content);
     }
 }
Exemplo n.º 10
0
 public function getFields($userIdList)
 {
     $fields = array();
     $qs = array();
     $qBdate = BOL_QuestionService::getInstance()->findQuestionByName('birthdate');
     if ($qBdate->onView) {
         $qs[] = 'birthdate';
     }
     $qSex = BOL_QuestionService::getInstance()->findQuestionByName('sex');
     if ($qSex->onView) {
         $qs[] = 'sex';
     }
     $questionList = BOL_QuestionService::getInstance()->getQuestionData($userIdList, $qs);
     foreach ($questionList as $uid => $question) {
         $fields[$uid] = array();
         $age = '';
         if (!empty($question['birthdate'])) {
             $date = UTIL_DateTime::parseDate($question['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         }
         $sexValue = '';
         if (!empty($question['sex'])) {
             $sex = $question['sex'];
             for ($i = 0; $i < 31; $i++) {
                 $val = pow(2, $i);
                 if ((int) $sex & $val) {
                     $sexValue .= BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $val) . ', ';
                 }
             }
             if (!empty($sexValue)) {
                 $sexValue = substr($sexValue, 0, -2);
             }
         }
         if (!empty($sexValue) && !empty($age)) {
             $fields[$uid][] = array('label' => '', 'value' => $sexValue . ' ' . $age);
         }
         if (!empty($question['birthdate'])) {
             $dinfo = date_parse($question['birthdate']);
             if ($this->listKey == 'birthdays') {
                 $birthdate = '';
                 if (intval(date('d')) + 1 == intval($dinfo['day'])) {
                     $questionList[$uid]['birthday'] = OW::getLanguage()->text('base', 'date_time_tomorrow');
                     $birthdate = '<a href="#" class="ow_lbutton ow_green">' . $questionList[$uid]['birthday'] . '</a>';
                 } else {
                     if (intval(date('d')) == intval($dinfo['day'])) {
                         $questionList[$uid]['birthday'] = OW::getLanguage()->text('base', 'date_time_today');
                         $birthdate = '<a href="#" class="ow_lbutton ow_green">' . $questionList[$uid]['birthday'] . '</a>';
                     } else {
                         $birthdate = UTIL_DateTime::formatBirthdate($dinfo['year'], $dinfo['month'], $dinfo['day']);
                     }
                 }
                 $fields[$uid][] = array('label' => 'Birthday: ', 'value' => $birthdate);
             }
         }
     }
     return $fields;
 }
Exemplo n.º 11
0
 public function getList($params)
 {
     $sort = empty($params["sort"]) ? "newest" : $params["sort"];
     $matchList = OW::getEventManager()->call("matchmaking.get_list", array("userId" => OW::getUser()->getId(), "sort" => $sort, "first" => empty($params["first"]) ? 0 : $params["first"], "count" => empty($params["count"]) ? 0 : $params["count"]));
     $idList = array();
     $compatibilityList = array();
     foreach ($matchList as $item) {
         $idList[] = $item["id"];
         $compatibilityList[$item["id"]] = $item["compatibility"];
     }
     $userData = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, false, false, true, true);
     $questionsData = BOL_QuestionService::getInstance()->getQuestionData($idList, array("googlemap_location", "birthdate"));
     foreach ($questionsData as $userId => $data) {
         $date = UTIL_DateTime::parseDate($data['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
         $userData[$userId]["ages"] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         $userData[$userId]["location"] = empty($data["googlemap_location"]["address"]) ? null : $data["googlemap_location"]["address"];
     }
     $photoList = array();
     $avatarList = array();
     foreach ($idList as $userId) {
         $bigAvatar = SKADATE_BOL_Service::getInstance()->findAvatarByUserId($userId);
         $avatarList[$userId] = $bigAvatar ? SKADATE_BOL_Service::getInstance()->getAvatarUrl($userId, $bigAvatar->hash) : BOL_AvatarService::getInstance()->getAvatarUrl($userId, 2);
         $event = new OW_Event('photo.getMainAlbum', array('userId' => $userId));
         OW::getEventManager()->trigger($event);
         $album = $event->getData();
         $photos = !empty($album['photoList']) ? $album['photoList'] : array();
         $photoList[$userId] = array();
         foreach ($photos as $photo) {
             $photoList[$userId][] = array("src" => $photo["url"]["main"]);
         }
     }
     $bookmarksList = OW::getEventManager()->call("bookmarks.get_mark_list", array("userId" => OW::getUser()->getId(), "idList" => $idList));
     $bookmarksList = empty($bookmarksList) ? array() : $bookmarksList;
     $list = array();
     foreach ($idList as $userId) {
         $list[] = array("userId" => $userId, "photos" => $photoList[$userId], "avatar" => $avatarList[$userId], "name" => empty($userData[$userId]["title"]) ? "" : $userData[$userId]["title"], "label" => $userData[$userId]["label"], "labelColor" => $userData[$userId]["labelColor"], "compatibility" => $compatibilityList[$userId], "location" => empty($userData[$userId]["location"]) ? "" : $userData[$userId]["location"], "ages" => $userData[$userId]["ages"], "bookmarked" => !empty($bookmarksList[$userId]));
     }
     $this->assign("list", $list);
     $total = OW::getEventManager()->call("matchmaking.get_list_count", array("userId" => OW::getUser()->getId()));
     $this->assign("total", $total);
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $auth = array('photo.view' => $service->getAuthorizationActionStatus('photo', 'view'));
     $this->assign('auth', $auth);
     $allowSendMessage = OW::getPluginManager()->isPluginActive('mailbox');
     $this->assign("actions", array("bookmark" => OW::getPluginManager()->isPluginActive('bookmarks'), "message" => $allowSendMessage, "wink" => OW::getPluginManager()->isPluginActive('winks')));
     $mailboxModes = OW::getEventManager()->call('mailbox.get_active_mode_list');
     $this->assign("mailboxModes", empty($mailboxModes) ? array() : $mailboxModes);
 }
Exemplo n.º 12
0
 public function getFields($userIdList)
 {
     $lang = OW::getLanguage();
     $fields = array();
     $qs = array();
     $qBdate = BOL_QuestionService::getInstance()->findQuestionByName('birthdate', 'sex');
     if ($qBdate->onView) {
         $qs[] = 'birthdate';
     }
     $qSex = BOL_QuestionService::getInstance()->findQuestionByName('sex');
     if ($qSex->onView) {
         $qs[] = 'sex';
     }
     $questionList = BOL_QuestionService::getInstance()->getQuestionData($userIdList, $qs);
     foreach ($questionList as $uid => $question) {
         $fields[$uid] = array();
         $age = '';
         if (!empty($question['birthdate'])) {
             $date = UTIL_DateTime::parseDate($question['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         }
         $sexValue = '';
         if (!empty($question['sex'])) {
             $sex = $question['sex'];
             for ($i = 0; $i < 31; $i++) {
                 $val = pow(2, $i);
                 if ((int) $sex & $val) {
                     $sexValue .= BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $val) . ', ';
                 }
             }
             if (!empty($sexValue)) {
                 $sexValue = substr($sexValue, 0, -2);
             }
         }
         if (!empty($sexValue) && !empty($age)) {
             $fields[$uid][] = array('label' => '', 'value' => $sexValue . ' ' . $age);
         }
         $fields[$uid][] = array('label' => ' ', 'value' => $this->guests[$uid]['last_visit']);
     }
     return $fields;
 }
Exemplo n.º 13
0
 public function __construct(BASE_CLASS_WidgetParameter $params)
 {
     parent::__construct();
     $service = BIRTHDAYS_BOL_Service::getInstance();
     $user = BOL_UserService::getInstance()->findUserById($params->additionalParamList['entityId']);
     if ($user === null) {
         $this->setVisible(false);
         return;
     }
     $eventParams = array('action' => 'birthdays_view_my_birthdays', 'ownerId' => $user->getId(), 'viewerId' => OW::getUser()->getId());
     try {
         OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     } catch (RedirectException $e) {
         $this->setVisible(false);
         return;
     }
     $result = $service->findListByBirthdayPeriod(date('Y-m-d'), date('Y-m-d', strtotime('+7 day')), 0, 1, array($user->getId()));
     $isComingSoon = !empty($result);
     $this->assign('ballonGreenSrc', OW::getPluginManager()->getPlugin('birthdays')->getStaticUrl() . 'img/' . 'ballon-lime-green.png');
     $data = BOL_QuestionService::getInstance()->getQuestionData(array($user->getId()), array('birthdate'));
     if (!$isComingSoon && !$params->customizeMode || !array_key_exists('birthdate', $data[$user->getId()])) {
         $this->setVisible(false);
         return;
     }
     $birtdate = $data[$user->getId()]['birthdate'];
     $dateInfo = UTIL_DateTime::parseDate($birtdate, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
     $label = '';
     if ($dateInfo['day'] == date('d')) {
         $label = '<span class="ow_lbutton ow_green">' . OW::getLanguage()->text('base', 'date_time_today') . '</span>';
     } else {
         if ($dateInfo['day'] == date('d') + 1) {
             $label = '<span class="ow_lbutton ow_green">' . OW::getLanguage()->text('base', 'date_time_tomorrow') . '</span>';
         } else {
             $label = '<span class="ow_small">' . UTIL_DateTime::formatBirthdate($dateInfo['year'], $dateInfo['month'], $dateInfo['day']) . '</span>';
         }
     }
     $this->assign('label', $label);
 }
Exemplo n.º 14
0
 private function renderQuestion($userId, $questionName)
 {
     $language = OW::getLanguage();
     $questionData = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array($questionName));
     if (!isset($questionData[$userId][$questionName])) {
         return null;
     }
     $question = BOL_QuestionService::getInstance()->findQuestionByName($questionName);
     switch ($question->presentation) {
         /*case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
                         
                         if ( (int) $questionData[$userId][$question->name] === 1 )
                         {
                             $questionData[$userId][$question['name']] = $language->text('base', 'questions_checkbox_value_true');
                         }
                         else
                         {
                             $questionData[$userId][$question['name']] = $language->text('base', 'questions_checkbox_value_false');
                         }
         
                         break;*/
         case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
             $format = OW::getConfig()->getValue('base', 'date_field_format');
             $value = 0;
             switch ($question->type) {
                 case BOL_QuestionService::QUESTION_VALUE_TYPE_DATETIME:
                     $date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
                     if (isset($date)) {
                         $format = OW::getConfig()->getValue('base', 'date_field_format');
                         $value = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
                     }
                     break;
                 case BOL_QuestionService::QUESTION_VALUE_TYPE_SELECT:
                     $value = (int) $questionData[$userId][$question->name];
                     break;
             }
             if ($format === 'dmy') {
                 $questionData[$userId][$question->name] = date("d/m/Y", $value);
             } else {
                 $questionData[$userId][$question->name] = date("m/d/Y", $value);
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
             $date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $questionData[$userId][$question->name] = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
             $date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $questionData[$userId][$question->name] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']) . " " . $language->text('base', 'questions_age_year_old');
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_RANGE:
             $range = explode('-', $questionData[$userId][$question->name]);
             $questionData[$userId][$question->name] = $language->text('base', 'form_element_from') . " " . $range[0] . " " . $language->text('base', 'form_element_to') . " " . $range[1];
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
         case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
         case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
             $value = "";
             $multicheckboxValue = (int) $questionData[$userId][$question->name];
             $questionValues = BOL_QuestionService::getInstance()->findQuestionValues($question->name);
             foreach ($questionValues as $val) {
                 /* @var $val BOL_QuestionValue */
                 if ((int) $val->value & $multicheckboxValue) {
                     if (strlen($value) > 0) {
                         $value .= ', ';
                     }
                     $value .= $language->text('base', 'questions_question_' . $question->name . '_value_' . $val->value);
                 }
             }
             if (strlen($value) > 0) {
                 $questionData[$userId][$question->name] = $value;
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_URL:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXT:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXTAREA:
             // googlemap_location shortcut
             if ($question->name == "googlemap_location" && !empty($questionData[$userId][$question->name]) && is_array($questionData[$userId][$question->name])) {
                 $mapData = $questionData[$userId][$question->name];
                 $value = trim($mapData["address"]);
             } else {
                 $value = trim($questionData[$userId][$question->name]);
             }
             if (strlen($value) > 0) {
                 $questionData[$userId][$question->name] = UTIL_HtmlTag::autoLink(nl2br($value));
             }
             break;
         default:
             $questionData[$userId][$question->name] = null;
     }
     return $questionData[$userId][$question->name];
 }
Exemplo n.º 15
0
 public function getFields($userIdList)
 {
     $fields = array();
     foreach ($userIdList as $userId) {
         $fields[$userId] = '';
     }
     $qs = array();
     $qs[] = 'username';
     $questionName = OW::getConfig()->getValue('base', 'display_name_question');
     $qs[] = $questionName;
     $qBdate = BOL_QuestionService::getInstance()->findQuestionByName('birthdate');
     if ($qBdate->onView) {
         $qs[] = 'birthdate';
     }
     $qSex = BOL_QuestionService::getInstance()->findQuestionByName('sex');
     if ($qSex->onView) {
         $qs[] = 'sex';
     }
     $qLocation = BOL_QuestionService::getInstance()->findQuestionByName('googlemap_location');
     if ($qLocation) {
         if ($qLocation->onView) {
             $qs[] = 'googlemap_location';
         }
     }
     $questionList = BOL_QuestionService::getInstance()->getQuestionData($userIdList, $qs);
     foreach ($questionList as $userId => $question) {
         $userFields = array();
         $fields[$userId] = isset($question[$questionName]) ? "<b>" . $question[$questionName] . "</b>" : "<b>" . $question['username'] . "</b>";
         $sexValue = '';
         if (!empty($question['sex'])) {
             $sex = $question['sex'];
             for ($i = 0; $i < 31; $i++) {
                 $val = pow(2, $i);
                 if ((int) $sex & $val) {
                     $sexValue .= BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $val) . ', ';
                 }
             }
             if (!empty($sexValue)) {
                 $userFields['sex'] = substr($sexValue, 0, -2);
                 $fields[$userId] .= "<br/>" . $userFields['sex'];
             }
         }
         if (!empty($question['birthdate'])) {
             $date = UTIL_DateTime::parseDate($question['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $userFields['age'] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
             $fields[$userId] .= "<br/>" . $userFields['age'];
         }
         if (!empty($question['googlemap_location'])) {
             $userFields['googlemap_location'] = !empty($question['googlemap_location']['address']) ? $question['googlemap_location']['address'] : '';
             $fields[$userId] .= "<br/>" . $userFields['googlemap_location'];
         }
     }
     return $fields;
 }
Exemplo n.º 16
0
 /**
  * @param BOL_Question $question
  * @param $value
  * @param string $prefix
  * @return array|string
  */
 private function prepareQuestionWhere(BOL_Question $question, $value, $prefix = '')
 {
     $result = '';
     $prefix = $this->dbo->escapeString($prefix);
     switch ($question->presentation) {
         case BOL_QuestionService::QUESTION_PRESENTATION_URL:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXT:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXTAREA:
             if ($question->base) {
                 $result = ' `user`.`' . $this->dbo->escapeString($question->name) . '` LIKE \'' . $this->dbo->escapeString($value) . '%\'';
             } else {
                 $result = " LCASE(`" . $prefix . "`.`textValue`) LIKE '" . $this->dbo->escapeString(strtolower($value)) . "%'";
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
             if ($question->base) {
                 $result = ' `user`.`' . $this->dbo->escapeString($question->name) . '` = ' . (bool) $value;
             } else {
                 $result = " `" . $prefix . "`.`intValue` = " . (bool) $value;
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
             if ($question->base) {
                 $result = ' `user`.`' . $this->dbo->escapeString($question->name) . '` & ' . $value . ' ';
             } else {
                 $result = ' `' . $this->dbo->escapeString($prefix) . '`.`intValue` & ' . $value . ' ';
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
         case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
             $questionValues = BOL_QuestionService::getInstance()->findQuestionValues($question->name);
             if (!empty($questionValues)) {
                 $result = array();
                 foreach ($questionValues as $val) {
                     if ((bool) ($val->value & (int) $value)) {
                         $result[] = $val->value;
                     }
                 }
                 $value = $result;
             }
             if (isset($value) && is_array($value) && !empty($value)) {
                 if ($question->base) {
                     $result = ' `user`.`' . $this->dbo->escapeString($question->name) . '` IN ( ' . $this->dbo->mergeInClause($value) . ' ) ';
                 } else {
                     $result = ' `' . $this->dbo->escapeString($prefix) . '`.`intValue` IN ( ' . $this->dbo->mergeInClause($value) . ' ) ';
                 }
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
         case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
         case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
             $value = explode('-', $value);
             $value = array('from' => $value[0], 'to' => $value[1]);
             if (isset($value['from']) && isset($value['to'])) {
                 $maxDate = date('Y') - (int) $value['from'] . '-12-31';
                 $minDate = date('Y') - (int) $value['to'] . '-01-01';
                 if ($question->base) {
                     $result = " `user`.`" . $this->dbo->escapeString($question->name) . "` BETWEEN  '" . $this->dbo->escapeString($minDate) . "' AND '" . $this->dbo->escapeString($maxDate) . "'";
                 } else {
                     $result = " `" . $prefix . "`.`dateValue` BETWEEN  '" . $this->dbo->escapeString($minDate) . "' AND '" . $this->dbo->escapeString($maxDate) . "'";
                 }
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_RANGE:
             $date = UTIL_DateTime::parseDate($value, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $value = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
             if ($question->base) {
                 $result = " " . $value . " BETWEEN SUBSTRING(`user`.`" . $this->dbo->escapeString($question->name) . "`, 1, LOCATE('-', `user`.`" . $this->dbo->escapeString($question->name) . "`)-1 ) AND SUBSTRING(`user`.`" . $this->dbo->escapeString($question->name) . "`, LOCATE('-', `user`.`" . $this->dbo->escapeString($question->name) . "`)+1 ) ";
             } else {
                 $result = " " . $value . " BETWEEN SUBSTRING(`" . $prefix . "`.`textValue`, 1, LOCATE('-', `" . $prefix . "`.`textValue`)-1 ) AND SUBSTRING(`" . $prefix . "`.`textValue`, LOCATE('-', `" . $prefix . "`.`textValue`)+1 )  ";
             }
             break;
     }
     return $result;
 }
Exemplo n.º 17
0
 public function getFieldsForEmail($userId)
 {
     $fields = array();
     $qs = array();
     $qBdate = BOL_QuestionService::getInstance()->findQuestionByName('birthdate');
     if ($qBdate->onView) {
         $qs[] = 'birthdate';
     }
     $qSex = BOL_QuestionService::getInstance()->findQuestionByName('sex');
     if ($qSex->onView) {
         $qs[] = 'sex';
     }
     $qLocation = BOL_QuestionService::getInstance()->findQuestionByName('googlemap_location');
     if ($qLocation->onView) {
         $qs[] = 'googlemap_location';
     }
     $questionList = BOL_QuestionService::getInstance()->getQuestionData(array($userId), $qs);
     $question = $questionList[$userId];
     if (!empty($question['birthdate'])) {
         $date = UTIL_DateTime::parseDate($question['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
         $fields['age'] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
     }
     $sexValue = '';
     if (!empty($question['sex'])) {
         $sex = $question['sex'];
         for ($i = 0; $i < 31; $i++) {
             $val = pow(2, $i);
             if ((int) $sex & $val) {
                 $sexValue .= BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $val) . ', ';
             }
         }
         if (!empty($sexValue)) {
             $fields['sex'] = substr($sexValue, 0, -2);
         }
     }
     if (!empty($question['googlemap_location'])) {
         $fields['googlemap_location'] = $question['googlemap_location']['address'];
     }
     return $fields;
 }
Exemplo n.º 18
0
 public function getFields($userIdList)
 {
     $fields = array();
     $qs = array();
     $qBdate = BOL_QuestionService::getInstance()->findQuestionByName('birthdate');
     if ($qBdate->onView) {
         $qs[] = 'birthdate';
     }
     $qSex = BOL_QuestionService::getInstance()->findQuestionByName('sex');
     if ($qSex->onView) {
         $qs[] = 'sex';
     }
     $qLocation = BOL_QuestionService::getInstance()->findQuestionByName('googlemap_location');
     if ($qLocation && $qLocation->onView) {
         $qs[] = 'googlemap_location';
     }
     //        if ( $this->listType == 'details' )
     //        {
     //            $qs[] = 'aboutme';
     //        }
     $questionList = BOL_QuestionService::getInstance()->getQuestionData($userIdList, $qs);
     $matchCompatibility = array();
     if ($this->orderType == USEARCH_BOL_Service::LIST_ORDER_MATCH_COMPATIBILITY) {
         if (OW::getPluginManager()->isPluginActive('matchmaking') && OW::getUser()->isAuthenticated()) {
             $maxCompatibility = MATCHMAKING_BOL_QuestionMatchDao::getInstance()->getMaxPercentValue();
             $matchCompatibilityList = MATCHMAKING_BOL_Service::getInstance()->findCompatibilityByUserIdList(OW::getUser()->getId(), $userIdList, 0, 1000);
             foreach ($matchCompatibilityList as $compatibility) {
                 $matchCompatibility[$compatibility['userId']] = (int) ($compatibility['compatibility'] / $maxCompatibility * 100);
             }
         }
     }
     foreach ($questionList as $uid => $q) {
         $fields[$uid] = array();
         $age = '';
         if (!empty($q['birthdate'])) {
             $date = UTIL_DateTime::parseDate($q['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         }
         if (!empty($q['sex'])) {
             $sex = $q['sex'];
             $sexValue = '';
             for ($i = 0; $i < 31; $i++) {
                 $val = pow(2, $i);
                 if ((int) $sex & $val) {
                     $sexValue .= BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $val) . ', ';
                 }
             }
             if (!empty($sexValue)) {
                 $sexValue = substr($sexValue, 0, -2);
             }
         }
         if (!empty($sexValue) && !empty($age)) {
             $fields[$uid]['base'][] = array('label' => '', 'value' => $sexValue . ' ' . $age);
         }
         if (!empty($q['aboutme'])) {
             $fields[$uid]['aboutme'] = array('label' => '', 'value' => $q['aboutme']);
         }
         if (!empty($q['googlemap_location']['address'])) {
             $fields[$uid]['location'] = array('label' => '', 'value' => $q['googlemap_location']['address']);
         }
         if (isset($matchCompatibility[$uid])) {
             $fields[$uid]['match_compatibility'] = array('label' => '', 'value' => $matchCompatibility[$uid] . '%');
         }
         if ($this->orderType == USEARCH_BOL_Service::LIST_ORDER_DISTANCE) {
             if (OW::getPluginManager()->isPluginActive('googlelocation') && !empty($q['googlemap_location']) && !empty($this->location)) {
                 $event = new OW_Event('googlelocation.calc_distance', array('lat' => $this->location['latitude'], 'lon' => $this->location['longitude'], 'lat1' => $q['googlemap_location']['latitude'], 'lon1' => $q['googlemap_location']['longitude']));
                 OW::getEventManager()->trigger($event);
                 $data = $event->getData();
                 if ($data['units'] == 'miles') {
                     $html = '&nbsp;<span>' . OW::getLanguage()->text('usearch', 'miles') . '</span>';
                 } else {
                     $html = '&nbsp;<span>' . OW::getLanguage()->text('usearch', 'kms') . '</span>';
                 }
                 $fields[$uid]['distance'] = array('label' => '', 'value' => $data['distance'] . $html);
             }
         }
     }
     return $fields;
 }
 public function prepareFieldValue($presentation, $value)
 {
     if (empty($value)) {
         return $value;
     }
     $result = $value;
     switch ($presentation) {
         case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
             $result = !empty($value);
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
         case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
         case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
             $date = UTIL_DateTime::parseDate($value, UTIL_DateTime::DEFAULT_DATE_FORMAT);
             if (!isset($date)) {
                 $date = UTIL_DateTime::parseDate($value, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             }
             if (isset($date)) {
                 $result = $date['year'] . '/' . $date['month'] . '/' . $date['day'];
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
             $data = array();
             $multicheckboxValue = (int) $value;
             for ($i = 0; $i < 31; $i++) {
                 $val = (int) pow(2, $i);
                 if ($val & $multicheckboxValue) {
                     $data[] = $val;
                 }
             }
             $result = $data;
             break;
     }
     return $result;
 }
Exemplo n.º 20
0
/**
 * Smarty printVar function for debugging purposes
 * 
 * @param mixed var
 * @package OW_Smarty $smarty
 */
function smarty_function_age($params, $smarty)
{
    $date = UTIL_DateTime::parseDate($params['dateTime'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
    return UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
}
Exemplo n.º 21
0
 public function getUserListFields(OW_Event $e)
 {
     $params = $e->getParams();
     $list = !empty($params['list']) ? $params['list'] : null;
     $userIdList = !empty($params['userIdList']) ? $params['userIdList'] : null;
     if (empty($userIdList)) {
         return;
     }
     $fieldsList = array();
     $qBirthdate = BOL_QuestionService::getInstance()->findQuestionByName('birthdate');
     if ($qBirthdate->onView) {
         $fieldsList[] = 'birthdate';
     }
     $qSex = BOL_QuestionService::getInstance()->findQuestionByName('sex');
     if ($qSex->onView) {
         $fieldsList[] = 'sex';
     }
     $questionList = BOL_QuestionService::getInstance()->findQuestionByNameList($fieldsList);
     $qData = BOL_QuestionService::getInstance()->getQuestionData($userIdList, $fieldsList);
     $data = $e->getData();
     foreach ($userIdList as $userId) {
         $questionsData = $qData[$userId];
         $age = '';
         if (!empty($questionsData['birthdate'])) {
             $date = UTIL_DateTime::parseDate($questionsData['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         }
         $sexValue = '';
         if (!empty($questionsData['sex'])) {
             $sexValue = BOL_QuestionService::getInstance()->getQuestionValueForUserList($questionList['sex'], $questionsData['sex']);
         }
         if (!empty($sexValue) && !empty($age)) {
             $data[$userId][] = $sexValue . ' ' . $age;
         }
         switch ($list) {
             case "birthdays":
                 if (!empty($questionsData['birthdate']) && $list == 'birthdays') {
                     $dinfo = date_parse($questionsData['birthdate']);
                     $birthdate = '';
                     if (intval(date('d')) + 1 == intval($dinfo['day'])) {
                         $birthday = OW::getLanguage()->text('base', 'date_time_tomorrow');
                         $birthdate = '<a href="#" class="ow_lbutton ow_green">' . $birthday . '</a>';
                     } else {
                         if (intval(date('d')) == intval($dinfo['day'])) {
                             $birthday = OW::getLanguage()->text('base', 'date_time_today');
                             $birthdate = '<a href="#" class="ow_lbutton ow_green">' . $birthday . '</a>';
                         } else {
                             $birthdate = UTIL_DateTime::formatBirthdate($dinfo['year'], $dinfo['month'], $dinfo['day']);
                         }
                     }
                     $data[$userId][] = OW::getLanguage()->text('birthdays', 'birthday') . ":" . $birthdate;
                 }
                 break;
         }
     }
     $e->setData($data);
 }
Exemplo n.º 22
0
 public function getList($params)
 {
     $service = SKANDROID_ABOL_Service::getInstance();
     $auth = array('photo_view' => $service->getAuthorizationActionStatus('photo', 'view'), 'base_search_users' => $service->getAuthorizationActionStatus('base', 'search_users'));
     $this->assign('auth', $auth);
     if ($auth["base_search_users"]["status"] != BOL_AuthorizationService::STATUS_AVAILABLE) {
         $this->assign("list", array());
         $this->assign("total", 0);
         return;
     }
     $_criteriaList = array_filter(json_decode($params["criteriaList"], true));
     $userId = OW::getUser()->getId();
     $userInfo = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array("sex", 'match_sex'));
     $_criteriaList["sex"] = !empty($userInfo[$userId]["sex"]) ? $userInfo[$userId]["sex"] : null;
     if (OW::getPluginManager()->isPluginActive('googlelocation')) {
         $location = null;
         $json = null;
         if (!empty($_criteriaList["current_location"]) && $_criteriaList["current_location"] != "false" && !empty($_criteriaList["current_location_address"])) {
             $location = !empty($_criteriaList["current_location_address"]) ? json_decode($_criteriaList["current_location_address"], true) : null;
             $json = $_criteriaList["current_location_address"];
         } else {
             if (!empty($_criteriaList["custom_location"])) {
                 $location = !empty($_criteriaList["custom_location"]) ? json_decode($_criteriaList["custom_location"], true) : null;
                 $json = $_criteriaList["custom_location"];
             }
         }
         if (!empty($location)) {
             $value = array('distance' => !empty($_criteriaList['distance']) ? $_criteriaList['distance'] : 0, 'address' => $location['address'], 'latitude' => $location['latitude'], 'longitude' => $location['longitude'], 'northEastLat' => $location['northEastLat'], 'northEastLng' => $location['northEastLng'], 'southWestLat' => $location['southWestLat'], 'southWestLng' => $location['southWestLng'], 'json' => $json);
             $_criteriaList['googlemap_location'] = $value;
         }
     }
     unset($_criteriaList["current_location"]);
     unset($_criteriaList["current_location_address"]);
     unset($_criteriaList["custom_location"]);
     $questionList = BOL_QuestionService::getInstance()->findQuestionByNameList(array_keys($_criteriaList));
     $criteriaList = array();
     foreach ($_criteriaList as $questionName => $questionValue) {
         if (empty($questionList[$questionName])) {
             continue;
         }
         $criteriaList[$questionName] = $this->convertQuestionValue($questionList[$questionName]->presentation, $questionValue);
     }
     if (empty($criteriaList['match_sex']) && !empty($userInfo[$userId]["match_sex"])) {
         $criteriaList['match_sex'] = $userInfo[$userId]["match_sex"];
     }
     $idList = OW::getEventManager()->call("usearch.get_user_id_list_for_android", array("criterias" => $criteriaList, "limit" => array($params["first"], $params["count"])));
     $idList = empty($idList) ? array() : $idList;
     //$idList = BOL_UserService::getInstance()->findUserIdListByQuestionValues($criteriaList, $params["first"], $params["count"]);
     $total = BOL_UserService::getInstance()->countUsersByQuestionValues($criteriaList);
     //$idList = empty($idList) ? array() : $idList;
     $userData = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, false, false, true, true);
     $questionsData = BOL_QuestionService::getInstance()->getQuestionData($idList, array("googlemap_location", "birthdate"));
     $displayNames = BOL_UserService::getInstance()->getDisplayNamesForList($idList);
     foreach ($questionsData as $userId => $data) {
         $date = UTIL_DateTime::parseDate($data['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
         $userData[$userId]["ages"] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         $userData[$userId]["location"] = empty($data["googlemap_location"]["address"]) ? null : $data["googlemap_location"]["address"];
     }
     $photoList = array();
     $avatars = array();
     foreach ($idList as $userId) {
         $bigAvatar = SKADATE_BOL_Service::getInstance()->findAvatarByUserId($userId);
         $event = new OW_Event('photo.getMainAlbum', array('userId' => $userId));
         OW::getEventManager()->trigger($event);
         $album = $event->getData();
         $photos = !empty($album['photoList']) ? $album['photoList'] : array();
         if ($bigAvatar) {
             $avatars[$userId] = SKADATE_BOL_Service::getInstance()->getAvatarUrl($userId, $bigAvatar->hash);
         } else {
             $avatars[$userId] = BOL_AvatarService::getInstance()->getAvatarUrl($userId, 2);
             if ($avatars[$userId] == BOL_AvatarService::getInstance()->getDefaultAvatarUrl(2)) {
                 unset($avatars[$userId]);
             }
         }
         foreach ($photos as $photo) {
             if ($photo['status'] == PHOTO_BOL_PhotoDao::STATUS_APPROVED) {
                 $photoList[$userId][] = array("src" => $photo["url"]["main"]);
             }
         }
     }
     $bookmarksList = OW::getEventManager()->call("bookmarks.get_mark_list", array("userId" => OW::getUser()->getId(), "idList" => $idList));
     $bookmarksList = empty($bookmarksList) ? array() : $bookmarksList;
     $list = array();
     foreach ($idList as $userId) {
         $list[] = array("userId" => $userId, "avatar" => !empty($avatars[$userId]) ? $avatars[$userId] : "", "photos" => empty($photoList[$userId]) ? array() : $photoList[$userId], "name" => empty($userData[$userId]["title"]) ? "" : $userData[$userId]["title"], "displayName" => !empty($displayNames[$userId]) ? $displayNames[$userId] : "", "label" => $userData[$userId]["label"], "labelColor" => $userData[$userId]["labelColor"], "location" => empty($userData[$userId]["location"]) ? "" : $userData[$userId]["location"], "ages" => $userData[$userId]["ages"], "bookmarked" => !empty($bookmarksList[$userId]));
     }
     $this->assign("list", $list);
     $this->assign("total", $total);
     BOL_AuthorizationService::getInstance()->trackAction("base", "search_users");
 }
Exemplo n.º 23
0
 public function getUserViewQuestions($userId, $adminMode = false, $questionNames = array(), $sectionNames = null)
 {
     $questionService = BOL_QuestionService::getInstance();
     $user = BOL_UserService::getInstance()->findUserById($userId);
     $accountType = $user->accountType;
     $language = OW::getLanguage();
     if (empty($questionNames)) {
         if ($adminMode) {
             $questions = $questionService->findAllQuestionsForAccountType($accountType);
         } else {
             $questions = $questionService->findViewQuestionsForAccountType($accountType);
         }
     } else {
         $questions = $questionService->findQuestionByNameList($questionNames);
         foreach ($questions as &$q) {
             $q = (array) $q;
         }
     }
     $section = null;
     $questionArray = array();
     $questionNameList = array();
     foreach ($questions as $sort => $question) {
         if (!empty($sectionNames) && !in_array($question['sectionName'], $sectionNames)) {
             continue;
         }
         if ($section !== $question['sectionName']) {
             $section = $question['sectionName'];
         }
         $questions[$sort]['hidden'] = false;
         if (!$questions[$sort]['onView']) {
             $questions[$sort]['hidden'] = true;
         }
         $questionArray[$section][$sort] = $questions[$sort];
         $questionNameList[] = $questions[$sort]['name'];
     }
     $questionData = $questionService->getQuestionData(array($userId), $questionNameList);
     $questionLabelList = array();
     // add form fields
     foreach ($questionArray as $sectionKey => $section) {
         foreach ($section as $questionKey => $question) {
             $event = new OW_Event('base.questions_field_get_label', array('presentation' => $question['presentation'], 'fieldName' => $question['name'], 'configs' => $question['custom'], 'type' => 'view'));
             OW::getEventManager()->trigger($event);
             $label = $event->getData();
             $questionLabelList[$question['name']] = !empty($label) ? $label : BOL_QuestionService::getInstance()->getQuestionLang($question['name']);
             $event = new OW_Event('base.questions_field_get_value', array('presentation' => $question['presentation'], 'fieldName' => $question['name'], 'value' => empty($questionData[$userId][$question['name']]) ? null : $questionData[$userId][$question['name']], 'questionInfo' => $question, 'userId' => $userId));
             OW::getEventManager()->trigger($event);
             $eventValue = $event->getData();
             if (!empty($eventValue)) {
                 $questionData[$userId][$question['name']] = $eventValue;
                 continue;
             }
             if (!empty($questionData[$userId][$question['name']])) {
                 switch ($question['presentation']) {
                     case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
                         if ((int) $questionData[$userId][$question['name']] === 1) {
                             $questionData[$userId][$question['name']] = OW::getLanguage()->text('base', 'yes');
                         } else {
                             unset($questionArray[$sectionKey][$questionKey]);
                         }
                         break;
                     case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
                         $format = OW::getConfig()->getValue('base', 'date_field_format');
                         $value = 0;
                         switch ($question['type']) {
                             case BOL_QuestionService::QUESTION_VALUE_TYPE_DATETIME:
                                 $date = UTIL_DateTime::parseDate($questionData[$userId][$question['name']], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
                                 if (isset($date)) {
                                     $format = OW::getConfig()->getValue('base', 'date_field_format');
                                     $value = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
                                 }
                                 break;
                             case BOL_QuestionService::QUESTION_VALUE_TYPE_SELECT:
                                 $value = (int) $questionData[$userId][$question['name']];
                                 break;
                         }
                         if ($format === 'dmy') {
                             $questionData[$userId][$question['name']] = date("d/m/Y", $value);
                         } else {
                             $questionData[$userId][$question['name']] = date("m/d/Y", $value);
                         }
                         break;
                     case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
                         $date = UTIL_DateTime::parseDate($questionData[$userId][$question['name']], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
                         $questionData[$userId][$question['name']] = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
                         break;
                     case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
                         $date = UTIL_DateTime::parseDate($questionData[$userId][$question['name']], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
                         $questionData[$userId][$question['name']] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']) . " " . $language->text('base', 'questions_age_year_old');
                         break;
                     case BOL_QuestionService::QUESTION_PRESENTATION_RANGE:
                         $range = explode('-', $questionData[$userId][$question['name']]);
                         $questionData[$userId][$question['name']] = $language->text('base', 'form_element_from') . " " . $range[0] . " " . $language->text('base', 'form_element_to') . " " . $range[1];
                         break;
                     case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
                     case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
                     case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
                         $value = "";
                         $multicheckboxValue = (int) $questionData[$userId][$question['name']];
                         $parentName = $question['name'];
                         if (!empty($question['parent'])) {
                             $parent = BOL_QuestionService::getInstance()->findQuestionByName($question['parent']);
                             if (!empty($parent)) {
                                 $parentName = $parent->name;
                             }
                         }
                         $questionValues = BOL_QuestionService::getInstance()->findQuestionValues($parentName);
                         $value = array();
                         foreach ($questionValues as $val) {
                             /* @var $val BOL_QuestionValue */
                             if ((int) $val->value & $multicheckboxValue) {
                                 /* if ( strlen($value) > 0 )
                                                                       {
                                                                       $value .= ', ';
                                                                       }
                                 
                                                                       $value .= $language->text('base', 'questions_question_' . $parentName . '_value_' . ($val->value)); */
                                 $value[$val->value] = BOL_QuestionService::getInstance()->getQuestionValueLang($val->questionName, $val->value);
                             }
                         }
                         if (!empty($value)) {
                             $questionData[$userId][$question['name']] = $value;
                         } else {
                             unset($questionArray[$sectionKey][$questionKey]);
                         }
                         break;
                     case BOL_QuestionService::QUESTION_PRESENTATION_URL:
                     case BOL_QuestionService::QUESTION_PRESENTATION_TEXT:
                     case BOL_QuestionService::QUESTION_PRESENTATION_TEXTAREA:
                         if (!is_string($questionData[$userId][$question['name']])) {
                             break;
                         }
                         $value = trim($questionData[$userId][$question['name']]);
                         if (strlen($value) > 0) {
                             $questionData[$userId][$question['name']] = UTIL_HtmlTag::autoLink(nl2br($value));
                         } else {
                             unset($questionArray[$sectionKey]);
                         }
                         break;
                     default:
                         unset($questionArray[$sectionKey][$questionKey]);
                 }
             } else {
                 unset($questionArray[$sectionKey][$questionKey]);
             }
         }
         if (isset($questionArray[$sectionKey]) && count($questionArray[$sectionKey]) === 0) {
             unset($questionArray[$sectionKey]);
         }
     }
     return array('questions' => $questionArray, 'data' => $questionData, 'labels' => $questionLabelList);
 }
Exemplo n.º 24
0
 private function getQuestionWhereString(BOL_Question $question, $value, $prefix = '')
 {
     $result = '';
     $prefix = $this->dbo->escapeString($prefix);
     /* $event = new OW_Event('base.questions_get_search_sql', array(
               'presentation' => $question->presentation,
               'fieldName' => $question->name,
               'value' => $value,
               'tablePrefix' => $prefix,
               'questionDto' => $question
               ));
     
               OW::getEventManager()->trigger($event);
     
               $result = $event->getData();
     
               if ( !empty($result) )
               {
               return $result;
               } */
     switch ($question->presentation) {
         case BOL_QuestionService::QUESTION_PRESENTATION_URL:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXT:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXTAREA:
             $result = " LCASE(`" . $prefix . "`.`textValue`) LIKE '" . $this->dbo->escapeString(strtolower($value)) . "%'";
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
             $result = " `" . $prefix . "`.`intValue` = " . (bool) $value;
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
         case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
             if (!empty($value)) {
                 if (is_array($value)) {
                     $result = ' `' . $this->dbo->escapeString($prefix) . '`.`intValue` IN ( ' . $this->dbo->mergeInClause($value) . ') ';
                 } else {
                     if ((int) $value > 0) {
                         $result = ' `' . $this->dbo->escapeString($prefix) . '`.`intValue` & \'' . (int) $value . '\' ';
                     }
                 }
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
             if (!empty($value)) {
                 if (is_array($value)) {
                     $result = " `" . $prefix . "`.`intValue` & '" . $this->dbo->escapeString(array_sum($value)) . "'";
                 } else {
                     if ((int) $value > 0) {
                         $result = " `" . $prefix . "`.`intValue` & '" . (int) $value . "'";
                     }
                 }
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
         case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
             if (isset($value['from']) && isset($value['to'])) {
                 $maxDate = date('Y') - (int) $value['from'] . '-12-31';
                 $minDate = date('Y') - (int) $value['to'] . '-01-01';
                 $result = " `" . $prefix . "`.`dateValue` BETWEEN  '" . $this->dbo->escapeString($minDate) . "' AND '" . $this->dbo->escapeString($maxDate) . "'";
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
             $dateFrom = UTIL_DateTime::parseDate($value['from']);
             $dateTo = UTIL_DateTime::parseDate($value['to']);
             if (isset($dateFrom)) {
                 if (UTIL_Validator::isDateValid($dateFrom[UTIL_DateTime::PARSE_DATE_MONTH], $dateFrom[UTIL_DateTime::PARSE_DATE_DAY], $dateFrom[UTIL_DateTime::PARSE_DATE_YEAR])) {
                     $valueFrom = $dateFrom[UTIL_DateTime::PARSE_DATE_YEAR] . '-' . $dateFrom[UTIL_DateTime::PARSE_DATE_MONTH] . '-' . $dateFrom[UTIL_DateTime::PARSE_DATE_DAY];
                 }
             }
             if (isset($dateTo)) {
                 if (UTIL_Validator::isDateValid($dateTo[UTIL_DateTime::PARSE_DATE_MONTH], $dateTo[UTIL_DateTime::PARSE_DATE_DAY], $dateTo[UTIL_DateTime::PARSE_DATE_YEAR])) {
                     $valueTo = $dateTo[UTIL_DateTime::PARSE_DATE_YEAR] . '-' . $dateTo[UTIL_DateTime::PARSE_DATE_MONTH] . '-' . $dateTo[UTIL_DateTime::PARSE_DATE_DAY];
                 }
             }
             if (isset($valueFrom) && isset($valueTo)) {
                 $result = " `" . $prefix . "`.`dateValue` BETWEEN  '" . $valueFrom . "' AND '" . $valueTo . "'";
             }
             break;
     }
     return $result;
 }
Exemplo n.º 25
0
 public function checkValue($value)
 {
     if ($value === null || mb_strlen(trim($value)) === 0) {
         return true;
     }
     $date = UTIL_DateTime::parseDate($value, $this->dateFormat);
     if ($date === null) {
         return false;
     }
     if (!UTIL_Validator::isDateValid($date[UTIL_DateTime::PARSE_DATE_MONTH], $date[UTIL_DateTime::PARSE_DATE_DAY], $date[UTIL_DateTime::PARSE_DATE_YEAR])) {
         return false;
     }
     if (!empty($this->maxYear) && $date[UTIL_DateTime::PARSE_DATE_YEAR] > $this->maxYear) {
         return false;
     }
     if (!empty($this->minYear) && $date[UTIL_DateTime::PARSE_DATE_YEAR] < $this->minYear) {
         return false;
     }
     return true;
 }
Exemplo n.º 26
0
 public function getList($params)
 {
     $viewerId = !empty($params['userId']) ? $params['userId'] : OW::getUser()->getId();
     $first = empty($params['first']) ? 0 : $params['first'];
     $count = empty($params['count']) ? self::COUNT_LIST : $params['count'];
     $exclude = empty($params['exclude']) ? array() : json_decode($params['exclude']);
     $filter = empty($params['filter']) ? array() : json_decode($params['filter'], true);
     $validFilter = $this->getValidFilter($filter);
     $status = SKANDROID_ABOL_Service::getInstance()->getAuthorizationActionStatus('base', 'view_profile');
     if ($status['status'] != BOL_AuthorizationService::STATUS_AVAILABLE) {
         $this->assign('authorized', false);
         $this->assign('promoted', $status['status'] == BOL_AuthorizationService::STATUS_PROMOTED);
         $this->assign('authorizeMsg', $status['msg']);
         return;
     }
     $this->assign('authorized', true);
     if (empty($filter['match_sex_data'])) {
         $question = BOL_QuestionService::getInstance()->findQuestionByName('match_sex');
         $values = $_filter = array();
         foreach (BOL_QuestionService::getInstance()->findQuestionValues('match_sex') as $value) {
             $values[] = array('id' => $value->value, 'label' => BOL_QuestionService::getInstance()->getQuestionValueLang($value->questionName, $value->value));
         }
         if (in_array($question->presentation, array(BOL_QuestionService::QUESTION_PRESENTATION_SELECT, BOL_QuestionService::QUESTION_PRESENTATION_RADIO, BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX))) {
             foreach ($values as $val) {
                 if ($val['id'] & $validFilter['sex']) {
                     $_filter[] = $val['id'];
                 }
             }
         } else {
             $_filter[] = $validFilter['match_sex'];
         }
         $filter['match_sex'] = $_filter;
         $filter['match_sex_data'] = $values;
     }
     if (isset($validFilter['googlemap_location'])) {
         $filter['googlemap_location'] = $validFilter['googlemap_location'];
     }
     $filter['match_age'] = $validFilter['birthdate'];
     $this->assign('filter', $filter);
     //unset($validFilter['googlemap_location']);
     $userIdList = $this->getSpeedmatchUserIdList($viewerId, $first, $count, $validFilter, $exclude);
     if (empty($userIdList)) {
         $this->assign('list', array());
         return;
     }
     $userService = BOL_UserService::getInstance();
     $questionService = BOL_QuestionService::getInstance();
     $userList = $accountTypes = $compatibility = array();
     foreach ($userService->findUserListByIdList($userIdList) as $user) {
         $userList[$user->id] = $user;
         $accountTypes[] = $user->accountType;
     }
     if ($_compatibility = OW::getEventManager()->call('matchmaking.get_compatibility_for_list', array('userId' => $viewerId, 'idList' => $userIdList))) {
         foreach ($_compatibility as $userId => $c) {
             $compatibility[$userId] = (int) $c;
         }
     }
     $accountTypes = array_unique($accountTypes);
     $totalQuestions = $accountTypeQuestions = $matchQuestions = array();
     foreach ($accountTypes as $accountType) {
         $questionsForAccountType = $questionService->findViewQuestionsForAccountType($accountType);
         $questions = array();
         foreach ($this->priorityQuestions as $pq) {
             foreach ($questionsForAccountType as $qfa) {
                 if ($qfa['name'] == $pq) {
                     $questions[] = $qfa;
                     $this->forbiddenQuestions[] = $qfa['name'];
                     $matchQuestions[] = $qfa['name'];
                     break;
                 }
             }
         }
         foreach ($questionsForAccountType as $question) {
             if ($question['sectionName'] == 'about_my_match') {
                 $questions[] = $question;
                 $this->forbiddenQuestions[] = $question['name'];
                 if ($question['name'] == 'relationship') {
                     $matchQuestions[] = 'relationship';
                 }
             }
         }
         $questionsForAccountType = array_filter($questionsForAccountType, array($this, 'filterQuestionForAccount'));
         $questionsForAccountType = array_merge($questions, $questionsForAccountType);
         $accountTypeQuestions[$accountType] = $questionsForAccountType;
         $totalQuestions = array_merge($totalQuestions, $accountTypeQuestions[$accountType]);
     }
     $totalQuestions = array_unique(array_map(array($this, 'filterTotalQuestion'), $totalQuestions));
     $displayNameList = $userService->getDisplayNamesForList($userIdList);
     $avatarList = array();
     $skadateService = SKADATE_BOL_Service::getInstance();
     foreach ($skadateService->findAvatarListByUserIdList($userIdList) as $avatar) {
         $avatarList[$avatar->userId] = $skadateService->getAvatarUrl($avatar->userId, $avatar->hash);
     }
     $avatarService = BOL_AvatarService::getInstance();
     $avatarList += $avatarService->getAvatarsUrlList(array_diff($userIdList, array_keys($avatarList)), 2);
     $avatarList = array_filter($avatarList, array($this, 'filterAvatarList'));
     $onlineStatus = BOL_UserService::getInstance()->findOnlineStatusForUserList($userIdList);
     $questionsData = $questionService->getQuestionData($userIdList, array_merge($totalQuestions, $this->baseQuestions));
     $userData = array();
     $authorizeMsg = '';
     $isAuthorized = $isSubscribe = OW::getUser()->isAuthorized('photo', 'view');
     if (!$isAuthorized) {
         $status = SKANDROID_ABOL_Service::getInstance()->getAuthorizationActionStatus('photo', 'view');
         $isSubscribe = $status['status'] == BOL_AuthorizationService::STATUS_PROMOTED;
         $authorizeMsg = $status['msg'];
     }
     foreach ($questionsData as $userId => $data) {
         $user = $userPhotos = array();
         if ($isAuthorized) {
             $event = new OW_Event('photo.getMainAlbum', array('userId' => $userId));
             OW::getEventManager()->trigger($event);
             $album = $event->getData();
             if (!empty($album['photoList'])) {
                 foreach ($album['photoList'] as $photo) {
                     if ($photo['status'] == PHOTO_BOL_PhotoDao::STATUS_APPROVED) {
                         $userPhotos[] = $photo['url']['main'];
                     }
                 }
             }
         }
         $user['userId'] = $userId;
         $user['isAuthorized'] = $isAuthorized;
         $user['isSubscribe'] = $isSubscribe;
         $user['authorizeMsg'] = $authorizeMsg;
         $user['isOnline'] = !empty($onlineStatus[$userId]);
         $user['displayName'] = $displayNameList[$userId];
         $user['location'] = empty($data['googlemap_location']['address']) ? '' : $data['googlemap_location']['address'];
         $date = UTIL_DateTime::parseDate($data['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
         $user['ages'] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
         $user['avatar'] = !empty($avatarList[$userId]) ? $avatarList[$userId] : null;
         $user['photos'] = $userPhotos;
         $user['compatibility'] = isset($compatibility[$userId]) ? $compatibility[$userId] : null;
         $user['info'] = array();
         $f = array();
         foreach ($accountTypeQuestions[$userList[$userId]->accountType] as $question) {
             if ($question['name'] == 'relationship' && array_search('relationship', $matchQuestions) !== false) {
                 continue;
             }
             $questionName = $question['name'];
             if (empty($data[$questionName]) || array_search($questionName, $f) !== false) {
                 continue;
             }
             $f[] = $questionName;
             $user['info'][] = $this->getUserInfo($userId, $question, $data[$questionName]);
         }
         $userData[] = $user;
     }
     $this->assign('list', $userData);
 }
Exemplo n.º 27
0
 /**
  * Sets form element value.
  *
  * @param mixed $value
  * @return FormElement
  */
 public function setValue($value)
 {
     $date = UTIL_DateTime::parseDate($value, $this->dateFormat);
     if (isset($date)) {
         $this->setDefaultDate($date['year'], $date['month'], $date['day']);
         $this->value = $value;
     }
     return $this;
 }
Exemplo n.º 28
0
 /**
  * Set field value
  *
  * @param FormElement $formField
  * @param string $presentation
  * @param string $value
  */
 protected function setFieldValue($formField, $presentation, $value)
 {
     switch ($presentation) {
         case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
             $formField->setValue(true);
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
         case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
         case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
             $date = UTIL_DateTime::parseDate($value, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             if (isset($date)) {
                 $formField->setValue($date['year'] . '/' . $date['month'] . '/' . $date['day']);
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
             $data = array();
             $multicheckboxValue = (int) $value;
             for ($i = 0; $i < 31; $i++) {
                 $val = (int) pow(2, $i);
                 if ($val & $multicheckboxValue) {
                     $data[] = $val;
                 }
             }
             $formField->setValue($data);
             break;
         default:
             $formField->setValue($value);
     }
 }
Exemplo n.º 29
0
function renderQuestion($userId, $questionName, $label = false)
{
    global $QuestionService;
    global $language;
    global $getConfig;
    global $QUESTION_PRESENTATION_SELECT;
    global $QUESTION_PRESENTATION_RADIO;
    global $QUESTION_PRESENTATION_MULTICHECKBOX;
    global $QUESTION_PRESENTATION_URL;
    global $QUESTION_PRESENTATION_TEXT;
    global $QUESTION_PRESENTATION_TEXTAREA;
    global $QUESTION_PRESENTATION_DATE;
    global $QUESTION_VALUE_TYPE_DATETIME;
    global $QUESTION_VALUE_TYPE_SELECT;
    global $QUESTION_PRESENTATION_BIRTHDATE;
    global $QUESTION_PRESENTATION_AGE;
    global $QUESTION_PRESENTATION_RANGE;
    global $MYSQL_DATETIME_DATE_FORMAT;
    $questionData = $QuestionService->getQuestionData(array($userId), array($questionName));
    if (!isset($questionData[$userId][$questionName])) {
        return null;
    }
    $question = $QuestionService->findQuestionByName($questionName);
    switch ($question->presentation) {
        case $QUESTION_PRESENTATION_DATE:
            $format = $getConfig->getValue('base', 'date_field_format');
            $value = 0;
            switch ($question->type) {
                case $QUESTION_VALUE_TYPE_DATETIME:
                    $date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], $MYSQL_DATETIME_DATE_FORMAT);
                    $value = $date;
                    break;
                case $QUESTION_VALUE_TYPE_SELECT:
                    $value = (int) $questionData[$userId][$question->name];
                    break;
            }
            if ($format === 'dmy') {
                $questionData[$userId][$question->name] = date("d/m/Y", $value);
            } else {
                $questionData[$userId][$question->name] = date("m/d/Y", $value);
            }
            break;
        case $QUESTION_PRESENTATION_BIRTHDATE:
            $date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], $MYSQL_DATETIME_DATE_FORMAT);
            $questionData[$userId][$question->name] = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
            break;
        case $QUESTION_PRESENTATION_AGE:
            $date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], $MYSQL_DATETIME_DATE_FORMAT);
            $questionData[$userId][$question->name] = date("Y/m/d", strtotime($date['year'] . "/" . $date['month'] . "/" . $date['day']));
            break;
        case $QUESTION_PRESENTATION_RANGE:
            $range = explode('-', $questionData[$userId][$question->name]);
            $questionData[$userId][$question->name] = $language->text('base', 'form_element_from') . " " . $range[0] . " " . $language->text('base', 'form_element_to') . " " . $range[1];
            break;
        case $QUESTION_PRESENTATION_SELECT:
        case $QUESTION_PRESENTATION_RADIO:
        case $QUESTION_PRESENTATION_MULTICHECKBOX:
            $value = "";
            $multicheckboxValue = (int) $questionData[$userId][$question->name];
            $questionValues = $QuestionService->findQuestionValues($question->name);
            foreach ($questionValues as $val) {
                /* @var $val BOL_QuestionValue */
                if ((int) $val->value & $multicheckboxValue) {
                    if ($label == false) {
                        if (strlen($value) > 0) {
                            $value .= ',';
                        }
                        $value .= $val->value;
                        //$language->text('base', 'questions_question_' . $question->name . '_value_' . ($val->value));
                    } else {
                        if (strlen($value) > 0) {
                            $value .= ',';
                            // $value .= '@@';
                        }
                        // $QuestionService = $QuestionService;
                        $value .= $QuestionService->getQuestionValueLang($question->name, $val->value);
                        //$language->text('base', 'questions_question_' . $question->name . '_value_' . ($val->value));
                    }
                }
            }
            if (strlen($value) > 0) {
                $questionData[$userId][$question->name] = $value;
            }
            break;
        case $QUESTION_PRESENTATION_URL:
        case $QUESTION_PRESENTATION_TEXT:
        case $QUESTION_PRESENTATION_TEXTAREA:
            // googlemap_location shortcut
            if ($question->name == "googlemap_location" && !empty($questionData[$userId][$question->name]) && is_array($questionData[$userId][$question->name])) {
                $mapData = $questionData[$userId][$question->name];
                $value = trim($mapData["address"]);
            } else {
                $value = trim($questionData[$userId][$question->name]);
            }
            if (strlen($value) > 0) {
                $questionData[$userId][$question->name] = UTIL_HtmlTag::autoLink(nl2br($value));
            }
            break;
        default:
            $questionData[$userId][$question->name] = null;
    }
    return $questionData[$userId][$question->name];
}
Exemplo n.º 30
0
 public function getQuestionValueForUserList(BOL_Question $question, $value)
 {
     $stringValue = "";
     switch ($question->presentation) {
         case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
             if ((int) $value === 1) {
                 $stringValue = OW::getLanguage()->text('base', 'yes');
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
             $format = OW::getConfig()->getValue('base', 'date_field_format');
             $value = 0;
             switch ($question->type) {
                 case BOL_QuestionService::QUESTION_VALUE_TYPE_DATETIME:
                     $date = UTIL_DateTime::parseDate($value, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
                     if (isset($date)) {
                         $stringValue = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
                     }
                     break;
                 case BOL_QuestionService::QUESTION_VALUE_TYPE_SELECT:
                     $stringValue = (int) $value;
                     break;
             }
             if ($format === 'dmy') {
                 $stringValue = date("d/m/Y", $value);
             } else {
                 $stringValue = date("m/d/Y", $value);
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
             $date = UTIL_DateTime::parseDate($value, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $stringValue = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
             $date = UTIL_DateTime::parseDate($alue, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $stringValue = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']) . " " . $language->text('base', 'questions_age_year_old');
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_RANGE:
             $range = explode('-', $value);
             $stringValue = $language->text('base', 'form_element_from') . " " . $range[0] . " " . $language->text('base', 'form_element_to') . " " . $range[1];
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
         case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
         case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
             $multicheckboxValue = (int) $value;
             $parentName = $question->name;
             if (!empty($question->parent)) {
                 $parent = BOL_QuestionService::getInstance()->findQuestionByName($question->parent);
                 if (!empty($parent)) {
                     $parentName = $parent->name;
                 }
             }
             $questionValues = BOL_QuestionService::getInstance()->findQuestionValues($parentName);
             foreach ($questionValues as $val) {
                 /* @var $val BOL_QuestionValue */
                 if ((int) $val->value & $multicheckboxValue) {
                     $stringValue .= BOL_QuestionService::getInstance()->getQuestionValueLang($val->questionName, $val->value) . ', ';
                 }
             }
             if (!empty($stringValue)) {
                 $stringValue = mb_substr($stringValue, 0, -2);
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_URL:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXT:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXTAREA:
             if (!is_string($value)) {
                 break;
             }
             $value = trim($value);
             if (strlen($value) > 0) {
                 $stringValue = UTIL_HtmlTag::autoLink(nl2br($value));
             }
             break;
     }
     return $stringValue;
 }