Esempio n. 1
0
 /**
  * Format string and media url for notification
  *
  * @param   array $params array ('action', 'post_id', 'initiator_id', 'total_items', 'format' )
  *
  * @return string/array     format notification as $params['format'] request
  */
 function format_like_notifications($params)
 {
     $action = $params['action'];
     $post_id = intval($params['post_id']);
     if ($this->component_action . $post_id === $action) {
         $initiator_id = $params['initiator_id'];
         $total_items = $params['total_items'];
         $format = $params['format'];
         $rtmedia_id = rtmedia_id($post_id);
         $liked_list = $this->fetch_media_like_stats($rtmedia_id);
         $liked_by = bp_core_get_username($liked_list[0]->user_id);
         $like_count = get_rtmedia_like($post_id);
         $link = esc_url(get_rtmedia_permalink($rtmedia_id));
         $media_type = rtmedia_type($rtmedia_id);
         $text = null;
         if (0 === intval($like_count)) {
             $this->delete_notification_by_item_id($initiator_id, $post_id);
         } elseif (1 === intval($like_count)) {
             $text = $liked_by . ' ' . __('liked your', 'buddypress-media') . ' ' . $media_type;
         } elseif (2 === intval($like_count)) {
             $text = $liked_by . ' ' . __('and one more friend liked your', 'buddypress-media') . ' ' . $media_type;
         } else {
             $count = $like_count - 1;
             $text = $liked_by . ' ' . __('and', 'buddypress-media') . ' ' . $count . ' ' . __('other friends liked your', 'buddypress-media') . ' ' . $media_type;
         }
         $return = apply_filters('rtmedia_before_like_notification', array('link' => $link, 'text' => $text), (int) $total_items);
         if ('string' === $format) {
             return '<a href="' . esc_url($return['link']) . '">' . esc_html($return['text']) . '</a>';
         } else {
             return $return;
         }
     }
 }
 /**
  * format the new notification in String or array
  * @param array         $params
  * @return array/string  As per $format 
  */
 function format_comment_notifications($params)
 {
     $action = $params['action'];
     $post_id = $params['post_id'];
     if ($this->component_action . $post_id == $action) {
         $initiator_id = $params['initiator_id'];
         $total_items = $params['total_items'];
         $format = $params['format'];
         $comment_author = bp_core_get_username($initiator_id);
         $media_url = get_rtmedia_permalink(rtmedia_id($post_id));
         $media_type = rtmedia_type(rtmedia_id($post_id));
         if ($total_items == 1) {
             $text = $comment_author . ' ' . __('commented on your', 'buddypress-media') . ' ' . $media_type;
         } else {
             $text = $total_items . ' ' . __('new comments on your', 'buddypress-media') . ' ' . $media_type;
         }
         $link = $media_url;
         if ($format == 'string') {
             $return = apply_filters('rtmedia_before_comment_notification', '<a href="' . $link . '">' . $text . '</a>', (int) $total_items);
         } else {
             $return = apply_filters('rtmedia_before_comment_notification', array('link' => $link, 'text' => $text), (int) $total_items);
         }
         return $return;
     }
 }
Esempio n. 3
0
 /**
  * Format string and media url for notification
  * 
  * @param   array           $params array ('action', 'post_id', 'initiator_id', 'total_items', 'format' )
  * @return string/array     format notification as $params['format'] request
  */
 function format_like_notifications($params)
 {
     $action = $params['action'];
     $post_id = $params['post_id'];
     if ($this->component_action . $post_id == $action) {
         $initiator_id = $params['initiator_id'];
         $total_items = $params['total_items'];
         $format = $params['format'];
         $liked_list = $this->fetch_media_like_stats(rtmedia_id($post_id));
         $liked_by = bp_core_get_username($liked_list[0]->user_id);
         $like_count = get_rtmedia_like($post_id);
         $link = get_rtmedia_permalink(rtmedia_id($post_id));
         $media_type = rtmedia_type(rtmedia_id($post_id));
         if ($like_count == 0) {
             $this->delete_notification_by_item_id($initiator_id, $post_id);
         } elseif ($like_count == 1) {
             $text = $liked_by . ' ' . __('liked your', 'rtmedia') . ' ' . $media_type;
         } elseif ($like_count == 2) {
             $text = $liked_by . ' ' . __('and one more friend liked your', 'rtmedia') . ' ' . $media_type;
         } else {
             $count = $like_count - 1;
             $text = $liked_by . ' ' . __('and', 'rtmedia') . ' ' . $count . ' ' . __('other friends liked your', 'rtmedia') . ' ' . $media_type;
         }
         if ($format == 'string') {
             $return = apply_filters('rtmedia_before_like_notification', '<a href="' . $link . '">' . $text . '</a>', (int) $total_items);
         } else {
             $return = apply_filters('rtmedia_before_like_notification', array('link' => $link, 'text' => $text), (int) $total_items);
         }
         return $return;
     }
 }
Esempio n. 4
0
/**
 * echo the album name of the media
 *
 * @global      object          $rtmedia_media
 *
 * @return      bool/string
 */
function rtmedia_album_name()
{
    global $rtmedia_media;
    if ($rtmedia_media->album_id) {
        if ('album' === rtmedia_type($rtmedia_media->album_id)) {
            return get_rtmedia_title($rtmedia_media->album_id);
        } else {
            return false;
        }
    } else {
        return false;
    }
}
function set_video_thumbnail($id)
{
    $media_type = rtmedia_type($id);
    if ('video' == $media_type && isset($_POST['rtmedia-thumbnail'])) {
        $model = new RTMediaModel();
        $model->update(array('cover_art' => $_POST['rtmedia-thumbnail']), array('id' => $id));
        update_activity_after_thumb_set($id);
        // code to update activity
    }
}
Esempio n. 6
0
        _e('Description: ', 'rtmedia');
        ?>
</label>
								<?php 
        echo rtmedia_description_input($editor = false);
        RTMediaMedia::media_nonce_generator(rtmedia_id());
        ?>
							</div>
							<!-- Use this hook to add new fields to the edit form-->
							<?php 
        do_action('rtmedia_add_edit_fields', rtmedia_type());
        ?>
						</div>
						<!-- use this hook to add content of a new tab-->
						<?php 
        do_action('rtmedia_add_edit_tab_content', rtmedia_type());
        ?>
					</div>
					<div class="rtmedia-editor-buttons">
						<input type="submit" class="button rtm-button rtm-button-save" value="<?php 
        _e('Save', 'rtmedia');
        ?>
" />
						<a class="button rtm-button rtm-button-back" href="<?php 
        rtmedia_permalink();
        ?>
"><?php 
        _e('Back', 'rtmedia');
        ?>
</a>
					</div>
Esempio n. 7
0
 /**
  * Generic method to add a media
  *
  * @param type $uploaded
  * @param type $file_object
  *
  * @return type
  */
 function add($uploaded, $file_object)
 {
     /* action to perform any task before adding a media */
     do_action('rtmedia_before_add_media', $file_object, $uploaded);
     /* Generate media details required to feed in database */
     $attachments = $this->generate_post_array($uploaded, $file_object);
     /* Insert the media as an attachment in Wordpress context */
     $attachment_ids = $this->insert_attachment($attachments, $file_object);
     /* check for multisite and if valid then add taxonomies */
     if (!$this->is_multisite()) {
         $this->add_taxonomy($attachment_ids, $uploaded['taxonomy']);
     }
     /* fetch custom fields and add them to meta table */
     $this->add_meta($attachment_ids, $uploaded['custom_fields']);
     /* add media in rtMedia context */
     $media_ids = $this->insertmedia($attachment_ids, $uploaded, $file_object);
     $rtmedia_type = rtmedia_type($media_ids);
     /* action to perform any task after adding a media */
     global $rtmedia_points_media_id;
     if ($media_ids && is_array($media_ids) && isset($media_ids[0])) {
         $rtmedia_points_media_id = $media_ids[0];
     }
     do_action('rtmedia_after_add_' . $rtmedia_type);
     do_action('rtmedia_after_add_media', $media_ids, $file_object, $uploaded);
     return $media_ids;
 }