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)
 {
     $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 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;
 }
 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 update(RESTRequest $request)
 {
     $stb_list = $request->getConvertedIdentifiers();
     if (empty($stb_list)) {
         throw new RESTCommandException('Empty stb list');
     }
     foreach ($stb_list as $uid) {
         Mysql::getInstance()->update('users', array('access_token' => strtoupper(md5(microtime(1) . uniqid()))), array('id' => $uid));
         Mysql::getInstance()->update('access_tokens', array('token' => 'invalid_' . md5(microtime(1) . uniqid()), 'refresh_token' => 'invalid_' . md5(microtime(1) . uniqid())), array('uid' => $uid));
     }
     return true;
 }
 public function create(RESTRequest $request)
 {
     $stb_list = $request->getConvertedIdentifiers();
     if (empty($stb_list)) {
         throw new RESTCommandException('Empty stb list');
     }
     $msg = $request->getData("msg");
     if (empty($msg)) {
         throw new RESTCommandException('Empty msg');
     }
     $event = new SysEvent();
     $ttl = (int) $request->getData("ttl");
     if (!empty($ttl)) {
         $event->setTtl($ttl);
     }
     $auto_hide_timeout = (int) $request->getData('auto_hide_timeout');
     if ($auto_hide_timeout) {
         $event->setAutoHideTimeout($auto_hide_timeout);
     }
     $event->setUserListById($stb_list);
     $event->sendMsg($msg);
     return true;
 }