[Php-calendar-discussion] Calendar tweaks I have made 8/9
Brought to you by:
sproctor
|
From: Larry J. <joh...@gm...> - 2008-07-19 14:55:38
|
This is a great calendar (thanks Sean!). I have made some minor personal
tweaks that customize it a bit for me. See the text below for the details
on those tweaks. I am pretty new to the PHP programming environment so
these tweaks may not have been written in the best fashion but they do
work. If you have any suggestions or comments on them let me know, or if
you have any great tweaks as well.
--
Larry
PHP Calendar - Tweaks
#1 - Take out the footer hyperlinks
#2 - Put in color settings
#3 - Put in IE document type so that calendar "stretches" like it
automatically does in Firefox
#4 - (3 entries) Putting in the programming so that a user can only modify
or delete their own entries
#5 - Things work perfectly in Firefox, but in IE the column widths are not
showing right. To fix that adjust this code.
#6 - Put in a header
#7 - Change the text in some of the buttons
#8 - Put in programming so that a user can only modify the calendars that
they have access to
#1 - Take out the footer hyperlinks calendar.php
comment this out -> function link_bar()
#2 - Put in different color settings index.php
define('SEPCOLOR', '#000000'); // calendar gridlines; default =
#000000 (which is black)
define('BG_COLOR1', '#FFFFFF'); // background behind calendar;
default = #FFFFFF (which is white)
define('BG_COLOR2', '#4E78A0'); // extra days at the beg/end of a
month that are not part of the month + background when highlight a cal
entry; default =
gray
define('BG_COLOR3', '#FF8C00'); // column headings and buttons at
top; default = silver
define('BG_COLOR4', '#EEE8AA'); // add event background; default =
#CCCCCC (which is gray)
define('BG_PAST', '#EEE8AA'); // past days, days already passed;
default = silver
define('BG_FUTURE', '#EEE8AA'); // future days; default = white
define('TEXTCOLOR1', '#000000'); // font for title, buttons, column
headings and date; default = #000000 (which is black)
define('TEXTCOLOR2', '#FFFFFF'); // font when highlight a calendar
entry; default = #FFFFFF (which is white)
#3 - Put in IE document type so that calendar "stretches" like it
automatically does in Firefox calendar.php
Place the following code at the top of calendar.php:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd">
#4 - (3 entries) Putting in the programming so that a user can only modify
or delete their own entries
#4a
display.php function display_id($id) in the php document
display.php
// displays a particular event to be show singly
// returns XHTML data for the event
function display_id($id)
{
global $db, $year, $month, $day, $config;
$row = get_event_by_id($id);
$year = $row['year'];
$month = $row['month'];
$day = $row['day'];
$time_str = formatted_time_string($row['starttime'], $row['eventtype']);
$date_str = formatted_date_string($row['year'], $row['month'],
$row['day'], $row['end_year'], $row['end_month'],
$row['end_day']);
$dur_str = get_duration($row['duration'], $row['eventtype']);
$subject = htmlspecialchars(strip_tags(stripslashes($row['subject'])));
if(empty($subject)) $subject = _('(No subject)');
$name = stripslashes($row['username']);
$desc = parse_desc($row['description']);
if(check_user() || $config['anon_permission'] >= 2)
{
if ($_SESSION['user'] == $name OR $_SESSION['user'] ==
"johnlaus")
{
return tag('div', attributes('class="phpc-main"'),
tag('h2', $subject),
tag('div', 'by ', tag('cite', $name)),
tag('div', create_id_link(_('Modify'),
'event_form',
$id), "\n",
create_id_link(_('Delete'),
'event_delete',
$id)),
tag('div',
tag('div', _('Date').": $date_str"),
tag('div', _('Time').": $time_str"),
tag('div', _('Duration').":
$dur_str")),
tag('p', $desc));
} else {
return tag('div', attributes('class="phpc-main"'),
tag('h2', $subject),
tag('div', 'by ', tag('cite', $name)),
tag('div',
tag('div', _('Date').": $date_str"),
tag('div', _('Time').": $time_str"),
tag('div', _('Duration').":
$dur_str")),
tag('p', $desc));
}
} else {
return tag('div', attributes('class="phpc-main"'),
tag('h2', $subject),
tag('div', 'by ', tag('cite', $name)),
tag('div',
tag('div', _('Date').": $date_str"),
tag('div', _('Time').": $time_str"),
tag('div', _('Duration').":
$dur_str")),
tag('p', $desc));
}
}
?>
#4b event_form.php
$name = stripslashes($row['username']);
if ($_SESSION['user'] <> $name AND $_SESSION['user'] <> "johnlaus")
{
die("Hacking attempt to modify! You are in trouble " .
$_SESSION['user'] . "!");
}
#4c event_delete.php
$row = get_event_by_id($id);
$name = stripslashes($row['username']);
if ($_SESSION['user'] <> $name AND $_SESSION['user'] <> "johnlaus")
{
die("Hacking attempt to delete! You are in trouble " .
$_SESSION['user'] . "!");
}
#5 - Things work perfectly in Firefox, but in IE the column widths are not
showing right. To fix that adjust this code. display.php
return tag('div',
month_navbar($month, $year),
tag('table', attributes('class="phpc-main"',
'id="calendar"'),
tag('caption', month_name($month)." $year"),
tag('colgroup', attributes('span="7"',
'width="14.3%"')),
tag('thead', $days),
create_month($month, $year)));
#6 - Put in a header header.php
<img src="images/Aesculap_Logo2.jpg" WIDTH=280 HEIGHT=60 alt="Logo">
<br>
calendar.php <?php include "header.php"; ?>
#7 - Change the text in some of the buttons display.php
function month_navbar($month, $year)
{
$html = tag('div', attributes('class="phpc-navbar"'));
menu_item_append($html, _('<< year'), 'display', $year - 1, $month);
menu_item_append($html, _('<< month'), 'display', $year, $month - 1);
for($i = 1; $i <= 12; $i++) {
menu_item_append($html, short_month_name($i), 'display', $year,
$i);
}
menu_item_append($html, _('>> month'), 'display', $year, $month + 1);
menu_item_append($html, _('>> year'), 'display', $year + 1, $month);
return $html;
}
#8 - Put in programming so that a user can only modify the calendars that
they have access to
When I installed the calendar I found that if a user has log-in access to
calendar 1, then if they open up calendar 2 they also have update access to
it as well,
i.e. they were also logged-in to the calendar 2. This occurred even if they
did not have a log-in for calendar 2. So I changed the text
$_SESSION['user'] in each
calendar to also include the calendar #. So for example for calendar 000 I
changed the text $_SESSION['user'] to $_SESSION['user000'].
|