function update() { if (!$this->input['id']) { $this->errorOutput("未传入更新ID"); } $id = intval($this->input['id']); $sql = "SELECT * FROM " . DB_PREFIX . "program_plan WHERE 1 AND id=" . $id; $f = $this->db->query_first($sql); if (!$this->input['channel_id']) { $this->errorOutput("频道不为空"); } $channel_id = intval($this->input['channel_id']); include_once ROOT_PATH . 'lib/class/live.class.php'; $newLive = new live(); $channel = $newLive->getChannelById($channel_id, -1); $channel = $channel[0]; if (!$channel['id']) { $this->errorOutput('该频道已经不存在!'); } #####节点权限认证需要将节点数据放在nodes=>标志=>节点id=>节点所有父级节点 $nodes = array(); $nodes['_action'] = 'manage'; $nodes['nodes'][$channel['id']] = $channel['id']; $this->verify_content_prms($nodes); #####节点权限认证需要将节点数据放在nodes=>标志=>节点id=>节点所有父级节点 if (!trim($this->input['title'])) { $this->errorOutput("标题不为空"); } if (!trim($this->input['start_time'])) { $this->errorOutput("开始日期不为空"); } else { $reg = "/[0-2]{1}[0-9]{1}:[0-5]{1}[0-9]{1}/i"; if (!preg_match($reg, trim($this->input['start_time']))) { $this->errorOutput("开始时间格式不正确"); } } //exit(); if (!trim($this->input['start_date'])) { $this->errorOutput("开始日期不为空"); } else { $reg = "/[1-3]{1}[0-9]{3}-[0-1]{1}[0-9]{1}-[0-3]{1}[0-9]{1}/i"; if (!preg_match($reg, trim($this->input['start_date']))) { $this->errorOutput("开始日期格式不正确"); } } /* if(!trim($this->input['end_date'])) { $this->errorOutput("结束日期不为空"); } else { $reg = "/[1-3]{1}[0-9]{3}-[0-1]{1}[0-9]{1}-[0-3]{1}[0-9]{1}/i"; if(!preg_match($reg, trim($this->input['end_date']))) { $this->errorOutput("结束日期格式不正确"); } } */ $data = array('channel_id' => $channel_id, 'program_name' => rawurldecode($this->input['title']), 'start_time' => strtotime($this->input['start_date'] . ' ' . trim($this->input['start_time'])), 'toff' => $this->input['end_date'] ? strtotime($this->input['end_date'] . ' ' . trim($this->input['start_time'])) - strtotime($this->input['start_date'] . ' ' . trim($this->input['start_time'])) : 0, 'indexpic' => trim($this->input['indexpic']), 'week_day' => $this->input['week_day'] ? $this->input['week_day'] : ''); $week = $this->obj->verify($data['start_time'], $data['toff'], $channel_id, $id); if (!empty($week)) { if ($data['toff']) { $result = hg_array_sameItems($data['week_day'], $week); } else { $result = trim($this->input['end_date']) ? $week : hg_array_sameItems($data['week_day'], $week); } if (is_array($result) && !empty($result)) { $weeks = $space = ""; foreach ($result as $k => $v) { $weeks .= $space . $v; $space = ","; } $al = array(1, 2, 3, 4, 5, 6, 7); $ch = array('一', '二', '三', '四', '五', '六', '日'); $output = str_replace($al, $ch, $weeks); $this->errorOutput("星期" . $output . "已经包含" . trim($this->input['start_time']) . "~开始的节目,<br/>请选择节目计划的时间段"); } } $info = $this->obj->update($data, $id); if (!$info) { $this->errorOutput("更新失败!"); } else { if ($info['id']) { $this->addLogs('更新节目计划', $f, $info, '', '', $info['program_name'] . $info['id']); } $this->addItem($info); $this->output(); } }
function update() { if (!$this->input['id']) { $this->errorOutput("未传入更新ID"); } if (!$this->input['channel_id']) { $this->errorOutput("频道不为空"); } $start_time = urldecode($this->input['start_time']); if (!$start_time) { $this->errorOutput("开始时间不为空"); } $end_time = urldecode($this->input['end_time']); if (strtotime(date("Y-m-d") . " " . $end_time) - strtotime(date("Y-m-d") . " " . $start_time) <= 0) { $this->errorOutput("结束时间必须大于开始时间"); } $week_num = $this->input['week_day']; if (empty($week_num)) { $this->errorOutput("请选择节目计划的时间段"); } $week = $this->obj->verify($start_time, $end_time, $this->input['channel_id'], $this->input['id']); if (!empty($week)) { $result = hg_array_sameItems($week_num, $week); if (is_array($result) && !empty($result)) { $weeks = $space = ""; foreach ($result as $k => $v) { $weeks .= $space . $v; $space = ","; } $al = array(1, 2, 3, 4, 5, 6, 7); $ch = array('一', '二', '三', '四', '五', '六', '日'); $output = str_replace($al, $ch, $weeks); $this->errorOutput("星期" . $output . "已经包含" . $start_time . "~" . $end_time . "的节目,请选择节目计划的时间段"); } } $info = $this->obj->update(); if (!$info) { $this->errorOutput("更新失败!"); } $this->show(); }
/** * 串联单计划更新 * @name update * @access public * @author lijiaying * @category hogesoft * @copyright hogesoft * @param $id int 串联单计划ID * @param $channel_id int 频道ID * @param $start_time int 开始时间 * @param $end_time int 结束时间 * @param $channel2_ids int 来源类型ID * @param $week_num tinyint 星期几 * @return array 所在频道串联单计划信息 */ function update() { $id = intval($this->input['id']); $channel_id = intval($this->input['channel_id']); $start_time = urldecode($this->input['plan_start_time']); $end_time = urldecode($this->input['plan_end_time']); $week_num = $this->input['week_day']; if (!$id) { $this->errorOutput("未传入更新ID"); } if (!$channel_id) { $this->errorOutput("未传入频道id"); } if (!$start_time) { $this->errorOutput("开始时间不为空"); } if (strtotime(date("Y-m-d") . " " . $end_time) - strtotime(date("Y-m-d") . " " . $start_time) <= 0) { $this->errorOutput("结束时间必须大于开始时间"); } if (empty($week_num)) { $this->errorOutput("请选择串联单计划的时间段"); } //直播频道 $channel_field = ' id, server_id '; $channel_info = $this->mChangePlan->get_channel_by_id($channel_id, $channel_field); if (empty($channel_info)) { $this->errorOutput('该频道不存在或已被删除'); } $server_id = $channel_info['server_id']; if ($server_id) { $server_info = $this->mServerConfig->get_server_config_by_id($server_id); } $week = $this->mChangePlan->verify($start_time, $end_time, $channel_id, $id); if (!empty($week)) { $result = hg_array_sameItems($week_num, $week); if (is_array($result) && !empty($result)) { $weeks = $space = ""; foreach ($result as $k => $v) { $weeks .= $space . $v; $space = ","; } $al = array(1, 2, 3, 4, 5, 6, 7); $ch = array('一', '二', '三', '四', '五', '六', '日'); $output = str_replace($al, $ch, $weeks); $this->errorOutput("星期" . $output . "已经包含" . $start_time . "~" . $end_time . "的节目,请选择串联单计划的时间段"); } } $add_input = array('channel_id' => $channel_id, 'channel2_ids' => $this->input['channel2_ids'], 'channel2_name' => $this->input['channel2_name'], 'type' => $this->input['type'], 'plan_start_time' => $this->input['plan_start_time'], 'plan_end_time' => $this->input['plan_end_time'], 'program_start_time' => $this->input['program_start_time'], 'week_d' => $this->input['week_d'], 'week_day' => $this->input['week_day'], 'server_id' => $channel_info['server_id']); $info = $this->mChangePlan->update($id, $add_input, $server_info); if (!$info) { $this->errorOutput("更新失败!"); } $this->show(); }