// get template file cache
//
- $this->template_file_cache = Template::cache_template_file_hierarchy();
+ $this->template_file_cache = Template::cache_template_file_hierarchy($template_set_id);
}
}
+ /**
+ * Determine what the RPC template set is.
+ *
+ * NOTE that if the default setting cannot be found in the
+ * main SquirrelMail configuration settings that the value
+ * of $default is returned.
+ *
+ * @param string $default The template set ID to use if
+ * the default setting cannot be
+ * found in SM config (optional;
+ * defaults to "default_rpc").
+ *
+ * @return string The ID of the RPC template set.
+ *
+ * @static
+ *
+ */
+ function get_rpc_template_set($default='default_rpc') {
+
+// FIXME: do we want to place any restrictions on the ID such as
+// making sure no slashes included?
+
+ // values are in main SM config file
+ //
+ global $rpc_templateset;
+ $rpc_templateset = (!isset($rpc_templateset)
+ ? $default : $rpc_templateset);
+
+ // FIXME: note that it is possible for this to
+ // point to an invalid (nonexistent) template set
+ // and that error will not be caught here
+ //
+ return $rpc_templateset;
+
+ }
+
/**
* Allow template set to override plugin configuration by either
* adding or removing plugins.
* constructed and stored in session before being returned
* to the caller.
*
+ * @param string $template_set_id The template set for which
+ * the cache should be built.
+ * This function will save more
+ * than one set's files, so it
+ * may be called multiple times
+ * with different values for this
+ * argument. When regenerating,
+ * all set caches are dumped.
* @param boolean $regenerate_cache When TRUE, the file hierarchy
* is reloaded and stored fresh
* (optional; default FALSE).
* empty - no additional files).
*
* @return array Template file hierarchy array, whose keys
- * are all the template file names (with path
- * information relative to the template set's
- * base directory, e.g., "css/style.css")
- * found in all parent template sets including
- * the ultimate fall-back template set.
- * Array values are sub-arrays with the
+ * are all the template file names for the given
+ * template set ID (with path information relative
+ * to the template set's base directory, e.g.,
+ * "css/style.css") found in all parent template
+ * sets including the ultimate fall-back template
+ * set. Array values are sub-arrays with the
* following key-value pairs:
*
* PATH -- file path, relative to SM_PATH
* @static
*
*/
- function cache_template_file_hierarchy($regenerate_cache=FALSE,
+ function cache_template_file_hierarchy($template_set_id,
+ $regenerate_cache=FALSE,
$additional_files=array()) {
sqGetGlobalVar('template_file_hierarchy', $template_file_hierarchy,
if ($regenerate_cache) unset($template_file_hierarchy);
- if (!empty($template_file_hierarchy)) {
+ if (!empty($template_file_hierarchy[$template_set_id])) {
// have to add additional files if given before returning
//
if (!empty($additional_files)) {
- $template_file_hierarchy = array_merge($template_file_hierarchy,
- $additional_files);
+ $template_file_hierarchy[$template_set_id]
+ = array_merge($template_file_hierarchy[$template_set_id],
+ $additional_files);
+
sqsession_register($template_file_hierarchy,
'template_file_hierarchy');
}
- return $template_file_hierarchy;
+ return $template_file_hierarchy[$template_set_id];
}
// nothing in cache apparently, so go build it now
//
- // FIXME: not sure if there is any possibility that
- // this could be called when $sTemplateID has
- // yet to be defined... throw error for now,
- // but if the error occurs, it's a coding error
- // rather than a configuration error
- //
- global $sTemplateID;
- if (empty($sTemplateID)) {
-
- trigger_error('Template set ID unknown', E_USER_ERROR);
+ $template_file_hierarchy[$template_set_id] = Template::catalog_template_files($template_set_id);
- } else {
-
- $template_file_hierarchy = Template::catalog_template_files($sTemplateID);
-
- // additional files, if any
- //
- if (!empty($additional_files)) {
- $template_file_hierarchy = array_merge($template_file_hierarchy,
- $additional_files);
- }
-
- sqsession_register($template_file_hierarchy,
- 'template_file_hierarchy');
+ // additional files, if any
+ //
+ if (!empty($additional_files)) {
+ $template_file_hierarchy[$template_set_id]
+ = array_merge($template_file_hierarchy[$template_set_id],
+ $additional_files);
+ }
- return $template_file_hierarchy;
+ sqsession_register($template_file_hierarchy,
+ 'template_file_hierarchy');
- }
+ return $template_file_hierarchy[$template_set_id];
}
)
);
$this->template_file_cache
- = $this->cache_template_file_hierarchy(FALSE, $file_list);
+ = $this->cache_template_file_hierarchy($this->template_set_id,
+ FALSE,
+ $file_list);
return TRUE;
}
}
close FILE;
+# RPC template sets aren't included in user interface skin list,
+# so add the one from the config file here
+#
+if ($rpc_templateset =~ /_rpc$/) {
+ $templateset_name[$#templateset_name + 1] = $rpc_templateset;
+ $templateset_id[$#templateset_id + 1] = $rpc_templateset;
+}
+
# FIXME: unknown introduction date
$useSendmail = 'false' if ( lc($useSendmail) ne 'true' );
$sendmail_path = "/usr/sbin/sendmail" if ( !$sendmail_path );
print " ";
}
if ( $templateset_id[$count] eq $templateset_fallback ) {
- print "f ";
+ print "f";
+ } else {
+ print " ";
+ }
+ if ( $templateset_id[$count] eq $rpc_templateset ) {
+ print "r ";
} else {
print " ";
}
if ( $count < 10 ) {
print " ";
}
+ if ( $count < 100 ) {
+ print " ";
+ }
$name = $templateset_name[$count];
- $num_spaces = 35 - length($name);
- for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
- $name = $name . " ";
+
+ # present RPC template sets differently
+ #
+ if ( $templateset_id[$count] =~ /_rpc$/ ) {
+ $name = $name . " (not shown in user interface; used for RPC interface only)";
+ } else {
+
+ $num_spaces = 35 - length($name);
+ for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
+ $name = $name . " ";
+ }
+ $name = $name . "($templateset_id[$count])";
+
}
- print " $count. $name";
- print "($templateset_id[$count])\n";
+ print " $count. $name\n";
$count++;
- }
- print "\n d = default template set\n"
- . " f = fallback template set\n\n";
+ }
+ print "\n d = default template set\n"
+ . " f = fallback template set\n"
+ . " r = RPC template set\n\n";
$menu_text = ".-------------------------------------.\n"
. "| t (detect template set) |\n"
. "| - N (remove template set) |\n"
. "| m N (mark default template set) |\n"
. "| f N (set fallback template set) |\n"
+ . "| r N (set RPC template set) |\n"
. "| l (list template sets/skins) |\n"
. "| d (done) |\n"
. "|-------------------------------------|\n"
print " ";
}
if ( $templateset_id[$count] eq $templateset_fallback ) {
- print "f ";
+ print "f";
+ } else {
+ print " ";
+ }
+ if ( $templateset_id[$count] eq $rpc_templateset ) {
+ print "r ";
} else {
print " ";
}
if ( $count < 10 ) {
print " ";
}
+ if ( $count < 100 ) {
+ print " ";
+ }
$name = $templateset_name[$count];
- $num_spaces = 35 - length($name);
- for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
- $name = $name . " ";
+
+ # present RPC template sets differently
+ #
+ if ( $templateset_id[$count] =~ /_rpc$/ ) {
+ $name = $name . " (not shown in user interface; used for RPC interface only)";
+ } else {
+
+ $num_spaces = 35 - length($name);
+ for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
+ $name = $name . " ";
+ }
+ $name = $name . "($templateset_id[$count])";
+
}
- print " $count. $name";
- print "($templateset_id[$count])\n";
+ print " $count. $name\n";
$count++;
}
print "\n d = default template set\n"
- . " f = fallback template set\n\n";
+ . " f = fallback template set\n"
+ . " r = RPC template set\n\n";
# mark default template set
#
print "Cannot set default template set to $input. That template set does not exist.\n";
$templateset_default = $old_def;
}
+ if ( $templateset_default =~ /_rpc$/ ) {
+ print "Cannot set default template set to $input. That template set is intended for the RPC interface only.\n";
+ $templateset_default = $old_def;
+ }
# set fallback template set
#
print "Cannot set fallback template set to $input. That template set does not exist.\n";
$templateset_fallback = $old_def;
}
+ if ( $templateset_fallback =~ /_rpc$/ ) {
+ print "Cannot set fallback template set to $input. That template set is intended for the RPC interface only.\n";
+ $templateset_fallback = $old_def;
+ }
+
+ # set RPC template set
+ #
+ } elsif ( $input =~ /^\s*r\s*[0-9]+/i ) {
+ $old_def = $rpc_templateset;
+ $input =~ s/^\s*r\s*//;
+ $rpc_templateset = $templateset_id[$input];
+ if ( $rpc_templateset =~ /^\s*$/ ) {
+ print "Cannot set RPC template set to $input. That template set does not exist.\n";
+ $rpc_templateset = $old_def;
+ }
+ if ( $rpc_templateset !~ /_rpc$/ ) {
+ print "Cannot set fallback template set to $input. That template set is not intended for the RPC interface.\n";
+ $rpc_templateset = $old_def;
+ }
# add template set
#
if ( $found != 1) {
print "** Found template set: $filename\n";
$def = $files[$cnt];
- $def =~ s/_/ /g;
- $def = lc($def);
- #$def =~ s/(^\w+)/ucfirst $1/eg;
- #$def =~ s/(\s+)(\w+)/$1 . ucfirst $2/eg;
- $def =~ s/(^\w+)|(\s+)(\w+)/ucfirst $1 . $2 . ucfirst $3/eg;
- print " What is it's name (as shown to your users)? [$def]: ";
- $nm = <STDIN>;
- $nm =~ s/^\s+|\s+$|[\n\r]//g;
- if ( $nm eq '' ) { $nm = $def; }
+
+ # no user-friendly names needed for RPC template sets
+ #
+ if ( $def =~ /_rpc$/ ) {
+ $nm = $def;
+ } else {
+ $def = lc($def);
+ $def =~ s/_/ /g;
+ #$def =~ s/(^\w+)/ucfirst $1/eg;
+ #$def =~ s/(\s+)(\w+)/$1 . ucfirst $2/eg;
+ $def =~ s/(^\w+)|(\s+)(\w+)/ucfirst $1 . $2 . ucfirst $3/eg;
+ print " What is it's name (as shown to your users)? [$def]: ";
+ $nm = <STDIN>;
+ $nm =~ s/^\s+|\s+$|[\n\r]//g;
+ if ( $nm eq '' ) { $nm = $def; }
+ }
$templateset_id[ $#templateset_id + 1 ] = $filename;
$templateset_name[ $#templateset_name + 1 ] = $nm;
}
print " Removing \"$filename\" (template set directory not found)\n";
if ( $templateset_default eq $filename ) { $templateset_default = 'default'; }
if ( $templateset_fallback eq $filename ) { $templateset_fallback = 'default'; }
+ if ( $rpc_templateset eq $filename ) { $rpc_templateset = 'default_rpc'; }
$offset = 0;
@new_templateset_name = ();
@new_templateset_id = ();
print "You cannot remove the default template set!\n";
} elsif ( $templateset_id[$rem_num] eq $templateset_fallback ) {
print "You cannot remove the fallback template set!\n";
+ } elsif ( $templateset_id[$rem_num] eq $rpc_templateset ) {
+ print "You cannot remove the RPC template set!\n";
} else {
$count = 0;
@new_templateset_name = ();
if ( $templateset_fallback eq '' ) { $templateset_fallback = 'default'; }
print CF "\$templateset_fallback = '$templateset_fallback';\n";
+ if ( $rpc_templateset eq '' ) { $rpc_templateset = 'default_rpc'; }
+ print CF "\$rpc_templateset = '$rpc_templateset';\n";
+
for ( $count = 0 ; $count <= $#templateset_name ; $count++ ) {
+
+ # don't include RPC template sets
+ #
+ if ( $templateset_id[$count] =~ /_rpc$/ ) { next; }
+
print CF "\$aTemplateSet[$count]['ID'] = '" . $templateset_id[$count] . "';\n";
# escape theme name so it can contain single quotes.
$esc_name = $templateset_name[$count];
* being used. (Must be the "ID" of the desired
* template set)
*
+ * $rpc_templateset sets the skin that will be used by default
+ * when a user is making an RPC request. This
+ * does not usually need to be changed, but
+ * can be used to change the RPC protocol that
+ * is used to respond to RPC requets. (Must be
+ * the "ID" of the desired template set and
+ * should NOT be a template set that is included
+ * in the $aTemplateSet list; PLEASE NOTE that
+ * new RPC template sets should always be named
+ * "<skin name>_rpc", as SquirrelMail will assume
+ * any template sets ending in "_rpc" are intended
+ * for its RPC interface only)
+ *
* @global string $templateset_default
* @global string $templateset_fallback
+ * @global string $rpc_templateset
*/
$templateset_default = 'default';
$templateset_fallback = 'default';
+$rpc_templateset = 'default_rpc';
$aTemplateSet[0]['ID'] = 'default';
$aTemplateSet[0]['NAME'] = 'Default';
// reset template file cache
//
$sTemplateID = Template::get_default_template_set();
- Template::cache_template_file_hierarchy(TRUE);
+ Template::cache_template_file_hierarchy($sTemplateID, TRUE);
/**
* Make sure icon variables are setup for the login page.
/*
* $sTemplateID is not initialized when a user is not logged in, so we
* will use the config file defaults here. If the neccesary variables
- * are net set, force a default value.
+ * are not set, force a default value.
*/
- $sTemplateID = Template::get_default_template_set();
+ if (PAGE_NAME == 'squirrelmail_rpc') {
+ $sTemplateID = Template::get_rpc_template_set();
+ } else {
+ $sTemplateID = Template::get_default_template_set();
+ }
$oTemplate = Template::construct_template($sTemplateID);
set_up_language($squirrelmail_language, true);
* so we shouldn't change it here.
*/
if (!isset($sTemplateID)) {
- $sTemplateID = Template::get_default_template_set();
+ if (PAGE_NAME == 'squirrelmail_rpc') {
+ $sTemplateID = Template::get_rpc_template_set();
+ } else {
+ $sTemplateID = Template::get_default_template_set();
+ }
$icon_theme_path = !$use_icons ? NULL : Template::calculate_template_images_directory($sTemplateID);
}
// template set setup
//
$sDefaultTemplateID = Template::get_default_template_set();
-$sTemplateID = getPref($data_dir, $username, 'sTemplateID', $sDefaultTemplateID);
+if (PAGE_NAME == 'squirrelmail_rpc') {
+ $sTemplateID = Template::get_rpc_template_set();
+} else {
+ $sTemplateID = getPref($data_dir, $username, 'sTemplateID', $sDefaultTemplateID);
+}
// load user theme
// check user prefs template selection against templates actually available
//
$found_templateset = false;
-for ($i = 0; $i < count($aTemplateSet); ++$i){
- if ($aTemplateSet[$i]['ID'] == $sTemplateID) {
+if (PAGE_NAME == 'squirrelmail_rpc') {
+ // RPC skins have no in-memory list
+ if (is_dir(SM_PATH . Template::calculate_template_file_directory($sTemplateID))) {
$found_templateset = true;
- break;
+ }
+} else {
+ for ($i = 0; $i < count($aTemplateSet); ++$i){
+ if ($aTemplateSet[$i]['ID'] == $sTemplateID) {
+ $found_templateset = true;
+ break;
+ }
}
}
//
global $sTemplateID;
$sTemplateID = $option->new_value;
- Template::cache_template_file_hierarchy(TRUE);
+ Template::cache_template_file_hierarchy($sTemplateID, TRUE);
}
// having just logged in, need to synch the template file cache
// so the right template set is displayed (per user prefs)
require(SM_PATH . 'include/load_prefs.php');
-Template::cache_template_file_hierarchy(TRUE);
+global $sTemplateID;
+Template::cache_template_file_hierarchy($sTemplateID, TRUE);
/* Complete autodetection of Javascript. */
checkForJavascript();
+++ /dev/null
-<?php
-
-/**
- * rpc_response_error.tpl
- *
- * Template for constructing an error response to a remote
- * procedure call.
- *
- * The following variables are available in this template:
- * + $error_code - The numeric error code associated with the
- * current error condition
- * + $error_text - Any error message associated with the current
- * error condition (optional; may not be present)
- *
- * @copyright © 1999-2007 The SquirrelMail Project Team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @version $Id$
- * @package squirrelmail
- * @subpackage templates
- */
-
-
-// retrieve the template vars
-//
-extract($t);
-
-
-/*echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>';*/
-echo '<?xml version="1.0" ?>';
-?>
-<response>
- <status>ERROR</status>
- <result_code><?php echo $error_code; ?></result_code>
- <result_text><?php echo $error_text; ?></result_text>
-</response>
+++ /dev/null
-<?php
-
-/**
- * rpc_response_success.tpl
- *
- * Template for constructing a standard response to a remote
- * procedure call.
- *
- * The following variables are available in this template:
- * + $result_code - The result code (optional; if not given
- * must default to 0 (zero))
- * + $result_text - Any result message (optional; may not be
- * present)
- *
- * @copyright © 1999-2007 The SquirrelMail Project Team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @version $Id$
- * @package squirrelmail
- * @subpackage templates
- */
-
-
-// retrieve the template vars
-//
-extract($t);
-
-
-/*echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>';*/
-echo '<?xml version="1.0" ?>';
-?>
-<response>
- <status>OK</status>
- <result_code><?php echo $result_code; ?></result_code>
- <result_text><?php echo $result_text; ?></result_text>
-</response>