note.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /*
  3. [UCenter] (C)2001-2099 Comsenz Inc.
  4. This is NOT a freeware, use is subject to license terms
  5. $Id: note.php 1155 2013-06-20 08:36:25Z andyzheng $
  6. */
  7. !defined('IN_UC') && exit('Access Denied');
  8. class control extends adminbase {
  9. var $apps = array();
  10. var $operations = array();
  11. function __construct() {
  12. $this->control();
  13. }
  14. function control() {
  15. parent::__construct();
  16. $this->check_priv();
  17. if(!$this->user['isfounder'] && !$this->user['allowadminnote']) {
  18. $this->message('no_permission_for_this_module');
  19. }
  20. $this->load('note');
  21. $this->apps = $this->cache['apps'];
  22. $this->operations = array(
  23. 'test'=>array('', 'action=test'),
  24. 'deleteuser'=>array('', 'action=deleteuser'),
  25. 'renameuser'=>array('', 'action=renameuser'),
  26. 'deletefriend'=>array('', 'action=deletefriend'),
  27. 'gettag'=>array('', 'action=gettag', 'tag', 'updatedata'),
  28. 'getcreditsettings'=>array('', 'action=getcreditsettings'),
  29. 'updatecreditsettings'=>array('', 'action=updatecreditsettings'),
  30. 'updateclient'=>array('', 'action=updateclient'),
  31. 'updatepw'=>array('', 'action=updatepw'),
  32. 'updatebadwords'=>array('', 'action=updatebadwords'),
  33. 'updatehosts'=>array('', 'action=updatehosts'),
  34. 'updateapps'=>array('', 'action=updateapps'),
  35. 'updatecredit'=>array('', 'action=updatecredit'),
  36. );
  37. $this->check_priv();
  38. }
  39. function onls() {
  40. $page = getgpc('page');
  41. $delete = getgpc('delete', 'P');
  42. $status = 0;
  43. if(!empty($delete)) {
  44. $_ENV['note']->delete_note($delete);
  45. $status = 2;
  46. $this->writelog('note_delete', "delete=".implode(',', $delete));
  47. }
  48. foreach($this->cache['apps'] as $key => $app) {
  49. if(empty($app['recvnote'])) {
  50. unset($this->apps[$key]);
  51. }
  52. }
  53. $num = $_ENV['note']->get_total_num(1);
  54. $notelist = $_ENV['note']->get_list($page, UC_PPP, $num, 1);
  55. $multipage = $this->page($num, UC_PPP, $page, 'admin.php?m=note&a=ls');
  56. $this->view->assign('status', $status);
  57. $this->view->assign('applist', $this->apps);
  58. $this->_format_notlist($notelist);
  59. $this->view->assign('notelist', $notelist);
  60. $this->view->assign('multipage', $multipage);
  61. $this->view->display('admin_note');
  62. }
  63. function onsend() {
  64. $noteid = intval(getgpc('noteid'));
  65. $appid = intval(getgpc('appid'));
  66. $result = $_ENV['note']->sendone($appid, $noteid);
  67. if($result) {
  68. $this->writelog('note_send', "appid=$appid&noteid=$noteid");
  69. $this->message('note_succeed', $_SERVER['HTTP_REFERER']);
  70. } else {
  71. $this->writelog('note_send', 'failed');
  72. $this->message('note_false', $_SERVER['HTTP_REFERER']);
  73. }
  74. }
  75. function _note_status($status, $appid, $noteid, $args, $operation) {
  76. if($status > 0) {
  77. return '<font color="green">'.$this->lang['note_succeed'].'</font>';
  78. } elseif($status == 0) {
  79. $url = 'admin.php?m=note&a=send&appid='.$appid.'&noteid='.$noteid;
  80. return '<a href="'.$url.'" class="red">'.$this->lang['note_na'].'</a>';
  81. } elseif($status < 0) {
  82. $url = 'admin.php?m=note&a=send&appid='.$appid.'&noteid='.$noteid;
  83. return '<a href="'.$url.'"><font color="red">'.$this->lang['note_false'].(-$status).$this->lang['note_times'].'</font></a>';
  84. }
  85. }
  86. function _format_notlist(&$notelist) {
  87. if(is_array($notelist)) {
  88. foreach($notelist AS $key => $note) {
  89. $notelist[$key]['operation'] = $this->lang['note_'.$note['operation']];//$this->operations[$note['operation']][0];
  90. foreach($this->apps AS $appid => $app) {
  91. $notelist[$key]['status'][$appid] = $this->_note_status($note['app'.$appid], $appid, $note['noteid'], $note['args'], $note['operation']);
  92. }
  93. }
  94. }
  95. }
  96. }
  97. ?>