示例#1
0
 public function index()
 {
     $language = OW::getLanguage();
     $config = OW::getConfig();
     $form = new Form('privacy_settings');
     $userApprove = new CheckboxField('user_approve');
     $userApprove->setLabel($language->text('admin', 'permissions_index_user_approve'));
     $form->addElement($userApprove);
     $whoCanJoin = new RadioField('who_can_join');
     $whoCanJoin->addOptions(array('1' => $language->text('admin', 'permissions_index_anyone_can_join'), '2' => $language->text('admin', 'permissions_index_by_invitation_only_can_join')));
     $whoCanJoin->setLabel($language->text('admin', 'permissions_index_who_can_join'));
     $form->addElement($whoCanJoin);
     $whoCanInvite = new RadioField('who_can_invite');
     $whoCanInvite->addOptions(array('1' => $language->text('admin', 'permissions_index_all_users_can_invate'), '2' => $language->text('admin', 'permissions_index_admin_only_can_invate')));
     $whoCanInvite->setLabel($language->text('admin', 'permissions_index_who_can_invite'));
     $form->addElement($whoCanInvite);
     $guestsCanView = new RadioField('guests_can_view');
     $guestsCanView->addOptions(array('1' => $language->text('admin', 'permissions_index_yes'), '2' => $language->text('admin', 'permissions_index_no'), '3' => $language->text('admin', 'permissions_index_with_password')));
     $guestsCanView->setLabel($language->text('admin', 'permissions_index_guests_can_view_site'));
     $guestsCanView->setDescription($language->text('admin', 'permissions_idex_if_not_yes_will_override_settings'));
     $form->addElement($guestsCanView);
     $password = new TextField('password');
     $form->addElement($password);
     $submit = new Submit('save');
     $submit->setValue($language->text('admin', 'permissions_index_save'));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $config->saveConfig('base', 'who_can_join', (int) $data['who_can_join']);
             $config->saveConfig('base', 'who_can_invite', (int) $data['who_can_invite']);
             $config->saveConfig('base', 'mandatory_user_approve', (bool) $data['user_approve'] ? 1 : 0);
             if ((int) $data['guests_can_view'] === 3 && empty($data['password'])) {
                 OW::getFeedback()->error($language->text('admin', 'permission_global_privacy_empty_pass_error_message'));
             } else {
                 if ((int) $data['guests_can_view'] === 3 && strlen(trim($data['password'])) < 4) {
                     OW::getFeedback()->error($language->text('admin', 'permission_global_privacy_pass_length_error_message'));
                 } else {
                     $config->saveConfig('base', 'guests_can_view', (int) $data['guests_can_view']);
                     $config->saveConfig('base', 'guests_can_view_password', trim($data['password']));
                 }
             }
             OW::getFeedback()->info($language->text('admin', 'permission_global_privacy_settings_success_message'));
             $this->redirect();
         }
     }
     $baseConfigs = $config->getValues('base');
     $form->getElement('who_can_join')->setValue($baseConfigs['who_can_join']);
     $form->getElement('who_can_invite')->setValue($baseConfigs['who_can_invite']);
     $form->getElement('guests_can_view')->setValue($baseConfigs['guests_can_view']);
     $form->getElement('user_approve')->setValue($baseConfigs['mandatory_user_approve']);
     $form->getElement('password')->setValue($baseConfigs['guests_can_view_password']);
 }
示例#2
0
 /**
  * Class constructor
  *
  */
 public function __construct($maxUploadMaxFilesize)
 {
     parent::__construct('userSettingsForm');
     $this->setEnctype("multipart/form-data");
     $language = OW::getLanguage();
     // avatar size Field
     $avatarSize = new TextField('avatarSize');
     $avatarSize->setRequired(true);
     $validator = new IntValidator(40, 150);
     $validator->setErrorMessage($language->text('admin', 'user_settings_avatar_size_error', array('max' => 150)));
     $avatarSize->addValidator($validator);
     $this->addElement($avatarSize->setLabel($language->text('admin', 'user_settings_avatar_size_label')));
     // big avatar size Field
     $bigAvatarSize = new TextField('bigAvatarSize');
     $bigAvatarSize->setRequired(true);
     $validator = new IntValidator(150, 250);
     $validator->setErrorMessage($language->text('admin', 'user_settings_big_avatar_size_error', array('max' => 250)));
     $bigAvatarSize->addValidator($validator);
     $this->addElement($bigAvatarSize->setLabel($language->text('admin', 'user_settings_big_avatar_size_label')));
     // --- avatar max size
     $maxUploadMaxFilesizeValidator = new FloatValidator(0, $maxUploadMaxFilesize);
     $maxUploadMaxFilesizeValidator->setErrorMessage($language->text('admin', 'settings_max_upload_size_error'));
     $avatarMaxUploadSize = new TextField('avatar_max_upload_size');
     $avatarMaxUploadSize->setLabel($language->text('admin', 'input_settings_avatar_max_upload_size_label'));
     $avatarMaxUploadSize->addValidator($maxUploadMaxFilesizeValidator);
     $this->addElement($avatarMaxUploadSize);
     // --- avatar max size
     if (!defined('OW_PLUGIN_XP')) {
         // confirm Email
         $confirmEmail = new CheckboxField('confirmEmail');
         $confirmEmail->setValue(OW::getConfig()->getValue('base', 'confirm_email'));
         $this->addElement($confirmEmail->setLabel($language->text('admin', 'user_settings_confirm_email')));
     }
     // display name Field
     $displayNameField = new Selectbox('displayName');
     $displayNameField->setRequired(true);
     $questions = array('username' => $language->text('base', 'questions_question_username_label'), 'realname' => $language->text('base', 'questions_question_realname_label'));
     $displayNameField->setHasInvitation(false);
     $displayNameField->setOptions($questions);
     $this->addElement($displayNameField->setLabel($language->text('admin', 'user_settings_display_name')));
     $avatar = new FileField('avatar');
     $this->addElement($avatar);
     $bigAvatar = new FileField('bigAvatar');
     $this->addElement($bigAvatar);
     // --
     $joinConfigField = new Selectbox('join_display_photo_upload');
     $options = array(BOL_UserService::CONFIG_JOIN_DISPLAY_PHOTO_UPLOAD => $language->text('base', 'config_join_display_photo_upload_display_label'), BOL_UserService::CONFIG_JOIN_DISPLAY_AND_SET_REQUIRED_PHOTO_UPLOAD => $language->text('base', 'config_join_display_photo_upload_display_and_require_label'), BOL_UserService::CONFIG_JOIN_NOT_DISPLAY_PHOTO_UPLOAD => $language->text('base', 'config_join_display_photo_upload_not_display_label'));
     $joinConfigField->addOptions($options);
     $joinConfigField->setHasInvitation(false);
     $joinConfigField->setValue(OW::getConfig()->getValue('base', 'join_display_photo_upload'));
     $this->addElement($joinConfigField);
     // --
     $joinConfigField = new CheckboxField('join_display_terms_of_use');
     $joinConfigField->setValue(OW::getConfig()->getValue('base', 'join_display_terms_of_use'));
     $this->addElement($joinConfigField);
     //--- privacy -----///
     $config = OW::getConfig();
     $baseConfigs = $config->getValues('base');
     $userApprove = new CheckboxField('user_approve');
     $userApprove->setLabel($language->text('admin', 'permissions_index_user_approve'));
     $this->addElement($userApprove);
     $whoCanJoin = new RadioField('who_can_join');
     $whoCanJoin->addOptions(array('1' => $language->text('admin', 'permissions_index_anyone_can_join'), '2' => $language->text('admin', 'permissions_index_by_invitation_only_can_join')));
     $whoCanJoin->setLabel($language->text('admin', 'permissions_index_who_can_join'));
     $this->addElement($whoCanJoin);
     $whoCanInvite = new RadioField('who_can_invite');
     $whoCanInvite->addOptions(array('1' => $language->text('admin', 'permissions_index_all_users_can_invate'), '2' => $language->text('admin', 'permissions_index_admin_only_can_invate')));
     $whoCanInvite->setLabel($language->text('admin', 'permissions_index_who_can_invite'));
     $this->addElement($whoCanInvite);
     $guestsCanView = new RadioField('guests_can_view');
     $guestsCanView->addOptions(array('1' => $language->text('admin', 'permissions_index_yes'), '2' => $language->text('admin', 'permissions_index_no'), '3' => $language->text('admin', 'permissions_index_with_password')));
     $guestsCanView->setLabel($language->text('admin', 'permissions_index_guests_can_view_site'));
     $guestsCanView->setDescription($language->text('admin', 'permissions_idex_if_not_yes_will_override_settings'));
     $this->addElement($guestsCanView);
     $password = new TextField('password');
     $password->setHasInvitation(true);
     if ($baseConfigs['guests_can_view'] == 3) {
         $password->setInvitation($language->text('admin', 'change_password'));
     } else {
         $password->setInvitation($language->text('admin', 'add_password'));
     }
     $this->addElement($password);
     // --- //
     //-- profile questions --//
     $userViewPresentationnew = new CheckboxField("user_view_presentation");
     $userViewPresentationnew->setLabel($language->text('base', 'questions_config_user_view_presentation_label'));
     $userViewPresentationnew->setDescription($language->text('base', 'questions_config_user_view_presentation_description'));
     $this->addElement($userViewPresentationnew);
     // --- //
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('admin', 'save_btn_label'));
     $this->addElement($submit);
 }
示例#3
0
 public function index()
 {
     $language = OW::getLanguage();
     $config = OW::getConfig();
     $baseConfigs = $config->getValues('base');
     $form = new Form('privacy_settings');
     $userApprove = new CheckboxField('user_approve');
     $userApprove->setLabel($language->text('admin', 'permissions_index_user_approve'));
     $form->addElement($userApprove);
     $whoCanJoin = new RadioField('who_can_join');
     $whoCanJoin->addOptions(array('1' => $language->text('admin', 'permissions_index_anyone_can_join'), '2' => $language->text('admin', 'permissions_index_by_invitation_only_can_join')));
     $whoCanJoin->setLabel($language->text('admin', 'permissions_index_who_can_join'));
     $form->addElement($whoCanJoin);
     $whoCanInvite = new RadioField('who_can_invite');
     $whoCanInvite->addOptions(array('1' => $language->text('admin', 'permissions_index_all_users_can_invate'), '2' => $language->text('admin', 'permissions_index_admin_only_can_invate')));
     $whoCanInvite->setLabel($language->text('admin', 'permissions_index_who_can_invite'));
     $form->addElement($whoCanInvite);
     $guestsCanView = new RadioField('guests_can_view');
     $guestsCanView->addOptions(array('1' => $language->text('admin', 'permissions_index_yes'), '2' => $language->text('admin', 'permissions_index_no'), '3' => $language->text('admin', 'permissions_index_with_password')));
     $guestsCanView->setLabel($language->text('admin', 'permissions_index_guests_can_view_site'));
     $guestsCanView->setDescription($language->text('admin', 'permissions_idex_if_not_yes_will_override_settings'));
     $form->addElement($guestsCanView);
     $password = new TextField('password');
     $password->setHasInvitation(true);
     if ($baseConfigs['guests_can_view'] == 3) {
         $password->setInvitation($language->text('admin', 'change_password'));
     } else {
         $password->setInvitation($language->text('admin', 'add_password'));
     }
     $form->addElement($password);
     $submit = new Submit('save');
     $submit->setValue($language->text('admin', 'permissions_index_save'));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $config->saveConfig('base', 'who_can_join', (int) $data['who_can_join']);
             $config->saveConfig('base', 'who_can_invite', (int) $data['who_can_invite']);
             $config->saveConfig('base', 'mandatory_user_approve', (bool) $data['user_approve'] ? 1 : 0);
             if ((int) $data['guests_can_view'] === 3 && empty($data['password'])) {
                 OW::getFeedback()->error($language->text('admin', 'permission_global_privacy_empty_pass_error_message'));
                 return;
             } else {
                 if ((int) $data['guests_can_view'] === 3 && strlen(trim($data['password'])) < 4) {
                     OW::getFeedback()->error($language->text('admin', 'permission_global_privacy_pass_length_error_message'));
                     return;
                 } else {
                     $adminEmail = OW::getUser()->getEmail();
                     $senderMail = $config->getValue('base', 'site_email');
                     $mail = OW::getMailer()->createMail();
                     $mail->addRecipientEmail($adminEmail);
                     $mail->setSender($senderMail);
                     $mail->setSenderSuffix(false);
                     $mail->setSubject(OW::getLanguage()->text('admin', 'site_password'));
                     $mail->setTextContent(OW::getLanguage()->text('admin', 'admin_password', array('password' => $data['password'])));
                     try {
                         OW::getMailer()->send($mail);
                     } catch (Exception $e) {
                         $logger = OW::getLogger('admin.send_password_message');
                         $logger->addEntry($e->getMessage());
                         $logger->writeLog();
                     }
                     $data['password'] = crypt($data['password'], OW_PASSWORD_SALT);
                     $config->saveConfig('base', 'guests_can_view', (int) $data['guests_can_view']);
                     $config->saveConfig('base', 'guests_can_view_password', $data['password']);
                 }
             }
             OW::getFeedback()->info($language->text('admin', 'permission_global_privacy_settings_success_message'));
             $this->redirect();
         }
     }
     $baseConfigs = $config->getValues('base');
     $form->getElement('who_can_join')->setValue($baseConfigs['who_can_join']);
     $form->getElement('who_can_invite')->setValue($baseConfigs['who_can_invite']);
     $form->getElement('guests_can_view')->setValue($baseConfigs['guests_can_view']);
     $form->getElement('user_approve')->setValue($baseConfigs['mandatory_user_approve']);
 }