New functionality in holiday management. Can now create new holidays and submit them to the central repository for inclusion to future releases.

This commit is contained in:
skeeter 2001-05-20 15:08:25 +00:00
parent cc91bb484a
commit ede2d05e7a
6 changed files with 189 additions and 52 deletions

33
calendar/accept_holiday.php Executable file
View File

@ -0,0 +1,33 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* Written by Mark Peters <skeeter@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$send_back_to = str_replace('submitlocale','holiday_admin',$HTTP_REFERER);
if(!$locale)
{
Header('Location: '.$send_back_to);
}
$send_back_to = str_replace('&locale='.$locale,'',$send_back_to);
$file = './holidays.'.$locale;
if(!file_exists($file) && count($name))
{
$c_holidays = count($name);
$fp = fopen($file,'w');
for($i=0;$i<$c_holidays;$i++)
{
fwrite($fp,$locale."\t".$name[$i]."\t".$day[$i]."\t".$month[$i]."\t".$occurence[$i]."\t".$dow[$i]."\t".$observance[$i]."\n");
}
fclose($fp);
}
Header('Location: '.$send_back_to);
?>

View File

@ -74,6 +74,7 @@
$p->set_block('locale','list','list');
$p->set_block('locale','row','row');
$p->set_block('locale','row_empty','row_empty');
$p->set_block('locale','back_button_form','back_button_form');
$total = country_total($locale,$query);
if(!$total && !isset($query))
@ -81,15 +82,19 @@
Header('Location: ' . $phpgw->link('/calendar/holiday_admin.php'));
}
$p->set_var('th_bg',$phpgw_info['theme']['th_bg']);
$var = Array(
'th_bg' => $phpgw_info['theme']['th_bg'],
'left_next_matchs' => $phpgw->nextmatchs->left('/calendar/'.basename($SCRIPT_FILENAME),$start,$total,'&locale='.$locale),
'right_next_matchs' => $phpgw->nextmatchs->right('/calendar/'.basename($SCRIPT_FILENAME),$start,$total,'&locale='.$locale),
'lang_groups' => lang('Holidays').' ('.$locale.')',
'sort_name' => $phpgw->nextmatchs->show_sort_order($sort,'name',$order,'/calendar/'.basename($SCRIPT_FILENAME),lang('Holiday'),'&locale='.$locale),
'header_edit' => lang('Edit'),
'header_delete' => lang('Delete'),
'header_submit' => '',
'submit_link_column' => ''
);
$p->set_var('left_next_matchs',$phpgw->nextmatchs->left('/calendar/'.basename($SCRIPT_FILENAME),$start,$total,'&locale='.$locale));
$p->set_var('right_next_matchs',$phpgw->nextmatchs->right('/calendar/'.basename($SCRIPT_FILENAME),$start,$total,'&locale='.$locale));
$p->set_var('lang_groups',lang('Holidays').' ('.$locale.')');
$p->set_var('sort_name',$phpgw->nextmatchs->show_sort_order($sort,'name',$order,'/calendar/'.basename($SCRIPT_FILENAME),lang('Holiday'),'&locale='.$locale));
$p->set_var('header_edit',lang('Edit'));
$p->set_var('header_delete',lang('Delete'));
$p->set_var($var);
$holidays = get_holiday_list($locale, $sort, $order, $query, $total);
@ -103,26 +108,31 @@
while (list($index,$name) = each($holidays))
{
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$p->set_var('tr_color',$tr_color);
if (! $name) $name = '&nbsp;';
$p->set_var('group_name',$name);
$p->set_var('edit_link','<a href="' . $phpgw->link('/calendar/editholiday.php','locale='.$locale.'&id='.$index) . '"> ' . lang('Edit') . ' </a>');
$p->set_var('delete_link','<a href="' . $phpgw->link('/calendar/deleteholiday.php','locale='.$locale.'&id='.$index) . '"> ' . lang('Delete') . ' </a>');
$var = Array(
'tr_color' => $tr_color,
'header_delete' => lang('Delete'),
'group_name' => $name,
'edit_link' => '<a href="' . $phpgw->link('/calendar/editholiday.php','locale='.$locale.'&id='.$index) . '"> ' . lang('Edit') . ' </a>',
'delete_link' => '<a href="' . $phpgw->link('/calendar/deleteholiday.php','locale='.$locale.'&id='.$index) . '"> ' . lang('Delete') . ' </a>'
);
$p->set_var($var);
$p->parse('rows','row',True);
}
}
$p->set_var('new_action',$phpgw->link('/calendar/editholiday.php','locale='.$locale.'&id=0'));
$p->set_var('lang_add',lang('add'));
$p->set_var('back_action',$phpgw->link('/calendar/holiday_admin.php'));
$p->set_var('lang_back',lang('Back'));
$p->set_var('search_action',$phpgw->link('/calendar/editlocale.php','locale='.$locale));
$p->set_var('lang_search',lang('search'));
$var = Array(
'new_action' => $phpgw->link('/calendar/editholiday.php','locale='.$locale.'&id=0'),
'lang_add' => lang('add'),
'back_action' => $phpgw->link('/calendar/holiday_admin.php'),
'lang_back' => lang('Back'),
'search_action' => $phpgw->link('/calendar/editlocale.php','locale='.$locale),
'lang_search' => lang('search')
);
$p->set_var($var);
$p->parse('back_button','back_button_form',False);
$phpgw->common->phpgw_header();
echo parse_navbar();

View File

@ -68,26 +68,34 @@
return $locale;
}
$p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin'));
$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$templates = Array(
'group' => 'groups.tpl'
'locales' => 'locales.tpl'
);
$p->set_file($templates);
$p->set_block('group','list','list');
$p->set_block('group','row','row');
$p->set_block('group','row_empty','row_empty');
$p->set_block('locales','list','list');
$p->set_block('locales','row','row');
$p->set_block('locales','row_empty','row_empty');
$p->set_block('locales','submit_column','submit_column');
$total = country_total($query);
$p->set_var('th_bg',$phpgw_info['theme']['th_bg']);
$var = Array(
'th_bg' => $phpgw_info['theme']['th_bg'],
'left_next_matchs' => $phpgw->nextmatchs->left('/calendar/'.basename($SCRIPT_FILENAME),$start,$total),
'right_next_matchs' => $phpgw->nextmatchs->right('/calendar/'.basename($SCRIPT_FILENAME),$start,$total),
'lang_groups' => lang('Countries'),
'sort_name' => $phpgw->nextmatchs->show_sort_order($sort,'locale',$order,'/calendar/'.basename($SCRIPT_FILENAME),lang('Country')),
'header_edit' => lang('Edit'),
'header_delete' => lang('Delete'),
'submit_extra' => '',
'submit_link' => lang('Submit to Repository'),
'back_button' => ''
);
$p->set_var('left_next_matchs',$phpgw->nextmatchs->left('/calendar/'.basename($SCRIPT_FILENAME),$start,$total));
$p->set_var('right_next_matchs',$phpgw->nextmatchs->right('/calendar/'.basename($SCRIPT_FILENAME),$start,$total));
$p->set_var('lang_groups',lang('Countries'));
$p->set_var($var);
$p->set_var('sort_name',$phpgw->nextmatchs->show_sort_order($sort,'locale',$order,'/calendar/'.basename($SCRIPT_FILENAME),lang('Country')));
$p->set_var('header_edit',lang('Edit'));
$p->set_var('header_delete',lang('Delete'));
$p->parse('header_submit','submit_column',False);
$locales = get_locale_list($sort, $order, $query, $total);
@ -98,6 +106,7 @@
}
else
{
$p->set_var('submit_extra',' width="5%"');
while (list(,$value) = each($locales))
{
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
@ -105,20 +114,27 @@
if (! $value) $value = '&nbsp;';
$p->set_var('group_name',$value);
$p->set_var("edit_link",'<a href="' . $phpgw->link('/calendar/editlocale.php','locale='.$value) . '"> ' . lang('Edit') . ' </a>');
$p->set_var("delete_link",'<a href="' . $phpgw->link('/calendar/deletelocale.php','locale='.$value) . '"> ' . lang('Delete') . ' </a>');
$var = Array(
'tr_color' => $tr_color,
'group_name' => $value,
'edit_link' => '<a href="' . $phpgw->link('/calendar/editlocale.php','locale='.$value) . '"> ' . lang('Edit') . ' </a>',
'delete_link' => '<a href="' . $phpgw->link('/calendar/deletelocale.php','locale='.$value) . '"> ' . lang('Delete') . ' </a>',
'submit_link' => '<a href="' . $phpgw->link('/calendar/submitlocale.php','locale='.$value) . '"> ' . lang('Submit') . ' </a>'
);
$p->set_var($var);
$p->parse('submit_link_column','submit_column',False);
$p->parse('rows','row',True);
}
}
$p->set_var('new_action',$phpgw->link('/calendar/editholiday.php','id=0'));
$p->set_var("lang_add",lang('add'));
$p->set_var('search_action',$phpgw->link('/calendar/holiday_admin.php'));
$p->set_var('lang_search',lang('search'));
$var = Array(
'new_action' => $phpgw->link('/calendar/editholiday.php','id=0'),
'lang_add' => lang('add'),
'search_action' => $phpgw->link('/calendar/holiday_admin.php'),
'lang_search' => lang('search')
);
$p->set_var($var);
$p->pparse('out','list');
$phpgw->common->phpgw_footer();

View File

@ -124,7 +124,7 @@ class calendar_holiday
$lines = $network->gethttpsocketfile($load_from.'/holidays.'.strtoupper($locale));
if (!$lines) return false;
$c_lines = count($lines);
for($i=10;$i<$c_lines;$i++)
for($i=0;$i<$c_lines;$i++)
{
// echo 'Line #'.$i.' : '.$lines[$i]."<br>\n";
$holiday = explode("\t",$lines[$i]);
@ -250,6 +250,26 @@ class calendar_holiday
return $this->holidays;
}
function build_list_for_submission($locale)
{
global $phpgw;
$i = -1;
$this->db->query("SELECT * FROM phpgw_cal_holidays WHERE locale='".$locale."'");
while($this->db->next_record())
{
$i++;
$holidays[$i]['locale'] = $this->db->f('locale');
$holidays[$i]['name'] = $phpgw->strip_html($this->db->f('name'));
$holidays[$i]['day'] = intval($this->db->f('mday'));
$holidays[$i]['month'] = intval($this->db->f('month_num'));
$holidays[$i]['occurence'] = intval($this->db->f('occurence'));
$holidays[$i]['dow'] = intval($this->db->f('dow'));
$holidays[$i]['observance_rule'] = $this->db->f('observance_rule');
}
return $holidays;
}
function build_holiday_query()
{
$sql = 'SELECT * FROM phpgw_cal_holidays WHERE locale in (';

52
calendar/submitlocale.php Executable file
View File

@ -0,0 +1,52 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* Written by Mark Peters <skeeter@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$phpgw_flags = Array(
'currentapp' => 'calendar',
'enable_nextmatchs_class' => True,
'admin_header' => True,
'noheader' => True,
'nonavbar' => True,
'noappheader' => True,
'noappfooter' => True,
'parent_page' => '../admin/index.php'
);
$phpgw_info['flags'] = $phpgw_flags;
include('../header.inc.php');
if(!isset($locale) || !$locale)
{
Header('Location: ' . $phpgw->link('/calendar/holiday_admin.php'));
}
$holidays = $phpgw->calendar->holidays->build_list_for_submission($locale);
$phpgw->common->phpgw_header();
?>
<body onLoad="document.submitform.submit()">
<form action="http://www.phpgroupware.org/cal/accept_holiday.php" method="post" name="submitform">
<!-- <form action="<?php echo $phpgw->link('/calendar/accept_holiday.php'); ?>" method="post" name="submitform"> -->
<?php
$c_holidays = count($holidays);
echo '<input type="hidden" name="locale" value="'.$locale.'">'."\n";
for($i=0;$i<$c_holidays;$i++)
{
echo '<input type="hidden" name="name[]" value="'.$holidays[$i]['name'].'">'."\n"
. '<input type="hidden" name="day[]" value="'.$holidays[$i]['day'].'">'."\n"
. '<input type="hidden" name="month[]" value="'.$holidays[$i]['month'].'">'."\n"
. '<input type="hidden" name="occurence[]" value="'.$holidays[$i]['occurence'].'">'."\n"
. '<input type="hidden" name="dow[]" value="'.$holidays[$i]['dow'].'">'."\n"
. '<input type="hidden" name="observance[]" value="'.$holidays[$i]['observance_rule'].'">'."\n";
}
?>
</form>
</body>
</head>

View File

@ -13,6 +13,7 @@
<td>{sort_name}</td>
<td>{header_edit}</td>
<td>{header_delete}</td>
{header_submit}
</tr>
{rows}
@ -26,11 +27,7 @@
<input type="submit" value="{lang_add}">
</form>
</td>
<td align="center">
<form method="POST" action="{back_action}">
<input type="submit" value="{lang_back}">
</form>
</td>
{back_button}
<td align="right">{lang_search}&nbsp;
<form method="POST" action="{search_action}">
<input name="query">
@ -39,17 +36,26 @@
</tr>
</table>
<!-- END list -->
<!-- BEGIN row -->
<tr bgcolor="{tr_color}">
<td>{group_name}</td>
<td width="5%">{edit_link}</td>
<td width="5%">{delete_link}</td>
{submit_link_column}
</tr>
<!-- END row -->
<!-- BEGIN row_empty -->
<tr>
<td colspan="5" align="center">{message}</td>
</tr>
<!-- END row_empty -->
<!-- BEGIN submit_column -->
<td{submit_extra}>{submit_link}</td>
<!-- END submit_column -->
<!-- BEGIN back_button_form -->
<td align="center">
<form method="POST" action="{back_action}">
<input type="submit" value="{lang_back}">
</form>
</td>
<!-- END back_button_form -->