]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Pages/API/Clients.php
baculum: Update copyright dates
[bacula/bacula] / gui / baculum / protected / Pages / API / Clients.php
1 <?php
2 /**
3  * Bacula® - The Network Backup Solution
4  * Baculum - Bacula web interface
5  *
6  * Copyright (C) 2013-2015 Marcin Haba
7  *
8  * The main author of Baculum is Marcin Haba.
9  * The main author of Bacula is Kern Sibbald, with contributions from many
10  * others, a complete list can be found in the file AUTHORS.
11  *
12  * You may use this file and others of this release according to the
13  * license defined in the LICENSE file, which includes the Affero General
14  * Public License, v3.0 ("AGPLv3") and some additional permissions and
15  * terms pursuant to its AGPLv3 Section 7.
16  *
17  * Bacula® is a registered trademark of Kern Sibbald.
18  */
19  
20 /**
21  * Clients resources.
22  * 
23  * Data format:
24  * {
25  *     "output": [
26  *         {
27  *             "clientid": client ID,
28  *             "name": "client name",
29  *             "uname": "client name and environment (uname -a)",
30  *             "autoprune": 0 for disabled, 1 for enabled,
31  *             "fileretention": file retention period in seconds,
32  *             "jobretention": job retention period in seconds,
33  *         },
34  *         {
35  *             "clientid": client ID,
36  *             "name": "client name",
37  *             "uname": "client name and environment (uname -a)",
38  *             "autoprune": 0 for disabled, 1 for enabled,
39  *             "fileretention": file retention period in seconds,
40  *             "jobretention": job retention period in seconds,
41  *         }
42  *              etc...
43  *     ],
44  *     "error": 0 for no errors, 1 for error
45  * }
46  */
47
48 class Clients extends BaculumAPI {
49
50         public function get() {
51                 $limit = intval($this->Request['limit']);
52                 $clients = $this->getModule('client')->getClients($limit);
53                 $allowedClients = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.client'), $this->user)->output;
54                 $clientsOutput = array();
55                 foreach($clients as $client) {
56                         if(in_array($client->name, $allowedClients)) {
57                                 $clientsOutput[] = $client;
58                         }
59                 }
60                 $this->output = $clientsOutput;
61                 $this->error = ClientError::ERROR_NO_ERRORS;
62         }
63 }
64
65 ?>