/** * Checks file uploaded size upon user's space left and max upload size * * @deprecated 1.3.0 * * @param array $file $_FILE array * @uses buddydrive_get_user_space_left() to get user's space left * @uses buddydrive_max_upload_size() to get max upload size * @return array $file the $_FILE array with an eventual error */ function buddydrive_check_upload_size($file) { // there's already an error if (!empty($file['error'])) { return $file; } // This codes are restricted to BuddyDrive $buddydrive_errors = array(9 => 1, 10 => 1, 11 => 1); // what's left in user's quota ? $space_left = buddydrive_get_user_space_left('diff'); $file_size = filesize($file['tmp_name']); // File is bigger than space left if ($space_left < $file_size) { $file['error'] = 9; } // File is bigger than the max allowed for BuddyDrive files if ($file_size > buddydrive_max_upload_size(true)) { $file['error'] = 10; } // No more space left if ($space_left <= 0) { $file['error'] = 11; } if (!isset($buddydrive_errors[$file['error']])) { return apply_filters('buddydrive_upload_errors', $file); } return $file; }
/** * Updates the display of the quota of the current user * * @uses buddydrive_get_user_space_left() to get the quota * @return string the quota */ function buddydrive_update_quota() { // Bail if not a POST action if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) { return; } add_filter('buddydrive_get_user_space_left', 'buddydrive_filter_user_space_left', 10, 2); echo buddydrive_get_user_space_left(); remove_filter('buddydrive_get_user_space_left', 'buddydrive_filter_user_space_left', 10, 2); die; }
/** * Outputs the BuddyDrive user's stats. */ function buddydrive_wpadmin_profile_stats($args) { if (empty($args['user_id'])) { return; } $space_left = buddydrive_get_user_space_left(false, $args['user_id']) . '%'; echo '<li class="buddydrive-profile-stats">' . $space_left . '</li>'; }
/** * Displays the row data for our new column * * @since version 1.1 * * @param string $retval * @param string $column_name * @param integer $user_id * @uses buddydrive_get_user_space_left() to calculate the disk usage * @return string the user's drive usage */ public static function user_quota_row($retval = '', $column_name = '', $user_id = 0) { if ('user_quota' === $column_name && !empty($user_id)) { $retval = buddydrive_get_user_space_left(false, $user_id) . '%'; } // Pass retval through return $retval; }