/** * Get Media delete url * * @param type $media * @return string */ function mpp_get_media_delete_url($media = null) { $media = mpp_get_media($media); $link = mpp_get_media_edit_url($media) . 'delete/?mpp-action=delete-media&mpp-nonce=' . wp_create_nonce('mpp-delete-media') . '&mpp-media-id=' . $media->id; return $link; //needs improvenemt }
function mpp_get_default_media_cover_image_src($media, $cover_type) { $media = mpp_get_media($media); //we need to cache the assets to avoid heavy file system read/write etc $key = $media->type . '-' . $cover_type; //let us assume a naming convention like this //media_type-cover_type.png? or whatever e.g video-thumbnail.png, photo-mid.png $default_image = $media->type . '-' . $cover_type . '.png'; $default_image = apply_filters('mpp_default_media_cover_file_name', $default_image, $cover_type, $media); return mpp_get_asset_url('assets/images/' . $default_image, $key); }
function mpp_media_filter_permalink($link, $post_id) { if (!mpp_is_valid_media($post_id)) { return $link; } $media = mpp_get_media($post_id); if ($media->component != 'sitewide') { return $link; } //in case of sitewide gallery, the permalink is like $gallery_permalink = mpp_get_gallery_permalink($media->gallery_id); return user_trailingslashit(untrailingslashit($gallery_permalink) . '/media/' . $media->slug); }
/** * Default view for the emdia attached to activity * * @param int[] $media_ids * @return null */ public function activity_display($media_ids = array()) { if (!$media_ids) { return; } $media = $media_ids[0]; $media = mpp_get_media($media); if (!$media) { return; } $type = $media->type; //we will use include to load found template file, the file will have $media_ids available $templates = array("buddypress/activity/views/grid-{$type}.php", 'buddypress/activity/views/grid.php'); $located_template = mpp_locate_template($templates, false); include $located_template; }
function mpp_activity_inject_media_in_comment_replies() { $activity_id = bp_get_activity_id(); $media_id = mpp_activity_get_media_id($activity_id); if (empty($media_id)) { return; } $media = mpp_get_media($media_id); if (!$media) { return; } // $gallery_id = mpp_activity_get_gallery_id( $activity_id ); // // $gallery = mpp_get_gallery( $gallery_id ); // // if( ! $gallery ) { // return ; // } $slug = $media->type; //media-loop-audio/media-loop-video,media-loop-photo, media-loop mpp_get_template_part('buddypress/activity/entry-comment', $slug); }
mpp_media_title(); ?> </div> <?php do_action('mpp_after_single_media_title'); ?> <div class="mpp-item-entry mpp-media-entry" > <?php do_action('mpp_before_single_media_content'); ?> <?php mpp_load_media_view(mpp_get_media()); ?> <?php do_action('mpp_after_single_media_content'); ?> </div> <div class="mpp-item-meta mpp-media-meta mpp-media-meta-bottom"> <?php do_action('mpp_media_meta'); ?> </div> <?php
/** * Set up query for fetching single media * * @param type $media_id */ public function setup_single_media_query($media) { $mp = mediapress(); if (!is_null($this->single_media_query)) { $mp->the_media_query = $this->single_media_query; } else { $mp->the_media_query = new MPP_Media_Query(array('id' => $media->ID)); } $mp->current_media = mpp_get_media($media); //now check if we are on edit page nor not? $this->current_action = isset($this->action_variables[2]) ? $this->action_variables[2] : ''; if ($this->current_action == 'edit') { $mp->set_editing('media'); //it is single media edit $mp->set_action('edit'); $edit_action = isset($this->action_variables[3]) ? $this->action_variables[3] : 'edit'; $mp->set_edit_action($edit_action); } }
function mpp_group_check_media_permission($can, $media, $gallery, $user_id) { $media = mpp_get_media($media); //if it is not a group gallery, we should not be worried if ($media->component != 'groups') { return $can; } $group_id = $media->component_id; if (groups_is_user_admin($user_id, $group_id) || groups_is_user_mod($user_id, $group_id)) { $can = true; } return $can; }
/** * When an activity is saved, check if there exists a media attachment cookie, * if yes, mark it as non orphaned and store in the activity meta * */ function mpp_activity_mark_attached_media($activity_id) { if (!is_user_logged_in()) { return; } if (empty($_COOKIE['_mpp_activity_attached_media_ids'])) { return; } //don't do anything //let us process $media_ids = $_COOKIE['_mpp_activity_attached_media_ids']; $media_ids = explode(',', $media_ids); //make an array foreach ($media_ids as $media_id) { //should we verify the logged in user & owner of media is same? mpp_delete_media_meta($media_id, '_mpp_is_orphan'); //or should we delete the key? } mpp_activity_update_attached_media_ids($activity_id, $media_ids); //store the media ids in the activity meta //also add the activity to gallery & gallery to activity link $media = mpp_get_media($media_id); if ($media->gallery_id) { mpp_activity_update_gallery_id($activity_id, $media->gallery_id); } //also update this activity and set its action to be mpp_media_upload $activity = new BP_Activity_Activity($activity_id); // $activity->component = buddypress()->mediapress->id; $activity->type = 'mpp_media_upload'; $activity->save(); mpp_activity_clear_attached_media_cookie(); //clear cookies //reset the cookie }
/** * Format activity action for 'mpp_media_upload' activity type. * * * @param string $action activity action. * @param object $activity Activity object. * @return string */ function mpp_format_activity_action_media_upload($action, $activity) { $userlink = mpp_get_user_link($activity->user_id); $media_ids = array(); $media_id = 0; $media_id = mpp_activity_get_media_id($activity->id); if (!$media_id) { $media_ids = mpp_activity_get_attached_media_ids($activity->id); if (!empty($media_ids)) { $media_id = $media_ids[0]; } } $gallery_id = mpp_activity_get_gallery_id($activity->id); if (!$media_id && !$gallery_id) { return $action; //not a gallery activity, no need to proceed further } $media = mpp_get_media($media_id); $gallery = mpp_get_gallery($gallery_id); if (!$media && !$gallery) { return $action; } $activity_type = mpp_activity_get_activity_type($activity->id); //is a type specified $skip = false; if ($activity_type) { if (in_array($activity_type, array('edit_gallery', 'add_media'))) { //'create_gallery', $skip = true; } } //there us still a chance for improvement, we should dynamically generate the action instead for the above actions too if ($skip) { return $action; } if ($activity_type == 'media_upload') { $media_count = count($media_ids); $media_id = current($media_ids); $type = $gallery->type; //we need the type plural in case of mult $type = _n($type, $type . 's', $media_count); //photo vs photos etc $action = sprintf(__('%s uploaded %d new %s', 'mediapress'), $userlink, $media_count, $type); //allow modules to filter the action and change the message $action = apply_filters('mpp_activity_action_media_upload', $action, $activity, $media_id, $media_ids, $gallery); } elseif ($activity_type == 'media_comment') { if (mpp_is_single_media()) { $action = sprintf(__('%s', 'mediapress'), $userlink); } else { $action = sprintf(__("%s commented on %s's %s", 'mediapress'), $userlink, mpp_get_user_link($media->user_id), $media->type); //brajesh singh commented on @mercime's photo } } elseif ($activity_type == 'gallery_comment') { if (mpp_is_single_gallery()) { $action = sprintf('%s', $userlink); } else { $action = sprintf(__("%s commented on %s's <a href='%s'>%s gallery</a>", 'mediapress'), $userlink, mpp_get_user_link($gallery->user_id), mpp_get_gallery_permalink($gallery), $gallery->type); } } elseif ($activity_type == 'create_gallery') { $action = sprintf(__('%s created a %s <a href="%s">gallery</a>', 'mediapress'), $userlink, $gallery->type, mpp_get_gallery_permalink($gallery)); } else { $action = sprintf(__('%s', 'mediapress'), $userlink); } return apply_filters('mpp_format_activity_action_media_upload', $action, $activity, $media_id, $media_ids); }
/** * Delete all the files associated with a Media * * @global type $wpdb * @param type $id * @return boolean */ public function delete($media_id) { $media = mpp_get_media($media_id); $meta = wp_get_attachment_metadata($media_id); $backup_sizes = get_post_meta($media_id, '_wp_attachment_backup_sizes', true); $file = get_attached_file($media_id); //relatiev path from uploads directory to the current directory $rel_path = str_replace(wp_basename($file), '', $file); ///echo "Rel path: $rel_path <br><br>"; //$media = mpp_get_media( $media_id ); //$upload_dir = wp_upload_dir(); //$base_upload_dir = trailingslashit( $upload_dir['basedir'] ); // $gallery_dir = trailingslashit($rel_path); //get the file system path to current gallery upload dir //if ( is_multisite() ) delete_transient('dirsize_cache'); do_action('mpp_before_media_files_delete', $media_id); delete_metadata('post', null, '_thumbnail_id', $media_id, true); // delete all for any posts. $sizes = isset($meta['sizes']) ? $meta['sizes'] : array(); // remove intermediate and backup images if there are any foreach ($sizes as $size) { /** This filter is documented in wp-admin/custom-header.php */ $media_file = apply_filters('mpp_delete_file', $size['file']); @unlink(path_join($gallery_dir, $media_file)); } $file = apply_filters('mpp_delete_file', $file); if (!empty($file)) { @unlink($base_upload_dir . $file); } $this->invalidate_transient($media->component, $media->component_id); return true; }
/** * Render media admin tabs * * @param type $media */ function mpp_media_menu($media) { $media = mpp_get_media($media); mediapress()->get_menu('media')->render($media); }
/** * Post a gallery or media Main comment on single page * * @return type */ public function post_comment() { //this is BuddyPress dependent if (!function_exists('buddypress')) { exit(0); } // Bail if not a POST action if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) { return; } // Check the nonce check_admin_referer('post_update', '_wpnonce_post_update'); if (!is_user_logged_in()) { exit('-1'); } $mpp_type = $_POST['mpp-type']; $mpp_id = $_POST['mpp-id']; if (empty($_POST['content'])) { exit('-1<div id="message" class="error"><p>' . __('Please enter some content to post.', 'mediapress') . '</p></div>'); } $activity_id = 0; if (empty($_POST['object']) && bp_is_active('activity')) { //we are preventing this comment to be set as the user's lastes_update $user_id = bp_loggedin_user_id(); $old_latest_update = bp_get_user_meta($user_id, 'bp_latest_update', true); $activity_id = bp_activity_post_update(array('content' => $_POST['content'])); //restore if (!empty($old_latest_update)) { bp_update_user_meta($user_id, 'bp_latest_update', $old_latest_update); } } elseif ($_POST['object'] == 'groups') { if (!empty($_POST['item_id']) && bp_is_active('groups')) { $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id'])); } } else { $activity_id = apply_filters('bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content']); } if (empty($activity_id)) { exit('-1<div id="message" class="error"><p>' . __('There was a problem posting your update, please try again.', 'mediapress') . '</p></div>'); } $status = ''; //if we have got activity id, let us add a meta key if ($mpp_type == 'gallery') { mpp_activity_update_gallery_id($activity_id, $mpp_id); mpp_activity_update_activity_type($activity_id, 'gallery_comment'); mpp_activity_update_context($activity_id, 'gallery'); $status = mpp_get_gallery_status($mpp_id); } elseif ($mpp_type == 'media') { $media = mpp_get_media($mpp_id); if (!$media) { die('-1'); } mpp_activity_update_gallery_id($activity_id, $media->gallery_id); mpp_activity_update_media_id($activity_id, $mpp_id); mpp_activity_update_activity_type($activity_id, 'media_comment'); mpp_activity_update_context($activity_id, 'media'); //also we need to keep the parent gallery id for caching $status = mpp_get_media_status($media); } $activity = new BP_Activity_Activity($activity_id); // $activity->component = buddypress()->mediapress->id; $activity->type = 'mpp_media_upload'; $activity->save(); //save activity privacy if ($status) { $status_object = mpp_get_status_object($status); if ($status_object) { bp_activity_update_meta($activity->id, 'activity-privacy', $status_object->activity_privacy); } } //create a shadow comment mpp_activity_create_comment_for_activity($activity_id); if (bp_has_activities('include=' . $activity_id)) { while (bp_activities()) { bp_the_activity(); mpp_locate_template(array('buddypress/activity/entry.php'), true); } } exit; }
<?php // Exit if the file is accessed directly over web if (!defined('ABSPATH')) { exit; } $media = mpp_get_current_media(); ?> <div class="mpp-lightbox-content mpp-clearfix"> <?php $media = mpp_get_media(); ?> <div class="mpp-lightbox-media-container"> <?php do_action('mpp_before_lightbox_media', $media); ?> <div class="mpp-item-meta mpp-media-meta mpp-lightbox-media-meta mpp-lightbox-media-meta-top"> <?php do_action('mpp_lightbox_media_meta_top', $media); ?> </div> <a href="<?php mpp_media_permalink(); ?> " title="<?php echo esc_attr(mpp_get_media_title());
/** * Check if the media can be deleted by the user * * @param type $media_id * @param type $user_id * @return boolean true if allowed false otherwise */ function mpp_user_can_delete_media($media_id, $user_id = null) { if (!$user_id) { $user_id = get_current_user_id(); } $media = mpp_get_media($media_id); if (!$media) { return false; } $gallery = mpp_get_gallery($media->gallery_id); $allow = false; //do not alow editing by default //if the user is gallery creator, allow him to delete media if ($gallery->user_id == $user_id) { //should we consider context here like members gallery or groups gallery? $allow = true; } elseif ($user_id == $media->user_id) { //since current user is uploader/contributor //let us check if the gallery allows deleting for contributor $allow_deleting = mpp_get_gallery_meta($gallery->id, '_mpp_contributors_can_delete', true); if ($allow_deleting == 'yes') { $allow = true; } elseif ($allow_deleting != 'no' && mpp_get_option('contributors_can_delete')) { //check for global settings & make sure it is not overridden in the local settings $allow = true; } } return apply_filters('mpp_user_can_delete_media', $allow, $media, $gallery, $user_id); }
/** * When an activity is saved, check if there exists a media attachment cookie, * if yes, mark it as non orphaned and store in the activity meta * */ function mpp_activity_mark_attached_media($activity_id) { if (!is_user_logged_in()) { return; } if (empty($_POST['mpp-attached-media'])) { return; } //don't do anything //let us process $media_ids = $_POST['mpp-attached-media']; $media_ids = explode(',', $media_ids); //make an array $media_ids = array_filter(array_unique($media_ids)); foreach ($media_ids as $media_id) { //should we verify the logged in user & owner of media is same? mpp_delete_media_meta($media_id, '_mpp_is_orphan'); //or should we delete the key? } mpp_activity_update_attached_media_ids($activity_id, $media_ids); mpp_activity_update_context($activity_id, 'gallery'); mpp_activity_update_activity_type($activity_id, 'media_upload'); //store the media ids in the activity meta //also add the activity to gallery & gallery to activity link $media = mpp_get_media($media_id); if ($media->gallery_id) { mpp_activity_update_gallery_id($activity_id, $media->gallery_id); } //also update this activity and set its action to be mpp_media_upload $activity = new BP_Activity_Activity($activity_id); // $activity->component = buddypress()->mediapress->id; $activity->type = 'mpp_media_upload'; $activity->save(); //save activity privacy $status_object = mpp_get_status_object($media->status); //if you have BuddyPress Activity privacy plugin enabled, this will work out of the box if ($status_object) { bp_activity_update_meta($activity->id, 'activity-privacy', $status_object->activity_privacy); } do_action('mpp_activity_media_marked_attached', $media_ids); //reset the cookie }
/** * Should we show mdia description on single media pages? * * @param type $media * @return boolean */ function mpp_show_media_description($media = false) { $media = mpp_get_media($media); $show = mpp_get_option('show_media_description'); //under theme tab in admin panel return apply_filters('mpp_show_media_description', $show, $media); }
public function reorder_media() { //verify nonce if (!wp_verify_nonce($_POST['_wpnonce'], 'mpp-manage-gallery')) { wp_send_json(array('message' => __('Invalid action.', 'mediapress'), 'error' => 1)); exit(0); } //should we check for the permission? not here $media_ids = $_POST['mpp-media-ids']; //array $media_ids = wp_parse_id_list($media_ids); $media_ids = array_filter($media_ids); $order = count($media_ids); foreach ($media_ids as $media_id) { if (!mpp_user_can_edit_media($media_id)) { //unauthorized attemt wp_send_json(array('message' => __("You don't have permission to update!", 'mediapress'), 'error' => 1)); exit(0); } //if we are here, let us update the order mpp_update_media_order($media_id, $order); $order--; } if ($media_id) { //mark the gallery assorted, we use it in MPP_Media_query to see what should be the default order $media = mpp_get_media($media_id); //mark the gallery as sorted mpp_mark_gallery_sorted($media->gallery_id); } wp_send_json(array('message' => __("Updated", 'mediapress'), 'success' => 1)); exit(0); }
function mpp_media_record_activity($args) { $default = array('media_id' => null, 'action' => '', 'content' => '', 'type' => ''); $args = wp_parse_args($args, $default); if (!$args['media_id']) { return false; } $media_id = absint($args['media_id']); $media = mpp_get_media($media_id); if (!$media) { return false; } $gallery_id = $media->gallery_id; $gallery = mpp_get_gallery($gallery_id); $status = $media->status; //when a media is public, make sure to check that the gallery is public too if ($status == 'public') { $status = mpp_get_gallery_status($gallery); } //it is actually a gallery activity, isn't it? unset($args['media_id']); $args['status'] = $status; $args['gallery_id'] = $gallery->id; // $args['media_ids'] = (array) $media_id; return mpp_record_activity($args); }
/** * Get registered View for this media type * * @param string $type media type * @param string $storage storage method * @return MPP_Media_View|boolean */ function mpp_get_media_view($media) { if (!$media) { $media = mpp_get_media(); } $type = $media->type; $storage = mpp_get_storage_method($media->id); if (!$type || !$storage) { return false; } $mp = mediapress(); if (isset($mp->media_views[$type][$storage])) { return $mp->media_views[$type][$storage]; } //if we are here, there is no specific view registered for this media/storage combination //fallback to default if (isset($mp->media_views[$type]['default'])) { return $mp->media_views[$type]['default']; } return false; //none registered }
/** * Delete all the files associated with a Media * For lovcal storage, WordPress handles deleting, we simply invalidate the transiesnt * @global type $wpdb * @param type $id * @return boolean */ public function delete_media($media_id) { $media = mpp_get_media($media_id); $this->invalidate_transient($media->component, $media->component_id); return true; }
/** * Action links like view/edit/dele/upload to show on indiavidula media * * @param type $media * @return type */ function mpp_get_media_action_links($media = null) { $links = array(); $media = mpp_get_media($media); //$links ['view'] = sprintf( '<a href="%1$s" title="view %2$s" class="mpp-view-media">%3$s</a>', mpp_get_media_permalink( $media ), esc_attr( $media->title ), __( 'view', 'mediapress' ) ); //upload? if (mpp_user_can_edit_media($media->id)) { $links['edit'] = sprintf('<a href="%s" alt="' . __('Edit %s', 'mediapress') . '">%s</a>', mpp_get_media_edit_url($media), mpp_get_media_title($media), __('edit', 'mediapress')); } //delete if (mpp_user_can_delete_media($media)) { $links['delete'] = sprintf('<a href="%s" alt="' . __('delete %s', 'mediapress') . '" class="confirm mpp-confirm mpp-delete mpp-delete-media">%s</a>', mpp_get_media_delete_url($media), mpp_get_media_title($media), __('delete', 'mediapress')); } return apply_filters('mpp_media_actions_links', join(' ', $links), $links, $media); }
/** * Handles Gallery Media Reordering * * * @return type */ function mpp_action_reorder_gallery_media() { if (empty($_POST['mpp-action']) || $_POST['mpp-action'] != 'reorder-gallery-media') { return; } $referer = wp_get_referer(); if (!wp_verify_nonce($_POST['mpp-nonce'], 'mpp-reorder-gallery-media')) { //add error message and return back to the old page mpp_add_feedback(__('Action not authorized!', 'mediapress'), 'error'); mpp_redirect($referer); } //should we check for the permission? not here $media_ids = $_POST['mpp-media-ids']; //array $media_ids = wp_parse_id_list($media_ids); $order = count($media_ids); foreach ($media_ids as $media_id) { if (!mpp_user_can_edit_media($media_id)) { //unauthorized attemt mpp_add_feedback(__("You don't have permission to update!", 'mediapress'), 'error'); if ($referer) { mpp_redirect($referer); } return; } //if we are here, let us update the order mpp_update_media_order($media_id, $order); $order--; } if ($media_id) { //mark the gallery assorted, we use it in MPP_Media_query to see what should be the default order $media = mpp_get_media($media_id); //mark the gallery as sorted mpp_mark_gallery_sorted($media->gallery_id); } mpp_add_feedback(__('Updated', 'mediapress')); if ($referer) { mpp_redirect($referer); } }
/** * Maps 'delete_attachment' to mpp_before_media_delete action * Also, cleans up cover, decrements media count and deletes activities associated * * @param type $media_id * @return type */ public function map_before_delete_attachment_action($media_id) { if (!mpp_is_valid_media($media_id)) { //the attachment is not media return; } //this is just a precaution in case some faulty plugin calls it again //if everything is normal, we don't need to check for this if ($this->is_queued($media_id)) { return; // } //push this media to teh queue $this->add_item($media_id, 'media'); /** * mpp_before_media_delete action fires before WordPress starts deleting an attachment which is a valid media( in MediaPress). * Any plugin utilizing this action can access the fully functional media object by using mpp_get_media() on the passed media id * */ do_action('mpp_before_media_delete', $media_id); $storage_manager = mpp_get_storage_manager($media_id); $storage_manager->delete_media($media_id); //delete if it is set as cover delete_metadata('post', null, '_mpp_cover_id', $media_id, true); // delete all for any posts. delete_metadata('post', null, '_mpp_unpublished_media_id', $media_id, true); // delete all for any posts. // //if media has cover, delete the cover $media = mpp_get_media($media_id); $gallery_id = $media->gallery_id; if (mpp_media_has_cover_image($media_id)) { mpp_delete_media(mpp_get_media_cover_id($media_id)); } if (apply_filters('mpp_cleanup_single_media_on_delete', true, $media_id, $gallery_id)) { mpp_gallery_decrement_media_count($gallery_id); if (mediapress()->is_bp_active()) { //delete all activities related to this media //mpp_media_delete_activities( $media_id ); mpp_delete_activity_for_single_published_media($media_id); //delete all activity meta key where this media is associated mpp_media_delete_activity_meta($media_id); } } return; }
/** * Record a new upload activity if auto publishing is enabled in the * @param type $media_id */ function mpp_action_record_new_media_activity($media_id) { if (!mpp_is_auto_publish_to_activity_enabled('add_media') || apply_filters('mpp_do_not_record_add_media_activity', false)) { return; } $media = mpp_get_media($media_id); //if media is upload from activity, do not publish it again to activity if ($media->context == 'activity') { return; } $user_link = mpp_get_user_link($media->user_id); $link = mpp_get_media_permalink($media); mpp_media_record_activity(array('media_id' => $media_id, 'type' => 'add_media', 'content' => '', 'action' => sprintf(__('%s added a new <a href="%s">%s</a>', 'mediapress'), $user_link, $link, $media->type))); }
?> </div> <a href="<?php mpp_media_permalink(); ?> " class="mpp-item-title mpp-media-title mpp-audio-title"><?php mpp_media_title(); ?> </a> <div class="mpp-item-actions mpp-media-actions mpp-audio-actions"> <?php mpp_media_action_links(); ?> </div> <div class="mpp-type-icon"><?php do_action('mpp_type_icon', mpp_get_media_type(), mpp_get_media()); ?> </div> <?php do_action('mpp_after_media_widget_item'); ?> </div> <?php } ?> <?php mpp_reset_media_data(); ?> </div>
public function reset_media_data() { parent::reset_postdata(); if (!empty($this->post)) { mediapress()->current_media = mpp_get_media($this->post); } }
// Exit if the file is accessed directly over web if (!defined('ABSPATH')) { exit; } /** * List videos attached to activity * */ ?> <div class=" mpp-activity-media-list mpp-activity-video-list mpp-activity-video-player"> <?php $ids = $media_ids; //is there only one video attached? if (count($ids) == 1) { $ids = array_pop($ids); $media = mpp_get_media($ids); $args = array('src' => mpp_get_media_src('', $media), 'poster' => mpp_get_media_src('thumbnail', $media)); //show single video with poster echo wp_video_shortcode($args); } else { //show all videos as playlist echo wp_playlist_shortcode(array('ids' => $ids, 'type' => 'video')); } ?> <script type='text/javascript'> mpp_mejs_activate(<?php echo bp_get_activity_id(); ?> ); </script> </div>
/** * Format activity action for 'mpp_media_upload' activity type. * * * @param string $action activity action. * @param object $activity Activity object. * @return string */ function mpp_format_activity_action_media_upload($action, $activity) { $userlink = bp_core_get_userlink($activity->user_id); $media_ids = array(); //this could be a comment //or a media comment //or a gallery comment //or an activity upload $media_id = mpp_activity_get_media_id($activity->id); $gallery_id = mpp_activity_get_gallery_id($activity->id); if (!$media_id && !$gallery_id) { return $action; } //not a gallery activity, no need to proceed further $type = mpp_activity_get_activity_type($activity->id); //is a type specified $skip = false; if ($type) { if (in_array($type, array('create_gallery', 'edit_gallery', 'add_media'))) { $skip = true; } } if (!$skip && $media_id) { $media = mpp_get_media($media_id); //this is an activity comment on single media if (mpp_is_single_media()) { $action = sprintf(__('%s', 'mpp'), $userlink); } else { $action = sprintf(__("%s commented on %s's %s", 'mpp'), $userlink, bp_core_get_userlink($media->user_id), $media->type); //brajesh singh commented on @mercime's photo } } elseif (!$skip && $gallery_id) { $gallery = mpp_get_gallery($gallery_id); //check for the uploaded media $media_ids = mpp_activity_get_attached_media_ids($activity->id); //this will never fire but let us be defensive if (empty($media_ids)) { //this is gallery comment if (mpp_is_single_gallery()) { $action = sprintf('%s', $userlink); } else { $action = sprintf(__("%s commented on %s's <a href='%s'>%s gallery</a>", 'mpp'), $userlink, bp_core_get_userlink($gallery->user_id), mpp_get_gallery_permalink($gallery), $gallery->type); } } else { //we will always be here $media_count = count($media_ids); $media_id = current($media_ids); $type = $gallery->type; //we need the type plural in case of mult $type = _n($type, $type . 's', $media_count); //photo vs photos etc $action = sprintf(__('%s uploaded %d new %s', 'mpp'), $userlink, $media_count, $type); //allow modules to filter the action and change the message $action = apply_filters('mpp_activity_action_media_upload', $action, $activity, $media_id, $media_ids, $gallery); } } return apply_filters('mpp_format_activity_action_media_upload', $action, $activity, $media_id, $media_ids); }