Commits

Fredrik Johansson committed cd8763c Merge

merge

  • Participants
  • Parent commits f3bf153, fe1cf15

Comments (0)

Files changed (4)

File classes/mtt-ui.php

 					'});</script>'
 			);
 		});
+		add_shortcode("cs_tournament",function($atts){
+			extract(shortcode_atts(
+				array(
+				'tournament_id' => '0',
+				),
+				$atts)
+			);
+			
+			
+			$url = 'http://csps1.cubeia.com/operator-api/rest/lobby/tournament/id/'.$tournament_id;
+		
+			$content = '';
+			try {
+				$tournament = null;
+				$transName = 'tournaments-'.$tournament_id; 
+				$cacheTime = 5; // Time in minutes between updates.
+				if(false === ($tournament = get_transient($transName) ) ){
+					//Get new $twitterData
+					$response = wp_remote_get( $url , array(
+						'method' => 'GET',
+						'timeout' => 15,
+						'redirection' => 5,
+						'httpversion' => '1.0',
+						'blocking' => true
+					)	
+					);
+					if( is_wp_error( $response ) ) {
+						$error_message = $response->get_error_message();
+						return "Tournament not found $url: $error_message";
+					}
+	
+					$tournament = json_decode($response['body'], false);
+					set_transient($transName, $tournament, 60 * $cacheTime);
+				}	
+
+				$content.='<h3>'.$tournament->params->NAME.'</h3>';
+				$content.='<p>Starts:'.$tournament->params->START_TIME.'</p>';
+				$content.='<p>Buy-In:'.$tournament->params->BUY_IN . ' + '.$tournament->params->FEE . ' </p>';
+				} catch(Exception $e) {
+					$content.= '<p>Unable to fetch tournament</p>';
+			}
+			
+			return $content;
+		});
 	}
 }

File cubeia-social.php

  Description: Plugin for integrating Cubeia Social poker into a WP installation.
  Plugin URI: http://www.cubeiasocial.com/
  License: GPLv2
- Version: 0.10
+ Version: 0.11
 */
 
 /*

File js/cs-tournaments.js

 			    // sort tournament according to start time
 			   	var list = data.tournamentList;
 				list.sort(function(a, b) {
-				    var aDate = moment.utc(a.params["START_TIME"]);
-				    var bDate = moment.utc(b.params["START_TIME"]);
-				    return aDate.millisecond() - bDate.millisecond();
+				    var aDate = parseInt(a.params["START_TIME"]);
+				    var bDate = parseInt(b.params["START_TIME"]);
+				    return aDate - bDate;
 				}); 
 				// render each table container
 				$(".cs-tournament-table-container").each(function(index, table) {
 				 	// one row for each tournament
 					for (var i = 0; i < list.length; i++) { 
 					    var tourn = list[i];
-					    // from UTC to local time
-					    var dateLocal = moment.utc(tourn.params["START_TIME"]).local().format('dddd hh:mm');
+					    
+					    var dateLocal = moment(parseInt(tourn.params["START_TIME"])).format('LLL');
 				     	// current status
 					    var stat = tourn.params["STATUS"];
 					    if(stat == 'REGISTERING' || stat == 'ANNOUNCED') {
 is valid from the first login or authentication of the user.   
 
 == Changelog ==
+= 0.11 =
+* Fixed turnament date format
 
 = 0.10 = 
 * Added shortcode [cs_achievements] that will display the achievement list for the logged in player.