/administrator/components/com_easyblog/elements/bloggers.php

https://bitbucket.org/pastor399/newcastleunifc · PHP · 79 lines · 58 code · 10 blank · 11 comment · 3 complexity · bf8380b09da5dc0c4113f63a6d73bc66 MD5 · raw file

  1. <?php
  2. /**
  3. * @package EasyBlog
  4. * @copyright Copyright (C) 2010 Stack Ideas Private Limited. All rights reserved.
  5. * @license GNU/GPL, see LICENSE.php
  6. * EasyBlog is free software. This version may have been modified pursuant
  7. * to the GNU General Public License, and as distributed it includes or
  8. * is derivative of works licensed under the GNU General Public License or
  9. * other free or open source software licenses.
  10. * See COPYRIGHT.php for copyright notices and details.
  11. */
  12. defined('_JEXEC') or die('Restricted access');
  13. class JElementBloggers extends JElement
  14. {
  15. var $_name = 'Bloggers';
  16. function fetchElement($name, $value, &$node, $control_name)
  17. {
  18. require_once( JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'constants.php' );
  19. require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'helper.php' );
  20. $mainframe = JFactory::getApplication();
  21. $db = EasyBlogHelper::db();
  22. $doc = JFactory::getDocument();
  23. require_once( JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'constants.php' );
  24. // get only bloggers
  25. $query = ' (SELECT a.`id`, a.`name`, a.`username`';
  26. $query .= ' FROM `#__users` AS `a`';
  27. $query .= ' INNER JOIN `#__core_acl_aro` AS `c` ON a.`id` = c.`value`';
  28. $query .= ' AND c.`section_value` = ' . $db->Quote('users');
  29. $query .= ' INNER JOIN `#__core_acl_groups_aro_map` AS `d` ON c.`id` = d.`aro_id`';
  30. $query .= ' INNER JOIN `#__easyblog_acl_group` AS `e` ON d.`group_id` = e.`content_id`';
  31. $query .= ' AND e.`type` = ' . $db->Quote('group') . ' AND e.`status` = 1';
  32. $query .= ' INNER JOIN `#__easyblog_acl` as `f` ON e.`acl_id` = f.`id`';
  33. $query .= ' AND f.`action` = ' . $db->Quote('add_entry');
  34. $query .= ' GROUP BY a.`id`';
  35. $query .= ' )';
  36. $query .= ' UNION ';
  37. $query .= ' (SELECT a1.`id`, a1.`name`, a1.`username`';
  38. $query .= ' FROM `#__users` AS `a1`';
  39. $query .= ' INNER JOIN `#__easyblog_acl_group` AS `c1` ON a1.`id` = c1.`content_id`';
  40. $query .= ' AND c1.`type` = ' . $db->Quote('assigned') . ' AND c1.`status` = 1';
  41. $query .= ' INNER JOIN `#__easyblog_acl` as `d1` ON c1.`acl_id` = d1.`id`';
  42. $query .= ' AND d1.`action` = ' . $db->Quote('add_entry');
  43. $query .= ' GROUP BY a1.`id`';
  44. $query .= ' ) ORDER BY `name` ASC';
  45. $db->setQuery($query);
  46. $data = $db->loadObjectList();
  47. ob_start();
  48. ?>
  49. <select name="<?php echo $control_name;?>[<?php echo $name;?>]">
  50. <option value="0"<?php echo $value == 0 ? ' selected="selected"' :'';?>><?php echo JText::_('Select a blogger');?></option>
  51. <?php
  52. if(count($data) > 0)
  53. {
  54. foreach($data as $blogger)
  55. {
  56. $selected = $blogger->id == $value ? ' selected="selected"' : '';
  57. ?>
  58. <option value="<?php echo $blogger->id;?>"<?php echo $selected;?>><?php echo $blogger->name . ' (' . $blogger->username . ')'; ?></option>
  59. <?php
  60. }
  61. }
  62. ?>
  63. </select>
  64. <?php
  65. $html = ob_get_contents();
  66. ob_end_clean();
  67. return $html;
  68. }
  69. }