当前位置: 首页>>代码示例>>PHP>>正文


PHP notice::send方法代码示例

本文整理汇总了PHP中notice::send方法的典型用法代码示例。如果您正苦于以下问题:PHP notice::send方法的具体用法?PHP notice::send怎么用?PHP notice::send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在notice的用法示例。


在下文中一共展示了notice::send方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendPM

 function sendPM(User $FromUser, $message)
 {
     $message = htmlentities($message, ENT_NOQUOTES, 'UTF-8');
     require_once l_r('lib/message.php');
     $message = message::linkify($message);
     if ($FromUser->isSilenced()) {
         notice::send($FromUser->id, $this->id, 'PM', 'No', 'Yes', l_t('Could not deliver message, you are currently silenced.') . '(' . $FromUser->getActiveSilence()->reason . ')', l_t('To:') . ' ' . $this->username, $this->id);
         return false;
     } else {
         if ($this->isUserMuted($FromUser->id)) {
             notice::send($FromUser->id, $this->id, 'PM', 'No', 'Yes', l_t('Could not deliver message, user has muted you.'), l_t('To:') . ' ' . $this->username, $this->id);
             return false;
         } else {
             notice::send($this->id, $FromUser->id, 'PM', 'Yes', 'Yes', $message, $FromUser->username, $FromUser->id);
             $this->setNotification('PrivateMessage');
             notice::send($FromUser->id, $this->id, 'PM', 'No', 'Yes', l_t('You sent:') . ' <em>' . $message . '</em>', l_t('To:') . ' ' . $this->username, $this->id);
             return true;
         }
     }
 }
开发者ID:Yoyoyozo,项目名称:webDiplomacy,代码行数:20,代码来源:user.php

示例2: cancelGame

 public function cancelGame(array $params)
 {
     global $DB, $Game;
     $gameID = (int) $params['gameID'];
     $DB->sql_put("BEGIN");
     require_once l_r('gamemaster/game.php');
     $Variant = libVariant::loadFromGameID($gameID);
     $Game = $Variant->processGame($gameID);
     if ($Game->phase == 'Diplomacy' or $Game->phase == 'Retreats' or $Game->phase == 'Builds') {
         $Game->setCancelled();
         // This throws an exception, since it expects to be run from within the
         // main gamemaster loop, and wants to stop the loop from continuing to use this game after
         // it has been cancelled. But it also contains its own commit, so the exception does not prevent
         // the game from being cancelled (it is messy though).
         // This point after $Game->setCancelled(); shouldn't actually be reached.
     } elseif ($Game->phase == 'Finished') {
         /* 
          * Some special action is needed; this game has already finished.
          * 
          * We need to get back all winnings that have been distributed first, then we need to 
          * return all starting bets.
          */
         $transactions = array();
         $sumPoints = 0;
         // Used to ensure the total points transactions add up roughly to 0
         $tabl = $DB->sql_tabl("SELECT type, points, userID, memberID FROM wD_PointsTransactions WHERE gameID = " . $Game->id . " FOR UPDATE");
         // Lock it for update, so other transactions can't interfere with these ones
         while (list($type, $points, $userID, $memberID) = $DB->tabl_row($tabl)) {
             if (!isset($transactions[$userID])) {
                 $transactions[$userID] = array();
             }
             if (!isset($transactions[$userID][$type])) {
                 $transactions[$userID][$type] = 0;
             }
             if ($type != 'Bet') {
                 $points = $points * -1;
             }
             // Bets are to be credited back, everything else is to be debited
             if ($type != 'Supplement') {
                 $sumPoints += $points;
             }
             $transactions[$userID][$type] += $points;
         }
         // Check that the total points transactions within this game make sense (i.e. they add up to roughly 0 accounting for rounding errors)
         if ($sumPoints < count($transactions) * -1 or count($transactions) < $sumPoints) {
             throw new Exception(l_t("The total points transactions (in a finished game) add up to %s, but there are %s members; " . "cannot cancel game with an unusual points transaction log.", $sumPoints, count($transactions)), 274);
         }
         // The points transactions make sense; we can now try and reverse them.
         // Get the current points each user has
         $tabl = $DB->sql_tabl("SELECT u.id, u.points FROM wD_Users u INNER JOIN wD_PointsTransactions pt ON pt.userID = u.id WHERE pt.gameID = " . $Game->id . " GROUP BY u.id, u.points " . " FOR UPDATE");
         // Lock it for update, so other transactions can't interfere with these ones
         $pointsInAccount = array();
         $pointsInPlay = array();
         while (list($userID, $points) = $DB->tabl_row($tabl)) {
             $sumPoints = 0;
             foreach ($transactions[$userID] as $type => $typePoints) {
                 $sumPoints += $typePoints;
             }
             if ($points + $sumPoints < 0) {
                 // If the user doesn't have enough points on hand to pay back the points transactions for this game we will need to supplement him the points to do it:
                 $supplementPoints = -($points + $sumPoints);
                 $points += $supplementPoints;
                 $DB->sql_put("INSERT INTO wD_PointsTransactions ( type, points, userID, gameID ) VALUES ( 'Supplement', " . $supplementPoints . ", " . $userID . ", " . $Game->id . ")");
                 $DB->sql_put("UPDATE wD_Users SET points = " . $points . " WHERE id = " . $userID);
             }
             // Now we have given the user enough points so their points transactions for this game can definitely be undone:
             $DB->sql_put("INSERT INTO wD_PointsTransactions ( type, points, userID, gameID ) VALUES ( 'Correction', " . $sumPoints . ", " . $userID . ", " . $Game->id . ")");
             $points += $sumPoints;
             $DB->sql_put("UPDATE wD_Users SET points = " . $points . " WHERE id = " . $userID);
             // Now check that they don't need a supplement to bring their total points in play back up to 100:
             $pointsInPlay = User::pointsInPlay($userID);
             if ($points + $pointsInPlay < 100) {
                 $supplementPoints = 100 - ($points + $pointsInPlay);
                 $points += $supplementPoints;
                 $DB->sql_put("INSERT INTO wD_PointsTransactions ( type, points, userID, gameID ) VALUES ( 'Supplement', " . $supplementPoints . ", " . $userID . ", " . $Game->id . ")");
                 $DB->sql_put("UPDATE wD_Users SET points = " . $points . " WHERE id = " . $userID);
             }
             notice::send($userID, $Game->id, 'Game', 'No', 'No', l_t("This game has been cancelled after having finished (usually to undo the effects of cheating). " . "%s points had to be added/taken from your account to undo the effects of the game. " . "Please contact the mod team with any queries.", $sumPoints, $points), $Game->name, $Game->id);
         }
         // Now backup and erase the game from existence, then commit:
         processGame::eraseGame($Game->id);
     } else {
         throw new Exception(l_t('This game is in phase %s, so it can\'t be cancelled', $Game->phase), 987);
     }
     // $DB->sql_put("COMMIT"); // $
     return l_t('This game was cancelled.');
 }
开发者ID:Yoyoyozo,项目名称:webDiplomacy,代码行数:87,代码来源:adminActions.php

示例3: send

 function send($keep, $private, $text, $fromCountryID = null)
 {
     notice::send($this->userID, $this->gameID, 'Game', $keep, $private, $text, $this->Game->name, $this->gameID);
 }
开发者ID:Yoyoyozo,项目名称:webDiplomacy,代码行数:4,代码来源:member.php

示例4: sendToWatchers

 function sendToWatchers($keep, $text)
 {
     global $DB;
     $tabl = $DB->sql_tabl('SELECT userID FROM wD_WatchedGames WHERE gameID=' . $this->Game->id);
     while ($watch = $DB->tabl_hash($tabl)) {
         notice::send($watch['userID'], $this->Game->id, 'Game', $keep, 'No', $text, $this->Game->name, $this->Game->id);
     }
 }
开发者ID:Yoyoyozo,项目名称:webDiplomacy,代码行数:8,代码来源:members.php


注:本文中的notice::send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。