本文整理汇总了PHP中mpp_get_current_component_id函数的典型用法代码示例。如果您正苦于以下问题:PHP mpp_get_current_component_id函数的具体用法?PHP mpp_get_current_component_id怎么用?PHP mpp_get_current_component_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mpp_get_current_component_id函数的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);
}
示例2: setup_nav
public function setup_nav($main = array(), $sub = array())
{
$bp = buddypress();
$component = 'members';
$component_id = mpp_get_current_component_id();
if (!mpp_is_enabled($component, $component_id)) {
//allow to disable user galleries in case they don't want it
return false;
}
$view_helper = MPP_Gallery_Screens::get_instance();
// Add 'Gallery' to the user's main navigation
$main_nav = array('name' => sprintf(__('Gallery <span>%d</span>', 'mediapress'), mpp_get_total_gallery_for_user()), 'slug' => $this->slug, 'position' => 86, 'screen_function' => array($view_helper, 'user_galleries'), 'default_subnav_slug' => 'my-galleries', 'item_css_id' => $this->id);
if (bp_is_user()) {
$user_domain = bp_displayed_user_domain();
} else {
$user_domain = bp_loggedin_user_domain();
}
$gallery_link = trailingslashit($user_domain . $this->slug);
//with a trailing slash
// Add the My Gallery nav item
$sub_nav[] = array('name' => __('My Gallery', 'mediapress'), 'slug' => 'my-galleries', 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array($view_helper, 'my_galleries'), 'position' => 10, 'item_css_id' => 'gallery-my-gallery');
if (mpp_user_can_create_gallery($component, get_current_user_id())) {
// Add the Create gallery link to gallery nav
$sub_nav[] = array('name' => __('Create a Gallery', 'mediapress'), 'slug' => 'create', 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array($view_helper, 'my_galleries'), 'user_has_access' => bp_is_my_profile(), 'position' => 20);
}
if (mpp_component_has_type_filters_enabled($component, $component_id)) {
$i = 10;
$supported_types = mpp_component_get_supported_types($component);
foreach ($supported_types as $type) {
if (!mpp_is_active_type($type)) {
continue;
}
$type_object = mpp_get_type_object($type);
$sub_nav[] = array('name' => $type_object->label, 'slug' => 'type/' . $type, 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array($view_helper, 'my_galleries'), 'position' => 20 + $i);
$i = $i + 10;
//increment the position
}
}
// Add the Upload link to gallery nav
/*$sub_nav[] = array(
'name' => __( 'Upload', 'mediapress'),
'slug' => 'upload',
'parent_url' => $gallery_link,
'parent_slug' => $this->slug,
'screen_function' => array( $view_helper, 'upload_media' ),
'user_has_access' => bp_is_my_profile(),
'position' => 30
);*/
parent::setup_nav($main_nav, $sub_nav);
//disallow these names in various lists
//we have yet to implement it
$this->forbidden_names = apply_filters('mpp_forbidden_names', array('gallery', 'galleries', 'my-gallery', 'create', 'delete', 'upload', 'add', 'edit', 'admin', 'request', 'upload', 'tags', 'audio', 'video', 'photo'));
//use this to extend the valid status
$this->valid_status = apply_filters('mpp_valid_gallery_status', array_keys(mpp_get_active_statuses()));
do_action('mpp_setup_nav');
// $bp->gallery->current_gallery->user_has_access
}
示例3: 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();
}
示例4: 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);
}
示例5: get_component_id
private function get_component_id($post_id)
{
//if it is not gallery edit page, let us not worry
if (!$this->is_gallery_edit()) {
return mpp_get_current_component_id();
}
//we are on edit page,
//it can be either add new or edit gallery
//we do not want to modify the component_id(associated component id)
$component_id = mpp_get_gallery_meta($post_id, '_mpp_component_id', true);
if (!$component_id) {
$component_id = get_current_user_id();
//
}
return $component_id;
}
示例6: setup_globals
/**
* Setup everything for BuddyPress Specific installation
*
*/
public function setup_globals($args = array())
{
//get current component/component_id
$this->component = mpp_get_current_component();
$this->component_id = mpp_get_current_component_id();
//override the component id if we are on user page
if (function_exists('bp_is_user') && bp_is_user()) {
$this->component_id = bp_displayed_user_id();
}
//let us setup global queries
$current_action = '';
//initialize query objects
mediapress()->the_gallery_query = new MPP_Gallery_Query();
mediapress()->the_media_query = new MPP_Media_Query();
if (!mpp_is_enabled($this->component, $this->component_id)) {
return;
//do not setup
}
//set the status types allowed for current user
$this->accessible_statuses = mpp_get_accessible_statuses($this->component, $this->component_id, get_current_user_id());
$this->status = $this->accessible_statuses;
//is this sitewide gallery?
if (mpp_is_enabled('sitewide', $this->component_id)) {
$this->setup_sitewide_gallery();
}
//I know we are not using ifelse, check setup_root_gallery() to know why
if (mpp_is_gallery_component()) {
$this->action_variables = buddypress()->action_variables;
//add the current action at the begining of the stack, we are doing it to unify the things for User gallery and component gallery
array_unshift($this->action_variables, bp_current_action());
$this->setup_user_gallery();
} elseif (mpp_is_component_gallery()) {
//are we on component gallery like groups or events etc?
$this->action_variables = buddypress()->action_variables;
$this->setup_component_gallery();
}
//fire this action to allow plugins do their own thing on mediapress()->the_gallery_query
do_action('mpp_setup_gallery_query', $this);
//once we are here, the basic action variables for mediapress are setup and so
//we can go ahead and test for the single gallery/media
$mp = mediapress();
//setup Single Gallery specific things
if (mpp_is_single_gallery()) {
//will save some db query with a few themes
if (has_action('wp_head', 'adjacent_posts_rel_link_wp_head')) {
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
}
$current_action = $this->current_action;
//setup and see the actions etc to find out what we need to do
//if it is one of the edit actions, It was already taken care of, don't do anything
//check if we are on management screen?
if ($this->current_action == 'manage') {
//this is media management page
$mp->set_editing('gallery');
$mp->set_action('manage');
$mp->set_edit_action($this->current_manage_action);
//on edit bulk media page
if ($mp->is_edit_action('edit')) {
$this->setup_gallery_media_query();
}
} elseif ($media = $this->get_media_id($this->current_action, $this->component, $this->component_id)) {
//yes, It is single media
$this->setup_single_media_query($media);
} else {
//we already know it is single gallery, so let us setup the media list query
$this->setup_gallery_media_query();
}
}
do_action('mpp_setup_globals');
}
示例7: mpp_gallery_breadcrumb
/**
* Generate/Display breadcrumb
* @param array $args
* @return string|null
*/
function mpp_gallery_breadcrumb($args = null)
{
$default = array('separator' => '/', 'before' => '', 'after' => '', 'show_home' => false);
$args = wp_parse_args($args, $default);
extract($args);
$crumbs = array();
$component = mpp_get_current_component();
$component_id = mpp_get_current_component_id();
if (mediapress()->is_bp_active() && bp_is_active('groups') && bp_is_group()) {
$name = bp_get_group_name(groups_get_current_group());
} elseif (mediapress()->is_bp_active() && bp_is_user()) {
$name = bp_get_displayed_user_fullname();
} elseif ($component == 'sitewide') {
$name = '';
}
$my_or_his_gallery = '';
if ($name) {
$my_or_his_gallery = sprintf(__("%s's gallery", 'mediapress'), $name);
}
if (function_exists('bp_is_my_profile') && bp_is_my_profile()) {
$my_or_his_gallery = __('Your Galleries', 'mediapress');
}
if (mpp_is_media_management()) {
$crumbs[] = ucwords(mediapress()->get_edit_action());
}
if (mpp_is_single_media()) {
$media = mpp_get_current_media();
if (mpp_is_media_management()) {
$crumbs[] = sprintf('<a href="%s">%s</a>', mpp_get_media_permalink($media), mpp_get_media_title($media));
} else {
$crumbs[] = sprintf('<span>%s</span>', mpp_get_media_title($media));
}
}
if (mpp_is_gallery_management()) {
$crumbs[] = ucwords(mediapress()->get_edit_action());
}
if (mpp_is_single_gallery()) {
$gallery = mpp_get_current_gallery();
if (mpp_is_gallery_management() || mpp_is_single_media()) {
$crumbs[] = sprintf('<a href="%s">%s</a>', mpp_get_gallery_permalink($gallery), mpp_get_gallery_title($gallery));
} else {
$crumbs[] = sprintf('<span>%s</span>', mpp_get_gallery_title($gallery));
}
}
if ($my_or_his_gallery) {
$crumbs[] = sprintf('<a href="%s">%s</a>', mpp_get_gallery_base_url($component, $component_id), $my_or_his_gallery);
}
if (count($crumbs) <= 1 && !$show_home) {
return;
}
$crumbs = array_reverse($crumbs);
echo join($separator, $crumbs);
}
示例8: 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);
}
示例9: 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);
}
示例10: 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
}
示例11: 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
}
示例12: mpp_activity_upload_buttons
/**
* Add various upload icons to activity post form
* @return type
*/
function mpp_activity_upload_buttons()
{
$component = mpp_get_current_component();
if (!mpp_is_activity_upload_enabled($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 (!mpp_is_enabled($component, mpp_get_current_component_id())) {
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;
}
?>
<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
}
示例13:
<?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'])) {
示例14: 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;
}
示例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('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;
}