Ejemplo n.º 1
0
 private function sendOpenIDNotifications($msg, $txtMsgKey, $txtMsgSection, $inputData, $objSender, $isPublic)
 {
     // First: load this users OpenID notification urls
     $db = Neuron_DB_Database::__getInstance();
     $openid_rows = Neuron_GameServer_Mappers_PlayerMapper::getOpenIDs($this);
     if (count($openid_rows) > 0) {
         $text = $this->getRightLanguage();
         // Load OpenID accounts and send Browser Games Hub notifications
         $objNot = new BrowserGamesHub_Notification($msg, time(), $text->getCurrentLanguage());
         $objNot->setIcon(STATIC_URL . 'icon.png');
         $objNot->setId($txtMsgSection, $txtMsgKey);
         $objNot->setTargetData($this->getBrowserBasedGamesData());
         if ($objSender instanceof Dolumar_Players_Player) {
             $objNot->setSenderData($objSender->getBrowserBasedGamesData());
         }
         // Keep in mind that the notification does not like actual names,
         // so we will replace all key names with their numeric value.
         $keys = array_keys($inputData);
         $replace_keys = array();
         foreach ($keys as $k => $v) {
             if ($v != 'actor') {
                 $replace_keys[$v] = '{' . $k . '}';
             } else {
                 $replace_keys[$v] = '{target}';
             }
         }
         $objNot->setSkeleton(Neuron_Core_Tools::putIntoText($text->get($txtMsgKey, $txtMsgSection, 'notifications'), $replace_keys));
         $desc = $text->get($txtMsgKey . '_long', $txtMsgSection, 'notifications', '');
         if (!empty($desc)) {
             $objNot->setDescription(Neuron_Core_Tools::putIntoText($desc, $replace_keys));
         }
         // Take all the value strings and put them in there aswell
         foreach ($inputData as $v) {
             if ($v instanceof Dolumar_Players_Player) {
                 $objNot->addArgument($v->getName(), 'user', $v->getBrowserBasedGamesData());
             } elseif ($v instanceof Neuron_GameServer_Interfaces_Logable) {
                 $objNot->addArgument($v->getName(), 'text');
             } else {
                 $objNot->addArgument($v, 'text');
             }
         }
         // Visibliity
         $objNot->setVisibility($isPublic ? 'public' : 'private');
         $this->onSendNotifications($objNot);
         // Send the notification
         foreach ($openid_rows as $v) {
             $objNot->send($v['notify_url']);
         }
     }
 }