Source for file auth.php

Documentation is available at auth.php

  1. <?php
  2.  
  3. class net_nemein_reservations_auth {
  4. var $user;
  5. var $_midgard;
  6. var $_poweruser;
  7. function net_nemein_reservations_auth($topic = null) {
  8. $this->_midgard = mgd_get_midgard();
  9. $this->user = mgd_get_person($this->_midgard->user);
  10. if ($this->user === false)
  11. {
  12. debug_add ("User in \$midgard was not found: " . mgd_errstr());
  13. $this->user = null;
  14. $this->_poweruser = false;
  15. }
  16. else
  17. {
  18. $this->_poweruser = $this->user->parameter("Interface","Power_User") != "NO" ? true : false;
  19. }
  20. }
  21. function is_admin() {
  22. return ($this->_midgard->admin == true);
  23. }
  24. function is_poweruser() {
  25. if ($this->is_admin())
  26. {
  27. return true;
  28. }
  29. if (! $this->is_owner())
  30. {
  31. return false;
  32. }
  33. return $this->_poweruser;
  34. }
  35. function is_owner($topic = null) {
  36. if ($this->is_admin())
  37. {
  38. return true;
  39. }
  40. if (is_null($topic))
  41. {
  42. return mgd_is_topic_owner($GLOBALS['midcom']->get_context_data(MIDCOM_CONTEXT_CONTENTTOPIC));
  43. }
  44. else
  45. {
  46. return mgd_is_topic_owner($topic);
  47. }
  48. }
  49. function check_is_owner() {
  50. $this->_check($this->is_owner(), "auth: need to be owner");
  51. }
  52. function check_is_poweruser() {
  53. $this->_check($this->is_owner(), "auth: need to be poweruser");
  54. }
  55. function check_is_admin() {
  56. $this->_check($this->is_owner(), "auth: need to be admin");
  57. }
  58. function _check($ok, $msg) {
  59. if (! $ok)
  60. {
  61. $GLOBALS["midcom"]->generate_error($this->_l10n->get($msg), MIDCOM_ERRFORBIDDEN);
  62. }
  63. }
  64. }
  65.  
  66. ?>

Documentation generated on Mon, 21 Nov 2005 18:12:16 +0100 by phpDocumentor 1.3.0RC3