public function __construct()
 {
     parent::__construct('MATCHMAKING_PreferencesForm');
     $this->questionService = BOL_QuestionService::getInstance();
     $language = OW::getLanguage();
     $save = new Submit('save');
     $save->setValue($language->text('matchmaking', 'btn_label_save'));
     $this->addElement($save);
 }
 /**
  * @param OW_ActionController $controller
  * @param string $name
  */
 public function __construct($controller, $name = '')
 {
     if ($name) {
         parent::__construct($name);
     } else {
         parent::__construct('MainSearchForm');
     }
     $this->initForm($controller);
 }
 /**
  * @param OW_ActionController $controller
  */
 public function __construct($controller)
 {
     parent::__construct('DisplayNameSearchForm');
     $this->controller = $controller;
     $questionService = BOL_QuestionService::getInstance();
     $this->setId('DisplayNameSearchForm');
     $submit = new Submit(self::SUBMIT_NAME);
     $submit->setValue(OW::getLanguage()->text('base', 'user_search_submit_button_label'));
     $this->addElement($submit);
     $questionName = OW::getConfig()->getValue('base', 'display_name_question');
     $question = $questionService->findQuestionByName($questionName);
     $questionPropertyList = array();
     foreach ($question as $property => $value) {
         $questionPropertyList[$property] = $value;
     }
     $this->addQuestions(array($questionName => $questionPropertyList), array(), array());
     $controller->assign('displayNameQuestion', $questionPropertyList);
 }
 public function __construct(OW_ActionController $controller)
 {
     parent::__construct('settings-form');
     $lang = OW::getLanguage();
     $newLogin = new CheckboxField('newLogin');
     $newLogin->setLabel($lang->text('femaleregonlymen', 'login_as_user'));
     $this->addElement($newLogin);
     $questionNameList = array('username', 'email', 'password', 'sex');
     $questionDtoList = BOL_QuestionService::getInstance()->findQuestionByNameList($questionNameList);
     $orderedQuestionList = array();
     $questionService = BOL_QuestionService::getInstance();
     $questionValueList = $questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     foreach ($questionNameList as $questionName) {
         if (!empty($questionDtoList[$questionName])) {
             $orderedQuestionList[] = get_object_vars($questionDtoList[$questionName]);
         }
     }
     $this->addQuestions($orderedQuestionList, $questionValueList);
     $controller->assign('questions', $orderedQuestionList);
     $submit = new Submit('reg_fake');
     $submit->setValue($lang->text('femaleregonlymen', 'reg_fake'));
     $this->addElement($submit);
 }
 public function __construct($controller)
 {
     parent::__construct('QuickSearchForm');
     $this->questionService = BOL_QuestionService::getInstance();
     $this->searchService = USEARCH_BOL_Service::getInstance();
     $lang = OW::getLanguage();
     $this->setAjax(true);
     $this->setAction(OW::getRouter()->urlForRoute('usearch.quick_search_action'));
     $this->setAjaxResetOnSuccess(false);
     $questionNameList = $this->searchService->getQuickSerchQuestionNames();
     $questionValueList = $this->questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     $sessionData = OW::getSession()->get(self::FORM_SESSEION_VAR);
     if ($sessionData === null) {
         $sessionData = array();
         if (OW::getUser()->isAuthenticated()) {
             $data = BOL_QuestionService::getInstance()->getQuestionData(array(OW::getUser()->getId()), array('sex', 'match_sex'));
             if (!empty($data[OW::getUser()->getId()]['sex'])) {
                 $sessionData['sex'] = $data[OW::getUser()->getId()]['sex'];
             }
             if (!empty($data[OW::getUser()->getId()]['match_sex'])) {
                 for ($i = 0; $i < 31; $i++) {
                     if (pow(2, $i) & $data[OW::getUser()->getId()]['match_sex']) {
                         $sessionData['match_sex'] = pow(2, $i);
                         break;
                     }
                 }
             }
             $sessionData['googlemap_location']['distance'] = 50;
             OW::getSession()->set(self::FORM_SESSEION_VAR, $sessionData);
         }
     }
     if (!empty($sessionData['match_sex'])) {
         if (is_array($sessionData['match_sex'])) {
             $sessionData['match_sex'] = array_shift($sessionData['match_sex']);
         } else {
             for ($i = 0; $i < 31; $i++) {
                 if (pow(2, $i) & $sessionData['match_sex']) {
                     $sessionData['match_sex'] = pow(2, $i);
                     break;
                 }
             }
         }
     }
     /* ------------------------- */
     $questionDtoList = BOL_QuestionService::getInstance()->findQuestionByNameList($questionNameList);
     $questions = array();
     $questionList = array();
     $orderedQuestionList = array();
     /* @var $question BOL_Question */
     foreach ($questionDtoList as $key => $question) {
         $dataList = (array) $question;
         $questions[$question->name] = $dataList;
         $isRequired = in_array($question->name, array('googlemap_location', 'match_sex')) ? 1 : 0;
         $questions[$question->name]['required'] = $isRequired;
         if ($question->name == 'sex' || $question->name == 'match_sex') {
             unset($questions[$question->name]);
         } else {
             $questionList[$question->name] = $dataList;
         }
     }
     foreach ($questionNameList as $questionName) {
         if (!empty($questionDtoList[$questionName])) {
             $orderedQuestionList[] = $questionDtoList[$questionName];
         }
     }
     $controller->assign('displayGender', false);
     $accounts = $this->getAccountTypes();
     $this->addQuestions($questions, $questionValueList, array());
     $locationField = $this->getElement('googlemap_location');
     if ($locationField) {
         $value = $locationField->getValue();
         if (empty($value['distance'])) {
             $locationField->setDistance(50);
         }
     }
     if (count($accounts) > 1) {
         $this->displayAccountType = true;
         $controller->assign('displayGender', true);
         $sex = new Selectbox('sex');
         $sex->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('sex'));
         $sex->setHasInvitation(false);
         $sex->setRequired();
         //$accountType->setHasInvitation(false);
         $this->setFieldOptions($sex, 'sex', $questionValueList['sex']);
         if (!empty($sessionData['sex'])) {
             $sex->setValue($sessionData['sex']);
         }
         $this->addElement($sex);
         $matchSex = new Selectbox('match_sex');
         $matchSex->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('match_sex'));
         $matchSex->setRequired();
         $matchSex->setHasInvitation(false);
         //$accountType->setHasInvitation(false);
         $this->setFieldOptions($matchSex, 'match_sex', $questionValueList['sex']);
         if (!empty($sessionData['match_sex']) && !is_array($sessionData['match_sex'])) {
             $matchSex->setValue($sessionData['match_sex']);
         }
         $this->addElement($matchSex);
     }
     $controller->assign('questionList', $orderedQuestionList);
     $controller->assign('displayAccountType', $this->displayAccountType);
     // 'online' field
     $onlineField = new CheckboxField('online');
     if (is_array($sessionData) && array_key_exists('online', $sessionData)) {
         $onlineField->setValue((int) $sessionData['online']);
     }
     $onlineField->setLabel($lang->text('usearch', 'online_only'));
     $this->addElement($onlineField);
     //        if ( OW::getPluginManager()->isPluginActive('photo') )
     //        {
     // with photo
     $withPhoto = new CheckboxField('with_photo');
     if (is_array($sessionData) && array_key_exists('with_photo', $sessionData)) {
         $withPhoto->setValue((int) $sessionData['with_photo']);
     }
     $withPhoto->setLabel($lang->text('usearch', 'with_photo'));
     $this->addElement($withPhoto);
     //        }
     // submit
     $submit = new Submit('search');
     $submit->setValue(OW::getLanguage()->text('base', 'user_search_submit_button_label'));
     $this->addElement($submit);
     $this->bindJsFunction(Form::BIND_SUCCESS, "function(data){\n            if ( data.result ) {\n                document.location.href = data.url;\n            }\n            else {\n                OW.warning(data.error);\n            }\n        }");
 }
 /**
  * @param OW_ActionController $controller
  */
 public function __construct($controller)
 {
     parent::__construct('MainSearchForm');
     $this->controller = $controller;
     $questionService = BOL_QuestionService::getInstance();
     $this->setId('MainSearchForm');
     $submit = new Submit(self::SUBMIT_NAME);
     $submit->setValue(OW::getLanguage()->text('base', 'user_search_submit_button_label'));
     $this->addElement($submit);
     $questionData = OW::getSession()->get(self::FORM_SESSEION_VAR);
     if ($questionData === null) {
         $questionData = array();
         if (OW::getUser()->isAuthenticated()) {
             $data = BOL_QuestionService::getInstance()->getQuestionData(array(OW::getUser()->getId()), array('match_sex'));
             $questionData['match_sex'] = $data[OW::getUser()->getId()]['match_sex'];
             $questionData['googlemap_location']['distance'] = 50;
             OW::getSession()->set(self::FORM_SESSEION_VAR, $questionData);
         }
     }
     if (!empty($questionData['match_sex'])) {
         if (is_array($questionData['match_sex'])) {
             $questionData['match_sex'] = array_shift($questionData['match_sex']);
         } else {
             for ($i = 0; $i < 31; $i++) {
                 if (pow(2, $i) & $questionData['match_sex']) {
                     $questionData['match_sex'] = pow(2, $i);
                     break;
                 }
             }
         }
     }
     $accounts = $this->getAccountTypes();
     $accountList = array();
     foreach ($accounts as $key => $account) {
         $accountList[$key] = $account;
     }
     $keys = array_keys($accountList);
     $this->accountType = $keys[0];
     $this->matchSexValue = USEARCH_BOL_Service::getInstance()->getGenderByAccounType($this->accountType);
     if (isset($questionData['match_sex'])) {
         $accountType = USEARCH_BOL_Service::getInstance()->getAccounTypeByGender($questionData['match_sex']);
         if (!empty($accountType)) {
             $this->accountType = $accountType;
             $this->matchSexValue = $questionData['match_sex'];
         }
     }
     $questions = $questionService->findSearchQuestionsForAccountType($this->accountType);
     $mainSearchQuestion = array();
     $questionNameList = array('sex' => 'sex', 'match_sex' => 'match_sex');
     foreach ($questions as $key => $question) {
         $sectionName = $question['sectionName'];
         $questionNameList[] = $question['name'];
         $isRequired = in_array($question['name'], array('googlemap_location', 'match_sex')) ? 1 : 0;
         $questions[$key]['required'] = $isRequired;
         if ($question['name'] == 'sex' || $question['name'] == 'match_sex') {
             unset($questions[$key]);
         } else {
             $mainSearchQuestion[$sectionName][] = $question;
         }
     }
     $questionValueList = $questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     $controller->assign('displayGender', false);
     if (count($accounts) > 1) {
         $this->displayAccountType = true;
         if (!OW::getUser()->isAuthenticated()) {
             $controller->assign('displayGender', true);
             $sex = new Selectbox('sex');
             $sex->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('sex'));
             $sex->setRequired();
             $sex->setHasInvitation(false);
             //$accountType->setHasInvitation(false);
             $this->setFieldOptions($sex, 'sex', $questionValueList['sex']);
             if (!empty($questionData['sex'])) {
                 $sex->setValue($questionData['sex']);
             }
             $this->addElement($sex);
         } else {
             $sexData = BOL_QuestionService::getInstance()->getQuestionData(array(OW::getUser()->getId()), array('sex'));
             if (!empty($sexData[OW::getUser()->getId()]['sex'])) {
                 $sex = new HiddenField('sex');
                 $sex->setValue($sexData[OW::getUser()->getId()]['sex']);
                 $this->addElement($sex);
             }
         }
         $matchSex = new Selectbox('match_sex');
         $matchSex->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('match_sex'));
         $matchSex->setRequired();
         $matchSex->setHasInvitation(false);
         //$accountType->setHasInvitation(false);
         $this->setFieldOptions($matchSex, 'match_sex', $questionValueList['sex']);
         if (!empty($questionData['match_sex'])) {
             $matchSex->setValue($questionData['match_sex']);
         }
         $this->addElement($matchSex);
     }
     $this->addQuestions($questions, $questionValueList, $questionData);
     $locationField = $this->getElement('googlemap_location');
     if ($locationField) {
         $value = $locationField->getValue();
         if (empty($value['json'])) {
             $locationField->setDistance(50);
         }
     }
     $controller->assign('questionList', $mainSearchQuestion);
     $controller->assign('displayAccountType', $this->displayAccountType);
     // 'online' field
     $onlineField = new CheckboxField('online');
     if (!empty($questionData) && is_array($questionData) && array_key_exists('online', $questionData)) {
         $onlineField->setValue($questionData['online']);
     }
     $onlineField->setLabel(OW::getLanguage()->text('usearch', 'online_only'));
     $this->addElement($onlineField);
     //        if ( OW::getPluginManager()->isPluginActive('photo') )
     //        {
     // with photo
     $withPhoto = new CheckboxField('with_photo');
     if (!empty($questionData) && is_array($questionData) && array_key_exists('with_photo', $questionData)) {
         $withPhoto->setValue($questionData['with_photo']);
     }
     $withPhoto->setLabel(OW::getLanguage()->text('usearch', 'with_photo'));
     $this->addElement($withPhoto);
     //        }
 }
 public function __construct($name, $userId = null)
 {
     parent::__construct($name);
     if ($userId != null) {
         $this->userId = $userId;
     }
 }
Exemple #8
0
 public function __construct($controller)
 {
     parent::__construct('joinForm');
     $this->setId('joinForm');
     $stamp = OW::getSession()->get(self::SESSION_START_STAMP);
     if (empty($stamp)) {
         OW::getSession()->set(self::SESSION_START_STAMP, time());
     }
     unset($stamp);
     $this->checkSession();
     $joinSubmitLabel = "";
     // get available account types from DB
     $accounts = $this->getAccountTypes();
     $joinData = OW::getSession()->get(self::SESSION_JOIN_DATA);
     if (!isset($joinData) || !is_array($joinData)) {
         $joinData = array();
     }
     $accountsKeys = array_keys($accounts);
     $this->accountType = $accountsKeys[0];
     if (isset($joinData['accountType'])) {
         $this->accountType = trim($joinData['accountType']);
     }
     $step = $this->getStep();
     if (count($accounts) > 1) {
         $this->stepCount = 2;
         switch ($step) {
             case 1:
                 $this->displayAccountType = true;
                 $joinSubmitLabel = OW::getLanguage()->text('base', 'join_submit_button_continue');
                 break;
             case 2:
                 $this->isLastStep = true;
                 $joinSubmitLabel = OW::getLanguage()->text('base', 'join_submit_button_join');
                 break;
         }
     } else {
         $this->isLastStep = true;
         $joinSubmitLabel = OW::getLanguage()->text('base', 'join_submit_button_join');
     }
     $joinSubmit = new Submit('joinSubmit');
     $joinSubmit->addAttribute('class', 'ow_button ow_ic_submit');
     $joinSubmit->setValue($joinSubmitLabel);
     $this->addElement($joinSubmit);
     $this->init($accounts);
     $this->getQuestions();
     $section = null;
     $questionNameList = array();
     $this->sortedQuestionsList = array();
     foreach ($this->questions as $sort => $question) {
         if ((string) $question['base'] === '0' && $step === 2 || $step === 1) {
             if ($section !== $question['sectionName']) {
                 $section = $question['sectionName'];
             }
             //$this->questionListBySection[$section][] = $this->questions[$sort];
             $questionNameList[] = $this->questions[$sort]['name'];
             $this->sortedQuestionsList[] = $this->questions[$sort];
         }
     }
     $this->questionValuesList = BOL_QuestionService::getInstance()->findQuestionsValuesByQuestionNameList($questionNameList);
     $this->addFakeQuestions();
     $this->addQuestions($this->sortedQuestionsList, $this->questionValuesList, $this->updateJoinData());
     $this->setQuestionsLabel();
     $this->addClassToBaseQuestions();
     if ($this->isLastStep) {
         $this->addLastStepQuestions($controller);
     }
     $controller->assign('step', $step);
     $controller->assign('questionArray', $this->questionListBySection);
     $controller->assign('displayAccountType', $this->displayAccountType);
     $controller->assign('isLastStep', $this->isLastStep);
 }