fingerprint.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * ElggPG -- Fingerprint output view
  4. *
  5. * @uses $vars['user'] The user entity
  6. *
  7. * @package Lorea
  8. * @subpackage ElggPG
  9. *
  10. * Copyright 2011-2013 Lorea Faeries <federation@lorea.org>
  11. *
  12. * This file is part of the ElggPG plugin for Elgg.
  13. *
  14. * ElggPG is free software: you can redistribute it and/or modify it
  15. * under the terms of the GNU Affero General Public License as
  16. * published by the Free Software Foundation, either version 3 of the
  17. * License, or (at your option) any later version.
  18. *
  19. * ElggPG is distributed in the hope that it will be useful, but
  20. * WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  22. * Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public
  25. * License along with this program. If not, see
  26. * <http://www.gnu.org/licenses/>.
  27. */
  28. $fingerprint = elgg_extract('value', $vars);
  29. // @todo Add access to fingerprint metadata
  30. $entity = elgg_get_page_owner_entity();
  31. if (elgg_instanceof($entity, 'user')
  32. && ($entity->isFriend() || $entity->guid == elgg_get_logged_in_user_guid()
  33. || elgg_is_admin_logged_in())) {
  34. $output = '';
  35. for ($i=0; $i<strlen($fingerprint); $i++) {
  36. $output .= $fingerprint[$i];
  37. if ($i % 4 == 3) {
  38. $output .= " ";
  39. }
  40. }
  41. if (elgg_in_context('profile')) {
  42. echo elgg_view('output/url', array(
  43. 'text' => substr($output, 0, 4 * 4 + 4),
  44. 'href' => 'elggpg/owner/' .elgg_get_page_owner_entity()->username,
  45. 'title' => $output,
  46. ));
  47. } else {
  48. echo $output;
  49. }
  50. } else {
  51. echo elgg_echo('access:limited:label');
  52. }