/**
  *
  * @return Game_Model_Gamesessionplayers
  */
 public static function getInstance()
 {
     if ($pReload || is_null(self::$_Instance)) {
         // process
         self::$_Instance = new self();
     }
     return self::$_Instance;
 }
 /**
  *
  */
 public function usergamesAction()
 {
     $data = array();
     $game = $this->_getParam('game', '');
     $user = $this->_getParam('user');
     if ($user) {
         $user = Model_Users::getInstance()->get($user);
     } else {
         $user = Model_Users::current_user();
     }
     $params = array('user' => $user->identity());
     $game_type = $game ? Game_Model_Gametypes::game_type($game) : NULL;
     $user_sessions = Game_Model_Gamesessionplayers::getInstance()->find($prarams);
     foreach ($user_sessions as $us) {
         $session = $us->session();
         if ($game_type && !$session->is_game_type($game_type)) {
             continue;
         }
         $out[] = $session->toArray(TRUE);
     }
     $this->_store('id', $out, 'name');
 }
 public function activate($pFor_user = NULL)
 {
     $game_type = $this->game_type();
     $gtid = $game_type->identity();
     if ($pFor_user) {
         $uid = Zupal_Domain_Abstract::_as($pFor_user, 'Model_Users', TRUE);
     } elseif ($user = Model_Users::current_user()) {
         $uid = $user->identity();
     } else {
         throw new Exception(__METHOD__ . ': no user present');
     }
     $params = array('game_type' => $gtid, 'user' => $uid);
     $other_player_sessions = Game_Model_Gamesessionplayers::getInstance()->find($params);
     foreach ($other_player_sessions as $other_player_session) {
         if ($other_player_session->game_session == $this->identity()) {
             $other_player_session->active = 1;
         } else {
             $other_player_session->active = 0;
         }
         $other_player_session->save();
     }
     /*
     
             $bond = new Model_Zupalbonds();
             if (!$pFor_user):
                 $pFor_user = Model_Users::current_user();
                 if (!$pFor_user):
                     throw new Exception(__METHOD__ . ': trying to bond missing user to session');
                 endif;
             endif;
     
             $bond->type = 'active';
             $bond->set_to_atom($this);
             $bond->set_from_atom($pFor_user);
             $bond->set_bond_atom($this->game_type());
     
             $params = array(
                 'from_atom' => $bond->from_atom()->get_atomic_id(),
                 'bond_atom' => $bond->to_atom()->get_atomic_id(),
                 'type' => 'active'
                 );
     
            $other_bonds = $bond->find($params);
     
            $other_bond = array_pop($other_bonds);
     
            if (count($other_bonds)):
                 foreach($other_bonds as $extra_bond):
                     $extra_bond->delete();
                 endforeach;
            endif;
     
            // find an existing bond that is a syner-G game activation for this user.
     
            if ($other_bond):
                 $other_bond->set_to_atom($this);
                 $other_bond->save();
            else:
                 $bond->save();
            endif;
     */
 }