spacecp_privacy.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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: spacecp_privacy.php 24946 2011-10-18 02:54:40Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. space_merge($space, 'field_home');
  12. $operation = in_array($_GET['op'], array('base', 'feed', 'filter', 'getgroup')) ? trim($_GET['op']) : 'base';
  13. if(submitcheck('privacysubmit')) {
  14. if($operation == 'base') {
  15. $space['privacy']['view'] = array();
  16. $viewtype = array('index', 'friend', 'wall', 'doing', 'blog', 'album', 'share', 'home', 'videoviewphoto');
  17. foreach ($_POST['privacy']['view'] as $key => $value) {
  18. if(in_array($key, $viewtype)) {
  19. $space['privacy']['view'][$key] = intval($value);
  20. }
  21. }
  22. }
  23. if($operation == 'feed') {
  24. $space['privacy']['feed'] = array();
  25. if(isset($_POST['privacy']['feed'])) {
  26. foreach ($_POST['privacy']['feed'] as $key => $value) {
  27. $space['privacy']['feed'][$key] = 1;
  28. }
  29. }
  30. }
  31. privacy_update();
  32. manyoulog('user', $_G['uid'], 'update');
  33. showmessage('do_success', 'home.php?mod=spacecp&ac=privacy&op='.$operation);
  34. } elseif(submitcheck('privacy2submit')) {
  35. $space['privacy']['filter_icon'] = array();
  36. if(isset($_POST['privacy']['filter_icon'])) {
  37. foreach($_POST['privacy']['filter_icon'] as $key => $value) {
  38. $space['privacy']['filter_icon'][$key] = 1;
  39. }
  40. }
  41. $space['privacy']['filter_gid'] = array();
  42. if(isset($_POST['privacy']['filter_gid'])) {
  43. foreach ($_POST['privacy']['filter_gid'] as $key => $value) {
  44. $space['privacy']['filter_gid'][$key] = intval($value);
  45. }
  46. }
  47. $space['privacy']['filter_note'] = array();
  48. if(isset($_POST['privacy']['filter_note'])) {
  49. foreach ($_POST['privacy']['filter_note'] as $key => $value) {
  50. $space['privacy']['filter_note'][$key] = 1;
  51. }
  52. }
  53. privacy_update();
  54. require_once libfile('function/friend');
  55. friend_cache($_G['uid']);
  56. showmessage('do_success', 'home.php?mod=spacecp&ac=privacy&op='.$operation);
  57. }
  58. if($operation == 'filter') {
  59. require_once libfile('function/friend');
  60. $groups = friend_group_list();
  61. $filter_icons = empty($space['privacy']['filter_icon'])?array():$space['privacy']['filter_icon'];
  62. $filter_note = empty($space['privacy']['filter_note'])?array():$space['privacy']['filter_note'];
  63. $iconnames = $appids = $icons = $uids = $users = array();
  64. foreach ($filter_icons as $key => $value) {
  65. list($icon, $uid) = explode('|', $key);
  66. $icons[$key] = $icon;
  67. $uids[$key] = $uid;
  68. if(is_numeric($icon)) {
  69. $appids[$key] = $icon;
  70. }
  71. }
  72. foreach ($filter_note as $key => $value) {
  73. list($type, $uid) = explode('|', $key);
  74. $types[$key] = $type;
  75. $uids[$key] = $uid;
  76. if(is_numeric($type)) {
  77. $appids[$key] = $type;
  78. }
  79. }
  80. if($uids) {
  81. foreach(C::t('common_member')->fetch_all($uids) as $uid => $value) {
  82. $users[$uid] = $value['username'];
  83. }
  84. }
  85. if($appids) {
  86. foreach(C::t('common_myapp')->fetch_all($appids) as $value) {
  87. $iconnames[$value['appid']] = $value['appname'];
  88. }
  89. }
  90. } elseif ($operation == 'getgroup') {
  91. $gid = empty($_GET['gid'])?0:intval($_GET['gid']);
  92. $users = array();
  93. $query = C::t('home_friend')->fetch_all_by_uid_gid($_G['uid'], $gid, 0, 0, false);
  94. foreach($query as $value) {
  95. $users[] = $value['fusername'];
  96. }
  97. $ustr = empty($users)?'': dhtmlspecialchars(implode(' ', $users));
  98. showmessage($ustr, '', array(), array('msgtype' => 3, 'handle'=>false));
  99. } else {
  100. $sels = array();
  101. if($space['privacy']['view']) {
  102. foreach ($space['privacy']['view'] as $key => $value) {
  103. $sels['view'][$key] = array($value => ' selected');
  104. }
  105. }
  106. if($space['privacy']['feed']) {
  107. foreach ($space['privacy']['feed'] as $key => $value) {
  108. $sels['feed'][$key] = ' checked';
  109. }
  110. }
  111. }
  112. $actives = array('privacy' =>' class="a"');
  113. $opactives = array($operation =>' class="a"');
  114. include template('home/spacecp_privacy');
  115. ?>