Commit f31a7916 authored by François Jacquet's avatar François Jacquet

Omit DBQuery call for DBGet SELECT

parent ba50fb53
......@@ -33,11 +33,11 @@ if ( isset( $_POST['email'] )
}
else
{
$user_RET = DBGet( DBQuery( "SELECT STAFF_ID AS ID, EMAIL, USERNAME, 'staff' AS USER_TYPE
$user_RET = DBGet( "SELECT STAFF_ID AS ID, EMAIL, USERNAME, 'staff' AS USER_TYPE
FROM STAFF
WHERE LOWER(EMAIL)=LOWER('" . $_REQUEST['email'] . "')
AND SYEAR='" . Config( 'SYEAR' ) . "'
LIMIT 1" ) );
LIMIT 1" );
if ( ! $user_RET
&& Config( 'STUDENTS_EMAIL_FIELD' ) )
......@@ -58,7 +58,7 @@ if ( isset( $_POST['email'] )
if ( $custom_field )
{
$user_RET = DBGet( DBQuery( "SELECT s.STUDENT_ID AS ID, s.USERNAME, 'student' AS USER_TYPE,
$user_RET = DBGet( "SELECT s.STUDENT_ID AS ID, s.USERNAME, 'student' AS USER_TYPE,
s." . $custom_field . " AS EMAIL
FROM STUDENTS s, STUDENT_ENROLLMENT ssm
WHERE LOWER(s." . $custom_field . ")=LOWER('" . $_REQUEST['email'] . "')
......@@ -67,7 +67,7 @@ if ( isset( $_POST['email'] )
AND ('" . DBDate() . "'>=ssm.START_DATE
AND (ssm.END_DATE IS NULL
OR '" . DBDate() . "'<=ssm.END_DATE ) )
LIMIT 1" ) );
LIMIT 1" );
}
}
......@@ -127,11 +127,11 @@ if ( isset( $_REQUEST['h'] )
&& mb_substr( $_REQUEST['h'], 0, 3 ) == '$6$' )
{
// Select Staff where last login > now.
$staff_RET = DBGet( DBQuery( "SELECT STAFF_ID AS ID, USERNAME, PASSWORD, EMAIL,
$staff_RET = DBGet( "SELECT STAFF_ID AS ID, USERNAME, PASSWORD, EMAIL,
" . DisplayNameSQL() . " AS FULL_NAME, LAST_LOGIN, PROFILE_ID
FROM STAFF
WHERE LAST_LOGIN > CURRENT_TIMESTAMP
AND SYEAR='" . Config( 'SYEAR' ) . "'" ) );
AND SYEAR='" . Config( 'SYEAR' ) . "'" );
$student_RET = array();
......@@ -154,7 +154,7 @@ if ( isset( $_REQUEST['h'] )
if ( $custom_field )
{
// Select Students where last login > now & enrolled.
$student_RET = DBGet( DBQuery( "SELECT s.STUDENT_ID AS ID, s.USERNAME, s.PASSWORD,
$student_RET = DBGet( "SELECT s.STUDENT_ID AS ID, s.USERNAME, s.PASSWORD,
s." . $custom_field . " AS EMAIL,
" . DisplayNameSQL( 's' ) . " AS FULL_NAME, s.LAST_LOGIN
FROM STUDENTS s, STUDENT_ENROLLMENT se
......@@ -163,7 +163,7 @@ if ( isset( $_REQUEST['h'] )
AND se.STUDENT_ID=s.STUDENT_ID
AND ('" . DBDate() . "'>=se.START_DATE
AND ('" . DBDate() . "'<=se.END_DATE
OR se.END_DATE IS NULL ) )" ) );
OR se.END_DATE IS NULL ) )" );
}
}
......@@ -324,11 +324,11 @@ function _sendPasswordResetEmail( $user_id, $user_type = 'staff', $email )
if ( $user_type === 'staff' )
{
// Get Staff email, password.
$staff_RET = DBGet( DBQuery( "SELECT USERNAME, PASSWORD,
$staff_RET = DBGet( "SELECT USERNAME, PASSWORD,
" . DisplayNameSQL() . " AS FULL_NAME
FROM STAFF
WHERE STAFF_ID='" . $user_id . "'
AND SYEAR='" . Config( 'SYEAR' ) . "'" ) );
AND SYEAR='" . Config( 'SYEAR' ) . "'" );
$username = $staff_RET[1]['USERNAME'];
......@@ -339,7 +339,7 @@ function _sendPasswordResetEmail( $user_id, $user_type = 'staff', $email )
elseif ( $user_type === 'student' )
{
// Get Student username, password, name.
$student_RET = DBGet( DBQuery( "SELECT USERNAME,PASSWORD,
$student_RET = DBGet( "SELECT USERNAME,PASSWORD,
" . DisplayNameSQL( 's' ) . " AS FULL_NAME
FROM STUDENTS s,STUDENT_ENROLLMENT ssm
WHERE s.STUDENT_ID='" . $user_id . "'
......@@ -347,7 +347,7 @@ function _sendPasswordResetEmail( $user_id, $user_type = 'staff', $email )
AND ssm.SYEAR='" . Config( 'SYEAR' ) . "'
AND ('" . DBDate() . "'>=ssm.START_DATE
AND (ssm.END_DATE IS NULL
OR '" . DBDate() . "'<=ssm.END_DATE ) )" ) );
OR '" . DBDate() . "'<=ssm.END_DATE ) )" );
$username = $student_RET[1]['USERNAME'];
......@@ -363,8 +363,8 @@ function _sendPasswordResetEmail( $user_id, $user_type = 'staff', $email )
}
// Last login = now + 2 hours.
$last_login_RET = DBGet( DBQuery( "SELECT
CAST(CURRENT_TIMESTAMP + INTERVAL '2 hours' AS TIMESTAMP(0)) AS LAST_LOGIN" ) );
$last_login_RET = DBGet( "SELECT
CAST(CURRENT_TIMESTAMP + INTERVAL '2 hours' AS TIMESTAMP(0)) AS LAST_LOGIN" );
$last_login = $last_login_RET[1]['LAST_LOGIN'];
......@@ -507,10 +507,10 @@ function _notifyServerAdminPasswordReset( $user_id )
return false;
}
$staff_RET = DBGet( DBQuery( "SELECT USERNAME," . DisplayNameSQL() . " AS FULL_NAME,PROFILE
$staff_RET = DBGet( "SELECT USERNAME," . DisplayNameSQL() . " AS FULL_NAME,PROFILE
FROM STAFF
WHERE STAFF_ID='" . $user_id . "'
AND SYEAR='" . Config( 'SYEAR' ) . "'" ) );
AND SYEAR='" . Config( 'SYEAR' ) . "'" );
// FJ add SendEmail function.
require_once 'ProgramFunctions/SendEmail.fnc.php';
......
......@@ -38,7 +38,7 @@ function AddDBField( $table, $sequence, $type )
return '';
}
$id = DBGet( DBQuery( 'SELECT ' . db_seq_nextval( $sequence ) . ' AS ID ' ) );
$id = DBGet( 'SELECT ' . db_seq_nextval( $sequence ) . ' AS ID ' );
$id = $id[1]['ID'];
......@@ -196,9 +196,9 @@ function DeleteDBFieldCategory( $table, $id )
$fields_table = $table === 'STUDENTS' ? 'CUSTOM' : $table;
// Delete all fields in Category.
$fields = DBGet( DBQuery( "SELECT ID
$fields = DBGet( "SELECT ID
FROM " . DBEscapeIdentifier( $fields_table . '_FIELDS' ) .
" WHERE CATEGORY_ID='" . (int) $id . "'" ) );
" WHERE CATEGORY_ID='" . (int) $id . "'" );
foreach ( (array) $fields as $field )
{
......@@ -388,9 +388,9 @@ function GetFieldsForm( $table, $title, $RET, $extra_category_fields = array(),
if ( $category_id )
{
// CATEGORIES.
$categories_RET = DBGet( DBQuery( "SELECT ID,TITLE,SORT_ORDER
$categories_RET = DBGet( "SELECT ID,TITLE,SORT_ORDER
FROM " . DBEscapeIdentifier( $table . '_FIELD_CATEGORIES' ) .
" ORDER BY SORT_ORDER,TITLE" ) );
" ORDER BY SORT_ORDER,TITLE" );
foreach ( (array) $categories_RET as $type )
{
......@@ -684,9 +684,9 @@ function FilterCustomFieldsMarkdown( $table, $request_index, $request_index_2 =
$table = preg_replace( "/[^a-zA-Z0-9_]+/", '', $table );
// FJ textarea fields MarkDown sanitize.
$textarea_RET = DBGet( DBQuery( "SELECT ID
$textarea_RET = DBGet( "SELECT ID
FROM " . DBEscapeIdentifier( $table ) . "
WHERE TYPE='textarea'") );
WHERE TYPE='textarea'" );
if ( ! $textarea_RET )
{
......@@ -740,8 +740,8 @@ function CheckRequiredCustomFields( $table, $request_values )
return false;
}
$required_RET = DBGet( DBQuery( "SELECT ID FROM " . DBEscapeIdentifier( $table ) . "
WHERE REQUIRED='Y'" ) );
$required_RET = DBGet( "SELECT ID FROM " . DBEscapeIdentifier( $table ) . "
WHERE REQUIRED='Y'" );
foreach ( (array) $required_RET as $required )
{
......
......@@ -31,7 +31,7 @@ function MailingLabel( $address_id )
if ( ! isset( $mailing_labels[ $address_id ][ $student_id ] ) )
{
$people_RET = DBGet( DBQuery( "SELECT p.FIRST_NAME,p.MIDDLE_NAME,p.LAST_NAME,
$people_RET = DBGet( "SELECT p.FIRST_NAME,p.MIDDLE_NAME,p.LAST_NAME,
coalesce(a.MAIL_ADDRESS,a.ADDRESS) AS ADDRESS,coalesce(a.MAIL_CITY,a.CITY) AS CITY,
coalesce(a.MAIL_STATE,a.STATE) AS STATE,coalesce(a.MAIL_ZIPCODE,a.ZIPCODE) AS ZIPCODE
FROM ADDRESS a JOIN STUDENTS_JOIN_ADDRESS sja ON (a.ADDRESS_ID=sja.ADDRESS_ID)
......@@ -41,7 +41,7 @@ function MailingLabel( $address_id )
LEFT OUTER JOIN PEOPLE p ON (p.PERSON_ID=sjp.PERSON_ID)
WHERE sja.STUDENT_ID='" . $student_id . "'
AND sja.ADDRESS_ID='" . $address_id . "'
ORDER BY sjp.STUDENT_RELATION" ), array(), array( 'LAST_NAME' ) );
ORDER BY sjp.STUDENT_RELATION", array(), array( 'LAST_NAME' ) );
$return = '';
......
......@@ -18,14 +18,14 @@ if ( !isset($PortalNotesFilesPath))
function PortalPollsVote( $poll_id, $votes_array )
{
// Get poll:
$poll_RET = DBGet( DBQuery( "SELECT EXCLUDED_USERS, VOTES_NUMBER, DISPLAY_VOTES
$poll_RET = DBGet( "SELECT EXCLUDED_USERS, VOTES_NUMBER, DISPLAY_VOTES
FROM PORTAL_POLLS
WHERE ID='" . $poll_id . "'" ) );
WHERE ID='" . $poll_id . "'" );
$poll_questions_RET = DBGet( DBQuery( "SELECT ID, QUESTION, OPTIONS, VOTES
$poll_questions_RET = DBGet( "SELECT ID, QUESTION, OPTIONS, VOTES
FROM PORTAL_POLL_QUESTIONS
WHERE PORTAL_POLL_ID='" . $poll_id . "'
ORDER BY ID" ) );
ORDER BY ID" );
if ( ! $poll_RET || ! $poll_questions_RET )
{
......@@ -142,16 +142,16 @@ function PortalPollsDisplay( $value, $name )
$poll_id = $THIS_RET['ID'];
// Get poll:
$poll_RET = DBGet( DBQuery( "SELECT EXCLUDED_USERS,VOTES_NUMBER,DISPLAY_VOTES
$poll_RET = DBGet( "SELECT EXCLUDED_USERS,VOTES_NUMBER,DISPLAY_VOTES
FROM PORTAL_POLLS
WHERE ID='" . $poll_id . "'" ) );
WHERE ID='" . $poll_id . "'" );
require_once 'ProgramFunctions/Linkify.fnc.php';
$poll_questions_RET = DBGet( DBQuery( "SELECT ID,QUESTION,OPTIONS,TYPE,VOTES
$poll_questions_RET = DBGet( "SELECT ID,QUESTION,OPTIONS,TYPE,VOTES
FROM PORTAL_POLL_QUESTIONS
WHERE PORTAL_POLL_ID='" . $poll_id . "'
ORDER BY ID" ), array( 'OPTIONS' => 'Linkify' ) );
ORDER BY ID", array( 'OPTIONS' => 'Linkify' ) );
if ( ! $poll_RET || ! $poll_questions_RET )
{
......@@ -434,12 +434,12 @@ function makePublishingVisibleTo( $profiles, $THIS_RET, $id )
<tr class="st">';
// FJ Portal Polls add students teacher.
$teachers_RET = DBGet( DBQuery( "SELECT STAFF_ID," . DisplayNameSQL() . " AS FULL_NAME
$teachers_RET = DBGet( "SELECT STAFF_ID," . DisplayNameSQL() . " AS FULL_NAME
FROM STAFF
WHERE (SCHOOLS IS NULL OR STRPOS(SCHOOLS,'," . UserSchool() . ",')>0)
AND SYEAR='" . UserSyear() . "'
AND PROFILE='teacher'
ORDER BY LAST_NAME,FIRST_NAME" ) );
ORDER BY LAST_NAME,FIRST_NAME" );
$teachers = array();
......
......@@ -668,10 +668,10 @@ function _makeStartInput( $value, $column )
{
$id = 'new';
$default = DBGet( DBQuery( "SELECT min(SCHOOL_DATE) AS START_DATE
$default = DBGet( "SELECT min(SCHOOL_DATE) AS START_DATE
FROM ATTENDANCE_CALENDAR
WHERE SYEAR='" . UserSyear() . "'
AND SCHOOL_ID='" . UserSchool() . "'" ) );
AND SCHOOL_ID='" . UserSchool() . "'" );
$default = $default[1]['START_DATE'];
......@@ -692,11 +692,11 @@ function _makeStartInput( $value, $column )
if ( ! $add_codes )
{
$options_RET = DBGet( DBQuery( "SELECT ID,TITLE AS TITLE
$options_RET = DBGet( "SELECT ID,TITLE AS TITLE
FROM STUDENT_ENROLLMENT_CODES
WHERE SYEAR='" . UserSyear() . "'
AND TYPE='Add'
ORDER BY SORT_ORDER" ) );
ORDER BY SORT_ORDER" );
foreach ( (array) $options_RET as $option )
{
......@@ -757,11 +757,11 @@ function _makeEndInput( $value, $column )
if ( ! $drop_codes )
{
$options_RET = DBGet( DBQuery( "SELECT ID,TITLE AS TITLE
$options_RET = DBGet( "SELECT ID,TITLE AS TITLE
FROM STUDENT_ENROLLMENT_CODES
WHERE SYEAR='" . UserSyear() . "'
AND TYPE='Drop'
ORDER BY SORT_ORDER" ) );
ORDER BY SORT_ORDER" );
foreach ( (array) $options_RET as $option )
{
......@@ -812,9 +812,9 @@ function _makeSchoolInput( $value, $column )
if ( ! isset( $schools )
|| ! is_array( $schools ) )
{
$schools = DBGet( DBQuery( "SELECT ID,TITLE
$schools = DBGet( "SELECT ID,TITLE
FROM SCHOOLS
WHERE SYEAR='" . UserSyear() . "'" ), array(), array( 'ID' ) );
WHERE SYEAR='" . UserSyear() . "'", array(), array( 'ID' ) );
}
foreach ( (array) $schools as $sid => $school )
......
......@@ -34,10 +34,10 @@ function GetTemplate( $modname = '', $staff_id = 0 ) {
$staff_id = User( 'STAFF_ID' );
}
$template_RET = DBGet( DBQuery( "SELECT TEMPLATE,STAFF_ID
$template_RET = DBGet( "SELECT TEMPLATE,STAFF_ID
FROM TEMPLATES
WHERE MODNAME='" . $modname . "'
AND STAFF_ID IN(0,'" . $staff_id . "')" ), array(), array( 'STAFF_ID' ) );
AND STAFF_ID IN(0,'" . $staff_id . "')", array(), array( 'STAFF_ID' ) );
if ( ! $template_RET )
{
......@@ -77,10 +77,10 @@ function SaveTemplate( $template, $modname = '', $staff_id = -1 )
$staff_id = User( 'STAFF_ID' );
}
$is_template_update = DBGet( DBQuery( "SELECT STAFF_ID
$is_template_update = DBGet( "SELECT STAFF_ID
FROM TEMPLATES
WHERE MODNAME='" . $modname . "'
AND STAFF_ID IN(0,'" . $staff_id . "')" ), array(), array( 'STAFF_ID' ) );
AND STAFF_ID IN(0,'" . $staff_id . "')", array(), array( 'STAFF_ID' ) );
if ( ! $is_template_update )
{
......
......@@ -42,11 +42,11 @@ function ThemeLiveUpdate( $new_theme, $old_theme, $default = true )
{
// Check if loaded stylesheet is the same as the new one.
// Get the value from DB as Preferences() value is overridden by THEME_FORCE!
$real_user_preferred_theme = DBGet( DBQuery( "SELECT VALUE
$real_user_preferred_theme = DBGet( "SELECT VALUE
FROM PROGRAM_USER_CONFIG
WHERE USER_ID='" . User( 'STAFF_ID' ) . "'
AND PROGRAM='Preferences'
AND TITLE='THEME'" ) );
AND TITLE='THEME'" );
if ( ! $real_user_preferred_theme
|| $real_user_preferred_theme[1]['VALUE'] === $new_theme )
......
......@@ -309,9 +309,9 @@ function _update43beta()
/**
* 1. COURSES table: Add DESCRIPTION column.
*/
$description_column_exists = DBGet( DBQuery( "SELECT 1 FROM pg_attribute
$description_column_exists = DBGet( "SELECT 1 FROM pg_attribute
WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'courses')
AND attname = 'description';" ) );
AND attname = 'description';" );
if ( ! $description_column_exists )
{
......@@ -348,9 +348,9 @@ function _update44beta()
* 1. GRADEBOOK_ASSIGNMENTS table:
* Add FILE column
*/
$file_column_exists = DBGet( DBQuery( "SELECT 1 FROM pg_attribute
$file_column_exists = DBGet( "SELECT 1 FROM pg_attribute
WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'gradebook_assignments')
AND attname = 'file';" ) );
AND attname = 'file';" );
if ( ! $file_column_exists )
{
......@@ -370,9 +370,9 @@ function _update44beta()
* 3. GRADEBOOK_ASSIGNMENTS table:
* Convert DESCRIPTION values from MarkDown to HTML.
*/
$assignments_RET = DBGet( DBQuery( "SELECT assignment_id,description
$assignments_RET = DBGet( "SELECT assignment_id,description
FROM gradebook_assignments
WHERE description IS NOT NULL;" ) );
WHERE description IS NOT NULL;" );
$assignment_update_sql = "UPDATE GRADEBOOK_ASSIGNMENTS
SET DESCRIPTION='%s'
......@@ -420,7 +420,7 @@ function _update44beta2()
/**
* 1. Add VERSION to PASSWORD_STRENGTH table.
*/
$version_added = DBGet( DBQuery( "SELECT 1 FROM CONFIG WHERE TITLE='PASSWORD_STRENGTH'" ) );
$version_added = DBGet( "SELECT 1 FROM CONFIG WHERE TITLE='PASSWORD_STRENGTH'" );
if ( ! $version_added )
{
......
......@@ -34,7 +34,7 @@ function _update29alpha()
/**
* 1. Add VERSION to CONFIG table.
*/
$version_added = DBGet( DBQuery( "SELECT 1 FROM CONFIG WHERE TITLE='VERSION'" ) );
$version_added = DBGet( "SELECT 1 FROM CONFIG WHERE TITLE='VERSION'" );
if ( ! $version_added )
{
......@@ -45,7 +45,7 @@ function _update29alpha()
/**
* 2. Add STUDENTS_EMAIL_FIELD to CONFIG table.
*/
$students_email_field_added = DBGet( DBQuery( "SELECT 1 FROM CONFIG WHERE TITLE='STUDENTS_EMAIL_FIELD'" ) );
$students_email_field_added = DBGet( "SELECT 1 FROM CONFIG WHERE TITLE='STUDENTS_EMAIL_FIELD'" );
if ( ! $students_email_field_added )
{
......@@ -83,10 +83,10 @@ function _update29alpha()
* 'comment' => 'comment1',
* )
*/
$comments_RET = DBGet( DBQuery( "SELECT SYEAR, MARKING_PERIOD_ID, STUDENT_ID, COMMENT
$comments_RET = DBGet( "SELECT SYEAR, MARKING_PERIOD_ID, STUDENT_ID, COMMENT
FROM STUDENT_MP_COMMENTS
WHERE COMMENT IS NOT NULL
AND COMMENT!=''" ) );
AND COMMENT!=''" );
if ( is_array( $comments_RET )
&& ! unserialize( $comments_RET[0]['COMMENT'] ) )
......@@ -135,8 +135,8 @@ function _update29alpha()
// 5. Create school_fields_seq Sequence.
$sequence_exists = DBGet( DBQuery( "SELECT 1 FROM pg_class
WHERE relname = 'school_fields_seq'" ) );
$sequence_exists = DBGet( "SELECT 1 FROM pg_class
WHERE relname = 'school_fields_seq'" );
if ( ! $sequence_exists )
{
......@@ -162,10 +162,10 @@ function _update29alpha()
data text
);");
$sa_constraint_exists = DBGet( DBQuery( "SELECT 1
$sa_constraint_exists = DBGet( "SELECT 1
FROM information_schema.constraint_column_usage
WHERE table_name = 'student_assignments'
AND constraint_name = 'student_assignments_pkey'" ) );
AND constraint_name = 'student_assignments_pkey'" );
if ( ! $sa_constraint_exists )
{
......@@ -173,9 +173,9 @@ function _update29alpha()
ADD CONSTRAINT student_assignments_pkey PRIMARY KEY (assignment_id, student_id);" );
}
$submission_column_exists = DBGet( DBQuery( "SELECT 1 FROM pg_attribute
$submission_column_exists = DBGet( "SELECT 1 FROM pg_attribute
WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'gradebook_assignments')
AND attname = 'submission';" ) );
AND attname = 'submission';" );
if ( ! $submission_column_exists )
{
......@@ -183,10 +183,10 @@ function _update29alpha()
ADD COLUMN submission character varying(1);" );
}
$sa_exceptions_exists = DBGet( DBQuery( "SELECT 1
$sa_exceptions_exists = DBGet( "SELECT 1
FROM profile_exceptions
WHERE profile_id IN (0,3)
AND modname='Grades/StudentAssignments.php'" ) );
AND modname='Grades/StudentAssignments.php'" );
if ( ! $sa_exceptions_exists )
{
......@@ -220,9 +220,9 @@ function _update292()
* 1. Add GP_PASSING_VALUE to REPORT_CARD_GRADE_SCALES table
* & Set minimum passing grade to '0' for already present scales.
*/
$gppassingvalue_column_exists = DBGet( DBQuery( "SELECT 1 FROM pg_attribute
$gppassingvalue_column_exists = DBGet( "SELECT 1 FROM pg_attribute
WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'report_card_grade_scales')
AND attname = 'gp_passing_value';" ) );
AND attname = 'gp_passing_value';" );
if ( ! $gppassingvalue_column_exists )
{
......@@ -257,8 +257,8 @@ function _update295()
/**
* 1. Add LIMIT_EXISTING_CONTACTS_ADDRESSES to CONFIG table.
*/
$limit_existing_contacts_addresses_field_added = DBGet( DBQuery( "SELECT 1 FROM CONFIG
WHERE TITLE='LIMIT_EXISTING_CONTACTS_ADDRESSES'" ) );
$limit_existing_contacts_addresses_field_added = DBGet( "SELECT 1 FROM CONFIG
WHERE TITLE='LIMIT_EXISTING_CONTACTS_ADDRESSES'" );
if ( ! $limit_existing_contacts_addresses_field_added )
{
......@@ -289,8 +289,8 @@ function _update2912()
/**
* 1. Add THEME_FORCE to CONFIG table.
*/
$theme_force_field_added = DBGet( DBQuery( "SELECT 1 FROM CONFIG
WHERE TITLE='THEME_FORCE'" ) );
$theme_force_field_added = DBGet( "SELECT 1 FROM CONFIG
WHERE TITLE='THEME_FORCE'" );
if ( ! $theme_force_field_added )
{
......@@ -323,18 +323,18 @@ function _update2913()
/**
* 1. Add Users/User.php&category_id=1&schools to profile_exceptions table.
*/
$admin_profiles_RET = DBGet( DBQuery( "SELECT id
$admin_profiles_RET = DBGet( "SELECT id
FROM profile_exceptions, user_profiles
WHERE profile='admin'" ) );
WHERE profile='admin'" );
foreach ( (array) $admin_profiles_RET as $admin_profile )
{
$profile_id = $admin_profile['ID'];
$as_profile_exceptions_exists = DBGet( DBQuery( "SELECT 1
$as_profile_exceptions_exists = DBGet( "SELECT 1
FROM profile_exceptions
WHERE profile_id='" . $profile_id . "'
AND modname='Users/User.php&category_id=1&schools'" ) );
AND modname='Users/User.php&category_id=1&schools'" );
if ( ! $as_profile_exceptions_exists )
{
......@@ -346,14 +346,14 @@ function _update2913()
/**
* 2. Add Users/User.php&category_id=1&schools to staff_exceptions table.
*/
$as_staff_exceptions_exists = DBGet( DBQuery( "SELECT 1
$as_staff_exceptions_exists = DBGet( "SELECT 1
FROM staff_exceptions
WHERE modname='Users/User.php&category_id=1&schools'" ) );
WHERE modname='Users/User.php&category_id=1&schools'" );
// Check if we have staff_exceptions.
$staff_exceptions_user_ids = DBGet( DBQuery( "SELECT user_id
$staff_exceptions_user_ids = DBGet( "SELECT user_id
FROM staff_exceptions
WHERE modname='Users/User.php&category_id=1'" ) );
WHERE modname='Users/User.php&category_id=1'" );
if ( ! $as_staff_exceptions_exists
&& $staff_exceptions_user_ids )
......@@ -393,9 +393,9 @@ function _update2914()
/**
* 1. Add SELECT_OPTIONS column to SCHOOL_FIELDS table.
*/
$select_options_column_exists = DBGet( DBQuery( "SELECT 1 FROM pg_attribute
$select_options_column_exists = DBGet( "SELECT 1 FROM pg_attribute
WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'school_fields')
AND attname = 'select_options';" ) );
AND attname = 'select_options';" );
if ( ! $select_options_column_exists )
{
......@@ -406,18 +406,18 @@ function _update2914()
/**
* 2. Add Users/User.php&category_id=1&user_profile to profile_exceptions table.
*/
$admin_profiles_RET = DBGet( DBQuery( "SELECT id
$admin_profiles_RET = DBGet( "SELECT id
FROM user_profiles
WHERE profile='admin'" ) );
WHERE profile='admin'" );
foreach ( (array) $admin_profiles_RET as $admin_profile )
{
$profile_id = $admin_profile['ID'];
$up_profile_exceptions_exists = DBGet( DBQuery( "SELECT 1
$up_profile_exceptions_exists = DBGet( "SELECT 1
FROM profile_exceptions
WHERE profile_id='" . $profile_id . "'
AND modname='Users/User.php&category_id=1&user_profile'" ) );
AND modname='Users/User.php&category_id=1&user_profile'" );
if ( ! $up_profile_exceptions_exists )
{
......@@ -429,14 +429,14 @@ function _update2914()
/**
* 3. Add Users/User.php&category_id=1&user_profile to staff_exceptions table.
*/
$up_staff_exceptions_exists = DBGet( DBQuery( "SELECT 1
$up_staff_exceptions_exists = DBGet( "SELECT 1
FROM staff_exceptions
WHERE modname='Users/User.php&category_id=1&user_profile'" ) );
WHERE modname='Users/User.php&category_id=1&user_profile'" );
// Check if we have staff_exceptions.
$staff_exceptions_user_ids = DBGet( DBQuery( "SELECT user_id
$staff_exceptions_user_ids = DBGet( "SELECT user_id
FROM staff_exceptions
WHERE modname='Users/User.php&category_id=1'" ) );
WHERE modname='Users/User.php&category_id=1'" );
if ( ! $up_staff_exceptions_exists
&& $staff_exceptions_user_ids )
......@@ -475,9 +475,9 @@ function _update30()
/**
* 1. Add ACCESS_LOG table.
*/
$access_log_table_exists = DBGet( DBQuery( "SELECT 1
$access_log_table_exists = DBGet( "SELECT 1
FROM pg_catalog.pg_tables
WHERE tablename = 'access_log'" ) );
WHERE tablename = 'access_log'" );
if ( ! $access_log_table_exists )
{
......@@ -493,9 +493,9 @@ function _update30()
} else {
// Add user_agent column.
$user_agent_column_exists = DBGet( DBQuery( "SELECT 1 FROM pg_attribute
$user_agent_column_exists = DBGet( "SELECT 1 FROM pg_attribute
WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'access_log')
AND attname = 'user_agent';" ) );
AND attname = 'user_agent';" );
if ( ! $user_agent_column_exists )
{
......@@ -562,18 +562,18 @@ function _update31()
/**
* 3. Add Grades/MassCreateAssignments.php to profile_exceptions table.
*/
$admin_profiles_RET = DBGet( DBQuery( "SELECT id
$admin_profiles_RET = DBGet( "SELECT id
FROM user_profiles
WHERE profile='admin'" ) );
WHERE profile='admin'" );
foreach ( (array) $admin_profiles_RET as $admin_profile )
{
$profile_id = $admin_profile['ID'];
$mca_profile_exceptions_exists = DBGet( DBQuery( "SELECT 1
$mca_profile_exceptions_exists = DBGet( "SELECT 1
FROM profile_exceptions
WHERE profile_id='" . $profile_id . "'
AND modname='Grades/MassCreateAssignments.php'" ) );
AND modname='Grades/MassCreateAssignments.php'" );
if ( ! $mca_profile_exceptions_exists )
{
......@@ -606,8 +606,8 @@ function _update35()
/**
* 1. Add FAILED_LOGIN_LIMIT to CONFIG table.
*/
$failed_login_limit_added = DBGet( DBQuery( "SELECT 1 FROM CONFIG
WHERE TITLE='FAILED_LOGIN_LIMIT'" ) );
$failed_login_limit_added = DBGet( "SELECT 1 FROM CONFIG
WHERE TITLE='FAILED_LOGIN_LIMIT'" );
if ( ! $failed_login_limit_added )
{
......@@ -638,7 +638,7 @@ function _update37beta()
/**
* 1. Add DISPLAY_NAME to CONFIG table.
*/
$display_name_added = DBGet( DBQuery( "SELECT 1 FROM CONFIG WHERE TITLE='DISPLAY_NAME'" ) );
$display_name_added = DBGet( "SELECT 1 FROM CONFIG WHERE TITLE='DISPLAY_NAME'" );
if ( ! $display_name_added )
{
......@@ -670,8 +670,8 @@ function _update39()
/**
* 1. Add DISPLAY_NAME to CONFIG table for every school.
*/
$display_name_added = DBGet( DBQuery( "SELECT 1 FROM CONFIG WHERE TITLE='DISPLAY_NAME'
AND SCHOOL_ID<>0" ) );
$display_name_added = DBGet( "SELECT 1 FROM CONFIG WHERE TITLE='DISPLAY_NAME'
AND SCHOOL_ID<>0" );
if ( ! $display_name_added )
{
......
......@@ -46,9 +46,9 @@ function _makeLetterGrade( $percent, $course_period_id = 0, $staff_id = 0, $ret
// Save courses in $_ROSARIO['_makeLetterGrade']['courses'] global var.
if ( ! isset( $_ROSARIO['_makeLetterGrade']['courses'][ $course_period_id ] ) )
{
$_ROSARIO['_makeLetterGrade']['courses'][ $course_period_id ] = DBGet( DBQuery( "SELECT DOES_BREAKOFF,GRADE_SCALE_ID
$_ROSARIO['_makeLetterGrade']['courses'][ $course_period_id ] = DBGet( "SELECT DOES_BREAKOFF,GRADE_SCALE_ID
FROM COURSE_PERIODS
WHERE COURSE_PERIOD_ID='" . $course_period_id . "'" ) );
WHERE COURSE_PERIOD_ID='" . $course_period_id . "'" );
}
$does_breakoff = $_ROSARIO['_makeLetterGrade']['courses'][ $course_period_id ][1]['DOES_BREAKOFF'];
......@@ -85,12 +85,12 @@ function _makeLetterGrade( $percent, $course_period_id = 0, $staff_id = 0, $ret
// Save grades in $_ROSARIO['_makeLetterGrade']['grades'] global var.
if ( ! isset( $_ROSARIO['_makeLetterGrade']['grades'][ $grade_scale_id ] ) )
{
$_ROSARIO['_makeLetterGrade']['grades'][ $grade_scale_id ] = DBGet( DBQuery( "SELECT TITLE,ID,BREAK_OFF,COMMENT
$_ROSARIO['_makeLetterGrade']['grades'][ $grade_scale_id ] = DBGet( "SELECT TITLE,ID,BREAK_OFF,COMMENT
FROM REPORT_CARD_GRADES
WHERE SYEAR='" . UserSyear() . "'
AND SCHOOL_ID='" . UserSchool() . "'
AND GRADE_SCALE_ID='" . $grade_scale_id . "'
ORDER BY BREAK_OFF IS NOT NULL DESC,BREAK_OFF DESC,SORT_ORDER" ) );
ORDER BY BREAK_OFF IS NOT NULL DESC,BREAK_OFF DESC,SORT_ORDER" );
}
// Fix error invalid input syntax for type numeric
......
......@@ -39,9 +39,9 @@ function _makePercentGrade( $grade_id_or_title, $course_period_id = 0, $staff_id
if ( ! isset( $_ROSARIO['_makeLetterGrade']['courses'][ $course_period_id ] ) )
{
$_ROSARIO['_makeLetterGrade']['courses'][ $course_period_id ] = DBGet( DBQuery( "SELECT DOES_BREAKOFF,GRADE_SCALE_ID
$_ROSARIO['_makeLetterGrade']['courses'][ $course_period_id ] = DBGet( "SELECT DOES_BREAKOFF,GRADE_SCALE_ID
FROM COURSE_PERIODS
WHERE COURSE_PERIOD_ID='" . $course_period_id . "'" ) );
WHERE COURSE_PERIOD_ID='" . $course_period_id . "'" );
}
$does_breakoff = $_ROSARIO['_makeLetterGrade']['courses'][ $course_period_id ][1]['DOES_BREAKOFF'];
......@@ -50,12 +50,12 @@ function _makePercentGrade( $grade_id_or_title, $course_period_id = 0, $staff_id
if ( ! isset( $_ROSARIO['_makeLetterGrade']['grades'][ $grade_scale_id ] ) )
{
$_ROSARIO['_makeLetterGrade']['grades'][ $grade_scale_id ] = DBGet( DBQuery( "SELECT TITLE,ID,BREAK_OFF
$_ROSARIO['_makeLetterGrade']['grades'][ $grade_scale_id ] = DBGet( "SELECT TITLE,ID,BREAK_OFF
FROM REPORT_CARD_GRADES
WHERE SYEAR='" . UserSyear() . "'
AND SCHOOL_ID='" . UserSchool() . "'
AND GRADE_SCALE_ID='" . $grade_scale_id . "'
ORDER BY BREAK_OFF IS NOT NULL DESC,BREAK_OFF DESC,SORT_ORDER" ) );
ORDER BY BREAK_OFF IS NOT NULL DESC,BREAK_OFF DESC,SORT_ORDER" );
}
//$grades = array('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-','F');
......
......@@ -36,9 +36,9 @@ function _makeNextSchool( $value, $column )
if ( ! $schools_RET )
{
$schools_RET = DBGet( DBQuery( "SELECT ID,TITLE
$schools_RET = DBGet( "SELECT ID,TITLE
FROM SCHOOLS WHERE
SYEAR='" . UserSyear() . "'" ), array(), array( 'ID' ) );
SYEAR='" . UserSyear() . "'", array(), array( 'ID' ) );
}
$school_title = $schools_RET[ $value ][1]['TITLE'];
......@@ -72,9 +72,9 @@ function _makeCalendar( $value, $column )
if ( ! $calendars_RET )
{
$calendars_RET = DBGet( DBQuery( "SELECT CALENDAR_ID,DEFAULT_CALENDAR,TITLE