예제 #1
0
 /**
  * Load attributes based on database arguments
  *
  * Loads all the DB stuff
  *
  * @param array $args $_REQUEST array
  *
  * @return success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     $id = $this->arg('notice');
     $this->notice = Notice::staticGet($id);
     if (empty($this->notice)) {
         // Did we used to have it, and it got deleted?
         $deleted = Deleted_notice::staticGet($id);
         if (!empty($deleted)) {
             $this->clientError(_('Notice deleted.'), 410);
         } else {
             $this->clientError(_('No such notice.'), 404);
         }
         return false;
     }
     $this->profile = $this->notice->getProfile();
     if (empty($this->profile)) {
         $this->serverError(_('Notice has no profile.'), 500);
         return false;
     }
     $this->user = User::staticGet('id', $this->profile->id);
     $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
     return true;
 }
예제 #2
0
 /**
  * Show the notice
  *
  * @return void
  */
 function showNotice()
 {
     if (!empty($this->notice)) {
         if ($this->format == 'xml') {
             $this->showSingleXmlStatus($this->notice);
         } elseif ($this->format == 'json') {
             $this->show_single_json_status($this->notice);
         }
     } else {
         // XXX: Twitter just sets a 404 header and doens't bother
         // to return an err msg
         $deleted = Deleted_notice::staticGet($this->notice_id);
         if (!empty($deleted)) {
             $this->clientError(_('Status deleted.'), 410, $this->format);
         } else {
             $this->clientError(_('No status with that ID found.'), 404, $this->format);
         }
     }
 }
예제 #3
0
 function delete()
 {
     // For auditing purposes, save a record that the notice
     // was deleted.
     // @fixme we have some cases where things get re-run and so the
     // insert fails.
     $deleted = Deleted_notice::staticGet('id', $this->id);
     if (!$deleted) {
         $deleted = new Deleted_notice();
         $deleted->id = $this->id;
         $deleted->profile_id = $this->profile_id;
         $deleted->uri = $this->uri;
         $deleted->created = $this->created;
         $deleted->deleted = common_sql_now();
         $deleted->insert();
     }
     if (Event::handle('NoticeDeleteRelated', array($this))) {
         // Clear related records
         $this->clearReplies();
         $this->clearRepeats();
         $this->clearFaves();
         $this->clearTags();
         $this->clearGroupInboxes();
         // NOTE: we don't clear inboxes
         // NOTE: we don't clear queue items
     }
     $result = parent::delete();
     $this->blowOnDelete();
     return $result;
 }
예제 #4
0
파일: Notice.php 프로젝트: Grasia/bolotweet
 /**
  * Look up the creation timestamp for a given notice ID, even
  * if it's been deleted.
  *
  * @param int $id
  * @return mixed string recorded creation timestamp, or false if can't be found
  */
 public static function getAsTimestamp($id)
 {
     if (!$id) {
         return false;
     }
     $notice = Notice::staticGet('id', $id);
     if ($notice) {
         return $notice->created;
     }
     $deleted = Deleted_notice::staticGet('id', $id);
     if ($deleted) {
         return $deleted->created;
     }
     return false;
 }
예제 #5
0
 /**
  * Show the notice
  *
  * @return void
  */
 function showNotice()
 {
     if (!empty($this->notice)) {
         switch ($this->format) {
             case 'xml':
                 $this->showSingleXmlStatus($this->notice);
                 break;
             case 'json':
                 $this->show_single_json_status($this->notice);
                 break;
             case 'atom':
                 $this->showSingleAtomStatus($this->notice);
                 break;
             default:
                 // TRANS: Exception thrown requesting an unsupported notice output format.
                 // TRANS: %s is the requested output format.
                 throw new Exception(sprintf(_("Unsupported format: %s."), $this->format));
         }
     } else {
         // XXX: Twitter just sets a 404 header and doens't bother
         // to return an err msg
         $deleted = Deleted_notice::staticGet($this->notice_id);
         if (!empty($deleted)) {
             $this->clientError(_('Status deleted.'), 410, $this->format);
         } else {
             $this->clientError(_('No status with that ID found.'), 404, $this->format);
         }
     }
 }
예제 #6
0
 /**
  * Fetch the notice to show. This may be overridden by child classes to
  * customize what we fetch without duplicating all of the prepare() method.
  *
  * @return Notice
  */
 function getNotice()
 {
     $id = $this->arg('notice');
     $notice = Notice::staticGet('id', $id);
     if (empty($notice)) {
         // Did we used to have it, and it got deleted?
         $deleted = Deleted_notice::staticGet($id);
         if (!empty($deleted)) {
             // TRANS: Client error displayed trying to show a deleted notice.
             $this->clientError(_('Notice deleted.'), 410);
         } else {
             // TRANS: Client error displayed trying to show a non-existing notice.
             $this->clientError(_('No such notice.'), 404);
         }
         return false;
     }
     return $notice;
 }