/**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return SKADATE_BOL_AccountTypeToGenderService
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Пример #2
0
 public function index()
 {
     $language = OW::getLanguage();
     $form = new FEMALEREGONLYMEN_CLASS_SettingsForm($this);
     $form->setId($form->getName());
     $this->addForm($form);
     $form->getElement('newLogin')->setValue(OW::getConfig()->getValue('femaleregonlymen', 'new_login'));
     if (OW::getRequest()->isPost() && $form->isValid($_POST)) {
         $values = $form->getValues();
         $userName = $values['username'];
         $email = $values['email'];
         $password = $values['password'];
         $sex = $values['sex'];
         $newLogin = $values['newLogin'];
         OW::getConfig()->saveConfig('femaleregonlymen', 'new_login', $values['newLogin']);
         $accountType = SKADATE_BOL_AccountTypeToGenderService::getInstance()->getAccountType($sex);
         $userData = BOL_UserService::getInstance()->createUser($userName, $password, $email, $accountType, true);
         if ($newLogin == true) {
             OW::getUser()->login($userData->id);
         } else {
             OW::getFeedback()->info($language->text('femaleregonlymen', 'reg_fake_success'));
             $this->redirect();
         }
     }
     $language->addKeyForJs('base', 'join_error_username_not_valid');
     $language->addKeyForJs('base', 'join_error_username_already_exist');
     $language->addKeyForJs('base', 'join_error_email_not_valid');
     $language->addKeyForJs('base', 'join_error_email_already_exist');
     $language->addKeyForJs('base', 'join_error_password_not_valid');
     $language->addKeyForJs('base', 'join_error_password_too_short');
     $language->addKeyForJs('base', 'join_error_password_too_long');
     $onLoadJs = " window.join = new OW_BaseFieldValidators( " . json_encode(array('formName' => $form->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Join", "ajaxResponder"), 'passwordMaxLength' => UTIL_Validator::PASSWORD_MAX_LENGTH, 'passwordMinLength' => UTIL_Validator::PASSWORD_MIN_LENGTH)) . ",\n                " . UTIL_Validator::EMAIL_PATTERN . ", " . UTIL_Validator::USER_NAME_PATTERN . " ); ";
     OW::getDocument()->addOnloadScript($onLoadJs);
     $jsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
     OW::getDocument()->addScript($jsDir . "base_field_validators.js");
     $this->setPageHeading(OW::getLanguage()->text('femaleregonlymen', 'config_page_heading'));
     $this->assign('mandatory_description', $language->text('femaleregonlymen', 'mandatory_description'));
 }
Пример #3
0
 public function questionList($params)
 {
     $questionService = BOL_QuestionService::getInstance();
     $fixedQuestionNames = array("sex", "match_sex", "email", "password", "username", "realname");
     if ($params["step"] == 1) {
         $questionNames = array("sex", "match_sex");
     } else {
         $gender = (int) $params["gender"];
         $accountType = SKADATE_BOL_AccountTypeToGenderService::getInstance()->getAccountType($gender);
         $signUpQuestions = $questionService->findSignUpQuestionsForAccountType($accountType);
         foreach ($signUpQuestions as $question) {
             if ($question["required"] && !in_array($question["name"], $fixedQuestionNames)) {
                 $questionNames[] = $question["name"];
             }
         }
     }
     $questionList = $questionService->findQuestionByNameList($questionNames);
     $questionOptions = $questionService->findQuestionsValuesByQuestionNameList($questionNames);
     $questions = array();
     foreach ($questionList as $question) {
         /* @var $question BOL_Question */
         $custom = json_decode($question->custom, true);
         $value = null;
         switch ($question->presentation) {
             case BOL_QuestionService::QUESTION_PRESENTATION_RANGE:
                 $value = "18-33";
                 break;
             case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
             case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
             case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
                 $value = date("Y-m-d H:i:s", strtotime("-18 year"));
                 break;
         }
         $questions[] = array('id' => $question->id, 'name' => $question->name, 'label' => $questionService->getQuestionLang($question->name), 'custom' => $custom, 'presentation' => $question->name == 'googlemap_location' ? $question->name : $question->presentation, 'options' => self::formatOptionsForQuestion($question->name, $questionOptions), 'value' => $value, 'rawValue' => $value);
     }
     $this->assign("list", array_reverse($questions));
 }
Пример #4
0
//$app = new \Slim\Slim();
$app = new \Slim\Slim();
//$baseJsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
$BOL_UserDao = BOL_UserDao::getInstance();
$ow_user = OW::getUser();
$OW_Auth_inst = OW_Auth::getInstance();
$Userservice = BOL_UserService::getInstance();
$EmailVerifyService = BOL_EmailVerifyService::getInstance();
$BOL_AvatarService_inst = BOL_AvatarService::getInstance();
$SKAPI_BOL_Service_inst = SKAPI_BOL_Service::getInstance();
$PHOTO_BOL_PhotoService_inst = PHOTO_BOL_PhotoService::getInstance();
$PHOTO_BOL_PhotoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
$PHOTO_BOL_PhotoTemporaryService = PHOTO_BOL_PhotoTemporaryService::getInstance();
$UserResetPassword = BOL_UserResetPasswordDao::getInstance();
$QuestionService = BOL_QuestionService::getInstance();
$AccountTypeToGenderService = SKADATE_BOL_AccountTypeToGenderService::getInstance();
$BOL_AuthorizationService = BOL_AuthorizationService::getInstance();
$BOL_UserOnlineDao = BOL_UserOnlineDao::getInstance();
$USEARCH_BOL_Service = USEARCH_BOL_Service::getInstance();
$BOL_SearchService = BOL_SearchService::getInstance();
$getPluginManager = OW::getPluginManager();
$CONTACTUS_BOL_Service = CONTACTUS_BOL_Service::getInstance();
$PHOTO_BOL_PhotoService = PHOTO_BOL_PhotoService::getInstance();
$PHOTO_BOL_PhotoAlbumCoverDao = PHOTO_BOL_PhotoAlbumCoverDao::getInstance();
$PHOTO_BOL_PhotoDao = PHOTO_BOL_PhotoDao::getInstance();
$getRouter = OW::getRouter();
$language = OW::getLanguage();
$getMailer = OW::getMailer();
$getConfig = OW::getConfig();
$getFeedback = OW::getFeedback();
$getEventManager = OW::getEventManager();
Пример #5
0
 protected function addOnloadJs($gender, $sectionsVisibility)
 {
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('usearch')->getStaticJsUrl() . 'main_search.js');
     $accountTypeList = BOL_QuestionService::getInstance()->findAllAccountTypes();
     $js = new UTIL_JsGenerator();
     $js->newObject('fieldModel', 'USearchFromQuestionModel');
     /*@var $dto BOL_QuestionAccountType */
     foreach ($accountTypeList as $dto) {
         $genderAccount = SKADATE_BOL_AccountTypeToGenderService::getInstance()->getGender($dto->name);
         $questionList = BOL_QuestionService::getInstance()->findSearchQuestionsForAccountType($dto->name);
         foreach ($questionList as $question) {
             $js->callFunction('fieldModel.addField', array($question['name'], $genderAccount, $genderAccount == $gender, $question['sectionName']));
         }
     }
     $js->newObject('sectionModel', 'USearchSectionModel');
     foreach ($sectionsVisibility as $section => $visibility) {
         $js->callFunction('sectionModel.addSection', array($section, $visibility));
     }
     $params = array('gender' => $gender, 'sectionPrefix' => self::SECTION_TR_PREFIX, 'fieldPrefix' => self::QUESTION_TR_PREFIX);
     $js->addScript('; USearchFromPresenter.init(fieldModel, sectionModel, {$params});', array('params' => $params));
     OW::getDocument()->addOnloadScript($js->generateJs());
 }
Пример #6
0
 public function onUserRegister(OW_Event $event)
 {
     $params = $event->getParams();
     if (empty($params['userId'])) {
         return;
     }
     $user = BOL_UserService::getInstance()->findUserById($params['userId']);
     if (empty($user)) {
         return;
     }
     $data = array();
     $accountType = $user->accountType;
     $questionData = BOL_QuestionService::getInstance()->getQuestionData(array($user->id), array('sex'));
     $sex = null;
     if (!empty($questionData[$user->id]['sex'])) {
         $sex = $questionData[$user->id]['sex'];
     }
     if (!empty($accountType)) {
         $genderToAccountTypeList = SKADATE_BOL_AccountTypeToGenderService::getInstance()->findAll();
         foreach ($genderToAccountTypeList as $value) {
             if ($value->accountType == $accountType) {
                 $data['sex'] = $value->genderValue;
             }
         }
     } else {
         if (!empty($sex)) {
             $genderToAccountTypeList = SKADATE_BOL_AccountTypeToGenderService::getInstance()->findAll();
             /* @var $value SKADATE_BOL_AccountTypeToGender */
             foreach ($genderToAccountTypeList as $value) {
                 if ($value->genderValue == $sex) {
                     $data['accountType'] = $value->accountType;
                 }
             }
         }
     }
     BOL_QuestionService::getInstance()->saveQuestionsData($data, $user->id);
     $this->updateMatchSex($user);
 }
Пример #7
0
 public function findMatchQuestionsForUser($userId)
 {
     if ($userId === null) {
         return array();
     }
     if (!OW::getPluginManager()->isPluginActive('skadate')) {
         return array();
     }
     $genderAccTypes = SKADATE_BOL_AccountTypeToGenderService::getInstance()->findAll();
     $lookingForValue = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array('match_sex'));
     $lookingForValues = array();
     foreach ($genderAccTypes as $type) {
         if ($lookingForValue[$userId]['match_sex'] & $type->genderValue) {
             $lookingForValues[] = $type->genderValue;
         }
     }
     if (empty($lookingForValues)) {
         return array();
     }
     $lookingForValues = $this->dbo->mergeInClause($lookingForValues);
     $sql = " SELECT DISTINCT `question`.* FROM `" . BOL_QuestionDao::getInstance()->getTableName() . "` as `question`\n\n                    LEFT JOIN  `" . BOL_QuestionSectionDao::getInstance()->getTableName() . "` as `section`\n                            ON ( `question`.`sectionName` = `section`.`name` AND `question`.`sectionName` != '' AND `question`.`sectionName` IS NOT NULL )\n\n                    LEFT JOIN " . BOL_QuestionToAccountTypeDao::getInstance()->getTableName() . " as `qta` ON ( `question`.`parent` = `qta`.`questionName` )\n\n                    LEFT JOIN `" . SKADATE_BOL_AccountTypeToGenderDao::getInstance()->getTableName() . "` as `atg` ON (`qta`.`accountType` = `atg`.`accountType`)\n\n                    WHERE `question`.`sectionName`='about_my_match' AND `atg`.`genderValue` IN ( {$lookingForValues} )\n\n                    ORDER BY IF( `section`.`name` IS NULL, 0, 1 ),  `section`.`sortOrder`, `question`.`sortOrder` ";
     return $this->dbo->queryForList($sql);
 }
Пример #8
0
function skadate_after_plugin_init(OW_Event $event)
{
    if (OW::getPluginManager()->getPlugin('skadate')->getDto()->build == 7651 && OW::getConfig()->configExists('skadate', 'update_gender_values')) {
        SKADATE_BOL_AccountTypeToGenderService::getInstance()->getInstance()->updateGenderValues();
        OW::getConfig()->saveConfig('skadate', 'update_gender_values', false);
    }
}
Пример #9
0
 public function ruleEditFormResponder()
 {
     if (!OW::getRequest()->isAjax()) {
         throw new Redirect404Exception();
     }
     $service = MATCHMAKING_BOL_Service::getInstance();
     $language = OW::getLanguage();
     if (OW::getRequest()->isPost()) {
         if (!empty($_POST['id']) && !empty($_POST['coefficient'])) {
             $question_match = $service->findById((int) $_POST['id']);
             if ($question_match !== null) {
                 $question_match->coefficient = $_POST['coefficient'];
                 $service->saveQuestionMatch($question_match);
                 exit(json_encode(array('result' => true, 'message' => OW::getLanguage()->text('matchmaking', 'rule_edit_form_success_message'))));
             }
         }
         if (!empty($_POST['name']) && !empty($_POST['coefficient']) && !empty($_POST['create'])) {
             $existingQuestion = $this->questionService->findQuestionByName('match_' . $_POST['name']);
             $questionLabel = $this->questionService->getQuestionLang($_POST['name']);
             $matchQuestionLabel = $language->text('matchmaking', 'match_question_lang_prefix', array('questionLabel' => $questionLabel));
             if (empty($existingQuestion)) {
                 //get question by parent name. if it doesn't exist, create one and then create match record
                 /**
                  * @var BOL_Question $newQuestion
                  */
                 $newQuestion = $this->questionService->findQuestionByName($_POST['name']);
                 $newQuestion->id = null;
                 $newQuestion->name = 'match_' . $newQuestion->name;
                 $newQuestion->parent = $_POST['name'];
                 $newQuestion->presentation = BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX;
                 $newQuestion->sectionName = 'about_my_match';
                 $newQuestion->required = 0;
                 $newQuestion->onJoin = 0;
                 $newQuestion->onEdit = 0;
                 $newQuestion->onSearch = 0;
                 $newQuestion->onView = 1;
                 $this->questionService->createQuestion($newQuestion, $matchQuestionLabel);
                 $accTypeList = SKADATE_BOL_AccountTypeToGenderService::getInstance()->findAll();
                 $accTypeNameList = array();
                 foreach ($accTypeList as $type) {
                     $accTypeNameList[] = $type->accountType;
                 }
                 $this->questionService->addQuestionToAccountType($newQuestion->name, $accTypeNameList);
                 $existingQuestion = $newQuestion;
             } else {
                 $this->questionService->setQuestionLabel($existingQuestion->name, $matchQuestionLabel);
             }
             $question_match = new MATCHMAKING_BOL_QuestionMatch();
             $question_match->questionName = $_POST['name'];
             $question_match->matchQuestionName = $existingQuestion->name;
             $question_match->coefficient = $_POST['coefficient'];
             $question_match->match_type = 'exact';
             $service->saveQuestionMatch($question_match);
             OW::getFeedback()->info($language->text('matchmaking', 'new_rule_form_success_message'));
             exit(json_encode(array('result' => true)));
         }
     }
     exit(json_encode(array('result' => false, 'message' => OW::getLanguage()->text('matchmaking', 'rule_edit_form_error_message'))));
 }
Пример #10
0
 public function getRealValues()
 {
     $list = $this->sortedQuestionsList;
     $values = $this->getValues();
     $result = array();
     if (!empty($list)) {
         foreach ($values as $fakeName => $value) {
             if (!empty($list[$fakeName]) && isset($list[$fakeName]['fake']) && $list[$fakeName]['fake'] == false) {
                 $result[$list[$fakeName]['realName']] = $value;
             }
             if ($fakeName == 'accountType') {
                 $result[$fakeName] = $value;
             }
         }
         if (!empty($result['sex'])) {
             $gender2accountType = SKADATE_BOL_AccountTypeToGenderService::getInstance()->findAll();
             if (!empty($gender2accountType)) {
                 /* @var $dto SKADATE_BOL_AccountTypeToGender */
                 foreach ($gender2accountType as $dto) {
                     if ($dto->genderValue == $result['sex']) {
                         $result['accountType'] = $dto->accountType;
                     }
                 }
             }
         }
     }
     return $result;
 }
Пример #11
0
 public function getSearchQuestions()
 {
     $userId = OW::getUser()->getId();
     if (!$userId) {
         throw new ApiResponseErrorException();
     }
     $user = BOL_UserService::getInstance()->findUserById($userId);
     if (!$user) {
         throw new ApiResponseErrorException();
     }
     $questionService = BOL_QuestionService::getInstance();
     $accTypes = $questionService->findAllAccountTypes();
     $basic = array();
     $advanced = array();
     $selectedSex = null;
     foreach ($accTypes as $type) {
         $searchQuestionList = $questionService->findSearchQuestionsForAccountType($type->name);
         $gender = SKADATE_BOL_AccountTypeToGenderService::getInstance()->getGender($type->name);
         if (!$selectedSex) {
             $selectedSex = $gender;
         }
         $searchNames = array();
         foreach ($searchQuestionList as $searchQuestion) {
             $searchNames[] = $searchQuestion['name'];
         }
         $searchOptions = $questionService->findQuestionsValuesByQuestionNameList($searchNames);
         $questionData = $questionService->getQuestionData(array($userId), $searchNames);
         $questionData = isset($questionData[$userId]) ? $questionData[$userId] : array();
         $basicQuestions = array();
         $advancedQuestions = array();
         foreach ($searchQuestionList as $searchQuestion) {
             $name = $searchQuestion['name'];
             if (in_array($name, self::$searchBasicNames)) {
                 $array = array('name' => $name, 'label' => $questionService->getQuestionLang($name), 'options' => self::formatOptionsForQuestion($name, $searchOptions), 'custom' => json_decode($searchQuestion['custom'], true), 'presentation' => $name == 'googlemap_location' ? $name : $searchQuestion['presentation']);
                 if (in_array($name, self::$searchFilledNames) && isset($questionData[$name])) {
                     if ($name == "birthdate" && !empty($array['custom']['year_range'])) {
                         $min = date("Y") - $array['custom']['year_range']['to'];
                         $array['value'] = $min . "-" . ($min + 15);
                     } else {
                         $array['value'] = $questionData[$name];
                     }
                 }
                 $basicQuestions[] = $array;
             } else {
                 $added = false;
                 if ($advancedQuestions) {
                     foreach ($advancedQuestions as $index => $addedSection) {
                         if ($addedSection['name'] == $searchQuestion['sectionName']) {
                             $advancedQuestions[$index]['questions'][] = array('name' => $name, 'label' => $questionService->getQuestionLang($name), 'custom' => json_decode($searchQuestion['custom'], true), 'options' => self::formatOptionsForQuestion($name, $searchOptions), 'presentation' => $searchQuestion['presentation']);
                             $added = true;
                             break;
                         }
                     }
                 }
                 if (!$added) {
                     $section = array();
                     $section['name'] = $searchQuestion['sectionName'];
                     $section['label'] = $questionService->getSectionLang($searchQuestion['sectionName']);
                     $section['questions'][] = array('name' => $name, 'label' => $questionService->getQuestionLang($name), 'custom' => json_decode($searchQuestion['custom'], true), 'options' => self::formatOptionsForQuestion($name, $searchOptions), 'presentation' => $searchQuestion['presentation']);
                     $advancedQuestions[] = $section;
                 }
             }
         }
         $basic[$gender] = $basicQuestions;
         $advanced[$gender] = $advancedQuestions;
     }
     $this->assign('basicQuestions', $basic);
     $this->assign('advancedQuestions', $advanced);
     $data = $questionService->getQuestionData(array($userId), array('match_sex'));
     if (!empty($data[$userId]['match_sex'])) {
         $matchSexValues = $questionService->prepareFieldValue(BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX, $data[$userId]['match_sex']);
         if (is_array($matchSexValues) && count($matchSexValues)) {
             $selectedSex = reset($matchSexValues);
         }
     }
     $this->assign('selectedSex', $selectedSex);
     $service = SKADATEIOS_ABOL_Service::getInstance();
     $auth = array('base.search_users' => $service->getAuthorizationActionStatus('base', 'search_users'));
     $this->assign('auth', $auth);
 }
Пример #12
0
 public function getGenderByAccounType($accountType)
 {
     $accountType2Gender = SKADATE_BOL_AccountTypeToGenderService::getInstance()->findAll();
     if (!empty($accountType2Gender)) {
         foreach ($accountType2Gender as $item) {
             if ($item->accountType == $accountType) {
                 return $item->genderValue;
             }
         }
     }
     return null;
 }
Пример #13
0
 public function __construct($section, $sectionQuestions, $data, $labels, $template = 'table', $hideSection = false, $additionalParams = array())
 {
     parent::__construct();
     $user = BOL_UserService::getInstance()->findUserById($additionalParams['userId']);
     if (!isset($user)) {
         $this->setVisible(false);
         return;
     }
     $sections = array();
     foreach ($sectionQuestions as $question) {
         if ($question['parent'] == null) {
             $accTypeList = BOL_QuestionService::getInstance()->findAccountTypeListByQuestionName($question['name']);
         } else {
             $accTypeList = BOL_QuestionService::getInstance()->findAccountTypeListByQuestionName($question['parent']);
         }
         if (count($accTypeList) > 1) {
             if (!isset($sections['general'])) {
                 $sections['general'] = array();
                 $sections['general']['name'] = 'general';
                 $sections['general']['label'] = OW::getLanguage()->text('matchmaking', "questions_general_label");
                 $sections['general']['questions'] = array();
             }
             $sections['general']['questions'][] = $question;
         } else {
             if (!isset($sections[$accTypeList[0]->accountType])) {
                 $sections[$accTypeList[0]->accountType] = array();
                 $sections[$accTypeList[0]->accountType]['name'] = $accTypeList[0]->accountType;
                 $sections[$accTypeList[0]->accountType]['label'] = BOL_QuestionService::getInstance()->getAccountTypeLang($accTypeList[0]->accountType);
                 $sections[$accTypeList[0]->accountType]['questions'] = array();
             }
             $sections[$accTypeList[0]->accountType]['questions'][] = $question;
         }
     }
     $this->assign('sections', $sections);
     $this->assign('sectionName', $section);
     $this->assign('questions', $sectionQuestions);
     $this->assign('generalQuestions', $sections['general']['questions']);
     $this->assign('questionsData', $data);
     $this->assign('labels', $labels);
     $this->assign('display', !$hideSection);
     $genderAccTypes = SKADATE_BOL_AccountTypeToGenderService::getInstance()->findAll();
     $lookingForValue = BOL_QuestionService::getInstance()->getQuestionData(array($user->getId()), array('match_sex'));
     $lookingForValues = array();
     foreach ($genderAccTypes as $type) {
         if ($lookingForValue[$user->getId()]['match_sex'] & $type->genderValue) {
             if (!in_array($type->genderValue, $lookingForValues)) {
                 $lookingForValues[] = $type->genderValue;
             }
         }
     }
     if (count($lookingForValues) > 1) {
         $mode = 'floatbox';
     } else {
         $mode = 'table';
     }
     $mode = 'floatbox';
     switch ($mode) {
         case 'floatbox':
             $this->setTemplate(OW::getPluginManager()->getPlugin('matchmaking')->getCmpViewDir() . 'user_view_section_floatbox.html');
             break;
         case 'table':
             $this->setTemplate(OW::getPluginManager()->getPlugin('matchmaking')->getCmpViewDir() . 'user_view_section_table.html');
             break;
     }
     $title = OW::getLanguage()->text('base', 'questions_section_about_my_match_label');
     $js = UTIL_JsGenerator::composeJsString(" \$('#matchmakingViewMatchSectionBtn').click(function(){\n\n            var matchmakingViewMatchSectionFloatbox = new OW_FloatBox({\$title: '{$title}', \$contents: \$('#matchmakingViewMatchSectionFloatbox'), width: '550px'});\n\n        }); ");
     OW::getDocument()->addOnloadScript($js);
 }