Commit e34c6bd5 authored by François Jacquet's avatar François Jacquet
Browse files

Declare $error, $note, $warning globals

Remove isset() checks!
parent 77d826ef
......@@ -62,8 +62,9 @@ Changes in 2.9
- Add jQuery Pin Menu plugin in assets/js/jquery-pinmenu/
- Add STUDENTS_EMAIL_FIELD to CONFIG table in rosariosis.sql & Configuration.php
- Add Password Reset feature in PasswordReset.php
- Update TinyMCE to version 4.3.4 in assets/js/tinymce/
- Update TinyMCE to version 4.3.6 in assets/js/tinymce/
- Add TinyMCEInput() & SanitizeHTML() functions in Inputs.php & MarkDownHTML.fnc.php
- Declare $error, $note, $warning globals in ErrorMessage.fnc.php & program wide
Changes in 2.8.11
-----------------
......
......@@ -534,15 +534,9 @@ function _printPageHead( $title )
echo '<div style="max-width: 500px; margin: 0 auto;">';
if ( $error )
{
echo ErrorMessage( $error );
}
echo ErrorMessage( $error );
if ( $note )
{
echo ErrorMessage( $note, 'note' );
}
echo ErrorMessage( $note, 'note' );
echo '</div>';
}
......
......@@ -6,6 +6,10 @@
* @subpackage functions
*/
// Declare Error & Note & Warning global arrays.
$note = $error = $warning = array();
/**
* Error Message
*
......@@ -33,65 +37,68 @@
*/
function ErrorMessage( $errors, $code = 'error' )
{
if ( ! $errors
|| ! is_array( $errors ) )
{
return '';
}
$return = '';
if ( is_array( $errors )
&& count( $errors ) )
// Error.
if ( $code === 'error'
|| $code === 'fatal' )
{
// Error.
if ( $code === 'error'
|| $code === 'fatal' )
{
$return .= '<div class="error"><p>' . button( 'x' ) .'&nbsp;<b>' . _( 'Error' ) . ':</b> ';
}
// Warning.
elseif ( $code === 'warning' )
{
$return .= '<div class="error"><p>' . button( 'warning' ) . '&nbsp;<b>' . _( 'Warning' ) . ':</b> ';
}
// Note / Update.
else
{
$return .= '<div class="updated"><p><b>' . _( 'Note' ) . ':</b> ';
}
$return .= '<div class="error"><p>' . button( 'x' ) .'&nbsp;<b>' . _( 'Error' ) . ':</b> ';
}
// Warning.
elseif ( $code === 'warning' )
{
$return .= '<div class="error"><p>' . button( 'warning' ) . '&nbsp;<b>' . _( 'Warning' ) . ':</b> ';
}
// Note / Update.
else
{
$return .= '<div class="updated"><p><b>' . _( 'Note' ) . ':</b> ';
}
if ( count( $errors ) === 1 )
if ( count( $errors ) === 1 )
{
$return .= ( isset( $errors[0] ) ? $errors[0] : $errors[1] ) . '</p>';
}
// More than one error: list.
else
{
$return .= '</p><ul>';
foreach ( (array) $errors as $error )
{
$return .= ( isset( $errors[0] ) ? $errors[0] : $errors[1] ) . '</p>';
$return .= '<li>' . $error . '</li>';
}
// More than one error: list.
else
{
$return .= '</p><ul>';
foreach ( (array) $errors as $error )
{
$return .= '<li>' . $error . '</li>';
}
$return .= '</ul>';
}
$return .= '</ul>';
}
$return .= '</div><br />';
$return .= '</div><br />';
// Fatal error, display error and exit.
if ( $code === 'fatal' )
{
echo $return;
// Fatal error, display error and exit.
if ( $code === 'fatal' )
if ( ! isset( $_REQUEST['_ROSARIO_PDF'] ) )
{
Warehouse( 'footer' );
}
else
{
echo $return;
if ( !isset( $_REQUEST['_ROSARIO_PDF'] ) )
Warehouse( 'footer' );
// FJ force PDF on fatal error.
else
{
global $print_data;
global $print_data;
PDFStop( $print_data );
}
exit;
PDFStop( $print_data );
}
exit;
}
return $return;
......
......@@ -129,11 +129,7 @@ function SaveData( $iu_extra, $field_names = array() )
' WHERE ' . str_replace( '__ID__', $id, $iu_extra[ $table ] );
}
// Display errors if any.
if ( $error )
{
echo ErrorMessage( $error );
}
echo ErrorMessage( $error );
if ( $go )
{
......
......@@ -99,10 +99,9 @@ if (isset($_REQUEST['modfunc']) && $_REQUEST['modfunc']=='save')
DrawHeader(ProgramTitle());
if (isset($note))
echo ErrorMessage($note, 'note');
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $note, 'note' );
echo ErrorMessage( $error );
if (empty($_REQUEST['modfunc']))
......
......@@ -90,9 +90,8 @@ if ( $_REQUEST['modfunc']=='remove' && AllowEdit())
}
}
//FJ fix SQL bug invalid sort order
if (isset($error))
echo ErrorMessage($error);
// FJ fix SQL bug invalid sort order
echo ErrorMessage( $error );
if (empty($_REQUEST['modfunc']))
{
......
......@@ -184,11 +184,9 @@ if (isset($_REQUEST['search_modfunc']) && $_REQUEST['search_modfunc']=='list' &&
DrawHeader(ProgramTitle());
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if (isset($note))
echo ErrorMessage($note, 'note');
echo ErrorMessage( $note, 'note' );
echo '<form action="Modules.php?modname=Attendance/DuplicateAttendance.php&modfunc=&search_modfunc=list&next_modname=Attendance/DuplicateAttendance.php&delete=true" method="POST">';
......@@ -361,8 +359,7 @@ if (isset($_REQUEST['search_modfunc']) && $_REQUEST['search_modfunc']=='list' &&
if ( !isset($_REQUEST['search_modfunc']) && $_REQUEST['delete']!='true')
{
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
DrawHeader(ProgramTitle());
......
......@@ -234,8 +234,7 @@ if (isset($_REQUEST['modfunc']) && $_REQUEST['modfunc']=='save' && AllowEdit())
unset($_SESSION['email_column'], $email_column);
}
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if (empty($_REQUEST['modfunc']) && !empty($email_column))
{
......
......@@ -95,8 +95,7 @@ if (isset($_REQUEST['modfunc']) && $_REQUEST['modfunc']=='save')
}
}
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if (empty($_REQUEST['modfunc']) || $_REQUEST['search_modfunc']=='list')
{
......
......@@ -135,9 +135,8 @@ if ( $_REQUEST['modfunc']=='add_usage' && AllowEdit())
}
//FJ fix SQL bug invalid sort order
if (isset($error))
echo ErrorMessage($error);
// FJ fix SQL bug invalid sort order
echo ErrorMessage( $error );
if (empty($_REQUEST['modfunc']))
{
......
......@@ -131,11 +131,9 @@ if ( isset( $_POST['values'] )
unset($_SESSION['student_id']);
}
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if (isset($note))
echo ErrorMessage($note,'note');
echo ErrorMessage( $note, 'note' );
//if ( ! $_REQUEST['student_id'])
$extra['new'] = true;
......
......@@ -35,7 +35,7 @@ if ( isset( $_POST['values'] )
if ( $column_data_type === 'numeric'
&& ! is_numeric( $value ) )
{
$error[] = _('Please enter valid Numeric data.');
$error[] = _( 'Please enter valid Numeric data.' );
continue;
}
......@@ -70,8 +70,7 @@ if ( isset( $_POST['values'] )
DrawHeader(ProgramTitle());
if ( $error)
echo ErrorMessage(array(_('Please enter valid Numeric data.')));
echo ErrorMessage( $error );
if ( $_REQUEST['modfunc']=='remove' && AllowEdit())
{
......@@ -283,13 +282,13 @@ if (empty($_REQUEST['modfunc']) && $_REQUEST['referral_id'])
}
else
{
$error[] = _('No Students were found.');
$error[] = _( 'No Students were found.' );
$_REQUEST['referral_id'] = false;
}
}
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if ( ! $_REQUEST['referral_id'] && ! $_REQUEST['modfunc'])
Search('student_id',$extra);
......
......@@ -30,10 +30,9 @@ if (isset($_REQUEST['modfunc']) && $_REQUEST['modfunc']=='save')
DrawHeader(ProgramTitle());
if (isset($note))
echo ErrorMessage($note, 'note');
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $note, 'note' );
echo ErrorMessage( $error );
if ( $_REQUEST['search_modfunc']=='list')
{
......
......@@ -223,8 +223,9 @@ if (empty($_REQUEST['modfunc']))
echo '<form action="Modules.php?modname='.$_REQUEST['modname'].'&modfunc=update&tab_id='.$_REQUEST['tab_id'].'" method="POST">';
DrawHeader('',SubmitButton(_('Save')));
echo '<br />';
//FJ fix SQL bug invalid sort order
if (isset($error)) echo ErrorMessage($error);
// FJ fix SQL bug invalid sort order
echo ErrorMessage( $error );
$extra = array('save'=>false,'search'=>false,
'header'=>WrapTabs($tabs,'Modules.php?modname='.$_REQUEST['modname'].'&tab_id='.$_REQUEST['tab_id']));
......
......@@ -100,9 +100,8 @@ if ( $_REQUEST['modfunc']=='remove' && AllowEdit())
}
}
//FJ fix SQL bug invalid sort order
if (isset($error))
echo ErrorMessage($error);
// FJ fix SQL bug invalid sort order
echo ErrorMessage( $error );
if (empty($_REQUEST['modfunc']))
{
......
......@@ -80,9 +80,8 @@ $extra['columns_after'] = array('BALANCE' => _('Balance'),'STATUS' => _('Status'
Search('student_id',$extra);
//FJ fix SQL bug invalid numeric data
if (isset($error))
echo ErrorMessage($error);
// FJ fix SQL bug invalid numeric data
echo ErrorMessage( $error );
if (UserStudentID() && empty($_REQUEST['modfunc']))
{
......
......@@ -48,8 +48,7 @@ $extra['columns_after'] = array('BALANCE' => _('Balance'),'STATUS' => _('Status'
Search('student_id',$extra);
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if (UserStudentID() && empty($_REQUEST['modfunc']))
{
......
......@@ -41,8 +41,7 @@ $extra['columns_after'] = array('BALANCE' => _('Balance'),'STATUS' => _('Status'
Search('staff_id',$extra);
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if (UserStaffID() && empty($_REQUEST['modfunc']))
{
......
......@@ -336,8 +336,7 @@ if ( isset( $_REQUEST['modfunc'] )
}
}
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if (empty($_REQUEST['modfunc']))
{
......
......@@ -135,9 +135,8 @@ if ( UserStudentID() )
}
}
//FJ fix SQL bug when text data entered, data verification
if (isset($error))
echo ErrorMessage($error);
// FJ fix SQL bug when text data entered, data verification
echo ErrorMessage( $error );
if (empty($_REQUEST['modfunc']))
{
......
......@@ -396,8 +396,7 @@ if (isset($_REQUEST['modfunc']) && $_REQUEST['modfunc']=='save')
if (empty($_REQUEST['modfunc']))
{
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if ( $_REQUEST['search_modfunc']=='list')
{
......
......@@ -99,9 +99,8 @@ if ( $_REQUEST['modfunc']=='remove' && AllowEdit())
}
}
//FJ fix SQL bug invalid sort order
if (isset($error))
echo ErrorMessage($error);
// FJ fix SQL bug invalid sort order
echo ErrorMessage( $error );
if (empty($_REQUEST['modfunc']))
{
......
......@@ -277,8 +277,9 @@ if (empty($_REQUEST['modfunc']))
echo '<form action="Modules.php?modname='.$_REQUEST['modname'].'&modfunc=update&course_id='.$_REQUEST['course_id'].'&tab_id='.$_REQUEST['tab_id'].'" method="POST">';
DrawHeader($subject_select.' : '.$course_select,SubmitButton(_('Save')));
echo '<br />';
//FJ fix SQL bug invalid sort order
if (isset($error)) echo ErrorMessage($error);
//FJ fix SQL bug invalid sort order
echo ErrorMessage( $error );
$LO_options = array('save'=>false,'search'=>false,'header_color' => $categories_RET[$_REQUEST['tab_id']][1]['COLOR'],
'header'=>WrapTabs($tabs,'Modules.php?modname='.$_REQUEST['modname'].'&subject_id='.$_REQUEST['subject_id'].'&course_id='.$_REQUEST['course_id'].'&tab_id='.$_REQUEST['tab_id']));
......
......@@ -95,8 +95,7 @@ if ( $_REQUEST['modfunc']=='remove' && AllowEdit())
}
//FJ fix SQL bug invalid numeric data
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if (empty($_REQUEST['modfunc']))
{
......
......@@ -39,11 +39,9 @@ if ( $_REQUEST['modfunc']=='delete' && AllowEdit())
}
}
if (isset($note))
echo ErrorMessage($note,'note');
echo ErrorMessage( $note,'note' );
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if ( $_REQUEST['modfunc']!='delete')
{
......
......@@ -120,14 +120,11 @@ if ( $_REQUEST['modfunc'] === 'save' )
DrawHeader(ProgramTitle());
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if (isset($note))
echo ErrorMessage($note, 'note');
echo ErrorMessage( $note, 'note' );
if (isset($warning))
echo ErrorMessage($warning, 'warning');
echo ErrorMessage( $warning, 'warning' );
if (empty($_REQUEST['modfunc']))
......
......@@ -56,9 +56,8 @@ if ( $_REQUEST['modfunc']=='remove' && AllowEdit())
}
}
//FJ fix SQL bug invalid sort order
if (isset($error))
echo ErrorMessage($error);
// FJ fix SQL bug invalid sort order
echo ErrorMessage( $error );
if ( $_REQUEST['modfunc']!='remove')
{
......
......@@ -352,8 +352,7 @@ else
}
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
Search('student_id');
......
......@@ -314,8 +314,7 @@ if ( $_REQUEST['modfunc']=='delete' && AllowEdit())
}
}
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if (empty($_REQUEST['modfunc']))
{
......
......@@ -40,11 +40,9 @@ if ( $_REQUEST['modfunc']=='delete' && AllowEdit())
}
}
if (isset($note))
echo ErrorMessage($note,'note');
echo ErrorMessage( $note, 'note' );
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if ( $_REQUEST['modfunc']!='delete')
{
......
......@@ -104,11 +104,9 @@ if ( $_REQUEST['values'] && $_POST['values'])
unset($_REQUEST['search_modfunc']);
unset($_SESSION['_REQUEST_vars']['search_modfunc']);
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if (isset($note))
echo ErrorMessage($note,'note');
echo ErrorMessage( $note,'note' );
if (empty($_REQUEST['modfunc']))
{
......
......@@ -351,8 +351,7 @@ else
}
if (isset($error))
echo ErrorMessage($error);
echo ErrorMessage( $error );
if ( $_REQUEST['modfunc']=='delete' && basename($_SERVER['PHP_SELF'])!='index.php' && AllowEdit())
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment