XuM
Full Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору alexsun я скоро выложу МОД для punbb на тему отметки прочитанным Добавлено punbb.org почемуто не ресолвится меня, поэтому выкладываю сюда. 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); } } |
---------- В этом нет ничего сложного. Просто нужно нажимать нужные клавиши в нужное время!(с) И.С. Бах |
|