Topic: Пометка новых сообщений

????? ?? ??????? ???, ????? ??? ????????? ?????? ?????????, ? ???? ????????? ????????? ??????? "?????"? ? ?? ???-?? ???????? ????? ??? ?????? "???????? ??? ?????? ??? ???????????", ?.?. ??? ????? ?? ??? ?????????...

2

Re: Пометка новых сообщений

Ïðîáëåìà â òîì, ÷òî êàê òû îïðåäåëèøü, ÷òî íóæíî óáðàòü ñ òåìû ïîìåòêó «íîâîå»? Íåïîíÿòíî... Â ýòîì âåñü ïðèêîë è ñîñòîèò. Õîòÿ ïî-ìîåìó çäåñü ñ ýòèì âñå â ïîðÿäêå

3

Re: Пометка новых сообщений

Íó âåäü â phpbb2 òàêîå ðåàëèçîâàíî!

4 (edited by XuMiX 2004-11-05 20:10)

Re: Пометка новых сообщений

viewtopic.php
-----8<------
~110 ??????
if (!$cookie['is_guest'])
$result = $db->query('SELECT t.subject, t.closed, t.sticky, t.num_replies, t.last_post_id, t.last_post, f.id, f.forum_name, f.moderators, f.closed AS forum_closed, f.admmod_only, s.user_id AS is_subscribed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON t.forum_id=f.id LEFT JOIN '.$db->prefix.'subscriptions AS s ON (s.topic_id=t.id AND s.user_id='.$cur_user['id'].') WHERE t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
else
$result = $db->query('SELECT t.subject, t.closed, t.sticky, t.num_replies, t.last_post_id, t.last_post, f.id, f.forum_name, f.moderators, f.closed AS forum_closed, f.admmod_only, 0 FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON t.forum_id=f.id WHERE t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
~118 ?????? list($subject, $closed, $sticky, $num_replies, $last_post_id, $last_post, $forum_id, $forum_name, $moderators, $forum_closed, $admmod_only, $is_subscribed) = $db->fetch_row($result);

+++  ????? $footer_style =.... ?????????
// Create/Update topic view session
if($cur_user['last_visit'] < $last_post)
setcookie('puntopic_'.$last_post_id, time(), (time()+$pun_config['o_timeout_visit']), $cookie_path, $cookie_domain, $cookie_secure);
------------->8--------

viewforum.php
~165? ??????
---if (!$cookie['is_guest'] && $cur_topic['last_post'] > $cur_user['last_visit'] && $cur_topic['moved_to'] == null)
+++if (!$cookie['is_guest'] && new_topic($cur_topic['last_post_id'], $cur_topic['last_post']) && $cur_topic['moved_to'] == null)

index.php
~88? ??????
---if (!$cookie['is_guest'] && $cur_forum['last_post'] > $cur_user['last_visit'])
+++if (!$cookie['is_guest'] && new_topic($cur_forum['last_post_id'], $cur_forum['last_post']))


include/functions.php
+++
function new_topic($id, $last_post)
{
    global $cur_user;

    if(isset($_COOKIE['puntopic_'.$id]))
    {
        if($_COOKIE['puntopic_'.$id] < $last_post)
            return true;
    }else
    {
        if($cur_user['last_visit'] < $last_post)
            return true;
    }
    return false;
}

Re: Пометка новых сообщений

Ñïàñèáû çà äàííûé âàðèàíò ðåøåíèÿ åíòîé ïðîáëåìû - íî â íåì åñòü íåáîëüøàÿ íåòî÷íîñòü... Åñëè â ãðóïïå åñòü íåñêîëüêî íåïðî÷èòàííûõ òåì, òî ïðè ïðî÷òåíèè òîëüêî âåðõíåé â ñïèñêå òåìû âñÿ ãðóïïà ñòàíîâèòñÿ "ïðî÷òåííîé", íåñìîòðÿ íà îñòàâøèåñÿ íåïðî÷òåííûìè îñòàëüíûå òåìû...

6

Re: Пометка новых сообщений

ÈÌÕÎ åäèíñòâåííûé âàðèàíò ó÷èòûâàòü êàæäîå íåïðî÷òåííîå ñîîáùåíèå, ýòî õðàíèòü âñþ èíôó â îòäåëüíîé òàáëèöå. òîãäà ãåíåðàöèÿ ñïèñêà íåïðî÷èòàííûõ ñîîáùåíèé çàìåòíî çàìåäëèò îòêðûòèå ôîðóìà.

Big Brother is not watching you, Big Brother is testing you

7 (edited by XuMiX 2004-11-19 03:15)

Re: Пометка новых сообщений

2 Death Angel: ??, ???? ????? ????, ??? ???? ?????? ??? ???, ????? ??????? ?? ????????? ??? + ??????????? ???????? ???????????? ??? ????? ?????? ? ???????????? ??????.

8

Re: Пометка новых сообщений

lang/en_common.php

find :
    'Mark all as read'        =>    'Mark all forums as read',

replace:
    'Mark all as read'        =>    'Mark forum as read',

include/functions.php

add:
     function explode_haveread($var){
    global $haveread;
    $haveread[$var]=true;
  }

idex.php

find: if (!$cookie['is_guest'] &&($cur_forum['last_post'] > $cur_user['last_post']))
delete it, and add:
    $f_id = $cur_forum['fid'];
     $forum_id = $f_id;

    $new_cookie="pun-new-$forum_id";
    $haveread_cookie="pun-haveread-$forum_id";

        $res = $db->query('Select last_post_id as f_maxid FROM '.$db->prefix.'forums WHERE id='.$f_id.'');
            $f_maxid = $db->result($res,0);
        if(!IsSet($$new_cookie)){
                $$new_cookie='0';
        }
      $use_haveread=false;
           if(IsSet($$haveread_cookie)) {
           $arr=explode(".", $$haveread_cookie);
           $old_message=reset($arr);
           array_walk($arr, "explode_haveread");
           $use_haveread=true;
           }
           else{
               $old_message=$$new_cookie;
    }
              $isnew=false;
             if($use_haveread){
              if ($old_message<$f_maxid) {
                  if(!IsSet($haveread[$f_maxid])) {
                    $isnew=true;
                    }
                  }
          }
              elseif($old_message<$f_maxid){
                $isnew=true;
        }
       if($isnew)
{
                $icon = '<img src="img/'.$pun_config['o_default_style'].'_new.png" width="16" height="16" alt="">';
        }
    else
        icon = ' ';

misc.php

find: elseif ($action == 'markread') and replace whole elsif with:
    elseif ($action == 'markread')
{
           $forum_id = intval($_GET['fid']);
           
    $new_cookie="pun-new-$forum_id";
    $haveread_cookie="pun-haveread-$forum_id";
   
        $res = $db->query('Select last_post_id as max_id FROM '.$db->prefix.'forums WHERE id='.$forum_id.'');
        //$aryRow=$q->getrow();
        $aryRow= $db->fetch_array($res);
        if(isset($aryRow['max_id'])){
            $max_id=$aryRow['max_id'];
            $$new_cookie=$max_id;
            SetCookie($new_cookie,$$new_cookie,time()+ 31536000);
            SetCookie($haveread_cookie,$$new_cookie); //destroy session cookie
            unset($$haveread_cookie);
        }
       
        redirect($_SERVER['HTTP_REFERER'], $lang_misc['Mark read redirect']);
    }
// end marking

viewforum.php

find:
<td class="punright" style="width: 19%; white-space: nowrap"><b><?php echo $post_link ?></b></td>
after add:
<td><?php echo '  <b><a href="misc.php?action=markread&fid='.$id.'">'.$lang_common['Mark forum read'].'</b></a>' ?></td>
   
find:
            if (!$cookie['is_guest'] && $cur_topic['last_post'] > $cur_user['last_visit'] && $cur_topic['moved_to'] == null)
        {
            if ($cur_user['show_img'] == '1')
                $icon = '<img src="img/'.$cur_user['style'].'_new.png" width="16" height="16" alt="">';
            else
                $icon = '<span class="puntext"><b>•</b></span>';

            $subject = '<b>'.$subject.'</b>';
            //New posts in the topic
            $subject_new_posts = '[ <a href="viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.$lang_common['New posts info'].'">'.$lang_common['New posts'].'</a> ]';
        }
        else
        {
            $icon = ' ';
            $subject_new_posts = null;
        }

replace with:

$forum_id = $id;
$new_cookie="pun-new-$forum_id";
$haveread_cookie="pun-haveread-$forum_id";
$t_id = $cur_topic['id'];

    $res = $db->query('Select last_post_id as t_maxid FROM '.$db->prefix.'topics WHERE id='.$cur_topic['id'].'');
    $t_maxid = $db->result($res,0);
    if(!IsSet($$new_cookie)){
        $$new_cookie='0';
    }

    $use_haveread=false;
    if(IsSet($$haveread_cookie)) {
        $arr=explode(".", $$haveread_cookie);
        $old_message=reset($arr);
        array_walk($arr, "explode_haveread");
        $use_haveread=true;
    }
    else{
        $old_message=$$new_cookie;
    }

   $isnew=false;
   
        if($use_haveread){
          if ($old_message<$t_maxid) {
            if(!IsSet($haveread[$t_maxid])) {
              $isnew=true;
            }
          }
        }
        elseif($old_message<$t_maxid){
          $isnew=true;
        }
   
         if($isnew){
                   //New posts in the topic
        $subject_new_posts = '[ <a href="viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.$lang_common['New posts info'].'"><font color=orange>New</font></a> ]';
      }
      else{
            $subject_new_posts = null;}

viewtopic.php

find:
else if (isset($_GET['action']) && $_GET['action'] == 'new' && !$cookie['is_guest'])
{
      $result = $db->query('SELECT MIN(id) FROM '.$db->prefix.'posts WHERE topic_id='.$id.' AND posted >'.$cur_user['last_visitonline']) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
  $first_new_post_id = $db->result($result, 0);

replace with
else if (isset($_GET['action']) && $_GET['action'] == 'new')
{
$res = $db->query('Select id from '.$db->prefix.'posts where topic_id='.$id.' ORDER BY id');
$rec = $db->fetch_row($res);
   While($rec){
       $msgarr[]=$rec[0];
        $rec = $db->fetch_row($res);
        }
$res = $db->query('Select forum_id from '.$db->prefix.'topics where topic_id='.$id.'');
$forum_id = $db->result($res,0);

$new_cookie="pun-new-$forum_id";
$haveread_cookie="pun-haveread-$forum_id";

$arr=explode(".", $$haveread_cookie);                         

        function newmsg($a, $b) {
        $al = sizeof($a);
        $bl = sizeof($b);
        sort($a);
                               
         if ($b[$bl-1]<$a[0]) return $b[$bl-1];
       
        $i = 0; $j = 0;
        while(1) {
        if ($a[$i] < $b[$j]) {
                   $i++;
             if ($i == $al) return $b[$j];
             } else if($a[$i] == $b[$j]) {
                $j++;
            if ($j == $bl) return $b[$bl-1];
                } else {
               return $b[$j];
              }
          }
        }

    $first_new_post_id = newmsg($arr, $msgarr);
   
   
find:
$footer_style = 'topic';
require $pun_root.'footer.php';

before add:
$new_cookie="pun-new-$forum_id";
$haveread_cookie="pun-haveread-$forum_id";


    if(!IsSet($$new_cookie)){
      $$new_cookie='0';
    }

    $use_haveread=false;
    if(IsSet($$haveread_cookie)) {
      $arr=explode(".", $$haveread_cookie);
      $old_message=@reset($arr);
      array_walk($arr, "explode_haveread");
      $use_haveread=true;
    }
    else{
      $old_message=$$new_cookie;
    }
   
   
  $res = $db->query('Select id from '.$db->prefix.'posts where topic_id='.$id.' ORDER BY id');
  $rec = $db->fetch_row($res);

  While($rec){
    $headers[]=$rec;
    $rec = $db->fetch_row($res);
     }
      $madechange=false;
     @reset($headers);
    $row=@current($headers);
      while(!empty($row[0])){

        if(empty($haveread[$row[0]]) && $row[0] > $old_message){
          $madechange=true;
          if(empty($$haveread_cookie)){
            $haveread[$$new_cookie] = true;
            $$haveread_cookie=$$new_cookie;
          }
          $$haveread_cookie.=".";
          $$haveread_cookie.=$row[0];
        }
        $haveread[$row[0]] = true;
        $max_id=$row[0];
        $row=next($headers);
      }
      if ($madechange) {
        SetCookie($haveread_cookie,$$haveread_cookie,0);
      }
   
 

  if($UseCookies){
    if($$new_cookie<$max_id){
      $$new_cookie=$max_id;
      SetCookie($new_cookie,$$new_cookie,time()+ 31536000);
    }
  }

9 (edited by alrond 2004-12-13 14:08)

Re: Пометка новых сообщений

?? ???????? sad ???????
Parse error: parse error in /srv/www/htdocs/web1/html/punbb/index.php on line 126

??? ????? ????

$f_id = $cur_forum['fid'];
     $forum_id = $f_id;

    $new_cookie="pun-new-$forum_id";
    $haveread_cookie="pun-haveread-$forum_id";

        $res = $db->query('Select last_post_id as f_maxid FROM '.$db->prefix.'forums WHERE id='.$f_id.'');
            $f_maxid = $db->result($res,0);
        if(!IsSet($$new_cookie)){
                $$new_cookie='0';
        }
      $use_haveread=false;
           if(IsSet($$haveread_cookie)) {
           $arr=explode(".", $$haveread_cookie);
           $old_message=reset($arr);
           array_walk($arr, "explode_haveread");
           $use_haveread=true;
           }
           else{
               $old_message=$$new_cookie;
    }
              $isnew=false;
             if($use_haveread){
              if ($old_message<$f_maxid) {
                  if(!IsSet($haveread[$f_maxid])) {
                    $isnew=true;
                    }
                  }
          }
              elseif($old_message<$f_maxid){
                $isnew=true;
        }
       if($isnew)
{
                $icon = '<img src="img/'.$pun_config['o_default_style'].'_new.png" width="16" height="16" alt="">';
        }
    else
        icon = ' ';
//    if (!$cookie['is_guest'] && $cur_forum['last_post'] > $cur_user['last_visit'])
//    {
//        if ($cur_user['show_img'] == '1')
//            $icon = '<img src="img/'.$cur_user['style'].'_new.png" width="16" height="16" alt="">';
//        else
//            $icon = '<span class="puntext"><b>?</b></span>';
//    }
//    else
//        $icon = ' ';

10

Re: Пометка новых сообщений

??? ? ???? ????, ??? ?????????
http://punbb.org/forums/viewtopic.php?id=5297