コード例 #1
0
ファイル: settings_form.php プロジェクト: vazahat/dudex
 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);
 }
コード例 #2
0
ファイル: admin.php プロジェクト: hardikamutech/loov
 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);
 }
コード例 #3
0
ファイル: config_fields_form.php プロジェクト: vazahat/dudex
 /**
  * Class constructor
  */
 public function __construct($providerName)
 {
     parent::__construct('provider-config-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('ynsocialconnect-admin-ajaxUpdateProfileQuestion'));
     $language = OW::getLanguage();
     $service = YNSOCIALCONNECT_BOL_ServicesService::getInstance();
     $questionDtoList = $service->getOWQuestionDtoList($providerName);
     $aliases = $service->findAliasList($providerName);
     $options = $service->getServiceFields($providerName);
     foreach ($questionDtoList as $question) {
         $new_element = new Selectbox('alias[' . $question->name . ']');
         foreach ($options as $option) {
             $new_element->addOption($option->name, $option->label);
         }
         $new_element->setValue(empty($aliases[$question->name]) ? '' : $aliases[$question->name]);
         $this->addElement($new_element);
     }
     $hidden = new TextField('providerName');
     $hidden->addAttribute('type', 'hidden');
     $hidden->setValue($providerName);
     $this->addElement($hidden);
     $submit = new Submit('edit');
     $submit->setValue($language->text('ynsocialconnect', 'save_btn_label'));
     $this->addElement($submit);
 }
コード例 #4
0
ファイル: admin.php プロジェクト: vazahat/dudex
 public function __construct()
 {
     parent::__construct('payeer-config-form');
     $language = OW::getLanguage();
     $billingService = BOL_BillingService::getInstance();
     $gwKey = BILLINGPAYEER_CLASS_PayeerAdapter::GATEWAY_KEY;
     $element = new TextField('m_key');
     $element->setValue($billingService->getGatewayConfigValue($gwKey, 'm_key'));
     $this->addElement($element);
     $element = new TextField('m_shop');
     $element->setValue($billingService->getGatewayConfigValue($gwKey, 'm_shop'));
     $this->addElement($element);
     $element = new Selectbox('m_curr');
     $element->setValue($billingService->getGatewayConfigValue($gwKey, 'm_curr'))->setHasInvitation(false)->addOption('RUB', 'RUB')->addOption('usd', 'USD');
     $this->addElement($element);
     $element = new Selectbox('lang');
     $element->setValue($billingService->getGatewayConfigValue($gwKey, 'lang'))->setHasInvitation(false)->addOption('ru', 'Русский')->addOption('en', 'English');
     $this->addElement($element);
     $element = new Selectbox('tabNum');
     $element->setValue($billingService->getGatewayConfigValue($gwKey, 'tabNum'))->setHasInvitation(false)->addOption('1', 'Electronic Systems')->addOption('2', 'Cash / Bank Transfers')->addOption('3', 'Terminals')->addOption('4', 'SMS payments');
     $this->addElement($element);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('billingpayeer', 'btn_save'));
     $this->addElement($submit);
 }
コード例 #5
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);
 }
コード例 #6
0
ファイル: admin.php プロジェクト: hardikamutech/loov
 /**
  * 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);
 }
コード例 #7
0
ファイル: admin.php プロジェクト: vazahat/dudex
 public function __construct($configs)
 {
     parent::__construct('EQUESTIONS_ConfigSaveForm');
     $this->configs = $configs;
     $language = OW::getLanguage();
     $field = new CheckboxField('allow_comments');
     $field->setLabel($language->text('equestions', 'admin_allow_comments_label'));
     $field->setValue($configs['allow_comments']);
     $this->addElement($field);
     $field = new CheckboxField('ask_friends');
     $field->setLabel($language->text('equestions', 'admin_enable_ask_friends_label'));
     $field->setValue($configs['ask_friends']);
     $this->addElement($field);
     $field = new Selectbox('list_order');
     foreach (array(EQUESTIONS_CMP_Feed::ORDER_LATEST, EQUESTIONS_CMP_Feed::ORDER_POPULAR) as $v) {
         $field->addOption($v, $language->text('equestions', 'feed_order_' . $v));
     }
     $field->setHasInvitation(false);
     $field->setLabel($language->text('equestions', 'admin_list_order_label'));
     $field->setValue($configs['list_order']);
     $this->addElement($field);
     $field = new CheckboxField('enable_follow');
     $field->setLabel($language->text('equestions', 'admin_enable_follow_label'));
     $field->setValue($configs['enable_follow']);
     $this->addElement($field);
     $field = new CheckboxField('allow_popups');
     $field->setLabel($language->text('equestions', 'admin_allow_popups_label'));
     $field->setValue($configs['allow_popups']);
     $this->addElement($field);
     $field = new CheckboxField('attachments');
     $field->setLabel($language->text('equestions', 'admin_enable_attachments_label'));
     $field->setValue($configs['attachments']);
     $this->addElement($field);
     $field = new CheckboxField('attachments_video');
     $field->setLabel($language->text('equestions', 'admin_attachments_video_enable_label'));
     $field->setValue($configs['attachments_video']);
     $this->addElement($field);
     $field = new CheckboxField('attachments_image');
     $field->setLabel($language->text('equestions', 'admin_attachments_image_enable_label'));
     $field->setValue($configs['attachments_image']);
     $this->addElement($field);
     $field = new CheckboxField('attachments_link');
     $field->setLabel($language->text('equestions', 'admin_attachments_link_enable_label'));
     $field->setValue($configs['attachments_link']);
     $this->addElement($field);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('equestions', 'admin_save_btn'));
     $this->addElement($submit);
 }
コード例 #8
0
ファイル: users_widget.php プロジェクト: vazahat/dudex
 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();
 }
コード例 #9
0
ファイル: admin.php プロジェクト: vazahat/dudex
 public function index()
 {
     $language = OW::getLanguage();
     $config = OW::getConfig();
     $adminForm = new Form('adminForm');
     $element = new Selectbox('actionMember');
     $element->setLabel($language->text('grouprss', 'action_member_label'));
     $element->setDescription($language->text('grouprss', 'action_member_desc'));
     $element->setValue($config->getValue('grouprss', 'actionMember'));
     $element->setRequired();
     $element->addOption('admin', $language->text('grouprss', 'site_admin'));
     $element->addOption('owner', $language->text('grouprss', 'group_owner'));
     $element->addOption('both', $language->text('grouprss', 'both_admin_owner'));
     $adminForm->addElement($element);
     $element = new Selectbox('postLocation');
     $element->setLabel($language->text('grouprss', 'post_location_label'));
     $element->setDescription($language->text('grouprss', 'post_location_desc'));
     $element->setValue($config->getValue('grouprss', 'postLocation'));
     $element->setRequired();
     $element->addOption('wall', $language->text('grouprss', 'wall_location'));
     $element->addOption('newsfeed', $language->text('grouprss', 'newsfeed_location'));
     $adminForm->addElement($element);
     $element = new CheckboxField('disablePosting');
     $element->setLabel($language->text('grouprss', 'disable_posting_label'));
     $element->setDescription($language->text('grouprss', 'disable_posting_desc'));
     $element->setValue($config->getValue('grouprss', 'disablePosting'));
     $adminForm->addElement($element);
     $element = new Submit('saveSettings');
     $element->setValue(OW::getLanguage()->text('grouprss', 'admin_save_settings'));
     $adminForm->addElement($element);
     if (OW::getRequest()->isPost()) {
         if ($adminForm->isValid($_POST)) {
             $values = $adminForm->getValues();
             $config->saveConfig('grouprss', 'actionMember', $values['actionMember']);
             $config->saveConfig('grouprss', 'postLocation', $values['postLocation']);
             $config->saveConfig('grouprss', 'disablePosting', $values['disablePosting']);
             GROUPRSS_BOL_FeedService::getInstance()->addAllGroupFeed();
             //OW::getFeedback()->info($language->text('grouprss', 'user_save_success'));
         }
     }
     $this->addForm($adminForm);
 }
コード例 #10
0
ファイル: template_edit.php プロジェクト: hardikamutech/loov
 /**
  * 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);
 }
コード例 #11
0
ファイル: init.php プロジェクト: hardikamutech/loov
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);
    }
}
コード例 #12
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);
 }
コード例 #13
0
ファイル: mass_mailing.php プロジェクト: vazahat/dudex
 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");
 }
コード例 #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);
             }
         }
     }
 }
コード例 #15
0
ファイル: join.php プロジェクト: ZyXelP/oxwall
 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);
     }
 }
コード例 #16
0
ファイル: user_search.php プロジェクト: hardikamutech/loov
 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);
 }
コード例 #17
0
ファイル: settings.php プロジェクト: hardikamutech/loov
 /**
  * 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);
 }
コード例 #18
0
ファイル: join.php プロジェクト: vazahat/dudex
 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);
 }
コード例 #19
0
ファイル: admin.php プロジェクト: vazahat/dudex
 public function index()
 {
     $language = OW::getLanguage();
     $config = OW::getConfig();
     $adminForm = new Form('adminForm');
     $element = new TextField('allowedFileSize');
     $element->setRequired(true);
     $element->setValue($config->getValue('ivideo', 'allowedFileSize'));
     $element->setLabel($language->text('ivideo', 'admin_allowed_file_size'));
     $element->setDescription($language->text('ivideo', 'admin_allowed_file_size_desc'));
     $validator = new FloatValidator(1);
     $validator->setErrorMessage($language->text('ivideo', 'admin_invalid_number_error'));
     $element->addValidator($validator);
     $adminForm->addElement($element);
     $element = new Multiselect('allowedExtensions');
     $element->setRequired(true);
     $element->setValue(explode(",", $config->getValue('ivideo', 'allowedExtensions')));
     $element->setLabel($language->text('ivideo', 'admin_allowed_extension'));
     $element->setDescription($language->text('ivideo', 'admin_allowed_extension_desc'));
     $element->addOption('mp4', 'MP4');
     $element->addOption('flv', 'FLV');
     $element->addOption('avi', 'AVI');
     $element->addOption('wmv', 'WMV');
     $element->addOption('swf', 'SWF');
     $element->addOption('mov', 'MOV');
     $element->addOption('mpg', 'MPG');
     $element->addOption('3g2', '3G2');
     $element->addOption('ram', 'RAM');
     $element->setSize(6);
     $adminForm->addElement($element);
     $element = new TextField('videosPerRow');
     $element->setValue($config->getValue('ivideo', 'videosPerRow'));
     $element->setLabel($language->text('ivideo', 'admin_videos_per_row'));
     $element->setDescription($language->text('ivideo', 'admin_videos_per_row_desc'));
     $validator = new IntValidator();
     $validator->setErrorMessage($language->text('ivideo', 'admin_invalid_number_error'));
     $element->addValidator($validator);
     $adminForm->addElement($element);
     $element = new TextField('videoPreviewWidth');
     $element->setValue($config->getValue('ivideo', 'videoPreviewWidth'));
     $element->setLabel($language->text('ivideo', 'admin_video_preview_size'));
     $element->setDescription($language->text('ivideo', 'admin_video_preview_size_desc'));
     $validator = new IntValidator();
     $validator->setErrorMessage($language->text('ivideo', 'admin_invalid_number_error'));
     $element->addValidator($validator);
     $adminForm->addElement($element);
     $element = new TextField('videoPreviewHeight');
     $element->setValue($config->getValue('ivideo', 'videoPreviewHeight'));
     $element->setLabel($language->text('ivideo', 'admin_video_preview_height'));
     $validator = new IntValidator();
     $validator->setErrorMessage($language->text('ivideo', 'admin_invalid_number_error'));
     $element->addValidator($validator);
     $adminForm->addElement($element);
     $element = new TextField('videoWidth');
     $element->setValue($config->getValue('ivideo', 'videoWidth'));
     $element->setLabel($language->text('ivideo', 'admin_video_size'));
     $element->setDescription($language->text('ivideo', 'admin_video_size_desc'));
     $validator = new IntValidator();
     $validator->setErrorMessage($language->text('ivideo', 'admin_invalid_number_error'));
     $element->addValidator($validator);
     $adminForm->addElement($element);
     $element = new TextField('videoHeight');
     $element->setValue($config->getValue('ivideo', 'videoHeight'));
     $element->setLabel($language->text('ivideo', 'admin_video_height'));
     $validator = new IntValidator();
     $validator->setErrorMessage($language->text('ivideo', 'admin_invalid_number_error'));
     $element->addValidator($validator);
     $adminForm->addElement($element);
     $element = new Selectbox('videoApproval');
     $element->setRequired(true);
     $element->setValue($config->getValue('ivideo', 'videoApproval'));
     $element->setLabel($language->text('ivideo', 'admin_video_approval'));
     $element->addOption('auto', $language->text('ivideo', 'auto_approve'));
     $element->addOption('admin', $language->text('ivideo', 'admin_approve'));
     $element->setDescription($language->text('ivideo', 'admin_video_approval_desc'));
     $adminForm->addElement($element);
     $element = new Selectbox('theme');
     $element->setRequired(true);
     $element->setValue($config->getValue('ivideo', 'theme'));
     $element->setLabel($language->text('ivideo', 'admin_video_theme'));
     $element->addOption('baseTheme', $language->text('ivideo', 'baseTheme'));
     $element->addOption('classicTheme', $language->text('ivideo', 'classicTheme'));
     $element->addOption('fancyTheme', $language->text('ivideo', 'fancyTheme'));
     $element->addOption('listTheme', $language->text('ivideo', 'listTheme'));
     $element->setDescription($language->text('ivideo', 'admin_video_theme_desc'));
     $adminForm->addElement($element);
     $element = new TextField('resultsPerPage');
     $element->setRequired(true);
     $element->setLabel($language->text('ivideo', 'admin_results_per_page'));
     $element->setDescription($language->text('ivideo', 'admin_results_per_page_desc'));
     $element->setValue($config->getValue('ivideo', 'resultsPerPage'));
     $adminForm->addElement($element);
     $element = new TextField('ffmpegPath');
     $element->setLabel($language->text('ivideo', 'admin_ffmpeg_path'));
     $element->setDescription($language->text('ivideo', 'admin_ffmpeg_path_desc'));
     $element->setValue($config->getValue('ivideo', 'ffmpegPath'));
     $adminForm->addElement($element);
     $element = new CheckboxField('makeUploaderMain');
     $element->setLabel($language->text('ivideo', 'admin_make_uploader_main'));
     $element->setDescription($language->text('ivideo', 'admin_make_uploader_main_desc'));
     $element->setValue($config->getValue('ivideo', 'makeUploaderMain'));
     $adminForm->addElement($element);
     $element = new Submit('saveSettings');
     $element->setValue(OW::getLanguage()->text('ivideo', 'admin_save_settings'));
     $adminForm->addElement($element);
     if (OW::getRequest()->isPost()) {
         if ($adminForm->isValid($_POST)) {
             $values = $adminForm->getValues();
             $config->saveConfig('ivideo', 'allowedFileSize', $values['allowedFileSize']);
             $config->saveConfig('ivideo', 'allowedExtensions', implode(",", $values['allowedExtensions']));
             $config->saveConfig('ivideo', 'videoWidth', $values['videoWidth']);
             $config->saveConfig('ivideo', 'videoHeight', $values['videoHeight']);
             $config->saveConfig('ivideo', 'videoPreviewWidth', $values['videoPreviewWidth']);
             $config->saveConfig('ivideo', 'videoPreviewHeight', $values['videoPreviewHeight']);
             $config->saveConfig('ivideo', 'resultsPerPage', $values['resultsPerPage']);
             $config->saveConfig('ivideo', 'videoApproval', $values['videoApproval']);
             $config->saveConfig('ivideo', 'theme', $values['theme']);
             $config->saveConfig('ivideo', 'videosPerRow', $values['videosPerRow']);
             $config->saveConfig('ivideo', 'makeUploaderMain', $values['makeUploaderMain']);
             $config->saveConfig('ivideo', 'ffmpegPath', $values['ffmpegPath']);
             OW::getFeedback()->info($language->text('ivideo', 'user_save_success'));
         }
     }
     $this->addForm($adminForm);
 }
コード例 #20
0
ファイル: questions.php プロジェクト: vazahat/dudex
 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");
 }
コード例 #21
0
ファイル: admin.php プロジェクト: vazahat/dudex
 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);
 }
コード例 #22
0
ファイル: settings.php プロジェクト: ZyXelP/oxwall
 /**
  * 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);
 }
コード例 #23
0
ファイル: admin.php プロジェクト: vazahat/dudex
 public function settings()
 {
     $language = OW::getLanguage();
     $config = OW::getConfig();
     $adminForm = new Form('adminForm');
     $element = new TextField('introWidth');
     $element->setValue($config->getValue('sitetour', 'introWidth'));
     $element->setLabel($language->text('sitetour', 'intro_width'));
     $element->setRequired();
     $element->addValidator(new IntValidator(1));
     $adminForm->addElement($element);
     $element = new TextField('guidePos');
     $element->setValue($config->getValue('sitetour', 'guidePos'));
     $element->setLabel($language->text('sitetour', 'guide_pos'));
     $element->setRequired();
     $element->addValidator(new IntValidator(1));
     $adminForm->addElement($element);
     $element = new TextField('guideColor');
     $element->setValue($config->getValue('sitetour', 'guideColor'));
     $element->setLabel($language->text('sitetour', 'guide_color'));
     $element->setId('colorBox');
     $adminForm->addElement($element);
     $element = new CheckboxField('enableForGuests');
     $element->setValue($config->getValue('sitetour', 'enableForGuests'));
     $element->setLabel($language->text('sitetour', 'enable_for_guests'));
     $adminForm->addElement($element);
     $element = new CheckboxField('enableRTL');
     $element->setValue($config->getValue('sitetour', 'enableRTL'));
     $element->setLabel($language->text('sitetour', 'enable_rtl'));
     $adminForm->addElement($element);
     $element = new Selectbox('exitOnEsc');
     $element->addOptions(array('true' => $language->text('sitetour', 'enabled'), 'false' => $language->text('sitetour', 'disabled')));
     $element->setValue($config->getValue('sitetour', 'exitOnEsc'));
     $element->setLabel($language->text('sitetour', 'exit_esc'));
     $element->setRequired();
     $adminForm->addElement($element);
     $element = new Selectbox('exitOnOverlayClick');
     $element->addOptions(array('true' => $language->text('sitetour', 'enabled'), 'false' => $language->text('sitetour', 'disabled')));
     $element->setValue($config->getValue('sitetour', 'exitOnOverlayClick'));
     $element->setLabel($language->text('sitetour', 'exit_overlay_click'));
     $element->setRequired();
     $adminForm->addElement($element);
     $element = new Selectbox('showStepNumbers');
     $element->addOptions(array('true' => $language->text('sitetour', 'enabled'), 'false' => $language->text('sitetour', 'disabled')));
     $element->setValue($config->getValue('sitetour', 'showStepNumbers'));
     $element->setLabel($language->text('sitetour', 'show_step_numbers'));
     $element->setRequired();
     $adminForm->addElement($element);
     $element = new Selectbox('keyboardNavigation');
     $element->addOptions(array('true' => $language->text('sitetour', 'enabled'), 'false' => $language->text('sitetour', 'disabled')));
     $element->setValue($config->getValue('sitetour', 'keyboardNavigation'));
     $element->setLabel($language->text('sitetour', 'keyboard_navigation'));
     $element->setRequired();
     $adminForm->addElement($element);
     $element = new Selectbox('showButtons');
     $element->addOptions(array('true' => $language->text('sitetour', 'enabled'), 'false' => $language->text('sitetour', 'disabled')));
     $element->setValue($config->getValue('sitetour', 'showButtons'));
     $element->setLabel($language->text('sitetour', 'show_buttons'));
     $element->setRequired();
     $adminForm->addElement($element);
     $element = new Selectbox('showBullets');
     $element->addOptions(array('true' => $language->text('sitetour', 'enabled'), 'false' => $language->text('sitetour', 'disabled')));
     $element->setValue($config->getValue('sitetour', 'showBullets'));
     $element->setLabel($language->text('sitetour', 'show_bullets'));
     $element->setRequired();
     $adminForm->addElement($element);
     $element = new Submit('saveSettings');
     $element->setValue($language->text('sitetour', 'admin_save_settings'));
     $adminForm->addElement($element);
     if (OW::getRequest()->isPost()) {
         if ($adminForm->isValid($_POST)) {
             $values = $adminForm->getValues();
             $config->saveConfig('sitetour', 'enableForGuests', $values['enableForGuests']);
             $config->saveConfig('sitetour', 'enableRTL', $values['enableRTL']);
             $config->saveConfig('sitetour', 'exitOnEsc', $values['exitOnEsc']);
             $config->saveConfig('sitetour', 'exitOnOverlayClick', $values['exitOnOverlayClick']);
             $config->saveConfig('sitetour', 'showStepNumbers', $values['showStepNumbers']);
             $config->saveConfig('sitetour', 'keyboardNavigation', $values['keyboardNavigation']);
             $config->saveConfig('sitetour', 'showButtons', $values['showButtons']);
             $config->saveConfig('sitetour', 'showBullets', $values['showBullets']);
             $config->saveConfig('sitetour', 'introWidth', $values['introWidth']);
             $config->saveConfig('sitetour', 'guideColor', $values['guideColor']);
             $config->saveConfig('sitetour', 'guidePos', $values['guidePos']);
             OW::getFeedback()->info($language->text('sitetour', 'user_save_success'));
         }
     }
     $this->addForm($adminForm);
     OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('sitetour')->getStaticCssUrl() . 'spectrum.css');
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('sitetour')->getStaticJsUrl() . 'spectrum.js');
     $this->setPageHeading(OW::getLanguage()->text('sitetour', 'admin_settings_title'));
     $this->setPageTitle(OW::getLanguage()->text('sitetour', 'admin_settings_title'));
     $this->setPageHeadingIconClass('ow_ic_gear_wheel');
 }
コード例 #24
0
ファイル: privacy.php プロジェクト: jorgemunoz8807/havanabook
 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);
 }
コード例 #25
0
ファイル: event_handler.php プロジェクト: ZyXelP/oxwall
 public function onPreferenceAddFormElement(BASE_CLASS_EventCollector $event)
 {
     $language = OW::getLanguage();
     $params = $event->getParams();
     $values = $params['values'];
     $fromElementList = array();
     $fromElement = new CheckboxField('mass_mailing_subscribe');
     $fromElement->setLabel($language->text('base', 'preference_mass_mailing_subscribe_label'));
     $fromElement->setDescription($language->text('base', 'preference_mass_mailing_subscribe_description'));
     if (isset($values['mass_mailing_subscribe'])) {
         $fromElement->setValue($values['mass_mailing_subscribe']);
     }
     $timeZoneSelect = new Selectbox("timeZoneSelect");
     $timeZoneSelect->setLabel($language->text('admin', 'timezone'));
     $timeZoneSelect->addOptions(UTIL_DateTime::getTimezones());
     $timeZoneSelect->setValue($values['timeZoneSelect']);
     $fromElementList[] = $timeZoneSelect;
     $fromElementList[] = $fromElement;
     $event->add($fromElementList);
 }
コード例 #26
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);
 }
コード例 #27
0
ファイル: admin.php プロジェクト: vazahat/dudex
 public function __construct()
 {
     parent::__construct('moneybookers-config-form');
     $language = OW::getLanguage();
     $billingService = BOL_BillingService::getInstance();
     $gwKey = OCSBILLINGMONEYBOOKERS_CLASS_MoneybookersAdapter::GATEWAY_KEY;
     $merchantId = new TextField('merchantId');
     $merchantId->setValue($billingService->getGatewayConfigValue($gwKey, 'merchantId'));
     $merchantId->setRequired(true);
     $merchantId->setLabel($language->text('ocsbillingmoneybookers', 'merchant_id'));
     $this->addElement($merchantId);
     $merchantEmail = new TextField('merchantEmail');
     $merchantEmail->setValue($billingService->getGatewayConfigValue($gwKey, 'merchantEmail'));
     $merchantEmail->setRequired(true);
     $merchantEmail->setLabel($language->text('ocsbillingmoneybookers', 'merchant_email'));
     $this->addElement($merchantEmail);
     $secret = new TextField('secret');
     $secret->setValue($billingService->getGatewayConfigValue($gwKey, 'secret'));
     $secret->setRequired(true);
     $secret->setLabel($language->text('ocsbillingmoneybookers', 'secret'));
     $this->addElement($secret);
     $sandboxMode = new CheckboxField('sandboxMode');
     $sandboxMode->setValue($billingService->getGatewayConfigValue($gwKey, 'sandboxMode'));
     $sandboxMode->setLabel($language->text('ocsbillingmoneybookers', 'sandbox_mode'));
     $this->addElement($sandboxMode);
     $desc = new TextField('recipientDescription');
     $desc->setValue($billingService->getGatewayConfigValue($gwKey, 'recipientDescription'));
     $desc->setLabel($language->text('ocsbillingmoneybookers', 'recipient_description'));
     $this->addElement($desc);
     $lang = new Selectbox('language');
     $lang->setLabel($language->text('ocsbillingmoneybookers', 'language'));
     $lang->addOptions(array('EN' => 'EN', 'DE' => 'DE', 'ES' => 'ES', 'FR' => 'FR', 'IT' => 'IT', 'PL' => 'PL', 'GR' => 'GR', 'RO' => 'PO', 'RU' => 'RU', 'TR' => 'TR', 'CN' => 'CN', 'CZ' => 'CZ', 'NL' => 'NL', 'DA' => 'DA', 'SV' => 'SV', 'FI' => 'FI'));
     $lang->setRequired(true);
     $lang->setValue($billingService->getGatewayConfigValue($gwKey, 'language'));
     $this->addElement($lang);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('ocsbillingmoneybookers', 'btn_save'));
     $this->addElement($submit);
 }
コード例 #28
0
ファイル: edit.php プロジェクト: ZyXelP/oxwall
 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);
             }
         }
     }
 }
コード例 #29
0
ファイル: languages.php プロジェクト: hardikamutech/hammu
 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);
 }
コード例 #30
0
 /**
  * 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);
 }