=START_DATE AND (CURRENT_DATE<=END_DATE OR END_DATE IS NULL)" ); if ( $student_account_activated ) { // @since 5.9 Automatic Student Account Activation. $message = _( 'New student account was activated for %s (%d).' ); } $message = sprintf( $message, $student_name, $student_id ); return SendEmail( $to, _( 'Create Student Account' ), $message ); } /** * Send Create User Account notification * * @since 5.9 * * @param int $staff_id Staff ID. * @param string $to To email address. Defaults to $RosarioNotifyAddress (see config.inc.php). * * @return bool False if email not sent, else true. */ function SendNotificationCreateUserAccount( $staff_id, $to = '' ) { global $RosarioNotifyAddress; require_once 'ProgramFunctions/SendEmail.fnc.php'; if ( empty( $to ) ) { $to = $RosarioNotifyAddress; } if ( ! $staff_id || ! filter_var( $to, FILTER_VALIDATE_EMAIL ) ) { return false; } $user_name = DBGetOne( "SELECT " . DisplayNameSQL() . " AS FULL_NAME FROM STAFF WHERE STAFF_ID='" . $staff_id . "'" ); $message = sprintf( _( 'New user account was created for %s (%d) (No Access).' ), $user_name, UserStaffID() ); return SendEmail( $to, _( 'Create User Account' ), $message ); } /** * Send New Administrator notification * * @since 5.9 * * @param int $staff_id Staff ID. * @param string $to To email address. Defaults to $RosarioNotifyAddress (see config.inc.php). * * @return bool False if not admin, email not sent, else true. */ function SendNotificationNewAdministrator( $staff_id, $to = '' ) { global $RosarioNotifyAddress; require_once 'ProgramFunctions/SendEmail.fnc.php'; if ( empty( $to ) ) { $to = $RosarioNotifyAddress; } if ( ! $staff_id || ! filter_var( $to, FILTER_VALIDATE_EMAIL ) ) { return false; } $is_admin_profile = DBGetOne( "SELECT 1 FROM STAFF WHERE STAFF_ID='" . $staff_id . "' AND PROFILE='admin'" ); if ( ! $is_admin_profile ) { return false; } $admin_name = DBGetOne( "SELECT " . DisplayNameSQL() . " AS FULL_NAME FROM STAFF WHERE STAFF_ID='" . $staff_id . "'" ); $message = sprintf( _( 'New Administrator account was created for %s, by %s.' ), $admin_name, User( 'NAME' ) ); return SendEmail( $to, _( 'New Administrator Account' ), $message ); } /** * Send Activate Student Account notification * Do not send notification if password not set. * Do not send notification if RosarioSIS installed on localhost (Windows typically). * * @since 5.9 * * @uses _rosarioLoginURL() function * * @param int $student_id Student ID. * @param string $to To email address. Defaults to student email (see Config( 'STUDENTS_EMAIL_FIELD' )). * * @return bool False if email not sent, else true. */ function SendNotificationActivateStudentAccount( $student_id, $to = '' ) { require_once 'ProgramFunctions/SendEmail.fnc.php'; if ( empty( $to ) ) { if ( ! Config( 'STUDENTS_EMAIL_FIELD' ) ) { return false; } // @since 5.9 Send Account Activation email notification to Student. $student_email_field = Config( 'STUDENTS_EMAIL_FIELD' ) === 'USERNAME' ? 'USERNAME' : 'CUSTOM_' . Config( 'STUDENTS_EMAIL_FIELD' ); $to = DBGetOne( "SELECT " . $student_email_field . " FROM STUDENTS WHERE STUDENT_ID='" . $student_id . "'" ); } if ( ! $student_id || ! filter_var( $to, FILTER_VALIDATE_EMAIL ) ) { return false; } $is_password_set = DBGetOne( "SELECT 1 FROM STUDENTS WHERE STUDENT_ID='" . $student_id . "' AND PASSWORD IS NOT NULL" ); if ( ! $is_password_set ) { return false; } $rosario_url = _rosarioLoginURL(); if ( ( strpos( $rosario_url, '127.0.0.1' ) !== false || strpos( $rosario_url, 'localhost' ) !== false ) && ! ROSARIO_DEBUG ) { // Do not send notification if RosarioSIS installed on localhost (Windows typically). return false; } $message = _( 'Your account was activated (%d). You can login at %s' ); $student_username = DBGetOne( "SELECT USERNAME FROM STUDENTS WHERE STUDENT_ID='" . $student_id . "'" ); $message .= "\n\n" . _( 'Username' ) . ': ' . $student_username; $message = sprintf( $message, $student_id, $rosario_url ); return SendEmail( $to, _( 'Create Student Account' ), $message ); } /** * Send Activate User Account notification * Do not send notification if password not set or "No Access" profile. * Do not send notification if RosarioSIS installed on localhost (Windows typically). * * @since 5.9 * * @uses _rosarioLoginURL() function * * @param int $staff_id User ID. * @param string $to To email address. Defaults to user email. * * @return bool False if email not sent, else true. */ function SendNotificationActivateUserAccount( $staff_id, $to = '' ) { require_once 'ProgramFunctions/SendEmail.fnc.php'; if ( empty( $to ) ) { $to = DBGetOne( "SELECT EMAIL FROM STAFF WHERE STAFF_ID='" . $staff_id . "'" ); } if ( ! $staff_id || ! filter_var( $to, FILTER_VALIDATE_EMAIL ) ) { return false; } $is_no_access_profile = DBGetOne( "SELECT 1 FROM STAFF WHERE STAFF_ID='" . $staff_id . "' AND PROFILE='none'" ); $is_password_set = DBGetOne( "SELECT 1 FROM STAFF WHERE STAFF_ID='" . $staff_id . "' AND PASSWORD IS NOT NULL" ); if ( $is_no_access_profile || ! $is_password_set ) { return false; } $rosario_url = _rosarioLoginURL(); if ( ( strpos( $rosario_url, '127.0.0.1' ) !== false || strpos( $rosario_url, 'localhost' ) !== false ) && ! ROSARIO_DEBUG ) { // Do not send notification if RosarioSIS installed on localhost (Windows typically). return false; } $message = _( 'Your account was activated (%d). You can login at %s' ); $staff_username = DBGetOne( "SELECT USERNAME FROM STAFF WHERE STAFF_ID='" . $staff_id . "'" ); $message .= "\n\n" . _( 'Username' ) . ': ' . $staff_username; $message = sprintf( $message, $staff_id, $rosario_url ); return SendEmail( $to, _( 'Create User Account' ), $message ); } /** * Send New Student Account notification * Do not send notification if password not set. * Send notification even if RosarioSIS installed on localhost (Windows typically) * because action should originate in user choice (checkbox checked). * * @since 6.1 * * @uses _rosarioLoginURL() function * * @param int $student_id Student ID. * @param string $to To email address. Defaults to student email (see Config( 'STUDENTS_EMAIL_FIELD' )). * @param string $password Plain password. * * @return bool False if email not sent, else true. */ function SendNotificationNewStudentAccount( $student_id, $to = '', $password = '' ) { require_once 'ProgramFunctions/SendEmail.fnc.php'; if ( empty( $to ) ) { if ( ! Config( 'STUDENTS_EMAIL_FIELD' ) ) { return false; } $student_email_field = Config( 'STUDENTS_EMAIL_FIELD' ) === 'USERNAME' ? 'USERNAME' : 'CUSTOM_' . Config( 'STUDENTS_EMAIL_FIELD' ); $to = DBGetOne( "SELECT " . $student_email_field . " FROM STUDENTS WHERE STUDENT_ID='" . $student_id . "'" ); } if ( ! $student_id || ! filter_var( $to, FILTER_VALIDATE_EMAIL ) ) { return false; } $is_password_set = DBGetOne( "SELECT 1 FROM STUDENTS WHERE STUDENT_ID='" . $student_id . "' AND PASSWORD IS NOT NULL" ); if ( ! $is_password_set ) { return false; } $rosario_url = _rosarioLoginURL(); $message = _( 'Your account was activated (%d). You can login at %s' ); $student_username = DBGetOne( "SELECT USERNAME FROM STUDENTS WHERE STUDENT_ID='" . $student_id . "'" ); $message .= "\n\n" . _( 'Username' ) . ': ' . $student_username; if ( $password ) { $message .= "\n" . _( 'Password' ) . ': ' . $password; } $message = sprintf( $message, $student_id, $rosario_url ); return SendEmail( $to, _( 'Student Account' ), $message ); } /** * Send New User Account notification * Do not send notification if password not set or "No Access" profile. * Send notification even if RosarioSIS installed on localhost (Windows typically) * because action should originate in user choice (checkbox checked). * * @since 6.1 * * @uses _rosarioLoginURL() function * * @param int $staff_id User ID. * @param string $to To email address. Defaults to user email. * @param string $password Plain password. * * @return bool False if email not sent, else true. */ function SendNotificationNewUserAccount( $staff_id, $to = '', $password = '' ) { require_once 'ProgramFunctions/SendEmail.fnc.php'; if ( empty( $to ) ) { $to = DBGetOne( "SELECT EMAIL FROM STAFF WHERE STAFF_ID='" . $staff_id . "'" ); } if ( ! $staff_id || ! filter_var( $to, FILTER_VALIDATE_EMAIL ) ) { return false; } $is_no_access_profile = DBGetOne( "SELECT 1 FROM STAFF WHERE STAFF_ID='" . $staff_id . "' AND PROFILE='none'" ); $is_password_set = DBGetOne( "SELECT 1 FROM STAFF WHERE STAFF_ID='" . $staff_id . "' AND PASSWORD IS NOT NULL" ); if ( $is_no_access_profile || ! $is_password_set ) { return false; } $rosario_url = _rosarioLoginURL(); $message = _( 'Your account was activated (%d). You can login at %s' ); $staff_username = DBGetOne( "SELECT USERNAME FROM STAFF WHERE STAFF_ID='" . $staff_id . "'" ); $message .= "\n\n" . _( 'Username' ) . ': ' . $staff_username; if ( $password ) { $message .= "\n" . _( 'Password' ) . ': ' . $password; } $message = sprintf( $message, $staff_id, $rosario_url ); return SendEmail( $to, _( 'User Account' ), $message ); } /** * RosarioSIS login page URL * Removes part beginning with 'Modules.php' or 'index.php' from URI. * * Local function * * @since 5.9 * * @return string Login page URL. */ function _rosarioLoginURL() { $page_url = 'http'; if ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) { $page_url .= 's'; } $page_url .= '://'; $root_pos = strpos( $_SERVER['REQUEST_URI'], 'Modules.php' ) ? strpos( $_SERVER['REQUEST_URI'], 'Modules.php' ) : strpos( $_SERVER['REQUEST_URI'], 'index.php' ); $root_uri = substr( $_SERVER['REQUEST_URI'], 0, $root_pos ); if ( $_SERVER['SERVER_PORT'] != '80' && $_SERVER['SERVER_PORT'] != '443' ) { $page_url .= $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $root_uri; } else { $page_url .= $_SERVER['SERVER_NAME'] . $root_uri; } return $page_url; }