From 3f95a395c8f989b370a43430b0fc7612f88c8764 Mon Sep 17 00:00:00 2001
From: Dmitriy Simushev <simushevds@ossg.ru>
Date: Wed, 18 Jul 2012 11:32:37 +0000
Subject: [PATCH] Integrate plugin system with mibew

---
 src/messenger/webim/libs/common.php  |  1 +
 src/messenger/webim/libs/config.php  | 14 ++++++++++++++
 src/messenger/webim/libs/plugins.php | 27 +++++++++++++++++++++++++++
 3 files changed, 42 insertions(+)
 create mode 100644 src/messenger/webim/libs/plugins.php

diff --git a/src/messenger/webim/libs/common.php b/src/messenger/webim/libs/common.php
index 9608ef45..2467efe3 100644
--- a/src/messenger/webim/libs/common.php
+++ b/src/messenger/webim/libs/common.php
@@ -19,6 +19,7 @@ session_start();
 
 require_once(dirname(__FILE__) . '/converter.php');
 require_once(dirname(__FILE__) . '/config.php');
+require_once(dirname(__FILE__) . '/plugins.php');
 require_once(dirname(__FILE__) . '/classes/database.php');
 require_once(dirname(__FILE__) . '/classes/settings.php');
 
diff --git a/src/messenger/webim/libs/config.php b/src/messenger/webim/libs/config.php
index ccbb670f..97d8c4b7 100644
--- a/src/messenger/webim/libs/config.php
+++ b/src/messenger/webim/libs/config.php
@@ -51,4 +51,18 @@ $mail_encoding = "utf-8";
 $home_locale = "en"; /* native name will be used in this locale */
 $default_locale = "en"; /* if user does not provide known lang */
 
+/*
+ * Plugins
+ */
+$plugins_list = array();
+/* Exapmle of plugins configuration
+$plugins_list[] = array(
+	'name' => 'plugin_name',
+	'config' => array(
+		'weight' => 100,
+		'some_configurable_value' => 'value'
+	)
+)
+*/
+
 ?>
\ No newline at end of file
diff --git a/src/messenger/webim/libs/plugins.php b/src/messenger/webim/libs/plugins.php
new file mode 100644
index 00000000..f3f8dd6b
--- /dev/null
+++ b/src/messenger/webim/libs/plugins.php
@@ -0,0 +1,27 @@
+<?php
+/*
+ * Copyright 2005-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require_once(dirname(__FILE__) . '/classes/event_dispatcher.php');
+require_once(dirname(__FILE__) . '/classes/plugin_manager.php');
+require_once(dirname(__FILE__) . '/classes/plugin.php');
+
+if (! empty($plugins_list)) {
+	// Variable $plugins_config defined in libs/config.php
+	PluginManager::loadPlugins($plugins_list);
+}
+
+?>
\ No newline at end of file