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


PHP mpp_get_current_component函数代码示例

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


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

示例1: mpp_shortcode_uploader

function mpp_shortcode_uploader($atts = array(), $content = '')
{
    $default = array('gallery_id' => 0, 'component' => mpp_get_current_component(), 'component_id' => mpp_get_current_component_id(), 'type' => '', 'status' => mpp_get_default_status(), 'view' => '', 'selected' => 0, 'label_empty' => __('Please select a gallery', 'mediapress'), 'show_error' => 1);
    $atts = shortcode_atts($default, $atts);
    //dropdown list of galleries to sllow userselect one
    $view = 'list';
    if (!empty($atts['gallery_id']) && is_numeric($atts['gallery_id'])) {
        $view = 'single';
        //single gallery uploader
        //override component and $component id
        $gallery = mpp_get_gallery($atts['gallery_id']);
        if (!$gallery) {
            return __('Nonexistent gallery should not be used', 'mediapress');
        }
        //reset
        $atts['component'] = $gallery->component;
        $atts['component_id'] = $gallery->component_id;
        $atts['type'] = $gallery->type;
    }
    //the user must be able to upload to current component or galler
    $can_upload = false;
    if (mpp_user_can_upload($atts['component'], $atts['component_id'], $atts['gallery_id'])) {
        $can_upload = true;
    }
    if (!$can_upload && $atts['show_error']) {
        return __('Sorry, you are not allowed to upload here.', 'mediapress');
    }
    //if we are here, the user can upload
    //we still have one issue, what if the user has not created any gallery and the admin intends to allow the user to upload to their created gallery
    $atts['context'] = 'shortcode';
    //from where it is being uploaded,
    $atts['view'] = $view;
    //passing the 2nd arg makes all these variables available to the loaded file
    mpp_get_template('shortcodes/uploader.php', $atts);
}
开发者ID:Kemitestech,项目名称:WordPress-Skeleton,代码行数:35,代码来源:mpp-shortcode-media-uploader.php

示例2: mpp_get_all_media_ids

function mpp_get_all_media_ids($args = null)
{
    $component = mpp_get_current_component();
    $component_id = mpp_get_current_component_id();
    $default = array('gallery_id' => mpp_get_current_gallery_id(), 'component' => $component, 'component_id' => $component_id, 'per_page' => -1, 'status' => mpp_get_accessible_statuses($component, $component_id, get_current_user_id()), 'nopaging' => true, 'fields' => 'ids');
    $args = wp_parse_args($args, $default);
    $ids = new MPP_Media_Query($args);
    return $ids->get_ids();
}
开发者ID:baden03,项目名称:mediapress,代码行数:9,代码来源:functions.php

示例3: mpp_get_current_user_access_permissions

/**
 * Get an array of all the permissions available to the current user for the gallery
 * 
 * 
 * @param type $component_type
 * @param type $component_id
 * @param type $gallery_id
 * @return type
 * @deprecated 1.0beta1
 * @see mpp_get_accessible_statuses()
 * 
 */
function mpp_get_current_user_access_permissions($component_type = false, $component_id = false, $gallery_id = false)
{
    if (!$component_type) {
        $component_type = mpp_get_current_component();
    }
    if (!$component_id) {
        $component_id = mpp_get_current_component_id();
    }
    return apply_filters("mpp_get_current_user_" . strtolower($component_type) . "_gallery_access", array('public'), $component_id, $gallery_id);
}
开发者ID:markc,项目名称:mediapress,代码行数:22,代码来源:deprecated.php

示例4: mpp_filter_body_class

function mpp_filter_body_class($classes, $class)
{
    $new_classes = array();
    $component = mpp_get_current_component();
    //if not mediapress pages, return
    if (!mpp_is_gallery_component() && !mpp_is_component_gallery()) {
        return $classes;
    }
    //ok, It must be mpp pages
    $new_classes[] = 'mpp-page';
    //for all mediapress pages
    //if it is a directory page
    if (mpp_is_gallery_directory()) {
        $new_classes[] = 'mpp-page-directory';
    } elseif (mpp_is_gallery_component() || mpp_is_component_gallery()) {
        //we are on user gallery  page or a component gallery page
        //append class mpp-page-members or mpp-page-groups or mpp-page-events etc depending on the current associated component
        $new_classes[] = 'mpp-page-' . $component;
        if (mpp_is_media_management()) {
            //is it edit media?
            $new_classes[] = 'mpp-page-media-management';
            $new_classes[] = 'mpp-page-media-management-' . mpp_get_media_type();
            //mpp-photo-management, mpp-audio-management
            $new_classes[] = 'mpp-page-media-manage-action-' . mediapress()->get_edit_action();
            //mpp-photo-management, mpp-audio-management
        } elseif (mpp_is_single_media()) {
            //is it single media
            $new_classes[] = 'mpp-page-media-single';
            $new_classes[] = 'mpp-page-media-single-' . mpp_get_media_type();
        } elseif (mpp_is_gallery_management()) {
            //id gallery management?
            $new_classes[] = 'mpp-page-gallery-management';
            $new_classes[] = 'mpp-page-gallery-management-' . mpp_get_gallery_type();
            $new_classes[] = 'mpp-page-gallery-manage-action-' . mediapress()->get_edit_action();
        } elseif (mpp_is_single_gallery()) {
            //is singe gallery
            $new_classes[] = 'mpp-page-single-gallery';
            $new_classes[] = 'mpp-page-single-gallery-' . mpp_get_gallery_type();
            $new_classes[] = 'mpp-page-single-gallery-' . mpp_get_gallery_status();
        } else {
            //it is the gallery listing page of the component
            $new_classes[] = 'mpp-page-gallery-list';
            //home could have been a better name
            $new_classes[] = 'mpp-page-gallery-list-' . $component;
            //home could have been a better name
        }
    }
    if (!empty($new_classes)) {
        $classes = array_merge($classes, $new_classes);
    }
    return $classes;
}
开发者ID:baden03,项目名称:mediapress,代码行数:52,代码来源:hooks.php

示例5: defult_settings

 public function defult_settings()
 {
     global $wp_scripts;
     $data = $wp_scripts->get_data('mpp_uploader', 'data');
     if ($data && false !== strpos($data, '_mppUploadSettings')) {
         return;
     }
     $max_upload_size = wp_max_upload_size();
     $defaults = array('runtimes' => 'html5,silverlight,flash,html4', 'file_data_name' => '_mpp_file', 'multiple_queues' => true, 'max_file_size' => $max_upload_size . 'b', 'url' => admin_url('admin-ajax.php'), 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'filters' => array(array('title' => __('Allowed Files'), 'extensions' => '*')), 'multipart' => true, 'urlstream_upload' => true);
     // Multi-file uploading doesn't currently work in iOS Safari,
     // single-file allows the built-in camera to be used as source for images
     if (wp_is_mobile()) {
         $defaults['multi_selection'] = false;
     }
     $defaults = apply_filters('mpp_upload_default_settings', $defaults);
     $params = array('action' => 'mpp_add_media', '_wpnonce' => wp_create_nonce('mpp_add_media'), 'component' => mpp_get_current_component(), 'component_id' => mpp_get_current_component_id(), 'context' => 'gallery');
     $params = apply_filters('mpp_plupload_default_params', $params);
     // $params['_wpnonce'] = wp_create_nonce( 'media-form' );
     $defaults['multipart_params'] = $params;
     $settings = array('defaults' => $defaults, 'browser' => array('mobile' => wp_is_mobile(), 'supported' => _device_can_upload()), 'limitExceeded' => false);
     $script = 'var _mppUploadSettings = ' . json_encode($settings) . ';';
     if ($data) {
         $script = "{$data}\n{$script}";
     }
     $wp_scripts->add_data('mpp_uploader', 'data', $script);
 }
开发者ID:markc,项目名称:mediapress,代码行数:26,代码来源:mpp-script-loader.php

示例6: mpp_get_adjacent_object_id

function mpp_get_adjacent_object_id($args, $post_type)
{
    global $wpdb;
    $post_type_sql = '';
    $sql = array();
    $default = array('component' => '', 'component_id' => false, 'status' => mpp_get_accessible_statuses(mpp_get_current_component(), mpp_get_current_component_id()), 'type' => '', 'post_status' => 'any', 'next' => true, 'object_id' => '', 'object_parent' => 0);
    if ($post_type == mpp_get_gallery_post_type()) {
        $default['post_status'] = 'publish';
        //for gallery, the default post type should be published status
    }
    //if component is set to user, we can simply avoid component query
    //may be next iteration someday
    $args = wp_parse_args($args, $default);
    extract($args);
    //whether we are looking for next post or previous post
    if ($next) {
        $op = '>';
    } else {
        $op = '<';
    }
    //do we have a component set
    if ($component) {
        $sql[] = mpp_get_tax_sql($component, mpp_get_component_taxname());
    }
    //do we have a component set
    if ($status) {
        $sql[] = mpp_get_tax_sql($status, mpp_get_status_taxname());
    }
    //for type, repeat it
    if ($type) {
        $sql[] = mpp_get_tax_sql($type, mpp_get_type_taxname());
    }
    //so let us build one
    /* $term_object_sql = "SELECT object_id FROM (
    	  (SELECT DISTINCT value FROM table_a)
    	  UNION ALL
    	  (SELECT DISTINCT value FROM table_b)
    	  ) AS t1 GROUP BY value HAVING count(*) >= 2; */
    $post_type_sql = $wpdb->prepare("SELECT DISTINCT ID as object_id FROM {$wpdb->posts} WHERE post_type = %s ", $post_type);
    //if a user or group id is given
    if ($component_id) {
        $post_type_sql = $wpdb->prepare("SELECT DISTINCT p.ID  as object_id FROM {$wpdb->posts} AS p INNER JOIN {$wpdb->postmeta} AS pm ON p.ID = pm.post_id WHERE p.post_type= %s  AND pm.meta_key=%s and pm.meta_value=%d", $post_type, '_mpp_component_id', $component_id);
    }
    $post_status_sql = '';
    if ($post_status && $post_status != 'any') {
        $post_status_sql = $wpdb->prepare(" AND post_status =%s", $post_status);
    }
    //$sql[] = $post_type_sql;
    $new_sql = $join_sql = '';
    //array();
    //let us generate inner sub queries
    if ($sql) {
        $join_sql = ' (' . join(' AND object_id IN (', $sql);
    }
    //we need to append the ) for closing the sub queries
    for ($i = 0; $i < count($sql); $i++) {
        $join_sql .= ')';
    }
    $new_sql = $post_type_sql . $post_status_sql;
    //if the join sql is present, let us append it
    if ($join_sql) {
        $new_sql .= ' AND ID IN ' . $join_sql;
    }
    //for next/prev
    //sorted gallery
    //or by date
    //
    $post = get_post($object_id);
    $sorted = false;
    if ($object_parent && mpp_is_gallery_sorted($object_parent)) {
        $new_sql .= $wpdb->prepare(" AND p.menu_order {$op} %d ", $post->menu_order);
        $sorted = true;
    } else {
        $new_sql .= $wpdb->prepare(" AND p.ID {$op} %d ", $object_id);
        $sorted = false;
    }
    if ($object_parent) {
        $new_sql .= $wpdb->prepare(" AND post_parent = %d ", $object_parent);
    }
    $oreder_by_clause = '';
    if ($sorted) {
        $oreder_by_clause = " ORDER BY p.menu_order ";
    } else {
        $oreder_by_clause = "ORDER BY p.ID";
    }
    if (!$next) {
        //for previous
        //find the last element les than give
        $oreder_by_clause .= " DESC ";
    } else {
        $oreder_by_clause .= " ASC";
    }
    if (!empty($new_sql)) {
        $new_sql .= $oreder_by_clause . ' LIMIT 0, 1';
    }
    return $wpdb->get_var($new_sql);
}
开发者ID:markc,项目名称:mediapress,代码行数:97,代码来源:mpp-misc-functions.php

示例7: mpp_display_space_usage

function mpp_display_space_usage($component = null, $component_id = null)
{
    if (!mpp_get_option('show_upload_quota')) {
        return;
    }
    if (!$component) {
        $component = mpp_get_current_component();
    }
    if (!$component_id) {
        $component_id = mpp_get_current_component_id();
    }
    $total_space = mpp_get_allowed_space($component, $component_id);
    $used = mpp_get_used_space($component, $component_id);
    if ($used > $total_space) {
        $percentused = '100';
    } else {
        $percentused = $used / $total_space * 100;
    }
    if ($total_space > 1000) {
        $total_space = number_format($total_space / 1024);
        $total_space .= __('GB');
    } else {
        $total_space .= __('MB');
    }
    ?>
	<strong><?php 
    printf(__('You have <span> %1s%%</span> of your %2s space left', 'mediapress'), number_format(100 - $percentused), $total_space);
    ?>
</strong>
	<?php 
}
开发者ID:baden03,项目名称:mediapress,代码行数:31,代码来源:space-stats.php

示例8:

<?php

// Exit if the file is accessed directly over web
if (!defined('ABSPATH')) {
    exit;
}
/**
 * Create Gallery shortcode
 * You can overwide it in yourtheme/mediapress/default/shortcodes/create-gallery.php
 * 
 */
?>
<div id="mpp-create-gallery-form-wrapper" class="mpp-container" >
	
	<?php 
if (mpp_user_can_create_gallery(mpp_get_current_component(), mpp_get_current_component_id())) {
    ?>

		<form method="post" action="" id="mpp-create-gallery-form" class="mpp-form mpp-form-stacked mpp-create-gallery-form">
			<?php 
    $title = $description = $status = $type = $component = '';
    if (!empty($_POST['mpp-gallery-title'])) {
        $title = $_POST['mpp-gallery-title'];
    }
    if (!empty($_POST['mpp-gallery-description'])) {
        $description = $_POST['mpp-gallery-description'];
    }
    if (!empty($_POST['mpp-gallery-status'])) {
        $status = $_POST['mpp-gallery-status'];
    }
    if (!empty($_POST['mpp-gallery-type'])) {
开发者ID:markc,项目名称:mediapress,代码行数:31,代码来源:create-gallery.php

示例9: mpp_gallery_create_button

/**
 * Display a create Gallery Button
 * 
 * @return string
 */
function mpp_gallery_create_button()
{
    //check whether to display the link or not
    $component = mpp_get_current_component();
    $component_id = mpp_get_current_component_id();
    if (!mpp_user_can_create_gallery($component, $component_id)) {
        return false;
    }
    ?>
    <a id="add_new_gallery_link" href="<?php 
    mpp_gallery_create_url($component, $component_id);
    ?>
">Add Gallery</a>
    <?php 
}
开发者ID:baden03,项目名称:mediapress,代码行数:20,代码来源:link-template.php

示例10: mpp_record_activity

/**
 * Record Media Activity
 * 
 * It does not actually records activity, simply simulates the activity update and rest are done by the actions.php functions
 * 
 * It will be removed in future for a better record_activity method
 * @param type $args
 * @return boolean
 */
function mpp_record_activity($args = null)
{
    //if activity module is not active, why bother
    if (!bp_is_active('activity')) {
        return false;
    }
    $default = array('gallery_id' => 0, 'media_id' => 0, 'media_ids' => null, 'action' => '', 'content' => '', 'type' => '', 'component' => mpp_get_current_component(), 'component_id' => mpp_get_current_component_id(), 'user_id' => get_current_user_id(), 'status' => '');
    $args = wp_parse_args($args, $default);
    //atleast a gallery id or a media id should be given
    if (!$args['gallery_id'] && !$args['media_id'] || !mpp_is_active_component($args['component']) || !$args['component_id']) {
        return false;
    }
    $gallery_id = absint($args['gallery_id']);
    $media_id = absint($args['media_id']);
    $type = $args['type'];
    //should we validate type too?
    $hide_sitewide = 0;
    $status_object = null;
    if ($args['status']) {
        $status_object = mpp_get_status_object($args['status']);
        if ($status_object && ($status_object->activity_privacy == 'hidden' || $status_object->activity_privacy == 'onlyme')) {
            $hide_sitewide = 1;
        }
    }
    $media_ids = $args['media_ids'];
    if (!empty($media_ids) && !is_array($media_ids)) {
        $media_ids = explode(',', $media_ids);
    }
    $component = $args['component'];
    if ($component == buddypress()->members->id) {
        $component = buddypress()->activity->id;
        //for user gallery updates, let it be simple activity , do not set the component to 'members'
    }
    $activity_id = bp_activity_add(array('id' => false, 'user_id' => $args['user_id'], 'action' => $args['action'], 'content' => $args['content'], 'component' => $component, 'type' => 'mpp_media_upload', 'item_id' => absint($args['component_id']), 'secondary_item_id' => false, 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => $hide_sitewide));
    if (!$activity_id) {
        return false;
        //there was a problem
    }
    //store the type of gallery activity in meta
    if ($type) {
        mpp_activity_update_activity_type($activity_id, $type);
    }
    if ($media_ids) {
        $media_ids = wp_parse_id_list($media_ids);
        mpp_activity_update_attached_media_ids($activity_id, $media_ids);
    }
    if ($gallery_id) {
        mpp_activity_update_gallery_id($activity_id, $gallery_id);
    }
    if ($media_id) {
        mpp_activity_update_media_id($activity_id, $media_id);
    }
    mpp_activity_update_context($activity_id, 'gallery');
    //save activity privacy
    if ($status_object) {
        bp_activity_update_meta($activity_id, 'activity-privacy', $status_object->activity_privacy);
    }
    return $activity_id;
}
开发者ID:markc,项目名称:mediapress,代码行数:68,代码来源:mpp-activity-functions.php

示例11: mpp_activity_upload_buttons

/**
 * Add various upload icons to activity post form
 * @return type
 */
function mpp_activity_upload_buttons()
{
    if (!mpp_is_activity_upload_enabled(mpp_get_current_component())) {
        return;
    }
    //if we are here, the gallery activity stream upload is enabled,
    //let us see if we are on user profile and gallery is enabled
    if (bp_is_user() && !mpp_is_active_component('members')) {
        return;
    }
    //if we are on group page and either the group component is not enabled or gallery is not enabled for current group, do not show the icons
    if (function_exists('bp_is_group') && bp_is_group() && (!mpp_is_active_component('groups') || !(function_exists('mpp_group_is_gallery_enabled') && mpp_group_is_gallery_enabled()))) {
        return;
    }
    //for now, avoid showing it on single gallery/media activity stream
    if (mpp_is_single_gallery() || mpp_is_single_media()) {
        return;
    }
    $component = mpp_get_current_component();
    ?>
    <div id="mpp-activity-upload-buttons" class="mpp-upload-buttons">
        <?php 
    do_action("mpp_before_activity_upload_buttons");
    //allow to add more type
    ?>
        
    <?php 
    if (mpp_is_active_type('photo') && mpp_component_supports_type($component, 'photo')) {
        ?>
        <a href="#" id="mpp-photo-upload" data-media-type="photo"><img src="<?php 
        echo mediapress()->get_url() . 'assets/images/media-button-image.gif';
        ?>
"/></a>
     <?php 
    }
    ?>
        
    <?php 
    if (mpp_is_active_type('audio') && mpp_component_supports_type($component, 'audio')) {
        ?>
        <a href="#" id="mpp-audio-upload" data-media-type="audio"><img src="<?php 
        echo mediapress()->get_url() . 'assets/images/media-button-music.gif';
        ?>
"/></a>
     <?php 
    }
    ?>

     <?php 
    if (mpp_is_active_type('video') && mpp_component_supports_type($component, 'video')) {
        ?>
        <a href="#" id="mpp-video-upload"  data-media-type="video"><img src="<?php 
        echo mediapress()->get_url() . 'assets/images/media-button-video.gif';
        ?>
"/></a>
    <?php 
    }
    ?>
		
     <?php 
    if (mpp_is_active_type('doc') && mpp_component_supports_type($component, 'doc')) {
        ?>
        <a href="#" id="mpp-doc-upload"  data-media-type="doc"><img src="<?php 
        echo mediapress()->get_url() . 'assets/images/media-button-doc.png';
        ?>
" /></a>
    <?php 
    }
    ?>
		
    <?php 
    //someone please provide me doc icon and some better icons
    ?>
 
    
	<?php 
    do_action('mpp_after_activity_upload_buttons');
    //allow to add more type
    ?>

    </div>
  <?php 
}
开发者ID:markc,项目名称:mediapress,代码行数:87,代码来源:mpp-activity-template.php

示例12: mpp_action_create_gallery

/**
 * Handles Gallery creation on the front end in non ajax case
 * 
 * @return type
 */
function mpp_action_create_gallery()
{
    //allow gallery to be created from anywhere
    //the form must have mpp-action set and It should be set to 'create-gallery'
    if (empty($_POST['mpp-action']) || $_POST['mpp-action'] != 'create-gallery') {
        return;
    }
    $referer = wp_get_referer();
    //if we are here, It is gallery create action
    if (!wp_verify_nonce($_POST['mpp-nonce'], 'mpp-create-gallery')) {
        //add error message and return back to the old page
        mpp_add_feedback(__('Action not authorized!', 'mediapress'), 'error');
        if ($referer) {
            mpp_redirect($referer);
        }
        return;
    }
    //update it to allow passing component/id from the form
    $component = mpp_get_current_component();
    $component_id = mpp_get_current_component_id();
    //check for permission
    //we may want to allow passing of component from the form in future!
    if (!mpp_user_can_create_gallery($component, $component_id)) {
        mpp_add_feedback(__("You don't have permission to create gallery!", 'mediapress'), 'error');
        if ($referer) {
            mpp_redirect($referer);
        }
        return;
    }
    //if we are here, validate the data and let us see if we can create
    $title = $_POST['mpp-gallery-title'];
    $description = $_POST['mpp-gallery-description'];
    $type = $_POST['mpp-gallery-type'];
    $status = $_POST['mpp-gallery-status'];
    $errors = array();
    if (!mpp_is_active_status($status)) {
        $errors['status'] = __('Invalid Gallery status!', 'mediapress');
    }
    if (!mpp_is_active_type($type)) {
        $errors['type'] = __('Invalid gallery type!', 'mediapress');
    }
    //check for current component
    if (!mpp_is_active_component($component)) {
        $errors['component'] = __('Invalid gallery component!', 'mediapress');
    }
    if (empty($title)) {
        $errors['title'] = __('Title can not be empty', 'mediapress');
    }
    //give opportunity to other plugins to add their own validation errors
    $validation_errors = apply_filters('mpp-create-gallery-field-validation', $errors, $_POST);
    if (!empty($validation_errors)) {
        //let us add the validation error and return back to the earlier page
        $message = join('\\r\\n', $validation_errors);
        mpp_add_feedback($message, 'error');
        if ($referer) {
            mpp_redirect($referer);
        }
        return;
    }
    //let us create gallery
    $gallery_id = mpp_create_gallery(array('title' => $title, 'description' => $description, 'type' => $type, 'status' => $status, 'creator_id' => get_current_user_id(), 'component' => $component, 'component_id' => $component_id));
    if (!$gallery_id) {
        mpp_add_feedback(__('Unable to create gallery!', 'mediapress'), 'error');
        if ($referer) {
            mpp_redirect($referer);
        }
        return;
    }
    //if we are here, the gallery was created successfully,
    //let us redirect to the gallery_slug/manage/upload page
    $redirect_url = mpp_get_gallery_add_media_url($gallery_id);
    mpp_add_feedback(__('Gallery created successfully!', 'mediapress'));
    mpp_redirect($redirect_url);
}
开发者ID:baden03,项目名称:mediapress,代码行数:79,代码来源:actions.php

示例13: mpp_group_filter_gallery_query

/**
 * Filter Main MPp Gallery Query to add support for "my-gallery" view on group component
 * @param type $args
 * @return type
 */
function mpp_group_filter_gallery_query($args)
{
    if (mpp_group_is_my_galleries_enabled() && bp_is_active('groups') && bp_is_group() && mpp_is_enabled(mpp_get_current_component(), mpp_get_current_component_id())) {
        //check if the current av0 is 'my-gallery';
        if (is_user_logged_in() && bp_is_action_variable('my-gallery', 0)) {
            $args['user_id'] = bp_loggedin_user_id();
        }
    }
    return $args;
}
开发者ID:Kemitestech,项目名称:WordPress-Skeleton,代码行数:15,代码来源:mpp-bp-groups-hooks.php

示例14: add_oembed_media

 /**
  * Not used, Oembed support is not yet available in 1.0 branch
  */
 public function add_oembed_media()
 {
     check_ajax_referer('mpp_add_media');
     //check for the referrer
     $media_type = '';
     $gallery_id = '';
     $component = $_POST['component'];
     $component_id = $_POST['component_id'];
     $context = mpp_get_upload_context(false, $_POST['context']);
     if (!$component) {
         $component = mpp_get_current_component();
     }
     if (!$component_id) {
         $component_id = mpp_get_current_component_id();
     }
     //get the uploader
     $uploader = mpp_get_storage_manager('oembed');
     //should we pass the component?
     //setup for component
     //$uploader->setup_for( $component, $component_id );
     //check if the server can handle the upload?
     if (!$uploader->can_handle()) {
         wp_send_json_error(array('message' => __('Server can not handle this much amount of data. Please upload a smaller file or ask your server administrator to change the settings.', 'mediapress')));
     }
     if (!mpp_has_available_space($component, $component_id)) {
         wp_send_json_error(array('message' => __('Unable to upload. You have used the allowed storage quota!', 'mediapress')));
     }
     //if we are here, the server can handle upload
     //check should be here
     $gallery_id = 0;
     if (isset($_POST['gallery_id'])) {
         $gallery_id = absint($_POST['gallery_id']);
     }
     if ($gallery_id) {
         $gallery = mpp_get_gallery($gallery_id);
     } else {
         $gallery = false;
     }
     //not set
     //if there is no gallery id given and the context is activity, we may want to auto create the gallery
     $media_type = mpp_get_media_type_from_extension(mpp_get_file_extension($file[$file_id]['name']));
     if (!$media_type) {
         wp_send_json_error(array('message' => __("This file type is not supported.", 'mediapress')));
     }
     //if there is no gallery type defined( It wil happen in case of new gallery creation from admin page
     //we will set the gallery type as the type of the first media
     if ($gallery && empty($gallery->type)) {
         //update gallery type
         //set it to media type
         mpp_update_gallery_type($gallery, $media_type);
     }
     //If the gallery is not given and It is members component, check if the upload context is activity?
     //Check if we have a profile gallery set for the current user for this type of media
     //if yes, then use that gallery to upload the media
     //otherwise we create a gallery of the current media type and set it as the profile gallery for that type
     if (!$gallery && $context == 'activity') {
         //if gallery is not given and the component supports wall gallery
         //then create
         if (!mpp_is_activity_upload_enabled($component)) {
             wp_send_json_error(array('message' => __("The gallery is not selected.", 'mediapress')));
         }
         $gallery_id = mpp_get_wall_gallery_id(array('component' => $component, 'component_id' => $component_id, 'media_type' => $media_type));
         if (!$gallery_id) {
             //if gallery does not exist, create 1
             $gallery_id = mpp_create_gallery(array('creator_id' => get_current_user_id(), 'title' => sprintf(_x('Wall %s Gallery', 'wall gallery name', 'mediapress'), $media_type), 'description' => '', 'status' => 'public', 'component' => $component, 'component_id' => $component_id, 'type' => $media_type));
             if ($gallery_id) {
                 //save the profile gallery id
                 mpp_update_wall_gallery_id(array('component' => $component, 'component_id' => $component_id, 'media_type' => $media_type, 'gallery_id' => $gallery_id));
             }
         }
         //setup gallery object from the profile gallery id
         if ($gallery_id) {
             $gallery = mpp_get_gallery($gallery_id);
         }
     }
     //we may want to check the upload type and set the gallery to activity gallery etc if it is not set already
     $error = false;
     //detect media type of uploaded file here and then upload it accordingly also check if the media type uploaded and the gallery type matches or not
     //let us build our response for javascript
     //if we are uploading to a gallery, check for type
     //since we will be allowin g upload without gallery too, It is required to make sure $gallery is present or not
     if ($gallery && !mpp_is_mixed_gallery($gallery) && $media_type !== $gallery->type) {
         //if we are uploading to a gallery and It is not a mixed gallery, the media type must match the gallery type
         wp_send_json_error(array('message' => sprintf(__('This file type is not allowed in current gallery. Only <strong>%s</strong> files are allowed!', 'mediapress'), mpp_get_allowed_file_extensions_as_string($gallery->type))));
     }
     //if we are here, all is well :)
     if (!mpp_user_can_upload($component, $component_id, $gallery)) {
         wp_send_json_error(array('message' => __("You don't have sufficient permissions to upload.", 'mediapress')));
     }
     //if we are here, we have checked for all the basic errors, so let us just upload now
     $uploaded = $uploader->upload($file, array('file_id' => $file_id, 'gallery_id' => $gallery_id, 'component' => $component, 'component_id' => $component_id));
     //upload was succesfull?
     if (!isset($uploaded['error'])) {
         //file was uploaded successfully
         $title = $_FILES[$file_id]['name'];
         $title_parts = pathinfo($title);
         $title = trim(substr($title, 0, -(1 + strlen($title_parts['extension']))));
//.........这里部分代码省略.........
开发者ID:enboig,项目名称:mediapress,代码行数:101,代码来源:mpp-ajax.php

示例15: mpp_record_activity

/**
 * Record Media Activity
 * 
 * It does not actually records activity, simply simulates the activity update and rest are done by the actions.php functions
 * 
 * It will be removed in future for a better record_activity method
 * @param type $args
 * @return boolean
 */
function mpp_record_activity($args = null)
{
    //if activity module is not active, why bother
    if (!bp_is_active('activity')) {
        return false;
    }
    $default = array('id' => false, 'gallery_id' => 0, 'media_id' => 0, 'media_ids' => null, 'action' => '', 'content' => '', 'type' => '', 'component' => mpp_get_current_component(), 'component_id' => mpp_get_current_component_id(), 'user_id' => get_current_user_id(), 'status' => '');
    $args = wp_parse_args($args, $default);
    //atleast a gallery id or a media id should be given
    if (!$args['gallery_id'] && !$args['media_id'] || !mpp_is_enabled($args['component'], $args['component_id']) || !$args['component_id']) {
        return false;
    }
    $gallery_id = absint($args['gallery_id']);
    $media_id = absint($args['media_id']);
    $type = $args['type'];
    //should we validate type too?
    $hide_sitewide = 0;
    $status_object = null;
    if ($args['status']) {
        $status_object = mpp_get_status_object($args['status']);
        if ($status_object && ($status_object->activity_privacy == 'hidden' || $status_object->activity_privacy == 'onlyme')) {
            $hide_sitewide = 1;
        }
        //if BuddyPress Activity privacy plugin is not active, revert back to hiding all non public activity
        if (!function_exists('bp_activity_privacy_check_config')) {
            $hide_sitewide = $args['status'] == 'public' ? 0 : 1;
            //overwrite privacy
        }
    }
    $media_ids = $args['media_ids'];
    if (!empty($media_ids) && !is_array($media_ids)) {
        $media_ids = explode(',', $media_ids);
    }
    $component = $args['component'];
    if ($component == buddypress()->members->id) {
        $component = buddypress()->activity->id;
        //for user gallery updates, let it be simple activity , do not set the component to 'members'
    }
    $activity_args = array('id' => $args['id'], 'user_id' => $args['user_id'], 'action' => $args['action'], 'content' => $args['content'], 'component' => $component, 'type' => 'mpp_media_upload', 'item_id' => absint($args['component_id']), 'secondary_item_id' => false, 'hide_sitewide' => $hide_sitewide);
    //only update record time if this is a new activity
    if (empty($args['id'])) {
        $activity_args['recorded_time'] = bp_core_current_time();
    }
    //let us give an opportunity to customize the activity args
    //use this filter to work with the activity privacy
    $activity_args = apply_filters('mpp_record_activity_args', $activity_args, $default);
    $activity_id = bp_activity_add($activity_args);
    if (!$activity_id) {
        return false;
        //there was a problem
    }
    //store the type of gallery activity in meta
    if ($type) {
        mpp_activity_update_activity_type($activity_id, $type);
    }
    if ($media_ids) {
        $media_ids = wp_parse_id_list($media_ids);
        mpp_activity_update_attached_media_ids($activity_id, $media_ids);
    }
    if ($gallery_id) {
        mpp_activity_update_gallery_id($activity_id, $gallery_id);
    }
    if ($media_id) {
        mpp_activity_update_media_id($activity_id, $media_id);
    }
    mpp_activity_update_context($activity_id, 'gallery');
    //save activity privacy
    if ($status_object) {
        bp_activity_update_meta($activity_id, 'activity-privacy', $status_object->activity_privacy);
    }
    return $activity_id;
}
开发者ID:Kemitestech,项目名称:WordPress-Skeleton,代码行数:81,代码来源:mpp-activity-functions.php


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