Пример #1
0
 public function index($params = array())
 {
     $userService = BOL_UserService::getInstance();
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('hotlist', 'admin_heading_settings'));
     $this->setPageHeadingIconClass('ow_ic_gear_wheel');
     $settingsForm = new Form('settingsForm');
     $settingsForm->setId('settingsForm');
     $expiration_time = new TextField('expiration_time');
     $expiration_time->setRequired();
     $expiration_time->setLabel($language->text('hotlist', 'label_expiration_time'));
     $expiration_time_value = (int) OW::getConfig()->getValue('hotlist', 'expiration_time') / 86400;
     $expiration_time->setValue($expiration_time_value);
     $settingsForm->addElement($expiration_time);
     $submit = new Submit('save');
     $submit->addAttribute('class', 'ow_ic_save');
     $submit->setValue($language->text('hotlist', 'label_save_btn_label'));
     $settingsForm->addElement($submit);
     $this->addForm($settingsForm);
     if (OW::getRequest()->isPost()) {
         if ($settingsForm->isValid($_POST)) {
             $data = $settingsForm->getValues();
             OW::getConfig()->saveConfig('hotlist', 'expiration_time', $data['expiration_time'] * 86400);
             OW::getFeedback()->info($language->text('hotlist', 'settings_saved'));
             $this->redirect();
         }
     }
 }
Пример #2
0
 public function __construct($ctrl)
 {
     parent::__construct('settings-form');
     $configs = OW::getConfig()->getValues('yncontactimporter');
     $ctrl->assign('configs', $configs);
     $l = OW::getLanguage();
     $miValidator = new IntValidator(1, 999);
     $miValidator->setErrorMessage($l->text('yncontactimporter', 'max_validation_error', array('min' => 1, 'max' => 999)));
     //Contacts per page
     $textField['contact_per_page'] = new TextField('contact_per_page');
     $textField['contact_per_page']->setLabel($l->text('yncontactimporter', 'settings_contact_per_page'))->setValue($configs['contact_per_page'])->addValidator($miValidator)->setRequired(true);
     $this->addElement($textField['contact_per_page']);
     //Maximum invite per times
     $textField['max_invite_per_times'] = new TextField('max_invite_per_times');
     $textField['max_invite_per_times']->setLabel($l->text('yncontactimporter', 'settings_max_invite_per_times'))->setValue($configs['max_invite_per_times'])->addValidator($miValidator)->setRequired(true);
     $this->addElement($textField['max_invite_per_times']);
     //Default invite message
     $textField['default_invite_message'] = new Textarea('default_invite_message');
     $textField['default_invite_message']->setLabel($l->text('yncontactimporter', 'settings_default_invite_message'))->setValue($configs['default_invite_message']);
     $this->addElement($textField['default_invite_message']);
     // Logo width
     $textField['logo_width'] = new TextField('logo_width');
     $textField['logo_width']->setLabel($l->text('yncontactimporter', 'settings_logo_width'))->setValue($configs['logo_width'])->addValidator($miValidator)->setRequired(true);
     $this->addElement($textField['logo_width']);
     // Logo Height
     $textField['logo_height'] = new TextField('logo_height');
     $textField['logo_height']->setLabel($l->text('yncontactimporter', 'settings_logo_height'))->setValue($configs['logo_height'])->addValidator($miValidator)->setRequired(true);
     $this->addElement($textField['logo_height']);
     $submit = new Submit('submit');
     $submit->setValue($l->text('yncontactimporter', 'save_btn_label'));
     $submit->addAttribute('class', 'ow_ic_save ow_positive');
     $this->addElement($submit);
 }
Пример #3
0
 public function __construct($name, $senderId, $context = MCOMPOSE_BOL_Service::CONTEXT_USER, $initJs = true, $inPopup = true)
 {
     parent::__construct($name);
     $language = OW::getLanguage();
     $this->userId = $senderId;
     $this->context = $context;
     $this->setAction(OW::getRouter()->urlFor('MCOMPOSE_CTRL_Compose', 'send', array('userId' => $senderId, 'formName' => $this->getName())));
     $this->setMethod(self::METHOD_POST);
     $this->setId($this->getName());
     $this->setEnctype('multipart/form-data');
     $this->setAjax();
     $this->setAjaxResetOnSuccess(false);
     $to = new MCOMPOSE_CLASS_UserSelectField('recipients', OW::getLanguage()->text('mcompose', 'selector_invitation_label'));
     $to->setRequired();
     $this->addElement($to);
     //thickbox
     $validatorSubject = new StringValidator(0, 2048);
     $validatorSubject->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => 2048)));
     $subject = new TextField('subject');
     $subject->setInvitation('Subject');
     $subject->setHasInvitation(true);
     $subject->setLabel($language->text('mailbox', 'subject'))->addAttribute('class', 'ow_text');
     $subject->addValidator($validatorSubject);
     $subject->setRequired(true);
     $this->addElement($subject);
     $validatorTextarea = new StringValidator(0, 24000);
     $validatorTextarea->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => 24000)));
     $message = new WysiwygTextarea('message', array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO), true);
     $message->setLabel($language->text('mailbox', 'text'))->addAttribute('class', 'ow_text');
     $message->setSize(300);
     $message->addValidator($validatorTextarea);
     $message->setRequired(true);
     $this->addElement($message);
     if (OW::getConfig()->getValue('mailbox', 'enable_attachments')) {
         $multiUpload = new MAILBOX_CLASS_AjaxFileUpload('attachments');
         //$multiUpload->setId('attachments');
         $this->addElement($multiUpload);
     }
     // Captcha
     $captcha = new MailboxCaptchaField('captcha');
     $captcha->addValidator(new MailboxCaptchaValidator($captcha->getId()));
     $captcha->addAttribute('disabled', 'disabled');
     $this->addElement($captcha);
     $submit = new Submit('send');
     $submit->setValue($language->text('mailbox', 'send_button'));
     $submit->addAttribute('class', 'ow_button ow_ic_mail');
     $this->addElement($submit);
     if ($initJs) {
         $js = "owForms['" . $this->getName() . "'].bind( 'success',\n            function( json )\n            {\n                var _complete = function(){ \n                    if ( _scope.floatBox ) _scope.floatBox.close();\n                };\n\n                var form = \$('#" . $this->getName() . "');\n                var captcha = form.find('input[name=captcha]');\n\n                if ( json.result == 'permission_denied' )\n                {\n                    if ( json.message )\n                    {\n                        OW.error(json.message);\n                    }\n                    else\n                    {\n                        OW.error(" . json_encode(OW::getLanguage()->text('mailbox', 'write_permission_denied')) . ");\n                    }\n                    \n                    _complete();\n                }\n                else if ( json.result == 'display_captcha' )\n            \t{\n                   window." . $captcha->jsObjectName . ".refresh();\n\n                   if ( captcha.attr('disabled') != 'disabled' )\n                   {\n                        owForms['" . $this->getName() . "'].getElement('captcha').showError(" . json_encode(OW::getLanguage()->text('base', 'form_validator_captcha_error_message')) . ");\n                   }\n                   else\n                   {\n                        captcha.removeAttr('disabled');\n                   }\n\n                   form.find('tr.captcha').show();\n                   form.find('tr.mailbox_conversation').hide();\n                }\n                else if ( json.result == true )\n            \t{\n                    captcha.attr('disabled','disabled');\n                    form.find('tr.captcha').hide();\n                    window." . $captcha->jsObjectName . ".refresh();\n\n                    form.find('tr.captcha').hide();\n                    form.find('tr.mailbox_conversation').show();\n\n                    owForms['" . $this->getName() . "'].resetForm();\n                    form.find('textarea[name=message]').get(0).htmlareaRefresh();\n\n                    if ( json.error )\n                        OW.error(json.error);\n\n                    if ( json.warning )\n                        OW.warning(json.warning);\n\n                     if ( json.message )\n                        OW.info(json.message);\n                        \n                    _complete();\n                }\n                else if ( json.error )\n                {\n                    OW.error(json.error);\n                    \n                    _complete();\n                }\n\n            }); ";
         OW::getDocument()->addOnloadScript($js);
     }
 }
Пример #4
0
 public function __construct($entityType, $entityId, $url = NULL)
 {
     parent::__construct('ajax-upload');
     $this->clipService = VIDEO_BOL_ClipService::getInstance();
     $this->setAjax(TRUE);
     $this->setAjaxResetOnSuccess(FALSE);
     //$this->setAjaxDataType(Form::AJAX_DATA_TYPE_JSON);
     $this->setAction(OW::getRouter()->urlForRoute('spvideolite.ajax_video_add_submit'));
     $this->bindJsFunction('success', UTIL_JsGenerator::composeJsString('function( data )
         {
             if ( data )
             {
                 if ( !data.result )
                 {
                     if ( data.msg )
                     {
                         OW.error(data.msg);
                     }
                     else
                     {
                         OW.getLanguageText("spvideolite", "video_add_error");
                     }
                 }
                 else
                 {
                     var url = {$url};
                     
                     if ( url )
                     {
                         window.location.href = url;
                     }
                     else if ( data.url )
                     {
                         window.location.href = data.url;
                     }
                 }
             }
             else
             {
                 OW.error("Server error");
             }
         }', array('url' => $url)));
     $language = OW::getLanguage();
     $userId = OW::getUser()->getId();
     $submit = new Submit('submit');
     $submit->addAttribute('class', 'ow_ic_submit ow_positive');
     $this->addElement($submit);
 }
Пример #5
0
 public function __construct($entityType, $entityId, $albumId = null, $albumName = null, $albumDescription = null, $url = null)
 {
     parent::__construct('ajax-upload');
     $this->setAjax(true);
     $this->setAjaxResetOnSuccess(false);
     $this->setAction(OW::getRouter()->urlForRoute('admin.ajax_upload_submit'));
     $this->bindJsFunction('success', UTIL_JsGenerator::composeJsString('function( data )
         {
             if ( data )
             {
                 if ( !data.result )
                 {
                     if ( data.msg )
                     {
                         OW.error(data.msg);
                     }
                     else
                     {
                         OW.getLanguageText("admin", "photo_upload_error");
                     }
                 }
                 else
                 {
                     var url = {$url};
                     
                     if ( url )
                     {
                         window.location.href = url;
                     }
                     else if ( data.url )
                     {
                         window.location.href = data.url;
                     }
                 }
             }
             else
             {
                 OW.error("Server error");
             }
         }', array('url' => $url)));
     $submit = new Submit('submit');
     $submit->addAttribute('class', 'ow_ic_submit ow_positive');
     $this->addElement($submit);
 }
Пример #6
0
 public function index($params = array())
 {
     $userService = BOL_UserService::getInstance();
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('admin', 'restrictedusernames'));
     $this->setPageHeadingIconClass('ow_ic_script');
     $restrictedUsernamesForm = new Form('restrictedUsernamesForm');
     $restrictedUsernamesForm->setId('restrictedUsernamesForm');
     $username = new TextField('restrictedUsername');
     $username->addAttribute('class', 'ow_text');
     $username->addAttribute('style', 'width: auto;');
     $username->setRequired();
     $username->setLabel($language->text('admin', 'restrictedusernames_username_label'));
     $restrictedUsernamesForm->addElement($username);
     $submit = new Submit('addUsername');
     $submit->addAttribute('class', 'ow_button');
     $submit->setValue($language->text('admin', 'restrictedusernames_add_username_button'));
     $restrictedUsernamesForm->addElement($submit);
     $this->addForm($restrictedUsernamesForm);
     $this->assign('restricted_list', $this->userService->getRestrictedUsernameList());
     if (OW::getRequest()->isPost()) {
         if ($restrictedUsernamesForm->isValid($_POST)) {
             $data = $restrictedUsernamesForm->getValues();
             $username = $this->userService->getRestrictedUsername($data['restrictedUsername']);
             if (empty($username)) {
                 $username = new BOL_RestrictedUsernames();
                 $username->setRestrictedUsername($data['restrictedUsername']);
                 $this->userService->addRestrictedUsername($username);
                 OW::getFeedback()->info($language->text('admin', 'restrictedusernames_username_added'));
                 $this->redirect();
             } else {
                 OW::getFeedback()->warning($language->text('admin', 'restrictedusernames_username_already_exists'));
             }
         }
     }
 }
Пример #7
0
 public function __construct($controller)
 {
     parent::__construct('joinForm');
     $this->setId('joinForm');
     $stamp = OW::getSession()->get(self::SESSION_START_STAMP);
     if (empty($stamp)) {
         OW::getSession()->set(self::SESSION_START_STAMP, time());
     }
     unset($stamp);
     $this->checkSession();
     $joinSubmitLabel = "";
     // get available account types from DB
     $accounts = $this->getAccountTypes();
     $joinData = OW::getSession()->get(self::SESSION_JOIN_DATA);
     if (!isset($joinData) || !is_array($joinData)) {
         $joinData = array();
     }
     $accountsKeys = array_keys($accounts);
     $this->accountType = $accountsKeys[0];
     if (isset($joinData['accountType'])) {
         $this->accountType = trim($joinData['accountType']);
     }
     $step = $this->getStep();
     if (count($accounts) > 1) {
         $this->stepCount = 2;
         switch ($step) {
             case 1:
                 $this->displayAccountType = true;
                 $joinSubmitLabel = OW::getLanguage()->text('base', 'join_submit_button_continue');
                 break;
             case 2:
                 $this->isLastStep = true;
                 $joinSubmitLabel = OW::getLanguage()->text('base', 'join_submit_button_join');
                 break;
         }
     } else {
         $this->isLastStep = true;
         $joinSubmitLabel = OW::getLanguage()->text('base', 'join_submit_button_join');
     }
     $joinSubmit = new Submit('joinSubmit');
     $joinSubmit->addAttribute('class', 'ow_button ow_ic_submit');
     $joinSubmit->setValue($joinSubmitLabel);
     $this->addElement($joinSubmit);
     $this->init($accounts);
     $this->getQuestions();
     $section = null;
     $questionNameList = array();
     $this->sortedQuestionsList = array();
     foreach ($this->questions as $sort => $question) {
         if ((string) $question['base'] === '0' && $step === 2 || $step === 1) {
             if ($section !== $question['sectionName']) {
                 $section = $question['sectionName'];
             }
             //$this->questionListBySection[$section][] = $this->questions[$sort];
             $questionNameList[] = $this->questions[$sort]['name'];
             $this->sortedQuestionsList[] = $this->questions[$sort];
         }
     }
     $this->questionValuesList = BOL_QuestionService::getInstance()->findQuestionsValuesByQuestionNameList($questionNameList);
     $this->addFakeQuestions();
     $this->addQuestions($this->sortedQuestionsList, $this->questionValuesList, $this->updateJoinData());
     $this->setQuestionsLabel();
     $this->addClassToBaseQuestions();
     if ($this->isLastStep) {
         $this->addLastStepQuestions($controller);
     }
     $controller->assign('step', $step);
     $controller->assign('questionArray', $this->questionListBySection);
     $controller->assign('displayAccountType', $this->displayAccountType);
     $controller->assign('isLastStep', $this->isLastStep);
 }
Пример #8
0
 public function view(array $params = array())
 {
     OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('photo')->getStaticCssUrl() . 'admin.css');
     OW::getDocument()->addOnloadScript(';window.photoAdmin.init();');
     $form = new Form('view-mode');
     $form->setAjax(TRUE);
     $form->bindJsFunction('success', 'function(data)
     {
         if ( data && data.result )
         {
             OW.info(data.msg);
         }
     }');
     if (OW::getRequest()->isPost()) {
         OW::getConfig()->saveConfig('photo', 'photo_list_view_classic', (bool) $_POST['photo-list-mode']);
         OW::getConfig()->saveConfig('photo', 'album_list_view_classic', (bool) $_POST['album-list-mode']);
         OW::getConfig()->saveConfig('photo', 'photo_view_classic', (bool) $_POST['photo-view-mode']);
         exit(json_encode(array('result' => true, 'msg' => OW::getLanguage()->text('photo', 'settings_updated'))));
     }
     $photoListMode = new HiddenField('photo-list-mode');
     $photoListMode->setValue(OW::getConfig()->getValue('photo', 'photo_list_view_classic'));
     $form->addElement($photoListMode);
     $albumListMode = new HiddenField('album-list-mode');
     $albumListMode->setValue(OW::getConfig()->getValue('photo', 'album_list_view_classic'));
     $form->addElement($albumListMode);
     $photoViewMode = new HiddenField('photo-view-mode');
     $photoViewMode->setValue(OW::getConfig()->getValue('photo', 'photo_view_classic'));
     $form->addElement($photoViewMode);
     $submit = new Submit('save');
     $submit->addAttribute('class', 'ow_ic_save ow_positive');
     $submit->setValue(OW::getLanguage()->text('photo', 'btn_edit'));
     $form->addElement($submit);
     $this->addForm($form);
 }
Пример #9
0
 public function __construct($entityType, $entityId, $albumId = NULL, $albumName = NULL, $albumDescription = NULL, $url = NULL)
 {
     parent::__construct('ajax-upload');
     $this->setAjax(TRUE);
     $this->setAjaxResetOnSuccess(FALSE);
     $this->setAction(OW::getRouter()->urlForRoute('photo.ajax_upload_submit'));
     $this->bindJsFunction('success', UTIL_JsGenerator::composeJsString('function( data )
         {
             if ( data )
             {
                 if ( !data.result )
                 {
                     if ( data.msg )
                     {
                         OW.error(data.msg);
                     }
                     else
                     {
                         OW.getLanguageText("photo", "photo_upload_error");
                     }
                 }
                 else
                 {
                     var url = {$url};
                     
                     if ( url )
                     {
                         window.location.href = url;
                     }
                     else if ( data.url )
                     {
                         window.location.href = data.url;
                     }
                 }
             }
             else
             {
                 OW.error("Server error");
             }
         }', array('url' => $url)));
     $language = OW::getLanguage();
     $albumField = new TextField('album');
     $albumField->setRequired();
     $albumField->addAttribute('class', 'ow_dropdown_btn ow_inputready ow_cursor_pointer');
     $albumField->addAttribute('autocomplete', 'off');
     $albumField->addAttribute('readonly');
     $albumNameField = new TextField('album-name');
     $albumNameField->setRequired();
     $albumNameField->addValidator(new PHOTO_CLASS_AlbumNameValidator(FALSE));
     $albumNameField->addAttribute('class', 'ow_smallmargin invitation');
     $this->addElement($albumNameField);
     $desc = new Textarea('description');
     $desc->addAttribute('class', 'invitation');
     if (!empty($albumDescription)) {
         $desc->setValue($albumDescription);
     } else {
         $desc->setValue($language->text('photo', 'album_desc'));
     }
     $this->addElement($desc);
     $userId = OW::getUser()->getId();
     if (!empty($albumId) && ($album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($albumId, $userId)) !== NULL && $album->userId == $userId && $album->name != trim(OW::getLanguage()->text('photo', 'newsfeed_album'))) {
         $albumField->setValue($album->name);
         $albumNameField->setValue($album->name);
     } elseif (!empty($albumName)) {
         $albumField->setValue($albumName);
         $albumNameField->setValue($albumName);
     } else {
         $event = new BASE_CLASS_EventCollector(PHOTO_CLASS_EventHandler::EVENT_SUGGEST_DEFAULT_ALBUM, array('userId' => $userId, 'entityType' => $entityType, 'entityId' => $entityId));
         OW::getEventManager()->trigger($event);
         $data = $event->getData();
         if (!empty($data)) {
             $albumField->setValue($data[0]);
             $albumNameField->setValue($data[0]);
         } else {
             $albumField->setValue($language->text('photo', 'choose_existing_or_create'));
             $albumNameField->setValue($language->text('photo', 'album_name'));
         }
     }
     $this->addElement($albumField);
     $submit = new Submit('submit');
     $submit->addAttribute('class', 'ow_ic_submit ow_positive');
     $this->addElement($submit);
 }
Пример #10
0
 public function fillRequiredQuestions($params)
 {
     if (!OW::getUser()->isAuthenticated()) {
         throw new AuthenticateException();
     }
     $user = OW::getUser()->getUserObject();
     $accountType = BOL_QuestionService::getInstance()->findAccountTypeByName($user->accountType);
     if (empty($accountType)) {
         throw new Redirect404Exception();
     }
     $language = OW::getLanguage();
     $event = new OW_Event(OW_EventManager::ON_BEFORE_USER_COMPLETE_PROFILE, array('user' => $user));
     OW::getEventManager()->trigger($event);
     // -- Edit form --
     $form = new EditQuestionForm('requiredQuestionsForm', $user->id);
     $form->setId('requiredQuestionsForm');
     $editSubmit = new Submit('submit');
     $editSubmit->addAttribute('class', 'ow_button ow_ic_save');
     $editSubmit->setValue($language->text('base', 'continue_button'));
     $form->addElement($editSubmit);
     $questions = $this->questionService->getEmptyRequiredQuestionsList($user->id);
     if (empty($questions)) {
         $this->redirect(OW::getRouter()->urlForRoute('base_default_index'));
     }
     $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($user->id), $questionNameList);
     $questionValues = $this->questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     $form->addQuestions($questions, $questionValues, array());
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $this->saveRequiredQuestionsData($form->getValues(), $user->id);
         }
     } else {
         OW::getDocument()->addOnloadScript(" OW.info(" . json_encode(OW::getLanguage()->text('base', 'complete_profile_info')) . ") ");
     }
     $this->addForm($form);
     $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' => $form->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Edit", "ajaxResponder"))) . ",\n                " . UTIL_Validator::EMAIL_PATTERN . ", " . UTIL_Validator::USER_NAME_PATTERN . ", " . $user->id . " ); ";
     OW::getDocument()->addOnloadScript($onLoadJs);
     $jsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
     OW::getDocument()->addScript($jsDir . "base_field_validators.js");
 }
Пример #11
0
    public function __construct($entityType, $entityId, $albumId = null, $albumName = null, $albumDescription = null, $url = null, $data = null)
    {
        parent::__construct(self::FORM_NAME);
        $this->setAjax(true);
        $this->setAjaxResetOnSuccess(false);
        $this->setAction(OW::getRouter()->urlForRoute('photo.ajax_upload_submit'));
        $this->bindJsFunction(self::BIND_SUCCESS, UTIL_JsGenerator::composeJsString('function( data )
        {
            if ( data )
            {
                if ( !data.result )
                {
                    if ( data.msg )
                    {
                        OW.error(data.msg);
                    }
                    else
                    {
                        OW.getLanguageText("photo", "photo_upload_error");
                    }
                }
                else
                {
                    var url = {$url};

                    if ( url )
                    {
                        window.location.href = url;
                    }
                    else if ( data.url )
                    {
                        window.location.href = data.url;
                    }
                }
            }
            else
            {
                OW.error("Server error");
            }
        }', array('url' => $url)));
        $language = OW::getLanguage();
        $albumField = new TextField(self::ELEMENT_ALBUM);
        $albumField->setRequired();
        $albumField->addAttribute(FormElement::ATTR_CLASS, 'ow_dropdown_btn ow_inputready ow_cursor_pointer');
        $albumField->addAttribute('autocomplete', 'off');
        $albumField->addAttribute(FormElement::ATTR_READONLY);
        $albumNameField = new TextField(self::ELEMENT_ALBUM_NAME);
        $albumNameField->setRequired();
        $albumNameField->addValidator(new PHOTO_CLASS_AlbumNameValidator(false));
        $albumNameField->addAttribute('placeholder', $language->text('photo', 'album_name'));
        $this->addElement($albumNameField);
        $desc = new Textarea(self::ELEMENT_DESCRIPTION);
        $desc->addAttribute('placeholder', $language->text('photo', 'album_desc'));
        $desc->setValue(!empty($albumDescription) ? $albumDescription : null);
        $this->addElement($desc);
        $userId = OW::getUser()->getId();
        $albumService = PHOTO_BOL_PhotoAlbumService::getInstance();
        if (!empty($albumId) && ($album = $albumService->findAlbumById($albumId)) !== null && $album->userId == $userId && !$albumService->isNewsfeedAlbum($album)) {
            $albumField->setValue($album->name);
            $albumNameField->setValue($album->name);
        } elseif (!empty($albumName)) {
            $albumField->setValue($albumName);
            $albumNameField->setValue($albumName);
        } else {
            $event = OW::getEventManager()->trigger(new BASE_CLASS_EventCollector(PHOTO_CLASS_EventHandler::EVENT_SUGGEST_DEFAULT_ALBUM, array('userId' => $userId, 'entityType' => $entityType, 'entityId' => $entityId)));
            $eventData = $event->getData();
            if (!empty($eventData)) {
                $value = array_shift($eventData);
                $albumField->setValue($value);
                $albumNameField->setValue($value);
            } else {
                $albumField->setValue($language->text('photo', 'choose_existing_or_create'));
            }
        }
        $this->addElement($albumField);
        $submit = new Submit('submit');
        $submit->addAttribute('class', 'ow_ic_submit ow_positive');
        $this->addElement($submit);
        $this->triggerReady(array('entityType' => $entityType, 'entityId' => $entityId, 'albumId' => $albumId, 'albumName' => $albumName, 'albumDescription' => $albumDescription, 'url' => $url, 'data' => $data));
    }
Пример #12
0
 public function __construct(Post $post, $tags = array())
 {
     parent::__construct('save');
     $this->service = PostService::getInstance();
     $this->post = $post;
     $this->setMethod('post');
     $titleTextField = new TextField('title');
     $this->addElement($titleTextField->setLabel(OW::getLanguage()->text('blogs', 'save_form_lbl_title'))->setValue($post->getTitle())->setRequired(true));
     $buttons = array(BOL_TextFormatService::WS_BTN_BOLD, BOL_TextFormatService::WS_BTN_ITALIC, BOL_TextFormatService::WS_BTN_UNDERLINE, BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_LINK, BOL_TextFormatService::WS_BTN_ORDERED_LIST, BOL_TextFormatService::WS_BTN_UNORDERED_LIST, BOL_TextFormatService::WS_BTN_MORE, BOL_TextFormatService::WS_BTN_SWITCH_HTML, BOL_TextFormatService::WS_BTN_HTML, BOL_TextFormatService::WS_BTN_VIDEO);
     $postTextArea = new WysiwygTextarea('post', $buttons);
     $postTextArea->setSize(WysiwygTextarea::SIZE_L);
     $postTextArea->setLabel(OW::getLanguage()->text('blogs', 'save_form_lbl_post'));
     $postTextArea->setValue($post->getPost());
     $postTextArea->setRequired(true);
     $this->addElement($postTextArea);
     $draftSubmit = new Submit('draft');
     $draftSubmit->addAttribute('onclick', "\$('#save_post_command').attr('value', 'draft');");
     if ($post->getId() != null && !$post->isDraft()) {
         $text = OW::getLanguage()->text('blogs', 'change_status_draft');
     } else {
         $text = OW::getLanguage()->text('blogs', 'sava_draft');
     }
     $this->addElement($draftSubmit->setValue($text));
     if ($post->getId() != null && !$post->isDraft()) {
         $text = OW::getLanguage()->text('blogs', 'update');
     } else {
         $text = OW::getLanguage()->text('blogs', 'save_publish');
     }
     $publishSubmit = new Submit('publish');
     $publishSubmit->addAttribute('onclick', "\$('#save_post_command').attr('value', 'publish');");
     $this->addElement($publishSubmit->setValue($text));
     $tagService = BOL_TagService::getInstance();
     $tags = array();
     if (intval($this->post->getId()) > 0) {
         $arr = $tagService->findEntityTags($this->post->getId(), 'blog-post');
         foreach (!empty($arr) ? $arr : array() as $dto) {
             $tags[] = $dto->getLabel();
         }
     }
     $tf = new TagsInputField('tf');
     $tf->setLabel(OW::getLanguage()->text('blogs', 'tags_field_label'));
     $tf->setValue($tags);
     $this->addElement($tf);
 }
Пример #13
0
 public function index($params)
 {
     $adminMode = false;
     $viewerId = OW::getUser()->getId();
     if (!OW::getUser()->isAuthenticated() || $viewerId === null) {
         throw new AuthenticateException();
     }
     if (!empty($params['userId']) && $params['userId'] != $viewerId) {
         if (OW::getUser()->isAdmin() || OW::getUser()->isAuthorized('base')) {
             $adminMode = true;
             $userId = (int) $params['userId'];
             $user = BOL_UserService::getInstance()->findUserById($userId);
             if (empty($user) || BOL_AuthorizationService::getInstance()->isSuperModerator($userId)) {
                 throw new Redirect404Exception();
             }
             $editUserId = $userId;
         } else {
             throw new Redirect403Exception();
         }
     } else {
         $editUserId = $viewerId;
         $changePassword = new BASE_CMP_ChangePassword();
         $this->addComponent("changePassword", $changePassword);
         $contentMenu = new BASE_CMP_DashboardContentMenu();
         $contentMenu->getElement('profile_edit')->setActive(true);
         $this->addComponent('contentMenu', $contentMenu);
         $user = OW::getUser()->getUserObject();
         //BOL_UserService::getInstance()->findUserById($editUserId);
     }
     $changeList = BOL_PreferenceService::getInstance()->getPreferenceValue(self::PREFERENCE_LIST_OF_CHANGES, $editUserId);
     if (empty($changeList)) {
         $changeList = '[]';
     }
     $this->assign('changeList', json_decode($changeList, true));
     $isEditedUserModerator = BOL_AuthorizationService::getInstance()->isModerator($editUserId) || BOL_AuthorizationService::getInstance()->isSuperModerator($editUserId);
     $accountType = $user->accountType;
     // dispaly account type
     if (OW::getUser()->isAdmin() || OW::getUser()->isAuthorized('base')) {
         $accountType = !empty($_GET['accountType']) ? $_GET['accountType'] : $user->accountType;
         // get available account types from DB
         $accountTypes = BOL_QuestionService::getInstance()->findAllAccountTypes();
         $accounts = array();
         if (count($accountTypes) > 1) {
             /* @var $value BOL_QuestionAccount */
             foreach ($accountTypes as $key => $value) {
                 $accounts[$value->name] = OW::getLanguage()->text('base', 'questions_account_type_' . $value->name);
             }
             if (!in_array($accountType, array_keys($accounts))) {
                 if (in_array($user->accountType, array_keys($accounts))) {
                     $accountType = $user->accountType;
                 } else {
                     $accountType = BOL_QuestionService::getInstance()->getDefaultAccountType()->name;
                 }
             }
             $editAccountType = new Selectbox('accountType');
             $editAccountType->setId('accountType');
             $editAccountType->setLabel(OW::getLanguage()->text('base', 'questions_question_account_type_label'));
             $editAccountType->setRequired();
             $editAccountType->setOptions($accounts);
             $editAccountType->setHasInvitation(false);
         } else {
             $accountType = BOL_QuestionService::getInstance()->getDefaultAccountType()->name;
         }
     }
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('base', 'edit_index'));
     $this->setPageHeadingIconClass('ow_ic_user');
     // -- Edit form --
     $editForm = new EditQuestionForm('editForm', $editUserId);
     $editForm->setId('editForm');
     $this->assign('displayAccountType', false);
     // dispaly account type
     if (!empty($editAccountType)) {
         $editAccountType->setValue($accountType);
         $editForm->addElement($editAccountType);
         OW::getDocument()->addOnloadScript(" \$('#accountType').change(function() {\n                \n                var form = \$(\"<form method='get'><input type='text' name='accountType' value='\" + \$(this).val() + \"' /></form>\");\n                \$('body').append(form);\n                \$(form).submit();\n\n            }  ); ");
         $this->assign('displayAccountType', true);
     }
     $userId = !empty($params['userId']) ? $params['userId'] : $viewerId;
     // add avatar field
     $editAvatar = OW::getClassInstance("BASE_CLASS_AvatarField", 'avatar', false);
     $editAvatar->setLabel(OW::getLanguage()->text('base', 'questions_question_user_photo_label'));
     $editAvatar->setValue(BOL_AvatarService::getInstance()->getAvatarUrl($userId, 1, null, true, false));
     $displayPhotoUpload = OW::getConfig()->getValue('base', 'join_display_photo_upload');
     // add the required avatar validator
     if ($displayPhotoUpload == BOL_UserService::CONFIG_JOIN_DISPLAY_AND_SET_REQUIRED_PHOTO_UPLOAD) {
         $avatarValidator = OW::getClassInstance("BASE_CLASS_AvatarFieldValidator", true, $userId);
         $editAvatar->addValidator($avatarValidator);
     }
     $editForm->addElement($editAvatar);
     $isUserApproved = BOL_UserService::getInstance()->isApproved($editUserId);
     $this->assign('isUserApproved', $isUserApproved);
     // add submit button
     $editSubmit = new Submit('editSubmit');
     $editSubmit->addAttribute('class', 'ow_button ow_ic_save');
     $editSubmit->setValue($language->text('base', 'edit_button'));
     if ($adminMode && !$isUserApproved) {
         $editSubmit->setName('saveAndApprove');
         $editSubmit->setValue($language->text('base', 'save_and_approve'));
         // TODO: remove
         if (!$isEditedUserModerator) {
             // add delete button
             $script = UTIL_JsGenerator::newInstance()->jQueryEvent('input.delete_user_by_moderator', 'click', 'OW.Users.deleteUser(e.data.userId, e.data.callbackUrl, false);', array('e'), array('userId' => $userId, 'callbackUrl' => OW::getRouter()->urlForRoute('base_member_dashboard')));
             OW::getDocument()->addOnloadScript($script);
         }
     }
     $editForm->addElement($editSubmit);
     // prepare question list
     $questions = $this->questionService->findEditQuestionsForAccountType($accountType);
     $section = null;
     $questionArray = array();
     $questionNameList = array();
     foreach ($questions as $sort => $question) {
         if ($section !== $question['sectionName']) {
             $section = $question['sectionName'];
         }
         $questionArray[$section][$sort] = $questions[$sort];
         $questionNameList[] = $questions[$sort]['name'];
     }
     $this->assign('questionArray', $questionArray);
     $questionData = $this->questionService->getQuestionData(array($editUserId), $questionNameList);
     $questionValues = $this->questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     // add question to form
     $editForm->addQuestions($questions, $questionValues, !empty($questionData[$editUserId]) ? $questionData[$editUserId] : array());
     // process form
     if (OW::getRequest()->isPost()) {
         if (isset($_POST['editSubmit']) || isset($_POST['saveAndApprove'])) {
             $this->process($editForm, $user->id, $questionArray, $adminMode);
         }
     }
     $this->addForm($editForm);
     $deleteUrl = OW::getRouter()->urlForRoute('base_delete_user');
     $this->assign('unregisterProfileUrl', $deleteUrl);
     // add langs to js
     $language->addKeyForJs('base', 'join_error_username_not_valid');
     $language->addKeyForJs('base', 'join_error_username_already_exist');
     $language->addKeyForJs('base', 'join_error_email_not_valid');
     $language->addKeyForJs('base', 'join_error_email_already_exist');
     $language->addKeyForJs('base', 'join_error_password_not_valid');
     $language->addKeyForJs('base', 'join_error_password_too_short');
     $language->addKeyForJs('base', 'join_error_password_too_long');
     //include js
     $onLoadJs = " window.edit = new OW_BaseFieldValidators( " . json_encode(array('formName' => $editForm->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Edit", "ajaxResponder"))) . ",\n                                                        " . UTIL_Validator::EMAIL_PATTERN . ", " . UTIL_Validator::USER_NAME_PATTERN . ", " . $editUserId . " ); ";
     $this->assign('isAdmin', OW::getUser()->isAdmin());
     $this->assign('isEditedUserModerator', $isEditedUserModerator);
     $this->assign('adminMode', $adminMode);
     $approveEnabled = OW::getConfig()->getValue('base', 'mandatory_user_approve');
     $this->assign('approveEnabled', $approveEnabled);
     OW::getDocument()->addOnloadScript('
         $("input.write_message_button").click( function() {
                 OW.ajaxFloatBox("BASE_CMP_SendMessageToEmail", [' . (int) $editUserId . '],
                 {
                     title: ' . json_encode($language->text('base', 'send_message_to_email')) . ',
                     width:600
                 });
             }
         );
     ');
     OW::getDocument()->addOnloadScript($onLoadJs);
     $jsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
     OW::getDocument()->addScript($jsDir . "base_field_validators.js");
     if (!$adminMode) {
         $editSynchronizeHook = OW::getRegistry()->getArray(self::EDIT_SYNCHRONIZE_HOOK);
         if (!empty($editSynchronizeHook)) {
             $content = array();
             foreach ($editSynchronizeHook as $function) {
                 $result = call_user_func($function);
                 if (trim($result)) {
                     $content[] = $result;
                 }
             }
             $content = array_filter($content, 'trim');
             if (!empty($content)) {
                 $this->assign('editSynchronizeHook', $content);
             }
         }
     }
 }
Пример #14
0
 public function index($params)
 {
     $adminMode = false;
     $viewerId = OW::getUser()->getId();
     if (!OW::getUser()->isAuthenticated() || $viewerId === null) {
         throw new AuthenticateException();
     }
     if (!empty($params['userId']) && $params['userId'] != $viewerId) {
         if (OW::getUser()->isAdmin() || OW::getUser()->isAuthorized('base')) {
             $adminMode = true;
             $userId = (int) $params['userId'];
             $user = BOL_UserService::getInstance()->findUserById($userId);
             if (empty($user) || BOL_AuthorizationService::getInstance()->isSuperModerator($userId)) {
                 throw new Redirect404Exception();
             }
             $editUserId = $userId;
         } else {
             throw new Redirect403Exception();
         }
     } else {
         $editUserId = $viewerId;
         $changePassword = new BASE_CMP_ChangePassword();
         $this->addComponent("changePassword", $changePassword);
         $contentMenu = new BASE_CMP_DashboardContentMenu();
         $contentMenu->getElement('profile_edit')->setActive(true);
         $this->addComponent('contentMenu', $contentMenu);
         $user = BOL_UserService::getInstance()->findUserById($editUserId);
     }
     $accountType = $user->accountType;
     $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');
     $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();
     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);
     $editForm->addQuestions($questions, $questionValues, $questionData[$editUserId]);
     if (OW::getRequest()->isPost()) {
         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
 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);
 }
Пример #16
0
 public function index($params)
 {
     $userId = OW::getUser()->getId();
     if (OW::getRequest()->isAjax()) {
         exit;
     }
     if (!OW::getUser()->isAuthenticated() || $userId === null) {
         throw new AuthenticateException();
     }
     $contentMenu = new BASE_CMP_PreferenceContentMenu();
     $contentMenu->getElement('privacy')->setActive(true);
     $this->addComponent('contentMenu', $contentMenu);
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('privacy', 'privacy_index'));
     $this->setPageHeadingIconClass('ow_ic_lock');
     // -- Action form --
     $privacyForm = new Form('privacyForm');
     $privacyForm->setId('privacyForm');
     $actionSubmit = new Submit('privacySubmit');
     $actionSubmit->addAttribute('class', 'ow_button ow_ic_save');
     $actionSubmit->setValue($language->text('privacy', 'privacy_submit_button'));
     $privacyForm->addElement($actionSubmit);
     // --
     $actionList = PRIVACY_BOL_ActionService::getInstance()->findAllAction();
     $actionNameList = array();
     foreach ($actionList as $action) {
         $actionNameList[$action->key] = $action->key;
     }
     $actionValueList = PRIVACY_BOL_ActionService::getInstance()->getActionValueList($actionNameList, $userId);
     $actionValuesEvent = new BASE_CLASS_EventCollector(PRIVACY_BOL_ActionService::EVENT_GET_PRIVACY_LIST);
     OW::getEventManager()->trigger($actionValuesEvent);
     $data = $actionValuesEvent->getData();
     $actionValuesInfo = empty($data) ? array() : $data;
     $optionsList = array();
     $sortOptionsList = array();
     $order = array();
     // -- sort action values
     foreach ($actionValuesInfo as $value) {
         $optionsList[$value['key']] = $value['label'];
         $order[$value['sortOrder']] = $value['key'];
     }
     asort($order);
     foreach ($order as $key) {
         $sortOptionsList[$key] = $optionsList[$key];
     }
     // --
     $resultList = array();
     foreach ($actionList as $action) {
         /* @var $action PRIVACY_CLASS_Action */
         if (!empty($action->label)) {
             $formElement = new Selectbox($action->key);
             $formElement->setLabel($action->label);
             $formElement->setDescription('');
             if (!empty($action->description)) {
                 $formElement->setDescription($action->description);
             }
             $formElement->setOptions($sortOptionsList);
             $formElement->setHasInvitation(false);
             if (!empty($actionValueList[$action->key])) {
                 $formElement->setValue($actionValueList[$action->key]);
                 if (array_key_exists($actionValueList[$action->key], $sortOptionsList)) {
                     $formElement->setValue($actionValueList[$action->key]);
                 } else {
                     if ($actionValueList[$action->key] != 'everybody') {
                         $formElement->setValue('only_for_me');
                     }
                 }
             }
             $privacyForm->addElement($formElement);
             $resultList[$action->key] = $action->key;
         }
     }
     if (OW::getRequest()->isPost()) {
         if ($privacyForm->isValid($_POST)) {
             $values = $privacyForm->getValues();
             $restul = PRIVACY_BOL_ActionService::getInstance()->saveActionValues($values, $userId);
             if ($restul) {
                 OW::getFeedback()->info($language->text('privacy', 'action_action_data_was_saved'));
             } else {
                 OW::getFeedback()->warning($language->text('privacy', 'action_action_data_not_changed'));
             }
             $this->redirect();
         }
     }
     $this->addForm($privacyForm);
     $this->assign('actionList', $resultList);
 }
Пример #17
0
 public function __construct()
 {
     $language = OW::getLanguage();
     parent::__construct('add_account_type_form');
     $this->setId('add_account_type_form');
     $account_type = new TextField('account_type');
     $account_type->setRequired();
     $this->addElement($account_type);
     $account_type_submit = new Submit('account_type_submit');
     $account_type_submit->addAttribute('class', 'ow_button');
     $account_type_submit->setValue($language->text('admin', 'questions_add_new_account_type'));
     $this->addElement($account_type_submit);
 }
Пример #18
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);
             }
         }
     }
 }
Пример #19
0
 public function index($params = array())
 {
     $userService = BOL_UserService::getInstance();
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('admin', 'massmailing'));
     $this->setPageHeadingIconClass('ow_ic_script');
     $massMailingForm = new Form('massMailingForm');
     $massMailingForm->setId('massMailingForm');
     $rolesList = BOL_AuthorizationService::getInstance()->getRoleList();
     $userRoles = new CheckboxGroup('userRoles');
     $userRoles->setLabel($language->text('admin', 'massmailing_user_roles_label'));
     foreach ($rolesList as $role) {
         if ($role->name != 'guest') {
             $userRoles->addOption($role->name, $language->text('base', 'authorization_role_' . $role->name));
         }
     }
     $massMailingForm->addElement($userRoles);
     $emailFormat = new Selectbox('emailFormat');
     $emailFormat->setLabel($language->text('admin', 'massmailing_email_format_label'));
     $emailFormat->setOptions(array(self::EMAIL_FORMAT_TEXT => $language->text('admin', 'massmailing_email_format_text'), self::EMAIL_FORMAT_HTML => $language->text('admin', 'massmailing_email_format_html')));
     $emailFormat->setValue(self::EMAIL_FORMAT_TEXT);
     $emailFormat->setHasInvitation(false);
     if (!empty($_POST['emailFormat'])) {
         $emailFormat->setValue($_POST['emailFormat']);
     }
     $massMailingForm->addElement($emailFormat);
     $subject = new TextField('subject');
     $subject->addAttribute('class', 'ow_text');
     $subject->addAttribute('style', 'width: auto;');
     $subject->setRequired();
     $subject->setLabel($language->text('admin', 'massmailing_subject_label'));
     if (!empty($_POST['subject'])) {
         $subject->setValue($_POST['subject']);
     }
     $massMailingForm->addElement($subject);
     $body = new Textarea('body');
     if ($emailFormat->getValue() == self::EMAIL_FORMAT_HTML) {
         $body = new WysiwygTextarea('body');
         $body->forceAddButtons(array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_HTML));
     }
     $body->addAttribute('class', 'ow_text');
     $body->addAttribute('style', 'width: auto;');
     $body->setRequired();
     $body->setLabel($language->text('admin', 'massmailing_body_label'));
     if (!empty($_POST['body'])) {
         $body->setValue($_POST['body']);
     }
     $massMailingForm->addElement($body);
     $submit = new Submit('startMailing');
     $submit->addAttribute('class', 'ow_button');
     $submit->setValue($language->text('admin', 'massmailing_start_mailing_button'));
     $massMailingForm->addElement($submit);
     $this->addForm($massMailingForm);
     $ignoreUnsubscribe = false;
     $isActive = true;
     if (defined('OW_PLUGIN_XP')) {
         $massMailingTimestamp = OW::getConfig()->getValue('admin', 'mass_mailing_timestamp');
         $timeout = $massMailingTimestamp + 60 * 60 * 24 - time();
         if ($timeout > 0) {
             $isActive = false;
             $this->assign('expireText', $language->text('admin', 'massmailing_expire_text', array('hours' => (int) ceil($timeout / (60 * 60)))));
         }
     }
     $this->assign('isActive', $isActive);
     $total = $userService->findMassMailingUserCount($ignoreUnsubscribe);
     if (OW::getRequest()->isPost() && $isActive && isset($_POST['startMailing'])) {
         if ($massMailingForm->isValid($_POST)) {
             $data = $massMailingForm->getValues();
             $start = 0;
             $count = self::MAILS_ARRAY_MAX_RECORDS;
             $mailCount = 0;
             $total = $userService->findMassMailingUserCount($ignoreUnsubscribe, $data['userRoles']);
             while ($start < $total) {
                 $result = $this->userService->findMassMailingUsers($start, $count, $ignoreUnsubscribe, $data['userRoles']);
                 $mails = array();
                 $userIdList = array();
                 foreach ($result as $user) {
                     $userIdList[] = $user->id;
                 }
                 $displayNameList = $this->userService->getDisplayNamesForList($userIdList);
                 $event = new BASE_CLASS_EventCollector('base.add_global_lang_keys');
                 OW::getEventManager()->trigger($event);
                 $vars = call_user_func_array('array_merge', $event->getData());
                 foreach ($result as $key => $user) {
                     $vars['user_email'] = $user->email;
                     $mail = OW::getMailer()->createMail();
                     $mail->addRecipientEmail($user->email);
                     $vars['user_name'] = $displayNameList[$user->id];
                     $code = md5($user->username . $user->password);
                     $link = OW::getRouter()->urlForRoute('base_massmailing_unsubscribe', array('id' => $user->id, 'code' => $code));
                     $subjectText = UTIL_String::replaceVars($data['subject'], $vars);
                     $mail->setSubject($subjectText);
                     if ($data['emailFormat'] === self::EMAIL_FORMAT_HTML) {
                         $htmlContent = UTIL_String::replaceVars($data['body'], $vars);
                         $htmlContent .= $language->text('admin', 'massmailing_unsubscribe_link_html', array('link' => $link));
                         $mail->setHtmlContent($htmlContent);
                         $textContent = preg_replace("/\\<br\\s*[\\/]?\\s*\\>/", "\n", $htmlContent);
                         $textContent = strip_tags($textContent);
                         $mail->setTextContent($textContent);
                     } else {
                         $textContent = UTIL_String::replaceVars($data['body'], $vars);
                         $textContent .= "\n\n" . $language->text('admin', 'massmailing_unsubscribe_link_text', array('link' => $link));
                         $mail->setTextContent($textContent);
                     }
                     $mails[] = $mail;
                     $mailCount++;
                 }
                 $start += $count;
                 //printVar($mails);
                 OW::getMailer()->addListToQueue($mails);
             }
             OW::getFeedback()->info($language->text('admin', 'massmailing_send_mails_message', array('count' => $mailCount)));
             if (defined('OW_PLUGIN_XP')) {
                 OW::getConfig()->saveConfig('admin', 'mass_mailing_timestamp', time());
             }
             $this->redirect();
         }
     }
     $this->assign('userCount', $total);
     $language->addKeyForJs('admin', 'questions_empty_lang_value');
     $language->addKeyForJs('admin', 'massmailing_total_members');
     $script = ' window.massMailing = new MassMailing(\'' . $this->ajaxResponderUrl . '\'); ';
     OW::getDocument()->addOnloadScript($script);
     $jsDir = OW::getPluginManager()->getPlugin("admin")->getStaticJsUrl();
     OW::getDocument()->addScript($jsDir . "mass_mailing.js");
 }
Пример #20
0
 public function __construct($controller)
 {
     $this->setId(UTIL_HtmlTag::generateAutoId('form'));
     $this->setMethod(self::METHOD_POST);
     $this->setAjaxResetOnSuccess(true);
     $this->setAjaxDataType(self::AJAX_DATA_TYPE_JSON);
     $this->bindedFunctions = array(self::BIND_SUBMIT => array(), self::BIND_SUCCESS => array());
     $this->setEmptyElementsErrorMessage(OW::getLanguage()->text('base', 'form_validate_common_error_message'));
     $formNameHidden = new HiddenField('form_name');
     $formNameHidden->setValue('joinForm');
     $this->addElement($formNameHidden);
     $this->setName('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);
     //
     $questionValueList = BOL_QuestionService::getInstance()->findQuestionsValuesByQuestionNameList(array('field_8eb4e427b80ac66d870fc0a5a0cc22ba'));
     //        echo "<pre>";
     //        print_r($questionValueList);
     //        echo "</pre>";
     //        $new = new RadioField('field_8eb4e427b80ac66d870fc0a5a0cc22ba');
     //        $new->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('field_8eb4e427b80ac66d870fc0a5a0cc22ba'));
     //        $new->setRequired();
     //
     //        $this->setFieldOptions($new, 'field_8eb4e427b80ac66d870fc0a5a0cc22ba', $questionValueList['field_8eb4e427b80ac66d870fc0a5a0cc22ba']);
     //
     //        if (!empty($joinData['field_8eb4e427b80ac66d870fc0a5a0cc22ba'])) {
     //            $new->setValue($joinData['field_8eb4e427b80ac66d870fc0a5a0cc22ba']);
     //        }
     //
     //        $this->addElement($new);
     /* if ( $this->displayAccountType )
               {
               $questionValueList = BOL_QuestionService::getInstance()->findQuestionsValuesByQuestionNameList(array('sex', 'match_sex'));
     
               $sex = new RadioField('sex');
               $sex->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('sex'));
               $sex->setRequired();
     
               $this->setFieldOptions($sex, 'sex', $questionValueList['sex']);
     
               if ( !empty($joinData['sex']) )
               {
               $sex->setValue($joinData['sex']);
               }
     
               $this->addElement($sex);
     
               $matchSex = new RadioField('match_sex');
               $matchSex->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('match_sex'));
               $matchSex->setRequired();
     
               $this->setFieldOptions($matchSex, 'match_sex', $questionValueList['match_sex']);
     
               if ( !empty($joinData['match_sex']) )
               {
               $matchSex->setValue($joinData['match_sex']);
               }
     
               $this->addElement($matchSex);
               } */
     $this->getQuestions();
     $section = null;
     //$this->questionListBySection = array();
     $questionNameList = array();
     $this->sortedQuestionsList = array();
     $allquer = $this->questions;
     //        $allquer[] = array
     //            (
     //            "id" => 197,
     //            "name" => "field_2d686163771de45485b437e4d0ecc4f2",
     //            "sectionName" => '179290597507249aa67160dc240b7cae',
     //            "accountTypeName" => "",
     //            "type" => "multiselect",
     //            "presentation" => "multicheckbox",
     //            "required" => 0,
     //            "onJoin" => 1,
     //            "onEdit" => 1,
     //            "onSearch" => 0,
     //            "onView" => 1,
     //            "base" => 0,
     //            "removable" => 1,
     //            "columnCount" => 1,
     //            "sortOrder" => 3,
     //            "custom" => [],
     //            "parent" => "",
     //        );
     //        echo '<pre>';
     //        print_r($allquer);
     //        echo '</pre>';
     foreach ($allquer 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'];
             if (!empty($_SESSION["joinData"][HAMMU_DB_IM_USING_HAMMU_AS_KEY]) && $_SESSION["joinData"][HAMMU_DB_IM_USING_HAMMU_AS_KEY] == 1) {
                 //CLIENT doNOT have
                 if ($question['name'] == HAMMU_DB_PRICE_KEY) {
                     unset($this->questions[$sort]);
                 }
                 if ($question['name'] == HAMMU_DB_METTING_POINT_KEY) {
                     unset($this->questions[$sort]);
                 }
                 //
                 //echo "got here";
                 if ($question['name'] == HAMMU_HOTEL_SERVICE) {
                     unset($this->questions[$sort]);
                 }
                 if ($question['name'] == HAMMU_HOME_VISIT) {
                     unset($this->questions[$sort]);
                 }
                 if ($question['name'] == HAMMU_SECRET_FANTASY) {
                     unset($this->questions[$sort]);
                 }
                 if ($question['name'] == HAMMU_LANGUAGE) {
                     unset($this->questions[$sort]);
                 }
                 if ($question['name'] == HAMMU_COUNTRY) {
                     unset($this->questions[$sort]);
                 }
             } else {
                 //ESCORT doNOT have
                 if ($question['name'] == HAMMU_DB_PAYMENT_TYPE_KEY) {
                     unset($this->questions[$sort]);
                 }
             }
             @($this->sortedQuestionsList[] = @$this->questions[$sort]);
         }
     }
     //
     $this->questionValuesList = BOL_QuestionService::getInstance()->findQuestionsValuesByQuestionNameList($questionNameList);
     //        echo '<pre>';
     //        print_r($this->sortedQuestionsList);
     //        echo '</pre>';
     //        echo '<pre>';
     //        print_r($this->questionValuesList);
     //        echo '</pre>';
     //field_538100b702f6e0ff23756c14be12281b
     $this->addFakeQuestions();
     $this->addQuestions($this->sortedQuestionsList, $this->questionValuesList, $this->updateJoinData());
     //        echo '<pre>';
     //        print_r($this->questionListBySection);
     //        echo '</pre>';
     $this->setQuestionsLabel();
     $this->addClassToBaseQuestions();
     if ($this->isLastStep) {
         $this->addLastStepQuestions($controller);
     }
     //  $questionValueList = BOL_QuestionService::getInstance()->findQuestionsValuesByQuestionNameList(array('field_8eb4e427b80ac66d870fc0a5a0cc22ba'));
     //        $new = new Selectbox('field_8eb4e427b80ac66d870fc0a5a0cc22ba');
     //        $new->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('field_8eb4e427b80ac66d870fc0a5a0cc22ba'));
     //        $new->setRequired();
     //
     //        $this->setFieldOptions($new, 'field_8eb4e427b80ac66d870fc0a5a0cc22ba', $questionValueList['field_8eb4e427b80ac66d870fc0a5a0cc22ba']);
     //
     //        if (!empty($joinData['field_8eb4e427b80ac66d870fc0a5a0cc22ba'])) {
     //            $new->setValue($joinData['field_8eb4e427b80ac66d870fc0a5a0cc22ba']);
     //        }
     //
     //        $this->addElement($new);
     $controller->assign('step', $step);
     $controller->assign('questionArray', $this->questionListBySection);
     $controller->assign('displayAccountType', $this->displayAccountType);
     $controller->assign('isLastStep', $this->isLastStep);
 }
Пример #21
0
 public function __construct($controller)
 {
     $this->setId(UTIL_HtmlTag::generateAutoId('form'));
     $this->setMethod(self::METHOD_POST);
     $this->setAjaxResetOnSuccess(true);
     $this->setAjaxDataType(self::AJAX_DATA_TYPE_JSON);
     $this->bindedFunctions = array(self::BIND_SUBMIT => array(), self::BIND_SUCCESS => array());
     $this->setEmptyElementsErrorMessage(OW::getLanguage()->text('base', 'form_validate_common_error_message'));
     $formNameHidden = new HiddenField('form_name');
     $formNameHidden->setValue('joinForm');
     $this->addElement($formNameHidden);
     $this->setName('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 )
               {
               $questionValueList = BOL_QuestionService::getInstance()->findQuestionsValuesByQuestionNameList(array('sex', 'match_sex'));
     
               $sex = new RadioField('sex');
               $sex->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('sex'));
               $sex->setRequired();
     
               $this->setFieldOptions($sex, 'sex', $questionValueList['sex']);
     
               if ( !empty($joinData['sex']) )
               {
               $sex->setValue($joinData['sex']);
               }
     
               $this->addElement($sex);
     
               $matchSex = new RadioField('match_sex');
               $matchSex->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('match_sex'));
               $matchSex->setRequired();
     
               $this->setFieldOptions($matchSex, 'match_sex', $questionValueList['match_sex']);
     
               if ( !empty($joinData['match_sex']) )
               {
               $matchSex->setValue($joinData['match_sex']);
               }
     
               $this->addElement($matchSex);
               } */
     $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);
 }
Пример #22
0
    public function __construct()
    {
        parent::__construct('addToHotListForm');
        $this->setAjax(true);
        $this->setAction(OW::getRouter()->urlFor('HOTLIST_CTRL_Index', 'ajax'));
        $this->setId('addToHotListForm');
        $add_to_list = new HiddenField('add_to_list');
        $add_to_list->setValue(1);
        $this->addElement($add_to_list);
        $submit = new Submit('add');
        $submit->addAttribute('class', 'ow_ic_add');
        $status = BOL_AuthorizationService::getInstance()->getActionStatus('hotlist', 'add_to_list');
        if (isset($status['authorizedBy']) && $status['authorizedBy'] == 'base') {
            $submit->setValue(OW::getLanguage()->text('hotlist', 'yes_btn_label'));
        } else {
            $submit->setValue(OW::getLanguage()->text('hotlist', 'label_add_btn_label'));
        }
        $this->addElement($submit);
        $js = 'owForms["' . $this->getName() . '"].bind("success", function(data){
            if ( data.error != undefined ){
                OW.error(data.error);
            }
            if ( data.message != undefined ){
                OW.info(data.message);
            }

            if ( data.added != undefined && data.added == 1)
            {
                //$("#add_to_list").html("' . OW::getLanguage()->text('hotlist', 'remove_from_hot_list') . '");

                OW.loadComponent("HOTLIST_CMP_Index", {},
                    {
                      onReady: function( html ){
                         $(".ow_box_empty.dashboard-HOTLIST_CMP_IndexWidget").empty().html(html);

                      }
                    });
            }

            hotListFloatBox.close()
        });';
        OW::getDocument()->addOnloadScript($js);
    }
Пример #23
0
 public function __construct($interlocutorId)
 {
     $language = OW::getLanguage();
     parent::__construct('mailbox-create-conversation-form');
     $this->setAction(OW::getRouter()->urlFor('MAILBOX_CTRL_Mailbox', 'sendMessageAjaxResponder', array('userId' => $interlocutorId)));
     $this->setId('mailbox-create-conversation-form');
     $this->setEnctype('multipart/form-data');
     $this->setAjax();
     $this->setAjaxResetOnSuccess(false);
     $hidden = new HiddenField('userId');
     $hidden->setValue($interlocutorId);
     $this->addElement($hidden);
     //thickbox
     $validatorSubject = new StringValidator(0, 2048);
     $validatorSubject->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => 2048)));
     $subject = new TextField('subject');
     $subject->setLabel($language->text('mailbox', 'subject'))->addAttribute('class', 'ow_text');
     $subject->addValidator($validatorSubject);
     $subject->setRequired(true);
     $this->addElement($subject);
     $validatorTextarea = new StringValidator(0, 24000);
     $validatorTextarea->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => 24000)));
     $message = new WysiwygTextarea('message', array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO), false);
     $message->setLabel($language->text('mailbox', 'text'))->addAttribute('class', 'ow_text');
     $message->addAttribute('rows', '10');
     $message->addValidator($validatorTextarea);
     $message->setRequired(true);
     $this->addElement($message);
     if (OW::getConfig()->getValue('mailbox', 'enable_attachments')) {
         $multiUpload = new MAILBOX_CLASS_AjaxFileUpload('attachments');
         $multiUpload->setId('attachments');
         $this->addElement($multiUpload);
     }
     $captcha = new MailboxCaptchaField('captcha');
     $captcha->addValidator(new MailboxCaptchaValidator($captcha->getId()));
     $LastSendStamp = BOL_PreferenceService::getInstance()->getPreferenceValue('mailbox_create_conversation_stamp', OW::getUser()->getId());
     $this->displayCapcha = BOL_PreferenceService::getInstance()->getPreferenceValue('mailbox_create_conversation_display_capcha', OW::getUser()->getId());
     if (!$this->displayCapcha && $LastSendStamp + self::DISPLAY_CAPTCHA_TIMEOUT > time()) {
         BOL_PreferenceService::getInstance()->savePreferenceValue('mailbox_create_conversation_display_capcha', true, OW::getUser()->getId());
         $this->displayCapcha = true;
     }
     $captcha->addAttribute('disabled', 'disabled');
     $this->addElement($captcha);
     $submit = new Submit('send');
     $submit->setValue($language->text('mailbox', 'send_button'));
     $submit->addAttribute('class', 'ow_button ow_ic_mail');
     $this->addElement($submit);
     if (!OW::getRequest()->isAjax()) {
         $messageError = $language->text('mailbox', 'create_conversation_fail_message');
         $messageSuccess = $language->text('mailbox', 'create_conversation_message');
         $js = " owForms['mailbox-create-conversation-form'].bind( 'success',\n            function( json )\n            {\n                var from = \$('#mailbox-create-conversation-form');\n                var captcha = from.find('input[name=captcha]');\n\n                if ( json.result == 'permission_denied' )\n                {\n                    if ( json.message != undefined )\n                    {\n                        OW.error(json.message);\n                    }\n                    else\n                    {\n                        OW.error(" . json_encode(OW::getLanguage()->text('mailbox', 'write_permission_denied')) . ");\n                    }\n                }\n                else if ( json.result == 'display_captcha' )\n            \t{\n                   window." . $captcha->jsObjectName . ".refresh();\n\n                   if ( captcha.attr('disabled') != 'disabled' )\n                   {\n                        owForms['mailbox-create-conversation-form'].getElement('captcha').showError(" . json_encode(OW::getLanguage()->text('base', 'form_validator_captcha_error_message')) . ");\n                   }\n                   else\n                   {\n                        captcha.removeAttr('disabled');\n                   }\n\n                   from.find('tr.captcha').show();\n                   from.find('tr.mailbox_conversation').hide();\n                }\n                else if ( json.result == true )\n            \t{\n            \t    window.mailbox_send_message_floatbox.close();\n                    \$('#attach_file_inputs').hide();\n\n                    captcha.attr('disabled','disabled');\n                    from.find('tr.captcha').hide();\n                    owForms['mailbox-create-conversation-form'].resetForm();\n                    window." . $captcha->jsObjectName . ".refresh();\n\n            \t    OW.info('{$messageSuccess}');\n                    from.find('tr.captcha').hide();\n                    from.find('tr.mailbox_conversation').show();\n                }\n                else\n                {\n                    OW.error('{$messageError}');\n                }\n\n                \$('#mailbox-create-conversation-form input[name=userId]').val(" . $interlocutorId . ");\n\n        \t} ); ";
         OW::getDocument()->addOnloadScript($js);
     }
 }
Пример #24
0
 public function index($params)
 {
     $userId = OW::getUser()->getId();
     if (OW::getRequest()->isAjax()) {
         exit;
     }
     if (!OW::getUser()->isAuthenticated() || $userId === null) {
         throw new AuthenticateException();
     }
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('base', 'preference_index'));
     $this->setPageHeadingIconClass('ow_ic_gear_wheel');
     // -- Preference form --
     $preferenceForm = new Form('preferenceForm');
     $preferenceForm->setId('preferenceForm');
     $preferenceSubmit = new Submit('preferenceSubmit');
     $preferenceSubmit->addAttribute('class', 'ow_button ow_ic_save');
     $preferenceSubmit->setValue($language->text('base', 'preference_submit_button'));
     $preferenceForm->addElement($preferenceSubmit);
     // --
     $sectionList = BOL_PreferenceService::getInstance()->findAllSections();
     $preferenceList = BOL_PreferenceService::getInstance()->findAllPreference();
     $preferenceNameList = array();
     foreach ($preferenceList as $preference) {
         $preferenceNameList[$preference->key] = $preference->key;
     }
     $preferenceValuesList = BOL_PreferenceService::getInstance()->getPreferenceValueListByUserIdList($preferenceNameList, array($userId));
     $formElementEvent = new BASE_CLASS_EventCollector(BOL_PreferenceService::PREFERENCE_ADD_FORM_ELEMENT_EVENT, array('values' => $preferenceValuesList[$userId]));
     OW::getEventManager()->trigger($formElementEvent);
     $data = $formElementEvent->getData();
     $formElements = empty($data) ? array() : call_user_func_array('array_merge', $data);
     $formElementList = array();
     foreach ($formElements as $formElement) {
         /* @var $formElement FormElement */
         $formElementList[$formElement->getName()] = $formElement;
     }
     $resultList = array();
     foreach ($sectionList as $section) {
         foreach ($preferenceList as $preference) {
             if ($preference->sectionName === $section->name && !empty($formElementList[$preference->key])) {
                 $resultList[$section->name][$preference->key] = $preference->key;
                 $element = $formElementList[$preference->key];
                 $preferenceForm->addElement($element);
             }
         }
     }
     if (OW::getRequest()->isPost()) {
         if ($preferenceForm->isValid($_POST)) {
             $values = $preferenceForm->getValues();
             $restul = BOL_PreferenceService::getInstance()->savePreferenceValues($values, $userId);
             if ($restul) {
                 OW::getFeedback()->info($language->text('base', 'preference_preference_data_was_saved'));
             } else {
                 OW::getFeedback()->warning($language->text('base', 'preference_preference_data_not_changed'));
             }
             $this->redirect();
         }
     }
     $this->addForm($preferenceForm);
     $data = array();
     $sectionLabelEvent = new BASE_CLASS_EventCollector(BOL_PreferenceService::PREFERENCE_SECTION_LABEL_EVENT);
     OW::getEventManager()->trigger($sectionLabelEvent);
     $data = $sectionLabelEvent->getData();
     $sectionLabels = empty($data) ? array() : call_user_func_array('array_merge', $data);
     $this->assign('preferenceList', $resultList);
     $this->assign('sectionLabels', $sectionLabels);
 }