Commit 8dab968a08754f30dcc4d219d64d4dc8c78ba6b9
1 parent
a93f299f
formatting update
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@812 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
66 additions
and
66 deletions
lib/session/SiteMap.inc
| @@ -24,12 +24,12 @@ class SiteMap { | @@ -24,12 +24,12 @@ class SiteMap { | ||
| 24 | * The underlying site map storage array | 24 | * The underlying site map storage array |
| 25 | */ | 25 | */ |
| 26 | var $aSiteMap; | 26 | var $aSiteMap; |
| 27 | - | 27 | + |
| 28 | /** | 28 | /** |
| 29 | * Whether to use the database to store the sitemap or not | 29 | * Whether to use the database to store the sitemap or not |
| 30 | */ | 30 | */ |
| 31 | var $bUseDB; | 31 | var $bUseDB; |
| 32 | - | 32 | + |
| 33 | /** | 33 | /** |
| 34 | * Constructs a new SiteMap | 34 | * Constructs a new SiteMap |
| 35 | * If the db is not being used, the array is initialised. | 35 | * If the db is not being used, the array is initialised. |
| @@ -42,7 +42,7 @@ class SiteMap { | @@ -42,7 +42,7 @@ class SiteMap { | ||
| 42 | $this->aSiteMap = array(); | 42 | $this->aSiteMap = array(); |
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | - | 45 | + |
| 46 | /** | 46 | /** |
| 47 | * Sets the database flag | 47 | * Sets the database flag |
| 48 | * | 48 | * |
| @@ -51,15 +51,15 @@ class SiteMap { | @@ -51,15 +51,15 @@ class SiteMap { | ||
| 51 | function setUseDB($bUseDB) { | 51 | function setUseDB($bUseDB) { |
| 52 | $this->bUseDB = $bUseDB; | 52 | $this->bUseDB = $bUseDB; |
| 53 | } | 53 | } |
| 54 | - | 54 | + |
| 55 | /** | 55 | /** |
| 56 | * Returns the database flag | 56 | * Returns the database flag |
| 57 | */ | 57 | */ |
| 58 | function getUseDB() { | 58 | function getUseDB() { |
| 59 | return $this->bUseDB; | 59 | return $this->bUseDB; |
| 60 | } | 60 | } |
| 61 | - | ||
| 62 | - | 61 | + |
| 62 | + | ||
| 63 | /** | 63 | /** |
| 64 | * Adds a site page mapping entry. | 64 | * Adds a site page mapping entry. |
| 65 | * | 65 | * |
| @@ -72,13 +72,13 @@ class SiteMap { | @@ -72,13 +72,13 @@ class SiteMap { | ||
| 72 | */ | 72 | */ |
| 73 | function addPage($sAction, $sPage, $sSectionName, $sRequiredAccess, $sLinkText, $bEnabled = true) { | 73 | function addPage($sAction, $sPage, $sSectionName, $sRequiredAccess, $sLinkText, $bEnabled = true) { |
| 74 | if (!$this->bUseDB) { | 74 | if (!$this->bUseDB) { |
| 75 | - $this->aSiteMap[$sSectionName][$sRequiredAccess][$sAction] = array ("page" => $sPage, | ||
| 76 | - "description" => $sLinkText, | ||
| 77 | - "enabled" => (($bEnabled) ? "1" : "0"), | ||
| 78 | - "default" => "0"); | 75 | + $this->aSiteMap[$sSectionName][$sRequiredAccess][$sAction] = array ("page" => $sPage, |
| 76 | + "description" => $sLinkText, | ||
| 77 | + "enabled" => (($bEnabled) ? "1" : "0"), | ||
| 78 | + "default" => "0"); | ||
| 79 | } | 79 | } |
| 80 | } | 80 | } |
| 81 | - | 81 | + |
| 82 | /** | 82 | /** |
| 83 | * Adds a site page mapping entry- the default page for the section. | 83 | * Adds a site page mapping entry- the default page for the section. |
| 84 | * | 84 | * |
| @@ -87,16 +87,16 @@ class SiteMap { | @@ -87,16 +87,16 @@ class SiteMap { | ||
| 87 | * @param string the section this page falls under | 87 | * @param string the section this page falls under |
| 88 | * @param int the minimum access needed to access this page | 88 | * @param int the minimum access needed to access this page |
| 89 | * @param string description of the page for link presentation | 89 | * @param string description of the page for link presentation |
| 90 | - */ | 90 | + */ |
| 91 | function addDefaultPage($sAction, $sPage, $sSectionName, $sRequiredAccess, $sLinkText, $bEnabled = true) { | 91 | function addDefaultPage($sAction, $sPage, $sSectionName, $sRequiredAccess, $sLinkText, $bEnabled = true) { |
| 92 | if (!$this->bUseDB) { | 92 | if (!$this->bUseDB) { |
| 93 | - $this->aSiteMap[$sSectionName][$sRequiredAccess][$sAction] = array ("page" => $sPage, | ||
| 94 | - "description" => $sLinkText, | ||
| 95 | - "enabled" => (($bEnabled) ? "1" : "0"), | ||
| 96 | - "default" => "1"); | 93 | + $this->aSiteMap[$sSectionName][$sRequiredAccess][$sAction] = array ("page" => $sPage, |
| 94 | + "description" => $sLinkText, | ||
| 95 | + "enabled" => (($bEnabled) ? "1" : "0"), | ||
| 96 | + "default" => "1"); | ||
| 97 | } | 97 | } |
| 98 | } | 98 | } |
| 99 | - | 99 | + |
| 100 | /** | 100 | /** |
| 101 | * Returns true if the user has the necessary rights to access | 101 | * Returns true if the user has the necessary rights to access |
| 102 | * a sitemap entry | 102 | * a sitemap entry |
| @@ -114,7 +114,7 @@ class SiteMap { | @@ -114,7 +114,7 @@ class SiteMap { | ||
| 114 | // if you're a system administrator, you've got access to everything | 114 | // if you're a system administrator, you've got access to everything |
| 115 | if (Permission::userIsSystemAdministrator()) { | 115 | if (Permission::userIsSystemAdministrator()) { |
| 116 | return true; | 116 | return true; |
| 117 | - } else { | 117 | + } else { |
| 118 | if (Permission::userIsUnitAdministrator()) { | 118 | if (Permission::userIsUnitAdministrator()) { |
| 119 | // if you're a unit administrator, then you have access to everything | 119 | // if you're a unit administrator, then you have access to everything |
| 120 | // including and less than UA | 120 | // including and less than UA |
| @@ -133,13 +133,13 @@ class SiteMap { | @@ -133,13 +133,13 @@ class SiteMap { | ||
| 133 | // return false anyway | 133 | // return false anyway |
| 134 | return false; | 134 | return false; |
| 135 | } | 135 | } |
| 136 | - | 136 | + |
| 137 | /** | 137 | /** |
| 138 | * Returns controller links for a section. | 138 | * Returns controller links for a section. |
| 139 | * Checks whether to use the db or not and calls the appropriate method | 139 | * Checks whether to use the db or not and calls the appropriate method |
| 140 | * | 140 | * |
| 141 | * @param string the section to return links for | 141 | * @param string the section to return links for |
| 142 | - */ | 142 | + */ |
| 143 | function getSectionLinks($sSectionName) { | 143 | function getSectionLinks($sSectionName) { |
| 144 | if ($this->bUseDB) { | 144 | if ($this->bUseDB) { |
| 145 | return $this->getSectionLinksUsingDB($sSectionName); | 145 | return $this->getSectionLinksUsingDB($sSectionName); |
| @@ -147,7 +147,7 @@ class SiteMap { | @@ -147,7 +147,7 @@ class SiteMap { | ||
| 147 | return $this->getSectionLinksUsingArray($sSectionName); | 147 | return $this->getSectionLinksUsingArray($sSectionName); |
| 148 | } | 148 | } |
| 149 | } | 149 | } |
| 150 | - | 150 | + |
| 151 | /** | 151 | /** |
| 152 | * Returns controller links for a section (uses the db) | 152 | * Returns controller links for a section (uses the db) |
| 153 | * | 153 | * |
| @@ -161,17 +161,17 @@ class SiteMap { | @@ -161,17 +161,17 @@ class SiteMap { | ||
| 161 | if ($sectionID) { | 161 | if ($sectionID) { |
| 162 | // initialise result array | 162 | // initialise result array |
| 163 | $results = array("descriptions" => array(), "links" => array()); | 163 | $results = array("descriptions" => array(), "links" => array()); |
| 164 | - | ||
| 165 | - if ($sql->query("SELECT link_text, action, access_id FROM $default->owl_sitemap_table WHERE section_id=$sectionID AND is_enabled=1")) { | 164 | + |
| 165 | + if ($sql->query("SELECT link_text, action, access_id FROM $default->owl_sitemap_table WHERE section_id=$sectionID AND is_enabled=1")) { | ||
| 166 | while ($sql->next_record()) { | 166 | while ($sql->next_record()) { |
| 167 | // check permissions | 167 | // check permissions |
| 168 | if ($this->hasPermission($sql->f("access_id"))) { | 168 | if ($this->hasPermission($sql->f("access_id"))) { |
| 169 | // add this array to the resultset array if there is link text | 169 | // add this array to the resultset array if there is link text |
| 170 | if (strlen($sql->f("link_text")) > 0) { | 170 | if (strlen($sql->f("link_text")) > 0) { |
| 171 | - $results["descriptions"][] = $sql->f("link_text"); | 171 | + $results["descriptions"][] = $sql->f("link_text"); |
| 172 | // if fFolderID is set and fFolderID is in the page string | 172 | // if fFolderID is set and fFolderID is in the page string |
| 173 | // append folderID to the controller link | 173 | // append folderID to the controller link |
| 174 | - $results["links"][] = $fFolderID ? generateControllerUrl($sql->f("action") . "&fFolderID=$fFolderID") : generateControllerUrl($sql->f("action")); | 174 | + $results["links"][] = $fFolderID ? generateControllerUrl($sql->f("action"), "fFolderID=$fFolderID") : generateControllerUrl($sql->f("action")); |
| 175 | } | 175 | } |
| 176 | } | 176 | } |
| 177 | } | 177 | } |
| @@ -180,7 +180,7 @@ class SiteMap { | @@ -180,7 +180,7 @@ class SiteMap { | ||
| 180 | return $results; | 180 | return $results; |
| 181 | } else { | 181 | } else { |
| 182 | return false; | 182 | return false; |
| 183 | - } | 183 | + } |
| 184 | } else { | 184 | } else { |
| 185 | $_SESSION["errorMessage"] = $lang_err_database; | 185 | $_SESSION["errorMessage"] = $lang_err_database; |
| 186 | return false; | 186 | return false; |
| @@ -190,7 +190,7 @@ class SiteMap { | @@ -190,7 +190,7 @@ class SiteMap { | ||
| 190 | return false; | 190 | return false; |
| 191 | } | 191 | } |
| 192 | } | 192 | } |
| 193 | - | 193 | + |
| 194 | /** | 194 | /** |
| 195 | * Returns controller links for a section (uses the array) | 195 | * Returns controller links for a section (uses the array) |
| 196 | * | 196 | * |
| @@ -199,24 +199,24 @@ class SiteMap { | @@ -199,24 +199,24 @@ class SiteMap { | ||
| 199 | function getSectionLinksUsingArray($sSectionName) { | 199 | function getSectionLinksUsingArray($sSectionName) { |
| 200 | global $default, $fFolderID, $fDocumentID; | 200 | global $default, $fFolderID, $fDocumentID; |
| 201 | // TODO: same for documentID | 201 | // TODO: same for documentID |
| 202 | - | 202 | + |
| 203 | // check if the section exists | 203 | // check if the section exists |
| 204 | if (is_array($this->aSiteMap[$sSectionName])) { | 204 | if (is_array($this->aSiteMap[$sSectionName])) { |
| 205 | // initialise result array | 205 | // initialise result array |
| 206 | $results = array("descriptions" => array(), "links" => array()); | 206 | $results = array("descriptions" => array(), "links" => array()); |
| 207 | - | 207 | + |
| 208 | // need to loop through all (access, page) arrays in this section | 208 | // need to loop through all (access, page) arrays in this section |
| 209 | foreach ($this->aSiteMap[$sSectionName] as $requiredAccess => $pages) { | 209 | foreach ($this->aSiteMap[$sSectionName] as $requiredAccess => $pages) { |
| 210 | if ($this->hasPermission($requiredAccess)) { | 210 | if ($this->hasPermission($requiredAccess)) { |
| 211 | foreach ($pages as $action => $pageDetail) { | 211 | foreach ($pages as $action => $pageDetail) { |
| 212 | // add this array to the resultset array if there is link text | 212 | // add this array to the resultset array if there is link text |
| 213 | if ((strlen($pages[$action]["description"]) > 0) && | 213 | if ((strlen($pages[$action]["description"]) > 0) && |
| 214 | - ($pages[$action]["enabled"])) { | 214 | + ($pages[$action]["enabled"])) { |
| 215 | 215 | ||
| 216 | $results["descriptions"][] = $pages[$action]["description"]; | 216 | $results["descriptions"][] = $pages[$action]["description"]; |
| 217 | // if fFolderID is set and fFolderID is in the page string | 217 | // if fFolderID is set and fFolderID is in the page string |
| 218 | // append folderID to the controller link | 218 | // append folderID to the controller link |
| 219 | - $results["links"][] = $fFolderID ? generateControllerUrl($action . "&fFolderID=$fFolderID") : generateControllerUrl($action); | 219 | + $results["links"][] = $fFolderID ? generateControllerUrl($action, "fFolderID=$fFolderID") : generateControllerUrl($action); |
| 220 | } | 220 | } |
| 221 | } | 221 | } |
| 222 | } | 222 | } |
| @@ -226,20 +226,20 @@ class SiteMap { | @@ -226,20 +226,20 @@ class SiteMap { | ||
| 226 | return $results; | 226 | return $results; |
| 227 | } else { | 227 | } else { |
| 228 | return false; | 228 | return false; |
| 229 | - } | 229 | + } |
| 230 | } else { | 230 | } else { |
| 231 | $_SESSION["errorMessage"] = "No such section name ($sSectionName) in the sitemap"; | 231 | $_SESSION["errorMessage"] = "No such section name ($sSectionName) in the sitemap"; |
| 232 | return false; | 232 | return false; |
| 233 | } | 233 | } |
| 234 | } | 234 | } |
| 235 | - | 235 | + |
| 236 | /** | 236 | /** |
| 237 | * Returns the page mapped to the (action, groupName) pair. | 237 | * Returns the page mapped to the (action, groupName) pair. |
| 238 | * Checks whether to use the db or not and calls the appropriate method | 238 | * Checks whether to use the db or not and calls the appropriate method |
| 239 | * | 239 | * |
| 240 | * @param string the action to lookup pages for | 240 | * @param string the action to lookup pages for |
| 241 | * @return string the page to redirect to, or false if the user doesn't have access to the page | 241 | * @return string the page to redirect to, or false if the user doesn't have access to the page |
| 242 | - */ | 242 | + */ |
| 243 | function getPage($action) { | 243 | function getPage($action) { |
| 244 | if ($this->bUseDB) { | 244 | if ($this->bUseDB) { |
| 245 | return $this->getPageUsingDB($action); | 245 | return $this->getPageUsingDB($action); |
| @@ -247,7 +247,7 @@ class SiteMap { | @@ -247,7 +247,7 @@ class SiteMap { | ||
| 247 | return $this->getPageUsingArray($action); | 247 | return $this->getPageUsingArray($action); |
| 248 | } | 248 | } |
| 249 | } | 249 | } |
| 250 | - | 250 | + |
| 251 | /** | 251 | /** |
| 252 | * Returns the page mapped to the (action, groupName) pair. (uses the db) | 252 | * Returns the page mapped to the (action, groupName) pair. (uses the db) |
| 253 | * | 253 | * |
| @@ -258,7 +258,7 @@ class SiteMap { | @@ -258,7 +258,7 @@ class SiteMap { | ||
| 258 | global $default, $lang_err_database; | 258 | global $default, $lang_err_database; |
| 259 | $sql = $default->db; | 259 | $sql = $default->db; |
| 260 | // lookup the page and access_id from the sitemap | 260 | // lookup the page and access_id from the sitemap |
| 261 | - if ($sql->query("SELECT page, access_id FROM $default->owl_sitemap_table WHERE action='$action'")) { | 261 | + if ($sql->query("SELECT page, access_id FROM $default->owl_sitemap_table WHERE action='$action'")) { |
| 262 | if ($sql->next_record()) { | 262 | if ($sql->next_record()) { |
| 263 | // check permissions | 263 | // check permissions |
| 264 | if ($this->hasPermission($sql->f("access_id"))) { | 264 | if ($this->hasPermission($sql->f("access_id"))) { |
| @@ -274,7 +274,7 @@ class SiteMap { | @@ -274,7 +274,7 @@ class SiteMap { | ||
| 274 | return false; | 274 | return false; |
| 275 | } | 275 | } |
| 276 | } | 276 | } |
| 277 | - | 277 | + |
| 278 | /** | 278 | /** |
| 279 | * Returns the page mapped to the (action, groupName) pair. (uses the array) | 279 | * Returns the page mapped to the (action, groupName) pair. (uses the array) |
| 280 | * | 280 | * |
| @@ -283,10 +283,10 @@ class SiteMap { | @@ -283,10 +283,10 @@ class SiteMap { | ||
| 283 | */ | 283 | */ |
| 284 | function getPageUsingArray($action) { | 284 | function getPageUsingArray($action) { |
| 285 | global $default; | 285 | global $default; |
| 286 | - | 286 | + |
| 287 | $default->log->info("SiteMap::getPage: checking ($action, " . $_SESSION["userID"] . ")"); | 287 | $default->log->info("SiteMap::getPage: checking ($action, " . $_SESSION["userID"] . ")"); |
| 288 | $groupIDs = array(); | 288 | $groupIDs = array(); |
| 289 | - | 289 | + |
| 290 | // for each section | 290 | // for each section |
| 291 | foreach ($this->aSiteMap as $section => $valArr) { | 291 | foreach ($this->aSiteMap as $section => $valArr) { |
| 292 | $default->log->debug("Sitemap::getPage section=$section"); | 292 | $default->log->debug("Sitemap::getPage section=$section"); |
| @@ -308,7 +308,7 @@ class SiteMap { | @@ -308,7 +308,7 @@ class SiteMap { | ||
| 308 | $default->log->info("Sitemap::getPage: access denied for ($action, " . $_SESSION["userID"] . ")"); | 308 | $default->log->info("Sitemap::getPage: access denied for ($action, " . $_SESSION["userID"] . ")"); |
| 309 | return false; | 309 | return false; |
| 310 | } | 310 | } |
| 311 | - | 311 | + |
| 312 | /** | 312 | /** |
| 313 | * Returns the section name of the supplied page | 313 | * Returns the section name of the supplied page |
| 314 | * Checks whether to use the db or not and calls the appropriate method | 314 | * Checks whether to use the db or not and calls the appropriate method |
| @@ -329,12 +329,12 @@ class SiteMap { | @@ -329,12 +329,12 @@ class SiteMap { | ||
| 329 | * @param string the page to lookup the section for | 329 | * @param string the page to lookup the section for |
| 330 | */ | 330 | */ |
| 331 | function getSectionNameUsingDB($sRequiredPage) { | 331 | function getSectionNameUsingDB($sRequiredPage) { |
| 332 | - global $default, $lang_err_database; | 332 | + global $default, $lang_err_database; |
| 333 | $sql = $default->db; | 333 | $sql = $default->db; |
| 334 | // lookup the page and access_id from the sitemap | 334 | // lookup the page and access_id from the sitemap |
| 335 | - if ($sql->query("SELECT SSL.name FROM $default->owl_sitemap_table AS S | ||
| 336 | - INNER JOIN $default->owl_site_sections_table AS SSL ON S.section_id=SSL.id | ||
| 337 | - WHERE S.page='$sRequiredPage'")) { | 335 | + if ($sql->query("SELECT SSL.name FROM $default->owl_sitemap_table AS S |
| 336 | + INNER JOIN $default->owl_site_sections_table AS SSL ON S.section_id=SSL.id | ||
| 337 | + WHERE S.page='$sRequiredPage'")) { | ||
| 338 | if ($sql->next_record()) { | 338 | if ($sql->next_record()) { |
| 339 | // return the section name | 339 | // return the section name |
| 340 | return $sql->f("name"); | 340 | return $sql->f("name"); |
| @@ -347,13 +347,13 @@ class SiteMap { | @@ -347,13 +347,13 @@ class SiteMap { | ||
| 347 | return false; | 347 | return false; |
| 348 | } | 348 | } |
| 349 | } | 349 | } |
| 350 | - | 350 | + |
| 351 | /** | 351 | /** |
| 352 | * Returns the section name of the supplied page (uses the array) | 352 | * Returns the section name of the supplied page (uses the array) |
| 353 | * | 353 | * |
| 354 | * @param string the page to lookup the section for | 354 | * @param string the page to lookup the section for |
| 355 | */ | 355 | */ |
| 356 | - function getSectionNameUsingArray($sRequiredPage) { | 356 | + function getSectionNameUsingArray($sRequiredPage) { |
| 357 | global $default; | 357 | global $default; |
| 358 | // for each section | 358 | // for each section |
| 359 | foreach ($this->aSiteMap as $section => $valArr) { | 359 | foreach ($this->aSiteMap as $section => $valArr) { |
| @@ -366,9 +366,9 @@ class SiteMap { | @@ -366,9 +366,9 @@ class SiteMap { | ||
| 366 | } | 366 | } |
| 367 | } | 367 | } |
| 368 | } | 368 | } |
| 369 | - } | 369 | + } |
| 370 | } | 370 | } |
| 371 | - | 371 | + |
| 372 | /** | 372 | /** |
| 373 | * Returns the default action for the supplied section | 373 | * Returns the default action for the supplied section |
| 374 | * Checks whether to use the db or not and calls the appropriate method | 374 | * Checks whether to use the db or not and calls the appropriate method |
| @@ -383,7 +383,7 @@ class SiteMap { | @@ -383,7 +383,7 @@ class SiteMap { | ||
| 383 | return $this->getDefaultActionUsingArray($sSectionName); | 383 | return $this->getDefaultActionUsingArray($sSectionName); |
| 384 | } | 384 | } |
| 385 | } | 385 | } |
| 386 | - | 386 | + |
| 387 | /** | 387 | /** |
| 388 | * Returns the default action for the supplied section (uses the db) | 388 | * Returns the default action for the supplied section (uses the db) |
| 389 | * | 389 | * |
| @@ -397,9 +397,9 @@ class SiteMap { | @@ -397,9 +397,9 @@ class SiteMap { | ||
| 397 | $sectionID = lookupID($default->owl_site_sections_table, "name", $sSectionName); | 397 | $sectionID = lookupID($default->owl_site_sections_table, "name", $sSectionName); |
| 398 | if ($sectionID) { | 398 | if ($sectionID) { |
| 399 | // lookup the default action for the specified section | 399 | // lookup the default action for the specified section |
| 400 | - if ($sql->query("SELECT action FROM $default->owl_sitemap_table | ||
| 401 | - WHERE section_id=$sectionID | ||
| 402 | - AND is_default=1 AND is_enabled=1")) { | 400 | + if ($sql->query("SELECT action FROM $default->owl_sitemap_table |
| 401 | + WHERE section_id=$sectionID | ||
| 402 | + AND is_default=1 AND is_enabled=1")) { | ||
| 403 | if ($sql->next_record()) { | 403 | if ($sql->next_record()) { |
| 404 | // return the section name | 404 | // return the section name |
| 405 | return $sql->f("action"); | 405 | return $sql->f("action"); |
| @@ -416,14 +416,14 @@ class SiteMap { | @@ -416,14 +416,14 @@ class SiteMap { | ||
| 416 | return false; | 416 | return false; |
| 417 | } | 417 | } |
| 418 | } | 418 | } |
| 419 | - | 419 | + |
| 420 | /** | 420 | /** |
| 421 | * Returns the default action for the supplied section (uses the array) | 421 | * Returns the default action for the supplied section (uses the array) |
| 422 | * | 422 | * |
| 423 | * @param string the section name to return the default action for | 423 | * @param string the section name to return the default action for |
| 424 | * @return string the controller action for the default page for this section | 424 | * @return string the controller action for the default page for this section |
| 425 | */ | 425 | */ |
| 426 | - function getDefaultActionUsingArray($sSectionName) { | 426 | + function getDefaultActionUsingArray($sSectionName) { |
| 427 | global $default; | 427 | global $default; |
| 428 | // check if the section exists | 428 | // check if the section exists |
| 429 | if (is_array($this->aSiteMap[$sSectionName])) { | 429 | if (is_array($this->aSiteMap[$sSectionName])) { |
| @@ -446,7 +446,7 @@ class SiteMap { | @@ -446,7 +446,7 @@ class SiteMap { | ||
| 446 | // TODO: internal error code? | 446 | // TODO: internal error code? |
| 447 | $_SESSION["errorMessage"] = "$sSectionName not in SiteMap!"; | 447 | $_SESSION["errorMessage"] = "$sSectionName not in SiteMap!"; |
| 448 | return false; | 448 | return false; |
| 449 | - } | 449 | + } |
| 450 | } | 450 | } |
| 451 | 451 | ||
| 452 | /** | 452 | /** |
| @@ -463,7 +463,7 @@ class SiteMap { | @@ -463,7 +463,7 @@ class SiteMap { | ||
| 463 | return $this->getActionFromPageUsingArray($sPage); | 463 | return $this->getActionFromPageUsingArray($sPage); |
| 464 | } | 464 | } |
| 465 | } | 465 | } |
| 466 | - | 466 | + |
| 467 | /** | 467 | /** |
| 468 | * Returns the action for a specific page- to enable redirects (uses the db) | 468 | * Returns the action for a specific page- to enable redirects (uses the db) |
| 469 | * | 469 | * |
| @@ -473,9 +473,9 @@ class SiteMap { | @@ -473,9 +473,9 @@ class SiteMap { | ||
| 473 | function getActionFromPageUsingDB($sPage) { | 473 | function getActionFromPageUsingDB($sPage) { |
| 474 | global $default, $lang_err_database; | 474 | global $default, $lang_err_database; |
| 475 | $sql = $default->db; | 475 | $sql = $default->db; |
| 476 | - | 476 | + |
| 477 | // lookup the action for the specified page | 477 | // lookup the action for the specified page |
| 478 | - if ($sql->query("SELECT action FROM $default->owl_sitemap_table WHERE page='$sPage'")) { | 478 | + if ($sql->query("SELECT action FROM $default->owl_sitemap_table WHERE page='$sPage'")) { |
| 479 | if ($sql->next_record()) { | 479 | if ($sql->next_record()) { |
| 480 | // return the section name | 480 | // return the section name |
| 481 | return $sql->f("action"); | 481 | return $sql->f("action"); |
| @@ -488,14 +488,14 @@ class SiteMap { | @@ -488,14 +488,14 @@ class SiteMap { | ||
| 488 | return false; | 488 | return false; |
| 489 | } | 489 | } |
| 490 | } | 490 | } |
| 491 | - | 491 | + |
| 492 | /** | 492 | /** |
| 493 | * Returns the action for a specific page- to enable redirects (uses the array) | 493 | * Returns the action for a specific page- to enable redirects (uses the array) |
| 494 | * | 494 | * |
| 495 | * @param string the page to perform the reverse lookup for | 495 | * @param string the page to perform the reverse lookup for |
| 496 | * @return string the action for this page | 496 | * @return string the action for this page |
| 497 | */ | 497 | */ |
| 498 | - function getActionFromPageUsingArray($sPage) { | 498 | + function getActionFromPageUsingArray($sPage) { |
| 499 | global $default; | 499 | global $default; |
| 500 | $default->log->debug("Sitemap::getActionFromPage: page=$sPage"); | 500 | $default->log->debug("Sitemap::getActionFromPage: page=$sPage"); |
| 501 | // for each section | 501 | // for each section |
| @@ -515,7 +515,7 @@ class SiteMap { | @@ -515,7 +515,7 @@ class SiteMap { | ||
| 515 | } | 515 | } |
| 516 | } | 516 | } |
| 517 | } | 517 | } |
| 518 | - | 518 | + |
| 519 | /** | 519 | /** |
| 520 | * Prints the current site map | 520 | * Prints the current site map |
| 521 | */ | 521 | */ |
| @@ -524,14 +524,14 @@ class SiteMap { | @@ -524,14 +524,14 @@ class SiteMap { | ||
| 524 | return arrayToString($this->aSiteMap); | 524 | return arrayToString($this->aSiteMap); |
| 525 | } | 525 | } |
| 526 | } | 526 | } |
| 527 | - | 527 | + |
| 528 | /** | 528 | /** |
| 529 | * Writes the current sitemap from the array to the DB | 529 | * Writes the current sitemap from the array to the DB |
| 530 | */ | 530 | */ |
| 531 | function syncWithDB() { | 531 | function syncWithDB() { |
| 532 | global $default; | 532 | global $default; |
| 533 | $sql = $default->db; | 533 | $sql = $default->db; |
| 534 | - | 534 | + |
| 535 | // only if we're using the array | 535 | // only if we're using the array |
| 536 | if (!$this->bUseDB) { | 536 | if (!$this->bUseDB) { |
| 537 | // clear section table | 537 | // clear section table |
| @@ -545,20 +545,20 @@ class SiteMap { | @@ -545,20 +545,20 @@ class SiteMap { | ||
| 545 | $default->log->debug("Sitemap::syncWithDB removed sitemap"); | 545 | $default->log->debug("Sitemap::syncWithDB removed sitemap"); |
| 546 | } else { | 546 | } else { |
| 547 | $default->log->error("Sitemap::syncWithDB remove sitemap failed"); | 547 | $default->log->error("Sitemap::syncWithDB remove sitemap failed"); |
| 548 | - } | 548 | + } |
| 549 | // for each section | 549 | // for each section |
| 550 | foreach ($this->aSiteMap as $section => $valArr) { | 550 | foreach ($this->aSiteMap as $section => $valArr) { |
| 551 | // insert into the section | 551 | // insert into the section |
| 552 | $sSectionSql = "INSERT INTO $default->owl_site_sections_table (name) VALUES ('$section')"; | 552 | $sSectionSql = "INSERT INTO $default->owl_site_sections_table (name) VALUES ('$section')"; |
| 553 | $default->log->debug("Sitemap::syncWithDB insert=$sSectionSql"); | 553 | $default->log->debug("Sitemap::syncWithDB insert=$sSectionSql"); |
| 554 | - | 554 | + |
| 555 | if ($sql->query($sSectionSql)) { | 555 | if ($sql->query($sSectionSql)) { |
| 556 | $sectionID = $sql->insert_id(); | 556 | $sectionID = $sql->insert_id(); |
| 557 | $default->log->debug("Sitemap::syncWithDB added section $section; $sectionID"); | 557 | $default->log->debug("Sitemap::syncWithDB added section $section; $sectionID"); |
| 558 | } else { | 558 | } else { |
| 559 | $default->log->error("Sitemap::syncWithDB add section $section failed"); | 559 | $default->log->error("Sitemap::syncWithDB add section $section failed"); |
| 560 | } | 560 | } |
| 561 | - | 561 | + |
| 562 | // for each group, page array combination | 562 | // for each group, page array combination |
| 563 | foreach ($valArr as $requiredAccess => $pageArr) { | 563 | foreach ($valArr as $requiredAccess => $pageArr) { |
| 564 | // now loop through all the pages | 564 | // now loop through all the pages |