event_joinmanage.inc.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <?php
  2. /**
  3. * [超级活动(xj_event.{modulename})] (C)2012-2099 Powered by 逍遥工作室.
  4. * Version: 1.0
  5. * Date: 2012-9-15 10:27
  6. */
  7. if (!defined('IN_DISCUZ')) {
  8. exit('Access Denied');
  9. }
  10. if (!$_G['uid']) {
  11. showmessage('not_loggedin', null, array(), array('login' => 1));
  12. }
  13. //调用核心类
  14. include 'source/plugin/xj_event/include/core.class.php';
  15. $eventcore = new xj_eventcore();
  16. include DISCUZ_ROOT . './source/plugin/xj_event/include/func.php';
  17. $tid = intval($_GET['tid']);
  18. //权限限制
  19. $thread = DB::fetch_first("SELECT authorid,userfield,setting,subject,starttime,event_address FROM " . DB::table('forum_thread') . " A," . DB::table('xj_event') . " B WHERE A.tid='$tid' and A.tid = B.tid");
  20. $setting = unserialize($thread['setting']);
  21. $event_starttime = dgmdate($thread['starttime'], 'dt');
  22. //判断是不是管理团队
  23. $event_admin = false;
  24. if (in_array($_G['username'], $setting['event_admin'])) {
  25. $event_admin = true;
  26. }
  27. if ($_G['groupid'] > 1 && $_G['uid'] != $thread['authorid'] && !$event_admin) {
  28. showmessage('quickclear_noperm');
  29. }
  30. if ($_GET['action'] == 'verify' and $_GET['applyid']) {
  31. if (!submitcheck('jmsubmit')) {
  32. showmessage('submit_invalid');
  33. }
  34. $applyids = implode(',', $_GET['applyid']);
  35. if ($_GET['verifyaction'] == 1) {
  36. $checknum = DB::result_first("SELECT SUM(applynumber) FROM " . DB::table('xj_eventapply') . " WHERE applyid in($applyids)"); //本次验证人数
  37. $applynum = DB::result_first("SELECT SUM(applynumber) FROM " . DB::table('xj_eventapply') . " WHERE tid='$tid' and verify=1"); //已报名人数
  38. $applycountnum = DB::result_first("SELECT event_number FROM " . DB::table('xj_event') . " WHERE tid='$tid'"); //活动总人数
  39. if ($checknum <= ($applycountnum - $applynum) or $applycountnum == 0) {
  40. $applys = DB::fetch_all("SELECT uid,tid,fromuid FROM " . DB::table('xj_eventapply') . " WHERE applyid in($applyids)");
  41. foreach ($applys as $value) {
  42. DB::query("UPDATE " . DB::table('xj_eventapply') . " SET verify = 1 WHERE uid=" . $value['uid'] . " AND tid=" . $value['tid']);
  43. }
  44. //DB::query("UPDATE ".DB::table('xj_eventapply')." SET verify = 1 WHERE applyid in($applyids)");
  45. //分享奖励处理
  46. if (file_exists(DISCUZ_ROOT . './source/plugin/xj_event/module/invitation/event_yqjl.php')) {
  47. if ($setting['yqjl_jfs'] > 0) {
  48. $selectlist = DB::fetch_all("SELECT uid,tid,fromuid FROM " . DB::table('xj_eventapply') . " WHERE applyid in($applyids)");
  49. foreach ($selectlist as $value) {
  50. $value['applynumber'] = DB::result_first("SELECT SUM(applynumber) FROM " . DB::table('xj_eventapply') . " WHERE tid=" . $value['tid'] . " AND uid=" . $value['uid']);
  51. if ($value['fromuid'] > 0) {
  52. $yqjl = array();
  53. $yqjl['tid'] = $value['tid'];
  54. $yqjl['fromuid'] = $value['fromuid'];
  55. $yqjl['applyuid'] = $value['uid'];
  56. $yqjl['jfs'] = $setting['yqjl_jfs'] * $value['applynumber'];
  57. $yqjl['jflx'] = $setting['yqjl_jflx'];
  58. $yqjl['dateline'] = $_G['timestamp'];
  59. DB::insert('xj_event_yqjl_log', $yqjl);
  60. updatemembercount($yqjl['fromuid'], array($yqjl['jflx'] => +$yqjl['jfs']));
  61. $applyusername = DB::result_first("SELECT username FROM " . DB::table('common_member') . " WHERE uid=" . $yqjl['applyuid']);
  62. notification_add($yqjl['fromuid'], 'system', $applyusername . lang('plugin/xj_event', 'beiniyaoqinbaomincanjiale') . ' <a href="forum.php?mod=viewthread&tid=' . $tid . '" target="_blank">' . $thread['subject'] . '</a> ' . lang('plugin/xj_event', 'huodonghuode') . $yqjl['jfs'] . $_G['setting']['extcredits'][$yqjl['jflx']]['title'] . lang('plugin/xj_event', 'jiangli'));
  63. }
  64. }
  65. }
  66. }
  67. //发手机短信
  68. if ($setting['seccode'] == 1) {
  69. include 'include/sms_func.php';
  70. $selectlist = DB::fetch_all("SELECT uid,mobile,applynumber,seccode FROM " . DB::table('xj_eventapply') . " WHERE applyid in($applyids)");
  71. foreach ($selectlist as $value) {
  72. $message = cutstr($thread['subject'], 30) . lang('plugin/xj_event', 'hdbmcgrs') . ':' . $value['applynumber'] . lang('plugin/xj_event', 'renyanzhengma') . ':' . $value['seccode'] . lang('plugin/xj_event', 'huodongshijian') . ' :' . $event_starttime;
  73. //xjsendsms(array($value['mobile']),$message,lang('plugin/xj_event', 'maomyzmdx'));
  74. sendsms_vcode($value['mobile'], $thread['subject'], $value['applynumber'], $value['seccode']);
  75. sendpm($value['uid'], '', $message, $_G['uid']);
  76. }
  77. } elseif ($setting['success_sms'] == 1) {
  78. include 'include/sms_func.php';
  79. $selectlist = DB::fetch_all("SELECT uid,mobile,applynumber,seccode FROM " . DB::table('xj_eventapply') . " WHERE applyid in($applyids)");
  80. foreach ($selectlist as $value) {
  81. sendsms_success($value['mobile'], $thread['subject'], $event_starttime);
  82. //易活动短信
  83. //$smsuid = DB::result_first("SELECT uid FROM ".DB::table('common_member')." WHERE username='".$setting['event_admin'][0]."'");
  84. //$smsmobile = DB::result_first("SELECT mobile FROM ".DB::table('common_member_profile')." WHERE uid=$smsuid");
  85. //sendsms_notice_yhd($value['mobile'],$thread['subject'],$event_starttime,$thread['event_address'],$smsmobile);
  86. }
  87. }
  88. //发送通知
  89. $query = DB::query("SELECT uid FROM " . DB::table('xj_eventapply') . " WHERE applyid in($applyids)");
  90. while ($value = DB::fetch($query)) {
  91. notification_add($value['uid'], 'system', lang('plugin/xj_event', 'ningbmcjd') . ' <a href="forum.php?mod=viewthread&tid=' . $tid . '" target="_blank">' . $thread['subject'] . '</a> ' . lang('plugin/xj_event', 'yishenghtg'), array(), 0);
  92. //微信消息
  93. if($_G['cache']['plugin']['xj_wxmessage']['wxlogin']){
  94. require_once DISCUZ_ROOT . './source/plugin/xj_wxmessage/class/core.class.php';
  95. $xj_wxmessagecore = new xj_wxmessagecore();
  96. $xj_wxmessagecore->send_eventmessage($value['uid'],$tid,1);
  97. }
  98. }
  99. } else {
  100. $onerror = lang('plugin/xj_event', 'mebgwfsh');
  101. }
  102. } elseif ($_GET['verifyaction'] == 2) {
  103. $applys = DB::fetch_all("SELECT uid,tid FROM " . DB::table('xj_eventapply') . " WHERE applyid in($applyids)");
  104. foreach ($applys as $value) {
  105. DB::query("UPDATE " . DB::table('xj_eventapply') . " SET verify = 0 WHERE uid=" . $value['uid'] . " AND tid=" . $value['tid']);
  106. //邀请奖励的取消奖励
  107. if (file_exists(DISCUZ_ROOT . './source/plugin/xj_event/module/invitation/event_yqjl.php')) {
  108. if ($setting['yqjl_jfs'] > 0) {
  109. $yqjl = DB::fetch_first("SELECT * FROM " . DB::table('xj_event_yqjl_log') . " WHERE tid=" . $value['tid'] . " AND applyuid=" . $value['uid']);
  110. if ($yqjl['jfs'] > 0) {
  111. updatemembercount($yqjl['fromuid'], array($yqjl['jflx'] => -$yqjl['jfs']));
  112. DB::delete('xj_event_yqjl_log', "tid=" . $value['tid'] . " AND applyuid=" . $value['uid']);
  113. $applyusername = DB::result_first("SELECT username FROM " . DB::table('common_member') . " WHERE uid=" . $yqjl['applyuid']);
  114. notification_add($yqjl['fromuid'], 'system', '[<a href="forum.php?mod=viewthread&tid=' . $tid . '" target="_blank">' . $thread['subject'] . '</a>] ' . $applyusername . lang('plugin/xj_event', 'beiglqxbmndyqjlsh') . ' -' . $yqjl['jfs'] . $_G['setting']['extcredits'][$yqjl['jflx']]['title']);
  115. }
  116. }
  117. }
  118. }
  119. //DB::query("UPDATE ".DB::table('xj_eventapply')." SET verify = 0 WHERE applyid in($applyids)");
  120. } elseif ($_GET['verifyaction'] == 3) {
  121. $items = DB::fetch_first("SELECT userfield,setting,use_extcredits_num,use_extcredits FROM " . DB::table('xj_event') . " WHERE tid = '$tid'");
  122. if ($items['use_extcredits_num'] > 0) {
  123. $query = DB::query("SELECT uid FROM " . DB::table('xj_eventapply') . " WHERE applyid in($applyids)");
  124. /*
  125. while($value = DB::fetch($query)){
  126. updatemembercount($value['uid'],array($items['use_extcredits']=>$items['use_extcredits_num']));
  127. }
  128. */
  129. }
  130. $applys = DB::fetch_all("SELECT uid,tid FROM " . DB::table('xj_eventapply') . " WHERE applyid in($applyids)");
  131. foreach ($applys as $value) {
  132. DB::query("DELETE FROM " . DB::table('xj_eventapply') . " WHERE uid=" . $value['uid'] . " AND tid=" . $value['tid']);
  133. //邀请奖励的取消奖励
  134. if (file_exists(DISCUZ_ROOT . './source/plugin/xj_event/module/invitation/event_yqjl.php')) {
  135. if ($setting['yqjl_jfs'] > 0) {
  136. $yqjl = DB::fetch_first("SELECT * FROM " . DB::table('xj_event_yqjl_log') . " WHERE tid=" . $value['tid'] . " AND applyuid=" . $value['uid']);
  137. if ($yqjl['jfs'] > 0) {
  138. updatemembercount($yqjl['fromuid'], array($yqjl['jflx'] => -$yqjl['jfs']));
  139. DB::delete('xj_event_yqjl_log', "tid=" . $value['tid'] . " AND applyuid=" . $value['uid']);
  140. $applyusername = DB::result_first("SELECT username FROM " . DB::table('common_member') . " WHERE uid=" . $yqjl['applyuid']);
  141. notification_add($yqjl['fromuid'], 'system', '[<a href="forum.php?mod=viewthread&tid=' . $tid . '" target="_blank">' . $thread['subject'] . '</a>] ' . $applyusername . lang('plugin/xj_event', 'beiglqxbmndyqjlsh') . ' -' . $yqjl['jfs'] . $_G['setting']['extcredits'][$yqjl['jflx']]['title']);
  142. }
  143. }
  144. }
  145. }
  146. }
  147. }
  148. //活动报名字段
  149. $selectuserfield = unserialize($thread['userfield']);
  150. $sysuserfield = unserialize($_G['setting']['activityfield']);
  151. //新的报名字段
  152. if($setting['myuserfield']){
  153. $myuserfield = $eventcore->GetUserField($setting['myuserfield']);
  154. }
  155. $listcount = DB::result_first("SELECT COUNT(*) FROM " . DB::table('xj_eventapply') . " WHERE tid='$tid'");
  156. $perpage = 15; //每页数
  157. $page = $_GET['page'] ? $_GET['page'] : 1;
  158. if (@ceil($listcount / $perpage) < $page) {
  159. $page = 1;
  160. }
  161. $start_limit = ($page - 1) * $perpage;
  162. $multipage = multi($listcount, $perpage, $page, "plugin.php?id=xj_event:event_joinmanage&tid=$tid", 0, 10, false, true, false, 'joinlist_display');
  163. $query = DB::query("SELECT * FROM " . DB::table('xj_eventapply') . " A," . DB::table('common_member') . " B WHERE A.uid = B.uid and A.tid = '$tid' ORDER BY A.verify,A.dateline DESC,A.first DESC LIMIT $start_limit,$perpage");
  164. $joinlist = array();
  165. require_once libfile('function/profile');
  166. loadcache('profilesetting');
  167. $i = 1;
  168. //签到
  169. if (file_exists(DISCUZ_ROOT . './source/plugin/xj_event/module/signed/wsq_signed.php')) {
  170. $signed_enable = true;
  171. }
  172. while ($value = DB::fetch($query)) {
  173. $value['dateline'] = dgmdate($value['dateline'], 'u'); //date('Y-m-d H:i:s',$value['dateline']);
  174. $value['ufielddata'] = unserialize($value['ufielddata']);
  175. //多种报名费用
  176. foreach ($setting['cost'] as $costvalue) {
  177. $value['cost' . $costvalue['id']] = $value['ufielddata']['cost' . $costvalue['id']];
  178. }
  179. $value['costclass'] = $value['ufielddata']['costclass'];
  180. $data = '';
  181. $ufielddata = array();
  182. foreach ($value['ufielddata'] as $key => $fieldid) {
  183. if (strpos($key, 'myfield')===false) {
  184. $data = profile_show($key, $value['ufielddata']);
  185. if ($_G['cache']['profilesetting'][$key]['formtype'] == 'file') {
  186. $data = '<a href="' . $data . '" target="_blank" onclick="zoom(this, this.href, 0, 0, 0); return false;">' . lang('forum/misc', 'activity_viewimg') . '</a>';
  187. }
  188. if ($key == 'birthday') {
  189. $ufielddata[$key]['value'] = $fieldid;
  190. } else {
  191. $ufielddata[$key]['value'] = $data;
  192. }
  193. if ($key == 'qq') {
  194. $ufielddata[$key]['value'] = '<a href="http://wpa.qq.com/msgrd?v=3&uin=' . $fieldid . '&Site=' . $_G['setting']['bbname'] . '&Menu=yes&from=discuz" target="_blank" title="' . lang('spacecp', 'qq_dialog') . '"><img src="' . STATICURL . '/image/common/qq.gif" alt="QQ" style="margin:0px;"/></a>' . $fieldid;
  195. }
  196. }else{
  197. $ufielddata[$key]['value'] = $fieldid;
  198. }
  199. }
  200. $value['ufielddata'] = $ufielddata;
  201. $value['No'] = $i;
  202. //签到
  203. if ($signed_enable) {
  204. $signed = DB::fetch_first("SELECT * FROM " . DB::table('xj_event_signed') . " WHERE tid='$tid' AND uid=" . $value['uid']);
  205. if ($signed) {
  206. $value['signed_dateline'] = dgmdate($signed['dateline']);
  207. }
  208. }
  209. //支付情况
  210. if ($setting['eventpay']) {
  211. $paylog = DB::fetch_first("SELECT * FROM " . DB::table('xj_eventpay_log') . " WHERE applyid=" . $value['applyid'] . " ORDER BY create_time DESC");
  212. $value['paytype'] = $paylog['paytype'];
  213. $value['price'] = $paylog['total_fee'];
  214. }
  215. $joinlist[] = $value;
  216. $i++;
  217. }
  218. include template('xj_event:join_manage');