wsq_join_modify.inc.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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: install.php 34718 2014-07-14 08:56:39Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(!$_G['uid']) {
  12. showmessage('not_loggedin', NULL, array(), array('login' => 1));
  13. }
  14. $uid = intval($_G['uid']);
  15. $siteid = $_G['wechat']['setting']['wsq_siteid'];
  16. $applyid = intval($_GET['applyid']);
  17. if($_GET['action'] == 'full'){
  18. $result = array();
  19. if($_GET['formhash'] != $_G['formhash']){
  20. $result['showmessage'] = $_G['charset']=='gbk'?iconv('GBK','UTF-8',lang('message','submit_invalid')):lang('message','submit_invalid');
  21. $result['full'] = 2;
  22. echo json_encode($result);
  23. exit;
  24. }
  25. $apply = DB::fetch_first("SELECT eid,applynumber FROM ".DB::table('xj_eventapply')." WHERE applyid=$applyid");
  26. $items = DB::fetch_first("SELECT * FROM ".DB::table('xj_event')." A,".DB::table('forum_thread')." B WHERE A.tid=B.tid AND A.eid=".$apply['eid']);
  27. //活动已成功报名人总数
  28. $ybnumber = DB::result_first("SELECT sum(applynumber) FROM ".DB::table('xj_eventapply')." WHERE eid=".$apply['eid']." AND verify=1");
  29. if($items['event_number']>0 && intval($_GET['applynumber'])>($items['event_number']-($ybnumber-$apply['applynumber']))){
  30. $result['showmessage'] = $_G['charset']=='gbk'?iconv('GBK','UTF-8',lang('plugin/xj_event','baomrsym')):lang('plugin/xj_event','baomrsym');
  31. $result['full'] = 2;
  32. echo json_encode($result);
  33. exit;
  34. }
  35. $applys = array();
  36. $applys['realname'] = addslashes($_GET['realname']);
  37. $applys['mobile'] = addslashes($_GET['mobile']);
  38. $applys['qq'] = addslashes($_GET['qq']);
  39. $applys['bmmessage'] = addslashes($_GET['message']);
  40. $applys['applynumber'] = intval($_GET['applynumber']);
  41. $applys['session'] = intval($_GET['session']);
  42. $ufielddata = array();
  43. $selectuserfield = unserialize($items['userfield']);
  44. $sysuserfield = unserialize($_G['setting']['activityfield']);
  45. foreach($sysuserfield as $key => $value){
  46. if(in_array($key,$selectuserfield)){
  47. if(is_array($_GET[$key])){
  48. $ufielddata[$key] = implode(',',$_GET[$key]);
  49. }elseif($key=='birthday'){
  50. $ufielddata[$key] = $_GET['birthyear'].'-'.$_GET['birthmonth'].'-'.$_GET['birthday'];
  51. }elseif($key=='residecity'){
  52. $ufielddata[$key] = $_GET['resideprovince'].$_GET['residecity'].$_GET['residedist'].$_GET['residecommunity'];
  53. }else{
  54. $ufielddata[$key] = $_GET[$key];
  55. }
  56. }
  57. }
  58. $applys['ufielddata'] = serialize($ufielddata);
  59. DB::update('xj_eventapply',$applys,"applyid=$applyid");
  60. //发提醒
  61. notification_add($items['authorid'], 'system', $_G['username'].' '.lang('plugin/xj_event','xglhd').' '.$items['subject'].' '.lang('plugin/xj_event','baominzl').',<a href="forum.php?mod=viewthread&tid='.$items['tid'].'" target="_blank">'.lang('plugin/xj_event','view').'</a>', array());
  62. $result['showmessage'] = $_G['charset']=='gbk'?iconv('GBK','UTF-8',lang('plugin/xj_event', 'bmzlxgcg')):lang('plugin/xj_event', 'bmzlxgcg');
  63. $result['full'] = 1;
  64. echo json_encode($result);
  65. exit;
  66. }
  67. $apply = DB::fetch_first("SELECT * FROM ".DB::table('xj_eventapply')." WHERE applyid=$applyid");
  68. $items = DB::fetch_first("SELECT * FROM ".DB::table('xj_event')." WHERE eid=".$apply['eid']);
  69. $items['setting'] = unserialize($items['setting']);
  70. $setting = $items['setting'];
  71. if($apply['verify']==1 && !$items['setting']['noverify']){
  72. showmessage('quickclear_noperm');
  73. }
  74. $apply['ufielddata'] = unserialize($apply['ufielddata']);
  75. $userfield = unserialize($items['userfield']);
  76. $tid = intval($items['tid']);
  77. $selectuserfield = unserialize($items['userfield']);
  78. if($selectuserfield) {
  79. if($selectuserfield) {
  80. $htmls = $settings = array();
  81. require_once libfile('function/profile');
  82. foreach($selectuserfield as $fieldid) {
  83. if(empty($ufielddata['userfield'])) {
  84. $memberprofile = C::t('common_member_profile')->fetch($_G['uid']);
  85. foreach($selectuserfield as $val) {
  86. if($val == 'birthday'){
  87. $tmp = explode('-',$apply['ufielddata']['birthday']);
  88. $ufielddata['userfield']['birthyear'] = $tmp[0];
  89. $ufielddata['userfield']['birthmonth'] = $tmp[1];
  90. $ufielddata['userfield']['birthday'] = $tmp[2];
  91. }elseif($val == 'realname'){
  92. $ufielddata['userfield']['realname'] = $apply['realname'];
  93. }elseif($val == 'mobile'){
  94. $ufielddata['userfield']['mobile'] = $apply['mobile'];
  95. }else{
  96. $ufielddata['userfield'][$val] = $apply['ufielddata'][$val];//$memberprofile[$val];
  97. }
  98. }
  99. unset($memberprofile);
  100. }
  101. $html = profile_setting($fieldid, $ufielddata['userfield'], false, true);
  102. if($html) {
  103. $settings[$fieldid] = $_G['cache']['profilesetting'][$fieldid];
  104. $htmls[$fieldid] = $html;
  105. }
  106. }
  107. }
  108. } else {
  109. $selectuserfield = '';
  110. }
  111. //报名时可能选择的人数
  112. $items['event_number_max'] = $items['event_number_max']>0?$items['event_number_max']:1;
  113. $applynumber = array();
  114. for($i=1;$i<=$items['event_number_max'];$i++){
  115. $applynumber[] = $i;
  116. }
  117. $thread = DB::fetch(DB::query("SELECT subject FROM ".DB::table('forum_thread')." WHERE tid = '$tid'"));
  118. ?>
  119. <script type="text/javascript" src="http://wsq.discuz.com/cdn/discuz/js/openjs.js"></script>
  120. <script>
  121. var menu = new Array();
  122. WSQ.initBtmBar(menu);
  123. WSQ.showBtmBar();
  124. WSQ.initPlugin({name:'<?php echo $thread['subject'].lang('plugin/xj_event', 'baomin'); ?>'});
  125. var initWx = {
  126. 'img': '<?php echo $_G['siteurl']; ?>/static/image/common/logo.png',
  127. 'desc': '<?php echo $_G['bbsname'].lang('plugin/xj_event', 'huodzx'); ?>',
  128. 'title': '<?php echo $thread['subject']; ?>',
  129. 'pluginid':'xj_event:wsq_join_test',
  130. 'param': 'a=1&b=2'
  131. };
  132. WSQ.initShareWx(initWx);
  133. </script>
  134. <style type="text/css">
  135. #container {margin:5px;}
  136. body {height:100%;}
  137. .input1{padding:14px; line-height:14px; width:100%;-moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius:4px; border:1px solid #d8d8d8;}
  138. select{height:42px;-webkit-appearance:none;appearance:none;border:none;font-size:14px;padding:0px 10px;display:block;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box;background-color: #FFFFFF;color:#aaa;border-radius:4px;}
  139. .selectdiv{margin-top:0px;outline:none;-moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius:4px; border:1px solid #d8d8d8;position:relative;}
  140. .checkbox {
  141. width: 19px;
  142. height: 25px;
  143. padding: 0 5px 0 0;
  144. background: url(checkbox.png) no-repeat;
  145. display: block;
  146. float: left;
  147. }
  148. label{float:left; font-size:14px; line-height:30px;}
  149. </style>
  150. <script type="text/javascript" src="source/plugin/xj_event/js/jquery.js"></script>
  151. <script type="text/javascript">
  152. $(function(){
  153. $("#testbtn").click(function(){
  154. $.ajax({
  155. type: 'POST',
  156. url: 'plugin.php?id=xj_event:wsq_join_modify&tid=<?php echo $tid; ?>&applyid=<?php echo $applyid; ?>&action=full',
  157. //data: {level:'fff', roomnumber:'bbb'},
  158. data:$('#bmform').serialize(),
  159. dataType: 'json',
  160. cache: false,
  161. error: function(){
  162. alert('error');
  163. return false;
  164. },
  165. success:function(json){
  166. if(json.full == 2){
  167. alert(json.showmessage);
  168. if(json.tourl != null){
  169. top.location.href=json.tourl;
  170. }
  171. return false;
  172. }
  173. if(json.full == 1){
  174. alert('<?php echo lang('plugin/xj_event','bmzlxgcg'); ?>');
  175. top.location.href="http://wsq.discuz.com/?c=index&a=viewthread&f=wx&tid=<?php echo $tid; ?>&siteid=<?php echo $siteid; ?>&_bpage=1";
  176. return true;
  177. }else{
  178. alert('error');
  179. return false;
  180. }
  181. }
  182. });
  183. });
  184. });
  185. </script>
  186. </head>
  187. <body>
  188. <div>
  189. <div style="height:20px;">
  190. </div>
  191. <form name="bmform" id="bmform">
  192. <input type="hidden" name="formhash" value="<?php echo $_G['formhash'];?>" />
  193. <input type="hidden" name="eid" value="<?php echo $items['eid'];?>" />
  194. <div style="padding:10px 30px;">
  195. <div class="selectdiv">
  196. <select name="session">
  197. <option><?php echo lang('plugin/xj_event','huodongcc'); ?></option>
  198. <?php foreach($setting['session'] as $key=>$value){ ?>
  199. <option value="<?php echo $key; ?>" <?php if($apply['session'] == $key){echo 'selected';} ?>><?php echo $value; ?></option>
  200. <?php } ?>
  201. </select>
  202. </div>
  203. </div>
  204. <?php
  205. if(!empty($selectuserfield)){
  206. foreach($selectuserfield as $fieldid){
  207. if($settings[$fieldid]['available']){
  208. if($settings[$fieldid]['formtype'] != 'file'){
  209. $htmls[$fieldid] = str_replace('class="px"','class="input1" placeholder="'.$settings[$fieldid]['title'].'"',$htmls[$fieldid]);
  210. $htmls[$fieldid] = preg_replace("/<div.+<\/div>/is", "", $htmls[$fieldid]);
  211. if(strpos($htmls[$fieldid],'select')>0){
  212. $htmls[$fieldid] = str_replace('tabindex="1">','tabindex="1"><option>'.$settings[$fieldid]['title'].'</option>',$htmls[$fieldid]);
  213. echo '<div style="padding:10px 30px;">'.$htmls[$fieldid].'</div>';
  214. }elseif(strpos($htmls[$fieldid],'checkbox')>0){
  215. //$htmls[$fieldid] = str_replace('type="checkbox"','type="checkbox" class="checkbox"',$htmls[$fieldid]);
  216. echo '<div style="padding:10px 30px;">'.$htmls[$fieldid].'<div style="clear:both;"></div></div>';
  217. }else{
  218. echo '<div style="padding:10px 30px;">'.$htmls[$fieldid].'</div>';
  219. }
  220. }else{
  221. }
  222. }
  223. }
  224. }
  225. ?>
  226. <div style="padding:10px 30px;">
  227. <div class="selectdiv">
  228. <select name="applynumber">
  229. <option><?php echo lang('plugin/xj_event','baomingrs'); ?></option>
  230. <?php foreach($applynumber as $key=>$value){ ?>
  231. <option value="<?php echo $value; ?>" <?php if($apply['applynumber'] == $value){echo 'selected';} ?>><?php echo $value; ?></option>
  232. <?php } ?>
  233. </select>
  234. </div>
  235. </div>
  236. <div style="padding:10px 30px;">
  237. <input name="message" type="text" placeholder="<?php echo lang('plugin/xj_event','liuyan'); ?>" class="input1">
  238. </div>
  239. </form>
  240. <a href="javascript:" id="testbtn" style="display:block; height:44px; line-height:44px; text-align:center; background-color:#ff4a00; color:#FFF;-moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius:4px; margin:10px 30px; font-size:16px; font-weight:bold;"><?php echo lang('plugin/xj_event','xgbmzl'); ?></a>
  241. </div>
  242. </body>
  243. </html>