Example #1
0
 /**
  * Presents registration forms.
  *
  * @param object $course Course info
  * @access public
  */
 function print_entry($course)
 {
     global $CFG, $USER, $form;
     $zerocost = zero_cost($course);
     if ($zerocost) {
         $manual = enrolment_factory::factory('manual');
         if (!empty($this->errormsg)) {
             $manual->errormsg = $this->errormsg;
         }
         $manual->print_entry($course);
         return;
     }
     prevent_double_paid($course);
     httpsrequired();
     if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 443) {
         // MDL-9836
         if (empty($CFG->loginhttps)) {
             print_error('httpsrequired', 'enrol_authorize');
         } else {
             $wwwsroot = str_replace('http:', 'https:', $CFG->wwwroot);
             redirect("{$wwwsroot}/course/enrol.php?id={$course->id}");
             exit;
         }
     }
     $strcourses = get_string('courses');
     $strloginto = get_string('loginto', '', $course->shortname);
     $navlinks = array();
     $navlinks[] = array('name' => $strcourses, 'link' => "{$CFG->wwwroot}/course/", 'type' => 'misc');
     $navlinks[] = array('name' => $strloginto, 'link' => null, 'type' => 'misc');
     $navigation = build_navigation($navlinks);
     print_header($strloginto, $course->fullname, $navigation);
     print_course($course, '80%');
     if ($course->password) {
         print_heading(get_string('choosemethod', 'enrol_authorize'), 'center');
     }
     print_simple_box_start('center', '80%');
     if ($USER->username == 'guest') {
         // only real guest user, not for users with guest role
         $curcost = get_course_cost($course);
         echo '<div class="mdl-align">';
         echo '<p>' . get_string('paymentrequired') . '</p>';
         echo '<p><b>' . get_string('cost') . ": {$curcost['currency']} {$curcost['cost']}" . '</b></p>';
         echo '<p><a href="' . $CFG->httpswwwroot . '/login/">' . get_string('loginsite') . '</a></p>';
         echo '</div>';
     } else {
         require_once $CFG->dirroot . '/enrol/authorize/enrol_form.php';
         $frmenrol = new enrol_authorize_form('enrol.php', compact('course'));
         if ($frmenrol->get_data()) {
             $authorizeerror = '';
             switch ($form->paymentmethod) {
                 case AN_METHOD_CC:
                     $authorizeerror = $this->cc_submit($form, $course);
                     break;
                 case AN_METHOD_ECHECK:
                     $authorizeerror = $this->echeck_submit($form, $course);
                     break;
             }
             if (!empty($authorizeerror)) {
                 error($authorizeerror);
             }
         }
         $frmenrol->display();
     }
     print_simple_box_end();
     if ($course->password) {
         $password = '';
         include $CFG->dirroot . '/enrol/manual/enrol.html';
     }
     print_footer();
 }
Example #2
0
/**
 * This functions prints tabs options
 *
 * @uses $CFG
 * @param int $courseid Course Id
 * @param int $folderid Folder Id
 * @param string $action  Actual action
 * @return boolean Success/Fail
 * @todo Finish documenting this function
 */
function email_print_tabs_options($courseid, $folderid, $action = NULL)
{
    global $CFG;
    // SSL encription
    if ($CFG->email_enable_ssl) {
        httpsrequired();
        $wwwroot = str_replace('http:', 'https:', $CFG->wwwroot);
    } else {
        $wwwroot = $CFG->wwwroot;
    }
    if ($courseid == SITEID) {
        $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
        // SYSTEM context
    } else {
        $context = get_context_instance(CONTEXT_COURSE, $courseid);
        // Course context
    }
    // Declare tab array
    $tabrow = array();
    // Tab for writting new email
    if (has_capability('block/email_list:sendmessage', $context)) {
        $tabrow[] = new email_tabobject('newmail', $wwwroot . '/blocks/email_list/email/sendmail.php?course=' . $courseid . '&amp;folderid=' . $folderid, get_string('newmail', 'block_email_list'), '<img alt="' . get_string('edit') . '" width="15" height="13" src="' . $CFG->pixpath . '/i/edit.gif" />');
    }
    if (has_capability('block/email_list:createfolder', $context)) {
        $tabrow[] = new email_tabobject('newfolderform', $CFG->wwwroot . '/blocks/email_list/email/folder.php?course=' . $courseid . '&amp;folderid=' . $folderid, get_string('newfolderform', 'block_email_list'), '<img alt="' . get_string('edit') . '" width="15" height="15" src="' . $CFG->wwwroot . '/blocks/email_list/email/images/folder_add.png" />');
    }
    /// FUTURE: Implement filters
    //$tabrow[] = new tabobject('newfilter', $CFG->wwwroot.'/blocks/email_list/email/view.php?'.$url .'&amp;action=\'newfilter\'', get_string('newfilter', 'email') );
    // If empty tabrow, add vspace. Only apply on Site Course.
    if (empty($tabrow)) {
        print_spacer(50, 1);
    }
    $tabrows = array($tabrow);
    // Print tabs, and if it's in case, selected this
    switch ($action) {
        case 'newmail':
            print_email_tabs($tabrows, 'newmail');
            break;
        case 'newfolderform':
            print_email_tabs($tabrows, 'newfolderform');
            break;
        case 'newfilter':
            print_email_tabs($tabrows, 'filter');
            break;
        default:
            print_email_tabs($tabrows);
    }
    return true;
}
Example #3
0
 */
function signup_captcha_enabled()
{
    global $CFG;
    return !empty($CFG->recaptchapublickey) && !empty($CFG->recaptchaprivatekey) && get_config('auth/email', 'recaptcha');
}
require_once 'signup_form.php';
if (empty($CFG->registerauth)) {
    print_error("Sorry, you may not use this page.");
}
$authplugin = get_auth_plugin($CFG->registerauth);
if (!$authplugin->can_signup()) {
    print_error("Sorry, you may not use this page.");
}
//HTTPS is potentially required in this page
httpsrequired();
$mform_signup = new login_signup_form();
if ($mform_signup->is_cancelled()) {
    redirect(get_login_url());
} else {
    if ($user = $mform_signup->get_data()) {
        $user->confirmed = 0;
        $user->lang = current_language();
        $user->firstaccess = time();
        $user->mnethostid = $CFG->mnet_localhost_id;
        $user->secret = random_string(15);
        $user->auth = $CFG->registerauth;
        $authplugin->user_signup($user, true);
        // prints notice and link to login/index.php
        exit;
        //never reached
Example #4
0
 /**
  * Will get called before the login page is shown, if NTLM SSO
  * is enabled, and the user is in the right network, we'll redirect
  * to the magic NTLM page for SSO...
  *
  */
 function loginpage_hook()
 {
     global $CFG, $SESSION;
     // HTTPS is potentially required
     httpsrequired();
     if (($_SERVER['REQUEST_METHOD'] === 'GET' || $_SERVER['REQUEST_METHOD'] === 'POST' && get_referer() != strip_querystring(qualified_me())) && !empty($this->config->ntlmsso_enabled) && !empty($this->config->ntlmsso_subnet) && empty($_GET['authldap_skipntlmsso']) && (isguestuser() || !isloggedin()) && address_in_subnet(getremoteaddr(), $this->config->ntlmsso_subnet)) {
         // First, let's remember where we were trying to get to before we got here
         if (empty($SESSION->wantsurl)) {
             $SESSION->wantsurl = array_key_exists('HTTP_REFERER', $_SERVER) && $_SERVER['HTTP_REFERER'] != $CFG->wwwroot && $_SERVER['HTTP_REFERER'] != $CFG->wwwroot . '/' && $_SERVER['HTTP_REFERER'] != $CFG->httpswwwroot . '/login/' && $_SERVER['HTTP_REFERER'] != $CFG->httpswwwroot . '/login/index.php' ? $_SERVER['HTTP_REFERER'] : NULL;
         }
         // Now start the whole NTLM machinery.
         if (!empty($this->config->ntlmsso_ie_fastpath)) {
             // Shortcut for IE browsers: skip the attempt page at all
             if (check_browser_version('MSIE')) {
                 $sesskey = sesskey();
                 redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_magic.php?sesskey=' . $sesskey);
             } else {
                 redirect($CFG->httpswwwroot . '/login/index.php?authldap_skipntlmsso=1');
             }
         } else {
             redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_attempt.php');
         }
     }
     // No NTLM SSO, Use the normal login page instead.
     // If $SESSION->wantsurl is empty and we have a 'Referer:' header, the login
     // page insists on redirecting us to that page after user validation. If
     // we clicked on the redirect link at the ntlmsso_finish.php page instead
     // of waiting for the redirection to happen, then we have a 'Referer:' header
     // we don't want to use at all. As we can't get rid of it, just point
     // $SESSION->wantsurl to $CFG->wwwroot (after all, we came from there).
     if (empty($SESSION->wantsurl) && get_referer() == $CFG->httpswwwroot . '/auth/ldap/ntlmsso_finish.php') {
         $SESSION->wantsurl = $CFG->wwwroot;
     }
 }