PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/content/code/trunk/modules/mod_artofcontent_add/helper.php

https://bitbucket.org/eddieajau/the-art-of-joomla-archive
PHP | 88 lines | 34 code | 10 blank | 44 comment | 3 complexity | e8def19608a59ca9d37c37fbe0404cfc MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id:combolayout.php 2547 2007-11-10 04:37:15Z masterchief $
  4. * @package NewLifeInIT
  5. * @subpackage mod_artofcontent_add
  6. * @copyright Copyright 2005 - 2010 New Life in IT Pty Ltd. All rights reserved.
  7. * @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
  8. * @author Andrew Eddie <andrew.eddie@newlifeinit.com>
  9. * @link http://www.theartofjoomla.com/extensions/artof-content.html
  10. */
  11. // No direct access.
  12. defined('JPATH_BASE') or die();
  13. /**
  14. * Artof Content Add module helper.
  15. *
  16. * @package NewLifeInIT
  17. * @subpackage mod_artofcontent_add
  18. * @since 1.0
  19. */
  20. class modArtofContentAddHelper
  21. {
  22. /**
  23. * Check if we can add an article to the active category (if there is one).
  24. *
  25. * @return boolean
  26. * @since 1.0
  27. */
  28. public static function canAdd()
  29. {
  30. // Look for the marker in the state.
  31. $app = JFactory::getApplication();
  32. if (self::isAdmin()) {
  33. return true;
  34. }
  35. else {
  36. return $app->get('com_artofcontent.core.create');
  37. }
  38. }
  39. /**
  40. * Get the category id.
  41. *
  42. * @return int
  43. * @since 1.0
  44. */
  45. public static function getCategoryId()
  46. {
  47. // Look for the marker in the state.
  48. $app = JFactory::getApplication();
  49. return (int) $app->get('com_artofcontent.category_id');
  50. }
  51. /**
  52. * Get the category id.
  53. *
  54. * @return int
  55. * @since 1.0
  56. */
  57. public static function getSectionId()
  58. {
  59. // Look for the marker in the state.
  60. $app = JFactory::getApplication();
  61. return (int) $app->get('com_artofcontent.section_id');
  62. }
  63. /**
  64. * Check if this user is an Admin.
  65. *
  66. * @return boolean
  67. * @since 1.0
  68. */
  69. protected function isAdmin()
  70. {
  71. static $result;
  72. if ($result === null) {
  73. $user = JFactory::getUser();
  74. $result = in_array($user->get('gid'), array(25, 24, 23));
  75. }
  76. return $result;
  77. }
  78. }