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


PHP bp_core_avatar_handle_upload函数代码示例

本文整理汇总了PHP中bp_core_avatar_handle_upload函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_core_avatar_handle_upload函数的具体用法?PHP bp_core_avatar_handle_upload怎么用?PHP bp_core_avatar_handle_upload使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: xprofile_screen_change_avatar

/**
 * Handles the uploading and cropping of a user avatar. Displays the change avatar page.
 *
 * @package BuddyPress XProfile
 * @uses bp_is_my_profile() Checks to make sure the current user being viewed equals the logged in user
 * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
 */
function xprofile_screen_change_avatar()
{
    global $bp;
    if (!bp_is_my_profile() && !is_super_admin()) {
        return false;
    }
    if (bp_action_variables()) {
        bp_do_404();
        return;
    }
    $bp->avatar_admin->step = 'upload-image';
    if (!empty($_FILES)) {
        // Check the nonce
        check_admin_referer('bp_avatar_upload');
        // Pass the file to the avatar upload handler
        if (bp_core_avatar_handle_upload($_FILES, 'xprofile_avatar_upload_dir')) {
            $bp->avatar_admin->step = 'crop-image';
            // Make sure we include the jQuery jCrop file for image cropping
            add_action('nxt_print_scripts', 'bp_core_add_jquery_cropper');
        }
    }
    // If the image cropping is done, crop the image and save a full/thumb version
    if (isset($_POST['avatar-crop-submit'])) {
        // Check the nonce
        check_admin_referer('bp_avatar_cropstore');
        if (!bp_core_avatar_handle_crop(array('item_id' => $bp->displayed_user->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h']))) {
            bp_core_add_message(__('There was a problem cropping your avatar, please try uploading it again', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('Your new avatar was uploaded successfully!', 'buddypress'));
            do_action('xprofile_avatar_uploaded');
        }
    }
    do_action('xprofile_screen_change_avatar');
    bp_core_load_template(apply_filters('xprofile_template_change_avatar', 'members/single/home'));
}
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:42,代码来源:bp-xprofile-screens.php

示例2: bp_avatar_ajax_upload

/**
 * Ajax upload an avatar.
 *
 * @since 2.3.0
 *
 * @return  string|null A json object containing success data if the upload succeeded
 *                      error message otherwise.
 */
function bp_avatar_ajax_upload()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        wp_die();
    }
    /**
     * Sending the json response will be different if
     * the current Plupload runtime is html4
     */
    $is_html4 = false;
    if (!empty($_POST['html4'])) {
        $is_html4 = true;
    }
    // Check the nonce
    check_admin_referer('bp-uploader');
    // Init the BuddyPress parameters
    $bp_params = array();
    // We need it to carry on
    if (!empty($_POST['bp_params'])) {
        $bp_params = $_POST['bp_params'];
    } else {
        bp_attachments_json_response(false, $is_html4);
    }
    // We need the object to set the uploads dir filter
    if (empty($bp_params['object'])) {
        bp_attachments_json_response(false, $is_html4);
    }
    // Capability check
    if (!bp_attachments_current_user_can('edit_avatar', $bp_params)) {
        bp_attachments_json_response(false, $is_html4);
    }
    $bp = buddypress();
    $bp_params['upload_dir_filter'] = '';
    $needs_reset = array();
    if ('user' === $bp_params['object'] && bp_is_active('xprofile')) {
        $bp_params['upload_dir_filter'] = 'xprofile_avatar_upload_dir';
        if (!bp_displayed_user_id() && !empty($bp_params['item_id'])) {
            $needs_reset = array('key' => 'displayed_user', 'value' => $bp->displayed_user);
            $bp->displayed_user->id = $bp_params['item_id'];
        }
    } elseif ('group' === $bp_params['object'] && bp_is_active('groups')) {
        $bp_params['upload_dir_filter'] = 'groups_avatar_upload_dir';
        if (!bp_get_current_group_id() && !empty($bp_params['item_id'])) {
            $needs_reset = array('component' => 'groups', 'key' => 'current_group', 'value' => $bp->groups->current_group);
            $bp->groups->current_group = groups_get_group(array('group_id' => $bp_params['item_id'], 'populate_extras' => false));
        }
    } else {
        /**
         * Filter here to deal with other components.
         *
         * @since 2.3.0
         *
         * @var array $bp_params the BuddyPress Ajax parameters.
         */
        $bp_params = apply_filters('bp_core_avatar_ajax_upload_params', $bp_params);
    }
    if (!isset($bp->avatar_admin)) {
        $bp->avatar_admin = new stdClass();
    }
    /**
     * The BuddyPress upload parameters is including the Avatar UI Available width,
     * add it to the avatar_admin global for a later use.
     */
    if (isset($bp_params['ui_available_width'])) {
        $bp->avatar_admin->ui_available_width = (int) $bp_params['ui_available_width'];
    }
    // Upload the avatar
    $avatar = bp_core_avatar_handle_upload($_FILES, $bp_params['upload_dir_filter']);
    // Reset objects
    if (!empty($needs_reset)) {
        if (!empty($needs_reset['component'])) {
            $bp->{$needs_reset['component']}->{$needs_reset['key']} = $needs_reset['value'];
        } else {
            $bp->{$needs_reset['key']} = $needs_reset['value'];
        }
    }
    // Init the feedback message
    $feedback_message = false;
    if (!empty($bp->template_message)) {
        $feedback_message = $bp->template_message;
        // Remove template message.
        $bp->template_message = false;
        $bp->template_message_type = false;
        @setcookie('bp-message', false, time() - 1000, COOKIEPATH);
        @setcookie('bp-message-type', false, time() - 1000, COOKIEPATH);
    }
    if (empty($avatar)) {
        // Default upload error
        $message = __('Upload failed.', 'buddypress');
        // Use the template message if set
        if (!empty($feedback_message)) {
//.........这里部分代码省略.........
开发者ID:toby-bushell,项目名称:triumph,代码行数:101,代码来源:bp-core-avatars.php

示例3: xprofile_screen_change_avatar

/**
 * Handles the uploading and cropping of a user avatar. Displays the change avatar page.
 *
 * @package BuddyPress XProfile
 * @uses bp_is_my_profile() Checks to make sure the current user being viewed equals the logged in user
 * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
 */
function xprofile_screen_change_avatar()
{
    // Bail if not the correct screen
    if (!bp_is_my_profile() && !bp_current_user_can('bp_moderate')) {
        return false;
    }
    // Bail if there are action variables
    if (bp_action_variables()) {
        bp_do_404();
        return;
    }
    $bp = buddypress();
    if (!isset($bp->avatar_admin)) {
        $bp->avatar_admin = new stdClass();
    }
    $bp->avatar_admin->step = 'upload-image';
    if (!empty($_FILES)) {
        // Check the nonce
        check_admin_referer('bp_avatar_upload');
        // Pass the file to the avatar upload handler
        if (bp_core_avatar_handle_upload($_FILES, 'xprofile_avatar_upload_dir')) {
            $bp->avatar_admin->step = 'crop-image';
            // Make sure we include the jQuery jCrop file for image cropping
            add_action('wp_print_scripts', 'bp_core_add_jquery_cropper');
        }
    }
    // If the image cropping is done, crop the image and save a full/thumb version
    if (isset($_POST['avatar-crop-submit'])) {
        // Check the nonce
        check_admin_referer('bp_avatar_cropstore');
        $args = array('item_id' => bp_displayed_user_id(), 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h']);
        if (!bp_core_avatar_handle_crop($args)) {
            bp_core_add_message(__('There was a problem cropping your profile photo.', 'buddypress'), 'error');
        } else {
            /**
             * Fires right before the redirect, after processing a new avatar.
             *
             * @since 1.1.0
             * @since 2.3.4 Add two new parameters to inform about the user id and
             *              about the way the avatar was set (eg: 'crop' or 'camera')
             *
             * @param string $item_id Inform about the user id the avatar was set for
             * @param string $value Inform about the way the avatar was set ('crop')
             */
            do_action('xprofile_avatar_uploaded', (int) $args['item_id'], 'crop');
            bp_core_add_message(__('Your new profile photo was uploaded successfully.', 'buddypress'));
            bp_core_redirect(bp_displayed_user_domain());
        }
    }
    /**
     * Fires right before the loading of the XProfile change avatar screen template file.
     *
     * @since BuddyPress (1.0.0)
     */
    do_action('xprofile_screen_change_avatar');
    /**
     * Filters the template to load for the XProfile change avatar screen.
     *
     * @since BuddyPress (1.0.0)
     *
     * @param string $template Path to the XProfile change avatar template to load.
     */
    bp_core_load_template(apply_filters('xprofile_template_change_avatar', 'members/single/home'));
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:71,代码来源:bp-xprofile-screens.php

示例4: groups_screen_group_admin_avatar

/**
 * Handle the display of a group's Change Avatar page.
 */
function groups_screen_group_admin_avatar()
{
    if ('group-avatar' != bp_get_group_current_admin_tab()) {
        return false;
    }
    // If the logged-in user doesn't have permission or if avatar uploads are disabled, then stop here.
    if (!bp_is_item_admin() || bp_disable_group_avatar_uploads() || !buddypress()->avatar->show_avatars) {
        return false;
    }
    $bp = buddypress();
    // If the group admin has deleted the admin avatar.
    if (bp_is_action_variable('delete', 1)) {
        // Check the nonce.
        check_admin_referer('bp_group_avatar_delete');
        if (bp_core_delete_existing_avatar(array('item_id' => $bp->groups->current_group->id, 'object' => 'group'))) {
            bp_core_add_message(__('The group profile photo was deleted successfully!', 'buddypress'));
        } else {
            bp_core_add_message(__('There was a problem deleting the group profile photo. Please try again.', 'buddypress'), 'error');
        }
    }
    if (!isset($bp->avatar_admin)) {
        $bp->avatar_admin = new stdClass();
    }
    $bp->avatar_admin->step = 'upload-image';
    if (!empty($_FILES)) {
        // Check the nonce.
        check_admin_referer('bp_avatar_upload');
        // Pass the file to the avatar upload handler.
        if (bp_core_avatar_handle_upload($_FILES, 'groups_avatar_upload_dir')) {
            $bp->avatar_admin->step = 'crop-image';
            // Make sure we include the jQuery jCrop file for image cropping.
            add_action('wp_print_scripts', 'bp_core_add_jquery_cropper');
        }
    }
    // If the image cropping is done, crop the image and save a full/thumb version.
    if (isset($_POST['avatar-crop-submit'])) {
        // Check the nonce.
        check_admin_referer('bp_avatar_cropstore');
        $args = array('object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h']);
        if (!bp_core_avatar_handle_crop($args)) {
            bp_core_add_message(__('There was a problem cropping the group profile photo.', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('The new group profile photo was uploaded successfully.', 'buddypress'));
        }
    }
    /**
     * Fires before the loading of the group Change Avatar page template.
     *
     * @since 1.0.0
     *
     * @param int $id ID of the group that is being displayed.
     */
    do_action('groups_screen_group_admin_avatar', $bp->groups->current_group->id);
    /**
     * Filters the template to load for a group's Change Avatar page.
     *
     * @since 1.0.0
     *
     * @param string $value Path to a group's Change Avatar template.
     */
    bp_core_load_template(apply_filters('groups_template_group_admin_avatar', 'groups/single/home'));
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:65,代码来源:bp-groups-screens.php

示例5: groups_action_create_group


//.........这里部分代码省略.........
                bp_core_add_message(__('There was an error saving group details, please try again.', 'buddypress'), 'error');
                bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_get_groups_current_create_step() . '/');
            }
            // Set the invite status
            // Checked against a whitelist for security
            $allowed_invite_status = apply_filters('groups_allowed_invite_status', array('members', 'mods', 'admins'));
            $invite_status = !empty($_POST['group-invite-status']) && in_array($_POST['group-invite-status'], (array) $allowed_invite_status) ? $_POST['group-invite-status'] : 'members';
            groups_update_groupmeta($bp->groups->new_group_id, 'invite_status', $invite_status);
        }
        if ('group-invites' === bp_get_groups_current_create_step()) {
            if (!empty($_POST['friends'])) {
                foreach ((array) $_POST['friends'] as $friend) {
                    groups_invite_user(array('user_id' => $friend, 'group_id' => $bp->groups->new_group_id));
                }
            }
            groups_send_invites(bp_loggedin_user_id(), $bp->groups->new_group_id);
        }
        do_action('groups_create_group_step_save_' . bp_get_groups_current_create_step());
        do_action('groups_create_group_step_complete');
        // Mostly for clearing cache on a generic action name
        /**
         * Once we have successfully saved the details for this step of the creation process
         * we need to add the current step to the array of completed steps, then update the cookies
         * holding the information
         */
        $completed_create_steps = isset($bp->groups->completed_create_steps) ? $bp->groups->completed_create_steps : array();
        if (!in_array(bp_get_groups_current_create_step(), $completed_create_steps)) {
            $bp->groups->completed_create_steps[] = bp_get_groups_current_create_step();
        }
        // Reset cookie info
        setcookie('bp_new_group_id', $bp->groups->new_group_id, time() + 60 * 60 * 24, COOKIEPATH);
        setcookie('bp_completed_create_steps', base64_encode(json_encode($bp->groups->completed_create_steps)), time() + 60 * 60 * 24, COOKIEPATH);
        // If we have completed all steps and hit done on the final step we
        // can redirect to the completed group
        $keys = array_keys($bp->groups->group_creation_steps);
        if (count($bp->groups->completed_create_steps) == count($keys) && bp_get_groups_current_create_step() == array_pop($keys)) {
            unset($bp->groups->current_create_step);
            unset($bp->groups->completed_create_steps);
            // Once we compelete all steps, record the group creation in the activity stream.
            groups_record_activity(array('type' => 'created_group', 'item_id' => $bp->groups->new_group_id));
            do_action('groups_group_create_complete', $bp->groups->new_group_id);
            bp_core_redirect(bp_get_group_permalink($bp->groups->current_group));
        } else {
            /**
             * Since we don't know what the next step is going to be (any plugin can insert steps)
             * we need to loop the step array and fetch the next step that way.
             */
            foreach ($keys as $key) {
                if ($key == bp_get_groups_current_create_step()) {
                    $next = 1;
                    continue;
                }
                if (isset($next)) {
                    $next_step = $key;
                    break;
                }
            }
            bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . $next_step . '/');
        }
    }
    // Remove invitations
    if ('group-invites' === bp_get_groups_current_create_step() && !empty($_REQUEST['user_id']) && is_numeric($_REQUEST['user_id'])) {
        if (!check_admin_referer('groups_invite_uninvite_user')) {
            return false;
        }
        $message = __('Invite successfully removed', 'buddypress');
        $error = false;
        if (!groups_uninvite_user((int) $_REQUEST['user_id'], $bp->groups->new_group_id)) {
            $message = __('There was an error removing the invite', 'buddypress');
            $error = 'error';
        }
        bp_core_add_message($message, $error);
        bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/group-invites/');
    }
    // Group avatar is handled separately
    if ('group-avatar' == bp_get_groups_current_create_step() && isset($_POST['upload'])) {
        if (!isset($bp->avatar_admin)) {
            $bp->avatar_admin = new stdClass();
        }
        if (!empty($_FILES) && isset($_POST['upload'])) {
            // Normally we would check a nonce here, but the group save nonce is used instead
            // Pass the file to the avatar upload handler
            if (bp_core_avatar_handle_upload($_FILES, 'groups_avatar_upload_dir')) {
                $bp->avatar_admin->step = 'crop-image';
                // Make sure we include the jQuery jCrop file for image cropping
                add_action('wp_print_scripts', 'bp_core_add_jquery_cropper');
            }
        }
        // If the image cropping is done, crop the image and save a full/thumb version
        if (isset($_POST['avatar-crop-submit']) && isset($_POST['upload'])) {
            // Normally we would check a nonce here, but the group save nonce is used instead
            if (!bp_core_avatar_handle_crop(array('object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h']))) {
                bp_core_add_message(__('There was an error saving the group profile photo, please try uploading again.', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('The group profile photo was uploaded successfully!', 'buddypress'));
            }
        }
    }
    bp_core_load_template(apply_filters('groups_template_create_group', 'groups/create'));
}
开发者ID:eresyyl,项目名称:mk,代码行数:101,代码来源:bp-groups-actions.php

示例6: xprofile_screen_change_avatar

/**
 * Handles the uploading and cropping of a user avatar. Displays the change avatar page.
 *
 * @package BuddyPress XProfile
 * @uses bp_is_my_profile() Checks to make sure the current user being viewed equals the logged in user
 * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
 */
function xprofile_screen_change_avatar()
{
    // Bail if not the correct screen
    if (!bp_is_my_profile() && !bp_current_user_can('bp_moderate')) {
        return false;
    }
    // Bail if there are action variables
    if (bp_action_variables()) {
        bp_do_404();
        return;
    }
    $bp = buddypress();
    if (!isset($bp->avatar_admin)) {
        $bp->avatar_admin = new stdClass();
    }
    $bp->avatar_admin->step = 'upload-image';
    if (!empty($_FILES)) {
        // Check the nonce
        check_admin_referer('bp_avatar_upload');
        // Pass the file to the avatar upload handler
        if (bp_core_avatar_handle_upload($_FILES, 'xprofile_avatar_upload_dir')) {
            $bp->avatar_admin->step = 'crop-image';
            // Make sure we include the jQuery jCrop file for image cropping
            add_action('wp_print_scripts', 'bp_core_add_jquery_cropper');
        }
    }
    // If the image cropping is done, crop the image and save a full/thumb version
    if (isset($_POST['avatar-crop-submit'])) {
        // Check the nonce
        check_admin_referer('bp_avatar_cropstore');
        $args = array('item_id' => bp_displayed_user_id(), 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h']);
        if (!bp_core_avatar_handle_crop($args)) {
            bp_core_add_message(__('There was a problem cropping your profile photo.', 'buddypress'), 'error');
        } else {
            do_action('xprofile_avatar_uploaded');
            bp_core_add_message(__('Your new profile photo was uploaded successfully.', 'buddypress'));
            bp_core_redirect(bp_displayed_user_domain());
        }
    }
    do_action('xprofile_screen_change_avatar');
    bp_core_load_template(apply_filters('xprofile_template_change_avatar', 'members/single/home'));
}
开发者ID:eresyyl,项目名称:mk,代码行数:49,代码来源:bp-xprofile-screens.php

示例7: rtmedia_api_process_update_avatar_request

 function rtmedia_api_process_update_avatar_request()
 {
     $this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
     $ec_no_file = 130001;
     $msg_no_file = __('no file', 'rtmedia');
     $ec_invalid_image = 130002;
     $msg_invalid_image = __('upload failed, check size and file type', 'rtmedia');
     $ec_avatar_updated = 130003;
     $msg_avatar_updated = __('avatar updated', 'rtmedia');
     extract($_POST);
     if (empty($_FILES['file'])) {
         echo $this->rtmedia_api_response_object('FALSE', $ec_no_file, $msg_no_file);
         exit;
     }
     $uploaded = bp_core_avatar_handle_upload($_FILES, 'xprofile_avatar_upload_dir');
     if (!$uploaded) {
         echo $this->rtmedia_api_response_object('FALSE', $ec_invalid_image, $msg_invalid_image);
         exit;
     } else {
         echo $this->rtmedia_api_response_object('TRUE', $ec_avatar_updated, $msg_avatar_updated);
         exit;
     }
 }
开发者ID:paulmedwal,项目名称:edxforumspublic,代码行数:23,代码来源:RTMediaJsonApi.php

示例8: groups_screen_group_admin_avatar

function groups_screen_group_admin_avatar()
{
    global $bp;
    if (bp_is_groups_component() && bp_is_action_variable('group-avatar', 0)) {
        // If the logged-in user doesn't have permission or if avatar uploads are disabled, then stop here
        if (!$bp->is_item_admin || (int) bp_get_option('bp-disable-avatar-uploads')) {
            return false;
        }
        // If the group admin has deleted the admin avatar
        if (bp_is_action_variable('delete', 1)) {
            // Check the nonce
            check_admin_referer('bp_group_avatar_delete');
            if (bp_core_delete_existing_avatar(array('item_id' => $bp->groups->current_group->id, 'object' => 'group'))) {
                bp_core_add_message(__('Your avatar was deleted successfully!', 'buddypress'));
            } else {
                bp_core_add_message(__('There was a problem deleting that avatar, please try again.', 'buddypress'), 'error');
            }
        }
        $bp->avatar_admin->step = 'upload-image';
        if (!empty($_FILES)) {
            // Check the nonce
            check_admin_referer('bp_avatar_upload');
            // Pass the file to the avatar upload handler
            if (bp_core_avatar_handle_upload($_FILES, 'groups_avatar_upload_dir')) {
                $bp->avatar_admin->step = 'crop-image';
                // Make sure we include the jQuery jCrop file for image cropping
                add_action('wp_print_scripts', 'bp_core_add_jquery_cropper');
            }
        }
        // If the image cropping is done, crop the image and save a full/thumb version
        if (isset($_POST['avatar-crop-submit'])) {
            // Check the nonce
            check_admin_referer('bp_avatar_cropstore');
            if (!bp_core_avatar_handle_crop(array('object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h']))) {
                bp_core_add_message(__('There was a problem cropping the avatar, please try uploading it again', 'buddypress'));
            } else {
                bp_core_add_message(__('The new group avatar was uploaded successfully!', 'buddypress'));
            }
        }
        do_action('groups_screen_group_admin_avatar', $bp->groups->current_group->id);
        bp_core_load_template(apply_filters('groups_template_group_admin_avatar', 'groups/single/home'));
    }
}
开发者ID:newington,项目名称:buddypress,代码行数:43,代码来源:bp-groups-screens.php

示例9: groups_action_create_group


//.........这里部分代码省略.........
			} else {
				/* Create the forum if enable_forum = 1 */
				if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $bp->groups->new_group_id, 'forum_id' ) ) {
					groups_new_group_forum();
				}
			}

			if ( 'private' == $_POST['group-status'] )
				$group_status = 'private';
			else if ( 'hidden' == $_POST['group-status'] )
				$group_status = 'hidden';

			if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_forum' => $group_enable_forum ) ) ) {
				bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
				bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step . '/' );
			}
		}

		if ( 'group-invites' == $bp->groups->current_create_step ) {
			groups_send_invites( $bp->loggedin_user->id, $bp->groups->new_group_id );
		}

		do_action( 'groups_create_group_step_save_' . $bp->groups->current_create_step );
		do_action( 'groups_create_group_step_complete' ); // Mostly for clearing cache on a generic action name

		/**
		 * Once we have successfully saved the details for this step of the creation process
		 * we need to add the current step to the array of completed steps, then update the cookies
		 * holding the information
		 */
		if ( !in_array( $bp->groups->current_create_step, (array)$bp->groups->completed_create_steps ) )
			$bp->groups->completed_create_steps[] = $bp->groups->current_create_step;

		/* Reset cookie info */
		setcookie( 'bp_new_group_id', $bp->groups->new_group_id, time()+60*60*24, COOKIEPATH );
		setcookie( 'bp_completed_create_steps', serialize( $bp->groups->completed_create_steps ), time()+60*60*24, COOKIEPATH );

		/* If we have completed all steps and hit done on the final step we can redirect to the completed group */
		if ( count( $bp->groups->completed_create_steps ) == count( $bp->groups->group_creation_steps ) && $bp->groups->current_create_step == array_pop( array_keys( $bp->groups->group_creation_steps ) ) ) {
			unset( $bp->groups->current_create_step );
			unset( $bp->groups->completed_create_steps );

			/* Once we compelete all steps, record the group creation in the activity stream. */
			groups_record_activity( array(
				'action' => apply_filters( 'groups_activity_created_group_action', sprintf( __( '%s created the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' ) ),
				'type' => 'created_group',
				'item_id' => $bp->groups->new_group_id
			) );

			do_action( 'groups_group_create_complete', $bp->groups->new_group_id );

			bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
		} else {
			/**
			 * Since we don't know what the next step is going to be (any plugin can insert steps)
			 * we need to loop the step array and fetch the next step that way.
			 */
			foreach ( (array)$bp->groups->group_creation_steps as $key => $value ) {
				if ( $key == $bp->groups->current_create_step ) {
					$next = 1;
					continue;
				}

				if ( $next ) {
					$next_step = $key;
					break;
				}
			}

			bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $next_step . '/' );
		}
	}

	/* Group avatar is handled separately */
	if ( 'group-avatar' == $bp->groups->current_create_step && isset( $_POST['upload'] ) ) {
		if ( !empty( $_FILES ) && isset( $_POST['upload'] ) ) {
			/* Normally we would check a nonce here, but the group save nonce is used instead */

			/* Pass the file to the avatar upload handler */
			if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {
				$bp->avatar_admin->step = 'crop-image';

				/* Make sure we include the jQuery jCrop file for image cropping */
				add_action( 'wp', 'bp_core_add_jquery_cropper' );
			}
		}

		/* If the image cropping is done, crop the image and save a full/thumb version */
		if ( isset( $_POST['avatar-crop-submit'] ) && isset( $_POST['upload'] ) ) {
			/* Normally we would check a nonce here, but the group save nonce is used instead */

			if ( !bp_core_avatar_handle_crop( array( 'object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
				bp_core_add_message( __( 'There was an error saving the group avatar, please try uploading again.', 'buddypress' ), 'error' );
			else
				bp_core_add_message( __( 'The group avatar was uploaded successfully!', 'buddypress' ) );
		}
	}

 	bp_core_load_template( apply_filters( 'groups_template_create_group', 'groups/create' ) );
}
开发者ID:n-sane,项目名称:zaroka,代码行数:101,代码来源:bp-groups.php

示例10: bp_core_screen_signup


//.........这里部分代码省略.........
				add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo "<div class=\"error\">' . $error_message . '</div>";' ) );
		} else {
			$bp->signup->step = 'save-details';

			/* No errors! Let's register those deets. */
			$active_signup = $bp->site_options['registration'];

			if ( 'none' != $active_signup ) {

				/* Let's compact any profile field info into usermeta */
				$profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );

				/* Loop through the posted fields formatting any datebox values then add to usermeta */
				foreach ( (array) $profile_field_ids as $field_id ) {
					if ( !isset( $_POST['field_' . $field_id] ) ) {
						if ( isset( $_POST['field_' . $field_id . '_day'] ) )
							$_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] );
					}

					if ( !empty( $_POST['field_' . $field_id] ) )
						$usermeta['field_' . $field_id] = $_POST['field_' . $field_id];
				}

				/* Store the profile field ID's in usermeta */
				$usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids'];

				/* Hash and store the password */
				$usermeta['password'] = wp_hash_password( $_POST['signup_password'] );

				/* If the user decided to create a blog, save those details to usermeta */
				if ( 'blog' == $active_signup || 'all' == $active_signup ) {
					$usermeta['public'] = ( 'public' == $_POST['signup_blog_privacy'] ) ? true : false;
				}

				$usermeta = apply_filters( 'bp_signup_usermeta', $usermeta );

				/* Finally, sign up the user and/or blog */
				if ( isset( $_POST['signup_with_blog'] ) && bp_core_is_multisite() )
					bp_core_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta );
				else {
					bp_core_signup_user( $_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta );
				}

				$bp->signup->step = 'completed-confirmation';
			}

			do_action( 'bp_complete_signup' );
		}

	}

	$bp->avatar_admin->step = 'upload-image';

	/* If user has uploaded a new avatar */
	if ( !empty( $_FILES ) ) {

		/* Check the nonce */
		check_admin_referer( 'bp_avatar_upload' );

		$bp->signup->step = 'completed-confirmation';

		if ( bp_core_is_multisite() ) {
			/* Get the activation key */
			if ( !$bp->signup->key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $_POST[ 'signup_username' ], $_POST[ 'signup_email' ] ) ) ) {
				bp_core_add_message( __( 'There was a problem uploading your avatar, please try uploading it again', 'buddypress' ) );
			} else {
				/* Hash the key to create the upload folder (added security so people don't sniff the activation key) */
				$bp->signup->avatar_dir = wp_hash( $bp->signup->key );
			}
		} else {
			$user_id = bp_core_get_userid( $_POST['signup_username'] );
			$bp->signup->avatar_dir = wp_hash( $user_id );
		}

		/* Pass the file to the avatar upload handler */
		if ( bp_core_avatar_handle_upload( $_FILES, 'bp_core_signup_avatar_upload_dir' ) ) {
			$bp->avatar_admin->step = 'crop-image';

			/* Make sure we include the jQuery jCrop file for image cropping */
			add_action( 'wp', 'bp_core_add_jquery_cropper' );
		}
	}

	/* If the image cropping is done, crop the image and save a full/thumb version */
	if ( isset( $_POST['avatar-crop-submit'] ) ) {

		/* Check the nonce */
		check_admin_referer( 'bp_avatar_cropstore' );

		/* Reset the avatar step so we can show the upload form again if needed */
		$bp->signup->step = 'completed-confirmation';
		$bp->avatar_admin->step = 'upload-image';

		if ( !bp_core_avatar_handle_crop( array( 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
			bp_core_add_message( __( 'There was a problem cropping your avatar, please try uploading it again', 'buddypress' ), 'error' );
		else
			bp_core_add_message( __( 'Your new avatar was uploaded successfully', 'buddypress' ) );
	}
	bp_core_load_template( 'registration/register' );
}
开发者ID:n-sane,项目名称:zaroka,代码行数:101,代码来源:bp-core-signup.php

示例11: bcp_cover_photo_screen

/**
 * cover photo subnav callback function. renders the title content and the template
 * files that are needed to process the upload and cropping of the photo
 * 
 * @author dunhakdis<codehaiku.io@gmail.com>
 * @package bp-cover-photo
 * @since 1.0
 * @return void
 */
function bcp_cover_photo_screen()
{
    // store buddypress object to $bp
    // same as global $bp;
    $bp = buddypress();
    // template directory
    $template = 'members';
    // filter function for uploading images
    $upload_filter = 'xprofile_avatar_upload_dir';
    // the id of the user
    $item_id = bp_displayed_user_id();
    if (bp_is_group_single()) {
        $template = 'groups';
        $upload_filter = 'groups_avatar_upload_dir';
        $item_id = $bp->groups->current_group->id;
    }
    // load jcrop
    add_action('wp_enqueue_scripts', 'bp_cover_photo_scripts');
    //add title and content here - last is to call the members plugin.php template
    add_action('bp_template_title', 'bp_cover_photo_screen_title');
    add_action('bp_template_content', 'bp_cover_photo_screen_content');
    // handle uploading of cover photo
    if (!empty($_FILES)) {
        // Check the nonce
        check_admin_referer('bp_avatar_upload');
        // create avatar_admin object to prevent notices
        // from empty variables and objects
        if (!isset($bp->avatar_admin)) {
            $bp->avatar_admin = new stdClass();
        }
        // Pass the file to the avatar upload handler
        $bp = buddypress();
        if (bp_core_avatar_handle_upload($_FILES, $upload_filter)) {
            // adjust current step
            $bp->avatar_admin->step = 'crop-image';
        }
    }
    // If the image cropping is done, crop the image and save a full/thumb version
    if (isset($_POST['avatar-crop-submit'])) {
        // Check the nonce
        check_admin_referer('bp_avatar_cropstore');
        $groups_slug = bcp_get_groups_slug();
        $args = array('item_id' => $item_id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h']);
        // change avatar path for groups
        if (bp_is_group_single()) {
            $args['avatar_dir'] = 'group-avatars';
        }
        if (!bcp_core_avatar_handle_crop($args)) {
            bp_core_add_message(__('There was a problem cropping your cover photo.', 'buddypress'), 'error');
        } else {
            // update the default cover photo image for groups
            if (isset($_POST['global-coverphoto'])) {
                $type = wp_kses($_POST['global-coverphoto'], array());
                $args = array('object_id' => $item_id, 'type' => $type);
                $new_cover_photo = bcp_fetch_cover_photo($args);
                update_option('__bcp_default_' . $type . '_cover_photo', $new_cover_photo['full']);
            }
            if (bp_is_group_single()) {
                // if its a single group
                // redirect to group home page
                $current_displayed_group_url = trailingslashit(get_bloginfo('url') . '/' . $groups_slug . '/' . $bp->groups->current_group->slug . '/');
                groups_update_groupmeta($item_id, 'cover-photo-timestamp', md5(time()));
                bp_core_redirect($current_displayed_group_url);
            } else {
                //otherwise, redirect to members profile
                update_user_meta($item_id, 'cover-photo-timestamp', md5(time()));
                bp_core_redirect(bp_displayed_user_domain());
            }
            bp_core_add_message(__('Your new cover photo was uploaded successfully.', 'buddypress'));
        }
    }
    bp_core_load_template(apply_filters('bp_core_template_plugin', $template . '/single/plugins'));
    return;
}
开发者ID:poweronio,项目名称:mbsite,代码行数:83,代码来源:index.php

示例12: bfox_bp_plans_update_plan_avatar

function bfox_bp_plans_update_plan_avatar(BfoxReadingPlan $plan, $is_create = false)
{
    global $bp;
    bfox_bp_plans_must_own($plan);
    if (!$is_create) {
        /* If the group admin has deleted the admin avatar */
        if ('delete' == $bp->action_variables[0]) {
            /* Check the nonce */
            check_admin_referer('bfox_bp_plan_avatar_delete');
            if (bp_core_delete_existing_avatar(array('item_id' => $plan->id, 'object' => 'plan'))) {
                bp_core_add_message(__('Your avatar was deleted successfully!', 'buddypress'));
            } else {
                bp_core_add_message(__('There was a problem deleting that avatar, please try again.', 'buddypress'), 'error');
            }
            bp_core_redirect($plan->url() . 'avatar/');
        }
    }
    $bp->avatar_admin->step = 'upload-image';
    if (!empty($_FILES) && isset($_POST['upload'])) {
        if ($is_create) {
            check_admin_referer('plans_create_save_plan-avatar');
        } else {
            check_admin_referer('bp_avatar_upload');
        }
        /* Pass the file to the avatar upload handler */
        if (bp_core_avatar_handle_upload($_FILES, 'bfox_bp_plans_avatar_upload_dir')) {
            $bp->avatar_admin->step = 'crop-image';
            /* Make sure we include the jQuery jCrop file for image cropping */
            add_action('wp', 'bp_core_add_jquery_cropper');
        }
    }
    /* If the image cropping is done, crop the image and save a full/thumb version */
    if (isset($_POST['avatar-crop-submit'])) {
        if ($is_create) {
            check_admin_referer('plans_create_save_plan-avatar');
        } else {
            check_admin_referer('bp_avatar_cropstore');
        }
        if (!bp_core_avatar_handle_crop(array('object' => 'plan', 'avatar_dir' => 'plan-avatars', 'item_id' => $plan->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h']))) {
            bp_core_add_message(__('There was a problem cropping the avatar, please try uploading it again', 'buddypress'));
        } else {
            bp_core_add_message(__('The new reading plan avatar was uploaded successfully!', 'buddypress'));
        }
    }
}
开发者ID:jeffryevans,项目名称:biblefox-wp,代码行数:45,代码来源:plans-directory.php

示例13: bp_links_screen_link_admin_avatar

/**
 * Load Link home page edit avatar template, handle form if submitted
 */
function bp_links_screen_link_admin_avatar()
{
    global $bp;
    if (!$bp->is_item_admin || 'link-avatar' != bp_links_admin_current_action_variable()) {
        return false;
    }
    // handle empty avatar admin property
    if (false === isset($bp->avatar_admin)) {
        $bp->avatar_admin = new stdClass();
    }
    // If the link admin has deleted the admin avatar
    if ('delete' == $bp->action_variables[1]) {
        /* Check the nonce */
        check_admin_referer('bp_link_avatar_delete');
        if (bp_core_delete_existing_avatar(array('item_id' => $bp->links->current_link->id, 'object' => 'link', 'avatar_dir' => 'link-avatars'))) {
            bp_core_add_message(__('Your avatar was deleted successfully!', 'buddypress-links'));
        } else {
            bp_core_add_message(sprintf('%s %s', __('There was a problem deleting that avatar', 'buddypress-links'), __('Please try again.', 'buddypress-links')), 'error');
        }
    }
    $bp->avatar_admin->step = 'upload-image';
    if (isset($_POST['avatar-crop-submit'])) {
        // Check the nonce
        check_admin_referer('bp_avatar_cropstore');
        // received crop coords, crop the image and save a full/thumb version
        if (bp_core_avatar_handle_crop(array('object' => 'link', 'avatar_dir' => 'link-avatars', 'item_id' => $bp->links->current_link->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h']))) {
            bp_links_embed_handle_crop($bp->links->current_link);
            bp_core_add_message(__('The link avatar was uploaded successfully!', 'buddypress-links'));
        } else {
            bp_core_add_message(sprintf('%s %s', __('There was an error saving link avatar.', 'buddypress-links'), __('Please try again.', 'buddypress-links')), 'error');
        }
    } elseif (isset($_POST['upload']) || isset($_POST['embed-submit'])) {
        // Check the nonce
        check_admin_referer('bp_avatar_upload');
        // handle image uploading
        if (!empty($_POST['embed-submit']) && bp_links_embed_handle_upload($bp->links->current_link, $_POST['embed-html'])) {
            // we are good to crop
            $bp->avatar_admin->step = 'crop-image';
            // Make sure we include the jQuery jCrop file for image cropping
            add_action('wp_enqueue_scripts', 'bp_core_add_jquery_cropper');
        } elseif (isset($_POST['upload']) && !empty($_FILES)) {
            // Pass the file to the avatar upload handler
            if (bp_core_avatar_handle_upload($_FILES, 'bp_links_avatar_upload_dir')) {
                // we are good to crop
                $bp->avatar_admin->step = 'crop-image';
                // Make sure we include the jQuery jCrop file for image cropping
                add_action('wp_enqueue_scripts', 'bp_core_add_jquery_cropper');
            }
        }
    }
    do_action('bp_links_screen_link_admin_avatar', $bp->links->current_link->id);
    bp_links_load_template('single/home');
}
开发者ID:OxBEEF,项目名称:merge-server,代码行数:56,代码来源:bp-links-core.php


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