Commit bfe9d1aff18bf626afc2d838e86c12428024a311
1 parent
e5a77c7c
debug logging
fixed group handling for page level access git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@201 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
25 additions
and
11 deletions
lib/SiteMap.inc
| @@ -45,25 +45,38 @@ class SiteMap { | @@ -45,25 +45,38 @@ class SiteMap { | ||
| 45 | * | 45 | * |
| 46 | * @param $action | 46 | * @param $action |
| 47 | * the action to lookup pages for | 47 | * the action to lookup pages for |
| 48 | - * @param $groupID | ||
| 49 | - * the user group ID to perform page level validation against | 48 | + * @param $groupIDs |
| 49 | + * array of user group IDs to perform page level validation against | ||
| 50 | * @return | 50 | * @return |
| 51 | * the page to redirect to, or false if the user class doesn't | 51 | * the page to redirect to, or false if the user class doesn't |
| 52 | * have access to the page | 52 | * have access to the page |
| 53 | */ | 53 | */ |
| 54 | - function getPage($action, $groupID) { | 54 | + function getPage($action, $groupIDs) { |
| 55 | global $default; | 55 | global $default; |
| 56 | - | 56 | + $default->log->debug("Sitemap::getPage function start; action=$action; groupIDs=" . arrayToString($groupIDs)); |
| 57 | // for each section | 57 | // for each section |
| 58 | foreach ($this->siteMapArray as $section => $valArr) { | 58 | foreach ($this->siteMapArray as $section => $valArr) { |
| 59 | + $default->log->debug("Sitemap::getPage section=$section"); | ||
| 59 | // for each group, page array combination | 60 | // for each group, page array combination |
| 60 | foreach ($valArr as $requiredGroup => $pageArr) { | 61 | foreach ($valArr as $requiredGroup => $pageArr) { |
| 61 | - $reqGrpID = lookup_id($default->owl_groups_table, "name", $requiredGroup); | ||
| 62 | - if ($groupID <= lookup_id($default->owl_groups_table, "name", $requiredGroup)) { | ||
| 63 | - // now loop through pages until we find the right one | ||
| 64 | - foreach ($pageArr as $ackshin => $page) { | ||
| 65 | - if ($ackshin == $action) { | ||
| 66 | - return $page; | 62 | + $reqGrpID = lookupID($default->owl_groups_table, "name", $requiredGroup); |
| 63 | + $default->log->debug("Sitemap::getPage requiredGroup=$requiredGroup; reqGrpID=$reqGrpID"); | ||
| 64 | + // now loop through pages until we find the right one | ||
| 65 | + foreach ($pageArr as $ackshin => $page) { | ||
| 66 | + if ($ackshin == $action) { | ||
| 67 | + // now check if we have the right group access by | ||
| 68 | + // looping through the groupID array and returning the page | ||
| 69 | + // if the current groupID <= $reqGrpID | ||
| 70 | + | ||
| 71 | + // FIXME: this won't work once we have lots of groups will it?? | ||
| 72 | + // we're assuming that the default groups will be created in the right | ||
| 73 | + // order, so that groups with sys and unit access have lower ids than | ||
| 74 | + // the required ones! | ||
| 75 | + for ($i = 0; $i<count($groupIDs); $i++) { | ||
| 76 | + $default->log->debug("Sitemap::getPage current groupid=" . $groupIDs[$i] . "; reqGrpID=$reqGrpID"); | ||
| 77 | + if ($groupIDs[$i] <= $reqGrpID) { | ||
| 78 | + return $page; | ||
| 79 | + } | ||
| 67 | } | 80 | } |
| 68 | } | 81 | } |
| 69 | } | 82 | } |
| @@ -106,6 +119,7 @@ class SiteMap { | @@ -106,6 +119,7 @@ class SiteMap { | ||
| 106 | } else { | 119 | } else { |
| 107 | // supplied section not in sitemap | 120 | // supplied section not in sitemap |
| 108 | // TODO: internal error code? | 121 | // TODO: internal error code? |
| 122 | + $_SESSION["errorMessage"] = "$sectionName not in SiteMap!"; | ||
| 109 | return false; | 123 | return false; |
| 110 | } | 124 | } |
| 111 | } | 125 | } |
| @@ -114,7 +128,7 @@ class SiteMap { | @@ -114,7 +128,7 @@ class SiteMap { | ||
| 114 | * Prints the current site map | 128 | * Prints the current site map |
| 115 | */ | 129 | */ |
| 116 | function printMap() { | 130 | function printMap() { |
| 117 | - print_r($this->siteMapArray); | 131 | + return arrayToString($this->siteMapArray); |
| 118 | } | 132 | } |
| 119 | } | 133 | } |
| 120 | ?> | 134 | ?> |