Access.php 795 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace ColdTrick\BlogTools;
  3. class Access {
  4. /**
  5. * Correct version of blog can comment
  6. *
  7. * @param string $hook the name of the hook
  8. * @param string $type the type of the hook
  9. * @param bool $returnvalue current return value
  10. * @param array $params supplied params
  11. *
  12. * @return bool
  13. */
  14. public static function blogCanComment($hook, $type, $returnvalue, $params) {
  15. if (empty($params) || !is_array($params)) {
  16. return $returnvalue;
  17. }
  18. $entity = elgg_extract('entity', $params);
  19. if (empty($entity) || !elgg_instanceof($entity, 'object', 'blog')) {
  20. return $returnvalue;
  21. }
  22. $returnvalue = false;
  23. if ($entity->comments_on != 'Off' && $entity->status == 'published') {
  24. $returnvalue = true;
  25. }
  26. return $returnvalue;
  27. }
  28. }