1 <?php
2 /**
3 * XLRstats : Real Time Player Stats (http://www.xlrstats.com)
4 * (CC) BY-NC-SA 2005-2013, Mark Weirath, Özgür Uysal
5 *
6 * Licensed under the Creative Commons BY-NC-SA 3.0 License
7 * Redistributions of files must retain the above copyright notice.
8 *
9 * @link http://www.xlrstats.com
10 * @license Creative Commons BY-NC-SA 3.0 License (http://creativecommons.org/licenses/by-nc-sa/3.0/)
11 * @package app.Controller
12 * @since XLRstats v3.0
13 * @version 0.1
14 */
15
16
17 class PlayerActivitiesController extends AppController {
18
19 /**
20 * Sets models we are using
21 *
22 * @var array
23 */
24 public $uses = array('PlayerStat', 'PlayerActivity');
25
26 //-------------------------------------------------------------------
27
28 /**
29 * Returns player activity
30 *
31 * @param null $playerID player ID
32 * @return mixed
33 */
34 public function view($playerID = null) {
35 $player = $this->PlayerStat->find('first', array (
36 'conditions' => array(
37 'PlayerStat.id' => $playerID,
38 ),
39 )
40 );
41
42 $guid = $player['Player']['guid'];
43
44 try {
45 $activity = $this->PlayerActivity->find('all', array(
46 'conditions' => array(
47 'PlayerActivity.guid' => $guid
48 ),
49 'order' => array(
50 'PlayerActivity.came' => 'asc'
51 )
52 )
53 );
54 } catch (Exception $e) {
55 $activity = null;
56 }
57
58 if ($this->request->is('requested')) {
59 return $activity;
60 } else {
61 $this->set('activity', $activity);
62 }
63
64 return null;
65 }
66
67 }