Example #1
0
 /**
  * 
  * @return BOOKMARKS_BOL_Service
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Example #2
0
 public function __construct()
 {
     parent::__construct();
     if (!OW::getUser()->isAuthenticated()) {
         throw new AuthenticateException();
     }
     $sortCtrl = new BASE_CMP_SortControl();
     $sortCtrl->addItem(BOOKMARKS_BOL_Service::LIST_LATEST, OW::getLanguage()->text('bookmarks', 'latest'), OW::getRouter()->urlForRoute('bookmarks.list', array('category' => BOOKMARKS_BOL_Service::LIST_LATEST)));
     $sortCtrl->addItem(BOOKMARKS_BOL_Service::LIST_ONLINE, OW::getLanguage()->text('bookmarks', 'online'), OW::getRouter()->urlForRoute('bookmarks.list', array('category' => BOOKMARKS_BOL_Service::LIST_ONLINE)));
     $this->addComponent('sort', $sortCtrl);
     $this->service = BOOKMARKS_BOL_Service::getInstance();
 }
Example #3
0
 public function getData(BASE_CLASS_WidgetParameter $params)
 {
     $count = (int) $params->customParamList['count'];
     $service = BOOKMARKS_BOL_Service::getInstance();
     $userId = $params->additionalParamList['entityId'];
     $toolbar = array('latest' => array('label' => OW::getLanguage()->text('bookmarks', 'view_all'), 'href' => OW::getRouter()->urlForRoute('bookmarks.list', array('category' => BOOKMARKS_BOL_Service::LIST_LATEST))), 'online' => array('label' => OW::getLanguage()->text('bookmarks', 'view_all'), 'href' => OW::getRouter()->urlForRoute('bookmarks.list', array('category' => BOOKMARKS_BOL_Service::LIST_ONLINE))));
     $bookmarksCount = $service->findBookmarksCount($userId);
     $onlineCount = $service->findBookmarksCount($userId, BOOKMARKS_BOL_Service::LIST_ONLINE);
     if ($bookmarksCount > $count) {
         $this->setSettingValue(self::SETTING_TOOLBAR, array($toolbar['latest']));
     }
     $resultList = array('latest' => array('menu-label' => OW::getLanguage()->text('bookmarks', 'latest'), 'menu_active' => true, 'userIds' => $service->findBookmarksUserIdList($userId, 0, $count), 'toolbar' => $bookmarksCount > $count ? array($toolbar['latest']) : false), 'online' => array('menu-label' => OW::getLanguage()->text('bookmarks', 'online'), 'userIds' => $service->findBookmarksUserIdList($userId, 0, $count, BOOKMARKS_BOL_Service::LIST_ONLINE), 'toolbar' => $onlineCount > $count ? array($toolbar['online']) : false));
     return $resultList;
 }
Example #4
0
 public function sendNotify()
 {
     $interval = (int) OW::getConfig()->getValue('bookmarks', 'notify_interval');
     if (empty($interval)) {
         return;
     }
     $service = BOOKMARKS_BOL_Service::getInstance();
     $activityStamp = $interval * 86400;
     $timestamp = time() - $activityStamp;
     $service->cleareExpiredNotifyLog($timestamp);
     $users = $service->findUserIdListForNotify($timestamp, 0, BOOKMARKS_BOL_Service::COUNT_CRON_USER);
     if (!empty($users)) {
         foreach ($users as $user) {
             if ($service->sendNotifyForUser($user)) {
                 $service->notifyLogSave($user);
             }
         }
     }
 }
Example #5
0
 public function __construct()
 {
     parent::__construct();
     $this->service = BOOKMARKS_BOL_Service::getInstance();
 }
Example #6
0
 public function getQuestions($params)
 {
     if (empty($params['userId'])) {
         throw new ApiResponseErrorException();
     }
     $userId = (int) $params['userId'];
     $user = BOL_UserService::getInstance()->findUserById($userId);
     if (!$user) {
         throw new ApiResponseErrorException();
     }
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $questionService = BOL_QuestionService::getInstance();
     $accountType = OW::getUser()->getUserObject()->accountType;
     $viewQuestionList = $questionService->findViewQuestionsForAccountType($accountType);
     $viewNames = array();
     foreach ($viewQuestionList as $viewQuestion) {
         $viewNames[] = $viewQuestion['name'];
     }
     $viewQuestionList = BOL_UserService::getInstance()->getUserViewQuestions($userId, false, $viewNames);
     $viewSections = array();
     $sortedSections = $questionService->findSortedSectionList();
     foreach ($viewQuestionList['questions'] as $sectionName => $section) {
         if ($sectionName == 'location') {
             continue;
         }
         $order = 0;
         foreach ($sortedSections as $sorted) {
             if ($sorted->name == $sectionName) {
                 $order = $sorted->sortOrder;
             }
         }
         $viewSections[] = array('order' => $order, 'name' => $sectionName, 'label' => $questionService->getSectionLang($sectionName));
     }
     usort($viewSections, array('SKADATEIOS_ACTRL_User', 'sortByOrder'));
     $viewQuestions = array();
     $viewBasic = array();
     $data = $viewQuestionList['data'][$userId];
     foreach ($viewQuestionList['questions'] as $sectName => $section) {
         $sectionQuestions = array();
         foreach ($section as $question) {
             $name = $question['name'];
             if (is_array($data[$name])) {
                 $values = array();
                 foreach ($data[$name] as $val) {
                     $values[] = strip_tags($val);
                 }
             } else {
                 $values = strip_tags($data[$name]);
             }
             if (in_array($name, self::$basicNames)) {
                 if ($name == 'sex') {
                     $v = array_values($values);
                     $viewBasic[$name] = array_shift($v);
                 } else {
                     $viewBasic[$name] = $values;
                 }
             } else {
                 $sectionQuestions[] = array('id' => $question['id'], 'name' => $name, 'label' => $questionService->getQuestionLang($name), 'value' => $values, 'section' => $sectName, 'presentation' => $name == 'googlemap_location' ? $name : $question['presentation'], 'order' => $question["sortOrder"]);
             }
         }
         usort($sectionQuestions, array('SKADATEIOS_ACTRL_User', 'sortByOrder'));
         $viewQuestions[$sectName] = $sectionQuestions;
     }
     $viewBasic['online'] = (bool) BOL_UserService::getInstance()->findOnlineUserById($userId);
     $viewBasic['avatar'] = self::dataForUserAvatar($userId);
     $viewBasic["displayName"] = BOL_UserService::getInstance()->getDisplayName($userId);
     // compatibility
     if ($userId != OW::getUser()->getId()) {
         $viewBasic['compatibility'] = OW::getEventManager()->call("matchmaking.get_compatibility", array("firstUserId" => OW::getUser()->getId(), "secondUserId" => $userId));
     } else {
         $viewBasic['compatibility'] = null;
     }
     // edit questions
     $editQuestionList = $questionService->findEditQuestionsForAccountType($accountType);
     $editNames = array();
     foreach ($editQuestionList as $editQuestion) {
         $editNames[] = $editQuestion['name'];
     }
     $editQuestionList = $this->getUserEditQuestions($userId, $editNames);
     $editOptions = $questionService->findQuestionsValuesByQuestionNameList($editNames);
     $editData = $questionService->getQuestionData(array($userId), $editNames);
     $editData = !empty($editData[$userId]) ? $editData[$userId] : array();
     $editSections = array();
     foreach ($editQuestionList['questions'] as $sectionName => $section) {
         if ($sectionName == 'location') {
             continue;
         }
         $order = 0;
         foreach ($sortedSections as $sorted) {
             if ($sorted->name == $sectionName) {
                 $order = $sorted->sortOrder;
             }
         }
         $editSections[] = array('order' => $order, 'name' => $sectionName, 'label' => $questionService->getSectionLang($sectionName));
     }
     usort($editSections, array('SKADATEIOS_ACTRL_User', 'sortByOrder'));
     $editQuestions = array();
     $editBasic = array();
     foreach ($editQuestionList['questions'] as $sectName => $section) {
         $sectionQuestions = array();
         foreach ($section as $question) {
             $data = $editQuestionList['data'][$userId];
             $name = $question['name'];
             $values = "";
             if (!empty($data[$name])) {
                 if (is_array($data[$name])) {
                     $values = array();
                     foreach ($data[$name] as $val) {
                         $values[] = strip_tags($val);
                     }
                 } else {
                     $values = strip_tags($data[$name]);
                 }
             }
             $q = array('id' => $question['id'], 'name' => $name, 'label' => $questionService->getQuestionLang($name), 'value' => $values, 'rawValue' => !empty($editData[$name]) ? $editData[$name] : null, 'section' => $sectName, 'custom' => json_decode($question['custom'], true), 'presentation' => $name == 'googlemap_location' ? $name : $question['presentation'], 'options' => self::formatOptionsForQuestion($name, $editOptions), 'order' => $question['sortOrder']);
             if (in_array($name, self::$basicNames)) {
                 $editBasic[] = $q;
             } else {
                 $sectionQuestions[] = $q;
             }
         }
         usort($sectionQuestions, array('SKADATEIOS_ACTRL_User', 'sortByOrder'));
         $editQuestions[$sectName] = $sectionQuestions;
     }
     $viewQuestionList = array();
     $editQuestionList = array();
     $viewSectionList = array();
     $editSectionList = array();
     foreach ($viewSections as $section) {
         unset($section['index']);
         $viewSectionList[] = $section;
         $viewQuestionList[] = empty($viewQuestions[$section["name"]]) ? array() : $viewQuestions[$section["name"]];
     }
     foreach ($editSections as $section) {
         unset($section['index']);
         $editSectionList[] = $section;
         $editQuestionList[] = empty($editQuestions[$section["name"]]) ? array() : $editQuestions[$section["name"]];
     }
     $this->assign('viewQuestions', $viewQuestionList);
     $this->assign('editQuestions', $editQuestionList);
     $this->assign('viewSections', $viewSectionList);
     $this->assign('editSections', $editSectionList);
     $this->assign('viewBasic', $viewBasic);
     $this->assign('editBasic', $editBasic);
     $this->assign('isBlocked', BOL_UserService::getInstance()->isBlocked($userId, OW::getUser()->getId()));
     $pm = OW::getPluginManager();
     $isBookmarked = $pm->isPluginActive('bookmarks') && BOOKMARKS_BOL_Service::getInstance()->isMarked(OW::getUser()->getId(), $userId);
     $this->assign('isBookmarked', $isBookmarked);
     $isWinked = $pm->isPluginActive('winks') && WINKS_BOL_Service::getInstance()->isLimited(OW::getUser()->getId(), $userId);
     $this->assign('isWinked', $isWinked);
     $isAdmin = BOL_AuthorizationService::getInstance()->isActionAuthorizedForUser($userId, BOL_AuthorizationService::ADMIN_GROUP_NAME);
     $this->assign('isAdmin', $isAdmin);
     $auth = array('base.view_profile' => $service->getAuthorizationActionStatus('base', 'view_profile'), 'photo.upload' => $service->getAuthorizationActionStatus('photo', 'upload'), 'photo.view' => $service->getAuthorizationActionStatus('photo', 'view'));
     $this->assign('auth', $auth);
     // track guests
     if ($userId != OW::getUser()->getId()) {
         $event = new OW_Event('guests.track_visit', array('userId' => $userId, 'guestId' => OW::getUser()->getId()));
         OW::getEventManager()->trigger($event);
     }
     $allowSendMessage = OW::getPluginManager()->isPluginActive('mailbox');
     $this->assign("actions", array("bookmark" => OW::getPluginManager()->isPluginActive('bookmarks'), "message" => $allowSendMessage, "wink" => OW::getPluginManager()->isPluginActive('winks') && OW::getPluginManager()->isPluginActive('mailbox')));
     $mailboxModes = OW::getEventManager()->call('mailbox.get_active_mode_list');
     $this->assign("mailboxModes", empty($mailboxModes) ? array() : $mailboxModes);
 }
Example #7
0
 public function getUserList(OW_Event $event)
 {
     $params = $event->getParams();
     $userId = $params['userId'];
     $first = empty($params['first']) ? 0 : $params['first'];
     $count = empty($params['count']) ? 1000000 : $params['count'];
     $users = BOOKMARKS_BOL_Service::getInstance()->findBookmarksUserIdList($userId, $first, $count);
     $event->setData($users);
     return $users;
 }
Example #8
0
 public function getQuestions($post, $params)
 {
     if (empty($params['id'])) {
         throw new ApiResponseErrorException();
     }
     $userId = (int) $params['id'];
     $user = BOL_UserService::getInstance()->findUserById($userId);
     if (!$user) {
         throw new ApiResponseErrorException();
     }
     $service = SKANDROID_ABOL_Service::getInstance();
     $questionService = BOL_QuestionService::getInstance();
     $accountType = OW::getUser()->getUserObject()->accountType;
     $viewQuestionList = $questionService->findViewQuestionsForAccountType($accountType);
     /* $viewNames = array();
     
             foreach ( $viewQuestionList as $viewQuestion )
             {
                 $viewNames[] = $viewQuestion['name'];
             } */
     $viewQuestionList = BOL_UserService::getInstance()->getUserViewQuestions($userId, false);
     $viewSections = array();
     $sortedSections = $questionService->findSortedSectionList();
     foreach ($viewQuestionList['questions'] as $sectionName => $section) {
         if ($sectionName == 'location') {
             continue;
         }
         $order = 0;
         foreach ($sortedSections as $sorted) {
             if ($sorted->name == $sectionName) {
                 $order = $sorted->sortOrder;
             }
         }
         $viewSections[] = array('order' => $order, 'name' => $sectionName, 'label' => $questionService->getSectionLang($sectionName));
     }
     usort($viewSections, array('SKANDROID_ACTRL_User', 'sortSectionsAsc'));
     $viewQuestions = array();
     $viewBasic = array();
     $data = $viewQuestionList['data'][$userId];
     $sectionIndex = 0;
     foreach ($viewQuestionList['questions'] as $sectName => $section) {
         $sectionQstions = array();
         foreach ($section as $question) {
             $name = $question['name'];
             if (is_array($data[$name])) {
                 $values = array();
                 foreach ($data[$name] as $val) {
                     $values[] = strip_tags($val);
                 }
             } else {
                 $values = strip_tags($data[$name]);
             }
             if (in_array($name, self::$basicNames)) {
                 if ($name == 'sex') {
                     $v = array_values($values);
                     $viewBasic[$name] = array_shift($v);
                 } else {
                     $viewBasic[$name] = $values;
                 }
             } else {
                 $sectionQstions[] = array('id' => $question['id'], 'name' => $name, 'label' => $questionService->getQuestionLang($name), 'value' => $values, 'section' => $sectName, 'presentation' => $name == 'googlemap_location' ? $name : $question['presentation']);
             }
         }
         $viewQuestions[] = $sectionQstions;
     }
     $viewBasic['online'] = (bool) BOL_UserService::getInstance()->findOnlineUserById($userId);
     $viewBasic['avatar'] = self::dataForUserAvatar($userId);
     // compatibility
     if ($userId != OW::getUser()->getId()) {
         $viewBasic['compatibility'] = OW::getEventManager()->call("matchmaking.get_compatibility", array("firstUserId" => OW::getUser()->getId(), "secondUserId" => $userId));
     } else {
         $viewBasic['compatibility'] = null;
     }
     // edit questions
     $editQuestionList = $questionService->findEditQuestionsForAccountType($accountType);
     $editNames = array();
     foreach ($editQuestionList as $editQuestion) {
         $editNames[] = $editQuestion['name'];
     }
     //$editQuestionList = $this->getUserEditQuestions($userId, $editNames);
     $editOptions = $questionService->findQuestionsValuesByQuestionNameList($editNames);
     $editData = $questionService->getQuestionData(array($userId), $editNames);
     $editData = !empty($editData[$userId]) ? $editData[$userId] : array();
     $editSections = array();
     $editQuestions = array();
     $i = 0;
     $sectionName = null;
     foreach ($editQuestionList as $question) {
         if (in_array($question['name'], array('email'))) {
             continue;
         }
         if ($sectionName != $question['sectionName']) {
             if ($sectionName != null) {
                 $i++;
             }
             $sectionName = $question['sectionName'];
             $order = 0;
             foreach ($sortedSections as $sorted) {
                 if ($sorted->name == $sectionName) {
                     $order = $sorted->sortOrder;
                 }
             }
             $editSections[] = array('order' => $order, 'name' => $sectionName, 'label' => $questionService->getSectionLang($sectionName));
             $editQuestions[] = array();
         }
         $name = $question['name'];
         $custom = json_decode($question['custom'], true);
         $options = self::formatOptionsForQuestion($name, $editOptions);
         $value = !empty($editData[$name]) ? $editData[$name] : null;
         if ($name == 'googlemap_location' && !empty($value)) {
             $value = json_encode($value);
         } elseif ($name == 'match_age') {
             $birthday = $questionService->findQuestionByName('birthdate');
             if ($birthday !== null && mb_strlen(trim($birthday->custom)) > 0) {
                 $custom = json_decode($birthday->custom, true);
             }
         }
         $q = array('id' => $question['id'], 'name' => $name, 'label' => $questionService->getQuestionLang($name), 'value' => $value, 'section' => $question['sectionName'], 'custom' => empty($custom) ? null : array_merge(array('custom' => 'custom'), $custom), 'presentation' => $name == 'googlemap_location' ? $name : $question['presentation'], 'required' => $question['required'], 'options' => !empty($options['values']) ? $options['values'] : array());
         $editQuestions[$i][] = $q;
     }
     usort($editSections, array('SKANDROID_ACTRL_User', 'sortSectionsAsc'));
     $this->assign('viewQuestions', $viewQuestions);
     $this->assign('editQuestions', $editQuestions);
     $viewSectionList = array();
     $editSectionList = array();
     foreach ($viewSections as $section) {
         unset($section['index']);
         $viewSectionList[] = $section;
     }
     foreach ($editSections as $section) {
         unset($section['index']);
         $editSectionList[] = $section;
     }
     $adat = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array("googlemap_location"));
     $viewBasic["location"] = empty($adat[$userId]["googlemap_location"]["json"]) ? null : $adat[$userId]["googlemap_location"]["address"];
     $this->assign('viewSections', $viewSectionList);
     $this->assign('editSections', $editSectionList);
     $this->assign('viewBasic', $viewBasic);
     $this->assign('isBlocked', BOL_UserService::getInstance()->isBlocked($userId, OW::getUser()->getId()));
     $pm = OW::getPluginManager();
     $isBookmarked = $pm->isPluginActive('bookmarks') && BOOKMARKS_BOL_Service::getInstance()->isMarked(OW::getUser()->getId(), $userId);
     $this->assign('isBookmarked', $isBookmarked);
     $isWinked = $pm->isPluginActive('winks') && WINKS_BOL_Service::getInstance()->isLimited(OW::getUser()->getId(), $userId);
     $this->assign('isWinked', $isWinked);
     $isAdmin = BOL_AuthorizationService::getInstance()->isActionAuthorizedForUser($userId, BOL_AuthorizationService::ADMIN_GROUP_NAME);
     $this->assign('isAdmin', $isAdmin);
     $auth = array('base.view_profile' => $service->getAuthorizationActionStatus('base', 'view_profile'), 'photo.upload' => $service->getAuthorizationActionStatus('photo', 'upload'), 'photo.view' => $service->getAuthorizationActionStatus('photo', 'view'));
     $this->assign('auth', $auth);
     // track guests
     if ($userId != OW::getUser()->getId()) {
         $event = new OW_Event('guests.track_visit', array('userId' => $userId, 'guestId' => OW::getUser()->getId()));
         OW::getEventManager()->trigger($event);
     }
     //printVar($this->assignedVars); exit;
 }