当前位置: 首页>>代码示例>>PHP>>正文


PHP BP_XProfile_Field::admin_validate方法代码示例

本文整理汇总了PHP中BP_XProfile_Field::admin_validate方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_XProfile_Field::admin_validate方法的具体用法?PHP BP_XProfile_Field::admin_validate怎么用?PHP BP_XProfile_Field::admin_validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BP_XProfile_Field的用法示例。


在下文中一共展示了BP_XProfile_Field::admin_validate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_admin_validate_field_options

 /**
  * @group xprofile_field_admin_validate
  */
 public function test_admin_validate_field_options()
 {
     // Mock POST global values
     $_POST['title'] = 'Foo';
     $_POST['required'] = false;
     $_POST['fieldtype'] = 'radio';
     $_POST['radio_option'] = array(1 => '0', 2 => '1', 3 => '4');
     // Validate the mocked POST radio button options
     $result = BP_XProfile_Field::admin_validate();
     // Assert valid
     $this->assertEquals($result, true);
     // cleanup
     unset($_POST['title'], $_POST['required'], $_POST['fieldtype'], $_POST['radio_option']);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:17,代码来源:class-bp-xprofile-field.php

示例2: xprofile_admin_manage_field

function xprofile_admin_manage_field($group_id, $field_id = null)
{
    global $bp, $nxtdb, $message, $groups;
    $field = new BP_XProfile_Field($field_id);
    $field->group_id = $group_id;
    if (isset($_POST['saveField'])) {
        if (BP_XProfile_Field::admin_validate()) {
            $field->name = nxt_filter_kses($_POST['title']);
            $field->description = !empty($_POST['description']) ? nxt_filter_kses($_POST['description']) : '';
            $field->is_required = nxt_filter_kses($_POST['required']);
            $field->type = nxt_filter_kses($_POST['fieldtype']);
            if (!empty($_POST["sort_order_{$field->type}"])) {
                $field->order_by = nxt_filter_kses($_POST["sort_order_{$field->type}"]);
            }
            $field->field_order = $nxtdb->get_var($nxtdb->prepare("SELECT field_order FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id));
            if (!$field->field_order) {
                $field->field_order = (int) $nxtdb->get_var($nxtdb->prepare("SELECT max(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id));
                $field->field_order++;
            }
            if (!$field->save()) {
                $message = __('There was an error saving the field. Please try again', 'buddypress');
                $type = 'error';
                unset($_GET['mode']);
                xprofile_admin($message, $type);
            } else {
                $message = __('The field was saved successfully.', 'buddypress');
                $type = 'success';
                if (1 == $field_id) {
                    bp_update_option('bp-xprofile-fullname-field-name', $field->name);
                }
                unset($_GET['mode']);
                do_action('xprofile_fields_saved_field', $field);
                $groups = BP_XProfile_Group::get();
                xprofile_admin($message, $type);
            }
        } else {
            $field->render_admin_form($message);
        }
    } else {
        $field->render_admin_form();
    }
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:42,代码来源:bp-xprofile-admin.php

示例3: xprofile_admin_manage_field

/**
 * Handles the adding or editing of profile field data for a user.
 */
function xprofile_admin_manage_field($group_id, $field_id = null)
{
    global $bp, $wpdb, $message, $groups;
    $field = new BP_XProfile_Field($field_id);
    $field->group_id = $group_id;
    if (isset($_POST['saveField'])) {
        if (BP_XProfile_Field::admin_validate()) {
            $field->name = wp_filter_kses($_POST['title']);
            $field->description = !empty($_POST['description']) ? wp_filter_kses($_POST['description']) : '';
            $field->is_required = wp_filter_kses($_POST['required']);
            $field->type = wp_filter_kses($_POST['fieldtype']);
            if (!empty($_POST["sort_order_{$field->type}"])) {
                $field->order_by = wp_filter_kses($_POST["sort_order_{$field->type}"]);
            }
            $field->field_order = $wpdb->get_var($wpdb->prepare("SELECT field_order FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id));
            if (!$field->field_order) {
                $field->field_order = (int) $wpdb->get_var($wpdb->prepare("SELECT max(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id));
                $field->field_order++;
            }
            // For new profile fields, set the $field_id. For existing profile fields,
            // this will overwrite $field_id with the same value.
            $field_id = $field->save();
            if (!$field_id) {
                $message = __('There was an error saving the field. Please try again', 'buddypress');
                $type = 'error';
                unset($_GET['mode']);
                xprofile_admin($message, $type);
            } else {
                $message = __('The field was saved successfully.', 'buddypress');
                $type = 'success';
                if (1 == $field_id) {
                    bp_update_option('bp-xprofile-fullname-field-name', $field->name);
                }
                if (!empty($_POST['default-visibility'])) {
                    bp_xprofile_update_field_meta($field_id, 'default_visibility', $_POST['default-visibility']);
                }
                if (!empty($_POST['allow-custom-visibility'])) {
                    bp_xprofile_update_field_meta($field_id, 'allow_custom_visibility', $_POST['allow-custom-visibility']);
                }
                unset($_GET['mode']);
                do_action('xprofile_fields_saved_field', $field);
                $groups = bp_xprofile_get_groups();
                xprofile_admin($message, $type);
            }
        } else {
            $field->render_admin_form($message);
        }
    } else {
        $field->render_admin_form();
    }
}
开发者ID:eresyyl,项目名称:mk,代码行数:54,代码来源:bp-xprofile-admin.php

示例4: bp_xprofile_save_global_field_value

 /**
  * Save the global field value.
  *
  * @since  1.0
  *
  * @param object 	$field
  */
 public function bp_xprofile_save_global_field_value($field)
 {
     if (!empty($_POST['saveField'])) {
         if (BP_XProfile_Field::admin_validate()) {
             $field_id = $field->id;
             if (empty($field_id)) {
                 $field_id = BP_XProfile_Field::get_id_from_name($field->name);
             }
             $this->__update_xprofile_meta($field_id, 'field', 'global_value', $_POST['fieldvalue']);
         }
     }
 }
开发者ID:nightbook,项目名称:buddypress-admin-global-profile-fields,代码行数:19,代码来源:bp-admin-only-profile-fields.php

示例5: xprofile_admin_manage_field

/**
 * Handles the adding or editing of profile field data for a user.
 *
 * @param int      $group_id ID of the group.
 * @param int|null $field_id ID of the field being managed.
 */
function xprofile_admin_manage_field($group_id, $field_id = null)
{
    global $wpdb, $message, $groups;
    $bp = buddypress();
    if (is_null($field_id)) {
        $field = new BP_XProfile_Field();
    } else {
        $field = xprofile_get_field($field_id);
    }
    $field->group_id = $group_id;
    if (isset($_POST['saveField'])) {
        if (BP_XProfile_Field::admin_validate()) {
            $field->is_required = $_POST['required'];
            $field->type = $_POST['fieldtype'];
            $field->name = $_POST['title'];
            if (!empty($_POST['description'])) {
                $field->description = $_POST['description'];
            } else {
                $field->description = '';
            }
            if (!empty($_POST["sort_order_{$field->type}"])) {
                $field->order_by = $_POST["sort_order_{$field->type}"];
            }
            $field->field_order = $wpdb->get_var($wpdb->prepare("SELECT field_order FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id));
            if (empty($field->field_order) || is_wp_error($field->field_order)) {
                $field->field_order = (int) $wpdb->get_var($wpdb->prepare("SELECT max(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id));
                $field->field_order++;
            }
            // For new profile fields, set the $field_id. For existing profile
            // fields, this will overwrite $field_id with the same value.
            $field_id = $field->save();
            if (empty($field_id)) {
                $message = __('There was an error saving the field. Please try again.', 'buddypress');
                $type = 'error';
            } else {
                $message = __('The field was saved successfully.', 'buddypress');
                $type = 'success';
                // @todo remove these old options
                if (1 == $field_id) {
                    bp_update_option('bp-xprofile-fullname-field-name', $field->name);
                }
                // Set member types.
                if (isset($_POST['has-member-types'])) {
                    $member_types = array();
                    if (isset($_POST['member-types'])) {
                        $member_types = stripslashes_deep($_POST['member-types']);
                    }
                    $field->set_member_types($member_types);
                }
                // Validate default visibility.
                if (!empty($_POST['default-visibility']) && in_array($_POST['default-visibility'], wp_list_pluck(bp_xprofile_get_visibility_levels(), 'id'))) {
                    bp_xprofile_update_field_meta($field_id, 'default_visibility', $_POST['default-visibility']);
                }
                // Validate custom visibility.
                if (!empty($_POST['allow-custom-visibility']) && in_array($_POST['allow-custom-visibility'], array('allowed', 'disabled'))) {
                    bp_xprofile_update_field_meta($field_id, 'allow_custom_visibility', $_POST['allow-custom-visibility']);
                }
                // Validate signup.
                if (!empty($_POST['signup-position'])) {
                    bp_xprofile_update_field_meta($field_id, 'signup_position', (int) $_POST['signup-position']);
                } else {
                    bp_xprofile_delete_meta($field_id, 'field', 'signup_position');
                }
                /**
                 * Fires at the end of the process to save a field for a user, if successful.
                 *
                 * @since 1.0.0
                 *
                 * @param BP_XProfile_Field $field Current BP_XProfile_Field object.
                 */
                do_action('xprofile_fields_saved_field', $field);
                $groups = bp_xprofile_get_groups();
            }
            unset($_GET['mode']);
            xprofile_admin($message, $type);
        } else {
            $field->render_admin_form($message);
        }
    } else {
        $field->render_admin_form();
    }
}
开发者ID:boonebgorges,项目名称:BuddyPress-1,代码行数:88,代码来源:bp-xprofile-admin.php

示例6: xprofile_admin_manage_field

function xprofile_admin_manage_field($group_id, $field_id = null)
{
    global $message, $groups;
    $field = new BP_XProfile_Field($field_id);
    $field->group_id = $group_id;
    if (isset($_POST['saveField'])) {
        if (BP_XProfile_Field::admin_validate($_POST)) {
            $field->name = wp_filter_kses($_POST['title']);
            $field->desc = wp_filter_kses($_POST['description']);
            $field->is_required = wp_filter_kses($_POST['required']);
            $field->is_public = wp_filter_kses($_POST['public']);
            $field->type = wp_filter_kses($_POST['fieldtype']);
            $field->order_by = wp_filter_kses($_POST["sort_order_{$field->type}"]);
            if (!$field->save()) {
                $message = __('There was an error saving the field. Please try again', 'buddypress');
                $type = 'error';
                unset($_GET['mode']);
                xprofile_admin($message, $type);
            } else {
                $message = __('The field was saved successfully.', 'buddypress');
                $type = 'success';
                unset($_GET['mode']);
                do_action('xprofile_fields_saved_field', $field);
                $groups = BP_XProfile_Group::get_all();
                xprofile_admin($message, $type);
            }
        } else {
            $field->render_admin_form($message);
        }
    } else {
        $field->render_admin_form();
    }
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:33,代码来源:bp-xprofile-admin.php


注:本文中的BP_XProfile_Field::admin_validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。