pm.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?php
  2. /*
  3. [UCenter] (C)2001-2009 Comsenz Inc.
  4. This is NOT a freeware, use is subject to license terms
  5. $Id: pm.php 643 2008-09-25 10:20:59Z monkey $
  6. */
  7. !defined('IN_UC') && exit('Access Denied');
  8. class pmcontrol extends base {
  9. function __construct() {
  10. $this->pmcontrol();
  11. }
  12. function pmcontrol() {
  13. parent::__construct();
  14. $this->load('user');
  15. $this->load('pm');
  16. }
  17. function oncheck_newpm() {
  18. $this->init_input();
  19. $this->user['uid'] = intval($this->input('uid'));
  20. $more = $this->input('more');
  21. $result = $_ENV['pm']->check_newpm($this->user['uid'], $more);
  22. if($more == 3) {
  23. require_once UC_ROOT.'lib/uccode.class.php';
  24. $this->uccode = new uccode();
  25. $result['lastmsg'] = $this->uccode->complie($result['lastmsg']);
  26. }
  27. return $result;
  28. }
  29. function onsendpm() {
  30. $this->init_input();
  31. $fromuid = $this->input('fromuid');
  32. $msgto = $this->input('msgto');
  33. $subject = $this->input('subject');
  34. $message = $this->input('message');
  35. $replypmid = $this->input('replypmid');
  36. $isusername = $this->input('isusername');
  37. if($fromuid) {
  38. $user = $_ENV['user']->get_user_by_uid($fromuid);
  39. $user = daddslashes($user, 1);
  40. if(!$user) {
  41. return 0;
  42. }
  43. $this->user['uid'] = $user['uid'];
  44. $this->user['username'] = $user['username'];
  45. } else {
  46. $this->user['uid'] = 0;
  47. $this->user['username'] = '';
  48. }
  49. if($replypmid) {
  50. $isusername = 1;
  51. $pms = $_ENV['pm']->get_pmnode_by_pmid($this->user['uid'], $replypmid, 3);
  52. if($pms['msgfromid'] == $this->user['uid']) {
  53. $user = $_ENV['user']->get_user_by_uid($pms['msgtoid']);
  54. } else {
  55. $user = $_ENV['user']->get_user_by_uid($pms['msgfromid']);
  56. }
  57. $msgto = $user['username'];
  58. }
  59. $msgto = array_unique(explode(',', $msgto));
  60. $isusername && $msgto = $_ENV['user']->name2id($msgto);
  61. $blackls = $_ENV['pm']->get_blackls($this->user['uid'], $msgto);
  62. $lastpmid = 0;
  63. foreach($msgto as $uid) {
  64. if(!$fromuid || !in_array('{ALL}', $blackls[$uid])) {
  65. $blackls[$uid] = $_ENV['user']->name2id($blackls[$uid]);
  66. if(!$fromuid || isset($blackls[$uid]) && !in_array($this->user['uid'], $blackls[$uid])) {
  67. $lastpmid = $_ENV['pm']->sendpm($subject, $message, $this->user, $uid, 0, $replypmid);
  68. }
  69. }
  70. }
  71. return $lastpmid;
  72. }
  73. function ondelete() {
  74. $this->init_input();
  75. $this->user['uid'] = intval($this->input('uid'));
  76. $id = $_ENV['pm']->deletepm($this->user['uid'], $this->input('pmids'));
  77. return $id;
  78. }
  79. function onignore() {
  80. $this->init_input();
  81. $this->user['uid'] = intval($this->input('uid'));
  82. return $_ENV['pm']->set_ignore($this->user['uid']);
  83. }
  84. function onls() {
  85. $this->init_input();
  86. $pagesize = $this->input('pagesize');
  87. $folder = $this->input('folder');
  88. $filter = $this->input('filter');
  89. $page = $this->input('page');
  90. $folder = in_array($folder, array('newbox', 'inbox')) ? $folder : 'inbox';
  91. $filter = $filter ? (in_array($filter, array('newpm', 'privatepm', 'systempm', 'announcepm')) ? $filter : '') : '';
  92. $msglen = $this->input('msglen');
  93. $this->user['uid'] = intval($this->input('uid'));
  94. $pmnum = $_ENV['pm']->get_num($this->user['uid'], $folder, $filter);
  95. if($pagesize > 0) {
  96. $pms = $_ENV['pm']->get_pm_list($this->user['uid'], $pmnum, $folder, $filter, $page, $pagesize);
  97. if(is_array($pms) && !empty($pms)) {
  98. foreach($pms as $key => $pm) {
  99. if($msglen) {
  100. $pms[$key]['message'] = $_ENV['pm']->removecode($pms[$key]['message'], $msglen);
  101. } else {
  102. unset($pms[$key]['message']);
  103. }
  104. $pms[$key]['dateline'] = $pms[$key]['dbdateline'];
  105. unset($pms[$key]['dbdateline'], $pms[$key]['folder']);
  106. }
  107. }
  108. $result['data'] = $pms;
  109. }
  110. $result['count'] = $pmnum;
  111. return $result;
  112. }
  113. function onviewnode() {
  114. $this->init_input();
  115. $this->user['uid'] = intval($this->input('uid'));
  116. $pmid = $_ENV['pm']->pmintval($this->input('pmid'));
  117. $type = $this->input('type');
  118. $pm = $_ENV['pm']->get_pmnode_by_pmid($this->user['uid'], $pmid, $type);
  119. if($pm) {
  120. require_once UC_ROOT.'lib/uccode.class.php';
  121. $this->uccode = new uccode();
  122. $pm['message'] = $this->uccode->complie($pm['message']);
  123. return $pm;
  124. }
  125. }
  126. function onview() {
  127. $this->init_input();
  128. $this->user['uid'] = intval($this->input('uid'));
  129. $pmid = $_ENV['pm']->pmintval($this->input('pmid'));
  130. $pm = $_ENV['pm']->get_pmnode_by_pmid($this->user['uid'], $pmid, 3);
  131. $touid = $pm['msgfromid'] == $this->user['uid'] ? $pm['msgtoid'] : $pm['msgfromid'];
  132. $pmid = $touid ? '' : $pmid;
  133. if(empty($pmid)) {
  134. $endtime = $this->time;
  135. $pms = $_ENV['pm']->get_pm_by_touid($this->user['uid'], $touid, 0, $endtime);
  136. } else {
  137. $pms = $_ENV['pm']->get_pm_by_pmid($this->user['uid'], $pmid);
  138. }
  139. require_once UC_ROOT.'lib/uccode.class.php';
  140. $this->uccode = new uccode();
  141. $status = FALSE;
  142. foreach($pms as $key => $pm) {
  143. $pms[$key]['message'] = $this->uccode->complie($pms[$key]['message']);
  144. !$status && $status = $pm['msgtoid'] && $pm['new'];
  145. }
  146. $status && $_ENV['pm']->set_pm_status($this->user['uid'], $touid);
  147. return $pms;
  148. }
  149. function onblackls_get() {
  150. $this->init_input();
  151. $this->user['uid'] = intval($this->input('uid'));
  152. return $_ENV['pm']->get_blackls($this->user['uid']);
  153. }
  154. function onblackls_set() {
  155. $this->init_input();
  156. $this->user['uid'] = intval($this->input('uid'));
  157. $blackls = $this->input('blackls');
  158. return $_ENV['pm']->set_blackls($this->user['uid'], $blackls);
  159. }
  160. function onblackls_add() {
  161. $this->init_input();
  162. $this->user['uid'] = intval($this->input('uid'));
  163. $username = $this->input('username');
  164. return $_ENV['pm']->update_blackls($this->user['uid'], $username, 1);
  165. }
  166. function onblackls_delete($arr) {
  167. $this->init_input();
  168. $this->user['uid'] = intval($this->input('uid'));
  169. $username = $this->input('username');
  170. return $_ENV['pm']->update_blackls($this->user['uid'], $username, 2);
  171. }
  172. }
  173. ?>