. * * @category Bookmark * @package StatusNet * @author Evan Prodromou * @copyright 2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ if (!defined('STATUSNET')) { // This check helps protect against security problems; // your code file can't be executed directly from the web. exit(1); } /** * Show a single bookmark, with associated information * * @category Bookmark * @package StatusNet * @author Evan Prodromou * @copyright 2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ class ShowbookmarkAction extends ShownoticeAction { protected $bookmark = null; /** * For initializing members of the class. * * @param array $argarray misc. arguments * * @return boolean true */ function prepare($argarray) { OwnerDesignAction::prepare($argarray); $this->user = User::staticGet('id', $this->trimmed('user')); if (empty($this->user)) { throw new ClientException(_('No such user.'), 404); } $this->profile = $this->user->getProfile(); if (empty($this->profile)) { throw new ServerException(_('User without a profile.')); } $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE); sscanf($this->trimmed('crc32'), '%08x', $crc32); if (empty($crc32)) { throw new ClientException(_('No such URL.'), 404); } $dt = new DateTime($this->trimmed('created'), new DateTimeZone('UTC')); if (empty($dt)) { throw new ClientException(_('No such create date.'), 404); } $bookmarks = Bookmark::getByCRC32($this->profile, $crc32); foreach ($bookmarks as $bookmark) { $bdt = new DateTime($bookmark->created, new DateTimeZone('UTC')); if ($bdt->format('U') == $dt->format('U')) { $this->bookmark = $bookmark; break; } } if (empty($this->bookmark)) { throw new ClientException(_('No such bookmark.'), 404); } $this->notice = Notice::staticGet('uri', $this->bookmark->uri); if (empty($this->notice)) { // Did we used to have it, and it got deleted? throw new ClientException(_('No such bookmark.'), 404); } return true; } /** * Title of the page * * Used by Action class for layout. * * @return string page tile */ function title() { return sprintf(_('%s\'s bookmark for "%s"'), $this->user->nickname, $this->bookmark->title); } /** * Overload page title display to show bookmark link * * @return void */ function showPageTitle() { $this->elementStart('h1'); $this->element('a', array('href' => $this->bookmark->url), $this->bookmark->title); $this->elementEnd('h1'); } }