Source for file Action.class.php

Documentation is available at Action.class.php

  1. <?php
  2. /**
  3. * @package polyphony.AbstractActions
  4. *
  5. * @copyright Copyright &copy; 2005, Middlebury College
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  7. *
  8. * @version $Id: Action.class.php,v 1.9 2007/09/19 14:04:41 adamfranco Exp $
  9. */
  10.  
  11. /**
  12. * This class is the most simple abstraction of an action. It provides a structure
  13. * for common methods
  14. *
  15. * @package polyphony.AbstractActions
  16. *
  17. * @copyright Copyright &copy; 2005, Middlebury College
  18. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  19. *
  20. * @version $Id: Action.class.php,v 1.9 2007/09/19 14:04:41 adamfranco Exp $
  21. * @since 4/28/05
  22. */
  23. class Action {
  24. /**
  25. * Check Authorizations
  26. *
  27. * @return boolean
  28. * @access public
  29. * @since 4/26/05
  30. */
  31. function isAuthorizedToExecute () {
  32. throwError(new Error(__CLASS__."::".__FUNCTION__."() must be overridded in child classes."));
  33. }
  34. /**
  35. * Answer the message to print when the user is not authorized to execute
  36. * this action
  37. *
  38. * @return string
  39. * @access public
  40. * @since 7/18/05
  41. */
  42. function getUnauthorizedMessage () {
  43. // Default implementation. Override as necessary.
  44. $harmoni = Harmoni::instance();
  45. $message = _("You are not authorized to ");
  46. if ($this->getHeadingText() == '') {
  47. $message .= _("execute this action, ");
  48. $message .= $harmoni->getCurrentAction();
  49. } else {
  50. $message .= $this->getHeadingText();
  51. }
  52. $message .= _(".");
  53. return $message;
  54. }
  55. /**
  56. * Return the heading text for this action, or an empty string.
  57. *
  58. * @return string
  59. * @access public
  60. * @since 4/26/05
  61. */
  62. function getHeadingText () {
  63. return '';
  64. }
  65. /**
  66. * Execute this action.
  67. *
  68. * @return mixed
  69. * @access public
  70. * @since 4/25/05
  71. */
  72. function execute () {
  73. throwError(new Error(__CLASS__."::".__FUNCTION__."() must be overridden in child classes."));
  74. }
  75. /**
  76. * Answer the requested module, maybe other than this action's module if this
  77. * action was chained onto another's request.
  78. *
  79. * @return string
  80. * @access public
  81. * @since 6/3/05
  82. */
  83. function requestedModule () {
  84. $harmoni = Harmoni::instance();
  85. list($module, $action) = explode(".", $harmoni->request->getRequestedModuleAction());
  86. return $module;
  87. }
  88. /**
  89. * Answer the requested action, maybe other than this action's action if this
  90. * action was chained onto another's request.
  91. *
  92. * @return string
  93. * @access public
  94. * @since 6/3/05
  95. */
  96. function requestedAction () {
  97. $harmoni = Harmoni::instance();
  98. list($module, $action) = explode(".", $harmoni->request->getRequestedModuleAction());
  99. return $action;
  100. }
  101. }
  102.  
  103. ?>

Documentation generated on Wed, 19 Sep 2007 10:21:17 -0400 by phpDocumentor 1.3.0RC3