function bp_checkins_untrashed_place($place_id) { // we need to rebuilt the activity type new_place and its activity_meta if (empty($place_id)) { return false; } $place = get_post($place_id); if (!in_array($place->post_type, array('places'))) { return false; } /* do we have a group_id ? */ $group_id = get_post_meta($place_id, '_bpci_group_id', true); /* let's build the activity vars */ $place_name = esc_attr($place->post_title); $thumbnail = bp_get_checkins_places_featured_image($place_id); $excerpt = bp_get_checkins_places_excerpt($place->post_content); $place_content = apply_filters('bp_checkins_place_content_before_activity', $thumbnail . $excerpt); $args = array('content' => $place_content, 'user_id' => $place->post_author, 'type' => 'new_place', 'place_id' => $place_id, 'place_name' => $place_name, 'recorded_time' => $place->post_date_gmt); if (!empty($group_id) && $group_id != 0) { // adding the group_id to args. $args['group_id'] = $group_id; $activity_id = bp_checkins_groups_post_update($args); } else { $activity_id = bp_checkins_post_update($args); } if (!empty($activity_id)) { /* * now we store the post meta as activity meta * this way if cookies of superadmin were writen * we'll be sure to have the correct values. */ $lat = get_post_meta($place_id, 'bpci_places_lat', true); $lng = get_post_meta($place_id, 'bpci_places_lng', true); $address = get_post_meta($place_id, 'bpci_places_address', true); if (empty($lat) || empty($lng) || empty($address)) { return false; } bp_activity_update_meta($activity_id, 'bpci_activity_lat', $lat); bp_activity_update_meta($activity_id, 'bpci_activity_lng', $lng); bp_activity_update_meta($activity_id, 'bpci_activity_address', $address); } }
function bp_checkins_post_places() { global $bp; // Bail if not a POST action if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) { return; } // Check the nonce check_admin_referer('post_places', '_wpnonce_post_places'); $group_id = 0; if (!empty($_POST['group_id'])) { $group_id = intval($_POST['group_id']); } if (!is_user_logged_in()) { echo '-1'; return false; } if (empty($_POST['title'])) { echo '-1<div id="message" class="error"><p>' . __('Please put the name of the place.', 'bp-checkins') . '</p></div>'; return false; } if (empty($_POST['content'])) { echo '-1<div id="message" class="error"><p>' . __('Please enter some content to place.', 'bp-checkins') . '</p></div>'; return false; } if (empty($_POST['bpci-address'])) { echo '-1<div id="message" class="error"><p>' . __('Please enter an address for the place.', 'bp-checkins') . '</p></div>'; return false; } if (empty($_POST['category'])) { echo '-1<div id="message" class="error"><p>' . __('Please select a category for the place.', 'bp-checkins') . '</p></div>'; return false; } if ($_POST['type'] == "live" && ($_POST['start'] == " " || $_POST['end'] == " ")) { echo '-1<div id="message" class="error"><p>' . __('Please choose a date for your live place.', 'bp-checkins') . '</p></div>'; return false; } $args = array('group_id' => $group_id, 'title' => $_POST['title'], 'content' => $_POST['content'], 'address' => $_POST['bpci-address'], 'lat' => $_POST['bpci-lat'], 'lng' => $_POST['bpci-lng'], 'place_category' => intval($_POST['category'])); if ($_POST['type'] == "live") { $args['type'] = $_POST['type']; $args['start'] = $_POST['start']; $args['end'] = $_POST['end']; } // If the group is not public, hide the activity sitewide. if (!empty($group_id)) { $bp->groups->current_group = new BP_Groups_Group($group_id); if (isset($bp->groups->current_group->status) && 'public' != $bp->groups->current_group->status) { $args['hide_sitewide'] = 1; } /*else $args['hide_sitewide'] = 0;*/ } $place_id = bp_checkins_add_new_place($args); if (empty($place_id)) { echo '-1<div id="message" class="error"><p>' . __('There was a problem posting your place, please try again.', 'bp-checkins') . '</p></div>'; return false; } // setting the activity content $place = get_post($place_id); $thumbnail = bp_get_checkins_places_featured_image($place_id); $excerpt = bp_get_checkins_places_excerpt($place->post_content); $place_name = esc_attr($place->post_title); $content = apply_filters('bp_checkins_place_content_before_activity', $thumbnail . $excerpt); $activity_id = 0; if (empty($group_id) && bp_is_active('checkins')) { $activity_id = bp_checkins_post_update(array('content' => $content, 'type' => 'new_place', 'place_id' => $place_id, 'place_name' => $place_name)); } else { $activity_id = bp_checkins_groups_post_update(array('content' => $content, 'group_id' => $group_id, 'type' => 'new_place', 'place_id' => $place_id, 'place_name' => $place_name)); } if (empty($place_id)) { echo '-1<div id="message" class="error"><p>' . __('There was a problem posting your place, please try again.', 'bp-checkins') . '</p></div>'; return false; } if (bp_checkins_has_places('p=' . $place->post_name)) { ?> <?php while (bp_checkins_has_places()) { bp_checkins_the_place(); ?> <?php bp_checkins_load_template_choose('bp-checkins-places-entry'); ?> <?php } ?> <?php } exit; }
function bp_checkins_places_excerpt() { echo bp_get_checkins_places_excerpt(); }