public function update(RESTRequest $request) { $stb_list = $request->getConvertedIdentifiers(); if (empty($stb_list)) { throw new RESTCommandException('Empty stb list'); } /*if (count($stb_list) != 1){ throw new RESTCommandException('Only one identifier allowed'); }*/ $uids = $stb_list; $data = $request->getPut(); if (empty($data)) { throw new RESTCommandException('HTTP PUT data is empty'); } if (!key_exists('disabled', $data) && !key_exists('restricted', $data)) { throw new RESTCommandException('Update data is empty'); } if (key_exists('disabled', $data)) { foreach ($uids as $uid) { Stb::setDisabledModulesByUid($uid, $data['disabled']); } } if (key_exists('restricted', $data)) { foreach ($uids as $uid) { Stb::setRestrictedModulesByUid($uid, $data['restricted']); } } return array('disabled' => Stb::getDisabledModulesByUid($uids[0]), 'restricted' => Stb::getRestrictedModulesByUid($uids[0])); }
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 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('status', 'additional_services_on', 'ls', 'reboot', 'end_date'), true); $data = array_intersect_key($put, $allowed_to_update_fields); if (array_key_exists('status', $data)) { $data['status'] = intval(!$data['status']); } if (isset($data['end_date'])) { $data['expire_billing_date'] = $data['end_date']; unset($data['end_date']); } if (empty($data)) { throw new RESTCommandException('Update data is empty'); } if (count($request->getIdentifiers()) == 0 && !Config::getSafe('allow_multiple_stb_update', false)) { throw new RESTCommandException('Identifier required'); } $stb_list = $this->manager->updateByUids($request->getConvertedIdentifiers(), $data); if (empty($stb_list)) { return false; } return $this->formatList($stb_list); }
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('sub_ch', 'additional_services_on'), true); $data = array_intersect_key($put, $allowed_to_update_fields); $stb_data = array_intersect_key($put, array('additional_services_on' => true)); if (empty($data)) { throw new RESTCommandException('Update data is empty'); } unset($data['additional_services_on']); if (!empty($stb_data)) { //$stb = Stb::getInstance(); //$stb->setParam('additional_services_on', intval($stb_data['additional_services_on'])); $uids = $request->getConvertedIdentifiers(); foreach ($uids as $uid) { Stb::setAdditionServicesById($uid, intval($stb_data['additional_services_on'])); } } //var_dump($stb_data); if (!empty($data)) { $list = ItvSubscription::updateByUids($request->getConvertedIdentifiers(), $data); if (empty($list)) { return false; } } return $this->formatList(ItvSubscription::getByUids($request->getConvertedIdentifiers())); }
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)); }