Menu

#48 Pending challenges/mail notifications

open
nobody
5
2013-03-17
2013-03-17
sourceforge
No

Would you be able to add some kind of notification stating that you have a new message, or a new challenge?
ie: Place the number of challenges pending next to the pending challenges link in the menu
or, (less preferred) a popup saying theres a new message/challenge.

Discussion

  • sourceforge

    sourceforge - 2013-03-17

    I've been able to create the new message count. As long as you have a message to you in your mailbox, it will display how many, until they are archived.

    I'm new to sourceforge, php and sql in general, so forgive me if my code is ugly, yet it took almost all day to figure out.
    I had to remove the font-family and text-transform:lowercase from #navcontainer, as it made zeros look like the lowercase letter O

    <?php
    $tmpQuery=$_SESSION['playerID'];
    $tmpPlayers = mysql_query($tmpQuery);
    $tmpMessages = mysql_query("SELECT COUNT(toID) FROM " . $CFG_TABLE[communication] . " WHERE toID=".$tmpQuery." AND ack='0'");
    $numMessages = mysql_result($tmpMessages,0);
    ?>

    </head>
    <body>
    <div id="header">
    <div id="heading">WebChess</div>
    </div>
    <div id="content">
    <div id="navcontainer">
    <ul id="navlist">
    <li><a href="#continuegame"><?php echo gettext("Active Games"); ?></a></li>
    <li><a href="#invitations"><?php echo gettext("Pending Challenges"); ?></a></li>
    <li><a href="#messages"><?php echo gettext("Messages (".$numMessages.")"); ?></a></li>
    <li><a href="#challenge"><?php echo gettext("Challenge Others"); ?></a></li>
    <li><a href="#viewgame"><?php echo gettext("Replay"); ?></a></li>
    <li><a href="#preferences"><?php echo gettext("Preferences"); ?></a></li>
    <li><a href="#personalinfo"><?php echo gettext("Personal"); ?></a></li>
    <li><a href="#reload"><?php echo gettext("Reload"); ?></a></li>
    <li><a href="#logout"><?php echo gettext("Logout"); ?></a></li>
    </ul>

     
  • sourceforge

    sourceforge - 2013-03-18

    So I've made another change in mainmenu.php. It's not clean, but it works. I now have mail and challenge notifications.

    <?php
    $tmpQuery=$_SESSION['playerID'];
    $tmpMessages = mysql_query("SELECT COUNT(toID) FROM " . $CFG_TABLE[communication] . " WHERE toID=".$tmpQuery." AND ack='0'");
    $numMessages = mysql_result($tmpMessages,0);
    $tmpFromWhite = mysql_query("SELECT COUNT(gameID) FROM " . $CFG_TABLE[games] . " WHERE messageFrom='white' AND gameMessage='playerInvited' AND blackPlayer='".$tmpQuery."'");
    $fromWhite = mysql_result($tmpFromWhite,0);
    $tmpFromBlack = mysql_query("SELECT COUNT(gameID) FROM " . $CFG_TABLE[games] . " WHERE messageFrom='black' AND gameMessage='playerInvited' AND whitePlayer='".$tmpQuery."'");
    $fromBlack = mysql_result($tmpFromBlack,0);
    $challenges = $fromBlack + $fromWhite;
    ?>
    </head>
    <body>
    <div id="header">
    <div id="heading">WebChess</div>
    </div>
    <div id="content">
    <div id="navcontainer">
    <ul id="navlist">
    <li><a href="#continuegame"><?php echo gettext("Active Games"); ?></a></li>
    <li><a href="#invitations"><?php echo gettext("Challenges ( ".$challenges." )"); ?></a></li>
    <li><a href="#messages"><?php echo gettext("Messages ( ".$numMessages." )"); ?></a></li>
    <li><a href="#challenge"><?php echo gettext("Challenge Others"); ?></a></li>
    <li><a href="#viewgame"><?php echo gettext("Replay"); ?></a></li>
    <li><a href="#preferences"><?php echo gettext("Preferences"); ?></a></li>
    <li><a href="#personalinfo"><?php echo gettext("Personal"); ?></a></li>
    <li><a href="#reload"><?php echo gettext("Reload"); ?></a></li>
    <li><a href="#logout"><?php echo gettext("Logout"); ?></a></li>
    </ul>

     

Log in to post a comment.

MongoDB Logo MongoDB