/**
  * Handle the request
  *
  * Make a new notice for the update, save it, and show it
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->clientError(_('This method requires a POST.'), 400, $this->format);
         return;
     }
     // Workaround for PHP returning empty $_POST and $_FILES when POST
     // length > post_max_size in php.ini
     if (empty($_FILES) && empty($_POST) && $_SERVER['CONTENT_LENGTH'] > 0) {
         // TRANS: Client error displayed when the number of bytes in a POST request exceeds a limit.
         // TRANS: %s is the number of bytes of the CONTENT_LENGTH.
         $msg = _m('The server was unable to handle that much POST data (%s byte) due to its current configuration.', 'The server was unable to handle that much POST data (%s bytes) due to its current configuration.', intval($_SERVER['CONTENT_LENGTH']));
         $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
         return;
     }
     if (empty($this->status)) {
         $this->clientError(_('Client must provide a \'status\' parameter with a value.'), 400, $this->format);
         return;
     }
     if (empty($this->auth_user)) {
         // TRANS: Client error displayed when updating a status for a non-existing user.
         $this->clientError(_('No such user.'), 404, $this->format);
         return;
     }
     $status_shortened = $this->auth_user->shortenlinks($this->status);
     if (Notice::contentTooLong($status_shortened)) {
         // Note: Twitter truncates anything over 140, flags the status
         // as "truncated."
         $this->clientError(sprintf(_m('That\'s too long. Maximum notice size is %d character.', 'That\'s too long. Maximum notice size is %d characters.', Notice::maxContent()), Notice::maxContent()), 406, $this->format);
         return;
     }
     // Check for commands
     $inter = new CommandInterpreter();
     $cmd = $inter->handle_command($this->auth_user, $status_shortened);
     if ($cmd) {
         if ($this->supported($cmd)) {
             $cmd->execute(new Channel());
         }
         // Cmd not supported?  Twitter just returns your latest status.
         // And, it returns your last status whether the cmd was successful
         // or not!
         $this->notice = $this->auth_user->getCurrentNotice();
     } else {
         $reply_to = null;
         if (!empty($this->in_reply_to_status_id)) {
             // Check whether notice actually exists
             $reply = Notice::staticGet($this->in_reply_to_status_id);
             if ($reply) {
                 $reply_to = $this->in_reply_to_status_id;
             } else {
                 $this->clientError(_('Parent notice not found.'), $code = 404, $this->format);
                 return;
             }
         }
         if (!empty($this->link)) {
             try {
                 $post_url_file = MediaFile::fromLink($this->link, $this->auth_user);
             } catch (Exception $e) {
                 $this->clientError($e->getMessage(), $e->getCode(), $this->format);
                 return;
             }
         }
         $upload2 = null;
         try {
             $upload2 = MediaFile::fromUpload('media2', $this->auth_user);
         } catch (Exception $e) {
             $this->clientError($e->getMessage(), $e->getCode(), $this->format);
             return;
         }
         $upload = null;
         try {
             $upload = MediaFile::fromUpload('media', $this->auth_user);
         } catch (Exception $e) {
             $this->clientError($e->getMessage(), $e->getCode(), $this->format);
             return;
         }
         if (isset($upload)) {
             if (Notice::contentTooLong($status_shortened)) {
                 $upload->delete();
                 // TRANS: Client error displayed exceeding the maximum notice length.
                 // TRANS: %d is the maximum lenth for a notice.
                 $msg = _m('Maximum notice size is %d character, including attachment URL.', 'Maximum notice size is %d characters, including attachment URL.', Notice::maxContent());
                 $this->clientError(sprintf($msg, Notice::maxContent()), 400, $this->format);
             }
         }
         $content = html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8');
         $options = array('reply_to' => $reply_to);
         if ($this->auth_user->shareLocation()) {
             $locOptions = Notice::locationOptions($this->lat, $this->lon, null, null, $this->auth_user->getProfile());
             $options = array_merge($options, $locOptions);
         }
         //dyg add to response to group_id request
         ToSelector::fillOptions($this, $options);
         //end
         if (!empty($this->html_status)) {
             $options['rendered'] = $this->html_status;
         }
         $created = $this->trimmed('created');
         if (!empty($created)) {
             $options['created'] = $created;
         }
         try {
             $this->notice = Notice::saveNew($this->auth_user->id, $content, $this->source, $options);
         } catch (Exception $e) {
             $this->clientError($e->getMessage(), $e->getCode(), $this->format);
             return;
         }
         if (isset($upload)) {
             $upload->attachToNotice($this->notice);
         }
         if (isset($upload2)) {
             $upload2->attachToNotice($this->notice);
         }
         if (isset($post_url_file)) {
             $post_url_file->attachToNotice($this->notice);
         }
     }
     $this->showNotice();
 }