1 <?php
2
3 4 5 6 7 8 9
10 class rex_api_sitemap_tree extends rex_api_function
11 {
12 public function execute()
13 {
14
15 $category_id = rex_request('toggle_category_id', 'int', -1);
16 $category_id = rex_category::get($category_id) ? $category_id : -1;
17
18 19 20
21 $user = rex::getUser();
22
23 if (!$user->getComplexPerm('structure')->hasCategoryPerm($category_id)) {
24 throw new rex_api_exception('user has no permission for this category!');
25 }
26
27 $context = rex_context::fromGet();
28 $categoryTree = new rex_sitemap_category_tree($context);
29 $tree = $categoryTree->getTree($category_id);
30
31 $result = new rex_api_result(true);
32 return $result;
33 }
34
35 protected function requiresCsrfProtection()
36 {
37 return true;
38 }
39 }
40