collection_view.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: collection_view.php 33065 2013-04-16 10:06:07Z chenmengshu $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $oplist = array('comment', 'followers', 'related');
  12. if(!in_array($op, $oplist)) {
  13. $op = '';
  14. }
  15. $fromoplist = array('my', 'all');
  16. $fromop = (!in_array($_GET['fromop'], $fromoplist)) ? '' : $_GET['fromop'];
  17. $fromtid = dintval($_GET['fromtid']);
  18. $tids = $fids = array();
  19. if(!$_G['collection']['ctid']) {
  20. showmessage('collection_permission_deny');
  21. }
  22. $navtitle = $_G['collection']['name'].' - '.lang('core', 'title_collection');
  23. $permission = checkcollectionperm($_G['collection'], $_G['uid']);
  24. $avgrate = number_format($_G['collection']['rate'], 1);
  25. $start = ($page-1)*$tpp;
  26. $collectionfollowdata = C::t('forum_collectionfollow')->fetch_by_ctid_uid($ctid, $_G['uid']);
  27. $collectionteamworker = C::t('forum_collectionteamworker')->fetch_all_by_ctid($_G['collection']['ctid']);
  28. $_G['collection']['arraykeyword'] = parse_keyword($_G['collection']['keyword'], false, false);
  29. if($_G['collection']['arraykeyword']) {
  30. foreach ($_G['collection']['arraykeyword'] as $kid=>$s_keyword) {
  31. $metakeywords .= ($metakeywords ? ',' : '').$s_keyword;
  32. $_G['collection']['urlkeyword'][$kid] = rawurlencode($s_keyword);
  33. }
  34. }
  35. $metadescription = $_G['collection']['name'];
  36. if($_G['collection']['ratenum']) {
  37. $star = imgdisplayrate($avgrate);
  38. }
  39. if(!$op || $op == 'related') {
  40. $isteamworkers = in_array($_G['uid'], array_keys($collectionteamworker));
  41. $cloud_apps = (array)unserialize($_G['setting']['cloud_apps']);
  42. $search_status = $cloud_apps['search']['status'] == 'normal' ? TRUE : FALSE;
  43. if(!$op && $op != 'related') {
  44. if($_G['collection']['uid'] == $_G['uid']) {
  45. $lastvisit = $_G['collection']['lastvisit'];
  46. if($_G['collection']['lastupdate'] >= $lastvisit) {
  47. C::t('forum_collection')->update($ctid, array('lastvisit' => TIMESTAMP), true, true);
  48. }
  49. } elseif($isteamworkers) {
  50. $lastvisit = $collectionteamworker[$_G['uid']]['lastvisit'];
  51. if($_G['collection']['lastupdate'] >= $lastvisit) {
  52. C::t('forum_collectionteamworker')->update($ctid, $_G['uid'], array('lastvisit' => TIMESTAMP), true, true);
  53. }
  54. } elseif($collectionfollowdata['ctid']) {
  55. $lastvisit = $collectionfollowdata['lastvisit'];
  56. if($_G['collection']['lastupdate'] >= $lastvisit) {
  57. C::t('forum_collectionfollow')->update($ctid, $_G['uid'], array('lastvisit' => TIMESTAMP), true, true);
  58. }
  59. } else {
  60. $lastvisit = null;
  61. }
  62. $collectiontids = C::t('forum_collectionthread')->fetch_all_by_ctid($_G['collection']['ctid'], $start, $tpp);
  63. $tids = array_keys($collectiontids);
  64. $threadlist = C::t('forum_thread')->fetch_all_by_tid($tids);
  65. collectionThread($threadlist, false, $lastvisit, $collectiontids);
  66. $multipage = multi($_G['collection']['threadnum'], $tpp, $page, "forum.php?mod=collection&action=view&ctid={$_G['collection']['ctid']}");
  67. $userCollections = C::t('forum_collection')->fetch_all_by_uid($_G['collection']['uid'], 0, 5, $_G['collection']['ctid']);
  68. }
  69. if($_G['collection']['commentnum'] > 0) {
  70. $commentlist = C::t('forum_collectioncomment')->fetch_all_by_ctid($_G['collection']['ctid'], 0, 5);
  71. foreach($commentlist as &$curvalue) {
  72. $curvalue['dateline'] = dgmdate($curvalue['dateline'], 'u', '9999', getglobal('setting/dateformat'));
  73. $curvalue['message'] = cutstr($curvalue['message'], 50);
  74. $curvalue['rateimg'] = imgdisplayrate($curvalue['rate']);
  75. }
  76. $memberrate = C::t('forum_collectioncomment')->fetch_rate_by_ctid_uid($_G['collection']['ctid'], $_G['uid']);
  77. }
  78. $followers = C::t('forum_collectionfollow')->fetch_all($ctid, true, 0, 6);
  79. include template('forum/collection_view');
  80. } elseif($op == 'comment') {
  81. $navtitle = lang('core', 'title_collection_comment_list').' - '.$navtitle;
  82. if($_G['collection']['commentnum'] > 0) {
  83. $start = ($page-1)*$_G['setting']['postperpage'];
  84. $commentlist = C::t('forum_collectioncomment')->fetch_all_by_ctid($_G['collection']['ctid'], $start, $_G['setting']['postperpage']);
  85. foreach($commentlist as &$curvalue) {
  86. $curvalue['dateline'] = dgmdate($curvalue['dateline'], 'u', '9999', getglobal('setting/dateformat'));
  87. $curvalue['rateimg'] = imgdisplayrate($curvalue['rate']);
  88. }
  89. $multipage = multi($_G['collection']['commentnum'], $_G['setting']['postperpage'], $page, "forum.php?mod=collection&action=view&op=comment&ctid={$_G['collection']['ctid']}");
  90. $memberrate = C::t('forum_collectioncomment')->fetch_rate_by_ctid_uid($_G['collection']['ctid'], $_G['uid']);
  91. }
  92. include template('forum/collection_comment');
  93. } elseif($op == 'followers') {
  94. $navtitle = lang('core', 'title_collection_followers_list').' - '.$navtitle;
  95. $cmemberperpage = 28;
  96. $start = ($page-1)*$cmemberperpage;
  97. $followers = C::t('forum_collectionfollow')->fetch_all($ctid, true, $start, $cmemberperpage);
  98. $multipage = multi($_G['collection']['follownum'], $cmemberperpage, $page, "forum.php?mod=collection&action=view&op=followers&ctid={$_G['collection']['ctid']}");
  99. include template('forum/collection_followers');
  100. }
  101. ?>