]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Web/Portlets/Console.php
baculum: Fix redundant loading users portlet
[bacula/bacula] / gui / baculum / protected / Web / Portlets / Console.php
1 <?php
2 /*
3  * Bacula(R) - The Network Backup Solution
4  * Baculum   - Bacula web interface
5  *
6  * Copyright (C) 2013-2016 Kern Sibbald
7  *
8  * The main author of Baculum is Marcin Haba.
9  * The original author of Bacula is Kern Sibbald, with contributions
10  * from many 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  * This notice must be preserved when any source code is
18  * conveyed and/or propagated.
19  *
20  * Bacula(R) is a registered trademark of Kern Sibbald.
21  */
22  
23 Prado::using('System.Web.UI.ActiveControls.TActivePanel');
24 Prado::using('System.Web.UI.ActiveControls.TActiveButton');
25 Prado::using('System.Web.UI.ActiveControls.TActiveTextBox');
26 Prado::using('Application.Web.Portlets.Portlets');
27
28 class Console extends Portlets {
29
30         const MAX_CONSOLE_OUTPUT_BATCH = -1000;
31
32         public function sendCommand($sender, $param) {
33                 $cmd = trim($this->CommandLine->Text);
34
35                 if(!empty($cmd)) {
36                         $command = explode(' ', $cmd);
37
38                         $out = $this->Application->getModule('api')->set(array('console'), $command)->output;
39                         if(is_array($out)) {
40                                 $out = array_slice($out, self::MAX_CONSOLE_OUTPUT_BATCH);
41                                 $output = $this->OutputListing->Text . PHP_EOL . implode(PHP_EOL, $out);
42                         } else {
43                                 $output = $this->OutputListing->Text . PHP_EOL . $out;
44                         }
45
46                         $this->OutputListing->Text = $output;
47                         $this->CommandLine->Text = '';
48                 }
49         }
50
51         public function clearConsole($sender, $param) {
52                 $this->OutputListing->Text = '';
53                 $this->CommandLine->Text = '';
54         }
55 }
56
57 ?>