Esempio n. 1
0
    public function __construct()
    {
        parent::__construct('hint-form');
        $this->setAjax(TRUE);
        $this->setAction(OW::getRouter()->urlForRoute('profileprogressbar.admin_hint'));
        $this->setAjaxResetOnSuccess(FALSE);
        $this->bindJsFunction('success', 'function(data)
        {
            $("#profile-progressbar").tipTip({content: data.content});

            OW.info("Settings successfully saved");
        }');
        $checkBox = new CheckboxField('show-hint');
        if ((bool) OW::getConfig()->getValue('profileprogressbar', 'show_hint')) {
            $checkBox->addAttribute('checked', 'checked');
        }
        $checkBox->setLabel(OW::getLanguage()->text('profileprogressbar', 'show_hint_label'));
        $checkBox->setDescription(OW::getLanguage()->text('profileprogressbar', 'show_hint_desc'));
        $this->addElement($checkBox);
        $hintText = new WysiwygTextarea('hint-text');
        $hintText->setRequired();
        $hintText->setSize(WysiwygTextarea::SIZE_L);
        $hintText->setValue(OW::getLanguage()->text('profileprogressbar', 'hint_text'));
        $hintText->setLabel(OW::getLanguage()->text('profileprogressbar', 'hint_label'));
        $hintText->setDescription(OW::getLanguage()->text('profileprogressbar', 'hint_desc'));
        $this->addElement($hintText);
        $submit = new Submit('save');
        $submit->setValue('Save');
        $this->addElement($submit);
    }
Esempio n. 2
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);
 }
Esempio n. 3
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");
 }
Esempio n. 4
0
 /**
  * Generates edit topic form.
  *
  * @param $topicDto
  * @param $postDto
  * @param $uid
  * @return Form
  */
 private function generateEditTopicForm($topicDto, $postDto, $uid)
 {
     $form = new Form('edit-topic-form');
     $form->setEnctype('multipart/form-data');
     $lang = OW::getLanguage();
     $topicIdField = new HiddenField('topic-id');
     $topicIdField->setValue($topicDto->id);
     $form->addElement($topicIdField);
     $postIdField = new HiddenField('post-id');
     $postIdField->setValue($postDto->id);
     $form->addElement($postIdField);
     $attachmentUid = new HiddenField('attachmentUid');
     $attachmentUid->setValue($uid);
     $attachmentUid->setRequired(true);
     $form->addElement($attachmentUid);
     $topicTitleField = new TextField('title');
     $topicTitleField->setValue($topicDto->title);
     $topicTitleField->setRequired(true);
     $sValidator = new StringValidator(1, 255);
     $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 255)));
     $topicTitleField->addValidator($sValidator);
     $form->addElement($topicTitleField);
     $btnSet = array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO, BOL_TextFormatService::WS_BTN_HTML);
     $postText = new WysiwygTextarea('text', $btnSet);
     $postText->setValue($postDto->text);
     $postText->setRequired(true);
     $sValidator = new StringValidator(1, 50000);
     $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 50000)));
     $postText->addValidator($sValidator);
     $form->addElement($postText);
     $submit = new Submit('save');
     $submit->setValue($lang->text('base', 'edit_button'));
     $form->addElement($submit);
     return $form;
 }
Esempio n. 5
0
 public function __construct($link)
 {
     parent::__construct('save');
     $language = OW::getLanguage()->getInstance();
     $this->link = $link;
     $urlField = new TextField('url');
     $urlField->setHasInvitation(true)->setInvitation('http://www.example.com');
     $this->addElement($urlField->setRequired(true)->addValidator(new UrlValidator())->setLabel($language->text('links', 'save_form_url_field_label'))->setValue($this->link->getUrl()));
     $titleField = new TextField('title');
     $this->addElement($titleField->setRequired(true)->setLabel($language->text('links', 'save_form_title_field_label'))->setValue($this->link->getTitle()));
     $descriptionTextArea = new WysiwygTextarea('description');
     $descriptionTextArea->setLabel($language->text('links', 'save_form_desc_field_label'));
     $descriptionTextArea->setValue($this->link->getDescription());
     $descriptionTextArea->setRequired(true);
     $this->addElement($descriptionTextArea);
     $tagService = BOL_TagService::getInstance();
     $tags = array();
     if (intval($this->link->getId()) > 0) {
         $arr = $tagService->findEntityTags($this->link->getId(), 'link');
         foreach (!empty($arr) ? $arr : array() as $dto) {
             $tags[] = $dto->getLabel();
         }
     }
     $tagsField = new TagsInputField('tags');
     $tagsField->setLabel($language->text('links', 'save_form_tags_field_label'));
     $tagsField->setValue($tags);
     $tagsField->setDelimiterChars(array('.'));
     $this->addElement($tagsField);
     //        $tagsField = new TagsField('tags', $tags);
     //        $this->addElement($tagsField->setLabel($language->text('links', 'save_form_tags_field_label')));
     $submit = new Submit('submit');
     $this->addElement($submit);
 }