From 9be2f43d02cd54340fc64c9b2cee9cfa94b49034 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Sun, 25 Nov 2012 11:35:53 -0500
Subject: [PATCH] Define more (uniquely prefixed) constants for Roundcube directories in order to enhance the interoperability of the Roundcube framework
---
program/lib/Roundcube/rcube.php | 22 +++++-----
program/lib/Roundcube/bootstrap.php | 20 ++++++++--
program/lib/Roundcube/rcube_output_html.php | 8 ++--
program/lib/Roundcube/rcube_config.php | 10 ++--
program/lib/Roundcube/rcube_csv2vcard.php | 4 +-
program/lib/Roundcube/rcube_plugin_api.php | 6 +-
program/lib/Roundcube/rcube_mime.php | 2
program/include/iniset.php | 8 ++++
program/lib/Roundcube/rcube_db_sqlite.php | 2
9 files changed, 51 insertions(+), 31 deletions(-)
diff --git a/program/include/iniset.php b/program/include/iniset.php
index 3e718c9..d79fbd4 100644
--- a/program/include/iniset.php
+++ b/program/include/iniset.php
@@ -43,6 +43,14 @@
define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');
}
+if (!defined('RCUBE_LOCALIZATION_DIR')) {
+ define('RCUBE_LOCALIZATION_DIR', INSTALL_PATH . 'program/localization/');
+}
+
+define('RCUBE_INSTALL_PATH', INSTALL_PATH);
+define('RCUBE_CONFIG_DIR', RCMAIL_CONFIG_DIR);
+
+
// RC include folders MUST be included FIRST to avoid other
// possible not compatible libraries (i.e PEAR) to be included
// instead the ones provided by RC
diff --git a/program/lib/Roundcube/bootstrap.php b/program/lib/Roundcube/bootstrap.php
index bc0456c..018701d 100644
--- a/program/lib/Roundcube/bootstrap.php
+++ b/program/lib/Roundcube/bootstrap.php
@@ -52,12 +52,24 @@
define('RCMAIL_CHARSET', 'UTF-8');
define('RCMAIL_START', microtime(true));
-if (!defined('INSTALL_PATH')) {
- define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/');
+if (!defined('RCUBE_LIB_DIR')) {
+ define('RCUBE_LIB_DIR', dirname(__FILE__).'/');
}
-if (!defined('RCMAIL_CONFIG_DIR')) {
- define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');
+if (!defined('RCUBE_INSTALL_PATH')) {
+ define('RCUBE_INSTALL_PATH', RCUBE_LIB_DIR);
+}
+
+if (!defined('RCUBE_CONFIG_DIR')) {
+ define('RCUBE_CONFIG_DIR', RCUBE_INSTALL_PATH . 'config');
+}
+
+if (!defined('RCUBE_PLUGINS_DIR')) {
+ define('RCUBE_PLUGINS_DIR', RCUBE_INSTALL_PATH . 'plugins/');
+}
+
+if (!defined('RCUBE_LOCALIZATION_DIR')) {
+ define('RCUBE_LOCALIZATION_DIR', RCUBE_INSTALL_PATH . 'localization/');
}
// set internal encoding for mbstring extension
diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php
index 9c1a6d8..0eed6cf 100644
--- a/program/lib/Roundcube/rcube.php
+++ b/program/lib/Roundcube/rcube.php
@@ -596,8 +596,8 @@
ob_start();
// get english labels (these should be complete)
- @include(INSTALL_PATH . 'program/localization/en_US/labels.inc');
- @include(INSTALL_PATH . 'program/localization/en_US/messages.inc');
+ @include(RCUBE_LOCALIZATION_DIR . 'en_US/labels.inc');
+ @include(RCUBE_LOCALIZATION_DIR . 'en_US/messages.inc');
if (is_array($labels))
$this->texts = $labels;
@@ -605,9 +605,9 @@
$this->texts = array_merge($this->texts, $messages);
// include user language files
- if ($lang != 'en' && $lang != 'en_US' && is_dir(INSTALL_PATH . 'program/localization/' . $lang)) {
- include_once(INSTALL_PATH . 'program/localization/' . $lang . '/labels.inc');
- include_once(INSTALL_PATH . 'program/localization/' . $lang . '/messages.inc');
+ if ($lang != 'en' && $lang != 'en_US' && is_dir(RCUBE_LOCALIZATION_DIR . $lang)) {
+ include_once(RCUBE_LOCALIZATION_DIR . $lang . '/labels.inc');
+ include_once(RCUBE_LOCALIZATION_DIR . $lang . '/messages.inc');
if (is_array($labels))
$this->texts = array_merge($this->texts, $labels);
@@ -645,7 +645,7 @@
}
if (empty($rcube_languages)) {
- @include(INSTALL_PATH . 'program/localization/index.inc');
+ @include(RCUBE_LOCALIZATION_DIR . 'index.inc');
}
// check if we have an alias for that language
@@ -666,7 +666,7 @@
}
}
- if (!isset($rcube_languages[$lang]) || !is_dir(INSTALL_PATH . 'program/localization/' . $lang)) {
+ if (!isset($rcube_languages[$lang]) || !is_dir(RCUBE_LOCALIZATION_DIR . $lang)) {
$lang = 'en_US';
}
@@ -684,11 +684,11 @@
static $sa_languages = array();
if (!sizeof($sa_languages)) {
- @include(INSTALL_PATH . 'program/localization/index.inc');
+ @include(RCUBE_LOCALIZATION_DIR . 'index.inc');
- if ($dh = @opendir(INSTALL_PATH . 'program/localization')) {
+ if ($dh = @opendir(RCUBE_LOCALIZATION_DIR)) {
while (($name = readdir($dh)) !== false) {
- if ($name[0] == '.' || !is_dir(INSTALL_PATH . 'program/localization/' . $name)) {
+ if ($name[0] == '.' || !is_dir(RCUBE_LOCALIZATION_DIR . $name)) {
continue;
}
@@ -1017,7 +1017,7 @@
$log_dir = self::$instance ? self::$instance->config->get('log_dir') : null;
if (empty($log_dir)) {
- $log_dir = INSTALL_PATH . 'logs';
+ $log_dir = RCUBE_INSTALL_PATH . 'logs';
}
// try to open specific log file for writing
diff --git a/program/lib/Roundcube/rcube_config.php b/program/lib/Roundcube/rcube_config.php
index 7d206ff..6d208ba 100644
--- a/program/lib/Roundcube/rcube_config.php
+++ b/program/lib/Roundcube/rcube_config.php
@@ -71,11 +71,11 @@
private function load()
{
// load main config file
- if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/main.inc.php'))
+ if (!$this->load_from_file(RCUBE_CONFIG_DIR . '/main.inc.php'))
$this->errors[] = 'main.inc.php was not found.';
// load database config
- if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/db.inc.php'))
+ if (!$this->load_from_file(RCUBE_CONFIG_DIR . '/db.inc.php'))
$this->errors[] = 'db.inc.php was not found.';
// load host-specific configuration
@@ -96,8 +96,8 @@
$this->prop['skin'] = self::DEFAULT_SKIN;
// fix paths
- $this->prop['log_dir'] = $this->prop['log_dir'] ? realpath(unslashify($this->prop['log_dir'])) : INSTALL_PATH . 'logs';
- $this->prop['temp_dir'] = $this->prop['temp_dir'] ? realpath(unslashify($this->prop['temp_dir'])) : INSTALL_PATH . 'temp';
+ $this->prop['log_dir'] = $this->prop['log_dir'] ? realpath(unslashify($this->prop['log_dir'])) : RCUBE_INSTALL_PATH . 'logs';
+ $this->prop['temp_dir'] = $this->prop['temp_dir'] ? realpath(unslashify($this->prop['temp_dir'])) : RCUBE_INSTALL_PATH . 'temp';
// fix default imap folders encoding
foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder)
@@ -156,7 +156,7 @@
}
if ($fname) {
- $this->load_from_file(RCMAIL_CONFIG_DIR . '/' . $fname);
+ $this->load_from_file(RCUBE_CONFIG_DIR . '/' . $fname);
}
}
diff --git a/program/lib/Roundcube/rcube_csv2vcard.php b/program/lib/Roundcube/rcube_csv2vcard.php
index 114d36d..ec7a3ab 100644
--- a/program/lib/Roundcube/rcube_csv2vcard.php
+++ b/program/lib/Roundcube/rcube_csv2vcard.php
@@ -244,8 +244,8 @@
{
// Localize fields map
if ($lang && $lang != 'en_US') {
- if (file_exists(INSTALL_PATH . "program/localization/$lang/csv2vcard.inc")) {
- include INSTALL_PATH . "program/localization/$lang/csv2vcard.inc";
+ if (file_exists(RCUBE_LOCALIZATION_DIR . "$lang/csv2vcard.inc")) {
+ include RCUBE_LOCALIZATION_DIR . "$lang/csv2vcard.inc";
}
if (!empty($map)) {
diff --git a/program/lib/Roundcube/rcube_db_sqlite.php b/program/lib/Roundcube/rcube_db_sqlite.php
index 9aa67d0..65dcb6d 100644
--- a/program/lib/Roundcube/rcube_db_sqlite.php
+++ b/program/lib/Roundcube/rcube_db_sqlite.php
@@ -66,7 +66,7 @@
// Initialize database structure in file is empty
if (!empty($dsn['database']) && !filesize($dsn['database'])) {
- $data = file_get_contents(INSTALL_PATH . 'SQL/sqlite.initial.sql');
+ $data = file_get_contents(RCUBE_INSTALL_PATH . 'SQL/sqlite.initial.sql');
if (strlen($data)) {
$this->debug('INITIALIZE DATABASE');
diff --git a/program/lib/Roundcube/rcube_mime.php b/program/lib/Roundcube/rcube_mime.php
index 7ce7c90..25ee31d 100644
--- a/program/lib/Roundcube/rcube_mime.php
+++ b/program/lib/Roundcube/rcube_mime.php
@@ -653,7 +653,7 @@
{
$mime_type = null;
$mime_magic = rcube::get_instance()->config->get('mime_magic');
- $mime_ext = @include RCMAIL_CONFIG_DIR . '/mimetypes.php';
+ $mime_ext = @include RCUBE_CONFIG_DIR . '/mimetypes.php';
// use file name suffix with hard-coded mime-type map
if (is_array($mime_ext) && $name) {
diff --git a/program/lib/Roundcube/rcube_output_html.php b/program/lib/Roundcube/rcube_output_html.php
index d751eb2..f5c6397 100644
--- a/program/lib/Roundcube/rcube_output_html.php
+++ b/program/lib/Roundcube/rcube_output_html.php
@@ -592,7 +592,7 @@
$ERROR_CODE = $code;
$ERROR_MESSAGE = $message;
- include INSTALL_PATH . 'program/steps/utils/error.inc';
+ include RCUBE_INSTALL_PATH . 'program/steps/utils/error.inc';
exit;
}
@@ -921,11 +921,11 @@
}
else if ($object == 'version') {
$ver = (string)RCMAIL_VERSION;
- if (is_file(INSTALL_PATH . '.svn/entries')) {
+ if (is_file(RCUBE_INSTALL_PATH . '.svn/entries')) {
if (preg_match('/Revision:\s(\d+)/', @shell_exec('svn info'), $regs))
$ver .= ' [SVN r'.$regs[1].']';
}
- else if (is_file(INSTALL_PATH . '.git/index')) {
+ else if (is_file(RCUBE_INSTALL_PATH . '.git/index')) {
if (preg_match('/Date:\s+([^\n]+)/', @shell_exec('git log -1'), $regs)) {
if ($date = date('Ymd.Hi', strtotime($regs[1]))) {
$ver .= ' [GIT '.$date.']';
@@ -1760,7 +1760,7 @@
'about.html',
);
foreach ($filenames as $file) {
- $fn = RCMAIL_CONFIG_DIR . '/' . $file;
+ $fn = RCUBE_CONFIG_DIR . '/' . $file;
if (is_readable($fn)) {
$content = file_get_contents($fn);
$content = $this->parse_conditions($content);
diff --git a/program/lib/Roundcube/rcube_plugin_api.php b/program/lib/Roundcube/rcube_plugin_api.php
index 51daf27..a8f83a2 100644
--- a/program/lib/Roundcube/rcube_plugin_api.php
+++ b/program/lib/Roundcube/rcube_plugin_api.php
@@ -20,8 +20,8 @@
*/
// location where plugins are loade from
-if (!defined('RCMAIL_PLUGINS_DIR'))
- define('RCMAIL_PLUGINS_DIR', INSTALL_PATH . 'plugins/');
+if (!defined('RCUBE_PLUGINS_DIR'))
+ define('RCUBE_PLUGINS_DIR', RCUBE_INSTALL_PATH . 'plugins/');
/**
@@ -101,7 +101,7 @@
*/
protected function __construct()
{
- $this->dir = slashify(RCMAIL_PLUGINS_DIR);
+ $this->dir = slashify(RCUBE_PLUGINS_DIR);
}
--
Gitblit v1.9.1