Source for file navigation.php

Documentation is available at navigation.php

  1. <?php
  2.  
  3. class net_nemein_reservations_navigation {
  4. var $_object;
  5. var $_config;
  6. var $_root_group;
  7. var $_l10n;
  8. var $_l10n_midcom;
  9. var $_auth;
  10. function net_nemein_reservations_navigation() {
  11. $this->_object = null;
  12. $this->_config = $GLOBALS["net_nemein_reservations__default_config"];
  13. $i18n =& $GLOBALS["midcom"]->get_service("i18n");
  14. $this->_l10n = $i18n->get_l10n("net.nemein.reservations");
  15. $this->_l10n_midcom = $i18n->get_l10n("midcom");
  16. $this->_auth = new net_nemein_reservations_auth();
  17. }
  18. function is_internal() {
  19. return false;
  20. }
  21. function get_leaves() {
  22. $ret = Array();
  23. $memberships = mgd_list_members($this->_root_group->id);
  24. if ($memberships)
  25. {
  26. while ($memberships->fetch())
  27. {
  28. $person = mgd_get_person($memberships->uid);
  29. if (! $person)
  30. {
  31. continue;
  32. }
  33. $toolbar = Array();
  34. if ($this->_auth->is_admin()) {
  35. $toolbar[50] = Array(
  36. MIDCOM_TOOLBAR_URL => "resource/edit/{$person->id}.html",
  37. MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('edit resource'),
  38. MIDCOM_TOOLBAR_HELPTEXT => null,
  39. MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png',
  40. MIDCOM_TOOLBAR_ENABLED => true
  41. );
  42. $toolbar[51] = Array(
  43. MIDCOM_TOOLBAR_URL => "resource/delete/{$person->id}.html",
  44. MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('delete resource'),
  45. MIDCOM_TOOLBAR_HELPTEXT => null,
  46. MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png',
  47. MIDCOM_TOOLBAR_ENABLED => true
  48. );
  49. }
  50. $ret[$person->id] = array (
  51. MIDCOM_NAV_SITE => Array (
  52. MIDCOM_NAV_URL => $person->guid() . ".html",
  53. MIDCOM_NAV_NAME => $person->name),
  54. MIDCOM_NAV_ADMIN => Array (
  55. MIDCOM_NAV_URL => "resource/view/{$person->id}.html",
  56. MIDCOM_NAV_NAME => $person->name),
  57. MIDCOM_NAV_GUID => $person->guid(),
  58. MIDCOM_NAV_TOOLBAR => ((count($toolbar) > 0) ? $toolbar : null),
  59. MIDCOM_META_CREATOR => $person->creator,
  60. MIDCOM_META_EDITOR => $person->creator,
  61. MIDCOM_META_CREATED => $person->created,
  62. MIDCOM_META_EDITED => $person->created
  63. );
  64. }
  65. }
  66. return $ret;
  67. }
  68. function get_node() {
  69. $topic = &$this->_object;
  70. $toolbar = Array();
  71. if ($this->_auth->is_poweruser())
  72. {
  73. $toolbar[100] = Array(
  74. MIDCOM_TOOLBAR_URL => 'config.html',
  75. MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('component configuration'),
  76. MIDCOM_TOOLBAR_HELPTEXT => $this->_l10n_midcom->get('component configuration helptext'),
  77. MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_folder-properties.png',
  78. MIDCOM_TOOLBAR_ENABLED => true
  79. );
  80. /* Add the new article link at the beginning*/
  81. $toolbar[0] = Array(
  82. MIDCOM_TOOLBAR_URL => 'resource/create.html',
  83. MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('create resource'),
  84. MIDCOM_TOOLBAR_HELPTEXT => null,
  85. MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_new.png',
  86. MIDCOM_TOOLBAR_ENABLED => true
  87. );
  88. }
  89. if ($this->_auth->is_admin())
  90. {
  91. $toolbar[101] = Array(
  92. MIDCOM_TOOLBAR_URL => 'reservation/maintain.html',
  93. MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('incomplete/corrupt reservations'),
  94. MIDCOM_TOOLBAR_HELPTEXT => null,
  95. MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/repair.png',
  96. MIDCOM_TOOLBAR_ENABLED => true
  97. );
  98. }
  99. return array (
  100. MIDCOM_NAV_URL => "",
  101. MIDCOM_NAV_NAME => $topic->extra,
  102. MIDCOM_NAV_TOOLBAR => ((count($toolbar) > 0) ? $toolbar : null),
  103. MIDCOM_META_CREATOR => $topic->creator,
  104. MIDCOM_META_EDITOR => $topic->revisor,
  105. MIDCOM_META_CREATED => $topic->created,
  106. MIDCOM_META_EDITED => $topic->revised
  107. );
  108. }
  109. function set_object($object) {
  110. $this->_object = $object;
  111. $this->_config->store_from_object($object, "net.nemein.reservations");
  112. $guid = $this->_config->get("root_group_guid");
  113. if (! is_null ($guid))
  114. {
  115. $object = mgd_get_object_by_guid($guid);
  116. if ($object == false || $object->__table__ != "grp")
  117. {
  118. debug_add("We could not successfully load the root group, the guid was [$guid], "
  119. . "last Midgard Error was: " . mgd_errstr(), MIDCOM_LOG_ERROR);
  120. debug_print_r("Resulting object dump: ", $object);
  121.  
  122. $GLOBALS["midcom"]->generate_error(MIDCOM_ERRCRIT,
  123. "Invalid configuration, root_group_guid [$guid] is invalid.");
  124. }
  125. $this->_root_group = $object;
  126. }
  127. return true;
  128. }
  129. function get_current_leaf() {
  130. if (array_key_exists("net_nemein_reservations_current_leaf", $GLOBALS))
  131. {
  132. return $GLOBALS["net_nemein_reservations_current_leaf"];
  133. }
  134. return false;
  135. }
  136. } // navigation
  137.  
  138. ?>

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