private function build_form()
    {
        $form = new HTMLForm(__CLASS__);
        //Configuration
        $fieldset = new FormFieldsetHTML('configuration_fieldset', LangLoader::get_message('configuration', 'admin-common'));
        $form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldNumberEditor('items_number_per_page', $this->lang['calendar.config.items_number_per_page'], $this->config->get_items_number_per_page(), array('min' => 1, 'max' => 50, 'required' => true), array(new FormFieldConstraintIntegerRange(1, 50))));
        $fieldset->add_field(new FormFieldCheckbox('comments_enabled', LangLoader::get_message('config.comments_enabled', 'admin-common'), $this->config->are_comments_enabled()));
        $fieldset->add_field(new FormFieldColorPicker('event_color', $this->lang['calendar.config.event_color'], $this->config->get_event_color(), array(), array(new FormFieldConstraintRegex('`^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$`i'))));
        $fieldset->add_field(new FormFieldCheckbox('members_birthday_enabled', $this->lang['calendar.config.members_birthday_enabled'], $this->config->is_members_birthday_enabled(), array('events' => array('click' => '
				if (HTMLForms.getField("members_birthday_enabled").getValue()) {
					HTMLForms.getField("birthday_color").enable();
				} else {
					HTMLForms.getField("birthday_color").disable();
				}'))));
        $user_born_field = ExtendedFieldsCache::load()->get_extended_field_by_field_name('user_born');
        if (!empty($user_born_field) && !$user_born_field['display']) {
            $fieldset->add_field(new FormFieldHTML('user_born_disabled_msg', MessageHelper::display($this->lang['calendar.error.e_user_born_field_disabled'], MessageHelper::WARNING)->render()));
        }
        $fieldset->add_field(new FormFieldColorPicker('birthday_color', $this->lang['calendar.config.birthday_color'], $this->config->get_birthday_color(), array('hidden' => !$this->config->is_members_birthday_enabled()), array(new FormFieldConstraintRegex('`^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$`i'))));
        $common_lang = LangLoader::get('common');
        $fieldset = new FormFieldsetHTML('authorizations_fieldset', $common_lang['authorizations'], array('description' => LangLoader::get_message('config.authorizations.explain', 'admin-common')));
        $form->add_fieldset($fieldset);
        $auth_settings = new AuthorizationsSettings(array(new ActionAuthorization($common_lang['authorizations.read'], Category::READ_AUTHORIZATIONS), new ActionAuthorization($common_lang['authorizations.write'], Category::WRITE_AUTHORIZATIONS), new ActionAuthorization($common_lang['authorizations.contribution'], Category::CONTRIBUTION_AUTHORIZATIONS), new ActionAuthorization($common_lang['authorizations.moderation'], Category::MODERATION_AUTHORIZATIONS)));
        $auth_setter = new FormFieldAuthorizationsSetter('authorizations', $auth_settings);
        $auth_settings->build_from_auth_array($this->config->get_authorizations());
        $fieldset->add_field($auth_setter);
        //Submit and reset buttons
        $this->submit_button = new FormButtonDefaultSubmit();
        $form->add_button($this->submit_button);
        $form->add_button(new FormButtonReset());
        $this->form = $form;
    }
    public function execute(HTTPRequestCustom $request)
    {
        $id = $request->get_getint('id');
        $this->init();
        $extended_field = new ExtendedField();
        $extended_field->set_id($id);
        $exist_field = ExtendedFieldsDatabaseService::check_field_exist_by_id($extended_field);
        if ($exist_field) {
            $this->extended_field = ExtendedFieldsCache::load()->get_extended_field($id);
            $this->build_form($request);
        } else {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
        $this->tpl = new StringTemplate('# INCLUDE MSG #
				# INCLUDE FORM #
				<script>
				jQuery(document).ready(function() {
				' . $this->get_events_select_type() . '});
				</script>');
        $this->tpl->add_lang($this->lang);
        $this->tpl->put_all(array('FIELD_TYPE' => $this->extended_field['field_type']));
        if ($this->submit_button->has_been_submited() && $this->form->validate()) {
            $extended_field = $this->save($id);
            $error = ExtendedFieldsService::get_error();
            if (!empty($error)) {
                $this->tpl->put('MSG', MessageHelper::display($error, MessageHelper::ERROR, 5));
            } else {
                AppContext::get_response()->redirect($this->form->get_value('referrer') ? $this->form->get_value('referrer') : AdminExtendedFieldsUrlBuilder::fields_list(), StringVars::replace_vars($this->lang['message.success.edit'], array('name' => $extended_field->get_name())));
            }
        }
        $this->tpl->put('FORM', $this->form->display());
        return new AdminExtendedFieldsDisplayResponse($this->tpl, $this->lang['extended-field-edit']);
    }
 private function update_fields($request)
 {
     if ($request->get_value('submit', false)) {
         $this->update_position($request);
         ExtendedFieldsCache::invalidate();
         $this->view->put('MSG', MessageHelper::display(LangLoader::get_message('message.success.position.update', 'status-messages-common'), MessageHelper::SUCCESS, 5));
     }
 }
 public function execute(HTTPRequestCustom $request)
 {
     $id = $request->get_int('id', 0);
     $display = $request->get_bool('display', true);
     if ($id !== 0) {
         PersistenceContext::get_querier()->update(DB_TABLE_MEMBER_EXTENDED_FIELDS_LIST, array('display' => (int) $display), 'WHERE id = :id', array('id' => $id));
         ExtendedFieldsCache::invalidate();
     }
     return new JSONResponse(array('id' => $id, 'display' => (int) $display));
 }
Example #5
0
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 ###################################################*/
require_once '../kernel/begin.php';
require_once '../forum/forum_begin.php';
require_once '../forum/forum_tools.php';
$Bread_crumb->add($config->get_forum_name(), 'index.php');
define('TITLE', $LANG['title_forum']);
require_once '../kernel/header.php';
$view_msg = retrieve(GET, 'id', 0);
if (!empty($view_msg)) {
    $_NBR_ELEMENTS_PER_PAGE = 10;
    $ranks_cache = ForumRanksCache::load()->get_ranks();
    //Récupère les rangs en cache.
    $extended_fields_cache = ExtendedFieldsCache::load();
    $displayed_extended_fields = $extended_fields_cache->get_websites_or_emails_extended_field_field_types();
    $extended_fields_to_recover_list = '';
    foreach ($displayed_extended_fields as $field_type) {
        $extended_fields_to_recover_list .= 'ext_field.' . $field_type . ', ';
    }
    $tpl = new FileTemplate('forum/forum_membermsg.tpl');
    $authorized_categories = ForumService::get_authorized_categories(Category::ROOT_CATEGORY);
    $row = PersistenceContext::get_querier()->select_single_row_query("SELECT COUNT(*) as nbr_msg\n\tFROM " . PREFIX . "forum_msg msg\n\tLEFT JOIN " . PREFIX . "forum_topics t ON msg.idtopic = t.id\n\tWHERE msg.user_id = :user_id AND t.idcat IN :authorized_categories", array('authorized_categories' => $authorized_categories, 'user_id' => $view_msg));
    $nbr_msg = $row['nbr_msg'];
    $page = AppContext::get_request()->get_getint('p', 1);
    $pagination = new ModulePagination($page, $nbr_msg, $_NBR_ELEMENTS_PER_PAGE, Pagination::LIGHT_PAGINATION);
    $pagination->set_url(new Url('/forum/membermsg.php?id=' . $view_msg . '&amp;p=%d'));
    if ($pagination->current_page_is_empty() && $page > 1) {
        $error_controller = PHPBoostErrors::unexisting_page();
        DispatchManager::redirect($error_controller);
 /**
  * @desc This private function display form create
  * @param object $member_extended_field MemberExtendedField
  */
 private function display_create_form(FormFieldset $fieldset)
 {
     $extended_fields_cache = ExtendedFieldsCache::load()->get_extended_fields();
     foreach ($extended_fields_cache as $id => $extended_field) {
         if ($extended_field['display'] == 1 && AppContext::get_current_user()->check_auth($extended_field['auth'], ExtendedField::READ_EDIT_AND_ADD_AUTHORIZATION)) {
             $extended_field['value'] = '';
             $member_extended_field = new MemberExtendedField();
             $member_extended_field->set_fieldset($fieldset);
             $member_extended_field->set_properties($extended_field);
             $member_extended_field->get_instance()->display_field_create($member_extended_field);
         }
     }
 }
Example #7
0
 $user_id_dest = $convers['user_id_dest'] == $current_user->get_id() ? $convers['user_id'] : $convers['user_id_dest'];
 if ($convers['user_convers_status'] == '0' && $user_id_dest > '0') {
     //Vu par exp et pas par dest  => 1
     //Vu par dest et pas par exp  => 2
     if ($convers['user_id'] == $current_user->get_id()) {
         //Le membre est le créateur de la conversation.
         $status = 1;
     } elseif ($convers['user_id_dest'] == $current_user->get_id()) {
         //Le membre est le destinataire de la conversation.
         $status = 2;
     }
     $contents = FormatingHelper::strparse($contents, array(), false);
     //Envoi du message privé.
     $pm_msg_id = PrivateMsg::send($user_id_dest, $pm_id_get, $contents, $current_user->get_id(), $status);
     //Envoi d'un mail si l'utilisateur a activé l'option
     $pmtomail_field = ExtendedFieldsCache::load()->get_extended_field_by_field_name('user_pmtomail');
     if (!empty($pmtomail_field) && $pmtomail_field['display']) {
         if (PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER_EXTENDED_FIELDS, 'user_pmtomail', 'WHERE user_id = :id', array('id' => $user_id_dest))) {
             $email_dest = PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER, 'email', 'WHERE user_id = :id', array('id' => $user_id_dest));
             AppContext::get_mail_service()->send_from_properties($email_dest, $LANG['new_pm'] . ' : ' . $convers['title'], $contents);
         }
     }
     //Calcul de la page vers laquelle on redirige.
     $last_page = ceil(($convers['nbr_msg'] + 1) / 25);
     $last_page_rewrite = $last_page > 1 ? '-' . $last_page : '';
     $last_page = $last_page > 1 ? '&p=' . $last_page : '';
     AppContext::get_response()->redirect('/user/pm' . url('.php?id=' . $pm_id_get . $last_page, '-0-' . $pm_id_get . $last_page_rewrite . '.php', '&') . '#m' . $pm_msg_id);
 } else {
     //Le destinataire a supprimé la conversation.
     AppContext::get_response()->redirect('/user/pm' . url('.php?id=' . $pm_id_get . '&error=e_pm_del', '-0-' . $pm_id_get . '-0.php?error=e_pm_del', '&') . '#message_helper');
 }
 /**
  * @desc Delete a extended field for field name
  * @param string $field_name the field name of the extended field
  */
 public static function delete_by_field_name($field_name)
 {
     if (!empty($field_name)) {
         $extended_field = new ExtendedField();
         $extended_field->set_field_name($field_name);
         if (ExtendedFieldsDatabaseService::check_field_exist_by_field_name($extended_field)) {
             $data = self::data_field($extended_field, self::SORT_BY_FIELD_NAME);
             $class = $data->get_instance();
             if (!$class->get_field_used_phpboost_configuration() || !$data->get_is_freeze()) {
                 ExtendedFieldsDatabaseService::delete_extended_field($data);
                 ExtendedFieldsCache::invalidate();
             }
         }
     }
 }