summaryrefslogtreecommitdiffstats
path: root/lib/kolab_api_controller.php
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-06-18 13:44:22 +0200
committerAleksander Machniak <machniak@kolabsys.com>2014-06-18 13:44:22 +0200
commita76268b3b1bd5b9522301a0b957d27f52ded3dc2 (patch)
treec3ee9c7e1d7b74cd80c8bafd27c66fd2450c1f40 /lib/kolab_api_controller.php
parented6445cd328b8a7772af04c09154f129bbb27aa9 (diff)
downloadwebadmin-a76268b3b1bd5b9522301a0b957d27f52ded3dc2.tar.gz
Add possibility to limit system.capabilities response to one domain
Diffstat (limited to 'lib/kolab_api_controller.php')
-rw-r--r--lib/kolab_api_controller.php59
1 files changed, 34 insertions, 25 deletions
diff --git a/lib/kolab_api_controller.php b/lib/kolab_api_controller.php
index 3fb625e..a735a68 100644
--- a/lib/kolab_api_controller.php
+++ b/lib/kolab_api_controller.php
@@ -34,7 +34,6 @@ class kolab_api_controller
private $uid;
private $request = array();
private $services = array();
- private $domains = array('localhost.localdomain');
private static $translation = array();
public function __construct()
@@ -344,35 +343,46 @@ class kolab_api_controller
/**
* Provide a list of capabilities the backend provides to the current user
+ *
+ * @param array GET request parameters
+ * @param array POST data
+ *
+ * @param array Capabilities indexed by domain name
*/
- private function capabilities()
+ private function capabilities($request, $postdata)
{
- Log::debug("system.capabilities called");
+ $result = array();
+ $domains = array();
- $auth = Auth::get_instance();
-
- // Get the domain name attribute
- $dna = $this->config->get('ldap', 'domain_name_attribute');
- if (empty($dna)) {
- $dna = 'associateddomain';
+ // specified domain
+ if (!empty($request['domain'])) {
+ $domains[] = $request['domain'];
}
+ // get all domains
+ else {
+ $auth = Auth::get_instance();
+
+ // Get the domain name attribute
+ $dna = $this->config->get('ldap', 'domain_name_attribute');
+ if (empty($dna)) {
+ $dna = 'associateddomain';
+ }
- $_domains = $auth->list_domains();
- $this->domains = $_domains['list'];
+ $_domains = $auth->list_domains();
+ $domains = $_domains['list'];
- $result = array();
+ foreach ($domains as $idx => $attrs) {
+ $domains[$idx] = is_array($attrs) ? (is_array($attrs[$dna]) ? $attrs[$dna][0] : $attrs[$dna]) : $attrs;
+ }
- // Should we have no permissions to list domain name spaces,
- // we should always return our own.
- if (count($this->domains) < 1) {
- //console("As there is but one domain, we insert our own");
- $this->domains[] = Array($dna => $_SESSION['user']->get_domain());
+ // Should we have no permissions to list domain name spaces,
+ // we should always return our own.
+ if (count($domains) < 1) {
+ $domains[] = $_SESSION['user']->get_domain();
+ }
}
- // add capabilities of all registered services
- foreach ($this->domains as $domain_dn => $domain_attrs) {
- $domain_name = is_array($domain_attrs) ? (is_array($domain_attrs[$dna]) ? $domain_attrs[$dna][0] : $domain_attrs[$dna]) : $domain_attrs;
-
+ foreach ($domains as $domain_name) {
// define our very own capabilities
$actions = array(
'system.quit' => array('type' => 'w'),
@@ -390,10 +400,9 @@ class kolab_api_controller
}
return array(
- 'list' => $result,
- 'count' => count($result),
- );
-
+ 'list' => $result,
+ 'count' => count($result),
+ );
}
private function get_domain() {