Esempio n. 1
0
 class="two_column_left"<?php 
    }
    ?>
>
				<div class="padder">
					<div class="page" id="blog-latest">                                                                
					
					<?php 
    if (have_posts()) {
        while (have_posts()) {
            the_post();
            ?>
                                            
                                          <?php 
            $real_star = get_real_meditators(get_the_ID());
            $black_star = get_total_meditators(get_the_ID());
            $green_star = get_total_seconds(get_the_ID());
            $convert = secns_to_human($green_star);
            ?>
		
						<div class="post" id="post-<?php 
            the_ID();
            ?>
">
                                                    
                                                    <span class="for_wishes">
                                                        <span class="real_star"><?php 
            echo $real_star;
            ?>
 people</span>
                                                        <span class="black_star"><?php 
Esempio n. 2
0
                    $response["authorid"] = $userid;
                    $response["total"] = $total;
                    $response["posts"] = $posts;
                    echo json_encode($response);
                } else {
                    if ($tag == "wishes") {
                        $number = (int) $_REQUEST['number'];
                        $args = array('orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish');
                        if (isset($number) && $number != '') {
                            $args['numberposts'] = $number;
                        } else {
                            $args['numberposts'] = 50;
                        }
                        $posts = get_posts($args);
                        foreach ($posts as $post) {
                            $post->meditators = get_total_meditators($post->ID);
                            $post->totalmedittime = secns_to_human(get_total_seconds($post->ID));
                        }
                        $response["success"] = 1;
                        $response["posts"] = $posts;
                        echo json_encode($response);
                    } else {
                        echo "Invalid Request";
                    }
                }
            }
        }
    }
} else {
    echo "Access Denied";
}
Esempio n. 3
0
function saveWishTime()
{
    global $wpdb;
    $intention_tbl_name = $wpdb->prefix . 'intentions';
    $realtime_tbl_name = $wpdb->prefix . 'realtime_medit';
    ob_clean();
    $meditime = $_POST['meditime'];
    $wish_id = $_POST['postid'];
    $wisher_id = get_current_user_id();
    $realpeople = get_real_meditators($wish_id);
    $totalpeople = get_total_meditators($wish_id);
    $totalseconds = get_total_seconds($wish_id);
    $newold = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$intention_tbl_name} WHERE intention_id={$wish_id} AND meditater_id={$wisher_id}"));
    if ($newold > 0) {
        $wish_total = $wpdb->get_var($wpdb->prepare("SELECT total_mins FROM {$intention_tbl_name} WHERE intention_id={$wish_id} AND meditater_id={$wisher_id}"));
    } else {
        $wish_total = 0;
    }
    list($minutes, $seconds, $micros) = sscanf($meditime, "%d:%d:%d");
    //$time_seconds = $hours * 3600 + $minutes * 60 + $seconds;
    $time_seconds = $minutes * 60 + $seconds;
    $wish_total += $time_seconds;
    if ($newold > 0) {
        $wpdb->update($intention_tbl_name, array('total_mins' => $wish_total), array('intention_id' => $wish_id, 'meditater_id' => $wisher_id), array('%s'), array('%s', '%s'));
    } else {
        $wpdb->insert($intention_tbl_name, array('total_mins' => $wish_total, 'intention_id' => $wish_id, 'meditater_id' => $wisher_id), array('%s', '%s', '%s'));
        $totalpeople++;
    }
    $totalseconds += $time_seconds;
    $forhuman = secns_to_human($totalseconds);
    if (is_current_medit($wish_id, $wisher_id)) {
        $wpdb->delete($realtime_tbl_name, array('intention_id' => $wish_id, 'meditater_id' => $wisher_id));
        $realpeople--;
    }
    /* See Who's meditating right now */
    if ($realpeople > 0) {
        $realbutton = '<button id="my-first" onclick="openPopup1();">see who</button>
                <div id="first_to_pop_up">              
                    <div class="close"></div>                
                    <div class="avatar-block">';
        $meditIDs = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT(meditater_id) FROM {$realtime_tbl_name} WHERE intention_id = {$wish_id}"));
        foreach ($meditIDs as $userID) {
            $realbutton .= '<div class="item-avatar">            
                <a href="' . bp_core_get_user_domain($userID) . '" 
                    title="' . bp_core_get_user_displayname($userID) . '">
                    ' . bp_core_fetch_avatar(array('item_id' => $userID)) . ' 
                    ' . bp_core_get_user_displayname($userID) . '</a>              
            </div>';
        }
        $realbutton .= '</div></div>';
    } else {
        $realbutton = '';
    }
    /* See Who already meditated */
    if ($totalpeople > 0) {
        $totalbutton = '<button id="my-button" onclick="openPopup2();">see who</button>
                <div id="element_to_pop_up">              
                    <div class="close"></div>                
                    <div class="avatar-block">';
        $totmeditIDs = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT(meditater_id) FROM {$intention_tbl_name} WHERE intention_id = {$wish_id}"));
        foreach ($totmeditIDs as $totuserID) {
            $totalbutton .= '<div class="item-avatar">            
                <a href="' . bp_core_get_user_domain($totuserID) . ' 
                    title="' . bp_core_get_user_displayname($totuserID) . '">
                    ' . bp_core_fetch_avatar(array('item_id' => $totuserID)) . ' 
                    ' . bp_core_get_user_displayname($totuserID) . '</a>              
            </div>';
        }
        $totalbutton .= '</div></div>';
    } else {
        $totalbutton = '';
    }
    $response = '<span class="autowidth">  
           <ul>
               <li id="orange"><b>Currently Meditating People:</b> 
                   <span class="stat-num"><span id="realtime_stat">' . $realpeople . ' ' . $realbutton . '</span></span>
               </li>
               <li id="white"><b>Total Meditated People:</b> 
                   <span class="stat-num">' . $totalpeople . ' ' . $totalbutton . '</span>
               </li>
               <li id="red"><b>Total Collective Meditated Time:</b> 
                   <span class="stat-num">' . $forhuman . '</span>
               </li>
           </ul>                                  
        </span>';
    ob_end_clean();
    echo $response;
    die(1);
}
    function widget($args, $instance)
    {
        $cache = wp_cache_get('widget_recent_intentions', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        ob_start();
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Intentions') : $instance['title'], $instance, $this->id_base);
        if (empty($instance['number']) || !($number = absint($instance['number']))) {
            $number = 10;
        }
        echo $before_widget;
        wp_enqueue_script("sortintention", get_template_directory_uri() . '/_inc/js/sortintention.js');
        wp_localize_script("sortintention", 'Recentobj', array('ajax_url' => admin_url()));
        ?>
            <?php 
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
    
                <form action="" method="post">
			<div class="intention-sort-tabs">
				<ul>
					<li id="intentions-orderby" class="last filter">

						<label for="intentions-orderby"><?php 
        _e('Order By:', 'buddypress');
        ?>
</label>
						<select id="intentions-orderby-select">
                                                        <option value="newest" selected>Newest Intentions</option>
							<option value="current">Current Mediators</option>
                                                        <option value="past">Total Mediators</option>
                                                        <option value="time">Total Collective Meditation Time</option>
						</select>
					</li>

				</ul>
			</div>
                </form>          
                        
                        
                        <div id="intentions-list">
<?php 
        $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true)));
        if ($r->have_posts()) {
            ?>
                    
		  <ul class="wish_list">
		  <?php 
            while ($r->have_posts()) {
                $r->the_post();
                ?>
                    
                   <?php 
                $real_star = get_real_meditators(get_the_ID());
                $black_star = get_total_meditators(get_the_ID());
                $green_star = get_total_seconds(get_the_ID());
                $convert = secns_to_human($green_star);
                ?>
		
                    <li>
                        <span class="for_wishes">
                            <span class="real_star"><?php 
                echo $real_star;
                ?>
 people</span>
                            <span class="black_star"><?php 
                echo $black_star;
                ?>
 people</span>
                            <span class="green_star"><?php 
                echo $convert;
                ?>
</span>                          
                        </span>
                        <div class="wishes_info">
                          <a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                echo esc_attr(get_the_title() ? get_the_title() : get_the_ID());
                ?>
"><?php 
                if (get_the_title()) {
                    the_title();
                } else {
                    the_ID();
                }
                ?>
</a>
                          <span><?php 
                printf(__('set by %s', 'buddypress'), get_the_author_meta('display_name'));
                ?>
</span>
                        </div>
                    </li>
                    
		<?php 
            }
            ?>
		</ul> 
                            
                <div class="stars_footer">
                  <ul>
                    <li id="or2">Total people currently meditating</li>
                    <li id="wh2" > Total people meditated</li>
                    <li id="red2"> Total collective meditation time</li>
                  </ul>
                </div>                                           		
<?php 
            // Reset the global $the_post as this query will have stomped on it
            wp_reset_postdata();
        }
        ?>
                        </div>
    
                      <?php 
        echo $after_widget;
        ?>
 
    
<?php 
        $cache[$args['widget_id']] = ob_get_flush();
        wp_cache_set('widget_recent_intentions', $cache, 'widget');
    }