Skip to content

Commit

Permalink
Created commom error functions to hopefully cleanup the code
Browse files Browse the repository at this point in the history
  • Loading branch information
umcesrjones committed Sep 13, 2006
1 parent 373fbdb commit de78604
Show file tree
Hide file tree
Showing 65 changed files with 316 additions and 308 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion access.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
$ALLOW_VIEW_OTHER == 'Y' ? true : false );

if ( ! access_is_enabled () ) {
etranslate ( 'You are not authorized' );
echo print_not_auth ();
exit;
}

Expand Down
2 changes: 1 addition & 1 deletion activity_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 )) {
Expand Down
2 changes: 1 addition & 1 deletion approve_entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
$error = '';

if ( $readonly == 'Y' ) {
$error = translate( 'You are not authorized' );
$error = print_not_auth ();
}


Expand Down
9 changes: 5 additions & 4 deletions availability.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions category.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -122,6 +122,6 @@
}

if ( ! empty ( $error ) ) {
echo "<span class=\"bold\">" . translate ( 'Error' ) . ':</span>' . $error;
echo print_error ( $error );
}
echo print_trailer(); ?>
2 changes: 1 addition & 1 deletion category_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down
4 changes: 2 additions & 2 deletions del_entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
}

if ( ! $can_edit ) {
$error = translate ( 'You are not authorized' );
$error = print_not_auth ();
}

// Is this a repeating event?
Expand Down Expand Up @@ -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 ) ) {
Expand Down
2 changes: 1 addition & 1 deletion del_layer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion doc.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
}
}
if ( empty ( $error ) && ! $can_view ) {
$error = translate ( 'You are not authorized' );
$error = print_not_auth ();
}
}

Expand Down
10 changes: 5 additions & 5 deletions docadd.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' )
Expand All @@ -96,11 +96,11 @@
}

if ( ! $can_add )
$error = translate ( 'You are not authorized' );
$error = print_not_auth ();

if ( ! empty ( $error ) ) {
print_header ();
echo '<h2>' . translate( 'Error' ) . '</h2>' . $error;
echo print_error ( $error );
echo print_trailer ();
exit;
}
Expand Down Expand Up @@ -197,7 +197,7 @@

if ( ! empty ( $error ) ) {
print_header ();
echo '<h2>' . translate( 'Error' ) . '</h2>' . $error;
echo print_error ( $error );
echo print_trailer ();
exit;
}
Expand Down
7 changes: 4 additions & 3 deletions docdel.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
}

if ( empty ( $error ) && ! $can_delete ) {
$error = translate ( 'You are not authorized' );
$error = print_not_auth ();
}

if ( empty ( $error ) && $can_delete ) {
Expand All @@ -92,8 +92,9 @@

// Some kind of error...
print_header ();
echo '<h2>' . translate ( 'Error' ) . '</h2>' . $error;
echo print_trailer (); ?>
echo print_error ( $error );
echo print_trailer ();
?>



2 changes: 1 addition & 1 deletion edit_entry_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion edit_layer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

if ( $ALLOW_VIEW_OTHER != 'Y' ) {
print_header ();
etranslate( 'You are not authorized' );
echo print_not_auth ();
echo print_trailer ();
exit;
}
Expand Down
2 changes: 1 addition & 1 deletion edit_layer_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$error = '';

if ( $ALLOW_VIEW_OTHER != 'Y' ) {
$error = translate( 'You are not authorized' );
$error = print_not_auth ();
}

if ( empty ( $dups ) )
Expand Down
7 changes: 3 additions & 4 deletions edit_nonusers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<h2>' . translate( 'Error' ) . "</h2>\n" .
translate( 'You are not authorized' ) . ".\n";
echo print_not_auth ( true );
echo "</body>\n</html>";
exit;
}
if ( ! $NONUSER_PREFIX ) {
echo '<h2>' . translate( 'Error' ) . "</h2>\n" .
echo print_error_header () .
translate( 'NONUSER_PREFIX not set' ) . ".\n";
echo "</body>\n</html>";
exit;
Expand Down
3 changes: 1 addition & 2 deletions edit_nonusers_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
load_user_layers ();

if ( ! $is_admin ) {
echo '<h2>' . translate( 'Error' ) .
'</h2>' . translate( 'You are not authorized' ) . ".\n";
echo print_not_auth ( true );
echo "</body>\n</html>";
exit;
}
Expand Down
4 changes: 2 additions & 2 deletions edit_remotes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<h2>' . translate( 'Error' ) . "</h2>\n" . $error . ".\n";
echo print_error ( $error );
echo "</body>\n</html>";
exit;
}
Expand Down
5 changes: 3 additions & 2 deletions edit_remotes_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
$data = parse_hcal( $result, $type );
}
print_header( '','','',true,false,true);
$errorStr = "<br /><br />\n<b>" . translate( 'Error' ) . ':</b> ';
if ( count ($data) && empty ($errormsg) ) {
//delete existing events
delete_events ( $nid );
Expand All @@ -52,9 +53,9 @@
echo '<p>' . translate( 'Create a new layer to view this calendar' ) . ".</p>\n";
} elseif (! empty ( $errormsg ) ) {
echo translate ( 'Errors' ) . ": $error_num<br /><br />\n";
echo "<br /><br />\n<b>" . translate( 'Error' ) . ":</b> $errormsg<br />\n";
echo $errorStr$errormsg . "<br />\n";
} else {
echo "<br /><br />\n<b>" . translate( 'Error' ) . ':</b> ' .
echo $errorStr .
translate( 'There was an error parsing the import file or no events were returned' ) .
".<br />\n";
}
Expand Down
8 changes: 4 additions & 4 deletions edit_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) {
Expand All @@ -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' );
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions edit_report_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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';
Expand Down
3 changes: 1 addition & 2 deletions edit_template.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@

<?php
if ( ! empty ( $error ) ) {
echo '<h2>' . translate( 'Error' ) . "</h2>\n" .
$error . "\n";
echo print_error ( $error );
} else {
?>
<form action="edit_template.php" method="post" name="reportform">
Expand Down
10 changes: 5 additions & 5 deletions edit_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<h2>' . translate ( 'Error' ) . "</h2>\n<p>" . $error . "</p>\n";
echo print_error ( $error );
} else {
?>
<table>
Expand Down
2 changes: 1 addition & 1 deletion edit_user_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) . '.';
Expand Down
6 changes: 3 additions & 3 deletions export_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ function transmit_header ( $mime, $file ) {
//exit;

print_header();

echo '<h2>' . translate( 'Export' ) . ' ' .translate( 'Error' ) . "</h2>\n"
. '<span class="bold">' . translate( 'Error' ) . ':</span> '
$errorStr = translate( 'Error' );
echo '<h2>' . translate( 'Export' ) . ' ' . $errorStr . "</h2>\n"
. '<span class="bold">' . $errorStr . ':</span> '
. translate( 'export format not defined or incorrect' ) . '.' . "<br />\n";
echo print_trailer ();

Expand Down
2 changes: 1 addition & 1 deletion freebusy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading

0 comments on commit de78604

Please sign in to comment.