Ejemplo n.º 1
0
function processNotifications($mid = null)
{
    if ($mid == null) {
        $mid = $_SESSION['mid'];
    }
    if (isset($_SESSION['email'])) {
        $email = $_SESSION['email'];
    } else {
        $query = "SELECT email FROM Mothers where mid={$mid}";
        $row = mysql_fetch_assoc(mysql_query($query));
        $email = $row['email'];
    }
    $query = "SELECT * FROM Notifications WHERE mid = {$mid};";
    $counter = 0;
    $result = mysql_query($query);
    if (!$result) {
        error_log(mysql_error());
    }
    while ($row = mysql_fetch_array($result)) {
        if ($row['status'] != 2 && $row['status'] != 8) {
            $counter = $counter + 1;
        }
        if ($row['status'] == 0) {
            $title = notificationTitle($row['ntype']);
            $body = notificationText($row['ntype']);
            $mail = generateNotMail($title, $email, $body);
            // determine this mother's consultant and generate an email.
            $consultant_query = "SELECT S.email FROM Mothers M LEFT JOIN Mothers_Scientists MS ON MS.mid=M.mid LEFT JOIN Scientists S ON S.sid=MS.sid WHERE M.mid={$mid};";
            $consultant_result = mysql_query($consultant_query);
            if (!$consultant_result) {
                error_log(mysql_error());
            } else {
                if (!mysql_num_rows($consultant_result)) {
                    error_log("Unable to determine consultant for Mother {$email}");
                } else {
                    $title = "Notification issued to {$email}.";
                    if ($row['ntype'] == 1) {
                        $body = "Latching ";
                    } else {
                        if ($row['ntype'] == 2) {
                            $body = "Sleepy ";
                        }
                    }
                    $body = "<h2>Notification issued to mother {$email}</h2><br />" . $body;
                    $consultant_row = mysql_fetch_assoc($consultant_result);
                    $mail = generateNotMail($title, $consultant_row['email'], $body);
                }
            }
        }
    }
    $_SESSION['num_not'] = $counter;
    $query = "UPDATE Notifications SET status = 1 WHERE status = 0 AND mid = {$mid};";
    $result = mysql_query($query);
}
Ejemplo n.º 2
0
?>
</head>
<body>
<div data-role='page'>
<?php 
include 'header.php';
?>
<div data-role='content'>
<h1>Notifications</h1>
<?php 
$query = "SELECT * FROM Notifications WHERE mid = " . $_SESSION['mid'] . " AND status = 1 ORDER BY NotificationIssued DESC;";
$result = mysql_query($query);
if (!$result) {
    error_log(mysql_error());
} else {
    if (!mysql_num_rows($result)) {
        echo "<h3>" . _("You have no unread notifications") . "</h3>";
    }
    while ($row = mysql_fetch_assoc($result)) {
        echo "<b>Date & Time:</b> " . getDateTime($row['NotificationIssued']) . "    <br /><b>Problem:</b> " . notificationTitle($row['ntype']) . "<br />";
        echo notificationText($row['ntype']);
        echo "<form method=\"post\" action=\"m.notifications.post.php\"><input type=\"hidden\" name=\"MarkRead\" value=\"" . $row['nid'] . "\"/><input value=\"" . _("Mark As Read") . "\" type=\"submit\"></form><br/>";
    }
}
include 'footer.php';
?>
</div>
</div>
</body>
</html>
Ejemplo n.º 3
0
            -->
          </div>

          <div id="past" class="content supplement">
            <h1><img src="image/rnotification.gif" width=48 height=48 alt=""/> <?php 
echo _("Read Notifications");
?>
</h1>
            <div class='notificationText'>
            </div>
            <!--
            <?php 
$query = "SELECT * FROM Notifications WHERE mid = " . $_SESSION['mid'] . " AND status = 2 ORDER BY NotificationIssued DESC;";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
    echo "<b>" . _("Date &amp; Time") . ":</b> " . getDateTime($row['NotificationIssued']) . "    <br /><b>" . _("Problem") . ":</b> " . notificationTitle($row['ntype']) . "<br />";
    echo notificationText($row['ntype']);
}
?>
            -->
          </div>
        </div>
      </div>
    </div>
  </div>
  <?php 
page_footer();
?>
  </div>
  <script type='text/javascript' src='js/notifications.js'></script>
  <script type='text/javascript'>