privatestreamexception.php 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. if (!defined('GNUSOCIAL')) { exit(1); }
  3. /**
  4. * An exception for private streams
  5. *
  6. * @category Exception
  7. * @package GNUsocial
  8. * @author Mikael Nordfeldth <mmn@hethane.se>
  9. * @copyright 2016 Free Software Foundation, Inc.
  10. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  11. */
  12. class PrivateStreamException extends AuthorizationException
  13. {
  14. var $owner = null; // owner of the private stream
  15. var $reader = null; // reader, may be null if not logged in
  16. public function __construct(Profile $owner, Profile $reader=null)
  17. {
  18. $this->owner = $owner;
  19. $this->reader = $reader;
  20. // TRANS: Message when a private stream attemps to be read by unauthorized third party.
  21. $msg = sprintf(_m('This stream is protected and only authorized subscribers may see its contents.'));
  22. // If $reader is a profile, authentication has been made but still not accepted (403),
  23. // otherwise authentication may give access to this resource (401).
  24. parent::__construct($msg, ($reader instanceof Profile ? 403 : 401));
  25. }
  26. }