function createEvent() { if (MEMBER_ID < 1) { $this->Messager("你需要先登录才能继续本操作", 'index.php?mod=login'); } load::logic('event'); $EventLogic = new EventLogic(); if (MEMBER_ROLE_TYPE != 'admin') { $is_allowed = $EventLogic->allowedCreate(MEMBER_ID, $this->Member); } if ($is_allowed) { $this->Messager($is_allowed); } $free = 'checked'; $all = 'checked'; $info = array(); $info = jconf::get('profileeventinfo'); $rs = $EventLogic->get_event_type(); $event_type = jform()->Select("type", $rs, $val['type_id']); if ($this->Member['province']) { $province_id = $EventLogic->get_province_id($this->Member['province']); } else { $province_id = $EventLogic->get_province_id(); } $province = $EventLogic->get_province(); $hid_province = $province_id; $province_list = jform()->Select("province", $province, $province_id, "onchange=\"changeProvince();\""); if ($this->Member['city']) { $city_id = $EventLogic->get_city_id(array('name' => $this->Member['city'], 'upid' => $province_id)); $where_city = " and upid = '{$city_id}'"; } $hid_city = $city_id; if ($this->Member['area']) { $area_where = array('name' => $this->Member['area']); if ($city_id) { $area_where['upid'] = $city_id; } $area_id = $EventLogic->get_area_id($area_where); } $hid_area = $area_id; $fromt = $edit_fromt ? $edit_fromt : my_date_format(TIMESTAMP, 'Y-m-d'); $edit_fromt_h = $edit_fromt_h ? $edit_fromt_h : false; $edit_fromt_i = $edit_fromt_i ? $edit_fromt_i : false; $hour_select_from = mk_time_select('hour', $edit_fromt_h, 'hour_select_from'); $min_select_from = mk_time_select('min', $edit_fromt_i, 'min_select_from'); $tot = $edit_tot ? $edit_tot : my_date_format(TIMESTAMP + 7 * 24 * 3600, 'Y-m-d'); $edit_tot_h = $edit_tot_h ? $edit_tot_h : false; $edit_tot_i = $edit_tot_i ? $edit_tot_i : false; $hour_select_to = mk_time_select('hour', $edit_tot_h, 'hour_select_to'); $min_select_to = mk_time_select('min', $edit_tot_i, 'min_select_to'); $member = $this->Member; if ($member['medal_id']) { $medal_list = $this->TopicLogic->GetMedal($member['medal_id'], $member['uid']); } $this->Title = "发起活动"; include template('event/event_create'); }
function create() { if (!$this->MemberHandler->HasPermission($this->Module, $this->Code)) { json_error($this->MemberHandler->GetError()); } $post = $this->Post; $post['name'] = jpost('name', 'txt'); if (!$post['name']) { json_error("请输入活动标题"); } $f_rets = filter($post['name']); if ($f_rets && $f_rets['error']) { json_error("活动标题" . $f_rets['msg']); } if (!$post['content1']) { json_error("请输入活动描述"); } $f_rets = filter($post['content1']); if ($f_rets && $f_rets['error']) { json_error("活动描述" . $f_rets['msg']); } $post['address'] = jpost('address', 'txt'); if (!$post['address']) { json_error("请输入活动地址"); } $f_rets = filter($post['address']); if ($f_rets && $f_rets['error']) { json_error("活动地址" . $f_rets['msg']); } if ($post['money_r'] == 'money' && !$post['money']) { json_error("请输入活动人均费用"); } if ($post['money_r'] == 'money' && !is_numeric($post['money'])) { json_error("活动人均费用应为数字"); } if ($post['qua'] == 'qua' && $post['fans'] && !is_numeric($post['fans_num'])) { json_error("粉丝数应为数字"); } if (!$post['fromt']) { json_error("请输入活动开始时间"); } if (!$post['tot']) { json_error("请输入活动结束时间"); } if (!$post['hid_pic']) { json_error("请上传活动海报"); } $fromt = strtotime($post['fromt'] . " " . $post['hour_select_from'] . ":" . $post['min_select_from']); $tot = strtotime($post['tot'] . " " . $post['hour_select_to'] . ":" . $post['min_select_to']); if ($fromt >= $tot) { json_error("活动结束时间不能早于开始时间"); } $verify = $this->Config['event_verify'] ? 0 : 1; load::logic('event'); $eventLogic = new EventLogic(); if (MEMBER_ROLE_TYPE != 'admin') { $is_allowed = $eventLogic->allowedCreate(MEMBER_ID, $this->Member); } if ($is_allowed) { json_error($is_allowed); } $item = get_param('item'); $item_id = (int) get_param('item_id'); $return = $eventLogic->createEvent($post, $item, $item_id, $verify); if (is_array($return)) { if ($return) { json_result("修改成功", $return); } else { json_error('修改失败'); } } else { $id = $return; } if (0 == $verify) { json_error('发布成功,等待管理员审核'); } $value = '我发布了一个活动【' . $post[name] . '】,地址:' . get_full_url($this->Config['site_url'], "index.php?mod=event&code=detail&id={$id}"); if ($post['top'] == 'top') { $values = array('id' => $id, 'content' => $value, 'from' => ''); json_result('发布成功', $values); } $item_id = $id; $msg = '发布成功'; include template('vote/vote_toweibo'); exit; }