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 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;
 }
 /**
  * @deprecated
  * @param $user_rec_id
  * @return bool
  */
 public function startDeferredNow($user_rec_id)
 {
     $user_rec_id = intval($user_rec_id);
     $user_record = Mysql::getInstance()->from('users_rec')->where(array('id' => $user_rec_id))->get()->first();
     if ($user_record['ended']) {
         $this->deleteUserRecord($user_rec_id);
         return false;
     }
     $data = array('t_start' => 'NOW()', 'started' => 1);
     Mysql::getInstance()->update('users_rec', $data, array('id' => $user_rec_id));
     $file_record = $this->createFileRecord($user_rec_id);
     if ($file_record) {
         $channel = Itv::getChannelById($user_record['ch_id']);
         $event = new SysEvent();
         $event->setUserListById($user_record['uid']);
         $event->setAutoHideTimeout(300);
         $user = User::getInstance((int) $user_record['uid']);
         $event->sendMsg($user->getLocalizedText('Starting recording') . ' — ' . $user_record['program'] . ' ' . $user->getLocalizedText('on channel') . ' ' . $channel['name']);
     }
     return $file_record;
 }