[dev] Re: [cvs] commit: vacation - Imported sources

Joel Vandal jvandal@subi.to
Wed, 22 May 2002 01:11:48 -0400


Eric,

I've see that you have add the vacation modules on cvs, but when I try to
use it, they use old horde api like  gettemplatepath(), getwebroot, etc...

Here are the change I've made to eliminate error on Horde 3.0-cvs/IMP
4.0-cvs ...

===cut===

diff -u -r vacation/config/conf.php vacation.new/config/conf.php
--- vacation/config/conf.php Tue May 21 23:07:06 2002
+++ vacation.new/config/conf.php Wed May 22 00:52:38 2002
@@ -43,6 +43,6 @@
 // Define apps to put in the menu bar.  To include IMP in the menu bar, you
 // would add: $conf['menu']['apps'] = array('imp');

-$conf['menu']['apps'] = array('accounts');
+$conf['menu']['apps'] = array();

 ?>
diff -u -r vacation/index.php vacation.new/index.php
--- vacation/index.php Tue May 21 23:07:06 2002
+++ vacation.new/index.php Wed May 22 01:08:10 2002
@@ -1,26 +1,32 @@
 <?php
+/*
+ * $Horde: vacation/index.php,v 1.1.1.1 2002/05/22 03:07:06 ericr Exp $
+ *
+ * Copyright 1999-2002 Jon Parise <jon@horde.org>
+ *
+ * See the enclosed file COPYING for license information (GPL).  If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ */
+
 define('VACATION_BASE', dirname(__FILE__));
-$vacation_configured =   (  @is_readable(VACATION_BASE .
'/config/html.php')
-                        &&  @is_readable(VACATION_BASE .
'/config/conf.php')
-                        &&  @is_readable(VACATION_BASE .
'/config/prefs.php'));
+$vacation_configured = (@is_readable(VACATION_BASE . '/config/conf.php') &&
+                     @is_readable(VACATION_BASE . '/config/html.php') &&
+                     @is_readable(VACATION_BASE . '/config/prefs.php'));

 if ($vacation_configured) {
     include_once VACATION_BASE . '/lib/base.php';
+
     $uri = 'main.php';
     if (!empty($HTTP_SERVER_VARS['QUERY_STRING'])) {
-       $uri .= '?' . $HTTP_SERVER_VARS['QUERY_STRING'];
+        $uri .= '?' . $HTTP_SERVER_VARS['QUERY_STRING'];
     }
+
     header('Location: ' . Horde::applicationUrl($uri, true));
     exit;

-/* vacation isn't configured */
+/* Vacation isn't configured */
 } else {
-    include_once VACATION_BASE . '/lib/base.php';
-
-    $title = 'Vacation module is not fully configured.';
-    include VACATION_BASE . '/templates/common-header.inc';
-    include VACATION_BASE . '/templates/notconfigured.inc';
-    include VACATION_BASE . '/templates/common-footer.inc';
+    include VACATION_BASE . '/templates/index/notconfigured.inc';
 }

 ?>
diff -u -r vacation/lib/base.php vacation.new/lib/base.php
--- vacation/lib/base.php Tue May 21 23:07:06 2002
+++ vacation.new/lib/base.php Wed May 22 00:39:49 2002
@@ -1,6 +1,5 @@
 <?php
 // $Horde: vacation/lib/base.php,v 1.1.1.1 2002/05/22 03:07:06 ericr Exp $
-
 /*
  * VACATION base inclusion file.
  *
@@ -11,7 +10,7 @@
 // Find the base file path of Horde
 @define('HORDE_BASE', dirname(__FILE__) . '/../..');

-// Find the base file path of VACATION
+// Find the base file path of Vacation
 @define('VACATION_BASE', dirname(__FILE__) . '/..');

 // Registry
@@ -19,57 +18,40 @@
 $registry = &Registry::singleton();
 $registry->pushApp('vacation');
 $conf = &$GLOBALS['conf'];
+@define('VACATION_TEMPLATES', $registry->getParam('templates'));

-// set error reporting according to config settings
+// Set the error reporting level in accordance with the config settings.
 error_reporting($conf['debug_level']);

-// set max execution time according to config settings
+// Set the maximum execution time in accordance with the config settings.
 set_time_limit($conf['max_exec_time']);

+// set the umask according to config settings
+if (isset($conf['umask'])) {
+    umask($conf['umask']);
+}
+
 // Horde base libraries
 require_once HORDE_BASE . '/lib/Horde.php';
 require_once HORDE_BASE . '/lib/Auth.php';
-require_once HORDE_BASE . '/lib/Secret.php';
+require_once HORDE_BASE . '/lib/Text.php';
+require_once HORDE_BASE . '/lib/Help.php';

+// Vacation base library
+// require_once VACATION_BASE . '/lib/Vacation.php';

 // Browser detection library
 require_once HORDE_BASE . '/lib/Browser.php';
 $browser = new Browser();
-if (isset($session_control)) {
-    switch ($session_control) {
-    case 'netscape':
-        if ($browser->isBrowser('netscape')) {
-            session_cache_limiter('private, must-revalidate');
-        }
-        break;
-
-    case 'cache_ssl_downloads':
-        header('Vary: User-Agent');
-        if ($browser->hasQuirk('cache_ssl_downloads')
-            && isset($GLOBALS['HTTP_SERVER_VARS']['HTTPS'])
-            && ($GLOBALS['HTTP_SERVER_VARS']['HTTPS'] == 'on')) {
-            session_cache_limiter('private, must-revalidate');
-        }
-        break;
-    }
-}
-
-// Help
-require_once HORDE_BASE . '/lib/Help.php';

-// VACATION base library
-#require_once VACATION_BASE . '/lib/version.php';
-define('VACATION_NAME', 'Horde Vacation module');
-
-// Code that should be run at the beginning of all vacation pages
-session_name($conf['session_name']);
-@session_start();
+// Notification sytem
+require_once HORDE_BASE . '/lib/Notification.php';
+$notification = &Notification::singleton();
+$notification->attach('status');

-// Don't allow access unless there is a Horde login
-// NOTE:  We explicitely do not honor the guests flag here!!!
+// Redirect the user to the Horde login page if they haven't authenticated.
 if (!Auth::getAuth()) {
-    header('Location: ' . Horde::url($registry->getWebRoot("horde") .
'/login.php?url=' . urlencode(Horde::selfUrl()), true));
-    echo "\n";
+    header('Location: ' . Horde::url($registry->getParam('webroot',
'horde') . '/login.php?url=' . urlencode(Horde::selfUrl()), true));
     exit;
 }

diff -u -r vacation/main.php vacation.new/main.php
--- vacation/main.php Tue May 21 23:07:06 2002
+++ vacation.new/main.php Wed May 22 00:51:55 2002
@@ -1,10 +1,11 @@
 <?php

 define('VACATION_BASE', dirname(__FILE__));
-include_once VACATION_BASE . '/lib/base.php';
+require_once VACATION_BASE . '/lib/base.php';
 require_once VACATION_BASE . '/config/conf.php';
-include  $registry->getTemplatePath() . '/common-header.inc';
-include_once $registry->getTemplatePath('horde') .
'/javascript/open_help_win.js';
+
+require VACATION_TEMPLATES . '/common-header.inc';
+//include_once VACATION_TEMPLATES . '/javascript/open_help_win.js';


 $submit=Horde::getFormData('submit', false);
@@ -74,8 +75,7 @@
   }
 ?>
 <?php
-    require $registry->getFileRoot() . '/status.php';
-    include  $registry->getTemplatePath() . '/main.inc';
-    include VACATION_BASE . '/templates/common-footer.inc';
-
+    require VACATION_BASE . '/status.php';
+    require VACATION_TEMPLATES . '/main.inc';
+    require VACATION_BASE . '/templates/common-footer.inc';
 ?>
diff -u -r vacation/menu.php vacation.new/menu.php
--- vacation/menu.php Tue May 21 23:07:06 2002
+++ vacation.new/menu.php Wed May 22 01:06:35 2002
@@ -9,24 +9,18 @@
  * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
  */

-define('VACATION_BASE', dirname(__FILE__));
-include_once VACATION_BASE . '/lib/base.php';
 require_once HORDE_BASE . '/lib/Menu.php';

-if ($prefs->getValue("frames_mode")  && ! preg_match("/frames_menu\.php$/",
$PHP_SELF)) return;
-
 /* Check for additional site-specific menu items (in config/menu.php). */
 $additional_items = '';
 if (@is_readable(VACATION_BASE . '/config/menu.php')) {
     include_once VACATION_BASE . '/config/menu.php';
-    if (isset($_menu) && is_array($_menu)) {
-        foreach ($_menu as $item) {
-            $additional_items .= Menu::customItem($item);
-        }
+    foreach ($_menu as $item) {
+        $additional_items .= Menu::customItem($item);
     }
 }

-require $registry->getTemplatePath() . '/menu.inc';
+require VACATION_TEMPLATES . '/menu.inc';

 /* Include the JavaScript for the help system (if enabled). */
 if ($conf['user']['online_help'] && $browser->hasFeature('javascript')) {
diff -u -r vacation/templates/common-footer.inc
vacation.new/templates/common-footer.inc
--- vacation/templates/common-footer.inc Tue May 21 23:07:07 2002
+++ vacation.new/templates/common-footer.inc Wed May 22 00:27:02 2002
@@ -1,8 +1,7 @@
-<?php // $Horde: vacation/templates/common-footer.inc,v 1.1.1.1 2002/05/22
03:07:07 ericr Exp $ ?>
 <?php if (!empty($title)): ?>
 <script language="JavaScript" type="text/javascript">
 <!--
-if (parent.frames.horde_main) parent.document.title = '<?=
addslashes($registry->getName() . ' :: ' . $title) ?>';
+if (parent.frames.horde_main) parent.document.title = '<?=
addslashes($registry->getParam('name') . ' :: ' . $title) ?>';
 //-->
 </script>
 <?php endif; ?>
diff -u -r vacation/templates/common-header.inc
vacation.new/templates/common-header.inc
--- vacation/templates/common-header.inc Tue May 21 23:07:07 2002
+++ vacation.new/templates/common-header.inc Wed May 22 00:26:20 2002
@@ -5,30 +5,27 @@
 }
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
-
-<!--          Vacation: Copyright 2000-2001, The Horde
         -->
-<!-- Horde Project: http://horde.org/ | Chora: http://horde.org/chora/ -->
-<!--     GNU Public License: http://www.fsf.org/copyleft/gpl.html      -->
-
-<html>
+<?= !empty($language) ? '<html lang="' . strtr($language, '_', '-') . '">'
: '<html>' ?>
 <head>
 <?php

-/* Print the page title. */
-$page_title = $registry->getName();
+$page_title = $registry->getParam('name');
 if (!empty($title)) $page_title .= ' :: ' . $title;
 if (!empty($refresh_time) && ($refresh_time > 0) && !empty($refresh_url)) {
     echo "<meta http-equiv=\"refresh\"
content=\"$refresh_time;url=$refresh_url\">\n";
 }

+$theme = '';
+if (isset($prefs)) {
+    $theme = $prefs->getValue('theme');
+}
+if (!empty($theme)) {
+    $theme = '&theme=' . $theme;
+}
+
 ?>
 <title><?= $page_title ?></title>
-<link href="<?= $registry->getWebRoot('horde') ?>/css.php?app=vacation"
rel="stylesheet" type="text/css" />
+<link href="<?= $registry->getParam('webroot', 'horde')
?>/css.php?app=vacation<?= $theme ?>" rel="stylesheet" type="text/css" />
 </head>

-<?php if (!empty($js_onLoad)): ?>
-<body onload="<?= $js_onLoad ?>">
-<?php else: ?>
-<body>
-<?php endif; ?>
-
+<body<?php if (!empty($js_onLoad)) echo ' onload="' . $js_onLoad . '"'; if
(!empty($bodyStyle)) echo ' class="' . $bodyStyle . '"' ?>>
diff -u -r vacation/templates/menu.inc vacation.new/templates/menu.inc
--- vacation/templates/menu.inc Tue May 21 23:07:07 2002
+++ vacation.new/templates/menu.inc Wed May 22 00:48:55 2002
@@ -1,9 +1,3 @@
-<?php // $Horde: vacation/templates/menu.inc,v 1.1.1.1 2002/05/22 03:07:07
ericr Exp $ ?>
-
-<?php
-include_once HORDE_BASE . '/lib/Menu.php';
-?>
-
 <table border="0" cellpadding="2" cellspacing="0" width="100%">
 <tr>
     <td class="menu">
@@ -12,42 +6,33 @@
 <tr>
 <?php

+/* Vacation menu items */
+
 /* Horde menu items */
 if ($conf['problems']['enabled']) {
-    include_once HORDE_BASE . '/lib/Identity.php';
-    $prob_identity = new Identity();
-    Menu::printItem(Horde::url($registry->getWebRoot("horde") .
'/problem.php?email=' . urlencode($prob_identity->getValue('from_addr')) .
'&name=' . urlencode($prob_identity->getValue('fullname')) . '&return_url='
. urlencode(Horde::url($HTTP_SERVER_VARS['PHP_SELF'], true))),
_("Problem?"), 'problem.gif', $registry->getGraphicsPath("horde"));
+     // Menu::printItem(Horde::url($registry->getParam('webroot', 'horde')
. '/problem.php?return_url=' .
urlencode(Horde::url($HTTP_SERVER_VARS['PHP_SELF'], true))), _("Problem?"),
'problem.gif', $registry->getParam('graphics', 'horde'));
 }

 /* Additional site-specific menu items */
 if (!empty($additional_items)) echo $additional_items;

-/* Links to other Horde applications. */
-if (isset($conf['menu']['apps']) && is_array($conf['menu']['apps'])) {
-    foreach ($conf['menu']['apps'] as $service) {
-        $params = $registry->applications[$service];
-        Menu::printItem(Horde::url($params['webroot'] . '/' .
(isset($params['initial_page']) ? $params['initial_page'] : '')),
-                        $params['name'], $params['icon'], '');
-    }
-}
-
 /* Online Help */
 if ($conf['user']['online_help'] && $browser->hasFeature('javascript')) {
-    Menu::printItem(Help::listLink('vacation'), _("Help"), 'help.gif',
$registry->getGraphicsPath("horde"));
+     // Menu::printItem(Help::listLink('mnemo'), _("Help"), 'help.gif',
$registry->getParam('graphics', 'horde'));
 }

-/* Logout */
-Menu::printItem(Horde::url($registry->getWebRoot('horde') .
'/login.php?reason=logout'), _("Logout"), 'logout.gif',
$registry->getGraphicsPath("horde"));
+/* Links to other Horde applications. */
+if (isset($conf['menu']['apps']) && is_array($conf['menu']['apps'])) {
+    foreach ($conf['menu']['apps'] as $app) {
+          Menu::printItem(Horde::url($registry->getInitialPage($app)),
+                        $registry->getParam('name', $app),
$registry->getParam('icon', $app), '');
+    }
+}

 ?>

 <td width="100%">&nbsp;</td><!-- spacer -->

-</tr>
-</table>
-
-    </td>
-</tr>
-</table>
+</tr></table></td></tr></table>

 <br />