/**
  * Public function that creates a single instance
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 /**
  * Return JSON object containing statistics for currently logged in user.
  */
 private function json_getStatistics()
 {
     $result = array();
     $manager = SapphireWavesManager::getInstance();
     $stats_manager = SapphireWavesStatisticsManager::getInstance();
     if ($_SESSION['logged']) {
         $user = $manager->getSingleItem($manager->getFieldNames(), array('user' => $_SESSION['uid']));
         if (is_object($user)) {
             $statistics = $stats_manager->getItems($stats_manager->getFieldNames(), array('user' => $user->id), array('timestamp'));
             if (count($statistics) > 0) {
                 foreach ($statistics as $statistic) {
                     $result[] = array($statistic->usage, $statistic->timestamp);
                 }
             }
         }
     }
     print json_encode($result);
 }