File: plugin.files.php

package info (click to toggle)
kopano-webapp-plugin-files 2.1.5%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 16,540 kB
  • sloc: php: 15,863; xml: 494; java: 295; python: 72; sh: 44; makefile: 11
file content (115 lines) | stat: -rw-r--r-- 2,813 bytes parent folder | download
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php

require_once __DIR__ . "/Files/Core/class.downloadhandler.php";
require_once __DIR__ . "/Files/Core/class.uploadhandler.php";
require_once __DIR__ . "/Files/Core/class.recipienthandler.php";
require_once __DIR__ . "/Files/Backend/class.backendstore.php";

use \Files\Core\DownloadHandler;
use \Files\Core\UploadHandler;
use \Files\Core\RecipientHandler;

/**
 * Files Plugin
 *
 * Integrates Files into the Kopano environment.
 */
class Pluginfiles extends Plugin
{

	/**
	 * Function initializes the Plugin and registers all hooks
	 *
	 * @return void
	 */
	function init()
	{
		$this->registerHook('server.core.settings.init.before');
		$this->registerHook('server.index.load.custom');
	}

	/**
	 * Function is executed when a hook is triggered by the PluginManager
	 *
	 * @param string $eventID the id of the triggered hook
	 * @param mixed $data object(s) related to the hook
	 *
	 * @return void
	 */
	function execute($eventID, &$data)
	{
		switch ($eventID) {
			case 'server.core.settings.init.before' :
				$this->injectPluginSettings($data);
				break;
			case 'server.index.load.custom':
				switch($data['name']) {
				case 'files_get_recipients':
					RecipientHandler::doGetRecipients();
					break;
				case 'download_file':
					DownloadHandler::doDownload();
					break;
				case 'upload_file':
					UploadHandler::doUpload();
					break;
				case 'form':
					if (isset($_GET['backend'])) {
						$backend = urldecode($_GET["backend"]);
					} else {
						$backend = '';
					}
					$backendstore = Files\Backend\BackendStore::getInstance();

					if ($backendstore->backendExists($backend)) {
						$backendInstance = $backendstore->getInstanceOfBackend($backend);
						$formdata = $backendInstance->getFormConfig();
						die($formdata);
					} else {
						die("Specified backend does not exist!");
					}
					break;
			}
			break;
		}
	}

	/**
	 * Called when the core Settings class is initialized and ready to accept sysadmin default
	 * settings. Registers the sysadmin defaults for the FILES plugin.
	 *
	 * @param array $data Reference to the data of the triggered hook
	 *
	 * @return void
	 */
	function injectPluginSettings(&$data)
	{
		$data['settingsObj']->addSysAdminDefaults(Array(
			'zarafa' => Array(
				'v1' => Array(
					'main' => Array(
						'notifier' => Array(
							'info' => Array(
								'files' => Array(
									'value' => "dropdown"        // static notifier
								)
							)
						)
					),
					'contexts' => Array(
						'files' => Array(
							'ask_before_delete' => PLUGIN_FILES_ASK_BEFORE_DELETE,
							'preload_folder' => PLUGIN_FILES_PRELOAD_FOLDER,
							'webapp_tmp' => TMP_PATH
						)
					),
					'plugins' => Array(
						'files' => Array(
							'enable' => PLUGIN_FILES_USER_DEFAULT_ENABLE
						)
					)
				)
			)
		));
	}
}