Welcome to mirror list, hosted at ThFree Co, Russian Federation.

getSettings.php « ajax « build - github.com/nextcloud/jsxc.nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e638a20b64c0d4ea9f3fca22e407820eb5a589c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php

header('Content-Type: application/json; charset=utf-8');

function validateBoolean($val)
{
    return $val === true || $val === 'true';
}

OCP\JSON::callCheck();

$username = $_POST ['username'];
$password = $_POST ['password'];

$ocUser = new OCP\User();

$auth = ($password !== null) ? $ocUser->checkPassword($username, $password) : OCP\User::isLoggedIn();

if (!$auth) {
    echo json_encode(array(
            'result' => 'noauth',
    ));
    exit();
}

$config = \OC::$server->getConfig();

$data = array();
$data ['xmpp'] = array();
$data ['serverType'] = $config->getAppValue('ojsxc', 'serverType', 'external');
$data ['loginForm'] ['startMinimized'] = validateBoolean($config->getAppValue('ojsxc', 'xmppStartMinimized'));

if ($data ['serverType'] === 'internal') {
    echo json_encode(array(
            'result' => 'success',
            'data' => $data,
    ));

    exit;
}

$data ['xmpp'] ['url'] = trim($config->getAppValue('ojsxc', 'boshUrl'));
$data ['xmpp'] ['domain'] = trim($config->getAppValue('ojsxc', 'xmppDomain'));
$data ['xmpp'] ['resource'] = trim($config->getAppValue('ojsxc', 'xmppResource'));
$data ['xmpp'] ['overwrite'] = validateBoolean($config->getAppValue('ojsxc', 'xmppOverwrite'));
$data ['xmpp'] ['onlogin'] = true;

$options = $config->getUserValue($username, 'ojsxc', 'options');

if ($options !== null) {
    $options = (array) json_decode($options, true);

    if (is_array($options)) {
      foreach ($options as $prop => $value) {
          if ($prop !== 'xmpp' || $data ['xmpp'] ['overwrite']) {
              foreach ($value as $key => $v) {
                  if ($v !== '') {
                      $data [$prop] [$key] = ($v === 'false' || $v === 'true') ? validateBoolean($v) : $v;
                  }
              }
          }
      }
    }
}

echo json_encode(array(
        'result' => 'success',
        'data' => $data,
));