Discuz教程网

[代码修改] 【Discuz!X1.5】定时发布主题

[复制链接]
authicon dly 发表于 2011-3-12 14:34:02 | 显示全部楼层 |阅读模式
首先,升级数据表,添加一个字段
  1. ALTER TABLE `pre_forum_thread` ADD `setpublishtime` INT( 10 ) NOT NULL DEFAULT '0'
复制代码


以下是文件修改操作:

template\default\forum\post.htm找到
  1. <!--{if $_G[gp_action] == 'edit' && $isorigauthor && ($isfirstpost && $thread['replies'] < 1 || !$isfirstpost) && !$rushreply && $_G['setting']['editperdel']}-->
复制代码
上面加
  1.                                                 <!--{if $_G[gp_action] == 'newthread' || ($_G[gp_action] == 'edit' && $isfirstpost) && $_G['adminid'] == '1' }-->
  2.                                                 <script type="text/javascript" src="static/js/calendar.js"></script>
  3.                                                 <input type="text" class="px" name="setpublishtime" value="$thread[setpublishtime]" style="width: 25em;margin-top: 5px;" tabindex="1"> 定时发布时间设定 <font color="red">[仅管理员可见]</font>
  4.                                                 <!--{/if}-->
复制代码

source\include\post\post_editpost.php
找到
  1. $thread['freecharge'] = $_G['setting']['maxchargespan'] && TIMESTAMP - $thread['dateline'] >= $_G['setting']['maxchargespan'] * 3600 ? 1 : 0;
复制代码
下面加
  1. $thread['setpublishtime'] = $thread['setpublishtime'] ? dgmdate($thread['setpublishtime'], 'Y-m-d H:i') : '';
复制代码

找到
  1. $displayorder = empty($_G['gp_save']) ? ($thread['displayorder'] == -4 ? 0 : $thread['displayorder']) : -4;
复制代码
下面加
  1. $setpublishtime = ($_G['gp_setpublishtime'] && ($_G['adminid'] == '1')) ? strtotime($_G['gp_setpublishtime']) : 0;
复制代码
找到
  1. DB::query("UPDATE ".DB::table('forum_thread')." SET typeid='$typeid', sortid='$sortid', subject='$subject', readperm='$readperm', price='$price' $authoradd $polladd ".($_G['forum_auditstatuson'] && $audit == 1 ? ",displayorder='$displayorder', moderated='1'" : ",displayorder='$displayorder'").", status='$thread[status]'
复制代码

后加
  1. ,setpublishtime='$setpublishtime'
复制代码

source\include\post\post_newthread.php
找到

  1. $_G['gp_hiddenreplies'] && $thread['status'] = setstatus(2, 1, $thread['status']);
复制代码
下面加
  1. $setpublishtime = ($_G['gp_setpublishtime'] && ($_G['adminid'] == '1')) ? strtotime($_G['gp_setpublishtime']) : 0;
复制代码
找到
  1. DB::query("INSERT INTO ".DB::table('forum_thread')." (fid, posttableid, readperm, price, typeid, sortid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, special, attachment, moderated, status, isgroup
复制代码
后加
  1. , setpublishtime
复制代码
找到
  1. VALUES ('$_G[fid]', '$posttableid', '$readperm', '$price', '$typeid', '$sortid', '$author', '$_G[uid]', '$subject', '$_G[timestamp]', '$_G[timestamp]', '$author', '$displayorder', '$digest', '$special', '0', '$moderated', '$thread[status]', '$isgroup'
复制代码
后加
  1. , '$setpublishtime'
复制代码

template\default\forum\forumdisplay_list.htm找到
  1. <!--{if $_G[setting][forumseparator] == 1 && $separatepos == $key + 1}-->
复制代码

上加

  1. <!--{if ($thread['setpublishtime'] < $_G['timestamp']) || $_G[adminid] == '1' }-->
复制代码

找到

  1.                                 <!--{/loop}-->
  2.                         <!--{else}-->
  3.                                 <tbody><tr><th colspan="{if !$_G['gp_archiveid'] && $_G['forum']['ismoderator']}6{else}5{/if}"><p class="emp">{lang forum_nothreads}</p></th></tr></tbody>
复制代码

上加
  1.                                 <!--{/if}-->
复制代码

source\module\forum\forum_viewthread.php
找到
  1. if(!$_G['forum_thread']) {
  2.         showmessage('thread_nonexistence');
  3. }
复制代码

下加

  1. if(($_G['forum_thread']['setpublishtime'] > $_G['timestamp']) && ($_G['adminid'] !== '1') ) {
  2.         showmessage('抱歉,该贴定时时间还未到,您无法查看其内容');
  3. }
复制代码


source\archiver\forum\forumdisplay.php找到
  1. <?php if($thread['isgroup'] == 0): ?>
复制代码

改成
  1. <?php if(($thread['isgroup'] == 0) && (($thread['setpublishtime'] < $_G['timestamp']) || $_G['adminid'] == '1')): ?>
复制代码

完成.




上一篇:【Discuz!X1.5】在搜索页面添加一个广告位
下一篇:【Discuz!X1.5】完美解决NGINX下的DZ伪静态
authicon Cute宝贝儿 发表于 2011-5-7 00:07:46 | 显示全部楼层
顶的就是你
authicon 82xiaochong911 发表于 2011-5-9 14:00:00 | 显示全部楼层
顶的就是你
authicon YY大兔子 发表于 2011-5-10 17:59:51 | 显示全部楼层
我回不回呢 考虑再三 还是不回了吧 ^_^
authicon kurt226 发表于 2011-5-12 19:59:57 | 显示全部楼层
看看  好像不错
authicon 福倒菜菜子 发表于 2011-5-14 18:59:43 | 显示全部楼层
看帖必回
authicon melody0721 发表于 2011-5-27 21:59:59 | 显示全部楼层
很好的,我喜欢
authicon soul2511 发表于 2011-6-17 22:00:02 | 显示全部楼层
顶的就是你
authicon melody0721 发表于 2011-6-18 00:59:56 | 显示全部楼层
哈哈,支持了
authicon 蓝色天空k 发表于 2011-6-21 07:59:42 | 显示全部楼层
很好的,我喜欢
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-2 16:16

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表