public function do_delete() { role::check('promotion_promotion'); // 收集请求数据 $request_data = $this->input->get(); $promotion = Mypromotion::instance($request_data['id'])->get(); if (!$promotion['id']) { remind::set(Kohana::lang('o_global.bad_request'), 'promotion/promotion_activity', 'error'); } if (Mypromotion::instance()->delete($promotion['id'])) { //promotion::delete_memcache($promotion['site_id']); remind::set(Kohana::lang('o_global.delete_success'), 'promotion/promotion_activity', 'success'); } }
public function do_edit() { role::check('promotion_promotion'); //收集请求 $request_data = $this->input->post(); //标签过滤 tool::filter_strip_tags($request_data); //错误信息返回 $session = Session::instance(); $session->set_flash('sessionErrorData', $request_data); $id = $request_data['id']; // 验证 - 数据有效性 $promotion_activity = Mypromotion_activity::instance($id)->get(); if (!$promotion_activity['id']) { remind::set(Kohana::lang('o_global.bad_request'), 'promotion/promotion_activity', 'error'); } if (strtotime($request_data['pmta_time_end']) + 24 * 3600 < time()) { remind::set(Kohana::lang('o_promotion.time_end'), request::referrer(), 'error'); } if (strtotime($request_data['pmta_time_end']) < strtotime($request_data['pmta_time_begin'])) { remind::set("开始时间不能比结束时间晚", request::referrer(), 'error'); } $dayTimeStamp = 24 * 3600; $request_data['pmta_time_end'] = date('Y-m-d H:i:s', strtotime($request_data['pmta_time_end']) + $dayTimeStamp); //判断促销活动的时间是否与促销规则的时间冲突 $promotions = Mypromotion::instance()->lists(array('where' => array('pmta_id' => $promotion_activity['id']))); if (!empty($promotions)) { $minTime = $promotions[0]['time_begin']; $maxTime = $promotions[0]['time_end']; foreach ($promotions as $promotion) { $minTime > $promotion['time_begin'] && ($minTime = $promotion['time_begin']); $maxTime < $promotion['time_end'] && ($maxTime = $promotion['time_end']); } if ($minTime < $request_data['pmta_time_begin'] || $maxTime > $request_data['pmta_time_end']) { remind::set(Kohana::lang('o_promotion.cpn_activity_time_conflict'), request::referrer(), 'error'); } } if (Mypromotion_activity::instance($id)->edit($request_data)) { $session->delete('sessionErrorData'); //promotion::delete_memcache($request_data['id']); remind::set(Kohana::lang('o_global.update_success'), "promotion/promotion_activity", 'success'); } else { remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error'); } }