diff --git a/ChangeLog b/ChangeLog index 0fa8a6fbe..085c1fa0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ Version 1.1.1 (?? ??? 2006) + - Created commom error function to hopefully cleanup the code - Fixed bug 1554383: Times next to events during import is wrong - Fixed bug 1555860: SQL Error on import - Changed translate.php to ignore /install/ files if unneeded diff --git a/access.php b/access.php index e8356d078..9e0240eef 100644 --- a/access.php +++ b/access.php @@ -26,7 +26,7 @@ $ALLOW_VIEW_OTHER == 'Y' ? true : false ); if ( ! access_is_enabled () ) { - etranslate ( 'You are not authorized' ); + echo print_not_auth (); exit; } diff --git a/activity_log.php b/activity_log.php index e8625df41..26652dff4 100644 --- a/activity_log.php +++ b/activity_log.php @@ -20,7 +20,7 @@ if ( ! $is_admin || ( access_is_enabled () && ! access_can_access_function ( ACCESS_ACTIVITY_LOG ) ) ) { - die_miserable_death ( translate ( 'You are not authorized' ) ); + die_miserable_death ( print_not_auth () ); } print_header(); diff --git a/admin.php b/admin.php index 549ec8ae2..ef9333139 100644 --- a/admin.php +++ b/admin.php @@ -59,7 +59,7 @@ function save_pref( $prefs, $src) { $currenttab = ''; if ( ! $is_admin ) { - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); } if ( ! empty ( $_POST ) && empty ( $error )) { diff --git a/approve_entry.php b/approve_entry.php index d69626359..63d5e790c 100644 --- a/approve_entry.php +++ b/approve_entry.php @@ -8,7 +8,7 @@ $error = ''; if ( $readonly == 'Y' ) { - $error = translate( 'You are not authorized' ); + $error = print_not_auth (); } diff --git a/availability.php b/availability.php index 3383b8f44..86c03c0d8 100644 --- a/availability.php +++ b/availability.php @@ -26,14 +26,15 @@ // input args in URL // users: list of comma-separated users +$programStr = translate ( 'Program Error' ) . ': '; if ( empty ( $users ) ) { - echo 'Program Error: No users specified!'; exit; + echo $programStr . translate ( 'No users specified!' ); exit; } else if ( empty ( $year ) ) { - echo 'Program Error: No year specified!'; exit; + echo $programStr . translate ( 'No year specified!' ); exit; } else if ( empty ( $month ) ) { - echo 'Program Error: No month specified!'; exit; + echo $programStr . translate ( 'No month specified!' ); exit; } else if ( empty ( $day ) ) { - echo 'Program Error: No day specified!'; exit; + echo $programStr . translate ( 'No day specified!' ); exit; } $parent_form = getGetValue ('form'); diff --git a/category.php b/category.php index 8c6a5fb3b..031aad3c6 100644 --- a/category.php +++ b/category.php @@ -24,7 +24,7 @@ if ( $row[0] != $id ) $error = translate( 'Invalid entry id' ) . ': ' . $id; else if ( $row[1] != $login && ! $is_admin ) - $error = translate ( 'You are not authorized' ) . '.'; + $error = print_not_auth () . '.'; } dbi_free_result ( $res ); } else { @@ -122,6 +122,6 @@ } if ( ! empty ( $error ) ) { - echo "" . translate ( 'Error' ) . ':' . $error; + echo print_error ( $error ); } echo print_trailer(); ?> diff --git a/category_handler.php b/category_handler.php index 03f6fd4b9..30fa16ac7 100644 --- a/category_handler.php +++ b/category_handler.php @@ -42,7 +42,7 @@ function renameIcon ( $id ) { } if ( ! $is_my_event ) - $error = translate ( 'You are not authorized' ) . '.'; + $error = print_not_auth () . '.'; $delete = getPostValue ( 'delete' ); if ( empty ( $error ) && ! empty ( $delete ) ) { diff --git a/del_entry.php b/del_entry.php index 25e645ffe..2a4119694 100644 --- a/del_entry.php +++ b/del_entry.php @@ -81,7 +81,7 @@ } if ( ! $can_edit ) { - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); } // Is this a repeating event? @@ -259,7 +259,7 @@ $del_user = $user; } else { // Error: user cannot delete from other user's calendar - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); } } if ( empty ( $error ) ) { diff --git a/del_layer.php b/del_layer.php index 22142ab45..410516fa2 100644 --- a/del_layer.php +++ b/del_layer.php @@ -6,7 +6,7 @@ if ( $ALLOW_VIEW_OTHER != 'Y' || empty ( $id )) { print_header (); - etranslate( 'You are not authorized' ); + echo print_not_auth (); echo print_trailer (); exit; } diff --git a/doc.php b/doc.php index c8a1258c9..664242e23 100644 --- a/doc.php +++ b/doc.php @@ -179,7 +179,7 @@ } } if ( empty ( $error ) && ! $can_view ) { - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); } } diff --git a/docadd.php b/docadd.php index 139fa1b00..0ac58d5c1 100644 --- a/docadd.php +++ b/docadd.php @@ -77,14 +77,14 @@ if ( $type == 'A' ) { if ( empty ( $ALLOW_ATTACH ) || $ALLOW_ATTACH != 'Y' ) - $error = translate( 'You are not authorized' ); + $error = print_not_auth (); else if ( empty ( $error ) && $ALLOW_ATTACH_PART == 'Y' && $is_my_event ) $can_add = true; else if ( $ALLOW_ATTACH_ANY == 'Y' ) $can_add = true; } else if ( $type == 'C' ) { if ( empty ( $ALLOW_COMMENTS ) || $ALLOW_COMMENTS != 'Y' ) - $error = translate( 'You are not authorized' ); + $error = print_not_auth (); else if ( empty ( $error ) && $ALLOW_COMMENTS_PART == 'Y' && $is_my_event ) $can_add = true; else if ( $ALLOW_COMMENTS_ANY == 'Y' ) @@ -96,11 +96,11 @@ } if ( ! $can_add ) - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); if ( ! empty ( $error ) ) { print_header (); - echo '

' . translate( 'Error' ) . '

' . $error; + echo print_error ( $error ); echo print_trailer (); exit; } @@ -197,7 +197,7 @@ if ( ! empty ( $error ) ) { print_header (); - echo '

' . translate( 'Error' ) . '

' . $error; + echo print_error ( $error ); echo print_trailer (); exit; } diff --git a/docdel.php b/docdel.php index 60a486c4e..2925786dd 100644 --- a/docdel.php +++ b/docdel.php @@ -69,7 +69,7 @@ } if ( empty ( $error ) && ! $can_delete ) { - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); } if ( empty ( $error ) && $can_delete ) { @@ -92,8 +92,9 @@ // Some kind of error... print_header (); -echo '

' . translate ( 'Error' ) . '

' . $error; -echo print_trailer (); ?> +echo print_error ( $error ); +echo print_trailer (); +?> diff --git a/edit_entry_handler.php b/edit_entry_handler.php index 94ac8180b..67b47e647 100644 --- a/edit_entry_handler.php +++ b/edit_entry_handler.php @@ -197,7 +197,7 @@ } if ( ! $can_edit && empty ( $error ) ) { - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); } // If display of participants is disabled, set the participant list diff --git a/edit_layer.php b/edit_layer.php index 3e833c53d..2e3b0da8e 100644 --- a/edit_layer.php +++ b/edit_layer.php @@ -4,7 +4,7 @@ if ( $ALLOW_VIEW_OTHER != 'Y' ) { print_header (); - etranslate( 'You are not authorized' ); + echo print_not_auth (); echo print_trailer (); exit; } diff --git a/edit_layer_handler.php b/edit_layer_handler.php index 5b23c32da..f73da8cf8 100644 --- a/edit_layer_handler.php +++ b/edit_layer_handler.php @@ -5,7 +5,7 @@ $error = ''; if ( $ALLOW_VIEW_OTHER != 'Y' ) { - $error = translate( 'You are not authorized' ); + $error = print_not_auth (); } if ( empty ( $dups ) ) diff --git a/edit_nonusers.php b/edit_nonusers.php index 5ae90a436..4c63c1a25 100644 --- a/edit_nonusers.php +++ b/edit_nonusers.php @@ -2,16 +2,15 @@ /* $Id$ */ include_once 'includes/init.php'; $INC = array('js/edit_nonuser.php/false'); -print_header( $INC, '', '', true ); +print_header( $INC, '', '', true, '', true, false ); if ( ! $is_admin ) { - echo '

' . translate( 'Error' ) . "

\n" . - translate( 'You are not authorized' ) . ".\n"; + echo print_not_auth ( true ); echo "\n"; exit; } if ( ! $NONUSER_PREFIX ) { - echo '

' . translate( 'Error' ) . "

\n" . + echo print_error_header () . translate( 'NONUSER_PREFIX not set' ) . ".\n"; echo "\n"; exit; diff --git a/edit_nonusers_handler.php b/edit_nonusers_handler.php index 441017985..41d395183 100644 --- a/edit_nonusers_handler.php +++ b/edit_nonusers_handler.php @@ -4,8 +4,7 @@ load_user_layers (); if ( ! $is_admin ) { - echo '

' . translate( 'Error' ) . - '

' . translate( 'You are not authorized' ) . ".\n"; + echo print_not_auth ( true ); echo "\n"; exit; } diff --git a/edit_remotes.php b/edit_remotes.php index a94e5bbd3..6bc9badb1 100644 --- a/edit_remotes.php +++ b/edit_remotes.php @@ -29,11 +29,11 @@ if ($REMOTES_ENABLED != 'Y' || ( access_is_enabled () && ! access_can_access_function ( ACCESS_IMPORT ) ) ) { - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); } if ( $error ) { - echo '

' . translate( 'Error' ) . "

\n" . $error . ".\n"; + echo print_error ( $error ); echo "\n"; exit; } diff --git a/edit_remotes_handler.php b/edit_remotes_handler.php index 529ffc77e..1a86dacb2 100644 --- a/edit_remotes_handler.php +++ b/edit_remotes_handler.php @@ -35,6 +35,7 @@ $data = parse_hcal( $result, $type ); } print_header( '','','',true,false,true); + $errorStr = "

\n" . translate( 'Error' ) . ': '; if ( count ($data) && empty ($errormsg) ) { //delete existing events delete_events ( $nid ); @@ -52,9 +53,9 @@ echo '

' . translate( 'Create a new layer to view this calendar' ) . ".

\n"; } elseif (! empty ( $errormsg ) ) { echo translate ( 'Errors' ) . ": $error_num

\n"; - echo "

\n" . translate( 'Error' ) . ": $errormsg
\n"; + echo $errorStr$errormsg . "
\n"; } else { - echo "

\n" . translate( 'Error' ) . ': ' . + echo $errorStr . translate( 'There was an error parsing the import file or no events were returned' ) . ".
\n"; } diff --git a/edit_report.php b/edit_report.php index 981f1e2e2..ecd78bb54 100644 --- a/edit_report.php +++ b/edit_report.php @@ -34,7 +34,7 @@ $error = ''; if ( empty ( $REPORTS_ENABLED ) || $REPORTS_ENABLED != 'Y' ) { - $error = translate ( 'You are not authorized' ) . '.'; + $error = print_not_auth () . '.'; } if ( $is_admin && ! empty ( $public ) && $PUBLIC_ACCESS == 'Y' ) { @@ -61,7 +61,7 @@ } if ( $login == '__public__' ) { - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); } $charset = ( ! empty ( $LANGUAGE )?translate( 'charset' ): 'iso-8859-1' ); @@ -152,12 +152,12 @@ } } if ( ! $user_is_in_list && $report_login != $login && ! $is_admin ) { - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); } } if ( ! $is_admin && $login != $report_login ) { // If not admin, only creator can edit/delete the event - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); } // If we are editing a public user report we need to set $updating_public diff --git a/edit_report_handler.php b/edit_report_handler.php index e6b255597..cd8f43212 100644 --- a/edit_report_handler.php +++ b/edit_report_handler.php @@ -41,7 +41,7 @@ $report_id = getIntValue ( 'report_id', true ); if ( empty ( $REPORTS_ENABLED ) || $REPORTS_ENABLED != 'Y' ) { - $error = translate ( 'You are not authorized' ) . '.'; + $error = print_not_auth () . '.'; } $updating_public = false; @@ -67,7 +67,7 @@ if ( $res ) { if ( $row = dbi_fetch_row ( $res ) ) { if ( $row[0] != $login ) { - $error = translate( 'You are not authorized' ); + $error = print_not_auth (); } } else { $error = 'No such report id'; diff --git a/edit_template.php b/edit_template.php index e7f270ee2..0390eb456 100644 --- a/edit_template.php +++ b/edit_template.php @@ -139,8 +139,7 @@ ' . translate( 'Error' ) . "\n" . - $error . "\n"; + echo print_error ( $error ); } else { ?>
diff --git a/edit_user.php b/edit_user.php index 6b66c91cf..db755c82b 100644 --- a/edit_user.php +++ b/edit_user.php @@ -17,25 +17,25 @@ if ( ! $is_admin ) { // must be admin... if ( ! access_can_access_function ( ACCESS_USER_MANAGEMENT ) ) { - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); } } if ( ! $admin_can_add_user ) { // if adding users is not allowed... - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); } } else { // User is editing their account info if ( ! access_can_access_function ( ACCESS_ACCOUNT_INFO ) ) - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); } $disableCustom = true; $INC = array('js/edit_user.php/false'); -print_header ( $INC, '', '', $disableCustom ); +print_header ( $INC, '', '', $disableCustom, '', true, false ); if ( ! empty ( $error ) ) { - echo '

' . translate ( 'Error' ) . "

\n

" . $error . "

\n"; + echo print_error ( $error ); } else { ?> diff --git a/edit_user_handler.php b/edit_user_handler.php index 032ceded9..7c6efec27 100644 --- a/edit_user_handler.php +++ b/edit_user_handler.php @@ -13,7 +13,7 @@ if ( ! $is_admin ) $user = $login; -$notAuthStr = translate( 'You are not authorized' ) . '.'; +$notAuthStr = print_not_auth () . '.'; $deleteStr = translate( 'Deleting users not supported' ) . '.'; $notIdenticalStr = translate( 'The passwords were not identical' ) . '.'; $noPasswordStr = translate( 'You have not entered a password' ) . '.'; diff --git a/export_handler.php b/export_handler.php index edce36ab0..81e4a97b8 100644 --- a/export_handler.php +++ b/export_handler.php @@ -253,9 +253,9 @@ function transmit_header ( $mime, $file ) { //exit; print_header(); - - echo '

' . translate( 'Export' ) . ' ' .translate( 'Error' ) . "

\n" - . '' . translate( 'Error' ) . ': ' + $errorStr = translate( 'Error' ); + echo '

' . translate( 'Export' ) . ' ' . $errorStr . "

\n" + . '' . $errorStr . ': ' . translate( 'export format not defined or incorrect' ) . '.' . "
\n"; echo print_trailer (); diff --git a/freebusy.php b/freebusy.php index dffd6bd7b..a1e049367 100644 --- a/freebusy.php +++ b/freebusy.php @@ -95,7 +95,7 @@ if ( empty ( $FREEBUSY_ENABLED ) || $FREEBUSY_ENABLED != 'Y' ) { header ( 'Content-Type: text/plain' ); echo "user=$user\n"; - etranslate( 'You are not authorized' ); + echo print_not_auth (); exit; } diff --git a/group_edit_handler.php b/group_edit_handler.php index a8a335d05..852adaf7c 100644 --- a/group_edit_handler.php +++ b/group_edit_handler.php @@ -3,7 +3,7 @@ include_once 'includes/init.php'; if ( ! $is_admin ) { - $error = 'You are not authorized'; + $error = print_not_auth (); } else { $delete = getPostValue ( 'delete' ); if ( ! empty ( $delete ) ) { diff --git a/help_admin.php b/help_admin.php index 7817b0ee9..9080d43d7 100644 --- a/help_admin.php +++ b/help_admin.php @@ -18,6 +18,10 @@ : +
+ : + +
: diff --git a/help_edit_entry.php b/help_edit_entry.php index ab50ed72a..691978039 100644 --- a/help_edit_entry.php +++ b/help_edit_entry.php @@ -8,74 +8,64 @@

:

- - - - - +

+ : +

+

+ : +

+

+ : +

+

+ : +

+

+ -

+ : + - - - + : + +

+ + +

+ : +

- +

+ : +

- +

+ : +

- - - - - -
- : - -
- : - -
- : - -
- : - -
- : - -
- : - -
- : - -
- : - -
- : - -
- : +

+ : -

- : - -
- : - -
- : - -
+

+

+ : +

+ +

+ : +

+ +

+ : +

+ +echo print_trailer( false, true, true ); ?> diff --git a/help_uac.php b/help_uac.php index 156bd3d4f..af8098a47 100644 --- a/help_uac.php +++ b/help_uac.php @@ -1,31 +1,34 @@ +echo <<: +
+

{$helpStr}:{$titleStr}

+

{$descStr}

+

+ {$inviteTStr}

+

+ {$emailTStr}

+

+ {$timeTStr}

+
- - - - - - -
-

-
 
- : - -
- : - -
- : - -
+EOT; - +echo print_trailer( false, true, true ); ?> diff --git a/import_handler.php b/import_handler.php index bac734f54..56e46ae20 100644 --- a/import_handler.php +++ b/import_handler.php @@ -89,7 +89,7 @@ break; } - + $errorStr = translate( 'Error' ); $count_con = $count_suc = $error_num = 0; if (! empty ($data) && empty ($errormsg) ) { import_data ( $data, $doOverwrite, $type ); @@ -101,14 +101,14 @@ } echo translate ( 'Errors' ) . ": $error_num

\n"; } elseif (! empty ( $errormsg ) ) { - echo "

\n" . translate( 'Error' ) . ": $errormsg
\n"; + echo "

\n" . $errorStr . ": $errormsg
\n"; } else { - echo "

\n" . translate( 'Error' ) . ': ' . + echo "

\n" . $errorStr . ': ' . translate( 'There was an error parsing the import file or no events were returned' ) . ".
\n"; } } else { - echo "

\n" . translate( 'Error' ) . ": " . + echo "

\n" . $errorStr . ": " . translate( 'The import file contained no data' ) . ".
\n"; } diff --git a/includes/classes/WebCalMailer.class b/includes/classes/WebCalMailer.class index dabf41743..9f940c070 100644 --- a/includes/classes/WebCalMailer.class +++ b/includes/classes/WebCalMailer.class @@ -84,8 +84,7 @@ class WebCalMailer extends phpmailer { $errStr .= translate ( 'Changes successfully saved' ); $errStr .= ''; } else { - $errStr = '

' . translate( 'Error' ) . "

\n"; - $errStr .= '
' . $error . "
\n"; + $errStr = print_error ( $error ); } echo $errStr; echo print_trailer(); diff --git a/includes/classes/WebCalendar.class b/includes/classes/WebCalendar.class index 35b4f951d..ee1b90c95 100644 --- a/includes/classes/WebCalendar.class +++ b/includes/classes/WebCalendar.class @@ -165,8 +165,7 @@ class WebCalendar { if ( ! access_can_view_page ( ) ) { echo "\n\n" . translate ( $APPLICATION_NAME ) . ' ' . translate( 'Error' ) . "\n" . - "\n

" . translate ( 'Error' ) . "

\n" . - translate ( 'You are not authorized' ); + "\n" . print_not_auth ( true ); exit; } diff --git a/includes/help_list.php b/includes/help_list.php index 39041acad..ab9cf405a 100644 --- a/includes/help_list.php +++ b/includes/help_list.php @@ -19,19 +19,18 @@ 'System Settings'=>'help_admin.php', 'Report Bug'=>'help_bug.php' ); -$helpListStr = '
' . - '' . translate( 'Page' ) . ':';; +$helpListStr = '
' . translate( 'Page' ) . ":\n"; $page = 0; if ( empty ( $thispage ) ) $thispage = 0; $cnt = count ( $help_list ); foreach ( $help_list as $key => $val ) { $page++; - $transStr = translate( $key ); + $transStr = translate( $key ); $val .= '?thispage=' . $page; - $bold = ( $page == $thispage ? ' style="font-weight:bold" ' : - ' style="text-decoration: underline" ' ); - $helpListStr .= ' ' . - $page .' '; + $bold = ( $page == $thispage ? 'bold' : + 'underline' ); + $helpListStr .= ' ' . + $page ." \n"; } $helpListStr .= '
'; ?> diff --git a/includes/init.php b/includes/init.php index 4a45bda40..47eaa0e77 100644 --- a/includes/init.php +++ b/includes/init.php @@ -87,9 +87,10 @@ * popup windows, such as color selection) * @param bool $disableStyle Do not include the standard css? * @param bool $disableRSS Do not include the RSS link + * @param bool $disableAJAX Do not include the prototype.js link */ function print_header($includes = '', $HeadX = '', $BodyX = '', - $disableCustom=false, $disableStyle=false, $disableRSS=false ) { + $disableCustom=false, $disableStyle=false, $disableRSS=false, $disableAJAX=true ) { global $APPLICATION_NAME; global $FONTS,$WEEKENDBG,$THFG,$THBG,$PHP_SELF; global $TABLECELLFG,$TODAYCELLBG,$TEXTCOLOR; @@ -151,7 +152,8 @@ function print_header($includes = '', $HeadX = '', $BodyX = '', } $ret .= "\n"; - $ret .= "\n"; + if ( !$disableAJAX ) + $ret .= "\n"; // Any other includes? if ( is_array ( $includes ) ) { diff --git a/includes/styles.php b/includes/styles.php index b051ccefe..5dd2890d4 100644 --- a/includes/styles.php +++ b/includes/styles.php @@ -192,6 +192,9 @@ function is to control cache expiration and compress the data if possible. .main td.othermonth { } +.underline { + text-decoration: underline; +} #tabscontent { margin: -1px 2px; padding: 0.5em; @@ -572,6 +575,23 @@ function is to control cache expiration and compress the data if possible. vertical-align: top; font-weight: bold; } +.helpbody { + vertical-align: top; + font-weight:normal; +} +.helpbody label { + vertical-align: top; + clear:left; + float:left; + width:150px; + font-size: 1.1em; + font-weight:bold; +} +.helplist { + text-align: center; + font-size: 1.2em; + font-weight: bold; +} img.help { border-width: 0px; @@ -665,7 +685,7 @@ function is to control cache expiration and compress the data if possible. cursor: help; text-decoration: none; font-weight: bold; - width:175px; + width:175px; } #minicalendar table { width: ; diff --git a/includes/views.php b/includes/views.php index e92c2fef0..b94387453 100644 --- a/includes/views.php +++ b/includes/views.php @@ -43,7 +43,7 @@ function view_init ( $view_id ) // If view_name not found, then the specified view id does not // belong to current user. if ( empty ( $view_name ) ) { - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); } } diff --git a/layers.php b/layers.php index 312c06850..59eabf640 100644 --- a/layers.php +++ b/layers.php @@ -28,7 +28,7 @@ print_header(); if ( $ALLOW_VIEW_OTHER != 'Y') { - echo translate( 'You are not authorized' ); + echo print_not_auth (); } else { ?> diff --git a/layers_toggle.php b/layers_toggle.php index d43ef90e9..9c03e2726 100644 --- a/layers_toggle.php +++ b/layers_toggle.php @@ -7,7 +7,7 @@ if ( $ALLOW_VIEW_OTHER != 'Y' ) { print_header (); - etranslate( 'You are not authorized' ); + echo print_not_auth (); echo print_trailer (); exit; } diff --git a/minical.php b/minical.php index 545153636..1fbe815a1 100644 --- a/minical.php +++ b/minical.php @@ -38,7 +38,7 @@ if ( empty ( $PUBLISH_ENABLED ) || $PUBLISH_ENABLED != 'Y' ) { header ( 'Content-Type: text/plain' ); - etranslate( 'You are not authorized' ); + echo print_not_auth (); exit; } /* @@ -81,7 +81,7 @@ if ( $public_must_be_enabled && $PUBLIC_ACCESS != 'Y' ) { - $error = translate ( 'You are not authorized' ) . '.'; + $error = print_not_auth () . '.'; } if ( $allow_user_override ) { diff --git a/nonusers.php b/nonusers.php index a912df146..92bd219e6 100644 --- a/nonusers.php +++ b/nonusers.php @@ -6,13 +6,12 @@ $targetStr = 'target="nonusersiframe" onclick="javascript:show(\'nonusersiframe\');">'; if ( ! $is_admin ) { - echo '

' . translate( 'Error' ) . "

\n" . - translate( 'You are not authorized' ) . ".\n"; + echo print_not_auth ( true ); echo "\n"; exit; } if ( ! $NONUSER_PREFIX ) { - echo '

' . translate( 'Error' ) . "

\n" . + echo print_error_header () . translate( 'NONUSER_PREFIX not set' ) . ".\n"; echo "\n"; exit; diff --git a/nonusers_handler.php b/nonusers_handler.php index e3396fc03..18565f1be 100644 --- a/nonusers_handler.php +++ b/nonusers_handler.php @@ -4,8 +4,7 @@ load_user_layers (); if ( ! $is_admin ) { - echo '

' . translate( 'Error' ) . - '

' . translate( 'You are not authorized' ) . ".\n"; + echo print_not_auth ( true ); echo print_trailer (); exit; } diff --git a/nulogin.php b/nulogin.php index 2e1d27562..b0c4da7f2 100644 --- a/nulogin.php +++ b/nulogin.php @@ -27,12 +27,12 @@ // No login for single-user mode if ( $single_user == 'Y' ) { - die_miserable_death ( translate ( 'You are not authorized' ) ); + die_miserable_death ( print_not_auth () ); } // No web login for HTTP-based authentication if ( $use_http_auth ) { - die_miserable_death ( translate ( 'You are not authorized' ) ); + die_miserable_death ( print_not_auth () ); } $login = getValue ( 'login' ); @@ -59,7 +59,7 @@ ': ' . $login ); } if ( empty ( $temp_is_public ) || $temp_is_public != 'Y' ) { - die_miserable_death ( translate ( 'You are not authorized' ) ); + die_miserable_death ( print_not_auth () ); } // calculate path for cookie diff --git a/publish.php b/publish.php index 0da5c1ddc..98b477a2a 100644 --- a/publish.php +++ b/publish.php @@ -70,7 +70,7 @@ if ( empty ( $PUBLISH_ENABLED ) || $PUBLISH_ENABLED != 'Y' ) { header ( 'Content-Type: text/plain' ); - etranslate( 'You are not authorized' ); + echo print_not_auth (); exit; } @@ -97,7 +97,7 @@ if ( empty ( $USER_PUBLISH_ENABLED ) || $USER_PUBLISH_ENABLED != 'Y' ) { header ( 'Content-Type: text/plain' ); - etranslate( 'You are not authorized' ); + echo print_not_auth (); exit; } diff --git a/register.php b/register.php index f596d0039..ed86be41b 100644 --- a/register.php +++ b/register.php @@ -30,7 +30,7 @@ -$notauth = translate ( 'You are not authorized' ); +$notauth = print_not_auth (); if ( empty ( $ALLOW_SELF_REGISTRATION ) || $ALLOW_SELF_REGISTRATION != 'Y' ) { $error = $notauth; diff --git a/reject_entry.php b/reject_entry.php index 9add79085..00a8db21d 100644 --- a/reject_entry.php +++ b/reject_entry.php @@ -7,7 +7,7 @@ $error = ''; if ( $readonly == 'Y' ) { - $error = translate( 'You are not authorized' ); + $error = print_not_auth (); } //give user a change to add comments to rejection email diff --git a/remotes.php b/remotes.php index b8962f7b6..623b0246c 100644 --- a/remotes.php +++ b/remotes.php @@ -6,7 +6,7 @@ $targetStr = 'target="remotesiframe" onclick="javascript:show(\'remotesiframe\');">'; if ( ! $NONUSER_PREFIX ) { - echo '

' . translate( 'Error' ) . "

\n" . + echo print_error_header () . translate( 'NONUSER_PREFIX not set' ) . ".\n"; echo "\n"; exit; diff --git a/report.php b/report.php index 3438288e8..3546e66d0 100644 --- a/report.php +++ b/report.php @@ -203,7 +203,7 @@ function event_to_text ( $event, $date ) { } if ( empty ( $REPORTS_ENABLED ) || $REPORTS_ENABLED != 'Y' ) { - $error = translate ( 'You are not authorized' ) . '.'; + $error = print_not_auth () . '.'; } $updating_public = false; @@ -221,7 +221,7 @@ function event_to_text ( $event, $date ) { // If no report id is specified, then generate a list of reports for // the user to select from. if ( empty ( $error ) && empty ( $report_id ) && $login == '__public__' ) { - $error = translate ( 'You are not authorized' ) . '.'; + $error = print_not_auth () . '.'; } if ( empty ( $error ) && empty ( $report_id ) ) { $list = ''; @@ -281,7 +281,7 @@ function event_to_text ( $event, $date ) { if ( $res ) { if ( $row = dbi_fetch_row ( $res ) ) { if ( $row[2] != 'Y' && $login != $row[0] ) { - $error = translate ( 'You are not authorized' ) . '.'; + $error = print_not_auth () . '.'; } else { $i = 0; $report_login = $row[$i++]; @@ -462,7 +462,7 @@ function event_to_text ( $event, $date ) { } } if ( ! empty ( $error ) ) { - echo '

' . translate ( 'Error' ) . "

\n" . $error; + echo print_error ( $error ); echo print_trailer (); exit; } diff --git a/rss.php b/rss.php index af2cee978..633e1b684 100644 --- a/rss.php +++ b/rss.php @@ -84,7 +84,7 @@ if ( empty ( $RSS_ENABLED ) || $RSS_ENABLED != 'Y' ) { header ( 'Content-Type: text/plain' ); - etranslate( 'You are not authorized' ); + echo print_not_auth (); exit; } /* @@ -172,7 +172,7 @@ if ( $username != '__public__' && ( empty ( $USER_RSS_ENABLED ) || $USER_RSS_ENABLED != 'Y' ) ) { header ( 'Content-Type: text/plain' ); - etranslate( 'You are not authorized' ); + echo print_not_auth (); exit; } diff --git a/search_handler.php b/search_handler.php index 81cb4b8d2..822ad9c31 100644 --- a/search_handler.php +++ b/search_handler.php @@ -83,7 +83,7 @@ ' . translate( 'Error' ) . ':' . $error; + echo print_error ( $error ); } else { $ids = array (); $words = split ( ' ', $keywords ); diff --git a/select_user.php b/select_user.php index b352f0cdb..8c9d7c2a0 100644 --- a/select_user.php +++ b/select_user.php @@ -9,7 +9,7 @@ ' . translate ( 'Error' ) . - "\n" . $error; - echo "\n

\n"; + echo print_error ( $error ); + echo ""; //restore previous working directory before exit if (strlen($save_current_working_dir)) chdir($save_current_working_dir); diff --git a/users.php b/users.php index b66527e5a..b1550e369 100644 --- a/users.php +++ b/users.php @@ -29,7 +29,7 @@ $INC = array('js/users.php/true','js/visible.php/true'); $BodyX = ( ! empty ( $tab ) ? "onload=\"showTab( '$tab' );\"" : '' ); -print_header($INC,'', $BodyX ); +print_header($INC,'', $BodyX, '', '', true ); echo display_admin_link(); ?> diff --git a/usersel.php b/usersel.php index dece1237a..f25299a6f 100644 --- a/usersel.php +++ b/usersel.php @@ -8,10 +8,10 @@ // listid: element id of user selection object in form // ... to be used like form.elements[$listid] if ( empty ( $form ) ) { - echo 'Program Error: No form specified!'; exit; + echo translate ('Program Error' ) . ': ' . translate ( 'No form specified!' ); exit; } if ( empty ( $listid ) ) { - echo 'Program Error: No listid specified!'; exit; + echo translate ('Program Error' ) . ': ' . translate ('No listid specified!' ); exit; } // parse $users diff --git a/view_d.php b/view_d.php index 4a2c1f2e5..01ace3adf 100644 --- a/view_d.php +++ b/view_d.php @@ -42,7 +42,7 @@ } if ( ! empty ( $error ) ) { - echo '

' . translate ( 'Error' ) . "

\n" . $error; + echo print_error ( $error ); echo print_trailer (); exit; } diff --git a/view_entry.php b/view_entry.php index 38ccdf4ea..02da3ac24 100644 --- a/view_entry.php +++ b/view_entry.php @@ -112,7 +112,7 @@ 'cal_name, cal_description, cal_location, cal_url, cal_due_date, ' . 'cal_due_time, cal_completed FROM webcal_entry WHERE cal_id = ?'; $res = dbi_execute ( $sql , array ( $id ) ); -if ( ! $res ) { +if ( ! $res ) { $error = translate( 'Invalid entry id' ) . ": $id"; } else { $row = dbi_fetch_row ( $res ); @@ -132,9 +132,10 @@ $due_time = $row[14]; $cal_completed = $row[15]; if ( $hide_details ) { - $name = translate ( $OVERRIDE_PUBLIC_TEXT ); - $description = translate ( $OVERRIDE_PUBLIC_TEXT ); - if ( ! empty ( $row[11] ) ) $location = translate ( $OVERRIDE_PUBLIC_TEXT ); + $overrideStr = translate ( $OVERRIDE_PUBLIC_TEXT ); + $name = $overrideStr; + $description = $overrideStr; + if ( ! empty ( $row[11] ) ) $location = $overrideStr; } else { $name = $row[9]; $description = $row[10]; @@ -145,101 +146,104 @@ } dbi_free_result ( $res ); } -//don't shift date if All Day or Untimed -$display_date = ( $event_time > 0 || ($event_time == 0 && $duration != 1440 ) ? date ('Ymd', - date_to_epoch ( $orig_date . sprintf( "%06d", $event_time ) ) ) :$orig_date ); -if ( ! empty ( $year ) ) { - $thisyear = $year; -} -if ( ! empty ( $month ) ) { - $thismonth = $month; -} - -//check UAC -if ( empty ( $user ) ) { - $euser = ( $is_my_event == true ? $login : $create_by ); -} else { - $euser = ( ! empty ( $user ) && $login != $user ? $user : $login ); -} -if ( access_is_enabled () && ! empty ( $euser ) ) { - $can_view = access_user_calendar ( 'view', $euser, $login, $cal_type, $cal_access ); - $can_edit = access_user_calendar ( 'edit', $euser, $login, $cal_type, $cal_access ); - $can_approve = access_user_calendar ( 'approve', $euser, $login, $cal_type, $cal_access ); - $time_only = access_user_calendar ( 'time', $euser ); -} else { - $time_only = 'N'; -} -if ( $is_admin || $is_nonuser_admin || $is_assistant ) { - $can_view = true; -} - if ( ($login != '__public__') && ($PUBLIC_ACCESS_OTHERS == 'Y') ) { - $can_view = true; +if ( empty ( $error ) ) { + //don't shift date if All Day or Untimed + $display_date = ( $event_time > 0 || ($event_time == 0 && $duration != 1440 ) ? date ('Ymd', + date_to_epoch ( $orig_date . sprintf( "%06d", $event_time ) ) ) :$orig_date ); + + if ( ! empty ( $year ) ) { + $thisyear = $year; + } + if ( ! empty ( $month ) ) { + $thismonth = $month; } - $can_edit = ( $can_edit || $is_admin || $is_nonuser_admin && ($user == $create_by) || - ( $is_assistant && ! $is_private && ($user == $create_by) ) || - ( $readonly != 'Y' && ( $login == $create_by || $single_user == 'Y' ) ) ); -if ( $readonly == 'Y' || $is_nonuser || - ( $PUBLIC_ACCESS == 'Y' && $login == '__public__' ) ) { - $can_edit = false; -} - - if ( ! $can_view ) { - $check_group = false; - // if not a participant in the event, must be allowed to look at - // other user's calendar. - if ( $login == '__public__' ) { - if ( $PUBLIC_ACCESS_OTHERS == 'Y' ) { - $check_group = true; - } - } else { - if ( $ALLOW_VIEW_OTHER == 'Y' ) { - $check_group = true; - } + //check UAC + if ( empty ( $user ) ) { + $euser = ( $is_my_event == true ? $login : $create_by ); + } else { + $euser = ( ! empty ( $user ) && $login != $user ? $user : $login ); + } + if ( access_is_enabled () && ! empty ( $euser ) ) { + $can_view = access_user_calendar ( 'view', $euser, $login, $cal_type, $cal_access ); + $can_edit = access_user_calendar ( 'edit', $euser, $login, $cal_type, $cal_access ); + $can_approve = access_user_calendar ( 'approve', $euser, $login, $cal_type, $cal_access ); + $time_only = access_user_calendar ( 'time', $euser ); + } else { + $time_only = 'N'; + } + if ( $is_admin || $is_nonuser_admin || $is_assistant ) { + $can_view = true; + } + if ( ($login != '__public__') && ($PUBLIC_ACCESS_OTHERS == 'Y') ) { + $can_view = true; } - // If $check_group is true now, it means this user can look at the - // event only if they are in the same group as some of the people in - // the event. - // This gets kind of tricky. If there is a participant from a different - // group, do we still show it? For now, the answer is no. - // This could be configurable somehow, but how many lines of text would - // it need in the admin page to describe this scenario? Would confuse - // 99.9% of users. - // In summary, make sure at least one event participant is in one of - // this user's groups. - $my_users = get_my_users (); - $my_usercnt = count ( $my_users ); - if ( is_array ( $my_users ) && $my_usercnt ) { - $sql_params = array (); - $sql = 'SELECT webcal_entry.cal_id FROM webcal_entry, ' . - 'webcal_entry_user WHERE webcal_entry.cal_id = ' . - 'webcal_entry_user.cal_id AND webcal_entry.cal_id = ? ' . - 'AND webcal_entry_user.cal_login IN ( '; - $sql_params[] = $id; - for ( $i = 0; $i < $my_usercnt; $i++ ) { - if ( $i > 0 ) { - $sql .= ', '; + $can_edit = ( $can_edit || $is_admin || $is_nonuser_admin && ($user == $create_by) || + ( $is_assistant && ! $is_private && ($user == $create_by) ) || + ( $readonly != 'Y' && ( $login == $create_by || $single_user == 'Y' ) ) ); + + if ( $readonly == 'Y' || $is_nonuser || + ( $PUBLIC_ACCESS == 'Y' && $login == '__public__' ) ) { + $can_edit = false; + } + + if ( ! $can_view ) { + $check_group = false; + // if not a participant in the event, must be allowed to look at + // other user's calendar. + if ( $login == '__public__' ) { + if ( $PUBLIC_ACCESS_OTHERS == 'Y' ) { + $check_group = true; + } + } else { + if ( $ALLOW_VIEW_OTHER == 'Y' ) { + $check_group = true; } - $sql .= '?'; - $sql_params[] = $my_users[$i]['cal_login']; } - $sql .= ' )'; - $res = dbi_execute ( $sql , $sql_params ); - if ( $res ) { - $row = dbi_fetch_row ( $res ); - if ( $row && $row[0] > 0 ) { - $can_view = true; + // If $check_group is true now, it means this user can look at the + // event only if they are in the same group as some of the people in + // the event. + // This gets kind of tricky. If there is a participant from a different + // group, do we still show it? For now, the answer is no. + // This could be configurable somehow, but how many lines of text would + // it need in the admin page to describe this scenario? Would confuse + // 99.9% of users. + // In summary, make sure at least one event participant is in one of + // this user's groups. + $my_users = get_my_users (); + $my_usercnt = count ( $my_users ); + if ( is_array ( $my_users ) && $my_usercnt ) { + $sql_params = array (); + $sql = 'SELECT webcal_entry.cal_id FROM webcal_entry, ' . + 'webcal_entry_user WHERE webcal_entry.cal_id = ' . + 'webcal_entry_user.cal_id AND webcal_entry.cal_id = ? ' . + 'AND webcal_entry_user.cal_login IN ( '; + $sql_params[] = $id; + for ( $i = 0; $i < $my_usercnt; $i++ ) { + if ( $i > 0 ) { + $sql .= ', '; + } + $sql .= '?'; + $sql_params[] = $my_users[$i]['cal_login']; + } + $sql .= ' )'; + $res = dbi_execute ( $sql , $sql_params ); + if ( $res ) { + $row = dbi_fetch_row ( $res ); + if ( $row && $row[0] > 0 ) { + $can_view = true; + } + dbi_free_result ( $res ); } - dbi_free_result ( $res ); } - } - // If we didn't indicate we need to check groups, then this user - // can't view this event. - if ( ! $check_group || access_is_enabled () ) { - $can_view = false; - } -} + // If we didn't indicate we need to check groups, then this user + // can't view this event. + if ( ! $check_group || access_is_enabled () ) { + $can_view = false; + } + } +} //end $error test // If they still cannot view, make sure they are not looking at a nonuser // calendar event where the nonuser is the _only_ participant. @@ -274,8 +278,7 @@ print_header (); if ( ! empty ( $error ) ) { - echo '

' . translate ( 'Error' ) . - "

\n" . $error; + echo print_error ( $error ); echo print_trailer (); exit; } @@ -330,9 +333,7 @@ // If we have no event status yet, it must have been deleted. if ( ( empty ( $event_status ) && ! $is_admin ) || ( ! $can_view && empty ( $rss_view ) ) ) { - echo '

' . - translate ( 'Error' ) . '

' . - translate ( 'You are not authorized' ) . ".\n"; + echo print_not_auth ( true ); echo print_trailer (); exit; } @@ -766,22 +767,22 @@ for ( $i = 0; $i < $num_wait; $i++ ) { user_load_variables ( $waiting[$i], 'temp' ); if ( strlen ( $tempemail ) ) { - echo '
" . - $tempfullname . " (?)\n"; + echo '" . + $tempfullname . " (?)
\n"; $allmails[] = $tempemail; } else { - echo '
' . $tempfullname . " (?)\n"; + echo $tempfullname . " (?)
\n"; } } for ( $i = 0; $i < $num_rej; $i++ ) { user_load_variables ( $rejected[$i], 'temp' ); if ( strlen ( $tempemail ) ) { - echo '
" . $tempfullname . - ' (' . translate( 'Rejected' ) . ")\n"; + ' (' . translate( 'Rejected' ) . ")
\n"; } else { - echo "
$tempfullname (" . - translate( 'Rejected' ) . ")\n"; + echo "$tempfullname (" . + translate( 'Rejected' ) . ")
\n"; } } } diff --git a/view_l.php b/view_l.php index e6bedf635..526987ed0 100644 --- a/view_l.php +++ b/view_l.php @@ -73,8 +73,7 @@ } if ( ! empty ( $error ) ) { - echo '

' . translate ( 'Error' ) . - "

\n" . $error; + echo print_error ( $error ); echo print_trailer (); exit; } diff --git a/view_m.php b/view_m.php index c849aa9bf..fbcf18b6e 100644 --- a/view_m.php +++ b/view_m.php @@ -78,8 +78,7 @@ } if ( ! empty ( $error ) ) { - echo '

' . translate ( 'Error' ) . - "

\n" . $error; + echo print_error ( $error ); echo print_trailer (); exit; } diff --git a/view_r.php b/view_r.php index b937003dc..b6be1b73f 100644 --- a/view_r.php +++ b/view_r.php @@ -182,8 +182,7 @@ } if ( ! empty ( $error ) ) { - echo '

' . translate ( 'Error' ) . - "

\n" . $error; + echo print_error ( $error ); echo print_trailer (); exit; } diff --git a/view_t.php b/view_t.php index 3ce1f089a..abcf5396b 100644 --- a/view_t.php +++ b/view_t.php @@ -309,8 +309,7 @@ function print_header_timebar() { print_header($INC); if ( ! empty ( $error ) ) { - echo '

' . translate ( 'Error' ) . - "

\n" . $error; + echo print_error ( $error ); echo print_trailer (); exit; } diff --git a/view_v.php b/view_v.php index 827a657da..b46dbe044 100644 --- a/view_v.php +++ b/view_v.php @@ -100,8 +100,7 @@ } if ( ! empty ( $error ) ) { - echo '

' . translate ( 'Error' ) . - "

\n" . $error; + echo print_error ( $error ); echo print_trailer (); exit; } diff --git a/view_w.php b/view_w.php index b5632c9ba..d6c28663d 100644 --- a/view_w.php +++ b/view_w.php @@ -73,8 +73,7 @@ } if ( ! empty ( $error ) ) { - echo '

' . translate ( 'Error' ) . - "

\n" . $error; + echo print_error ( $error ); echo print_trailer (); exit; } diff --git a/views_edit.php b/views_edit.php index 0fb1c6551..36a156e6a 100644 --- a/views_edit.php +++ b/views_edit.php @@ -59,7 +59,7 @@ // If view_name not found, then the specified view id does not // belong to current user. if ( empty( $viewname ) ) { - $error = translate ( 'You are not authorized' ); + $error = print_not_auth (); } // get list of users for this view @@ -80,8 +80,7 @@ } if ( ! empty ( $error ) ) { - echo '

' . translate ( 'Error' ) . - "

\n" . $error; + echo print_error ( $error ); echo print_trailer (); exit; }