Page 1 of 1

Mark notifications read properly

PostPosted: 04 Feb 2011, 05:51
by Jack
This is a reply to this thread:
viewtopic.php?f=6&t=578&p=2653#p2653

functions_notifications.php
find this function
Code: Select all
function getMarkup($author_id, $author_name, $type, $message_time, $misc1, $misc2, $misc3) {


replace with
Code: Select all
function getMarkup($alert_id,$author_id, $author_name, $type, $message_time, $misc1, $misc2, $misc3) {
   
      $markup = "";
      $longago = getLogoAgo($message_time);
   
      $sql = "SELECT markup FROM arrowchat_notifications_markup WHERE type='".$type."'";
      $result = mysql_query($sql);
      if ($result && mysql_num_rows($result) > 0) {
         $row = mysql_fetch_array($result);
         $markup = $row['markup'];
         
         $markup = str_replace("{alert_id}",$alert_id, $markup);
         $markup = str_replace("{author_name}", $author_name, $markup);
         $markup = str_replace("{author_id}", $author_id, $markup);
         $markup = str_replace("{longago}", $longago, $markup);
         $markup = str_replace("{message_time}", $message_time, $markup);
         $markup = str_replace("{misc1}", $misc1, $markup);
         $markup = str_replace("{misc2}", $misc2, $markup);
         $markup = str_replace("{misc3}", $misc3, $markup);
      }
      
      return $markup;

   }


receive_core.php
find
Code: Select all
$markup = getMarkup($author_id, $author_name, $type, $message_time, $misc1, $misc2, $misc3);


replace with
Code: Select all
$markup = getMarkup($alert_id, $author_id, $author_name, $type, $message_time, $misc1, $misc2, $misc3);


Head over to arrowchat admin panel:
Mange->Notifications

Append this onto the notification url:
Code: Select all
&noteAck={alert_id}

Now in whatever your main project is; throw this line of code somewhere:
Code: Select all
if(isset($_GET['noteAck'])){
         mysql_query(sprintf('UPDATE arrowchat_notifications SET alert_read=1,user_read=1 WHERE id=%d and to_id=%d',
                        intval($_GET['noteAck']),
                        $_SESSION['user_id']
                        ));
      }


Depending on how your application is setup you will have to mess with the current logged in user stuff.

Update: Just got done testing and this code should work.

Topic Closed

PostPosted: 07 Nov 2012, 12:40
by Staff Bot
This thread has been locked because the last post is greater than six months old. There is a good chance that the information in this thread is outdated. Please open a new topic if you wish to discuss this further.