Commit 5ac09421 authored by François Jacquet's avatar François Jacquet

Add FirstLoginPoll() function

parent 7bf36742
......@@ -18,6 +18,7 @@ Changes in 4.6
- JS Navigate form inputs vertically using tab key in Grades.php & InputFinalGrades.php
- Performance Run multiple DELETE SQL queries at once, progam wide
- Merge Address Fields & Contact Fields programs with Student Fields program in StudentFields.php, AddressFields.php, PeopleFields.php & Menu.php
- Add FirstLoginPoll() function in FirstLogin.fnc.php
Changes in 4.5.2
----------------
......
......@@ -60,26 +60,24 @@ if ( ! function_exists( 'DoFirstLoginForm' ) )
function FirstLoginForm()
{
ob_start();
?>
<form action="index.php" method="POST">
<?php PopTable( 'header', _( 'Confirm Successful Installation' ) ); ?>
<h4 class="center">
<?php
echo sprintf(
_( 'You have successfully installed %s.' ),
ParseMLField( Config( 'TITLE' ) )
);
?>
</h4>
<p><?php echo implode( '</p><p>', FirstLoginFormFields() ); ?></p>
<p class="center"><?php echo Buttons( _( 'OK' ) ); ?></p>
<?php PopTable( 'footer' ); ?>
PopTable( 'header', _( 'Confirm Successful Installation' ) ); ?>
<form action="index.php" method="POST" id="first-login-form">
<h4 class="center">
<?php
echo sprintf(
_( 'You have successfully installed %s.' ),
ParseMLField( Config( 'TITLE' ) )
);
?>
</h4>
<p><?php echo implode( '</p><p>', FirstLoginFormFields() ); ?></p>
<p class="center"><?php echo Buttons( _( 'OK' ) ); ?></p>
</form>
<?php
<?php echo FirstLoginPoll(); ?>
<?php PopTable( 'footer' );
return ob_get_clean();
}
......@@ -98,10 +96,15 @@ if ( ! function_exists( 'FirstLoginFormFields' ) )
{
$fields = array();
$fields[] = sprintf(
_( 'Check the %s page to spot remaining configuration problems.' ),
'<a href="diagnostic.php" target="_blank">diagnostic.php</a>'
);
if ( User( 'STAFF_ID' ) === '1' )
{
// Set admin password on first login.
$fields[] = '<input type="text" name="first_login[ADMIN_PASSWORD]" id="first_login_ADMIN_PASSWORD"
$fields[] = '<br /><input type="text" name="first_login[ADMIN_PASSWORD]" id="first_login_ADMIN_PASSWORD"
size="25" maxlength="42" minlength="5" tabindex="1" required />' .
FormatInputTitle(
'<span class="legend-red">' . _( 'New Password' ) . '</span>',
......@@ -110,11 +113,123 @@ if ( ! function_exists( 'FirstLoginFormFields' ) )
);
}
return $fields;
}
}
if ( ! function_exists( 'FirstLoginPoll' ) )
{
/**
* Get First Login Poll
*
* @since 4.6
*
* @return array Poll HTML array.
*/
function FirstLoginPoll()
{
global $locale,
$_ROSARIO;
if ( User( 'STAFF_ID' ) !== '1' )
{
return false;
}
// Check if client has Internet connection.
$has_connection = @file_get_contents( 'https://www.rosariosis.org/installation-poll/poll-submit.php' );
if ( ! $has_connection )
{
// Server may be down?
return false;
}
$fields = array();
$fields[] = '<input type="hidden" name="locale" value="' . $locale . '" />';
$fields[] = '<input type="hidden" name="version" value="' . ROSARIO_VERSION . '" />';
$_ROSARIO['allow_edit'] = true;
$usage_options = array(
'testing' => _( 'Testing' ),
'production' => _( 'Production' ),
);
$fields[] = RadioInput( '', 'usage', _( 'Usage' ), $usage_options, false );
$school_options = array(
'primary' => _( 'Primary' ),
'secondary' => _( 'Secondary' ),
'superior' => _( 'Superior' ),
'other' => _( 'Other' ),
);
$fields[] = RadioInput( '', 'school', _( 'School' ), $school_options, false );
$fields[] = TextInput(
'0',
'students',
_( 'Students' ),
'type="number" min="0" max="100000" length="4"',
false
);
$_ROSARIO['allow_edit'] = false;
$fields[] = '<div class="center">' . Buttons( _( 'Submit' ), _( 'Cancel' ) ) . '</div>';
$url_lang = '';
if ( $locale === 'es_ES.utf8'
|| $locale === 'fr_FR.utf8' )
{
$url_lang = substr( $locale, 0, 2 ) . '/';
}
$fields[] = sprintf(
_( 'Check the %s page to spot remaining configuration problems.' ),
'<a href="diagnostic.php" target="_blank">diagnostic.php</a>'
_( 'Poll answers are anonymous. Consult installation statistics <a href="%s" target="_blank">online</a>.' ),
'https://www.rosariosis.org/' . $url_lang . 'installation-poll/'
);
return $fields;
ob_start(); ?>
<script src="assets/js/jquery.js"></script>
<script>$('#first-login-form').hide();
$('#first-login-poll-form input[type="reset"]').click(function(){
console.log('ici');
$('#first-login-poll-form').hide();
$('#first-login-form').show();
});
$('#first-login-poll-form').submit(function(e){
var form = $(this),
url = form.attr('action');
$('#first-login-poll-form input[type="submit"],#first-login-poll-form input[type="reset"]').attr('disabled', 'disabled');
$.ajax({
type: 'POST',
url: url,
data: form.serialize(),
complete: function(jqxhr,status) {
$('#first-login-poll-form').hide();
$('#first-login-form').show();
}
});
e.preventDefault();
});</script>
<?php
$js = ob_get_clean();
$form = '<form action="https://www.rosariosis.org/installation-poll/poll-submit.php" method="POST" id="first-login-poll-form">';
$title = '<legend>' . _( 'Installation Poll' ) . '</legend>';
return $form . '<fieldset>' . $title . implode( '</p><p>', $fields ) . '</fieldset></form>' . $js;
}
}
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