par
Kiroha » 11 mars 2010, 19:16
Code : Tout sélectionner
<?php
/* $Id: edit_entry.php,v 1.203.2.9 2008/04/04 18:42:59 umcesrjones Exp $
*
* Description:
* Presents page to edit/add an event/task/journal
*
* Notes:
* A SysAdmin can enable HTML for event full descriptions. If one of the
* supported HTML edit widgets is also installed, users can use WYSIWYG editing.
* See the WebCalendar page at
* http://www.k5n.us/webcalendar.php?topic=Add-Ons
* for download and install instructions for these packages.
*/
include_once 'includes/init.php';
/* Generate HTML for a time selection for use in a form.
*
* @param string $prefix Prefix to use in front of form element names
* @param string $time Currently selected time in HHMMSS
* @param bool $trigger Add onchange event trigger that
* calls javascript function $prefix_timechanged ()
*
* @return string HTML for the selection box
*/
function time_selection ( $prefix, $time = '', $trigger = false ) {
global $checked, $ENTRY_SLOTS, $selected, $TIME_FORMAT, $WORK_DAY_START_HOUR;
$amsel = $pmsel = $ret = '';
$trigger_str = ( $trigger ? 'onchange="' . $prefix . 'timechanged() ' : '' );
if ( ! isset ( $time ) && $time != 0 ) {
$hour = $WORK_DAY_START_HOUR;
$minute = 0;
} else {
$hour = floor ( $time / 10000 );
$minute = ( ( $time / 100 ) % 100 ) % 60;
}
if ( $TIME_FORMAT == '12' ) {
$maxhour = 12;
if ( $hour < 12 || $hour == 24 )
$amsel = $checked;
else
$pmsel = $checked;
$hour %= 12;
if ( $hour == 0 )
$hour = 12;
} else {
$maxhour = 24;
$hour = sprintf ( "%02d", $hour );
}
$minute = sprintf ( "%02d", $minute );
$ret .= '
<select ' . 'name="' . $prefix . 'hour" id="' . $prefix . 'hour" '
. $trigger_str . '>';
for ( $i = 0; $i < $maxhour; $i++ ) {
$ihour = ( $TIME_FORMAT == '24' ? sprintf ( "%02d", $i ) : $i );
if ( $i == 0 && $TIME_FORMAT == '12' )
$ihour = 12;
$ret .= '
<option value="' . "$i\"" . ( $ihour == $hour ? $selected : '' )
. ">$ihour" . '</option>';
}
$ret .= '
</select>:
<select ' . 'name="' . $prefix . 'minute" id="' . $prefix
. 'minute" ' . $trigger_str . '>';
// We use $TIME_SLOTS to populate the minutes pulldown.
$found = false;
for ( $i = 0; $i < 60; ) {
$imin = sprintf ( "%02d", $i );
$isselected = '';
if ( $imin == $minute ) {
$found = true;
$isselected = $selected;
}
$ret .= '
<option value="' . "$i\"$isselected>$imin" . '</option>';
$i += ( 1440 / $ENTRY_SLOTS );
}
// We'll add an option with the exact time if not found above.
return $ret . ( $found ? '' : '
<option value="' . "$minute\" $selected>$minute" . '</option>' ) . '
</select>' . ( $TIME_FORMAT == '12' ? '
<label><input type="radio" name="' . $prefix . 'ampm" id="'
. $prefix . 'ampmA" value="0" ' . $amsel . ' /> ' . translate ( 'am' )
. '</label>
<label><input type="radio" name="' . $prefix . 'ampm" id="'
. $prefix . 'ampmP" value="12" ' . $pmsel . ' /> ' . translate ( 'pm' )
. '</label>' : '
<input type="hidden" name="' . $prefix . 'ampm" value="0" />' );
}
$daysStr = translate ( 'days' );
$hoursStr = translate ( 'hours' );
$minutStr = translate ( 'minutes' );
$saveStr = translate ( 'Save' );
load_user_categories ();
// Default for using tabs is enabled.
if ( empty ( $EVENT_EDIT_TABS ) )
$EVENT_EDIT_TABS = 'Y'; // default
$useTabs = ( $EVENT_EDIT_TABS == 'Y' );
// Make sure this is not a read-only calendar.
$can_edit = false;
$others_complete = 'yes';
$checked = ' checked="checked"';
$selected = ' selected="selected"';
// Public access can only add events, not edit.
if ( empty ( $login ) || ( $login == '__public__' && $id > 0 ) )
$id = 0;
$eType = getGetValue ( 'eType' );
if ( empty ( $eType ) )
$eType = 'event';
$copy = getValue ( 'copy', '[01]' );
$date = getValue ( 'date', '-?[0-9]+' );
$day = getValue ( 'day', '-?[0-9]+' );
$month = getValue ( 'month', '-?[0-9]+' );
$year = getValue ( 'year', '-?[0-9]+' );
if ( empty ( $date ) && empty ( $month ) ) {
if ( empty ( $year ) )
$year = date ( 'Y' );
$month = date ( 'm' );
if ( empty ( $day ) )
$day = date ( 'd' );
$date = sprintf ( "%04d%02d%02d", $year, $month, $day );
}
$BodyX = 'onload="onLoad();"';
$INC = array ( 'js/edit_entry.php/false/' . $user, 'js/visible.php' );
$textareasize = '15';
// Can we use HTMLArea or FCKEditor? (Relax! That's the authors initials.)
// Note: HTMLArea has been discontinued, so FCKEditor is preferred.
$use_fckeditor = $use_htmlarea = false;
if ( $ALLOW_HTML_DESCRIPTION == 'Y' ) {
// Allow HTML in description.
// If they have installed an HTML edit widget, make use of it.
if ( file_exists ( 'includes/FCKeditor-2.0/fckeditor.js' ) &&
file_exists ( 'includes/FCKeditor-2.0/fckconfig.js' ) ) {
$textareasize = '20';
$use_fckeditor = true;
} else
if ( file_exists ( 'includes/htmlarea/htmlarea.php' ) ) {
$BodyX = 'onload="onLoad();initEditor();';
$INC[] = 'htmlarea/core.php/true';
$INC[] = 'htmlarea/htmlarea.php/true';
$use_htmlarea = true;
}
}
$byday = $bymonth = $bymonthday = $bysetpos = $participants = array ();
$exceptions = $inclusions = $reminder = array ();
$byweekno = $byyearday = $catList = $catNames = $external_users = $rpt_count = '';
$create_by = $login;
//This is the default per RFC2445
//We could override it and use $byday_names[$WEEK_START]
$wkst = 'MO';
$real_user = ( ( ! empty ( $user ) && strlen ( $user ) ) &&
( $is_assistant || $is_admin ) ) ? $user : $login;
print_header ( $INC, '', $BodyX, false, false, false, true );
ob_start ();
if ( $readonly == 'Y' || $is_nonuser )
$can_edit = false;
else
if ( ! empty ( $id ) && $id > 0 ) {
// First see who has access to edit this entry.
if ( $is_admin )
$can_edit = true;
$res = dbi_execute ( 'SELECT cal_create_by, cal_date, cal_time, cal_mod_date,
cal_mod_time, cal_duration, cal_priority, cal_type, cal_access, cal_name,
cal_description, cal_group_id, cal_location, cal_due_date, cal_due_time,
cal_completed, cal_url FROM webcal_entry WHERE cal_id = ?', array ( $id ) );
if ( $res ) {
$row = dbi_fetch_row ( $res );
// If current user is creator of event, then they can edit.
if ( $row[0] == $login )
$can_edit = true;
$cal_date = ( ! empty ( $override ) && ! empty ( $date )
? $date // Leave $cal_date to what was set in URL with date=YYYYMMDD.
: $row[1] );
$create_by = $row[0];
if ( ( $user == $create_by ) && ( $is_assistant || $is_nonuser_admin ) )
$can_edit = true;
$cal_time = sprintf ( "%06d", $row[2] );
$due_date = $row[13];
$due_time = $row[14];
$calTS = date_to_epoch ( $cal_date . $cal_time );
// Don't adjust for All Day entries.
if ( $cal_time > 0 || ( $cal_time == 0 && $row[5] != 1440 ) ) {
$cal_date = date ( 'Ymd', $calTS );
$cal_time = date ( 'His', $calTS );
}
$hour = floor ( $cal_time / 10000 );
$minute = ( $cal_time / 100 ) % 100;
$dueTS = date_to_epoch ( $due_date . $due_time );
$due_date = date ( 'Ymd', $dueTS );
$due_time = date ( 'His', $dueTS );
$due_hour = floor ( $due_time / 10000 );
$due_minute = ( $due_time / 100 ) % 100;
$priority = $row[6];
$type = $row[7];
$access = $row[8];
$name = $row[9];
$description = $row[10];
$parent = $row[11];
$location = $row[12];
$completed = ( empty ( $row[15] ) ? date ( 'Ymd' ) : $row[15] );
$cal_url = $row[16];
// What kind of entry are we dealing with?
if ( strpos ( 'EM', $type ) !== false )
$eType = 'event';
elseif ( strpos ( 'JO', $type ) !== false )
$eType = 'journal';
elseif ( strpos ( 'NT', $type ) !== false )
$eType = 'task';
// Public access has no access to tasks.
// translate ( 'You are not authorized to edit this task' )
if ( $login == '__public__' && $eType == 'task' )
echo str_replace ( 'XXX', translate ( 'task' ),
translate ( 'You are not authorized to edit this XXX.' ) );
// Check UAC.
if ( access_is_enabled () )
$can_edit =
access_user_calendar ( 'edit', $create_by, $login, $type, $access );
$day = $cal_date % 100;
$month = ( $cal_date / 100 ) % 100;
$year = intval ( $cal_date / 10000 );
$time = $row[2];
if ( $time >= 0 )
$duration = $row[5];
else {
$duration = '';
$hour = -1;
}
// Check for repeating event info...
// but not if we're overriding a single entry of an already repeating event...
// confusing, eh?
if ( ! empty ( $override ) ) {
$rpt_end = 0;
$rpt_end_date = $cal_date;
$rpt_freq = 1;
$rpt_type = 'none';
} else {
$res = dbi_execute ( 'SELECT cal_id, cal_type, cal_end, cal_endtime,
cal_frequency, cal_byday, cal_bymonth, cal_bymonthday, cal_bysetpos,
cal_byweekno, cal_byyearday, cal_wkst, cal_count
FROM webcal_entry_repeats WHERE cal_id = ?', array ( $id ) );
if ( $res ) {
if ( $row = dbi_fetch_row ( $res ) ) {
$rpt_type = $row[1];
$rpt_end = ( $row[2] > 0 ? date_to_epoch ( $row[2] . $row[3] ) : 0 );
if ( empty ( $row[2] ) ) {
$rpt_end_date = $cal_date;
$rpt_end_time = $cal_time;
} else {
$rpt_endTS = date_to_epoch ( $row[2] . $row[3] );
$rpt_end_date = date ( 'Ymd', $rpt_endTS );
$rpt_end_time = date ( 'His', $rpt_endTS );
}
$rpt_freq = $row[4];
if ( ! empty ( $row[5] ) )
$byday = explode ( ',', $row[5] );
$bydayStr = $row[5];
if ( ! empty ( $row[6] ) )
$bymonth = explode ( ',', $row[6] );
if ( ! empty ( $row[7] ) )
$bymonthday = explode ( ',', $row[7] );
$bymonthdayStr = $row[7];
if ( ! empty ( $row[8] ) )
$bysetpos = explode ( ',', $row[8] );
$bysetposStr = $row[8];
$byweekno = $row[9];
$byyearday = $row[10];
$wkst = $row[11];
$rpt_count = $row[12];
// Check to see if Weekends Only is applicable.
$weekdays_only = ( $rpt_type == 'daily' && $byday == 'MO,TU,WE,TH,FR' );
}
dbi_free_result ( $res );
}
}
$res = dbi_execute ( 'SELECT cal_login, cal_percent, cal_status
FROM webcal_entry_user WHERE cal_id = ?', array ( $id ) );
if ( $res ) {
while ( $row = dbi_fetch_row ( $res ) ) {
$overall_percent[] = $row;
if ( $login == $row[0] || ( $is_admin && $user == $row[0] ) ) {
$task_percent = $row[1];
$task_status = $row[2];
}
}
dbi_free_result ( $res );
}
// Determine if Expert mode needs to be set.
$expert_mode = ( count ( $byday ) || count ( $bymonth ) ||
count ( $bymonthday ) || count ( $bysetpos ) ||
isset ( $byweekno ) || isset ( $byyearday ) || isset ( $rpt_count ) );
// Get Repeat Exceptions.
$res = dbi_execute ( 'SELECT cal_date, cal_exdate
FROM webcal_entry_repeats_not WHERE cal_id = ?', array ( $id ) );
if ( $res ) {
while ( $row = dbi_fetch_row ( $res ) ) {
if ( $row[1] == 1 )
$exceptions[] = $row[0];
else
$inclusions[] = $row[0];
}
dbi_free_result ( $res );
}
}
if ( $CATEGORIES_ENABLED == 'Y' ) {
$catById = get_categories_by_id ( $id, $real_user, true );
if ( ! empty ( $catById ) ) {
$catNames = implode ( ', ', $catById );
$catList = implode ( ',', array_keys ( $catById ) );
}
} //end CATEGORIES_ENABLED test
// Get reminders.
$reminder = getReminders ( $id );
$reminder_offset = ( empty ( $reminder ) ? 0 : $reminder['offset'] );
$rem_status = ( count ( $reminder ));
$rem_use_date = ( ! empty ( $reminder['date'] ) );
// Get participants.
$res = dbi_execute ( 'SELECT cal_login, cal_status FROM webcal_entry_user WHERE cal_id = ?
AND cal_status IN ( \'A\', \'W\' )', array ( $id ) );
if ( $res ) {
while ( $row = dbi_fetch_row ( $res ) ) {
$participants[$row[0]] = 1;
$selectedStatus[$row[0]] = $row[1];
}
dbi_free_result ( $res );
}
// Not allowed for tasks or journals.
if ( $eType == 'event' && !
empty ( $ALLOW_EXTERNAL_USERS ) && $ALLOW_EXTERNAL_USERS == 'Y' )
$external_users = event_get_external_users ( $id );
} else {
// ########## New entry ################
$id = 0; // To avoid warnings below about use of undefined var.
// We'll use $WORK_DAY_START_HOUR and $WORK_DAY_END_HOUR
// as our starting and due times.
$cal_time = $WORK_DAY_START_HOUR . '0000';
$completed = '';
$due_hour = $WORK_DAY_END_HOUR;
$due_minute = $task_percent = 0;
$due_time = $WORK_DAY_END_HOUR . '0000';
$overall_percent = array ();
// Get category if passed in URL as cat_id.
$cat_id = getGetValue ( 'cat_id' );
if ( ! empty ( $cat_id ) ) {
$res = dbi_execute ( 'SELECT cat_name FROM webcal_categories
WHERE cat_id = ? AND ( cat_owner = ? OR cat_owner IS NULL )',
array ( $cat_id, $real_user ) );
if ( $res ) {
$row = dbi_fetch_row ( $res );
$catNames = $row[0];
$catList = $cat_id;
}
}
// Reminder settings.
$reminder_offset = ( $REMINDER_WITH_DATE == 'N' ? $REMINDER_OFFSET : 0 );
$rem_status = ( $REMINDER_DEFAULT == 'Y' );
$rem_use_date = ( $reminder_offset == 0 && $REMINDER_WITH_DATE == 'Y' );
if ( $eType == 'task' )
$hour = $WORK_DAY_START_HOUR;
// Anything other then testing for strlen breaks either hour=0 or no hour in URL.
if ( strlen ( $hour ) )
$time = $hour * 100;
else
$hour = $time = -1;
if ( ! empty ( $defusers ) ) {
$tmp_ar = explode ( ',', $defusers );
for ( $i = 0, $cnt = count ( $tmp_ar ); $i < $cnt; $i++ ) {
$participants[$tmp_ar[$i]] = 1;
}
}
//Add the logged in user if none other supplied
if ( count ( $participants ) == 0 )
$participants[$login] = 1;
if ( $readonly == 'N' ) {
// Is public allowed to add events?
if ( $login == '__public__' && $PUBLIC_ACCESS_CAN_ADD != 'Y' )
$can_edit = false;
else
$can_edit = true;
}
}
$dateYmd = date ( 'Ymd' );
$thisday = $day;
$thismonth = $month;
$thisyear = $year;
if ( empty ( $rpt_type ) || ! $rpt_type )
$rpt_type = 'none';
// Avoid error for using undefined vars.
if ( ! isset ( $hour ) && $hour != 0 )
$hour = -1;
else
if ( isset ( $hour ) && $hour >= 0 )
$cal_time = ( $hour * 10000 ) + ( isset ( $minute ) ? $minute * 100 : 0 );
if ( empty ( $access ) )
$access = '';
if ( empty ( $cal_url ) )
$cal_url = '';
if ( empty ( $description ) || $description == '<br />' )
$description = '';
if ( empty ( $duration ) )
$duration = 0;
if ( $duration == 1440 && $time == 0 ) {
$duration = $hour = $minute = '';
$allday = 'Y';
} else
$allday = 'N';
if ( empty ( $location ) )
$location = '';
if ( empty ( $name ) )
$name = '';
if ( empty ( $priority ) )
$priority = 5;
if ( empty ( $rpt_end_date ) )
$rpt_end_date = 0;
if ( empty ( $rpt_end_time ) )
$rpt_end_time = 0;
if ( empty ( $rpt_freq ) )
$rpt_freq = 0;
if ( empty ( $cal_date ) ) {
$cal_date = ( ! empty ( $date ) && $eType != 'task' ? $date : $dateYmd );
if ( empty ( $due_date ) )
$due_date = $dateYmd;
}
if ( empty ( $thisyear ) )
$thisdate = $dateYmd;
else {
$thisdate = sprintf ( "%04d%02d%02d", $thisyear,
empty ( $thismonth ) ? date ( 'm' ) : $thismonth,
empty ( $thisday ) ? date ( 'd' ) : $thisday );
}
if ( empty ( $cal_date ) || ! $cal_date )
$cal_date = $thisdate;
if ( empty ( $due_date ) || ! $due_date )
$due_date = $thisdate;
// Setup to display user's timezone difference if Admin or Assistant.
// Even though event is stored in GMT,
// an Assistant may need to know that the boss is in a different Timezone.
if ( $is_assistant || $is_admin && ! empty ( $user ) ) {
$tz_offset = date ( 'Z', date_to_epoch ( $cal_date . $cal_time ) );
$user_TIMEZONE = get_pref_setting ( $user, 'TIMEZONE' );
set_env ( 'TZ', $user_TIMEZONE );
$user_tz_offset = date ( 'Z', date_to_epoch ( $cal_date . $cal_time ) );
if ( $tz_offset != $user_tz_offset ) { // Different TZ_Offset.
user_load_variables ( $user, 'temp' );
$tz_diff = ( $user_tz_offset - $tz_offset ) / 3600;
$abs_diff = abs ( $tz_diff );
// translate ( 'is in a different timezone than you are. Currently' )
// translate ( 'hour ahead of you' ) translate ( 'hour behind you' )
// translate ( 'hours ahead of you' ) translate ( 'hours behind you' )
// translate ( 'XXX is in a different timezone (ahead)' )
// translate ( 'XXX is in a different timezone (behind)' )
// Line breaks in translates below are to bypass update_translation.pl.
$TZ_notice = str_replace ( 'XXX',
array ( $tempfullname,
// TODO show hh:mm instead of abs.
$abs_diff . ' ' . translate ( 'hour'
. ( $abs_diff == 1 ? '' : 's' ) ),
translate ( 'Time entered here is based on your Timezone.' ) ),
translate ( 'XXX is in a different timezone ('
. ( $tz_diff > 0 ? 'ahead)' : 'behind)' ) ) );
}
// Return to $login TIMEZONE.
set_env ( 'TZ', $TIMEZONE );
}
$eType_label = ' ( ' . translate ( $eType ) . ' )';
echo '
<h2>' . ( $id ? translate ( 'Edit Entry' ) : translate ( 'Add Entry' ) )
. $eType_label . ' <img src="images/help.gif" alt="' . translate ( 'Help' )
. '" class="help" onclick="window.open( \'help_edit_entry.php'
. ( empty ( $id ) ? '?add=1' : '' )
. '\', \'cal_help\', \'dependent,menubar,scrollbars,height=400,width=400,'
. 'innerHeight=420,outerWidth=420\' );" /></h2>';
if ( $can_edit ) {
$tabs_ar = array ( 'details', translate ( 'Details' ) );
if ( $DISABLE_PARTICIPANTS_FIELD != 'Y' ) {
$tabs_ar[] = 'participants';
$tabs_ar[] = translate ( 'Participants' );
}
if ( $DISABLE_REPEATING_FIELD != 'Y' ) {
$tabs_ar[] = 'pete';
$tabs_ar[] = translate ( 'Repeat' );
}
if ( $DISABLE_REMINDER_FIELD != 'Y' ) {
$tabs_ar[] = 'reminder';
$tabs_ar[] = translate ( 'Reminders' );
}
$tabs = '';
for ( $i = 0, $cnt = count ( $tabs_ar ); $i < $cnt; $i++ ) {
$tabs .= '
<span class="tab'
. ( $i > 0 ? 'bak' : 'for' )
. '" id="tab_' . $tabs_ar[$i]
. '"><a href="#tab' . $tabs_ar[$i] . '" onclick="return showTab( \''
. $tabs_ar[$i] . '\' )">' . $tabs_ar[++$i] . '</a></span>';
}
echo '
<form action="edit_entry_handler.php" method="post" name="editentryform" '
. 'id="editentryform">
<input type="hidden" name="eType" value="' . $eType . '" />'
. ( ! empty ( $id ) && ( empty ( $copy ) || $copy != '1' ) ? '
<input type="hidden" name="cal_id" value="' . $id . '" />' : '' )
/* We need an additional hidden input field. */ . '
<input type="hidden" name="entry_changed" value="" />'
// Are we overriding an entry from a repeating event...
. ( empty ( $override ) ? '' : '
<input type="hidden" name="override" value="1" />
<input type="hidden" name="override_date" value="' . $cal_date . '" />' )
// If assistant, need to remember boss = user.
. ( $is_assistant || $is_nonuser_admin || ! empty ( $user ) ? '
<input type="hidden" name="user" value="' . $user . '" />' : '' )
// If has cal_group_id was set, need to set parent = $parent.
. ( empty ( $parent ) ? '' : '
<input type="hidden" name="parent" value="' . $parent . '" />' ) . '
<!-- TABS -->' . ( $useTabs ? '
<div id="tabs">' . $tabs . '
</div>' : '' ) . '
<!-- TABS BODY -->' . ( $useTabs ? '
<div id="tabscontent">
<!-- DETAILS -->
<a name="tabdetails"></a>
<div id="tabscontent_details">' : '
<fieldset>
<legend>' . translate ( 'Details' ) . '</legend>' ) . '
<table border="0" summary="">
<tr>
<td style="width:14%;" class="tooltip" title="'
. tooltip ( 'brief-description-help' ) . '"><label for="entry_brief">'
. translate ( 'Brief Description' ) . ':</label></td>
<td colspan="2"><input type="text" name="name" id="entry_brief" '
. 'size="25" value="' . htmlspecialchars ( $name ) . '" /></td>
</tr>
<tr>
<td class="tooltip aligntop" title="'
. tooltip ( 'full-description-help' ) . '"><label for="entry_full">'
. translate ( 'Full Description' ) . ':</label></td>
<td><textarea name="description" id="entry_full" rows="'
. $textareasize . '" cols="50"' . '>' . htmlspecialchars ( $description )
. '</textarea></td>' . ( $use_fckeditor || $use_htmlarea ? '
</tr>
<tr>
<td colspan="2"' : '
<td' ) . ' class="aligntop">'
. ( ! empty ( $categories ) || $DISABLE_ACCESS_FIELD != 'Y' ||
( $DISABLE_PRIORITY_FIELD != 'Y' )
/* New table for extra fields. */ ? '
<table border="0" width="90%" summary="">' : '' )
. ( $DISABLE_ACCESS_FIELD != 'Y' ? '
<tr>
<td class="tooltip" title="' . tooltip ( 'access-help' )
. '"><label for="entry_access">' . translate ( 'Access' ) . ':</label></td>
<td width="80%">
<select name="access" id="entry_access">
<option value="P"' . ( $access == 'P' || !
strlen ( $access ) ? $selected : '' ) . '>' . translate ( 'Public' )
. '</option>
<option value="R"' . ( $access == 'R' ? $selected : '' )
. '>' . translate ( 'Private' ) . '</option>
<option value="C"' . ( $access == 'C' ? $selected : '' )
. '>' . translate ( 'Confidential' ) . '</option>
</select>
</td>
</tr>' : '' );
if ( $DISABLE_PRIORITY_FIELD != 'Y' ) {
echo '
<tr>
<td class="tooltip" title="' . tooltip ( 'priority-help' )
. '"><label for="entry_prio">' . translate ( 'Priority' )
. ': </label></td>
<td>
<select name="priority" id="entry_prio">';
$pri = array ( '',
translate ( 'High' ),
translate ( 'Medium' ),
translate ( 'Low' ) );
for ( $i = 1; $i <= 9; $i++ ) {
echo '
<option value="' . $i . '"'
. ( $priority == $i ? $selected : '' )
. '>' . $i . '-' . $pri[ceil ( $i / 3 )] . '</option>';
}
echo '
</select>
</td>
</tr>';
}
echo ( ! empty ( $categories ) && $CATEGORIES_ENABLED == 'Y' ? '
<tr>
<td class="tooltip" title="' . tooltip ( 'category-help' )
. '" valign="top">
<label for="entry_categories">' . translate ( 'Category' )
. ':<br /></label>
<input type="button" value="' . translate ( 'Edit' )
. '" onclick="editCats( event )" />
</td>
<td valign="top">
<input readonly="readonly" type="text" name="catnames" '
. 'id="entry_categories" value="' . $catNames
. '" size="30" onclick="editCats( event )"/>
<input type="hidden" name="cat_id" value="' . $catList
. '" />
</td>
</tr>' : '' )
. ( ! empty ( $categories ) || $DISABLE_ACCESS_FIELD != 'Y' ||
( $DISABLE_PRIORITY_FIELD != 'Y' ) ? '
</table>' : '' );
if ( $eType == 'task' ) { // Only for tasks.
$completed_visible = ( strlen ( $completed ) ? 'visible' : 'hidden' );
echo '<br />
<table border="0" summary="">
<tr id="completed">
<td class="tooltip" title="' . tooltip ( 'completed-help' )
. '"><label for="task_percent">' . translate ( 'Date Completed' )
. ': </label></td>
<td>' . date_selection ( 'completed_', $completed ) . '</td>
</tr>
<tr>
<td class="tooltip" title="' . tooltip ( 'percent-help' )
. '"><label for="task_percent">' . translate ( 'Percent Complete' )
. ': </label></td>
<td>
<select name="percent" id="task_percent" '
. 'onchange="completed_handler()">';
for ( $i = 0; $i < 101; $i += 10 ) {
echo '
<option value="' . "$i\" "
. ( $task_percent == $i ? $selected : '' )
. '>' . $i . '</option>';
}
echo '
</select>
</td>
</tr>';
if ( ! empty ( $overall_percent ) ) {
echo '
<tr>
<td colspan="2">
<table width="100%" border="0" cellpadding="2" '
. 'cellspacing="5" summary="">
<tr>
<td colspan="2">' . translate ( 'All Percentages' )
. '</td>
</tr>';
$others_complete = 'yes';
for ( $i = 0, $cnt = count ( $overall_percent ); $i < $cnt; $i++ ) {
user_load_variables ( $overall_percent[$i][0], 'percent' );
echo '
<tr>
<td>' . $percentfullname . '</td>
<td>' . $overall_percent[$i][1] . '</td>
</tr>';
if ( $overall_percent[$i][0] != $real_user &&
$overall_percent[$i][1] < 100 )
$others_complete = 'no';
}
echo '
</table>';
}
echo '
</td>
</tr>
</table>
<input type="hidden" name="others_complete" value="'
. $others_complete . '" />';
} //end tasks only
[code]<?php
/* $Id: edit_entry.php,v 1.203.2.9 2008/04/04 18:42:59 umcesrjones Exp $
*
* Description:
* Presents page to edit/add an event/task/journal
*
* Notes:
* A SysAdmin can enable HTML for event full descriptions. If one of the
* supported HTML edit widgets is also installed, users can use WYSIWYG editing.
* See the WebCalendar page at
* http://www.k5n.us/webcalendar.php?topic=Add-Ons
* for download and install instructions for these packages.
*/
include_once 'includes/init.php';
/* Generate HTML for a time selection for use in a form.
*
* @param string $prefix Prefix to use in front of form element names
* @param string $time Currently selected time in HHMMSS
* @param bool $trigger Add onchange event trigger that
* calls javascript function $prefix_timechanged ()
*
* @return string HTML for the selection box
*/
function time_selection ( $prefix, $time = '', $trigger = false ) {
global $checked, $ENTRY_SLOTS, $selected, $TIME_FORMAT, $WORK_DAY_START_HOUR;
$amsel = $pmsel = $ret = '';
$trigger_str = ( $trigger ? 'onchange="' . $prefix . 'timechanged() ' : '' );
if ( ! isset ( $time ) && $time != 0 ) {
$hour = $WORK_DAY_START_HOUR;
$minute = 0;
} else {
$hour = floor ( $time / 10000 );
$minute = ( ( $time / 100 ) % 100 ) % 60;
}
if ( $TIME_FORMAT == '12' ) {
$maxhour = 12;
if ( $hour < 12 || $hour == 24 )
$amsel = $checked;
else
$pmsel = $checked;
$hour %= 12;
if ( $hour == 0 )
$hour = 12;
} else {
$maxhour = 24;
$hour = sprintf ( "%02d", $hour );
}
$minute = sprintf ( "%02d", $minute );
$ret .= '
<select ' . 'name="' . $prefix . 'hour" id="' . $prefix . 'hour" '
. $trigger_str . '>';
for ( $i = 0; $i < $maxhour; $i++ ) {
$ihour = ( $TIME_FORMAT == '24' ? sprintf ( "%02d", $i ) : $i );
if ( $i == 0 && $TIME_FORMAT == '12' )
$ihour = 12;
$ret .= '
<option value="' . "$i\"" . ( $ihour == $hour ? $selected : '' )
. ">$ihour" . '</option>';
}
$ret .= '
</select>:
<select ' . 'name="' . $prefix . 'minute" id="' . $prefix
. 'minute" ' . $trigger_str . '>';
// We use $TIME_SLOTS to populate the minutes pulldown.
$found = false;
for ( $i = 0; $i < 60; ) {
$imin = sprintf ( "%02d", $i );
$isselected = '';
if ( $imin == $minute ) {
$found = true;
$isselected = $selected;
}
$ret .= '
<option value="' . "$i\"$isselected>$imin" . '</option>';
$i += ( 1440 / $ENTRY_SLOTS );
}
// We'll add an option with the exact time if not found above.
return $ret . ( $found ? '' : '
<option value="' . "$minute\" $selected>$minute" . '</option>' ) . '
</select>' . ( $TIME_FORMAT == '12' ? '
<label><input type="radio" name="' . $prefix . 'ampm" id="'
. $prefix . 'ampmA" value="0" ' . $amsel . ' /> ' . translate ( 'am' )
. '</label>
<label><input type="radio" name="' . $prefix . 'ampm" id="'
. $prefix . 'ampmP" value="12" ' . $pmsel . ' /> ' . translate ( 'pm' )
. '</label>' : '
<input type="hidden" name="' . $prefix . 'ampm" value="0" />' );
}
$daysStr = translate ( 'days' );
$hoursStr = translate ( 'hours' );
$minutStr = translate ( 'minutes' );
$saveStr = translate ( 'Save' );
load_user_categories ();
// Default for using tabs is enabled.
if ( empty ( $EVENT_EDIT_TABS ) )
$EVENT_EDIT_TABS = 'Y'; // default
$useTabs = ( $EVENT_EDIT_TABS == 'Y' );
// Make sure this is not a read-only calendar.
$can_edit = false;
$others_complete = 'yes';
$checked = ' checked="checked"';
$selected = ' selected="selected"';
// Public access can only add events, not edit.
if ( empty ( $login ) || ( $login == '__public__' && $id > 0 ) )
$id = 0;
$eType = getGetValue ( 'eType' );
if ( empty ( $eType ) )
$eType = 'event';
$copy = getValue ( 'copy', '[01]' );
$date = getValue ( 'date', '-?[0-9]+' );
$day = getValue ( 'day', '-?[0-9]+' );
$month = getValue ( 'month', '-?[0-9]+' );
$year = getValue ( 'year', '-?[0-9]+' );
if ( empty ( $date ) && empty ( $month ) ) {
if ( empty ( $year ) )
$year = date ( 'Y' );
$month = date ( 'm' );
if ( empty ( $day ) )
$day = date ( 'd' );
$date = sprintf ( "%04d%02d%02d", $year, $month, $day );
}
$BodyX = 'onload="onLoad();"';
$INC = array ( 'js/edit_entry.php/false/' . $user, 'js/visible.php' );
$textareasize = '15';
// Can we use HTMLArea or FCKEditor? (Relax! That's the authors initials.)
// Note: HTMLArea has been discontinued, so FCKEditor is preferred.
$use_fckeditor = $use_htmlarea = false;
if ( $ALLOW_HTML_DESCRIPTION == 'Y' ) {
// Allow HTML in description.
// If they have installed an HTML edit widget, make use of it.
if ( file_exists ( 'includes/FCKeditor-2.0/fckeditor.js' ) &&
file_exists ( 'includes/FCKeditor-2.0/fckconfig.js' ) ) {
$textareasize = '20';
$use_fckeditor = true;
} else
if ( file_exists ( 'includes/htmlarea/htmlarea.php' ) ) {
$BodyX = 'onload="onLoad();initEditor();';
$INC[] = 'htmlarea/core.php/true';
$INC[] = 'htmlarea/htmlarea.php/true';
$use_htmlarea = true;
}
}
$byday = $bymonth = $bymonthday = $bysetpos = $participants = array ();
$exceptions = $inclusions = $reminder = array ();
$byweekno = $byyearday = $catList = $catNames = $external_users = $rpt_count = '';
$create_by = $login;
//This is the default per RFC2445
//We could override it and use $byday_names[$WEEK_START]
$wkst = 'MO';
$real_user = ( ( ! empty ( $user ) && strlen ( $user ) ) &&
( $is_assistant || $is_admin ) ) ? $user : $login;
print_header ( $INC, '', $BodyX, false, false, false, true );
ob_start ();
if ( $readonly == 'Y' || $is_nonuser )
$can_edit = false;
else
if ( ! empty ( $id ) && $id > 0 ) {
// First see who has access to edit this entry.
if ( $is_admin )
$can_edit = true;
$res = dbi_execute ( 'SELECT cal_create_by, cal_date, cal_time, cal_mod_date,
cal_mod_time, cal_duration, cal_priority, cal_type, cal_access, cal_name,
cal_description, cal_group_id, cal_location, cal_due_date, cal_due_time,
cal_completed, cal_url FROM webcal_entry WHERE cal_id = ?', array ( $id ) );
if ( $res ) {
$row = dbi_fetch_row ( $res );
// If current user is creator of event, then they can edit.
if ( $row[0] == $login )
$can_edit = true;
$cal_date = ( ! empty ( $override ) && ! empty ( $date )
? $date // Leave $cal_date to what was set in URL with date=YYYYMMDD.
: $row[1] );
$create_by = $row[0];
if ( ( $user == $create_by ) && ( $is_assistant || $is_nonuser_admin ) )
$can_edit = true;
$cal_time = sprintf ( "%06d", $row[2] );
$due_date = $row[13];
$due_time = $row[14];
$calTS = date_to_epoch ( $cal_date . $cal_time );
// Don't adjust for All Day entries.
if ( $cal_time > 0 || ( $cal_time == 0 && $row[5] != 1440 ) ) {
$cal_date = date ( 'Ymd', $calTS );
$cal_time = date ( 'His', $calTS );
}
$hour = floor ( $cal_time / 10000 );
$minute = ( $cal_time / 100 ) % 100;
$dueTS = date_to_epoch ( $due_date . $due_time );
$due_date = date ( 'Ymd', $dueTS );
$due_time = date ( 'His', $dueTS );
$due_hour = floor ( $due_time / 10000 );
$due_minute = ( $due_time / 100 ) % 100;
$priority = $row[6];
$type = $row[7];
$access = $row[8];
$name = $row[9];
$description = $row[10];
$parent = $row[11];
$location = $row[12];
$completed = ( empty ( $row[15] ) ? date ( 'Ymd' ) : $row[15] );
$cal_url = $row[16];
// What kind of entry are we dealing with?
if ( strpos ( 'EM', $type ) !== false )
$eType = 'event';
elseif ( strpos ( 'JO', $type ) !== false )
$eType = 'journal';
elseif ( strpos ( 'NT', $type ) !== false )
$eType = 'task';
// Public access has no access to tasks.
// translate ( 'You are not authorized to edit this task' )
if ( $login == '__public__' && $eType == 'task' )
echo str_replace ( 'XXX', translate ( 'task' ),
translate ( 'You are not authorized to edit this XXX.' ) );
// Check UAC.
if ( access_is_enabled () )
$can_edit =
access_user_calendar ( 'edit', $create_by, $login, $type, $access );
$day = $cal_date % 100;
$month = ( $cal_date / 100 ) % 100;
$year = intval ( $cal_date / 10000 );
$time = $row[2];
if ( $time >= 0 )
$duration = $row[5];
else {
$duration = '';
$hour = -1;
}
// Check for repeating event info...
// but not if we're overriding a single entry of an already repeating event...
// confusing, eh?
if ( ! empty ( $override ) ) {
$rpt_end = 0;
$rpt_end_date = $cal_date;
$rpt_freq = 1;
$rpt_type = 'none';
} else {
$res = dbi_execute ( 'SELECT cal_id, cal_type, cal_end, cal_endtime,
cal_frequency, cal_byday, cal_bymonth, cal_bymonthday, cal_bysetpos,
cal_byweekno, cal_byyearday, cal_wkst, cal_count
FROM webcal_entry_repeats WHERE cal_id = ?', array ( $id ) );
if ( $res ) {
if ( $row = dbi_fetch_row ( $res ) ) {
$rpt_type = $row[1];
$rpt_end = ( $row[2] > 0 ? date_to_epoch ( $row[2] . $row[3] ) : 0 );
if ( empty ( $row[2] ) ) {
$rpt_end_date = $cal_date;
$rpt_end_time = $cal_time;
} else {
$rpt_endTS = date_to_epoch ( $row[2] . $row[3] );
$rpt_end_date = date ( 'Ymd', $rpt_endTS );
$rpt_end_time = date ( 'His', $rpt_endTS );
}
$rpt_freq = $row[4];
if ( ! empty ( $row[5] ) )
$byday = explode ( ',', $row[5] );
$bydayStr = $row[5];
if ( ! empty ( $row[6] ) )
$bymonth = explode ( ',', $row[6] );
if ( ! empty ( $row[7] ) )
$bymonthday = explode ( ',', $row[7] );
$bymonthdayStr = $row[7];
if ( ! empty ( $row[8] ) )
$bysetpos = explode ( ',', $row[8] );
$bysetposStr = $row[8];
$byweekno = $row[9];
$byyearday = $row[10];
$wkst = $row[11];
$rpt_count = $row[12];
// Check to see if Weekends Only is applicable.
$weekdays_only = ( $rpt_type == 'daily' && $byday == 'MO,TU,WE,TH,FR' );
}
dbi_free_result ( $res );
}
}
$res = dbi_execute ( 'SELECT cal_login, cal_percent, cal_status
FROM webcal_entry_user WHERE cal_id = ?', array ( $id ) );
if ( $res ) {
while ( $row = dbi_fetch_row ( $res ) ) {
$overall_percent[] = $row;
if ( $login == $row[0] || ( $is_admin && $user == $row[0] ) ) {
$task_percent = $row[1];
$task_status = $row[2];
}
}
dbi_free_result ( $res );
}
// Determine if Expert mode needs to be set.
$expert_mode = ( count ( $byday ) || count ( $bymonth ) ||
count ( $bymonthday ) || count ( $bysetpos ) ||
isset ( $byweekno ) || isset ( $byyearday ) || isset ( $rpt_count ) );
// Get Repeat Exceptions.
$res = dbi_execute ( 'SELECT cal_date, cal_exdate
FROM webcal_entry_repeats_not WHERE cal_id = ?', array ( $id ) );
if ( $res ) {
while ( $row = dbi_fetch_row ( $res ) ) {
if ( $row[1] == 1 )
$exceptions[] = $row[0];
else
$inclusions[] = $row[0];
}
dbi_free_result ( $res );
}
}
if ( $CATEGORIES_ENABLED == 'Y' ) {
$catById = get_categories_by_id ( $id, $real_user, true );
if ( ! empty ( $catById ) ) {
$catNames = implode ( ', ', $catById );
$catList = implode ( ',', array_keys ( $catById ) );
}
} //end CATEGORIES_ENABLED test
// Get reminders.
$reminder = getReminders ( $id );
$reminder_offset = ( empty ( $reminder ) ? 0 : $reminder['offset'] );
$rem_status = ( count ( $reminder ));
$rem_use_date = ( ! empty ( $reminder['date'] ) );
// Get participants.
$res = dbi_execute ( 'SELECT cal_login, cal_status FROM webcal_entry_user WHERE cal_id = ?
AND cal_status IN ( \'A\', \'W\' )', array ( $id ) );
if ( $res ) {
while ( $row = dbi_fetch_row ( $res ) ) {
$participants[$row[0]] = 1;
$selectedStatus[$row[0]] = $row[1];
}
dbi_free_result ( $res );
}
// Not allowed for tasks or journals.
if ( $eType == 'event' && !
empty ( $ALLOW_EXTERNAL_USERS ) && $ALLOW_EXTERNAL_USERS == 'Y' )
$external_users = event_get_external_users ( $id );
} else {
// ########## New entry ################
$id = 0; // To avoid warnings below about use of undefined var.
// We'll use $WORK_DAY_START_HOUR and $WORK_DAY_END_HOUR
// as our starting and due times.
$cal_time = $WORK_DAY_START_HOUR . '0000';
$completed = '';
$due_hour = $WORK_DAY_END_HOUR;
$due_minute = $task_percent = 0;
$due_time = $WORK_DAY_END_HOUR . '0000';
$overall_percent = array ();
// Get category if passed in URL as cat_id.
$cat_id = getGetValue ( 'cat_id' );
if ( ! empty ( $cat_id ) ) {
$res = dbi_execute ( 'SELECT cat_name FROM webcal_categories
WHERE cat_id = ? AND ( cat_owner = ? OR cat_owner IS NULL )',
array ( $cat_id, $real_user ) );
if ( $res ) {
$row = dbi_fetch_row ( $res );
$catNames = $row[0];
$catList = $cat_id;
}
}
// Reminder settings.
$reminder_offset = ( $REMINDER_WITH_DATE == 'N' ? $REMINDER_OFFSET : 0 );
$rem_status = ( $REMINDER_DEFAULT == 'Y' );
$rem_use_date = ( $reminder_offset == 0 && $REMINDER_WITH_DATE == 'Y' );
if ( $eType == 'task' )
$hour = $WORK_DAY_START_HOUR;
// Anything other then testing for strlen breaks either hour=0 or no hour in URL.
if ( strlen ( $hour ) )
$time = $hour * 100;
else
$hour = $time = -1;
if ( ! empty ( $defusers ) ) {
$tmp_ar = explode ( ',', $defusers );
for ( $i = 0, $cnt = count ( $tmp_ar ); $i < $cnt; $i++ ) {
$participants[$tmp_ar[$i]] = 1;
}
}
//Add the logged in user if none other supplied
if ( count ( $participants ) == 0 )
$participants[$login] = 1;
if ( $readonly == 'N' ) {
// Is public allowed to add events?
if ( $login == '__public__' && $PUBLIC_ACCESS_CAN_ADD != 'Y' )
$can_edit = false;
else
$can_edit = true;
}
}
$dateYmd = date ( 'Ymd' );
$thisday = $day;
$thismonth = $month;
$thisyear = $year;
if ( empty ( $rpt_type ) || ! $rpt_type )
$rpt_type = 'none';
// Avoid error for using undefined vars.
if ( ! isset ( $hour ) && $hour != 0 )
$hour = -1;
else
if ( isset ( $hour ) && $hour >= 0 )
$cal_time = ( $hour * 10000 ) + ( isset ( $minute ) ? $minute * 100 : 0 );
if ( empty ( $access ) )
$access = '';
if ( empty ( $cal_url ) )
$cal_url = '';
if ( empty ( $description ) || $description == '<br />' )
$description = '';
if ( empty ( $duration ) )
$duration = 0;
if ( $duration == 1440 && $time == 0 ) {
$duration = $hour = $minute = '';
$allday = 'Y';
} else
$allday = 'N';
if ( empty ( $location ) )
$location = '';
if ( empty ( $name ) )
$name = '';
if ( empty ( $priority ) )
$priority = 5;
if ( empty ( $rpt_end_date ) )
$rpt_end_date = 0;
if ( empty ( $rpt_end_time ) )
$rpt_end_time = 0;
if ( empty ( $rpt_freq ) )
$rpt_freq = 0;
if ( empty ( $cal_date ) ) {
$cal_date = ( ! empty ( $date ) && $eType != 'task' ? $date : $dateYmd );
if ( empty ( $due_date ) )
$due_date = $dateYmd;
}
if ( empty ( $thisyear ) )
$thisdate = $dateYmd;
else {
$thisdate = sprintf ( "%04d%02d%02d", $thisyear,
empty ( $thismonth ) ? date ( 'm' ) : $thismonth,
empty ( $thisday ) ? date ( 'd' ) : $thisday );
}
if ( empty ( $cal_date ) || ! $cal_date )
$cal_date = $thisdate;
if ( empty ( $due_date ) || ! $due_date )
$due_date = $thisdate;
// Setup to display user's timezone difference if Admin or Assistant.
// Even though event is stored in GMT,
// an Assistant may need to know that the boss is in a different Timezone.
if ( $is_assistant || $is_admin && ! empty ( $user ) ) {
$tz_offset = date ( 'Z', date_to_epoch ( $cal_date . $cal_time ) );
$user_TIMEZONE = get_pref_setting ( $user, 'TIMEZONE' );
set_env ( 'TZ', $user_TIMEZONE );
$user_tz_offset = date ( 'Z', date_to_epoch ( $cal_date . $cal_time ) );
if ( $tz_offset != $user_tz_offset ) { // Different TZ_Offset.
user_load_variables ( $user, 'temp' );
$tz_diff = ( $user_tz_offset - $tz_offset ) / 3600;
$abs_diff = abs ( $tz_diff );
// translate ( 'is in a different timezone than you are. Currently' )
// translate ( 'hour ahead of you' ) translate ( 'hour behind you' )
// translate ( 'hours ahead of you' ) translate ( 'hours behind you' )
// translate ( 'XXX is in a different timezone (ahead)' )
// translate ( 'XXX is in a different timezone (behind)' )
// Line breaks in translates below are to bypass update_translation.pl.
$TZ_notice = str_replace ( 'XXX',
array ( $tempfullname,
// TODO show hh:mm instead of abs.
$abs_diff . ' ' . translate ( 'hour'
. ( $abs_diff == 1 ? '' : 's' ) ),
translate ( 'Time entered here is based on your Timezone.' ) ),
translate ( 'XXX is in a different timezone ('
. ( $tz_diff > 0 ? 'ahead)' : 'behind)' ) ) );
}
// Return to $login TIMEZONE.
set_env ( 'TZ', $TIMEZONE );
}
$eType_label = ' ( ' . translate ( $eType ) . ' )';
echo '
<h2>' . ( $id ? translate ( 'Edit Entry' ) : translate ( 'Add Entry' ) )
. $eType_label . ' <img src="images/help.gif" alt="' . translate ( 'Help' )
. '" class="help" onclick="window.open( \'help_edit_entry.php'
. ( empty ( $id ) ? '?add=1' : '' )
. '\', \'cal_help\', \'dependent,menubar,scrollbars,height=400,width=400,'
. 'innerHeight=420,outerWidth=420\' );" /></h2>';
if ( $can_edit ) {
$tabs_ar = array ( 'details', translate ( 'Details' ) );
if ( $DISABLE_PARTICIPANTS_FIELD != 'Y' ) {
$tabs_ar[] = 'participants';
$tabs_ar[] = translate ( 'Participants' );
}
if ( $DISABLE_REPEATING_FIELD != 'Y' ) {
$tabs_ar[] = 'pete';
$tabs_ar[] = translate ( 'Repeat' );
}
if ( $DISABLE_REMINDER_FIELD != 'Y' ) {
$tabs_ar[] = 'reminder';
$tabs_ar[] = translate ( 'Reminders' );
}
$tabs = '';
for ( $i = 0, $cnt = count ( $tabs_ar ); $i < $cnt; $i++ ) {
$tabs .= '
<span class="tab'
. ( $i > 0 ? 'bak' : 'for' )
. '" id="tab_' . $tabs_ar[$i]
. '"><a href="#tab' . $tabs_ar[$i] . '" onclick="return showTab( \''
. $tabs_ar[$i] . '\' )">' . $tabs_ar[++$i] . '</a></span>';
}
echo '
<form action="edit_entry_handler.php" method="post" name="editentryform" '
. 'id="editentryform">
<input type="hidden" name="eType" value="' . $eType . '" />'
. ( ! empty ( $id ) && ( empty ( $copy ) || $copy != '1' ) ? '
<input type="hidden" name="cal_id" value="' . $id . '" />' : '' )
/* We need an additional hidden input field. */ . '
<input type="hidden" name="entry_changed" value="" />'
// Are we overriding an entry from a repeating event...
. ( empty ( $override ) ? '' : '
<input type="hidden" name="override" value="1" />
<input type="hidden" name="override_date" value="' . $cal_date . '" />' )
// If assistant, need to remember boss = user.
. ( $is_assistant || $is_nonuser_admin || ! empty ( $user ) ? '
<input type="hidden" name="user" value="' . $user . '" />' : '' )
// If has cal_group_id was set, need to set parent = $parent.
. ( empty ( $parent ) ? '' : '
<input type="hidden" name="parent" value="' . $parent . '" />' ) . '
<!-- TABS -->' . ( $useTabs ? '
<div id="tabs">' . $tabs . '
</div>' : '' ) . '
<!-- TABS BODY -->' . ( $useTabs ? '
<div id="tabscontent">
<!-- DETAILS -->
<a name="tabdetails"></a>
<div id="tabscontent_details">' : '
<fieldset>
<legend>' . translate ( 'Details' ) . '</legend>' ) . '
<table border="0" summary="">
<tr>
<td style="width:14%;" class="tooltip" title="'
. tooltip ( 'brief-description-help' ) . '"><label for="entry_brief">'
. translate ( 'Brief Description' ) . ':</label></td>
<td colspan="2"><input type="text" name="name" id="entry_brief" '
. 'size="25" value="' . htmlspecialchars ( $name ) . '" /></td>
</tr>
<tr>
<td class="tooltip aligntop" title="'
. tooltip ( 'full-description-help' ) . '"><label for="entry_full">'
. translate ( 'Full Description' ) . ':</label></td>
<td><textarea name="description" id="entry_full" rows="'
. $textareasize . '" cols="50"' . '>' . htmlspecialchars ( $description )
. '</textarea></td>' . ( $use_fckeditor || $use_htmlarea ? '
</tr>
<tr>
<td colspan="2"' : '
<td' ) . ' class="aligntop">'
. ( ! empty ( $categories ) || $DISABLE_ACCESS_FIELD != 'Y' ||
( $DISABLE_PRIORITY_FIELD != 'Y' )
/* New table for extra fields. */ ? '
<table border="0" width="90%" summary="">' : '' )
. ( $DISABLE_ACCESS_FIELD != 'Y' ? '
<tr>
<td class="tooltip" title="' . tooltip ( 'access-help' )
. '"><label for="entry_access">' . translate ( 'Access' ) . ':</label></td>
<td width="80%">
<select name="access" id="entry_access">
<option value="P"' . ( $access == 'P' || !
strlen ( $access ) ? $selected : '' ) . '>' . translate ( 'Public' )
. '</option>
<option value="R"' . ( $access == 'R' ? $selected : '' )
. '>' . translate ( 'Private' ) . '</option>
<option value="C"' . ( $access == 'C' ? $selected : '' )
. '>' . translate ( 'Confidential' ) . '</option>
</select>
</td>
</tr>' : '' );
if ( $DISABLE_PRIORITY_FIELD != 'Y' ) {
echo '
<tr>
<td class="tooltip" title="' . tooltip ( 'priority-help' )
. '"><label for="entry_prio">' . translate ( 'Priority' )
. ': </label></td>
<td>
<select name="priority" id="entry_prio">';
$pri = array ( '',
translate ( 'High' ),
translate ( 'Medium' ),
translate ( 'Low' ) );
for ( $i = 1; $i <= 9; $i++ ) {
echo '
<option value="' . $i . '"'
. ( $priority == $i ? $selected : '' )
. '>' . $i . '-' . $pri[ceil ( $i / 3 )] . '</option>';
}
echo '
</select>
</td>
</tr>';
}
echo ( ! empty ( $categories ) && $CATEGORIES_ENABLED == 'Y' ? '
<tr>
<td class="tooltip" title="' . tooltip ( 'category-help' )
. '" valign="top">
<label for="entry_categories">' . translate ( 'Category' )
. ':<br /></label>
<input type="button" value="' . translate ( 'Edit' )
. '" onclick="editCats( event )" />
</td>
<td valign="top">
<input readonly="readonly" type="text" name="catnames" '
. 'id="entry_categories" value="' . $catNames
. '" size="30" onclick="editCats( event )"/>
<input type="hidden" name="cat_id" value="' . $catList
. '" />
</td>
</tr>' : '' )
. ( ! empty ( $categories ) || $DISABLE_ACCESS_FIELD != 'Y' ||
( $DISABLE_PRIORITY_FIELD != 'Y' ) ? '
</table>' : '' );
if ( $eType == 'task' ) { // Only for tasks.
$completed_visible = ( strlen ( $completed ) ? 'visible' : 'hidden' );
echo '<br />
<table border="0" summary="">
<tr id="completed">
<td class="tooltip" title="' . tooltip ( 'completed-help' )
. '"><label for="task_percent">' . translate ( 'Date Completed' )
. ': </label></td>
<td>' . date_selection ( 'completed_', $completed ) . '</td>
</tr>
<tr>
<td class="tooltip" title="' . tooltip ( 'percent-help' )
. '"><label for="task_percent">' . translate ( 'Percent Complete' )
. ': </label></td>
<td>
<select name="percent" id="task_percent" '
. 'onchange="completed_handler()">';
for ( $i = 0; $i < 101; $i += 10 ) {
echo '
<option value="' . "$i\" "
. ( $task_percent == $i ? $selected : '' )
. '>' . $i . '</option>';
}
echo '
</select>
</td>
</tr>';
if ( ! empty ( $overall_percent ) ) {
echo '
<tr>
<td colspan="2">
<table width="100%" border="0" cellpadding="2" '
. 'cellspacing="5" summary="">
<tr>
<td colspan="2">' . translate ( 'All Percentages' )
. '</td>
</tr>';
$others_complete = 'yes';
for ( $i = 0, $cnt = count ( $overall_percent ); $i < $cnt; $i++ ) {
user_load_variables ( $overall_percent[$i][0], 'percent' );
echo '
<tr>
<td>' . $percentfullname . '</td>
<td>' . $overall_percent[$i][1] . '</td>
</tr>';
if ( $overall_percent[$i][0] != $real_user &&
$overall_percent[$i][1] < 100 )
$others_complete = 'no';
}
echo '
</table>';
}
echo '
</td>
</tr>
</table>
<input type="hidden" name="others_complete" value="'
. $others_complete . '" />';
} //end tasks only
[/code]