/administrator/components/com_easyblog/elements/teamblogs.php

https://bitbucket.org/pastor399/newcastleunifc · PHP · 62 lines · 42 code · 9 blank · 11 comment · 3 complexity · e944f2bb1ff3ce0afb7e55d6bafe80af 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 JElementTeamBlogs extends JElement
  14. {
  15. var $_name = 'Teamblogs';
  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.`title` FROM ' . $db->nameQuote( '#__easyblog_team' ) . ' AS a';
  26. $query .= ' LEFT JOIN `#__easyblog_team_users` AS b ON a.`id` = b.`team_id` ';
  27. $query .= ' WHERE a.`published` = ' . $db->Quote( '1' );
  28. $query .= ' ORDER BY a.`id` DESC';
  29. $db->setQuery($query);
  30. $data = $db->loadObjectList();
  31. ob_start();
  32. ?>
  33. <select name="<?php echo $control_name;?>[<?php echo $name;?>]">
  34. <option value="0"<?php echo $value == 0 ? ' selected="selected"' :'';?>><?php echo JText::_('Select a team');?></option>
  35. <?php
  36. if(count($data) > 0)
  37. {
  38. foreach($data as $team)
  39. {
  40. $selected = $team->id == $value ? ' selected="selected"' : '';
  41. ?>
  42. <option value="<?php echo $team->id;?>"<?php echo $selected;?>><?php echo '(' . $team->id . ') ' . $team->title; ?></option>
  43. <?php
  44. }
  45. }
  46. ?>
  47. </select>
  48. <?php
  49. $html = ob_get_contents();
  50. ob_end_clean();
  51. return $html;
  52. }
  53. }