Exemplo n.º 1
0
 public function __construct()
 {
     parent::__construct('delete-membership-form');
     $this->setAjaxResetOnSuccess(false);
     $this->setAjax(true);
     $this->setAction(OW::getRouter()->urlForRoute('membership_delete_type'));
     $lang = OW::getLanguage();
     $typeId = new HiddenField('typeId');
     $typeId->setRequired(true);
     $this->addElement($typeId);
     $newTypeId = new Selectbox('newTypeId');
     $newTypeId->setHasInvitation(false);
     $this->addElement($newTypeId);
     $types = new RadioGroupItemField('type');
     $types->setRequired(true);
     $types->setLabel($lang->text('membership', 'set_membership'));
     $this->addElement($types);
     $this->bindJsFunction(Form::BIND_SUCCESS, "function( data ) {\n                if ( data.result ) {\n                    document.location.reload();\n                }\n            }");
     $script = '$("#btn-confirm-type-delete").click(function(){
         if ( confirm(' . json_encode($lang->text('membership', 'type_delete_confirm')) . ') ) {
              $(this).parents("form:eq(0)").submit();
         }
     });
     ';
     OW::getDocument()->addOnloadScript($script);
 }
Exemplo n.º 2
0
 public function __construct()
 {
     parent::__construct('bookmarks_settings');
     $language = OW::getLanguage();
     $this->setAjax();
     $this->setAjaxResetOnSuccess(FALSE);
     $this->setAction(OW::getRouter()->urlForRoute('bookmarks.admin'));
     $this->bindJsFunction('success', 'function()
     {
         OW.info("' . $language->text('bookmarks', 'settings_saved') . '");
     }');
     $notifyIntervalConfigVal = OW::getConfig()->getValue('bookmarks', 'notify_interval');
     $notifyIntervalVal = array(0 => $language->text('bookmarks', 'remainderinterval_dont_send'), 10 => $language->text('bookmarks', 'remainderinterval_10'), 20 => $language->text('bookmarks', 'remainderinterval_20'), 30 => $language->text('bookmarks', 'remainderinterval_30'));
     $notifyInterval = new Selectbox('notify_interval');
     $notifyInterval->addValidator(new BookmarkSelectboxValidator($notifyIntervalVal));
     $notifyInterval->setOptions($notifyIntervalVal);
     $notifyInterval->setValue($notifyIntervalConfigVal);
     $notifyInterval->setLabel($language->text('bookmarks', 'notify_interval_label'));
     $notifyInterval->setDescription($language->text('bookmarks', 'notify_interval_desc'));
     $notifyInterval->setHasInvitation(FALSE);
     $this->addElement($notifyInterval);
     $submit = new Submit('save');
     $submit->setValue($language->text('bookmarks', 'submit_label'));
     $this->addElement($submit);
 }
Exemplo n.º 3
0
 public function __construct($userId)
 {
     parent::__construct();
     $data = OW::getEventManager()->call("photo.entity_albums_find", array("entityType" => "user", "entityId" => $userId));
     $albums = empty($data["albums"]) ? array() : $data["albums"];
     $source = BOL_PreferenceService::getInstance()->getPreferenceValue("pcgallery_source", $userId);
     $this->assign("source", $source == "album" ? "album" : "all");
     $selectedAlbum = BOL_PreferenceService::getInstance()->getPreferenceValue("pcgallery_album", $userId);
     $form = new Form("pcGallerySettings");
     $form->setEmptyElementsErrorMessage(null);
     $form->setAction(OW::getRouter()->urlFor("PCGALLERY_CTRL_Gallery", "saveSettings"));
     $element = new HiddenField("userId");
     $element->setValue($userId);
     $form->addElement($element);
     $element = new Selectbox("album");
     $element->setHasInvitation(true);
     $element->setInvitation(OW::getLanguage()->text("pcgallery", "settings_album_invitation"));
     $validator = new PCGALLERY_AlbumValidator();
     $element->addValidator($validator);
     $albumsPhotoCount = array();
     foreach ($albums as $album) {
         $element->addOption($album["id"], $album["name"] . " ({$album["photoCount"]})");
         $albumsPhotoCount[$album["id"]] = $album["photoCount"];
         if ($album["id"] == $selectedAlbum) {
             $element->setValue($album["id"]);
         }
     }
     OW::getDocument()->addOnloadScript(UTIL_JsGenerator::composeJsString('window.pcgallery_settingsAlbumCounts = {$albumsCount};', array("albumsCount" => $albumsPhotoCount)));
     $element->setLabel(OW::getLanguage()->text("pcgallery", "source_album_label"));
     $form->addElement($element);
     $submit = new Submit("save");
     $submit->setValue(OW::getLanguage()->text("pcgallery", "save_settings_btn_label"));
     $form->addElement($submit);
     $this->addForm($form);
 }
Exemplo n.º 4
0
 /**
  * Class constructor
  *
  */
 public function __construct()
 {
     parent::__construct('configSaveForm');
     $language = OW::getLanguage();
     $configs = OW::getConfig()->getValues('googlelocation');
     $element = new TextField('api_key');
     $element->setValue($configs['api_key']);
     $validator = new StringValidator(0, 40);
     $validator->setErrorMessage($language->text('googlelocation', 'api_key_too_long'));
     $element->addValidator($validator);
     $this->addElement($element);
     $options = array(GOOGLELOCATION_BOL_LocationService::DISTANCE_UNITS_MILES => $language->text('googlelocation', 'miles'), GOOGLELOCATION_BOL_LocationService::DISTANCE_UNITS_KM => $language->text('googlelocation', 'kms'));
     $distanseUnits = new Selectbox('distanse_units');
     $distanseUnits->setOptions($options);
     $distanseUnits->setValue(GOOGLELOCATION_BOL_LocationService::getInstance()->getDistanseUnits());
     $distanseUnits->setHasInvitation(false);
     $this->addElement($distanseUnits);
     $restrictions = new Selectbox('country_restriction');
     $restrictions->setValue(!empty($configs['country_restriction']) ? $configs['country_restriction'] : null);
     $restrictions->setOptions($this->countryList);
     $restrictions->setInvitation(OW::getLanguage()->text('googlelocation', 'no_country_restriction'));
     $this->addElement($restrictions);
     $autofill = OW::getConfig()->getValue('googlelocation', 'auto_fill_location_on_search');
     $autoFillLocationOnSearch = new CheckboxField('auto_fill_location_on_search');
     $autoFillLocationOnSearch->setValue(empty($autofill) || $autofill == '0' ? false : $autofill);
     $this->addElement($autoFillLocationOnSearch);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('base', 'edit_button'));
     $this->addElement($submit);
 }
Exemplo n.º 5
0
 public function __construct($configs)
 {
     parent::__construct('QUESTIONS_ConfigSaveForm');
     $this->configs = $configs;
     $language = OW::getLanguage();
     $field = new CheckboxField('allow_comments');
     $field->setLabel($language->text('questions', 'admin_allow_comments_label'));
     $field->setValue($configs['allow_comments']);
     $this->addElement($field);
     $field = new Selectbox('list_order');
     foreach (array(QUESTIONS_CMP_Feed::ORDER_LATEST, QUESTIONS_CMP_Feed::ORDER_POPULAR) as $v) {
         $field->addOption($v, $language->text('questions', 'feed_order_' . $v));
     }
     $field->setHasInvitation(false);
     $field->setLabel($language->text('questions', 'admin_list_order_label'));
     $field->setValue($configs['list_order']);
     $this->addElement($field);
     $field = new CheckboxField('enable_follow');
     $field->setLabel($language->text('questions', 'admin_enable_follow_label'));
     $field->setValue($configs['enable_follow']);
     $this->addElement($field);
     $field = new CheckboxField('allow_popups');
     $field->setLabel($language->text('questions', 'admin_allow_popups_label'));
     $field->setValue($configs['allow_popups']);
     $this->addElement($field);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('questions', 'admin_save_btn'));
     $this->addElement($submit);
 }
Exemplo n.º 6
0
 public function __construct($name)
 {
     parent::__construct($name);
     $lang = OW::getLanguage();
     $period = new TextField('period');
     $period->setRequired(true);
     $period->setLabel($lang->text('ocsaffiliates', 'settings_timeout'));
     $this->addElement($period);
     $status = new Selectbox('status');
     $status->setRequired(true);
     $status->setHasInvitation(false);
     $options = array('active' => $lang->text('ocsaffiliates', 'status_active'), 'unverified' => $lang->text('ocsaffiliates', 'status_unverified'));
     $status->addOptions($options);
     $status->setLabel($lang->text('ocsaffiliates', 'settings_status'));
     $this->addElement($status);
     $clickAmount = new TextField('clickAmount');
     $clickAmount->setRequired(true);
     $clickAmount->setLabel($lang->text('ocsaffiliates', 'settings_click_amount'));
     $clickAmount->addValidator(new FloatValidator());
     $this->addElement($clickAmount);
     $regAmount = new TextField('regAmount');
     $regAmount->setRequired(true);
     $regAmount->setLabel($lang->text('ocsaffiliates', 'settings_reg_amount'));
     $regAmount->addValidator(new FloatValidator());
     $this->addElement($regAmount);
     $saleCommission = new Selectbox('saleCommission');
     $saleCommission->setRequired(true);
     $options = array('amount' => $lang->text('ocsaffiliates', 'commission_amount'), 'percent' => $lang->text('ocsaffiliates', 'commission_percent'));
     $saleCommission->addOptions($options);
     $saleCommission->setLabel($lang->text('ocsaffiliates', 'settings_sale_commission'));
     $this->addElement($saleCommission);
     $saleAmount = new TextField('saleAmount');
     $saleAmount->setLabel($lang->text('ocsaffiliates', 'settings_sale_amount'));
     $saleAmount->addValidator(new FloatValidator());
     $this->addElement($saleAmount);
     $salePercent = new TextField('salePercent');
     $salePercent->setLabel($lang->text('ocsaffiliates', 'settings_sale_percent'));
     $salePercent->addValidator(new FloatValidator());
     $this->addElement($salePercent);
     $showRates = new CheckboxField('showRates');
     $showRates->setLabel($lang->text('ocsaffiliates', 'show_rates'));
     $this->addElement($showRates);
     $allowBanners = new CheckboxField('allowBanners');
     $allowBanners->setLabel($lang->text('ocsaffiliates', 'allow_banners'));
     $this->addElement($allowBanners);
     $terms = new CheckboxField('terms');
     $terms->setLabel($lang->text('ocsaffiliates', 'enable_terms'));
     $this->addElement($terms);
     $submit = new Submit('save');
     $submit->setLabel($lang->text('ocsaffiliates', 'save'));
     $this->addElement($submit);
 }
Exemplo n.º 7
0
 public function __construct()
 {
     parent::__construct('acc-type-select-form');
     $this->setMethod(Form::METHOD_GET);
     $accountType = new Selectbox('accountType');
     $accountType->addAttribute('id', 'account-type-select');
     $accTypes = BOL_QuestionService::getInstance()->findAllAccountTypesWithLabels();
     $accountType->setOptions($accTypes);
     $accountType->setHasInvitation(false);
     $this->addElement($accountType);
     $script = '$("#account-type-select").change( function(){
          $(this).parents("form:eq(0)").submit();
      });
      ';
     OW::getDocument()->addOnloadScript($script);
 }
Exemplo n.º 8
0
 public function fillAccountType($params)
 {
     if (!OW::getUser()->isAuthenticated()) {
         throw new AuthenticateException();
     }
     $user = OW::getUser()->getUserObject();
     $accountType = BOL_QuestionService::getInstance()->findAccountTypeByName($user->accountType);
     if (!empty($accountType)) {
         throw new Redirect404Exception();
     }
     $event = new OW_Event(OW_EventManager::ON_BEFORE_USER_COMPLETE_ACCOUNT_TYPE, array('user' => $user));
     OW::getEventManager()->trigger($event);
     $accounts = $this->getAccountTypes();
     if (count($accounts) == 1) {
         $accountTypeList = array_keys($accounts);
         $firstAccountType = reset($accountTypeList);
         $accountType = BOL_QuestionService::getInstance()->findAccountTypeByName($firstAccountType);
         if ($accountType) {
             $user->accountType = $firstAccountType;
             BOL_UserService::getInstance()->saveOrUpdate($user);
             //BOL_PreferenceService::getInstance()->savePreferenceValue('profile_details_update_stamp', time(), $user->getId());
             $this->redirect(OW::getRouter()->urlForRoute('base_default_index'));
         }
     }
     $form = new Form('accountTypeForm');
     $joinAccountType = new Selectbox('accountType');
     $joinAccountType->setLabel(OW::getLanguage()->text('base', 'questions_question_account_type_label'));
     $joinAccountType->setRequired();
     $joinAccountType->setOptions($accounts);
     $joinAccountType->setHasInvitation(false);
     $form->addElement($joinAccountType);
     $submit = new Submit('submit');
     $submit->addAttribute('class', 'ow_button ow_ic_save');
     $submit->setValue(OW::getLanguage()->text('base', 'continue_button'));
     $form->addElement($submit);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $this->saveRequiredQuestionsData($data, $user->id);
         }
     } else {
         OW::getDocument()->addOnloadScript(" OW.info(" . json_encode(OW::getLanguage()->text('base', 'complete_profile_info')) . ") ");
     }
     $this->addForm($form);
 }
Exemplo n.º 9
0
 public function __construct($name, $mode)
 {
     parent::__construct($name);
     $this->setAction(OW::getRouter()->urlForRoute('ocsaffiliates.action_edit'));
     $this->setAjax();
     $lang = OW::getLanguage();
     $idField = new HiddenField('affiliateId');
     $this->addElement($idField);
     $modeField = new HiddenField('mode');
     $modeField->setValue($mode);
     $this->addElement($modeField);
     if ($mode == 'admin') {
         $emailVerified = new CheckboxField('emailVerified');
         $emailVerified->setLabel($lang->text('ocsaffiliates', 'email_verified'));
         $this->addElement($emailVerified);
         $status = new Selectbox('status');
         $status->setLabel($lang->text('ocsaffiliates', 'status'));
         $status->setHasInvitation(false);
         $status->setRequired(true);
         $options = array('active' => $lang->text('ocsaffiliates', 'status_active'), 'unverified' => $lang->text('ocsaffiliates', 'status_unverified'));
         $status->setOptions($options);
         $this->addElement($status);
     }
     $affName = new TextField('name');
     $affName->setRequired(true);
     $affName->setLabel($lang->text('ocsaffiliates', 'affiliate_name'));
     $this->addElement($affName);
     $email = new TextField('email');
     $email->setRequired(true);
     $email->setLabel($lang->text('ocsaffiliates', 'email'));
     $email->addValidator(new EmailValidator());
     $this->addElement($email);
     $password = new PasswordField('password');
     $password->setLabel($lang->text('ocsaffiliates', 'password'));
     $this->addElement($password);
     $payment = new Textarea('payment');
     $payment->setRequired(true);
     $payment->setLabel($lang->text('ocsaffiliates', 'payment_details'));
     $this->addElement($payment);
     $submit = new Submit('save');
     $submit->setValue($lang->text('ocsaffiliates', 'edit'));
     $this->addElement($submit);
     $this->bindJsFunction(Form::BIND_SUCCESS, "function(data){\n            if ( !data.result ) {\n                OW.error(data.error);\n            }\n            else {\n                document.location.reload();\n            }\n        }");
 }
Exemplo n.º 10
0
function usearch_set_presentation(OW_Event $event)
{
    $params = $event->getParams();
    if ($params['type'] != 'search' || !in_array($params['fieldName'], array('sex', 'birthdate'))) {
        return;
    }
    $lang = OW::getLanguage();
    $sessionData = OW::getSession()->get(USEARCH_CLASS_QuickSearchForm::FORM_SESSEION_VAR);
    switch ($params['fieldName']) {
        case 'sex':
            $field = new Selectbox('sex');
            $field->setLabel($lang->text('usearch', 'search_label_sex'));
            $field->setHasInvitation(false);
            if (!empty($sessionData['sex'])) {
                $field->setValue($sessionData['sex']);
            }
            break;
        case 'birthdate':
            $field = new USEARCH_CLASS_AgeRangeField('birthdate');
            $field->setLabel($lang->text('usearch', 'age'));
            if (!empty($sessionData['birthdate']['from']) && !empty($sessionData['birthdate']['to'])) {
                $field->setValue($sessionData['birthdate']);
            }
            $configs = !empty($params['configs']) ? BOL_QuestionService::getInstance()->getQuestionConfig($params['configs'], 'year_range') : null;
            $max = !empty($configs['from']) ? date("Y") - (int) $configs['from'] : null;
            $min = !empty($configs['to']) ? date("Y") - (int) $configs['to'] : null;
            $field->setMaxAge($max);
            $field->setMinAge($min);
            $validator = new USEARCH_CLASS_AgeRangeValidator($min, $max);
            $errorMsg = $lang->text('usearch', 'age_range_incorrect_values', array('min' => $min, 'max' => $max));
            $validator->setErrorMessage($errorMsg);
            $field->addValidator($validator);
            break;
    }
    if (!empty($field)) {
        $event->setData($field);
    }
}
Exemplo n.º 11
0
 /**
  * Class constructor
  */
 public function __construct($providerId)
 {
     parent::__construct('provider-edit-form');
     $this->setAjax(true);
     $this->bindJsFunction(Form::BIND_SUCCESS, 'function(data){if( data.result ){OW.info(data.message);setTimeout(function(){location.reload();}, 1000);}else{OW.error(data.message);}}');
     $this->setAction(OW::getRouter()->urlForRoute('yncontactimporter-admin-ajaxEditProvider'));
     $language = OW::getLanguage();
     $provider = YNCONTACTIMPORTER_BOL_ProviderService::getInstance()->findProviderById($providerId);
     // provider id field
     $providerIdField = new HiddenField('id');
     $providerIdField->setRequired(true);
     $this->addElement($providerIdField);
     // provider title
     $providerTitle = new TextField('title');
     $providerTitle->setLabel($language->text('yncontactimporter', 'provider_title'));
     $providerTitle->setRequired(true);
     $this->addElement($providerTitle);
     for ($i = 1; $i <= 10; $i++) {
         $option[$i] = $i;
     }
     // provider order
     $providerOrder = new Selectbox('order');
     $providerOrder->setLabel($language->text('yncontactimporter', 'order'));
     $providerOrder->addOptions($option);
     $providerOrder->setHasInvitation(false);
     $this->addElement($providerOrder);
     // provider enable
     $providerEnable = new Selectbox('enable');
     $providerEnable->setLabel($language->text('yncontactimporter', 'enabled_disabled'));
     $providerEnable->addOptions(array(1 => 'Enabled', 0 => 'Disabled'));
     $providerEnable->setHasInvitation(false);
     $this->addElement($providerEnable);
     $submit = new Submit('edit');
     $submit->setValue($language->text('yncontactimporter', 'save_btn_label'));
     $this->addElement($submit);
 }
Exemplo n.º 12
0
 public function index($params)
 {
     $userId = OW::getUser()->getId();
     if (OW::getRequest()->isAjax()) {
         exit;
     }
     if (!OW::getUser()->isAuthenticated() || $userId === null) {
         throw new AuthenticateException();
     }
     $contentMenu = new BASE_CMP_PreferenceContentMenu();
     $contentMenu->getElement('privacy')->setActive(true);
     $this->addComponent('contentMenu', $contentMenu);
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('privacy', 'privacy_index'));
     $this->setPageHeadingIconClass('ow_ic_lock');
     // -- Action form --
     $privacyForm = new Form('privacyForm');
     $privacyForm->setId('privacyForm');
     $actionSubmit = new Submit('privacySubmit');
     $actionSubmit->addAttribute('class', 'ow_button ow_ic_save');
     $actionSubmit->setValue($language->text('privacy', 'privacy_submit_button'));
     $privacyForm->addElement($actionSubmit);
     // --
     $actionList = PRIVACY_BOL_ActionService::getInstance()->findAllAction();
     $actionNameList = array();
     foreach ($actionList as $action) {
         $actionNameList[$action->key] = $action->key;
     }
     $actionValueList = PRIVACY_BOL_ActionService::getInstance()->getActionValueList($actionNameList, $userId);
     $actionValuesEvent = new BASE_CLASS_EventCollector(PRIVACY_BOL_ActionService::EVENT_GET_PRIVACY_LIST);
     OW::getEventManager()->trigger($actionValuesEvent);
     $data = $actionValuesEvent->getData();
     $actionValuesInfo = empty($data) ? array() : $data;
     $optionsList = array();
     $sortOptionsList = array();
     $order = array();
     // -- sort action values
     foreach ($actionValuesInfo as $value) {
         $optionsList[$value['key']] = $value['label'];
         $order[$value['sortOrder']] = $value['key'];
     }
     asort($order);
     foreach ($order as $key) {
         $sortOptionsList[$key] = $optionsList[$key];
     }
     // --
     $resultList = array();
     foreach ($actionList as $action) {
         /* @var $action PRIVACY_CLASS_Action */
         if (!empty($action->label)) {
             $formElement = new Selectbox($action->key);
             $formElement->setLabel($action->label);
             $formElement->setDescription('');
             if (!empty($action->description)) {
                 $formElement->setDescription($action->description);
             }
             $formElement->setOptions($sortOptionsList);
             $formElement->setHasInvitation(false);
             if (!empty($actionValueList[$action->key])) {
                 $formElement->setValue($actionValueList[$action->key]);
                 if (array_key_exists($actionValueList[$action->key], $sortOptionsList)) {
                     $formElement->setValue($actionValueList[$action->key]);
                 } else {
                     if ($actionValueList[$action->key] != 'everybody') {
                         $formElement->setValue('only_for_me');
                     }
                 }
             }
             $privacyForm->addElement($formElement);
             $resultList[$action->key] = $action->key;
         }
     }
     if (OW::getRequest()->isPost()) {
         if ($privacyForm->isValid($_POST)) {
             $values = $privacyForm->getValues();
             $restul = PRIVACY_BOL_ActionService::getInstance()->saveActionValues($values, $userId);
             if ($restul) {
                 OW::getFeedback()->info($language->text('privacy', 'action_action_data_was_saved'));
             } else {
                 OW::getFeedback()->warning($language->text('privacy', 'action_action_data_not_changed'));
             }
             $this->redirect();
         }
     }
     $this->addForm($privacyForm);
     $this->assign('actionList', $resultList);
 }
Exemplo n.º 13
0
 public function index($params = array())
 {
     $userService = BOL_UserService::getInstance();
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('admin', 'massmailing'));
     $this->setPageHeadingIconClass('ow_ic_script');
     $massMailingForm = new Form('massMailingForm');
     $massMailingForm->setId('massMailingForm');
     $rolesList = BOL_AuthorizationService::getInstance()->getRoleList();
     $userRoles = new CheckboxGroup('userRoles');
     $userRoles->setLabel($language->text('admin', 'massmailing_user_roles_label'));
     foreach ($rolesList as $role) {
         if ($role->name != 'guest') {
             $userRoles->addOption($role->name, $language->text('base', 'authorization_role_' . $role->name));
         }
     }
     $massMailingForm->addElement($userRoles);
     $emailFormat = new Selectbox('emailFormat');
     $emailFormat->setLabel($language->text('admin', 'massmailing_email_format_label'));
     $emailFormat->setOptions(array(self::EMAIL_FORMAT_TEXT => $language->text('admin', 'massmailing_email_format_text'), self::EMAIL_FORMAT_HTML => $language->text('admin', 'massmailing_email_format_html')));
     $emailFormat->setValue(self::EMAIL_FORMAT_TEXT);
     $emailFormat->setHasInvitation(false);
     if (!empty($_POST['emailFormat'])) {
         $emailFormat->setValue($_POST['emailFormat']);
     }
     $massMailingForm->addElement($emailFormat);
     $subject = new TextField('subject');
     $subject->addAttribute('class', 'ow_text');
     $subject->addAttribute('style', 'width: auto;');
     $subject->setRequired();
     $subject->setLabel($language->text('admin', 'massmailing_subject_label'));
     if (!empty($_POST['subject'])) {
         $subject->setValue($_POST['subject']);
     }
     $massMailingForm->addElement($subject);
     $body = new Textarea('body');
     if ($emailFormat->getValue() == self::EMAIL_FORMAT_HTML) {
         $body = new WysiwygTextarea('body');
         $body->forceAddButtons(array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_HTML));
     }
     $body->addAttribute('class', 'ow_text');
     $body->addAttribute('style', 'width: auto;');
     $body->setRequired();
     $body->setLabel($language->text('admin', 'massmailing_body_label'));
     if (!empty($_POST['body'])) {
         $body->setValue($_POST['body']);
     }
     $massMailingForm->addElement($body);
     $submit = new Submit('startMailing');
     $submit->addAttribute('class', 'ow_button');
     $submit->setValue($language->text('admin', 'massmailing_start_mailing_button'));
     $massMailingForm->addElement($submit);
     $this->addForm($massMailingForm);
     $ignoreUnsubscribe = false;
     $isActive = true;
     if (defined('OW_PLUGIN_XP')) {
         $massMailingTimestamp = OW::getConfig()->getValue('admin', 'mass_mailing_timestamp');
         $timeout = $massMailingTimestamp + 60 * 60 * 24 - time();
         if ($timeout > 0) {
             $isActive = false;
             $this->assign('expireText', $language->text('admin', 'massmailing_expire_text', array('hours' => (int) ceil($timeout / (60 * 60)))));
         }
     }
     $this->assign('isActive', $isActive);
     $total = $userService->findMassMailingUserCount($ignoreUnsubscribe);
     if (OW::getRequest()->isPost() && $isActive && isset($_POST['startMailing'])) {
         if ($massMailingForm->isValid($_POST)) {
             $data = $massMailingForm->getValues();
             $start = 0;
             $count = self::MAILS_ARRAY_MAX_RECORDS;
             $mailCount = 0;
             $total = $userService->findMassMailingUserCount($ignoreUnsubscribe, $data['userRoles']);
             while ($start < $total) {
                 $result = $this->userService->findMassMailingUsers($start, $count, $ignoreUnsubscribe, $data['userRoles']);
                 $mails = array();
                 $userIdList = array();
                 foreach ($result as $user) {
                     $userIdList[] = $user->id;
                 }
                 $displayNameList = $this->userService->getDisplayNamesForList($userIdList);
                 $event = new BASE_CLASS_EventCollector('base.add_global_lang_keys');
                 OW::getEventManager()->trigger($event);
                 $vars = call_user_func_array('array_merge', $event->getData());
                 foreach ($result as $key => $user) {
                     $vars['user_email'] = $user->email;
                     $mail = OW::getMailer()->createMail();
                     $mail->addRecipientEmail($user->email);
                     $vars['user_name'] = $displayNameList[$user->id];
                     $code = md5($user->username . $user->password);
                     $link = OW::getRouter()->urlForRoute('base_massmailing_unsubscribe', array('id' => $user->id, 'code' => $code));
                     $subjectText = UTIL_String::replaceVars($data['subject'], $vars);
                     $mail->setSubject($subjectText);
                     if ($data['emailFormat'] === self::EMAIL_FORMAT_HTML) {
                         $htmlContent = UTIL_String::replaceVars($data['body'], $vars);
                         $htmlContent .= $language->text('admin', 'massmailing_unsubscribe_link_html', array('link' => $link));
                         $mail->setHtmlContent($htmlContent);
                         $textContent = preg_replace("/\\<br\\s*[\\/]?\\s*\\>/", "\n", $htmlContent);
                         $textContent = strip_tags($textContent);
                         $mail->setTextContent($textContent);
                     } else {
                         $textContent = UTIL_String::replaceVars($data['body'], $vars);
                         $textContent .= "\n\n" . $language->text('admin', 'massmailing_unsubscribe_link_text', array('link' => $link));
                         $mail->setTextContent($textContent);
                     }
                     $mails[] = $mail;
                     $mailCount++;
                 }
                 $start += $count;
                 //printVar($mails);
                 OW::getMailer()->addListToQueue($mails);
             }
             OW::getFeedback()->info($language->text('admin', 'massmailing_send_mails_message', array('count' => $mailCount)));
             if (defined('OW_PLUGIN_XP')) {
                 OW::getConfig()->saveConfig('admin', 'mass_mailing_timestamp', time());
             }
             $this->redirect();
         }
     }
     $this->assign('userCount', $total);
     $language->addKeyForJs('admin', 'questions_empty_lang_value');
     $language->addKeyForJs('admin', 'massmailing_total_members');
     $script = ' window.massMailing = new MassMailing(\'' . $this->ajaxResponderUrl . '\'); ';
     OW::getDocument()->addOnloadScript($script);
     $jsDir = OW::getPluginManager()->getPlugin("admin")->getStaticJsUrl();
     OW::getDocument()->addScript($jsDir . "mass_mailing.js");
 }
Exemplo n.º 14
0
 public function index($params)
 {
     $adminMode = false;
     $oneAccountType = false;
     $viewerId = OW::getUser()->getId();
     if (!OW::getUser()->isAuthenticated() || $viewerId === null) {
         throw new AuthenticateException();
     }
     if (!empty($params['userId']) && $params['userId'] != $viewerId) {
         if (OW::getUser()->isAdmin() || OW::getUser()->isAuthorized('base')) {
             $adminMode = true;
             $userId = (int) $params['userId'];
             $user = BOL_UserService::getInstance()->findUserById($userId);
             if (empty($user) || BOL_AuthorizationService::getInstance()->isSuperModerator($userId)) {
                 throw new Redirect404Exception();
             }
             $editUserId = $userId;
         } else {
             throw new Redirect403Exception();
         }
     } else {
         $editUserId = $viewerId;
         $changePassword = new BASE_CMP_ChangePassword();
         $this->addComponent("changePassword", $changePassword);
         $contentMenu = new BASE_CMP_DashboardContentMenu();
         $contentMenu->getElement('profile_edit')->setActive(true);
         $this->addComponent('contentMenu', $contentMenu);
         $user = OW::getUser()->getUserObject();
         //BOL_UserService::getInstance()->findUserById($editUserId);
     }
     $accountType = $user->accountType;
     // dispaly account type
     if (OW::getUser()->isAdmin() || OW::getUser()->isAuthorized('base')) {
         $accountType = !empty($_GET['accountType']) ? $_GET['accountType'] : $user->accountType;
         // get available account types from DB
         $accountTypes = BOL_QuestionService::getInstance()->findAllAccountTypes();
         $accounts = array();
         if (count($accountTypes) > 1) {
             /* @var $value BOL_QuestionAccount */
             foreach ($accountTypes as $key => $value) {
                 $accounts[$value->name] = OW::getLanguage()->text('base', 'questions_account_type_' . $value->name);
             }
             if (!in_array($accountType, array_keys($accounts))) {
                 if (in_array($user->accountType, array_keys($accounts))) {
                     $accountType = $user->accountType;
                 } else {
                     $accountType = BOL_QuestionService::getInstance()->getDefaultAccountType()->name;
                 }
             }
             $editAccountType = new Selectbox('accountType');
             $editAccountType->setId('accountType');
             $editAccountType->setLabel(OW::getLanguage()->text('base', 'questions_question_account_type_label'));
             $editAccountType->setRequired();
             $editAccountType->setOptions($accounts);
             $editAccountType->setHasInvitation(false);
         } else {
             $accountType = BOL_QuestionService::getInstance()->getDefaultAccountType()->name;
         }
     }
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('base', 'edit_index'));
     $this->setPageHeadingIconClass('ow_ic_user');
     // -- Edit form --
     $editForm = new EditQuestionForm('editForm', $editUserId);
     $editForm->setId('editForm');
     $this->assign('displayAccountType', false);
     // dispaly account type
     if (!empty($editAccountType)) {
         $editAccountType->setValue($accountType);
         $editForm->addElement($editAccountType);
         OW::getDocument()->addOnloadScript(" \$('#accountType').change(function() {\n\n                var form = \$(\"<form method='get'><input type='text' name='accountType' value='\" + \$(this).val() + \"' /></form>\");\n                \$('body').append(form);\n                \$(form).submit();\n\n            }  ); ");
         $this->assign('displayAccountType', true);
     }
     $editSubmit = new Submit('editSubmit');
     $editSubmit->addAttribute('class', 'ow_button ow_ic_save');
     $editSubmit->setValue($language->text('base', 'edit_button'));
     $editForm->addElement($editSubmit);
     $questions = $this->questionService->findEditQuestionsForAccountType($accountType);
     $section = null;
     $questionArray = array();
     $questionNameList = array();
     //        echo '<pre>';
     //        print_r($questions);
     //        echo '</pre>';
     $userData = BOL_QuestionService::getInstance()->getQuestionData(array($editUserId), array(HAMMU_DB_IM_USING_HAMMU_AS_KEY));
     $im_using_hammu_as = $userData[$editUserId][HAMMU_DB_IM_USING_HAMMU_AS_KEY];
     foreach ($questions as $sort => $question) {
         if ($section !== $question['sectionName']) {
             $section = $question['sectionName'];
         }
         $questionArray[$section][$sort] = $questions[$sort];
         $questionNameList[] = $questions[$sort]['name'];
     }
     echo "user->" . $editUserId;
     $this->assign('questionArray', $questionArray);
     $questionData = $this->questionService->getQuestionData(array($editUserId), $questionNameList);
     $questionValues = $this->questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     $editForm->addQuestions($questions, $questionValues, !empty($questionData[$editUserId]) ? $questionData[$editUserId] : array());
     if (OW::getRequest()->isPost() && isset($_POST['editSubmit'])) {
         if ($editForm->isValid($_POST)) {
             $data = $editForm->getValues();
             foreach ($questionArray as $section) {
                 foreach ($section as $key => $question) {
                     switch ($question['presentation']) {
                         case 'multicheckbox':
                             if (is_array($data[$question['name']])) {
                                 $data[$question['name']] = array_sum($data[$question['name']]);
                             } else {
                                 $data[$question['name']] = 0;
                             }
                             break;
                     }
                 }
             }
             // save user data
             if (!empty($user->id)) {
                 if ($this->questionService->saveQuestionsData($data, $user->id)) {
                     if (!$adminMode) {
                         $event = new OW_Event(OW_EventManager::ON_USER_EDIT, array('userId' => $user->id, 'method' => 'native'));
                         OW::getEventManager()->trigger($event);
                         OW::getFeedback()->info($language->text('base', 'edit_successfull_edit'));
                         $this->redirect();
                     } else {
                         $event = new OW_Event(OW_EventManager::ON_USER_EDIT_BY_ADMIN, array('userId' => $user->id));
                         OW::getEventManager()->trigger($event);
                         OW::getFeedback()->info($language->text('base', 'edit_successfull_edit'));
                         $this->redirect(OW::getRouter()->urlForRoute('base_user_profile', array('username' => BOL_UserService::getInstance()->getUserName($editUserId))));
                     }
                 } else {
                     OW::getFeedback()->info($language->text('base', 'edit_edit_error'));
                 }
             } else {
                 OW::getFeedback()->info($language->text('base', 'edit_edit_error'));
             }
         }
     }
     $this->addForm($editForm);
     $this->assign('unregisterProfileUrl', OW::getRouter()->urlForRoute('base_delete_user'));
     $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');
     //include js
     $onLoadJs = " window.edit = new OW_BaseFieldValidators( " . json_encode(array('formName' => $editForm->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Edit", "ajaxResponder"))) . ",\n                                                        " . UTIL_Validator::EMAIL_PATTERN . ", " . UTIL_Validator::USER_NAME_PATTERN . ", " . $editUserId . " ); ";
     $this->assign('isAdmin', OW::getUser()->isAdmin());
     OW::getDocument()->addOnloadScript($onLoadJs);
     $jsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
     OW::getDocument()->addScript($jsDir . "base_field_validators.js");
     if (!$adminMode) {
         $editSynchronizeHook = OW::getRegistry()->getArray(self::EDIT_SYNCHRONIZE_HOOK);
         if (!empty($editSynchronizeHook)) {
             $content = array();
             foreach ($editSynchronizeHook as $function) {
                 $result = call_user_func($function);
                 if (trim($result)) {
                     $content[] = $result;
                 }
             }
             $content = array_filter($content, 'trim');
             if (!empty($content)) {
                 $this->assign('editSynchronizeHook', $content);
             }
         }
     }
 }
Exemplo n.º 15
0
 /**
  * Class constructor
  *
  */
 public function __construct($clipId)
 {
     parent::__construct('vwvcEditForm');
     $language = OW::getLanguage();
     // clip id field
     $clipIdField = new HiddenField('id');
     $clipIdField->setRequired(true);
     $this->addElement($clipIdField);
     // select box for permission
     $permArr0 = array('1' => 'moderators', '3' => 'none', '2' => 'owner', '0' => 'all');
     $permArr1 = array('0' => 'all', '3' => 'none', '2' => 'owner', '1' => 'moderators');
     // room_name Field
     $room_nameField = new TextField('room_name');
     $sValidator = new StringValidator(1, 22);
     $room_nameField->addValidator($sValidator);
     $room_nameField->setRequired(true);
     $this->addElement($room_nameField->setLabel($language->text('vwvc', 'room_name')));
     // Description Field
     $descriptionField = new Textarea('description');
     $this->addElement($descriptionField->setLabel($language->text('vwvc', 'description')));
     // welcome Field
     $welcomeField = new Textarea('welcome');
     $welcomeField->setValue($language->text('vwvc', 'welcome_default'));
     $this->addElement($welcomeField->setLabel($language->text('vwvc', 'welcome')));
     // resolution Field
     $resolutionArr = array('320x240' => '320x240', '160x120' => '160x120', '176x144' => '176x144', '352x288' => '352x288', '640x480' => '640x480');
     $resolutionField = new Selectbox('resolution');
     $resolutionField->addOptions($resolutionArr);
     $resolutionField->setRequired();
     $resolutionField->setHasInvitation(false);
     $this->addElement($resolutionField->setLabel($language->text('vwvc', 'resolution')));
     // camera_fps Field
     $camera_fpsArr = array('10' => '10', '12' => '12', '20' => '20', '25' => '25', '30' => '30');
     $camera_fpsField = new Selectbox('camera_fps');
     $camera_fpsField->addOptions($camera_fpsArr);
     $camera_fpsField->setRequired();
     $camera_fpsField->setHasInvitation(false);
     $this->addElement($camera_fpsField->setLabel($language->text('vwvc', 'camera_fps')));
     // Microphone Rate Field
     $microphone_rateArr = array('11' => '11', '22' => '22', '44' => '44', '48' => '48');
     $microphone_rateField = new Selectbox('microphone_rate');
     $microphone_rateField->addOptions($microphone_rateArr);
     $microphone_rateField->setRequired();
     $microphone_rateField->setHasInvitation(false);
     $this->addElement($microphone_rateField->setLabel($language->text('vwvc', 'microphone_rate')));
     // soundQuality Field
     $soundQualityField = new TextField('soundQuality');
     $soundQualityField->setRequired(true);
     $this->addElement($soundQualityField->setLabel($language->text('vwvc', 'soundQuality')));
     // Bandwidth Field
     $bandwidthField = new TextField('bandwidth');
     $bandwidthField->setRequired(true);
     $bandwidthField->setValue(40960);
     $this->addElement($bandwidthField->setLabel($language->text('vwvc', 'bandwidth')));
     // verbose_level Field
     $verbose_levelArr = array('2' => 'warning/recoverable failure', '0' => 'nothing', '1' => 'failure', '3' => 'success', '4' => 'action');
     $verbose_levelField = new Selectbox('verbose_level');
     $verbose_levelField->addOptions($verbose_levelArr);
     $verbose_levelField->setRequired();
     $verbose_levelField->setHasInvitation(false);
     $this->addElement($verbose_levelField->setLabel($language->text('vwvc', 'verbose_level')));
     // Background url Field
     $background_urlField = new TextField('background_url');
     $this->addElement($background_urlField->setLabel($language->text('vwvc', 'background_url')));
     // Layout Code Field
     $layout_codeField = new Textarea('layout_code');
     $this->addElement($layout_codeField->setLabel($language->text('vwvc', 'layout_code')));
     // Fill window Field
     $fill_windowField = new Selectbox('fill_window');
     $fill_windowField->addOptions($permArr0);
     $fill_windowField->setRequired();
     $fill_windowField->setHasInvitation(false);
     $this->addElement($fill_windowField->setLabel($language->text('vwvc', 'fill_window')));
     // FloodProtection Field
     $flood_protectionField = new TextField('flood_protection');
     $flood_protectionField->setValue(3);
     $this->addElement($flood_protectionField->setLabel($language->text('vwvc', 'flood_protection')));
     // Filter regex Field
     $filter_regexField = new TextField('filter_regex');
     $filter_regexField->setValue('(?i)(f**k|c**t)(?-i)');
     $this->addElement($filter_regexField->setLabel($language->text('vwvc', 'filter_regex')));
     // Filter replace Field
     $filter_replaceField = new TextField('filter_replace');
     $filter_replaceField->setValue('**');
     $this->addElement($filter_replaceField->setLabel($language->text('vwvc', 'filter_replace')));
     // Show Camera Settings Field
     $show_camera_settingsField = new Selectbox('show_camera_settings');
     $show_camera_settingsField->addOptions($permArr1);
     $show_camera_settingsField->setRequired();
     $show_camera_settingsField->setHasInvitation(false);
     $this->addElement($show_camera_settingsField->setLabel($language->text('vwvc', 'show_camera_settings')));
     // Advanced Camera Settings Field
     $advanced_camera_settingsField = new Selectbox('advanced_camera_settings');
     $advanced_camera_settingsField->addOptions($permArr1);
     $advanced_camera_settingsField->setRequired();
     $advanced_camera_settingsField->setHasInvitation(false);
     $this->addElement($advanced_camera_settingsField->setLabel($language->text('vwvc', 'advanced_camera_settings')));
     // Configure Source Field
     $configure_sourceField = new Selectbox('configure_source');
     $configure_sourceField->addOptions($permArr1);
     $configure_sourceField->setRequired();
     $configure_sourceField->setHasInvitation(false);
     $this->addElement($configure_sourceField->setLabel($language->text('vwvc', 'configure_source')));
     // Disable Video Field
     $disable_videoField = new Selectbox('disable_video');
     $disable_videoField->addOptions($permArr1);
     $disable_videoField->setRequired();
     $disable_videoField->setHasInvitation(false);
     $this->addElement($disable_videoField->setLabel($language->text('vwvc', 'disable_video')));
     // disable_sound Field
     $disable_soundField = new Selectbox('disable_sound');
     $disable_soundField->addOptions($permArr1);
     $disable_soundField->setRequired();
     $disable_soundField->setHasInvitation(false);
     $this->addElement($disable_soundField->setLabel($language->text('vwvc', 'disable_sound')));
     // panel Files Field
     $panel_filesField = new Selectbox('panel_files');
     $panel_filesField->addOptions($permArr1);
     $panel_filesField->setRequired();
     $panel_filesField->setHasInvitation(false);
     $this->addElement($panel_filesField->setLabel($language->text('vwvc', 'panel_files')));
     // panel rooms Field
     $panel_roomsField = new Selectbox('panel_rooms');
     $panel_roomsField->addOptions($permArr1);
     $panel_roomsField->setRequired();
     $panel_roomsField->setHasInvitation(false);
     $this->addElement($panel_roomsField->setLabel($language->text('vwvc', 'panel_rooms')));
     // panel users Field
     $panel_usersField = new Selectbox('panel_users');
     $panel_usersField->addOptions($permArr1);
     $panel_usersField->setRequired();
     $panel_usersField->setHasInvitation(false);
     $this->addElement($panel_usersField->setLabel($language->text('vwvc', 'panel_users')));
     // File Upload Field
     $file_uploadField = new Selectbox('file_upload');
     $file_uploadField->addOptions($permArr1);
     $file_uploadField->setRequired();
     $file_uploadField->setHasInvitation(false);
     $this->addElement($file_uploadField->setLabel($language->text('vwvc', 'file_upload')));
     // file_delete Field
     $file_deleteField = new Selectbox('file_delete');
     $file_deleteField->addOptions($permArr0);
     $file_deleteField->setRequired();
     $file_deleteField->setHasInvitation(false);
     $this->addElement($file_deleteField->setLabel($language->text('vwvc', 'file_delete')));
     // Tutorial Field
     $tutorialField = new Selectbox('tutorial');
     $tutorialField->addOptions($permArr1);
     $tutorialField->setRequired();
     $tutorialField->setHasInvitation(false);
     $this->addElement($tutorialField->setLabel($language->text('vwvc', 'tutorial')));
     // Auto View Cameras Field
     $auto_view_camerasField = new Selectbox('auto_view_cameras');
     $auto_view_camerasField->addOptions($permArr1);
     $auto_view_camerasField->setRequired();
     $auto_view_camerasField->setHasInvitation(false);
     $this->addElement($auto_view_camerasField->setLabel($language->text('vwvc', 'auto_view_cameras')));
     // Show Timer Field
     $show_timerField = new Selectbox('show_timer');
     $show_timerField->addOptions($permArr1);
     $show_timerField->setRequired();
     $show_timerField->setHasInvitation(false);
     $this->addElement($show_timerField->setLabel($language->text('vwvc', 'show_timer')));
     // writeText Field
     $write_textField = new Selectbox('write_text');
     $write_textField->addOptions($permArr1);
     $write_textField->setRequired();
     $write_textField->setHasInvitation(false);
     $this->addElement($write_textField->setLabel($language->text('vwvc', 'write_text')));
     // regularWatch Field
     $regular_watchField = new Selectbox('regular_watch');
     $regular_watchField->addOptions($permArr1);
     $regular_watchField->setRequired();
     $regular_watchField->setHasInvitation(false);
     $this->addElement($regular_watchField->setLabel($language->text('vwvc', 'regular_watch')));
     // newWatch Field
     $new_watchField = new Selectbox('new_watch');
     $new_watchField->addOptions($permArr1);
     $new_watchField->setRequired();
     $new_watchField->setHasInvitation(false);
     $this->addElement($new_watchField->setLabel($language->text('vwvc', 'new_watch')));
     // privateTextchat Field
     $private_textchatField = new Selectbox('private_textchat');
     $private_textchatField->addOptions($permArr1);
     $private_textchatField->setRequired();
     $private_textchatField->setHasInvitation(false);
     $this->addElement($private_textchatField->setLabel($language->text('vwvc', 'private_textchat')));
     // user_list Field
     $user_listField = new Textarea('user_list');
     $this->addElement($user_listField->setLabel($language->text('vwvc', 'user_list')));
     // moderator_list Field
     $moderator_listField = new Textarea('moderator_list');
     $userService = BOL_UserService::getInstance();
     $user = $userService->findUserById(OW::getUser()->getId());
     $username = $user->getUsername();
     $moderator_listField->setValue($username);
     $this->addElement($moderator_listField->setLabel($language->text('vwvc', 'moderator_list')));
     // administrator Field
     $administratorField = new Selectbox('administrator');
     $administratorField->addOptions($permArr0);
     $administratorField->setRequired();
     $administratorField->setHasInvitation(false);
     $this->addElement($administratorField->setLabel($language->text('vwvc', 'administrator')));
     // clean_up Field
     $clean_upField = new TextField('clean_up');
     $clean_upField->setValue(0);
     $this->addElement($clean_upField->setLabel($language->text('vwvc', 'clean_up')));
     $entityTags = BOL_TagService::getInstance()->findEntityTags($clipId, 'vwvc');
     if ($entityTags) {
         $tags = array();
         foreach ($entityTags as $entityTag) {
             $tags[] = $entityTag->label;
         }
         $tagsField = new TagsField('tags', $tags);
     } else {
         $tagsField = new TagsField('tags');
     }
     $this->addElement($tagsField->setLabel($language->text('vwvc', 'tags')));
     $submit = new Submit('edit');
     $submit->setValue($language->text('vwvc', 'btn_edit'));
     $this->addElement($submit);
 }
Exemplo n.º 16
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();
     $stepCount = 1;
     $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);
     if ($this->displayAccountType) {
         $joinAccountType = new Selectbox('accountType');
         $joinAccountType->setLabel(OW::getLanguage()->text('base', 'questions_question_account_type_label'));
         $joinAccountType->setRequired();
         $joinAccountType->setOptions($accounts);
         $joinAccountType->setValue($this->accountType);
         $joinAccountType->setHasInvitation(false);
         $this->addElement($joinAccountType);
     }
     $this->getQuestions();
     $section = null;
     //$this->questionListBySection = array();
     $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);
 }
Exemplo n.º 17
0
 protected function addGenderQuestions($controller, $accounts, $questionValueList, $questionData)
 {
     $controller->assign('displayGender', false);
     $controller->assign('displayAccountType', false);
     if (count($accounts) > 1) {
         $controller->assign('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);
     }
 }
Exemplo n.º 18
0
 protected function init($params = array())
 {
     $accountTypes = $this->questionService->findAllAccountTypes();
     $serviceLang = BOL_LanguageService::getInstance();
     $language = OW::getLanguage();
     $currentLanguageId = OW::getLanguage()->getCurrentId();
     $accounts = array();
     /* @var $value BOL_QuestionAccount */
     foreach ($accountTypes as $value) {
         $accounts[$value->name] = $this->questionService->getAccountTypeLang($value->name);
     }
     $sections = $this->questionService->findSortedSectionList();
     // need to hide sections select box
     if (empty($sections)) {
         $this->assign('no_sections', true);
     }
     $sectionsArray = array();
     /* @var $section BOL_QuestionSection */
     foreach ($sections as $section) {
         $sectionsArray[$section->name] = $language->text('base', 'questions_section_' . $section->name . '_label');
     }
     $event = new OW_Event('base.question.add_question_form.on_get_available_sections', $sectionsArray, $sectionsArray);
     OW::getEventManager()->trigger($event);
     $sectionsArray = $event->getData();
     $presentationList = array_keys($this->presentations2types);
     $presentations = array();
     $presentationsLabel = array();
     foreach ($presentationList as $item) {
         $presentations[$item] = $item;
         $presentationsLabel[$item] = $language->text('base', 'questions_question_presentation_' . $item . '_label');
     }
     $presentation = $presentationList[0];
     if (isset($_POST['qst_answer_type']) && isset($presentations[$_POST['qst_answer_type']])) {
         $presentation = $presentations[$_POST['qst_answer_type']];
     }
     $qstName = new TextField('qst_name');
     $qstName->setLabel($language->text('admin', 'questions_question_name_label'));
     //$qstName->addValidator(new StringValidator(0, 24000));
     $qstName->setRequired();
     $this->addElement($qstName);
     $qstName = new TextField('qst_description');
     $qstName->setLabel($language->text('admin', 'questions_question_description_label'));
     //$qstName->addValidator(new StringValidator(0, 24000));
     $this->addElement($qstName);
     if (count($accountTypes) > 1) {
         $qstAccountType = new CheckboxGroup('qst_account_type');
         $qstAccountType->setLabel($language->text('admin', 'questions_for_account_type_label'));
         $qstAccountType->setRequired();
         $qstAccountType->setDescription($language->text('admin', 'questions_for_account_type_description'));
         $qstAccountType->setOptions($accounts);
         $this->addElement($qstAccountType);
     }
     if (!empty($sectionsArray)) {
         $qstSection = new Selectbox('qst_section');
         $qstSection->setLabel($language->text('admin', 'questions_question_section_label'));
         $qstSection->setOptions($sectionsArray);
         $qstSection->setHasInvitation(false);
         $this->addElement($qstSection);
     }
     $qstAnswerType = new Selectbox('qst_answer_type');
     $qstAnswerType->setLabel($language->text('admin', 'questions_answer_type_label'));
     $qstAnswerType->addAttribute('class', $qstAnswerType->getName());
     $qstAnswerType->setOptions($presentationsLabel);
     $qstAnswerType->setRequired();
     $qstAnswerType->setHasInvitation(false);
     $qstAnswerType->setValue($presentation);
     $this->addElement($qstAnswerType);
     //        if ( $displayPossibleValues )
     //        {
     $qstPossibleValues = new addValueField('qst_possible_values');
     //$qstPossibleValues->addAttribute('class', $qstPossibleValues->getName());
     $qstPossibleValues->setLabel($language->text('admin', 'questions_possible_values_label'));
     $qstPossibleValues->setDescription($language->text('admin', 'questions_possible_values_description'));
     //$qstPossibleValues->setValue( array( '1' => 'aaa', '2' => 'bbbb', '4' => 'ccc' ) );
     $this->addElement($qstPossibleValues);
     //        }
     $configList = $this->questionConfigs;
     foreach ($configList as $config) {
         $className = $config->presentationClass;
         /* @var $qstConfig OW_FormElement */
         $qstConfig = OW::getClassInstance($className, $config->name);
         $qstConfig->setLabel($language->text('admin', 'questions_config_' . $config->name . '_label'));
         if (!empty($config->description)) {
             $qstConfig->setDescription($config->description);
         }
         $this->addElement($qstConfig);
     }
     $qstColumnCount = new Selectbox('qst_column_count');
     $qstColumnCount->addAttribute('class', $qstColumnCount->getName());
     $qstColumnCount->setLabel($language->text('admin', 'questions_columns_count_label'));
     $qstColumnCount->setOptions($this->qstColumnCountValues);
     $qstColumnCount->setValue(1);
     $this->addElement($qstColumnCount);
     $qstRequired = new CheckboxField('qst_required');
     $qstRequired->setLabel($language->text('admin', 'questions_required_label'));
     $qstRequired->setDescription($language->text('admin', 'questions_required_description'));
     $this->addElement($qstRequired);
     $qstOnSignUp = new CheckboxField('qst_on_sign_up');
     $qstOnSignUp->setLabel($language->text('admin', 'questions_on_sing_up_label'));
     $qstOnSignUp->setDescription($language->text('admin', 'questions_on_sing_up_description'));
     $this->addElement($qstOnSignUp);
     $qstOnEdit = new CheckboxField('qst_on_edit');
     $qstOnEdit->setLabel($language->text('admin', 'questions_on_edit_label'));
     $qstOnEdit->setDescription($language->text('admin', 'questions_on_edit_description'));
     $this->addElement($qstOnEdit);
     $qstOnView = new CheckboxField('qst_on_view');
     $qstOnView->setLabel($language->text('admin', 'questions_on_view_label'));
     $qstOnView->setDescription($language->text('admin', 'questions_on_view_description'));
     $this->addElement($qstOnView);
     $qstOnSearch = new CheckboxField('qst_on_search');
     $qstOnSearch->setLabel($language->text('admin', 'questions_on_search_label'));
     $qstOnSearch->setDescription($language->text('admin', 'questions_on_search_description'));
     $this->addElement($qstOnSearch);
     $qstSubmit = new Submit('qst_submit');
     $qstSubmit->setValue($language->text('admin', 'save_btn_label'));
     $qstSubmit->addAttribute('class', 'ow_button ow_ic_save');
     $this->addElement($qstSubmit);
     $this->addElement($qstSubmit);
 }
Exemplo n.º 19
0
 public function edit($params)
 {
     if (!isset($params['questionId'])) {
         throw new Redirect404Exception();
     }
     $questionId = (int) @$params['questionId'];
     if (empty($questionId)) {
         throw new Redirect404Exception();
     }
     $this->addContentMenu();
     $this->contentMenu->getElement('qst_index')->setActive(true);
     $editQuestion = $this->questionService->findQuestionById($questionId);
     $parent = $editQuestion->parent;
     $parentIsset = false;
     if (!empty($parent)) {
         $parentDto = $this->questionService->findQuestionByName($parent);
         $parentIsset = !empty($parentDto) ? true : false;
         if ($parentIsset) {
             $this->assign('parentUrl', OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'edit', array("questionId" => $parentDto->id)));
             $this->assign('parentLabel', $this->questionService->getQuestionLang($parentDto->name));
         }
     }
     $this->assign('parentIsset', $parentIsset);
     if ($editQuestion === null) {
         throw new Redirect404Exception();
     }
     $this->assign('question', $editQuestion);
     //$editQuestionToAccountType = $this->questionService->findAccountTypeByQuestionName( $editQuestion->name );
     // get available account types from DB
     /* @var BOL_QuestionService $this->questionService */
     $accountTypes = $this->questionService->findAllAccountTypes();
     $serviceLang = BOL_LanguageService::getInstance();
     $language = OW::getLanguage();
     $currentLanguageId = OW::getLanguage()->getCurrentId();
     $accounts = array(BOL_QuestionService::ALL_ACCOUNT_TYPES => $language->text('base', 'questions_account_type_all'));
     /* @var $value BOL_QuestionAccount */
     foreach ($accountTypes as $value) {
         $accounts[$value->name] = $language->text('base', 'questions_account_type_' . $value->name);
     }
     $sections = $this->questionService->findAllSections();
     // need to hide sections select box
     if (empty($section)) {
         $this->assign('no_sections', true);
     }
     $sectionsArray = array();
     /* @var $section BOL_QuestionSection */
     foreach ($sections as $section) {
         $sectionsArray[$section->name] = $language->text('base', 'questions_section_' . $section->name . '_label');
     }
     $presentations = array();
     $presentationsLabel = array();
     $presentationList = $this->questionService->getPresentations();
     if ($editQuestion->name != 'password') {
         unset($presentationList[BOL_QuestionService::QUESTION_PRESENTATION_PASSWORD]);
     }
     foreach ($presentationList as $presentationKey => $presentation) {
         if ($presentationList[$editQuestion->presentation] == $presentation) {
             $presentations[$presentationKey] = $presentationKey;
             //TODO add langs with presentation labels
             $presentationsLabel[$presentationKey] = $language->text('base', 'questions_question_presentation_' . $presentationKey . '_label');
         }
     }
     $presentation = $editQuestion->presentation;
     if (OW::getSession()->isKeySet(self::EDIT_QUESTION_SESSION_VAR)) {
         $session = OW::getSession()->get(self::EDIT_QUESTION_SESSION_VAR);
         if (isset($session['qst_answer_type']) && isset($presentations[$session['qst_answer_type']])) {
             $presentation = $presentations[$session['qst_answer_type']];
         }
     }
     if (isset($_POST['qst_answer_type']) && isset($presentations[$_POST['qst_answer_type']])) {
         $presentation = $presentations[$_POST['qst_answer_type']];
     }
     //$this->addForm(new LanguageValueEditForm( 'base', 'questions_question_' . ($editQuestion->id) . '_label', $this ) );
     //--  -------------------------------------
     //--  add question values form creating
     //--  -------------------------------------
     $questionValues = $this->questionService->findQuestionValues($editQuestion->name);
     $this->assign('questionValues', $questionValues);
     //add field values form
     $addQuestionValuesForm = new AddValuesForm($questionId);
     $addQuestionValuesForm->setAction($this->ajaxResponderUrl);
     $this->addForm($addQuestionValuesForm);
     //--  -------------------------------------
     //--  edit field form creating
     //--  -------------------------------------
     $editForm = new Form('qst_edit_form');
     $editForm->setId('qst_edit_form');
     $disableActionList = array('disable_account_type' => false, 'disable_answer_type' => false, 'disable_presentation' => false, 'disable_column_count' => false, 'disable_display_config' => false, 'disable_required' => false, 'disable_on_join' => false, 'disable_on_view' => false, 'disable_on_search' => false, 'disable_on_edit' => false);
     $event = new OW_Event('admin.disable_fields_on_edit_profile_question', array('questionDto' => $editQuestion), $disableActionList);
     OW::getEventManager()->trigger($event);
     $disableActionList = $event->getData();
     if (count($accountTypes) > 1) {
         $qstAccountType = new Selectbox('qst_account_type');
         $qstAccountType->setLabel($language->text('admin', 'questions_for_account_type_label'));
         $qstAccountType->setDescription($language->text('admin', 'questions_for_account_type_description'));
         $qstAccountType->setOptions($accounts);
         $qstAccountType->setValue(BOL_QuestionService::ALL_ACCOUNT_TYPES);
         $qstAccountType->setHasInvitation(false);
         if ($editQuestion->accountTypeName !== null) {
             $qstAccountType->setValue($editQuestion->accountTypeName);
         }
         if ($editQuestion->base == 1) {
             $qstAccountType->addAttribute('disabled', 'disabled');
         } else {
             if ($disableActionList['disable_account_type']) {
                 $qstAnswerType->setRequired(false);
                 $qstAccountType->addAttribute('disabled', 'disabled');
             }
         }
         $editForm->addElement($qstAccountType);
     }
     if (!empty($sectionsArray)) {
         $qstSection = new Selectbox('qst_section');
         $qstSection->setLabel($language->text('admin', 'questions_question_section_label'));
         $qstSection->setOptions($sectionsArray);
         $qstSection->setValue($editQuestion->sectionName);
         $qstSection->setHasInvitation(false);
         $editForm->addElement($qstSection);
     }
     $qstAnswerType = new Selectbox('qst_answer_type');
     $qstAnswerType->setLabel($language->text('admin', 'questions_answer_type_label'));
     $qstAnswerType->addAttribute('class', $qstAnswerType->getName());
     $qstAnswerType->setOptions($presentationsLabel);
     $qstAnswerType->setValue($presentation);
     $qstAnswerType->setRequired();
     $qstAnswerType->setHasInvitation(false);
     if ($parentIsset) {
         $qstAnswerType->setValue($parentDto->columnCount);
         $qstAnswerType->addAttribute('disabled', 'disabled');
     }
     if ((int) $editQuestion->base === 1 || count($presentations) <= 1 || $parentIsset || $disableActionList['disable_answer_type']) {
         $qstAnswerType->setRequired(false);
         $qstAnswerType->addAttribute('disabled', 'disabled');
     }
     $editForm->addElement($qstAnswerType);
     $columnCountPresentation = array(BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX, BOL_QuestionService::QUESTION_PRESENTATION_RADIO);
     if (in_array($presentation, $columnCountPresentation)) {
         $qstColumnCount = new Selectbox('qst_column_count');
         $qstColumnCount->addAttribute('class', $qstColumnCount->getName());
         $qstColumnCount->setLabel($language->text('admin', 'questions_columns_count_label'));
         $qstColumnCount->setRequired();
         $qstColumnCount->setOptions($this->qstColumnCountValues);
         $qstColumnCount->setValue($editQuestion->columnCount);
         $parentIsset = !empty($parentDto) ? true : false;
         if ($parentIsset) {
             $qstColumnCount->setValue($parentDto->columnCount);
             $qstColumnCount->addAttribute('disabled', 'disabled');
             $qstColumnCount->setRequired(false);
         } else {
             if ($disableActionList['disable_column_count']) {
                 $qstAnswerType->setRequired(false);
                 $qstAnswerType->addAttribute('disabled', 'disabled');
             }
         }
         $editForm->addElement($qstColumnCount);
     }
     $presentationConfigList = BOL_QuestionService::getInstance()->getConfigList($presentation);
     $presentationConfigValues = json_decode($editQuestion->custom, true);
     if ($editQuestion->name !== 'joinStamp' && !$disableActionList['disable_display_config']) {
         foreach ($presentationConfigList as $config) {
             $className = $config->presentationClass;
             /* @var $qstConfig OW_FormElement */
             $qstConfig = new $className($config->name);
             $qstConfig->setLabel($language->text('admin', 'questions_config_' . $config->name . '_label'));
             if (!empty($config->description)) {
                 $qstConfig->setDescription($config->description);
             }
             if (isset($presentationConfigValues[$config->name])) {
                 $qstConfig->setValue($presentationConfigValues[$config->name]);
             }
             $editForm->addElement($qstConfig);
         }
     }
     $qstRequired = new CheckboxField('qst_required');
     $qstRequired->setLabel($language->text('admin', 'questions_required_label'));
     $qstRequired->setDescription($language->text('admin', 'questions_required_description'));
     $qstRequired->setValue((bool) $editQuestion->required);
     if ((int) $editQuestion->base === 1 || $disableActionList['disable_required']) {
         $qstRequired->addAttribute('disabled', 'disabled');
     }
     $editForm->addElement($qstRequired);
     $qstOnSignUp = new CheckboxField('qst_on_sign_up');
     $qstOnSignUp->setLabel($language->text('admin', 'questions_on_sing_up_label'));
     $qstOnSignUp->setDescription($language->text('admin', 'questions_on_sing_up_description'));
     $qstOnSignUp->setValue((bool) $editQuestion->onJoin);
     if ((int) $editQuestion->base === 1 || $disableActionList['disable_on_join']) {
         $qstOnSignUp->addAttribute('disabled', 'disabled');
     }
     $editForm->addElement($qstOnSignUp);
     $qstOnEdit = new CheckboxField('qst_on_edit');
     $qstOnEdit->setLabel($language->text('admin', 'questions_on_edit_label'));
     $qstOnEdit->setDescription($language->text('admin', 'questions_on_edit_description'));
     $qstOnEdit->setValue((bool) $editQuestion->onEdit);
     $description = $language->text('admin', 'questions_on_edit_description');
     if ($editQuestion->name === 'username') {
         $qstOnEdit->setDescription($language->text('admin', 'questions_on_edit_description') . "<br/><br/>" . $language->text('admin', 'questions_edit_username_warning'));
     } else {
         if ((int) $editQuestion->base === 1 || $disableActionList['disable_on_edit']) {
             $qstOnEdit->addAttribute('disabled', 'disabled');
         }
     }
     $editForm->addElement($qstOnEdit);
     $qstOnView = new CheckboxField('qst_on_view');
     $qstOnView->setLabel($language->text('admin', 'questions_on_view_label'));
     $qstOnView->setDescription($language->text('admin', 'questions_on_view_description'));
     $qstOnView->setValue((bool) $editQuestion->onView);
     if ((int) $editQuestion->base === 1 && $editQuestion->name !== 'joinStamp' || $disableActionList['disable_on_view']) {
         $qstOnView->addAttribute('disabled', 'disabled');
     }
     $editForm->addElement($qstOnView);
     $qstOnSearch = new CheckboxField('qst_on_search');
     $qstOnSearch->setLabel($language->text('admin', 'questions_on_search_label'));
     $qstOnSearch->setDescription($language->text('admin', 'questions_on_search_description'));
     $qstOnSearch->setValue((bool) $editQuestion->onSearch);
     if ((int) $editQuestion->base === 1 && $editQuestion->name != 'username' || $parentIsset || $disableActionList['disable_on_search']) {
         $qstOnSearch->addAttribute('disabled', 'disabled');
     }
     $editForm->addElement($qstOnSearch);
     $qstSubmit = new Submit('qst_submit');
     $qstSubmit->addAttribute('class', 'ow_button ow_ic_save');
     $qstSubmit->setValue($language->text('admin', 'btn_label_edit'));
     $editForm->addElement($qstSubmit);
     if (OW::getSession()->isKeySet(self::EDIT_QUESTION_SESSION_VAR)) {
         $editForm->setValues(OW::getSession()->get(self::EDIT_QUESTION_SESSION_VAR));
         OW::getSession()->delete(self::EDIT_QUESTION_SESSION_VAR);
     }
     $this->addForm($editForm);
     if (OW_Request::getInstance()->isPost()) {
         if ((isset($_POST['qst_submit_and_add']) || isset($_POST['qst_submit'])) && $editForm->isValid($_POST)) {
             OW::getSession()->delete(self::EDIT_QUESTION_SESSION_VAR);
             $updated = false;
             $data = $editForm->getValues();
             $elements = $editForm->getElements();
             foreach ($elements as $element) {
                 if (!$element->getAttribute('disabled')) {
                     switch ($element->getName()) {
                         case 'qst_required':
                             $editQuestion->required = isset($_POST['qst_required']) ? 1 : 0;
                             break;
                         case 'qst_on_sign_up':
                             $editQuestion->onJoin = isset($_POST['qst_on_sign_up']) ? 1 : 0;
                             break;
                         case 'qst_on_edit':
                             $editQuestion->onEdit = isset($_POST['qst_on_edit']) ? 1 : 0;
                             break;
                         case 'qst_on_search':
                             $editQuestion->onSearch = isset($_POST['qst_on_search']) ? 1 : 0;
                             break;
                         case 'qst_on_view':
                             $editQuestion->onView = isset($_POST['qst_on_view']) ? 1 : 0;
                             break;
                         case 'qst_answer_type':
                             $editQuestion->presentation = htmlspecialchars($data['qst_answer_type']);
                             break;
                         case 'qst_column_count':
                             $editQuestion->columnCount = htmlspecialchars($data['qst_column_count']);
                             break;
                         case 'qst_section':
                             if (!empty($data['qst_section'])) {
                                 $section = $this->questionService->findSectionBySectionName(htmlspecialchars(trim($data['qst_section'])));
                                 $sectionName = null;
                                 if (isset($section)) {
                                     $sectionName = $section->name;
                                 }
                                 if ($editQuestion->sectionName !== $sectionName) {
                                     $editQuestion->sectionName = $sectionName;
                                     $editQuestion->sortOrder = (int) BOL_QuestionService::getInstance()->findLastQuestionOrder($editQuestion->sectionName) + 1;
                                 }
                             }
                             break;
                         case 'qst_account_type':
                             if ($data['qst_account_type'] !== null) {
                                 $editQuestion->accountTypeName = htmlspecialchars(trim($data['qst_account_type']));
                                 if ($editQuestion->accountTypeName === BOL_QuestionService::ALL_ACCOUNT_TYPES) {
                                     $editQuestion->accountTypeName = null;
                                 }
                             }
                             break;
                     }
                 }
             }
             if (!$disableActionList['disable_display_config']) {
                 // save question configs
                 $configs = array();
                 foreach ($presentationConfigList as $config) {
                     if (isset($data[$config->name])) {
                         $configs[$config->name] = $data[$config->name];
                     }
                 }
                 $editQuestion->custom = json_encode($configs);
             }
             $this->questionService->saveOrUpdateQuestion($editQuestion);
             if (OW::getDbo()->getAffectedRows() > 0) {
                 $updated = true;
                 $list = $this->questionService->findQuestionChildren($editQuestion->name);
                 /* @var BOL_Question $child */
                 foreach ($list as $child) {
                     $child->columnCount = $editQuestion->columnCount;
                     $this->questionService->saveOrUpdateQuestion($child);
                 }
             }
             //update question values sort
             if (isset($_POST['question_values_order'])) {
                 $valuesOrder = json_decode($_POST['question_values_order'], true);
                 if (isset($valuesOrder) && count($valuesOrder) > 0 && is_array($valuesOrder)) {
                     foreach ($questionValues as $questionValue) {
                         if (isset($valuesOrder[$questionValue->value])) {
                             $questionValue->sortOrder = (int) $valuesOrder[$questionValue->value];
                         }
                         $this->questionService->saveOrUpdateQuestionValue($questionValue);
                         if (OW::getDbo()->getAffectedRows() > 0) {
                             $updated = true;
                         }
                     }
                 }
             }
             if ($updated) {
                 OW::getFeedback()->info($language->text('admin', 'questions_update_question_message'));
             } else {
                 OW::getFeedback()->info($language->text('admin', 'questions_question_was_not_updated_message'));
             }
             //exit;
             $this->redirect(OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'index'));
         }
         $editForm->setValues($_POST);
         OW::getSession()->set(self::EDIT_QUESTION_SESSION_VAR, $_POST);
         //OW::getFeedback()->error($language->text('admin', 'questions_question_was_not_updated_message'));
         $this->redirect();
     }
     $types = array();
     foreach ($this->questionService->getPresentations() as $presentation => $type) {
         if ($type === 'select') {
             $types[] = $presentation;
         }
     }
     $questionLabel = $this->questionService->getQuestionLang($editQuestion->name);
     $questionDescription = $this->questionService->getQuestionDescriptionLang($editQuestion->name);
     $noValue = $language->text('admin', 'questions_empty_lang_value');
     $questionLabel = mb_strlen(trim($questionLabel)) == 0 || $questionLabel == '&nbsp;' ? $noValue : $questionLabel;
     $questionDescription = mb_strlen(trim($questionDescription)) == 0 || $questionDescription == '&nbsp;' ? $noValue : $questionDescription;
     $this->assign('questionLabel', $questionLabel);
     $this->assign('questionDescription', $questionDescription);
     $language->addKeyForJs('admin', 'questions_empty_lang_value');
     $language->addKeyForJs('admin', 'questions_edit_question_name_title');
     $language->addKeyForJs('admin', 'questions_edit_question_description_title');
     $language->addKeyForJs('admin', 'questions_edit_question_value_title');
     $language->addKeyForJs('admin', 'questions_edit_delete_value_confirm_message');
     $fields = array();
     foreach ($editForm->getElements() as $element) {
         if (!$element instanceof HiddenField) {
             $fields[$element->getName()] = $element->getName();
         }
     }
     $this->assign('formData', $fields);
     $script = '
                 window.editQuestion = new editQuestion(' . json_encode(array('types' => $types, 'ajaxResponderUrl' => $this->ajaxResponderUrl)) . ');
                 ';
     OW::getDocument()->addOnloadScript($script);
     $jsDir = OW::getPluginManager()->getPlugin("admin")->getStaticJsUrl();
     $baseJsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
     OW::getDocument()->addScript($jsDir . "questions.js");
     OW::getDocument()->addScript($baseJsDir . "jquery-ui.min.js");
 }
Exemplo n.º 20
0
 /**
  * Class constructor
  *
  */
 public function __construct($clipId)
 {
     parent::__construct('vwlsEditForm');
     $language = OW::getLanguage();
     // clip id field
     $clipIdField = new HiddenField('id');
     $clipIdField->setRequired(true);
     $this->addElement($clipIdField);
     // select box for broadcasting
     $arr1 = array('1' => 'yes', '0' => 'no');
     $arr0 = array('0' => 'no', '1' => 'yes');
     // select box for permission
     $permArr0 = array('1' => 'moderators', '3' => 'none', '2' => 'owner', '0' => 'all');
     $permArr1 = array('0' => 'all', '3' => 'none', '2' => 'owner', '1' => 'moderators');
     $permArr2 = array('3' => 'none', '2' => 'owner', '1' => 'moderators', '0' => 'all');
     // room_name Field
     $generated = base_convert(time() - 1224000000 . rand(0, 10), 10, 36);
     $room_nameField = new TextField('room_name');
     $sValidator = new StringValidator(1, 22);
     $room_nameField->addValidator($sValidator);
     $room_nameField->setRequired(true);
     $room_nameField->setValue($generated);
     $this->addElement($room_nameField->setLabel($language->text('vwls', 'room_name')));
     // Description Field
     $descriptionField = new Textarea('description');
     $this->addElement($descriptionField->setLabel($language->text('vwls', 'description')));
     // Room limit Field
     $room_limitField = new TextField('room_limit');
     $room_limitField->setRequired(false);
     $room_limitField->setValue(0);
     $this->addElement($room_limitField->setLabel($language->text('vwls', 'room_limit')));
     // Show Camera Settings Field
     $show_camera_settingsField = new Selectbox('show_camera_settings');
     $show_camera_settingsField->addOptions($arr1);
     $show_camera_settingsField->setRequired();
     $show_camera_settingsField->setHasInvitation(false);
     $this->addElement($show_camera_settingsField->setLabel($language->text('vwls', 'show_camera_settings')));
     // Advanced Camera Settings Field
     $advanced_camera_settingsField = new Selectbox('advanced_camera_settings');
     $advanced_camera_settingsField->addOptions($arr1);
     $advanced_camera_settingsField->setRequired();
     $advanced_camera_settingsField->setHasInvitation(false);
     $this->addElement($advanced_camera_settingsField->setLabel($language->text('vwls', 'advanced_camera_settings')));
     // Configure Source Field
     $configure_sourceField = new Selectbox('configure_source');
     $configure_sourceField->addOptions($arr1);
     $configure_sourceField->setRequired();
     $configure_sourceField->setHasInvitation(false);
     $this->addElement($configure_sourceField->setLabel($language->text('vwls', 'configure_source')));
     // user_list Field
     $user_listField = new Textarea('user_list');
     $this->addElement($user_listField->setLabel($language->text('vwls', 'user_list')));
     // moderator_list Field
     $moderator_listField = new Textarea('moderator_list');
     $userService = BOL_UserService::getInstance();
     $user = $userService->findUserById(OW::getUser()->getId());
     $username = $user->getUsername();
     $moderator_listField->setValue($username);
     $this->addElement($moderator_listField->setLabel($language->text('vwls', 'moderator_list')));
     // administrator Field
     /**        $administratorField = new Selectbox('administrator');
             $administratorField->addOptions($permArr0);
             $administratorField->setRequired();
             $administratorField->setHasInvitation(false);
             $this->addElement($administratorField->setLabel($language->text('vwls', 'administrator')));
     */
     // clean_up Field
     $clean_upField = new TextField('clean_up');
     $clean_upField->setValue(0);
     $this->addElement($clean_upField->setLabel($language->text('vwls', 'clean_up')));
     // Broadcasting
     // welcome Field
     $welcomeField = new Textarea('welcome');
     $welcomeField->setValue($language->text('vwls', 'welcome_default'));
     $this->addElement($welcomeField->setLabel($language->text('vwls', 'welcome')));
     // Only video Field
     $only_videoField = new Selectbox('only_video');
     $only_videoField->addOptions($arr0);
     $only_videoField->setRequired();
     $only_videoField->setHasInvitation(false);
     $this->addElement($only_videoField->setLabel($language->text('vwls', 'only_video')));
     // No Video Field
     $no_videoField = new Selectbox('no_video');
     $no_videoField->addOptions($arr0);
     $no_videoField->setRequired();
     $no_videoField->setHasInvitation(false);
     $this->addElement($no_videoField->setLabel($language->text('vwls', 'no_video')));
     // No Embeds Field
     $no_embedsField = new Selectbox('no_embeds');
     $no_embedsField->addOptions($arr0);
     $no_embedsField->setRequired();
     $no_embedsField->setHasInvitation(false);
     $this->addElement($no_embedsField->setLabel($language->text('vwls', 'no_embeds')));
     // Show Timer Field
     $show_timerField = new Selectbox('show_timer');
     $show_timerField->addOptions($arr1);
     $show_timerField->setRequired();
     $show_timerField->setHasInvitation(false);
     $this->addElement($show_timerField->setLabel($language->text('vwls', 'show_timer')));
     // writeText Field
     $write_textField = new Selectbox('write_text');
     $write_textField->addOptions($arr1);
     $write_textField->setRequired();
     $write_textField->setHasInvitation(false);
     $this->addElement($write_textField->setLabel($language->text('vwls', 'write_text')));
     // resolution Field
     $resolutionArr = array('320x240' => '320x240', '160x120' => '160x120', '176x144' => '176x144', '352x288' => '352x288', '640x480' => '640x480');
     $resolutionField = new Selectbox('resolution');
     $resolutionField->addOptions($resolutionArr);
     $resolutionField->setRequired();
     $resolutionField->setHasInvitation(false);
     $this->addElement($resolutionField->setLabel($language->text('vwls', 'resolution')));
     // camera_fps Field
     $camera_fpsArr = array('10' => '10', '12' => '12', '20' => '20', '25' => '25', '30' => '30');
     $camera_fpsField = new Selectbox('camera_fps');
     $camera_fpsField->addOptions($camera_fpsArr);
     $camera_fpsField->setRequired();
     $camera_fpsField->setHasInvitation(false);
     $this->addElement($camera_fpsField->setLabel($language->text('vwls', 'camera_fps')));
     // Microphone Rate Field
     $microphone_rateArr = array('11' => '11', '22' => '22', '44' => '44', '48' => '48');
     $microphone_rateField = new Selectbox('microphone_rate');
     $microphone_rateField->addOptions($microphone_rateArr);
     $microphone_rateField->setRequired();
     $microphone_rateField->setHasInvitation(false);
     $this->addElement($microphone_rateField->setLabel($language->text('vwls', 'microphone_rate')));
     // soundQuality Field
     $soundQualityField = new TextField('soundQuality');
     $soundQualityField->setRequired(true);
     $this->addElement($soundQualityField->setLabel($language->text('vwls', 'soundQuality')));
     // Bandwidth Field
     $bandwidthField = new TextField('bandwidth');
     $bandwidthField->setRequired(true);
     $bandwidthField->setValue(40960);
     $this->addElement($bandwidthField->setLabel($language->text('vwls', 'bandwidth')));
     // FloodProtection Field
     $flood_protectionField = new TextField('flood_protection');
     $flood_protectionField->setValue(3);
     $this->addElement($flood_protectionField->setLabel($language->text('vwls', 'flood_protection')));
     // verbose_level Field
     $verbose_levelArr = array('2' => 'warning/recoverable failure', '0' => 'nothing', '1' => 'failure', '3' => 'success', '4' => 'action');
     $verbose_levelField = new Selectbox('verbose_level');
     $verbose_levelField->addOptions($verbose_levelArr);
     $verbose_levelField->setRequired();
     $verbose_levelField->setHasInvitation(false);
     $this->addElement($verbose_levelField->setLabel($language->text('vwls', 'verbose_level')));
     // Label Color Field
     $label_colorField = new TextField('label_color');
     $label_colorField->setValue('FFFFFF');
     $this->addElement($label_colorField->setLabel($language->text('vwls', 'label_color')));
     // privateTextchat Field
     $private_textchatField = new Selectbox('private_textchat');
     $private_textchatField->addOptions($arr1);
     $private_textchatField->setRequired();
     $private_textchatField->setHasInvitation(false);
     $this->addElement($private_textchatField->setLabel($language->text('vwls', 'private_textchat')));
     // Layout Code Field
     $layout_codeField = new Textarea('layout_code');
     $this->addElement($layout_codeField->setLabel($language->text('vwls', 'layout_code')));
     // Fill window Field
     $fill_windowField = new Selectbox('fill_window');
     $fill_windowField->addOptions($arr1);
     $fill_windowField->setRequired();
     $fill_windowField->setHasInvitation(false);
     $this->addElement($fill_windowField->setLabel($language->text('vwls', 'fill_window')));
     // Video / Watch
     // welcome Field
     $welcome2Field = new Textarea('welcome2');
     $welcome2Field->setValue($language->text('vwls', 'welcome_default2'));
     $this->addElement($welcome2Field->setLabel($language->text('vwls', 'welcome2')));
     // Offline message Field
     $offline_messageField = new Textarea('offline_message');
     $this->addElement($offline_messageField->setLabel($language->text('vwls', 'offline_message')));
     // FloodProtection2 Field
     $flood_protection2Field = new TextField('flood_protection2');
     $flood_protection2Field->setValue(3);
     $this->addElement($flood_protection2Field->setLabel($language->text('vwls', 'flood_protection2')));
     // Filter regex Field
     $filter_regexField = new TextField('filter_regex');
     $filter_regexField->setValue('(?i)(f**k|c**t)(?-i)');
     $this->addElement($filter_regexField->setLabel($language->text('vwls', 'filter_regex')));
     // Filter replace Field
     $filter_replaceField = new TextField('filter_replace');
     $filter_replaceField->setValue('**');
     $this->addElement($filter_replaceField->setLabel($language->text('vwls', 'filter_replace')));
     // Layout Code2 Field
     $layout_code2Field = new Textarea('layout_code2');
     $this->addElement($layout_code2Field->setLabel($language->text('vwls', 'layout_code2')));
     // Fill window2 Field
     $fill_window2Field = new Selectbox('fill_window2');
     $fill_window2Field->addOptions($permArr0);
     $fill_window2Field->setRequired();
     $fill_window2Field->setHasInvitation(false);
     $this->addElement($fill_window2Field->setLabel($language->text('vwls', 'fill_window2')));
     // writeText2 Field
     $write_text2Field = new Selectbox('write_text2');
     $write_text2Field->addOptions($permArr1);
     $write_text2Field->setRequired();
     $write_text2Field->setHasInvitation(false);
     $this->addElement($write_text2Field->setLabel($language->text('vwls', 'write_text2')));
     // Enable Video Field
     $enable_videoField = new Selectbox('enable_video');
     $enable_videoField->addOptions($permArr1);
     $enable_videoField->setRequired();
     $enable_videoField->setHasInvitation(false);
     $this->addElement($enable_videoField->setLabel($language->text('vwls', 'enable_video')));
     // Enable chat Field
     $enable_chatField = new Selectbox('enable_chat');
     $enable_chatField->addOptions($permArr1);
     $enable_chatField->setRequired();
     $enable_chatField->setHasInvitation(false);
     $this->addElement($enable_chatField->setLabel($language->text('vwls', 'enable_chat')));
     // Enable users Field
     $enable_usersField = new Selectbox('enable_users');
     $enable_usersField->addOptions($permArr1);
     $enable_usersField->setRequired();
     $enable_usersField->setHasInvitation(false);
     $this->addElement($enable_usersField->setLabel($language->text('vwls', 'enable_users')));
     $entityTags = BOL_TagService::getInstance()->findEntityTags($clipId, 'vwls');
     if ($entityTags) {
         $tags = array();
         foreach ($entityTags as $entityTag) {
             $tags[] = $entityTag->label;
         }
         $tagsField = new TagsField('tags', $tags);
     } else {
         $tagsField = new TagsField('tags');
     }
     $this->addElement($tagsField->setLabel($language->text('vwls', 'tags')));
     $submit = new Submit('edit');
     $submit->setValue($language->text('vwls', 'btn_edit'));
     $this->addElement($submit);
 }
Exemplo n.º 21
0
 public function __construct($controller)
 {
     parent::__construct('MainSearchForm');
     $this->controller = $controller;
     $questionService = BOL_QuestionService::getInstance();
     $language = OW::getLanguage();
     $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();
     }
     $accounts = $this->getAccountTypes();
     $accountList = array();
     $accountList[BOL_QuestionService::ALL_ACCOUNT_TYPES] = OW::getLanguage()->text('base', 'questions_account_type_' . BOL_QuestionService::ALL_ACCOUNT_TYPES);
     foreach ($accounts as $key => $account) {
         $accountList[$key] = $account;
     }
     $keys = array_keys($accountList);
     $this->accountType = $keys[0];
     if (isset($questionData['accountType']) && in_array($questionData['accountType'], $keys)) {
         $this->accountType = $questionData['accountType'];
     }
     if (count($accounts) > 1) {
         $this->displayAccountType = true;
         $accountType = new Selectbox('accountType');
         $accountType->setLabel(OW::getLanguage()->text('base', 'questions_question_account_type_label'));
         $accountType->setRequired();
         $accountType->setOptions($accountList);
         $accountType->setValue($this->accountType);
         $accountType->setHasInvitation(false);
         $this->addElement($accountType);
     }
     $questions = $questionService->findSearchQuestionsForAccountType($this->accountType);
     $mainSearchQuestion = array();
     $questionNameList = array();
     foreach ($questions as $key => $question) {
         $sectionName = $question['sectionName'];
         $mainSearchQuestion[$sectionName][] = $question;
         $questionNameList[] = $question['name'];
         $questions[$key]['required'] = '0';
     }
     $questionValueList = $questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     $this->addQuestions($questions, $questionValueList, $questionData);
     $controller->assign('questionList', $mainSearchQuestion);
     $controller->assign('displayAccountType', $this->displayAccountType);
 }
Exemplo n.º 22
0
 /**
  *
  * Constructor
  * @param $prefix
  * @param $key
  * @param BASE_CMP_LanguageValueEdit $parent
  */
 public function __construct(BOL_QuestionAccountType $accountType, $formName = '')
 {
     if (empty($formName)) {
         $formName = 'account_type_' . sha1(rand(0, 99999999));
     }
     parent::__construct($formName);
     $key = BOL_QuestionService::getInstance()->getQuestionLangKeyName(BOL_QuestionService::LANG_KEY_TYPE_ACCOUNT_TYPE, $accountType->name);
     $prefix = 'base';
     $this->setAjax(true);
     $this->setAction(OW::getRouter()->urlFor("ADMIN_CTRL_Questions", "ajaxResponder"));
     $hidden = new HiddenField('command');
     $hidden->setValue('AddAccountType');
     $this->addElement($hidden);
     $hidden = new HiddenField('key');
     $hidden->setValue($key);
     $this->addElement($hidden);
     $hidden = new HiddenField('prefix');
     $hidden->setValue($prefix);
     $this->addElement($hidden);
     $hidden = new HiddenField('accountTypeName');
     $hidden->setValue($accountType->name);
     $this->addElement($hidden);
     $languageService = BOL_LanguageService::getInstance();
     $list = $languageService->findActiveList();
     foreach ($list as $item) {
         $textArea = new Textarea("lang[{$item->getId()}][{$prefix}][{$key}]");
         $dto = $languageService->getValue($item->getId(), $prefix, $key);
         $value = $dto !== null ? $dto->getValue() : '';
         $textArea->setValue($value);
         $textArea->addAttribute('style', 'height: 32px;');
         $this->addElement($textArea);
     }
     $roleList = BOL_AuthorizationService::getInstance()->findNonGuestRoleList();
     $defaultRole = null;
     if (!empty($accountType->roleId)) {
         $defaultRole = BOL_AuthorizationService::getInstance()->getRoleById($accountType->roleId);
     }
     if (empty($defaultRole)) {
         $defaultRole = BOL_AuthorizationService::getInstance()->getDefaultRole();
     }
     $options = array();
     foreach ($roleList as $role) {
         $options[$role->id] = BOL_AuthorizationService::getInstance()->getRoleLabel($role->name);
     }
     $roleFormElement = new Selectbox('role');
     $roleFormElement->setOptions($options);
     $roleFormElement->setValue($defaultRole->id);
     $roleFormElement->setHasInvitation(false);
     $this->addElement($roleFormElement);
     if (!empty($accountType->id)) {
         $accountTypes = BOL_QuestionService::getInstance()->findAllAccountTypes();
         if (count($accountTypes) > 1) {
             $options = array();
             $i = 1;
             foreach ($accountTypes as $dto) {
                 /* @var $dto BOL_QuestionAccountType  */
                 $options[$dto->sortOrder] = $i;
                 $i++;
             }
             $orderFormElement = new Selectbox('order');
             $orderFormElement->setOptions($options);
             $orderFormElement->setValue($accountType->sortOrder);
             $orderFormElement->setHasInvitation(false);
             $this->addElement($orderFormElement);
         }
     }
     $submit = new Submit('submit');
     $submit->setValue(OW::getLanguage()->text('admin', 'questions_add_new_account_type'));
     $jsString = ' owForms[{$formName}].bind("success", function(json){
         if ( json.result.add == true) {
             OW.registerLanguageKey("base", ' . json_encode($key) . ', json.accountTypeName);
             OW.trigger("admin.add_account_type", [json], this);
         }
     }); ';
     OW::getLanguage()->addKeyForJs($prefix, $key);
     if (!empty($accountType->id)) {
         $jsString = ' owForms[{$formName}].bind("success", function(json){
             if ( json.result.update == true) {
                 OW.registerLanguageKey("base", ' . json_encode($key) . ', json.accountTypeName);
                 OW.trigger("admin.update_account_type", [json], this);
             }
         }); ';
     }
     $script = UTIL_JsGenerator::composeJsString($jsString, array('formName' => $this->getName()));
     OW::getDocument()->addOnloadScript($script);
     if ($accountType->id) {
         $submit->setValue(OW::getLanguage()->text('admin', 'questions_save_account_type'));
     }
     $this->addElement($submit);
 }
Exemplo n.º 23
0
 /**
  * Class constructor
  *
  */
 public function __construct()
 {
     parent::__construct('mailSettingsForm');
     $language = OW::getLanguage();
     // Mail Settings
     $smtpField = new CheckboxField('mailSmtpEnabled');
     $this->addElement($smtpField);
     $smtpField = new TextField('mailSmtpHost');
     $this->addElement($smtpField);
     $smtpField = new TextField('mailSmtpUser');
     $this->addElement($smtpField);
     $smtpField = new TextField('mailSmtpPassword');
     $this->addElement($smtpField);
     $smtpField = new TextField('mailSmtpPort');
     $this->addElement($smtpField);
     $smtpField = new Selectbox('mailSmtpConnectionPrefix');
     $smtpField->setHasInvitation(true);
     $smtpField->setInvitation(OW::getLanguage()->text('admin', 'mail_smtp_secure_invitation'));
     $smtpField->addOption('ssl', 'SSL');
     $smtpField->addOption('tls', 'TLS');
     $this->addElement($smtpField);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('admin', 'save_btn_label'));
     $this->addElement($submit);
 }
Exemplo n.º 24
0
 /**
  * @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);
     //        }
 }
Exemplo n.º 25
0
 public function sitemap()
 {
     $language = OW::getLanguage();
     $config = OW::getConfig();
     $form = new Form('sitemap_form');
     $sitemapUrl = new TextField('sitemap_url');
     $sitemapUrl->setLabel($language->text('oaseo', 'sitemap_url_label'));
     $sitemapUrl->setDescription($language->text('oaseo', 'sitemap_url_desc'));
     $sitemapUrl->setValue(OW_URL_HOME . $config->getValue('oaseo', 'sitemap_url'));
     $form->addElement($sitemapUrl);
     //        $rorUrl = new TextField('ror_url');
     //        $rorUrl->setLabel($language->text('oaseo', 'ror_url_label'));
     //        $rorUrl->setDescription($language->text('oaseo', 'ror_url_desc'));
     //        $rorUrl->setValue(OW_URL_HOME . $config->getValue('oaseo', 'ror_url'));
     //        $form->addElement($rorUrl);
     $imageUrl = new TextField('imagemap_url');
     $imageUrl->setLabel($language->text('oaseo', 'imagemap_url_label'));
     $imageUrl->setDescription($language->text('oaseo', 'imagemap_url_desc'));
     $imageUrl->setValue(OW_URL_HOME . $config->getValue('oaseo', 'imagemap_url'));
     $form->addElement($imageUrl);
     $undateFreq = new Selectbox('update_freq');
     $options = array('86400' => 'Daily', '604800' => 'Weekly', '2419200' => 'Monthly');
     $undateFreq->setHasInvitation(false);
     $undateFreq->addOptions($options);
     $undateFreq->setLabel($language->text('oaseo', 'update_freq_label'));
     $undateFreq->setDescription($language->text('oaseo', 'update_freq_desc'));
     $form->addElement($undateFreq);
     $undateFreq->setValue($config->getValue('oaseo', 'update_freq'));
     //        $prio = new CheckboxField('prio');
     //        $prio->setLabel($language->text('oaseo', 'prio_label'));
     //        $prio->setDescription($language->text('oaseo', 'prio_desc'));
     //        $form->addElement($prio);
     //        $email = new TextField('email');
     //        $email->setLabel($language->text('oaseo', 'email_label'));
     //        $email->setDescription($language->text('oaseo', 'email_desc'));
     //        $form->addElement($email);
     $inform = new CheckboxGroup('inform');
     $inform->setLabel($language->text('oaseo', 'inform_label'));
     $inform->setDescription($language->text('oaseo', 'inform_desc'));
     $inform->setOptions(array('google' => 'Google', 'bing' => 'Bing', 'yahoo' => 'Yahoo', 'ask' => 'Ask'));
     $form->addElement($inform);
     $inform->setValue(json_decode($config->getValue('oaseo', 'inform')));
     //        $extlink = new CheckboxField('extlink');
     //        $extlink->setLabel($language->text('oaseo', 'extlink_label'));
     //        $extlink->setDescription($language->text('oaseo', 'extlink_desc'));
     //        $form->addElement($extlink);
     //
     //        $brock = new CheckboxField('brock_link');
     //        $brock->setLabel($language->text('oaseo', 'brock_link_label'));
     //        $brock->setDescription($language->text('oaseo', 'brock_link_desc'));
     //        $form->addElement($brock);
     $submit = new Submit('submit');
     $submit->setValue(OW::getLanguage()->text('admin', 'save_btn_label'));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isPost() && $form->isValid($_POST)) {
         $data = $form->getValues();
         $config->saveConfig('oaseo', 'sitemap_url', str_replace(OW_URL_HOME, '', $data['sitemap_url']));
         $config->saveConfig('oaseo', 'imagemap_url', str_replace(OW_URL_HOME, '', $data['imagemap_url']));
         $config->saveConfig('oaseo', 'update_freq', (int) $data['update_freq']);
         $config->saveConfig('oaseo', 'inform', json_encode($data['inform'] ? $data['inform'] : array()));
     }
 }
Exemplo n.º 26
0
 public function index()
 {
     $this->setPageTitle(OW::getLanguage()->text('contactus', 'index_page_title'));
     $this->setPageHeading(OW::getLanguage()->text('contactus', 'index_page_heading'));
     $contactEmails = array();
     $contacts = CONTACTUS_BOL_Service::getInstance()->getDepartmentList();
     foreach ($contacts as $contact) {
         /* @var $contact CONTACTUS_BOL_Department */
         $contactEmails[$contact->id]['label'] = CONTACTUS_BOL_Service::getInstance()->getDepartmentLabel($contact->id);
         $contactEmails[$contact->id]['email'] = $contact->email;
     }
     $form = new Form('contact_form');
     $fieldTo = new Selectbox('to');
     foreach ($contactEmails as $id => $value) {
         $fieldTo->addOption($id, $value['label']);
     }
     $fieldTo->setRequired();
     $fieldTo->setHasInvitation(false);
     $fieldTo->setLabel($this->text('contactus', 'form_label_to'));
     $form->addElement($fieldTo);
     $fieldFrom = new TextField('from');
     $fieldFrom->setLabel($this->text('contactus', 'form_label_from'));
     $fieldFrom->setRequired();
     $fieldFrom->addValidator(new EmailValidator());
     if (ow::getUser()->isAuthenticated()) {
         $fieldFrom->setValue(OW::getUser()->getEmail());
     }
     $form->addElement($fieldFrom);
     $fieldSubject = new TextField('subject');
     $fieldSubject->setLabel($this->text('contactus', 'form_label_subject'));
     $fieldSubject->setRequired();
     $form->addElement($fieldSubject);
     $fieldMessage = new Textarea('message');
     $fieldMessage->setLabel($this->text('contactus', 'form_label_message'));
     $fieldMessage->setRequired();
     $form->addElement($fieldMessage);
     $fieldCaptcha = new CaptchaField('captcha');
     $fieldCaptcha->setLabel($this->text('contactus', 'form_label_captcha'));
     $form->addElement($fieldCaptcha);
     $submit = new Submit('send');
     $submit->setValue($this->text('contactus', 'form_label_submit'));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             if (!array_key_exists($data['to'], $contactEmails)) {
                 OW::getFeedback()->error($this->text('contactus', 'no_department'));
                 return;
             }
             $mail = OW::getMailer()->createMail();
             $mail->addRecipientEmail($contactEmails[$data['to']]['email']);
             $mail->setSender($data['from']);
             $mail->setSenderSuffix(false);
             $mail->setSubject($data['subject']);
             $mail->setTextContent($data['message']);
             OW::getMailer()->addToQueue($mail);
             OW::getSession()->set('contactus.dept', $contactEmails[$data['to']]['label']);
             $this->redirectToAction('sent');
         }
     }
 }
Exemplo n.º 27
0
 protected function init(array $accounts)
 {
     if ($this->displayAccountType) {
         $joinAccountType = new Selectbox('accountType');
         $joinAccountType->setLabel(OW::getLanguage()->text('base', 'questions_question_account_type_label'));
         $joinAccountType->setRequired();
         $joinAccountType->setOptions($accounts);
         $joinAccountType->setValue($this->accountType);
         $joinAccountType->setHasInvitation(false);
         $this->addElement($joinAccountType);
     }
 }
Exemplo n.º 28
0
 public function index($params)
 {
     $adminMode = false;
     $viewerId = OW::getUser()->getId();
     if (!OW::getUser()->isAuthenticated() || $viewerId === null) {
         throw new AuthenticateException();
     }
     if (!empty($params['userId']) && $params['userId'] != $viewerId) {
         if (OW::getUser()->isAdmin() || OW::getUser()->isAuthorized('base')) {
             $adminMode = true;
             $userId = (int) $params['userId'];
             $user = BOL_UserService::getInstance()->findUserById($userId);
             if (empty($user) || BOL_AuthorizationService::getInstance()->isSuperModerator($userId)) {
                 throw new Redirect404Exception();
             }
             $editUserId = $userId;
         } else {
             throw new Redirect403Exception();
         }
     } else {
         $editUserId = $viewerId;
         $changePassword = new BASE_CMP_ChangePassword();
         $this->addComponent("changePassword", $changePassword);
         $contentMenu = new BASE_CMP_DashboardContentMenu();
         $contentMenu->getElement('profile_edit')->setActive(true);
         $this->addComponent('contentMenu', $contentMenu);
         $user = OW::getUser()->getUserObject();
         //BOL_UserService::getInstance()->findUserById($editUserId);
     }
     $changeList = BOL_PreferenceService::getInstance()->getPreferenceValue(self::PREFERENCE_LIST_OF_CHANGES, $editUserId);
     if (empty($changeList)) {
         $changeList = '[]';
     }
     $this->assign('changeList', json_decode($changeList, true));
     $isEditedUserModerator = BOL_AuthorizationService::getInstance()->isModerator($editUserId) || BOL_AuthorizationService::getInstance()->isSuperModerator($editUserId);
     $accountType = $user->accountType;
     // dispaly account type
     if (OW::getUser()->isAdmin() || OW::getUser()->isAuthorized('base')) {
         $accountType = !empty($_GET['accountType']) ? $_GET['accountType'] : $user->accountType;
         // get available account types from DB
         $accountTypes = BOL_QuestionService::getInstance()->findAllAccountTypes();
         $accounts = array();
         if (count($accountTypes) > 1) {
             /* @var $value BOL_QuestionAccount */
             foreach ($accountTypes as $key => $value) {
                 $accounts[$value->name] = OW::getLanguage()->text('base', 'questions_account_type_' . $value->name);
             }
             if (!in_array($accountType, array_keys($accounts))) {
                 if (in_array($user->accountType, array_keys($accounts))) {
                     $accountType = $user->accountType;
                 } else {
                     $accountType = BOL_QuestionService::getInstance()->getDefaultAccountType()->name;
                 }
             }
             $editAccountType = new Selectbox('accountType');
             $editAccountType->setId('accountType');
             $editAccountType->setLabel(OW::getLanguage()->text('base', 'questions_question_account_type_label'));
             $editAccountType->setRequired();
             $editAccountType->setOptions($accounts);
             $editAccountType->setHasInvitation(false);
         } else {
             $accountType = BOL_QuestionService::getInstance()->getDefaultAccountType()->name;
         }
     }
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('base', 'edit_index'));
     $this->setPageHeadingIconClass('ow_ic_user');
     // -- Edit form --
     $editForm = new EditQuestionForm('editForm', $editUserId);
     $editForm->setId('editForm');
     $this->assign('displayAccountType', false);
     // dispaly account type
     if (!empty($editAccountType)) {
         $editAccountType->setValue($accountType);
         $editForm->addElement($editAccountType);
         OW::getDocument()->addOnloadScript(" \$('#accountType').change(function() {\n                \n                var form = \$(\"<form method='get'><input type='text' name='accountType' value='\" + \$(this).val() + \"' /></form>\");\n                \$('body').append(form);\n                \$(form).submit();\n\n            }  ); ");
         $this->assign('displayAccountType', true);
     }
     $userId = !empty($params['userId']) ? $params['userId'] : $viewerId;
     // add avatar field
     $editAvatar = OW::getClassInstance("BASE_CLASS_AvatarField", 'avatar', false);
     $editAvatar->setLabel(OW::getLanguage()->text('base', 'questions_question_user_photo_label'));
     $editAvatar->setValue(BOL_AvatarService::getInstance()->getAvatarUrl($userId, 1, null, true, false));
     $displayPhotoUpload = OW::getConfig()->getValue('base', 'join_display_photo_upload');
     // add the required avatar validator
     if ($displayPhotoUpload == BOL_UserService::CONFIG_JOIN_DISPLAY_AND_SET_REQUIRED_PHOTO_UPLOAD) {
         $avatarValidator = OW::getClassInstance("BASE_CLASS_AvatarFieldValidator", true, $userId);
         $editAvatar->addValidator($avatarValidator);
     }
     $editForm->addElement($editAvatar);
     $isUserApproved = BOL_UserService::getInstance()->isApproved($editUserId);
     $this->assign('isUserApproved', $isUserApproved);
     // add submit button
     $editSubmit = new Submit('editSubmit');
     $editSubmit->addAttribute('class', 'ow_button ow_ic_save');
     $editSubmit->setValue($language->text('base', 'edit_button'));
     if ($adminMode && !$isUserApproved) {
         $editSubmit->setName('saveAndApprove');
         $editSubmit->setValue($language->text('base', 'save_and_approve'));
         // TODO: remove
         if (!$isEditedUserModerator) {
             // add delete button
             $script = UTIL_JsGenerator::newInstance()->jQueryEvent('input.delete_user_by_moderator', 'click', 'OW.Users.deleteUser(e.data.userId, e.data.callbackUrl, false);', array('e'), array('userId' => $userId, 'callbackUrl' => OW::getRouter()->urlForRoute('base_member_dashboard')));
             OW::getDocument()->addOnloadScript($script);
         }
     }
     $editForm->addElement($editSubmit);
     // prepare question list
     $questions = $this->questionService->findEditQuestionsForAccountType($accountType);
     $section = null;
     $questionArray = array();
     $questionNameList = array();
     foreach ($questions as $sort => $question) {
         if ($section !== $question['sectionName']) {
             $section = $question['sectionName'];
         }
         $questionArray[$section][$sort] = $questions[$sort];
         $questionNameList[] = $questions[$sort]['name'];
     }
     $this->assign('questionArray', $questionArray);
     $questionData = $this->questionService->getQuestionData(array($editUserId), $questionNameList);
     $questionValues = $this->questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     // add question to form
     $editForm->addQuestions($questions, $questionValues, !empty($questionData[$editUserId]) ? $questionData[$editUserId] : array());
     // process form
     if (OW::getRequest()->isPost()) {
         if (isset($_POST['editSubmit']) || isset($_POST['saveAndApprove'])) {
             $this->process($editForm, $user->id, $questionArray, $adminMode);
         }
     }
     $this->addForm($editForm);
     $deleteUrl = OW::getRouter()->urlForRoute('base_delete_user');
     $this->assign('unregisterProfileUrl', $deleteUrl);
     // add langs to js
     $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');
     //include js
     $onLoadJs = " window.edit = new OW_BaseFieldValidators( " . json_encode(array('formName' => $editForm->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Edit", "ajaxResponder"))) . ",\n                                                        " . UTIL_Validator::EMAIL_PATTERN . ", " . UTIL_Validator::USER_NAME_PATTERN . ", " . $editUserId . " ); ";
     $this->assign('isAdmin', OW::getUser()->isAdmin());
     $this->assign('isEditedUserModerator', $isEditedUserModerator);
     $this->assign('adminMode', $adminMode);
     $approveEnabled = OW::getConfig()->getValue('base', 'mandatory_user_approve');
     $this->assign('approveEnabled', $approveEnabled);
     OW::getDocument()->addOnloadScript('
         $("input.write_message_button").click( function() {
                 OW.ajaxFloatBox("BASE_CMP_SendMessageToEmail", [' . (int) $editUserId . '],
                 {
                     title: ' . json_encode($language->text('base', 'send_message_to_email')) . ',
                     width:600
                 });
             }
         );
     ');
     OW::getDocument()->addOnloadScript($onLoadJs);
     $jsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
     OW::getDocument()->addScript($jsDir . "base_field_validators.js");
     if (!$adminMode) {
         $editSynchronizeHook = OW::getRegistry()->getArray(self::EDIT_SYNCHRONIZE_HOOK);
         if (!empty($editSynchronizeHook)) {
             $content = array();
             foreach ($editSynchronizeHook as $function) {
                 $result = call_user_func($function);
                 if (trim($result)) {
                     $content[] = $result;
                 }
             }
             $content = array_filter($content, 'trim');
             if (!empty($content)) {
                 $this->assign('editSynchronizeHook', $content);
             }
         }
     }
 }
Exemplo n.º 29
0
 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        }");
 }
Exemplo n.º 30
0
 /**
  * Class constructor
  *
  */
 public function __construct()
 {
     parent::__construct('configSaveForm');
     $language = OW::getLanguage();
     // baseSwf_url Field
     $baseSwf_urlField = new TextField('baseSwf_url');
     $baseSwf_urlField->addAttribute('readonly', 'readonly');
     $this->addElement($baseSwf_urlField->setLabel($language->text('vwvc', 'baseSwf_url')));
     // server Field
     $serverField = new TextField('server');
     $serverField->setRequired(true);
     $this->addElement($serverField->setLabel($language->text('vwvc', 'server')));
     // serverAMF Field
     $serverAMFField = new TextField('serverAMF');
     $serverAMFField->setRequired(true);
     $this->addElement($serverAMFField->setLabel($language->text('vwvc', 'serverAMF')));
     // serverRTMFP Field
     $serverRTMFPField = new TextField('serverRTMFP');
     $serverRTMFPField->setRequired(true);
     $this->addElement($serverRTMFPField->setLabel($language->text('vwvc', 'serverRTMFP')));
     // select box for certain parameters
     $par = array('0' => 'no', '1' => 'yes');
     $par1 = array('1' => 'yes', '0' => 'no');
     // enableRTMP Field
     $enableRTMPField = new Selectbox('enableRTMP');
     $enableRTMPField->addOptions($par1);
     $enableRTMPField->setRequired();
     $enableRTMPField->setHasInvitation(false);
     $this->addElement($enableRTMPField->setLabel($language->text('vwvc', 'enableRTMP')));
     // enableP2P Field
     $enableP2PField = new Selectbox('enableP2P');
     $enableP2PField->addOptions($par);
     $enableP2PField->setRequired();
     $enableP2PField->setHasInvitation(false);
     $this->addElement($enableP2PField->setLabel($language->text('vwvc', 'enableP2P')));
     // supportRTMP Field
     $supportRTMPField = new Selectbox('supportRTMP');
     $supportRTMPField->addOptions($par1);
     $supportRTMPField->setRequired();
     $supportRTMPField->setHasInvitation(false);
     $this->addElement($supportRTMPField->setLabel($language->text('vwvc', 'supportRTMP')));
     // supportP2P Field
     $supportP2PField = new Selectbox('supportP2P');
     $supportP2PField->addOptions($par1);
     $supportP2PField->setRequired();
     $supportP2PField->setHasInvitation(false);
     $this->addElement($supportP2PField->setLabel($language->text('vwvc', 'supportP2P')));
     // alwaysRTMP Field
     $alwaysRTMPField = new Selectbox('alwaysRTMP');
     $alwaysRTMPField->addOptions($par);
     $alwaysRTMPField->setRequired();
     $alwaysRTMPField->setHasInvitation(false);
     $this->addElement($alwaysRTMPField->setLabel($language->text('vwvc', 'alwaysRTMP')));
     // alwaysP2P Field
     $alwaysP2PField = new Selectbox('alwaysP2P');
     $alwaysP2PField->addOptions($par);
     $alwaysP2PField->setRequired();
     $alwaysP2PField->setHasInvitation(false);
     $this->addElement($alwaysP2PField->setLabel($language->text('vwvc', 'alwaysP2P')));
     // videoCodec Field
     $videoCodecField = new TextField('videoCodec');
     $videoCodecField->setRequired(true);
     $this->addElement($videoCodecField->setLabel($language->text('vwvc', 'videoCodec')));
     // codecLevel Field
     $codecLevelField = new TextField('codecLevel');
     $codecLevelField->setRequired(true);
     $this->addElement($codecLevelField->setLabel($language->text('vwvc', 'codecLevel')));
     // codecProfile Field
     $codecProfileArr = array('main' => 'main', 'baseline' => 'baseline');
     $codecProfileField = new Selectbox('codecProfile');
     $codecProfileField->addOptions($codecProfileArr);
     $codecProfileField->setRequired();
     $codecProfileField->setHasInvitation(false);
     $this->addElement($codecProfileField->setLabel($language->text('vwvc', 'codecProfile')));
     // soundCodec Field
     $soundCodecArr = array('Speex' => 'Speex', 'Nellymoser' => 'Nellymoser');
     $soundCodecField = new Selectbox('soundCodec');
     $soundCodecField->addOptions($soundCodecArr);
     $soundCodecField->setRequired();
     $soundCodecField->setHasInvitation(false);
     $this->addElement($soundCodecField->setLabel($language->text('vwvc', 'soundCodec')));
     // p2pGroup Field
     $p2pGroupField = new TextField('p2pGroup');
     $p2pGroupField->setRequired(true);
     $this->addElement($p2pGroupField->setLabel($language->text('vwvc', 'p2pGroup')));
     // camMaxBandwidth Field
     $camMaxBandwidthField = new TextField('camMaxBandwidth');
     $camMaxBandwidthField->setRequired(true);
     $this->addElement($camMaxBandwidthField->setLabel($language->text('vwvc', 'camMaxBandwidth')));
     // bufferLive Field
     $bufferLiveField = new TextField('bufferLive');
     $bufferLiveField->setRequired(true);
     $this->addElement($bufferLiveField->setLabel($language->text('vwvc', 'bufferLive')));
     // bufferFull Field
     $bufferFullField = new TextField('bufferFull');
     $bufferFullField->setRequired(true);
     $this->addElement($bufferFullField->setLabel($language->text('vwvc', 'bufferFull')));
     // bufferLivePlayback Field
     $bufferLivePlaybackField = new TextField('bufferLivePlayback');
     $bufferLivePlaybackField->setRequired(true);
     $this->addElement($bufferLivePlaybackField->setLabel($language->text('vwvc', 'bufferLivePlayback')));
     // bufferFullPlayback Field
     $bufferFullPlaybackField = new TextField('bufferFullPlayback');
     $bufferFullPlaybackField->setRequired(true);
     $this->addElement($bufferFullPlaybackField->setLabel($language->text('vwvc', 'bufferFullPlayback')));
     // disableBandwidthDetection Field
     $disableBandwidthDetectionField = new Selectbox('disableBandwidthDetection');
     $disableBandwidthDetectionField->addOptions($par);
     $disableBandwidthDetectionField->setRequired();
     $disableBandwidthDetectionField->setHasInvitation(false);
     $this->addElement($disableBandwidthDetectionField->setLabel($language->text('vwvc', 'disableBandwidthDetection')));
     // disableUploadDetection Field
     $disableUploadDetectionField = new Selectbox('disableUploadDetection');
     $disableUploadDetectionField->addOptions($par);
     $disableUploadDetectionField->setRequired();
     $disableUploadDetectionField->setHasInvitation(false);
     $this->addElement($disableUploadDetectionField->setLabel($language->text('vwvc', 'disableUploadDetection')));
     // limitByBandwidth Field
     $limitByBandwidthField = new Selectbox('limitByBandwidth');
     $limitByBandwidthField->addOptions($par);
     $limitByBandwidthField->setRequired();
     $limitByBandwidthField->setHasInvitation(false);
     $this->addElement($limitByBandwidthField->setLabel($language->text('vwvc', 'limitByBandwidth')));
     // ws_ads Field
     $ws_adsField = new TextField('ws_ads');
     $ws_adsField->setRequired(true);
     $this->addElement($ws_adsField->setLabel($language->text('vwvc', 'ws_ads')));
     // adsTimeout Field
     $adsTimeoutField = new TextField('adsTimeout');
     $adsTimeoutField->setRequired(true);
     $this->addElement($adsTimeoutField->setLabel($language->text('vwvc', 'adsTimeout')));
     // adsInterval Field
     $adsIntervalField = new TextField('adsInterval');
     $adsIntervalField->setRequired(true);
     $this->addElement($adsIntervalField->setLabel($language->text('vwvc', 'adsInterval')));
     // statusInterval Field
     $statusIntervalField = new TextField('statusInterval');
     $statusIntervalField->setRequired(true);
     $this->addElement($statusIntervalField->setLabel($language->text('vwvc', 'statusInterval')));
     // availability Field
     $availabilityField = new TextField('availability');
     $availabilityField->setRequired(true);
     $this->addElement($availabilityField->setLabel($language->text('vwvc', 'availability')));
     // status Field
     $statusBox = array('approved' => 'approved', 'pending' => 'pending');
     $statusField = new Selectbox('status');
     $statusField->addOptions($statusBox);
     $statusField->setRequired();
     $statusField->setHasInvitation(false);
     $this->addElement($statusField->setLabel($language->text('vwvc', 'status')));
     // who can create room Field
     $memberBox = array('all' => 'all', 'member' => 'member list');
     $memberField = new Selectbox('member');
     $memberField->addOptions($memberBox);
     $memberField->setRequired();
     $memberField->setHasInvitation(false);
     $this->addElement($memberField->setLabel($language->text('vwvc', 'member')));
     // member_list Field
     $member_listField = new Textarea('member_list');
     $userService = BOL_UserService::getInstance();
     $user = $userService->findUserById(OW::getUser()->getId());
     $username = $user->getUsername();
     $member_listField->setValue($username);
     $this->addElement($member_listField->setLabel($language->text('vwvc', 'member_list')));
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('vwvc', 'btn_edit'));
     $this->addElement($submit);
 }