public function update(RESTRequest $request) { $put = $request->getPut(); if (empty($put)) { throw new RESTCommandException('HTTP PUT data is empty'); } if (empty($put['action'])) { throw new RESTCommandException('Action param is empty'); } $identifiers = $request->getIdentifiers(); if (empty($identifiers)) { throw new RESTCommandException('Empty identifiers'); } if ($put['action'] == 'started') { foreach ($identifiers as $identifier) { $this->manager->setStarted(intval($identifier)); } return true; } elseif ($put['action'] == 'ended') { foreach ($identifiers as $identifier) { $this->manager->setEnded(intval($identifier)); } return true; } else { throw new RESTCommandException('Action is wrong'); } }
public function create(RESTRequest $request) { $stb_list = $request->getConvertedIdentifiers(); $identifiers = $request->getIdentifiers(); if (empty($stb_list) && !empty($identifiers)) { throw new RESTCommandException('STB not found'); } $event = new SysEvent(); if (empty($identifiers)) { $event->setUserListByMac('all'); } else { $event->setUserListById($stb_list); } if ($request->getData('ttl')) { $event->setTtl($request->getData('ttl')); } switch ($request->getData('event')) { case 'send_msg': if ($request->getData('need_reboot')) { $event->sendMsgAndReboot($request->getData('msg')); } else { $event->sendMsg($request->getData('msg')); } if ($request->getData('auto_hide_timeout')) { $event->setAutoHideTimeout($request->getData('auto_hide_timeout')); } break; case 'send_msg_with_video': $event->sendMsgWithVideo($request->getData('msg'), $request->getData('video')); break; case 'reboot': $event->sendReboot(); break; case 'reload_portal': $event->sendReloadPortal(); break; case 'update_channels': $event->sendUpdateChannels(); break; case 'play_channel': $event->sendPlayChannel($request->getData('channel')); break; case 'play_radio_channel': $event->sendPlayRadioChannel($request->getData('channel')); break; case 'update_image': $event->sendUpdateImage(); break; case 'cut_off': $event->sendCutOff(); break; case 'show_menu': $event->sendShowMenu(); break; default: return false; } return true; }
/** * Delete recording task * * @param RESTRequest $request * @return bool * @throws ErrorException */ public function delete(RESTRequest $request) { $ch_ids = $request->getIdentifiers(); if (empty($ch_ids[0])) { throw new ErrorException('Empty ch_id'); } return $this->manager->stop($ch_ids[0]); }
public function get(RESTRequest $request) { $identifiers = $request->getIdentifiers(); if (empty($identifiers[0])) { throw new ErrorException('Empty media_name'); } return $this->manager->checkMedia($identifiers[0]); }
public function get(RESTRequest $request) { $ids = $request->getIdentifiers(); if (empty($ids[0])) { throw new ErrorException('Empty token'); } return Itv::checkTemporaryLink($ids[0]); }
public function delete(RESTRequest $request) { if (count($request->getIdentifiers()) == 0) { throw new RESTCommandException('Identifier required'); } $stb_list = $request->getConvertedIdentifiers(); if (count($stb_list) == 0) { throw new RESTCommandException('STB not found'); } return $this->manager->deleteById($stb_list); }
public function get(RESTRequest $request) { $identifiers = $request->getIdentifiers(); if (!empty($identifiers[0])) { $plan_id = (int) $identifiers[0]; } else { $plan_id = null; } $result = Tariff::getDetailedPlanInfo($plan_id); return $result; }
public function update(RESTRequest $request) { $ids = $request->getIdentifiers(); if (empty($ids[0]) || intval($ids[0]) == 0) { throw new ErrorException('Empty channel id'); } $data = $request->getData(); if (key_exists('start_time', $data)) { $this->manager->updateStartTime(intval($ids[0]), $data['start_time']); } if (key_exists('end_time', $data)) { $this->manager->updateEndTime(intval($ids[0]), $data['end_time']); } return true; }
public function update(RESTRequest $request) { $put = $request->getPut(); if (empty($put)) { throw new RESTCommandException('HTTP PUT data is empty'); } $allowed_to_update_fields = array_fill_keys(array('monitoring_status'), true); $data = array_intersect_key($put, $allowed_to_update_fields); if (empty($data)) { throw new RESTCommandException('Update data is empty'); } $ids = $request->getIdentifiers(); if (empty($ids)) { throw new RESTCommandException('Empty channel id'); } $channel_id = intval($ids[0]); return Mysql::getInstance()->update('itv', $data, array('id' => $channel_id)); }
public function delete(RESTRequest $request) { $identifiers = $request->getIdentifiers(); if (!empty($identifiers[0]) && strlen($identifiers[0]) >= 12) { $users_ids = Stb::getUidByMacs($identifiers); } else { $users_ids = Stb::getUidByAccountNumber($identifiers); } if (count($identifiers) == 1 && count($users_ids) == 0) { throw new RESTCommandException('Account not found'); } if (count($identifiers) > 1) { throw new RESTCommandException('Only one identifier allowed'); } $result = true; foreach ($users_ids as $user_id) { $user = User::getInstance($user_id); $info = $user->getAccountInfo(); $subscribe = $user->updateOptionalPackageSubscription(array('subscribe' => array(), 'unsubscribe' => $info['subscribed'])); $result = $result && $subscribe; User::clear(); } return $result; }
public function delete(RESTRequest $request) { $identifiers = $request->getIdentifiers(); if (count($identifiers) == 0) { throw new RESTCommandException('Identifier required'); } $users_ids = $this->getUsersIdsFromIdentifiers($identifiers); if (count($identifiers) == 1 && count($users_ids) == 0) { throw new RESTCommandException('Account not found'); } if (count($identifiers) > 1) { throw new RESTCommandException('Only one identifier allowed'); } $result = true; foreach ($users_ids as $user_id) { $user = User::getInstance($user_id); $result = $user->delete() && $result; User::clear(); } return $result; }