Source for file _auth.php

Documentation is available at _auth.php

  1. <?php
  2. /**
  3. * @package net.nemein.incidentdb
  4. * @author The Midgard Project, http://www.midgard-project.org
  5. * @version $Id: _auth.php,v 1.2 2005/03/12 09:57:23 torben Exp $
  6. * @copyright The Midgard Project, http://www.midgard-project.org
  7. * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
  8. */
  9.  
  10. /**
  11. * IncidentDB Authentication/Authorization helper class
  12. *
  13. * @todo document
  14. *
  15. * @package net.nemein.incidentdb
  16. */
  17. class net_nemein_incidentdb__auth {
  18. var $_midgard;
  19. var $_person;
  20. var $_mgrgroup;
  21. var $_rptgroup;
  22. var $_canwrite;
  23. var $_ismanager;
  24. var $_ispoweruser;
  25.  
  26. var $_topic;
  27. var $_config;
  28. function net_nemein_incidentdb__auth ($topic, $config) {
  29. $this->_topic = $topic;
  30. $this->_config = $config;
  31. $this->_midgard = mgd_get_midgard();
  32. if (! $this->_midgard->user) {
  33. $GLOBALS["midcom"]->generate_error(MIDCOM_ERRFORBIDDEN,
  34. "Authentication failed (Midgard Auth not enabled?)");
  35. }
  36. $this->_person = mgd_get_person($this->_midgard->user);
  37. $this->_mgrgroup = mgd_get_object_by_guid($this->_config->get("managergrpguid"));
  38. $this->_rptgroup = $this->_get_topic_ownergrp($this->_topic);
  39. $this->_canwrite = mgd_is_topic_owner($this->_topic->id) ? true : false;
  40. $this->_ismanager = mgd_is_member($this->_mgrgroup->id) ? true : false;
  41. $this->_ispoweruser = $this->_person->parameter("Interface","Power_User") != "NO" ? true : false;
  42. }
  43. function get_midgard() { return $this->_midgard; }
  44. function get_person() { return $this->_person; }
  45. function get_mgrgroup() { return $this->_mgrgroup; }
  46. function get_rptgroup() { return $this->_rptgroup; }
  47. function can_write() { return $this->_canwrite; }
  48. function is_manager() { return $this->_ismanager; }
  49. function is_poweruser() { return $this->_ispoweruser; }
  50. function _get_topic_ownergrp ($topic) {
  51. while ($topic->owner == 0 && $topic->up != 0)
  52. $topic = mgd_get_topic ($topic->up);
  53. if ($topic && $topic->owner != 0) {
  54. return mgd_get_group($topic->owner);
  55. } else {
  56. $sg = mgd_get_sitegroup($this->_midgard->sitegroup);
  57. return mgd_get_group($sg->admingroup);
  58. }
  59. }
  60. }
  61.  
  62.  
  63.  
  64. ?>

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