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); }
public function __construct() { parent::__construct('settingsForm'); $themes = new Selectbox('themeList'); $themes->setRequired(); $themes->setLabel(OW::getLanguage()->text('profileprogressbar', 'theme_label')); $plugin = OW::getPluginManager()->getPlugin('profileprogressbar'); $dirIterator = new RecursiveDirectoryIterator($plugin->getStaticDir() . 'css' . DS); $interator = new RecursiveIteratorIterator($dirIterator); $themesList = array(); foreach ($interator as $file) { if ($file->getFilename() == '.') { continue; } if (!$file->isDir() && pathinfo($file->getPathname(), PATHINFO_EXTENSION) == 'css') { $themeName = substr($file->getFilename(), 0, strrpos($file->getFilename(), '.')); if (file_exists($plugin->getStaticDir() . 'img' . DS . $themeName . DS . 'background.png') && file_exists($plugin->getStaticDir() . 'img' . DS . $themeName . DS . 'complete.png')) { $themesList[$themeName] = ucfirst($themeName); } } } asort($themesList); $themes->setOptions($themesList); $themes->setValue(OW::getConfig()->getValue('profileprogressbar', 'theme')); $this->addElement($themes); $validator = new SelectboxValidator($themesList); $themes->addValidator($validator); $submit = new Submit('save'); $submit->setValue(OW::getLanguage()->text('profileprogressbar', 'save_settings')); $this->addElement($submit); }
/** * 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); }
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); }
public static function renderListTypeSelect($uniqName, $fieldName, $value) { $language = OW::getLanguage(); $field = new Selectbox($fieldName); $uniqId = uniqid("select-list-"); $field->setId($uniqId); $field->setOptions(array('latest' => $language->text('ucarousel', 'widget_list_type_latest'), 'recently' => $language->text('ucarousel', 'widget_list_type_recently'), 'online' => $language->text('ucarousel', 'widget_list_type_online'), 'featured' => $language->text('ucarousel', 'widget_list_type_featured'), 'by_role' => $language->text('ucarousel', 'widget_list_type_by_role'), 'by_account_type' => $language->text('ucarousel', 'widget_list_type_by_account_type'))); $field->setValue($value); if ($value != "by_role") { OW::getDocument()->addOnloadScript('$("#uc-role-setting").parents("tr:eq(0)").hide();'); } if ($value != "by_account_type") { OW::getDocument()->addOnloadScript('$("#uc-account-type-setting").parents("tr:eq(0)").hide();'); } OW::getDocument()->addOnloadScript('$("#' . $uniqId . '").change(function() { ' . '$("#uc-role-setting").parents("tr:eq(0)").hide(); ' . '$("#uc-account-type-setting").parents("tr:eq(0)").hide(); ' . 'if ($(this).val() == "by_role") $("#uc-role-setting").parents("tr:eq(0)").show(); ' . 'if ($(this).val() == "by_account_type") $("#uc-account-type-setting").parents("tr:eq(0)").show(); ' . ' })'); return $field->renderInput(); }
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); }
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 }"); }
/** * Class constructor */ public function __construct($tpls) { parent::__construct('edit-template-form'); $this->setAction(OW::getRouter()->urlFor('VIRTUALGIFTS_CTRL_Admin', 'editTemplate')); $single = count($tpls) == 1; $this->setEnctype('multipart/form-data'); $language = OW::getLanguage(); $giftService = VIRTUALGIFTS_BOL_VirtualGiftsService::getInstance(); if ($single) { $file = new FileField('file'); $file->setLabel($language->text('virtualgifts', 'gift_image')); $this->addElement($file); $tpl = $giftService->findTemplateById($tpls[0]); } $tplId = new HiddenField('tplId'); $tplId->setRequired(true); $tplId->setValue(implode('|', $tpls)); $this->addElement($tplId); if ($giftService->categoriesSetup()) { $categories = new Selectbox('category'); $categories->setLabel($language->text('virtualgifts', 'category')); $categories->setOptions($giftService->getCategories()); if ($single && isset($tpl)) { $categories->setValue($tpl->categoryId); } $this->addElement($categories); } if (OW::getPluginManager()->isPluginActive('usercredits')) { $price = new TextField('price'); $price->setLabel($language->text('virtualgifts', 'gift_price')); if ($single && isset($tpl)) { $price->setValue($tpl->price); } $this->addElement($price); } // submit $submit = new Submit('save'); $submit->setValue($language->text('virtualgifts', 'btn_save')); $this->addElement($submit); }
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"); }
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); } } } }
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); } }
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); } } } }
public function __construct($assignedMemberships) { parent::__construct('add-membership-form'); $this->assignedMemberships = $assignedMemberships; $lang = OW::getLanguage(); $accTypeField = new HiddenField('accType'); $accTypeField->setRequired(true); $this->addElement($accTypeField); $rolesField = new Selectbox('role'); $roles = MEMBERSHIP_BOL_MembershipService::getInstance()->getRolesAvailableForMembership($this->assignedMemberships); $options = array(); foreach ($roles as $role) { $options[$role->id] = $lang->text('base', 'authorization_role_' . $role->name); } if (count($options)) { $rolesField->setOptions($options); } $rolesField->setRequired(true)->setLabel($lang->text('membership', 'select_role')); $this->addElement($rolesField); $periodField = new TextField('period'); $periodField->setRequired(true); $periodField->addValidator(new IntValidator(1, 100000)); $this->addElement($periodField); $priceField = new TextField('price'); $priceField->setRequired(true); $priceField->addValidator(new FloatValidator(0, 1000000)); $this->addElement($priceField); $recurringField = new CheckboxField('isRecurring'); $this->addElement($recurringField); // submit $submit = new Submit('save'); $submit->setValue($lang->text('membership', 'add_btn')); $this->addElement($submit); }
/** * Class constructor */ public function __construct() { parent::__construct('albumEditForm'); $language = OW::getLanguage(); // album id field $albumIdField = new HiddenField('id'); $albumIdField->setRequired(true); $this->addElement($albumIdField); // album name Field $albumNameField = new TextField('albumName'); $this->addElement($albumNameField->setLabel($language->text('photo', 'album'))); // category $categoryField = new Selectbox('category'); $categories = array(); foreach (ADVANCEDPHOTO_BOL_CategoryService::getInstance()->getCategoriesList() as $key => $item) { $categories[$item->id] = $item->name; } $categoryField->setOptions($categories); $this->addElement($categoryField->setLabel($language->text('advancedphoto', 'category'))); $submit = new Submit('save'); $submit->setValue($language->text('photo', 'btn_edit')); $this->addElement($submit); }
public function __construct($typeId) { parent::__construct('edit-membership-form'); $lang = OW::getLanguage(); $typeField = new HiddenField('type'); $typeField->setValue($typeId); $typeField->setRequired(true); $this->addElement($typeField); $type = MEMBERSHIP_BOL_MembershipService::getInstance()->findTypeById($typeId); $rolesField = new Selectbox('role'); $roles = MEMBERSHIP_BOL_MembershipService::getInstance()->getRolesAvailableForMembership(); foreach ($roles as $role) { $options[$role->id] = $lang->text('base', 'authorization_role_' . $role->name); } if (count($options)) { $rolesField->setOptions($options); } $rolesField->setRequired(true)->setValue($type->roleId)->setLabel($lang->text('membership', 'select_role')); $this->addElement($rolesField); // submit $submit = new Submit('update'); $submit->setValue($lang->text('admin', 'save_btn_label')); $this->addElement($submit); }
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 == ' ' ? $noValue : $questionLabel; $questionDescription = mb_strlen(trim($questionDescription)) == 0 || $questionDescription == ' ' ? $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"); }
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); }
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); }
/** * Class constructor * */ public function __construct($maxUploadMaxFilesize) { parent::__construct('userSettingsForm'); $this->setEnctype("multipart/form-data"); $language = OW::getLanguage(); // avatar size Field $avatarSize = new TextField('avatarSize'); $avatarSize->setRequired(true); $validator = new IntValidator(40, 150); $validator->setErrorMessage($language->text('admin', 'user_settings_avatar_size_error', array('max' => 150))); $avatarSize->addValidator($validator); $this->addElement($avatarSize->setLabel($language->text('admin', 'user_settings_avatar_size_label'))); // big avatar size Field $bigAvatarSize = new TextField('bigAvatarSize'); $bigAvatarSize->setRequired(true); $validator = new IntValidator(150, 250); $validator->setErrorMessage($language->text('admin', 'user_settings_big_avatar_size_error', array('max' => 250))); $bigAvatarSize->addValidator($validator); $this->addElement($bigAvatarSize->setLabel($language->text('admin', 'user_settings_big_avatar_size_label'))); // --- avatar max size $maxUploadMaxFilesizeValidator = new FloatValidator(0, $maxUploadMaxFilesize); $maxUploadMaxFilesizeValidator->setErrorMessage($language->text('admin', 'settings_max_upload_size_error')); $avatarMaxUploadSize = new TextField('avatar_max_upload_size'); $avatarMaxUploadSize->setLabel($language->text('admin', 'input_settings_avatar_max_upload_size_label')); $avatarMaxUploadSize->addValidator($maxUploadMaxFilesizeValidator); $this->addElement($avatarMaxUploadSize); // --- avatar max size if (!defined('OW_PLUGIN_XP')) { // confirm Email $confirmEmail = new CheckboxField('confirmEmail'); $confirmEmail->setValue(OW::getConfig()->getValue('base', 'confirm_email')); $this->addElement($confirmEmail->setLabel($language->text('admin', 'user_settings_confirm_email'))); } // display name Field $displayNameField = new Selectbox('displayName'); $displayNameField->setRequired(true); $questions = array('username' => $language->text('base', 'questions_question_username_label'), 'realname' => $language->text('base', 'questions_question_realname_label')); $displayNameField->setHasInvitation(false); $displayNameField->setOptions($questions); $this->addElement($displayNameField->setLabel($language->text('admin', 'user_settings_display_name'))); $avatar = new FileField('avatar'); $this->addElement($avatar); $bigAvatar = new FileField('bigAvatar'); $this->addElement($bigAvatar); // -- $joinConfigField = new Selectbox('join_display_photo_upload'); $options = array(BOL_UserService::CONFIG_JOIN_DISPLAY_PHOTO_UPLOAD => $language->text('base', 'config_join_display_photo_upload_display_label'), BOL_UserService::CONFIG_JOIN_DISPLAY_AND_SET_REQUIRED_PHOTO_UPLOAD => $language->text('base', 'config_join_display_photo_upload_display_and_require_label'), BOL_UserService::CONFIG_JOIN_NOT_DISPLAY_PHOTO_UPLOAD => $language->text('base', 'config_join_display_photo_upload_not_display_label')); $joinConfigField->addOptions($options); $joinConfigField->setHasInvitation(false); $joinConfigField->setValue(OW::getConfig()->getValue('base', 'join_display_photo_upload')); $this->addElement($joinConfigField); // -- $joinConfigField = new CheckboxField('join_display_terms_of_use'); $joinConfigField->setValue(OW::getConfig()->getValue('base', 'join_display_terms_of_use')); $this->addElement($joinConfigField); //--- privacy -----/// $config = OW::getConfig(); $baseConfigs = $config->getValues('base'); $userApprove = new CheckboxField('user_approve'); $userApprove->setLabel($language->text('admin', 'permissions_index_user_approve')); $this->addElement($userApprove); $whoCanJoin = new RadioField('who_can_join'); $whoCanJoin->addOptions(array('1' => $language->text('admin', 'permissions_index_anyone_can_join'), '2' => $language->text('admin', 'permissions_index_by_invitation_only_can_join'))); $whoCanJoin->setLabel($language->text('admin', 'permissions_index_who_can_join')); $this->addElement($whoCanJoin); $whoCanInvite = new RadioField('who_can_invite'); $whoCanInvite->addOptions(array('1' => $language->text('admin', 'permissions_index_all_users_can_invate'), '2' => $language->text('admin', 'permissions_index_admin_only_can_invate'))); $whoCanInvite->setLabel($language->text('admin', 'permissions_index_who_can_invite')); $this->addElement($whoCanInvite); $guestsCanView = new RadioField('guests_can_view'); $guestsCanView->addOptions(array('1' => $language->text('admin', 'permissions_index_yes'), '2' => $language->text('admin', 'permissions_index_no'), '3' => $language->text('admin', 'permissions_index_with_password'))); $guestsCanView->setLabel($language->text('admin', 'permissions_index_guests_can_view_site')); $guestsCanView->setDescription($language->text('admin', 'permissions_idex_if_not_yes_will_override_settings')); $this->addElement($guestsCanView); $password = new TextField('password'); $password->setHasInvitation(true); if ($baseConfigs['guests_can_view'] == 3) { $password->setInvitation($language->text('admin', 'change_password')); } else { $password->setInvitation($language->text('admin', 'add_password')); } $this->addElement($password); // --- // //-- profile questions --// $userViewPresentationnew = new CheckboxField("user_view_presentation"); $userViewPresentationnew->setLabel($language->text('base', 'questions_config_user_view_presentation_label')); $userViewPresentationnew->setDescription($language->text('base', 'questions_config_user_view_presentation_description')); $this->addElement($userViewPresentationnew); // --- // // submit $submit = new Submit('save'); $submit->setValue($language->text('admin', 'save_btn_label')); $this->addElement($submit); }
public function __construct($entityType, $actions, $features, $info) { parent::__construct("HINT_ConfigurationForm"); $language = OW::getLanguage(); $this->actions = $actions; $this->entityType = $entityType; // Actions foreach ($actions as $action) { $field = new CheckboxField("action-" . $action["key"]); $field->setId("action-" . $action["key"]); $field->addAttribute("data-key", $action["key"]); $field->setValue($action["active"]); $field->setLabel($action["label"]); $field->addAttribute("class", "h-refresher"); $this->addElement($field); } // Additional Features $field = new CheckboxField("uheader_enabled"); $field->setId("feature_uheader"); $field->setValue($features["cover"]); $field->addAttribute("class", "h-refresher"); $field->addAttribute("data-key", "cover"); $this->addElement($field); // User Information $line0Options = HINT_BOL_Service::getInstance()->getInfoLineSettings($entityType, HINT_BOL_Service::INFO_LINE0); $field = new Selectbox("info_" . HINT_BOL_Service::INFO_LINE0); $field->setId("info0"); foreach ($line0Options as $lineOption) { $field->addOption($lineOption["key"], $lineOption["label"]); } if (!empty($info[HINT_BOL_Service::INFO_LINE0]["key"])) { $field->setValue($info[HINT_BOL_Service::INFO_LINE0]["key"]); } $this->addElement($field); $questions = $this->findQuestions(); $questionOptions = array(); foreach ($questions as $question) { $questionOptions[$question->name] = BOL_QuestionService::getInstance()->getQuestionLang($question->name); } $field = new Selectbox("info_" . HINT_BOL_Service::INFO_LINE0 . "_question"); $field->setId("info0_q"); $field->setOptions($questionOptions); if (!empty($info[HINT_BOL_Service::INFO_LINE0]["question"])) { $field->setValue($info[HINT_BOL_Service::INFO_LINE0]["question"]); } $this->addElement($field); $line1Options = HINT_BOL_Service::getInstance()->getInfoLineSettings($entityType, HINT_BOL_Service::INFO_LINE1); $field = new Selectbox("info_" . HINT_BOL_Service::INFO_LINE1); $field->setId("info1"); foreach ($line1Options as $lineOption) { $field->addOption($lineOption["key"], $lineOption["label"]); } if (!empty($info[HINT_BOL_Service::INFO_LINE1]["key"])) { $field->setValue($info[HINT_BOL_Service::INFO_LINE1]["key"]); } $this->addElement($field); $field = new Selectbox("info_" . HINT_BOL_Service::INFO_LINE1 . "_question"); $field->setId("info1_q"); $field->setOptions($questionOptions); if (!empty($info[HINT_BOL_Service::INFO_LINE1]["question"])) { $field->setValue($info[HINT_BOL_Service::INFO_LINE1]["question"]); } $this->addElement($field); $line2Options = HINT_BOL_Service::getInstance()->getInfoLineSettings($entityType, HINT_BOL_Service::INFO_LINE2); $field = new Selectbox("info_" . HINT_BOL_Service::INFO_LINE2); $field->setId("info2"); foreach ($line2Options as $lineOption) { $field->addOption($lineOption["key"], $lineOption["label"]); } if (!empty($info[HINT_BOL_Service::INFO_LINE2]["key"])) { $field->setValue($info[HINT_BOL_Service::INFO_LINE2]["key"]); } $this->addElement($field); $field = new Selectbox("info_" . HINT_BOL_Service::INFO_LINE2 . "_question"); $field->setId("info2_q"); $field->setOptions($questionOptions); if (!empty($info[HINT_BOL_Service::INFO_LINE2]["question"])) { $field->setValue($info[HINT_BOL_Service::INFO_LINE2]["question"]); } $this->addElement($field); // submit $submit = new Submit('save'); $submit->setValue($language->text('hint', 'admin_save_btn')); $this->addElement($submit); }
/** * * 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); }
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); }
/** * Class constructor */ public function __construct() { parent::__construct('add-template-form'); $this->setEnctype('multipart/form-data'); $language = OW::getLanguage(); $file = new FileField('file'); $file->setLabel($language->text('virtualgifts', 'gift_image')); $this->addElement($file); $giftService = VIRTUALGIFTS_BOL_VirtualGiftsService::getInstance(); if ($giftService->categoriesSetup()) { $categories = new Selectbox('category'); $categories->setLabel($language->text('virtualgifts', 'category')); $categories->setOptions($giftService->getCategories()); $this->addElement($categories); } if (OW::getPluginManager()->isPluginActive('usercredits')) { $price = new TextField('price'); $price->setLabel($language->text('virtualgifts', 'gift_price')); $this->addElement($price); } // submit $submit = new Submit('add'); $submit->setValue($language->text('virtualgifts', 'btn_add')); $this->addElement($submit); }
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); }
/** * Class constructor * */ public function __construct($maxUploadMaxFilesize) { parent::__construct('userSettingsForm'); $this->setEnctype("multipart/form-data"); $language = OW::getLanguage(); // avatar size Field $avatarSize = new TextField('avatarSize'); $avatarSize->setRequired(true); $validator = new IntValidator(40, 150); $validator->setErrorMessage($language->text('admin', 'user_settings_avatar_size_error', array('max' => 150))); $avatarSize->addValidator($validator); $this->addElement($avatarSize->setLabel($language->text('admin', 'user_settings_avatar_size_label'))); // big avatar size Field $bigAvatarSize = new TextField('bigAvatarSize'); $bigAvatarSize->setRequired(true); $validator = new IntValidator(150, 250); $validator->setErrorMessage($language->text('admin', 'user_settings_big_avatar_size_error', array('max' => 250))); $bigAvatarSize->addValidator($validator); $this->addElement($bigAvatarSize->setLabel($language->text('admin', 'user_settings_big_avatar_size_label'))); // --- avatar max size $maxUploadMaxFilesizeValidator = new FloatValidator(0, $maxUploadMaxFilesize); $maxUploadMaxFilesizeValidator->setErrorMessage($language->text('admin', 'settings_max_upload_size_error')); $avatarMaxUploadSize = new TextField('avatar_max_upload_size'); $avatarMaxUploadSize->setLabel($language->text('admin', 'input_settings_avatar_max_upload_size_label')); $avatarMaxUploadSize->addValidator($maxUploadMaxFilesizeValidator); $this->addElement($avatarMaxUploadSize); // --- avatar max size if (!defined('OW_PLUGIN_XP')) { // confirm Email $confirmEmail = new CheckboxField('confirmEmail'); $confirmEmail->setValue(OW::getConfig()->getValue('base', 'confirm_email')); $this->addElement($confirmEmail->setLabel($language->text('admin', 'user_settings_confirm_email'))); } // display name Field $displayNameField = new Selectbox('displayName'); $displayNameField->setRequired(true); $questions = array('username' => $language->text('base', 'questions_question_username_label'), 'realname' => $language->text('base', 'questions_question_realname_label')); $displayNameField->setHasInvitation(false); $displayNameField->setOptions($questions); $this->addElement($displayNameField->setLabel($language->text('admin', 'user_settings_display_name'))); $avatar = new FileField('avatar'); $this->addElement($avatar); $bigAvatar = new FileField('bigAvatar'); $this->addElement($bigAvatar); // -- $joinConfigField = new Selectbox('join_display_photo_upload'); $options = array(BOL_UserService::CONFIG_JOIN_DISPLAY_PHOTO_UPLOAD => $language->text('base', 'config_join_display_photo_upload_display_label'), BOL_UserService::CONFIG_JOIN_DISPLAY_AND_SET_REQUIRED_PHOTO_UPLOAD => $language->text('base', 'config_join_display_photo_upload_display_and_require_label'), BOL_UserService::CONFIG_JOIN_NOT_DISPLAY_PHOTO_UPLOAD => $language->text('base', 'config_join_display_photo_upload_not_display_label')); $joinConfigField->addOptions($options); $joinConfigField->setHasInvitation(false); $joinConfigField->setValue(OW::getConfig()->getValue('base', 'join_display_photo_upload')); $this->addElement($joinConfigField); // -- $joinConfigField = new CheckboxField('join_display_terms_of_use'); $joinConfigField->setValue(OW::getConfig()->getValue('base', 'join_display_terms_of_use')); $this->addElement($joinConfigField); // submit $submit = new Submit('save'); $submit->setValue($language->text('admin', 'save_btn_label')); $this->addElement($submit); }
function __construct($prefixes, $language, $isDevMode = false) { parent::__construct('form'); $languageService = BOL_LanguageService::getInstance(); $this->setAjax(true); $this->setAction(OW::getRouter()->urlFor('ADMIN_CTRL_Languages', 'ajaxAddKey')); $this->setMethod('post'); $languageHidden = new HiddenField('language'); $languageHidden->setValue($language->getId()); $this->addElement($languageHidden); $keyTextField = new TextField('key'); $keyTextField->setLabel(OW::getLanguage()->text('admin', 'add_key_form_lbl_key')); $this->addElement($keyTextField->setRequired(ADMIN_CTRL_Languages::isDevMode())); $prefixSelectBox = new Selectbox('prefix'); if (!empty($_GET['prefix']) && strlen($_GET['prefix']) > 0) { $prefixSelectBox->setValue($_GET['prefix']); } $options = array(); foreach ($prefixes as $prefix) { $options["{$prefix->getPrefix()}"] = $prefix->getLabel(); } $prefixSelectBox->setOptions($options)->setLabel(OW::getLanguage()->text('admin', 'section')); $this->addElement($prefixSelectBox->setRequired(ADMIN_CTRL_Languages::isDevMode())); $valueTextArea = new Textarea('value'); $this->addElement($valueTextArea->setRequired(true)->setLabel(OW::getLanguage()->text('admin', 'add_key_form_lbl_val', array('label' => $language->getLabel(), 'tag' => $language->getTag())))); $submit = new Submit('submit'); $submit->setValue(OW::getLanguage()->text('admin', 'add_key_form_lbl_add')); if (!OW::getRequest()->isAjax()) { OW::getDocument()->addOnloadScript("owForms['{$this->getName()}'].bind('success', function(json){\n\t\t\t\tswitch( json['result'] ){\n\t\t\t\t\tcase 'success':\n\t\t\t\t\t\tlocation.reload();\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'dublicate':\n\t\t\t\t\t\tOW.info('" . OW::getLanguage()->text('admin', 'msg_dublicate_key') . "');\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});"); } $this->addElement($submit); }
/** * Class constructor * * @param string $name * @apram string $defaultGroup */ public function __construct($name, $defaultGroup) { parent::__construct($name); $processedGroups = ADMIN_CMP_ContentStatisticWidget::getContentTypes(); $groupField = new Selectbox('group'); $groupField->setOptions($processedGroups); $groupField->setValue($defaultGroup); $groupField->setHasInvitation(false); $this->addElement($groupField); }