예제 #1
0
function swa_post_update()
{
    global $bp;
    /* Check the nonce */
    check_admin_referer('swa_post_update', '_wpnonce_swa_post_update');
    if (!is_user_logged_in()) {
        echo '-1';
        return false;
    }
    if (empty($_POST['content'])) {
        echo '-1<div id="message" class="error"><p>' . __('Please enter some content to post.', 'swa') . '</p></div>';
        return false;
    }
    if (empty($_POST['object']) && function_exists('bp_activity_post_update')) {
        $activity_id = bp_activity_post_update(array('content' => $_POST['content']));
    } elseif ($_POST['object'] == 'groups') {
        if (!empty($_POST['item_id']) && function_exists('groups_post_update')) {
            $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 (!$activity_id) {
        echo '-1<div id="message" class="error"><p>' . __('There was a problem posting your update, please try again.', 'swa') . '</p></div>';
        return false;
    }
    $show_avatar = $_POST["show_avatar"] ? $_POST["show_avatar"] : "no";
    $show_content = $_POST["show_content"] ? $_POST["show_content"] : "no";
    if (bp_has_activities('include=' . $activity_id)) {
        ?>
		<?php 
        while (bp_activities()) {
            bp_the_activity();
            ?>
			<?php 
            swa_activity_entry('show_avatar=' . $show_avatar . '&show_activity_content=' . $show_content);
            ?>
		<?php 
        }
        ?>
	 <?php 
    }
    exit(0);
}
/**
 * template/output control functions
 */
function bp_swa_list_activities($args)
{
    $defaults = array('per_page' => 10, 'page' => 1, 'scope' => '', 'max' => 20, 'show_avatar' => "yes", 'show_filters' => "yes", 'included' => false, 'excluded' => false, 'is_personal' => "no", 'is_blog_admin_activity' => "no", 'show_post_form' => "no");
    $args = wp_parse_args($args, $defaults);
    extract($args);
    //check for the scope of activity
    //is it the activity of logged in user/blog admin
    //logged in user over rides blog admin
    global $bp;
    $primary_id = '';
    if (function_exists('bp_is_group') && bp_is_group()) {
        $primary_id = null;
    }
    $user_id = false;
    //for limiting to users
    if ($is_personal == "yes") {
        $user_id = bp_loggedin_user_id();
    } else {
        if ($is_blog_admin_activity == "yes") {
            $user_id = swa_get_blog_admin_id();
        } else {
            if (bp_is_user()) {
                $user_id = null;
            }
        }
    }
    $components_scope = swa_get_base_component_scope($included, $excluded);
    $components_base_scope = "";
    if (!empty($components_scope)) {
        $components_base_scope = join(",", $components_scope);
    }
    ?>
      <div class='swa-wrap'>
          <?php 
    if (is_user_logged_in() && $show_post_form == "yes") {
        swa_show_post_form();
    }
    ?>
          
          <?php 
    if ($show_filters == "yes") {
        ?>
			<ul id="activity-filter-links">
				<?php 
        swa_activity_filter_links("scope=" . $scope . "&include=" . $included . "&exclude=" . $excluded);
        ?>
			</ul>
                        <div class="clear"></div>
          <?php 
    }
    ?>
        
          <?php 
    if (bp_has_activities('type=sitewide&max=' . $max . '&page=' . $page . '&per_page=' . $per_page . '&object=' . $scope . "&user_id=" . $user_id . "&primary_id=" . $primary_id)) {
        ?>

                <div class="swa-pagination ">
                        <div class="pag-count" id="activity-count">
                                <?php 
        bp_activity_pagination_count();
        ?>
                        </div>

                        <div class="pagination-links" id="activity-pag">
                                &nbsp; <?php 
        bp_activity_pagination_links();
        ?>
                        </div>
                    <div class="clear" ></div>
                </div>


                <div class="clear" ></div>
                
                <ul  class="site-wide-stream swa-activity-list">
                    <?php 
        while (bp_activities()) {
            bp_the_activity();
            ?>
                        <?php 
            swa_activity_entry($args);
            ?>
                    <?php 
        }
        ?>
               </ul>

	<?php 
    } else {
        ?>

                <div class="widget-error">
                    <?php 
        if ($is_personal == "yes") {
            $error = sprintf(__("You have no recent %s activity.", "swa"), $scope);
        } else {
            $error = __('There has been no recent site activity.', 'swa');
        }
        ?>
                        <?php 
        echo $error;
        ?>
                </div>
	<?php 
    }
    ?>
     </div>
     
<?php 
}