예제 #1
0
function xprofile_insert_field_group($args = '')
{
    $defaults = array('field_group_id' => false, 'name' => false, 'description' => '', 'can_delete' => true);
    $r = nxt_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    if (!$name) {
        return false;
    }
    $field_group = new BP_XProfile_Group($field_group_id);
    $field_group->name = $name;
    $field_group->description = $description;
    $field_group->can_delete = $can_delete;
    return $field_group->save();
}
예제 #2
0
/**
 * Insert a new profile field group
 *
 * @since BuddyPress (1.0.0)
 *
 * @param type $args
 * @return boolean
 */
function xprofile_insert_field_group($args = '')
{
    // Parse the arguments
    $r = bp_parse_args($args, array('field_group_id' => false, 'name' => false, 'description' => '', 'can_delete' => true), 'xprofile_insert_field_group');
    // Bail if no group name
    if (empty($r['name'])) {
        return false;
    }
    // Create new field group object, maybe using an existing ID
    $field_group = new BP_XProfile_Group($r['field_group_id']);
    $field_group->name = $r['name'];
    $field_group->description = $r['description'];
    $field_group->can_delete = $r['can_delete'];
    return $field_group->save();
}
예제 #3
0
function xprofile_admin_manage_group($group_id = null)
{
    global $message, $type;
    $group = new BP_XProfile_Group($group_id);
    if (isset($_POST['save_group'])) {
        if (BP_XProfile_Group::admin_validate($_POST)) {
            $group->name = nxt_filter_kses($_POST['group_name']);
            $group->description = !empty($_POST['group_description']) ? nxt_filter_kses($_POST['group_description']) : '';
            if (!$group->save()) {
                $message = __('There was an error saving the group. Please try again', 'buddypress');
                $type = 'error';
            } else {
                $message = __('The group was saved successfully.', 'buddypress');
                $type = 'success';
                if (1 == $group_id) {
                    bp_update_option('bp-xprofile-base-group-name', $group->name);
                }
                do_action('xprofile_groups_saved_group', $group);
            }
            unset($_GET['mode']);
            xprofile_admin($message, $type);
        } else {
            $group->render_admin_form($message);
        }
    } else {
        $group->render_admin_form();
    }
}
 /**
  * @group save_xprofile_group_name
  */
 public function test_save_xprofile_group_name()
 {
     $g1 = $this->factory->xprofile_group->create(array('name' => "Test ' Name"));
     $e1 = new BP_XProfile_Group($g1);
     $e1->save();
     wp_cache_delete($g1, 'bp_xprofile_groups');
     $e2 = new BP_XProfile_Group($g1);
     $this->assertSame($e1->name, $e2->name);
 }
/**
 * Handles the adding or editing of groups.
 *
 * @param int|null $group_id Group ID to manage.
 */
function xprofile_admin_manage_group($group_id = null)
{
    global $message, $type;
    // Get the field group.
    $group = new BP_XProfile_Group($group_id);
    // Updating.
    if (isset($_POST['save_group'])) {
        // Validate $_POSTed data.
        if (BP_XProfile_Group::admin_validate()) {
            // Set the group name.
            $group->name = $_POST['group_name'];
            // Set the group description.
            if (!empty($_POST['group_description'])) {
                $group->description = $_POST['group_description'];
            } else {
                $group->description = '';
            }
            // Attempt to save the field group.
            if (false === $group->save()) {
                $message = __('There was an error saving the group. Please try again.', 'buddypress');
                $type = 'error';
                // Save successful.
            } else {
                $message = __('The group was saved successfully.', 'buddypress');
                $type = 'success';
                // @todo remove these old options
                if (1 == $group_id) {
                    bp_update_option('bp-xprofile-base-group-name', $group->name);
                }
                /**
                 * Fires at the end of the group adding/saving process, if successful.
                 *
                 * @since 1.0.0
                 *
                 * @param BP_XProfile_Group $group Current BP_XProfile_Group object.
                 */
                do_action('xprofile_groups_saved_group', $group);
            }
            unset($_GET['mode']);
            xprofile_admin($message, $type);
        } else {
            $group->render_admin_form($message);
        }
    } else {
        $group->render_admin_form();
    }
}
예제 #6
0
/**
 * Handles the adding or editing of groups.
 */
function xprofile_admin_manage_group($group_id = null)
{
    global $message, $type;
    $group = new BP_XProfile_Group($group_id);
    if (isset($_POST['save_group'])) {
        if (BP_XProfile_Group::admin_validate($_POST)) {
            $group->name = wp_filter_kses($_POST['group_name']);
            $group->description = !empty($_POST['group_description']) ? wp_filter_kses($_POST['group_description']) : '';
            if (!$group->save()) {
                $message = __('There was an error saving the group. Please try again.', 'buddypress');
                $type = 'error';
            } else {
                $message = __('The group was saved successfully.', 'buddypress');
                $type = 'success';
                if (1 == $group_id) {
                    bp_update_option('bp-xprofile-base-group-name', $group->name);
                }
                /**
                 * Fires at the end of the group adding/saving process, if successful.
                 *
                 * @since BuddyPress (1.0.0)
                 *
                 * @param BP_XProfile_Group $group Current BP_XProfile_Group object.
                 */
                do_action('xprofile_groups_saved_group', $group);
            }
            unset($_GET['mode']);
            xprofile_admin($message, $type);
        } else {
            $group->render_admin_form($message);
        }
    } else {
        $group->render_admin_form();
    }
}