• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP enrol_into_course函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中enrol_into_course函数的典型用法代码示例。如果您正苦于以下问题:PHP enrol_into_course函数的具体用法?PHP enrol_into_course怎么用?PHP enrol_into_course使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了enrol_into_course函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: check_entry

 /**
 * The other half to print_entry, this checks the form data
 *
 * This function checks that the user has completed the task on the
 * enrolment entry page and then enrolls them.
 *
 * @param    form    the form data submitted, as an object
 * @param    course  the current course, as an object
 */
 function check_entry($form, $course)
 {
     global $CFG, $USER, $SESSION, $THEME;
     if (empty($form->password)) {
         $form->password = '';
     }
     if (empty($course->password)) {
         // do not allow entry when no course password set
         // automatic login when manual primary, no login when secondary at all!!
         error('illegal enrolment attempted');
     }
     $groupid = $this->check_group_entry($course->id, $form->password);
     if (stripslashes($form->password) == $course->password or $groupid !== false) {
         if (isguestuser()) {
             // only real user guest, do not use this for users with guest role
             $USER->enrolkey[$course->id] = true;
             add_to_log($course->id, 'course', 'guest', 'view.php?id=' . $course->id, getremoteaddr());
         } else {
             /// Update or add new enrolment
             if (enrol_into_course($course, $USER, 'manual')) {
                 // force a refresh of mycourses
                 unset($USER->mycourses);
                 if ($groupid !== false) {
                     if (!groups_add_member($groupid, $USER->id)) {
                         print_error('couldnotassigngroup');
                     }
                 }
             } else {
                 print_error('couldnotassignrole');
             }
         }
         if ($SESSION->wantsurl) {
             $destination = $SESSION->wantsurl;
             unset($SESSION->wantsurl);
         } else {
             $destination = "{$CFG->wwwroot}/course/view.php?id={$course->id}";
         }
         redirect($destination);
     } else {
         if (!isset($CFG->enrol_manual_showhint) or $CFG->enrol_manual_showhint) {
             $this->errormsg = get_string('enrolmentkeyhint', '', substr($course->password, 0, 1));
         } else {
             $this->errormsg = get_string('enrolmentkeyerror', 'enrol_manual');
         }
     }
 }
开发者ID:kai707,项目名称:ITSA-backup,代码行数:55,代码来源:enrol.php


示例2: error

}
echo "<br> Context id is {$context->id}";
if (!($user = get_record('user', 'username', $username))) {
    echo 'The username ' . $username . ' is invalid';
    error("That's an invalid username");
    exit;
}
echo "<br> User is {$user->firstname} {$user->lastname}";
// If user wasn't enrolled, enrol now. Ignore otherwise.
if ($role = get_record('role', 'name', 'Student')) {
    // if (($role = get_default_course_role($course))) {
    echo "<br> The role description is {$role->description}";
    echo "<br> Calling user_has_role_assignment(\$user->id, \$role->id, \$context->id) with user_has_role_assignment({$user->id}, {$role->id}, {$context->id})";
    if (!user_has_role_assignment($user->id, $role->id, $context->id)) {
        echo "<br> User is not enroled in this course";
        if (!enrol_into_course($course, $user, 'manual')) {
            print_error('couldnotassignrole');
            echo "<br> User could NOT be enrolled into the course";
            error("User could NOT be enrolled into the course");
            exit;
        }
        echo "<br> User was just enrolled into the course";
        // force a refresh of mycourses
        unset($user->mycourses);
        if (!empty($SESSION->wantsurl)) {
            $destination = $SESSION->wantsurl;
            unset($SESSION->wantsurl);
        } else {
            $destination = "{$CFG->wwwroot}/course/view.php?id={$course->id}";
        }
        echo "<br> \$destination is set to {$destination}";
开发者ID:kaseya-university,项目名称:efront,代码行数:31,代码来源:auto-enroll.php


示例3: cc_submit


//.........这里部分代码省略.........
         email_to_admin("Error while trying to insert new data", $order);
         return "Insert record error. Admin has been notified!";
     }
     $extra = new stdClass();
     $extra->x_card_num = $form->cc;
     $extra->x_card_code = $form->cvv;
     $extra->x_exp_date = $exp_date;
     $extra->x_currency_code = $curcost['currency'];
     $extra->x_amount = $curcost['cost'];
     $extra->x_first_name = $form->firstname;
     $extra->x_last_name = $form->lastname;
     $extra->x_country = $form->cccountry;
     $extra->x_address = $form->ccaddress;
     $extra->x_state = $form->ccstate;
     $extra->x_city = $form->cccity;
     $extra->x_zip = $form->cczip;
     $extra->x_invoice_num = $order->id;
     $extra->x_description = $course->shortname;
     $extra->x_cust_id = $USER->id;
     $extra->x_email = $USER->email;
     $extra->x_customer_ip = $useripno;
     $extra->x_email_customer = empty($CFG->enrol_mailstudents) ? 'FALSE' : 'TRUE';
     $extra->x_phone = '';
     $extra->x_fax = '';
     if (!empty($CFG->an_authcode) && !empty($form->ccauthcode)) {
         $action = AN_ACTION_CAPTURE_ONLY;
         $extra->x_auth_code = $form->ccauthcode;
     } elseif (!empty($CFG->an_review)) {
         $action = AN_ACTION_AUTH_ONLY;
     } else {
         $action = AN_ACTION_AUTH_CAPTURE;
     }
     $message = '';
     if (AN_APPROVED != authorize_action($order, $message, $extra, $action, $form->cctype)) {
         email_to_admin($message, $order);
         return $message;
     }
     $SESSION->ccpaid = 1;
     // security check: don't duplicate payment
     if (AN_ACTION_AUTH_ONLY == $action) {
         // review enabled, inform payment managers and redirect the user who have paid to main page.
         $a = new stdClass();
         $a->url = "{$CFG->wwwroot}/enrol/authorize/index.php?order={$order->id}";
         $a->orderid = $order->id;
         $a->transid = $order->transid;
         $a->amount = "{$order->currency} {$order->amount}";
         $a->expireon = userdate(authorize_getsettletime($timenow + 30 * 3600 * 24));
         $a->captureon = userdate(authorize_getsettletime($timenow + intval($CFG->an_capture_day) * 3600 * 24));
         $a->course = $course->fullname;
         $a->user = fullname($USER);
         $a->acstatus = $CFG->an_capture_day > 0 ? get_string('yes') : get_string('no');
         $emailmessage = get_string('adminneworder', 'enrol_authorize', $a);
         $a = new stdClass();
         $a->course = $course->shortname;
         $a->orderid = $order->id;
         $emailsubject = get_string('adminnewordersubject', 'enrol_authorize', $a);
         $context = get_context_instance(CONTEXT_COURSE, $course->id);
         if ($paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments')) {
             foreach ($paymentmanagers as $paymentmanager) {
                 email_to_user($paymentmanager, $USER, $emailsubject, $emailmessage);
             }
         }
         redirect($CFG->wwwroot, get_string("reviewnotify", "enrol_authorize"), '30');
         return;
     }
     // Credit card captured, ENROL student now...
     if (enrol_into_course($course, $USER, 'authorize')) {
         if (!empty($CFG->enrol_mailstudents)) {
             send_welcome_messages($order->id);
         }
         if (!empty($CFG->enrol_mailteachers)) {
             $context = get_context_instance(CONTEXT_COURSE, $course->id);
             $paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments', '', '', '0', '1');
             $paymentmanager = array_shift($paymentmanagers);
             $a = new stdClass();
             $a->course = "{$course->fullname}";
             $a->user = fullname($USER);
             email_to_user($paymentmanager, $USER, get_string("enrolmentnew", '', format_string($course->shortname)), get_string('enrolmentnewuser', '', $a));
         }
         if (!empty($CFG->enrol_mailadmins)) {
             $a = new stdClass();
             $a->course = "{$course->fullname}";
             $a->user = fullname($USER);
             $admins = get_admins();
             foreach ($admins as $admin) {
                 email_to_user($admin, $USER, get_string("enrolmentnew", '', format_string($course->shortname)), get_string('enrolmentnewuser', '', $a));
             }
         }
     } else {
         email_to_admin("Error while trying to enrol " . fullname($USER) . " in '{$course->fullname}'", $order);
     }
     if ($SESSION->wantsurl) {
         $destination = $SESSION->wantsurl;
         unset($SESSION->wantsurl);
     } else {
         $destination = "{$CFG->wwwroot}/course/view.php?id={$course->id}";
     }
     load_all_capabilities();
     redirect($destination, get_string('paymentthanks', 'moodle', $course->fullname), 10);
 }
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:101,代码来源:enrol.php


示例4: redirect

    }
} else {
    redirect($CFG->wwwroot . '/index.php');
}
$id = required_param('id', PARAM_INT);
// Masoud Sadjadi: PARAM_ALPHANUM changed to PARAM_RAW to support emails being passed as user names.
// $username     = required_param('username', PARAM_ALPHANUM);
$username = required_param('username', PARAM_RAW);
$loginasguest = optional_param('loginasguest', 0, PARAM_BOOL);
// hmm, is this still needed?
if (!isloggedin()) {
    // do not use require_login here because we are usually comming from it
    redirect(get_login_url());
}
if (!($course = get_record('course', 'id', $id))) {
    print_error("That's an invalid course id");
}
if (!($context = get_context_instance(CONTEXT_COURSE, $course->id))) {
    print_error("That's an invalid course id");
}
if (!($USER = get_record('user', 'username', $username))) {
    print_error("That's an invalid username");
}
/// Users can't enroll to site course
if ($course->id != SITEID) {
    if (!enrol_into_course($course, $USER, 'auto')) {
        print_error('couldnotassignrole');
    } else {
        echo "Enrolled - " . $username;
    }
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:31,代码来源:auto_enrol.php


示例5: moodle_url

             // if the plugin auto-opens the course, then find the course this cohort enrols for and set it as the opener link
             if (get_config('auth/wp2moodle', 'autoopen') == 'yes') {
                 if ($enrolrow = $DB->get_record('enrol', array('enrol' => 'cohort', 'customint1' => $cohortrow->id, 'status' => 0))) {
                     $SESSION->wantsurl = new moodle_url('/course/view.php', array('id' => $enrolrow->courseid));
                 }
             }
         }
     }
 }
 // also optionally find a groupid we sent in, enrol this user in that group, and optionally open the course
 if (!empty($group)) {
     $ids = explode(',', $group);
     foreach ($ids as $group) {
         if ($DB->record_exists('groups', array('idnumber' => $group))) {
             $grouprow = $DB->get_record('groups', array('idnumber' => $group));
             enrol_into_course($grouprow->courseid, $user->id);
             if (!$DB->record_exists('groups_members', array('groupid' => $grouprow->id, 'userid' => $user->id))) {
                 // internally triggers groups_member_added event
                 groups_add_member($grouprow->id, $user->id);
                 //  not a component ,'enrol_wp2moodle');
             }
             // if the plugin auto-opens the course, then find the course this group is for and set it as the opener link
             if (get_config('auth/wp2moodle', 'autoopen') == 'yes') {
                 $SESSION->wantsurl = new moodle_url('/course/view.php', array('id' => $grouprow->courseid));
             }
         }
     }
 }
 // also optionally find a courseid we sent in, enrol this user in that course
 if (!empty($course)) {
     // find in table roles, record with shortname = student
开发者ID:nagyistoce,项目名称:wp2moodle-moodle,代码行数:31,代码来源:login.php


示例6: format_float

 if ((double) $course->cost < 0) {
     $cost = (double) $CFG->enrol_cost;
 } else {
     $cost = (double) $course->cost;
 }
 if ($data->payment_gross < $cost) {
     $cost = format_float($cost, 2);
     email_paypal_error_to_admin("Amount paid is not enough ({$data->payment_gross} < {$cost}))", $data);
     die;
 }
 // ALL CLEAR !
 if (!insert_record("enrol_paypal", addslashes_object($data))) {
     // Insert a transaction record
     email_paypal_error_to_admin("Error while trying to insert valid transaction", $data);
 }
 if (!enrol_into_course($course, $user, 'paypal')) {
     email_paypal_error_to_admin("Error while trying to enrol " . fullname($user) . " in '{$course->fullname}'", $data);
     die;
 } else {
     $teacher = get_teacher($course->id);
     if (!empty($CFG->enrol_mailstudents)) {
         $a->coursename = $course->fullname;
         $a->profileurl = "{$CFG->wwwroot}/user/view.php?id={$user->id}";
         email_to_user($user, $teacher, get_string("enrolmentnew", '', $course->shortname), get_string('welcometocoursetext', '', $a));
     }
     if (!empty($CFG->enrol_mailteachers)) {
         $a->course = $course->fullname;
         $a->user = fullname($user);
         email_to_user($teacher, $user, get_string("enrolmentnew", '', $course->shortname), get_string('enrolmentnewuser', '', $a));
     }
     if (!empty($CFG->enrol_mailadmins)) {
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:ipn.php


示例7: require_capability

require "../../config.php";
// Allow access only to admin
require_capability('moodle/legacy:admin', get_context_instance(CONTEXT_SYSTEM), NULL, false);
// Get mandatory params
$cid = required_param('cid', PARAM_INT);
// course
$uid = required_param('uid', PARAM_INT);
// user
$action = required_param('action', PARAM_ACTION);
// enrol OR delete
$course = get_record("course", "id", $cid);
$user = get_record("user", "id", $uid);
if ($action == 'delete') {
    delete_records('enrol_moderated', 'userid', $uid, 'courseid', $cid);
    // Send email to student
    $a->site = $SITE->shortname;
    $a->course = $course->shortname;
    $subject = get_string('applicationsubject', 'enrol_moderated', $a);
    $body = get_string('applicationbodyrejected', 'enrol_moderated');
    email_to_user($user, $SITE->shortname, $subject, $body);
    redirect($CFG->wwwroot . '/enrol/moderated/show_requests.php', get_string('applicationrejected', 'enrol_moderated'), 3);
}
if ($action == 'enrol') {
    if (!enrol_into_course($course, $user, 'moderated')) {
        print_error('couldnotassignrole');
    }
    delete_records('enrol_moderated', 'userid', $uid, 'courseid', $cid);
    // No needo to send email because enrol_into_course() sends it.
    redirect($CFG->wwwroot . '/enrol/moderated/show_requests.php', get_string('applicationaproved', 'enrol_moderated'), 3);
}
开发者ID:jk3us,项目名称:enrol_moderated,代码行数:30,代码来源:process_request.php


示例8: enrol_user

 /**
  * Enrols user to course with the default role
  *
  * @param string $username   The username of the remote use
  * @param int    $courseid   The id of the local course
  * @return bool              Whether the enrolment has been successful
  */
 function enrol_user($user, $courseid)
 {
     global $MNET, $MNET_REMOTE_CLIENT;
     $userrecord = get_record('user', 'username', addslashes($user['username']), 'mnethostid', $MNET_REMOTE_CLIENT->id);
     if ($userrecord == false) {
         // We should at least be checking that we allow the remote
         // site to create users
         // TODO: more rigour here thanks!
         $userrecord = new stdClass();
         $userrecord->username = addslashes($user['username']);
         $userrecord->email = addslashes($user['email']);
         $userrecord->firstname = addslashes($user['firstname']);
         $userrecord->lastname = addslashes($user['lastname']);
         $userrecord->mnethostid = $MNET_REMOTE_CLIENT->id;
         if ($userrecord->id = insert_record('user', $userrecord)) {
             $userrecord = get_record('user', 'id', $userrecord->id);
         } else {
             // TODO: Error out
             return false;
         }
     }
     if (!($course = get_record('course', 'id', $courseid))) {
         // TODO: Error out
         return false;
     }
     $courses = $this->available_courses();
     if (!empty($courses[$courseid])) {
         if (enrol_into_course($course, $userrecord, 'mnet')) {
             return true;
         }
     }
     return false;
 }
开发者ID:r007,项目名称:PMoodle,代码行数:40,代码来源:enrol.php


示例9: unset

     if (isguestuser()) {
         $is_guest = TRUE;
     }
 } else {
     if (function_exists(isguest)) {
         if (isguest()) {
             $is_guest = TRUE;
         }
     }
 }
 if ($is_guest) {
     $json_output["enrol"] = true;
 } else {
     require_once "{$CFG->dirroot}/enrol/manual/enrol.php";
     if (function_exists(enrol_into_course)) {
         if (enrol_into_course($course, $USER, 'manual')) {
             unset($USER->mycourses);
             $json_output["enrol"] = true;
         } else {
             $json_output["errors"][] = "Error enrolling student into course.";
         }
     } else {
         // For older versions of Moodle.
         $timestart = time();
         $timeend = $timestart + $course->enrolperiod;
         if (enrol_student($USER->id, $course->id, $timestart, $timeend, 'manual')) {
             $json_output["enrol"] = true;
             unset($USER->mycourses);
         } else {
             $json_output["errors"][] = "Error enrolling student into course.";
         }
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:31,代码来源:main.php


示例10: authorize_print_order_details

/**
 * authorize_print_order_details
 *
 * @param int $orderno
 */
function authorize_print_order_details($orderno)
{
    global $CFG, $USER;
    global $strs, $authstrs;
    $cmdcapture = optional_param(ORDER_CAPTURE, '', PARAM_ALPHA);
    $cmddelete = optional_param(ORDER_DELETE, '', PARAM_ALPHA);
    $cmdrefund = optional_param(ORDER_REFUND, '', PARAM_ALPHA);
    $cmdvoid = optional_param(ORDER_VOID, '', PARAM_ALPHA);
    $unenrol = optional_param('unenrol', 0, PARAM_BOOL);
    $confirm = optional_param('confirm', 0, PARAM_BOOL);
    $table = new stdClass();
    $table->width = '100%';
    $table->size = array('30%', '70%');
    $table->align = array('right', 'left');
    $order = get_record('enrol_authorize', 'id', $orderno);
    if (!$order) {
        notice("Order {$orderno} not found.", "index.php");
        return;
    }
    $course = get_record('course', 'id', $order->courseid);
    $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
    if ($USER->id != $order->userid) {
        // Current user viewing someone else's order
        require_capability('enrol/authorize:managepayments', $coursecontext);
    }
    echo "<form action=\"index.php\" method=\"post\">\n";
    echo "<div>";
    echo "<input type=\"hidden\" name=\"order\" value=\"{$orderno}\" />\n";
    echo "<input type=\"hidden\" name=\"sesskey\" value=\"" . sesskey() . "\" />";
    $settled = authorize_settled($order);
    $status = authorize_get_status_action($order);
    $table->data[] = array("<b>{$authstrs->paymentmethod}:</b>", $order->paymentmethod == AN_METHOD_CC ? $authstrs->methodcc : $authstrs->methodecheck);
    $table->data[] = array("<b>{$authstrs->orderid}:</b>", $orderno);
    $table->data[] = array("<b>{$authstrs->transid}:</b>", $order->transid);
    $table->data[] = array("<b>{$authstrs->amount}:</b>", "{$order->currency} {$order->amount}");
    if (empty($cmdcapture) and empty($cmdrefund) and empty($cmdvoid) and empty($cmddelete)) {
        $color = authorize_get_status_color($status->status);
        $table->data[] = array("<b>{$strs->course}:</b>", format_string($course->shortname));
        $table->data[] = array("<b>{$strs->status}:</b>", "<font style='color:{$color}'>" . $authstrs->{$status->status} . "</font>");
        if ($order->paymentmethod == AN_METHOD_CC) {
            $table->data[] = array("<b>{$authstrs->nameoncard}:</b>", $order->ccname);
        } else {
            $table->data[] = array("<b>{$authstrs->echeckfirslasttname}:</b>", $order->ccname);
        }
        $table->data[] = array("<b>{$strs->time}:</b>", userdate($order->timecreated));
        $table->data[] = array("<b>{$authstrs->settlementdate}:</b>", $settled ? userdate($order->settletime) : $authstrs->notsettled);
    }
    $table->data[] = array("&nbsp;", "<hr size='1' />\n");
    if (!empty($cmdcapture) and confirm_sesskey()) {
        // CAPTURE
        if (!in_array(ORDER_CAPTURE, $status->actions)) {
            $a = new stdClass();
            $a->action = $authstrs->capture;
            print_error('youcantdo', 'enrol_authorize', '', $a);
        }
        if (empty($confirm)) {
            $strcaptureyes = get_string('captureyes', 'enrol_authorize');
            $table->data[] = array("<b>{$strs->confirm}:</b>", "{$strcaptureyes} <br />\n            <input type='hidden' name='confirm' value='1' /><input type='submit' name='" . ORDER_CAPTURE . "' value='{$authstrs->capture}' />\n            &nbsp;&nbsp;&nbsp;<a href='index.php?order={$orderno}'>{$strs->no}</a>");
        } else {
            $message = '';
            $extra = NULL;
            if (AN_APPROVED != authorize_action($order, $message, $extra, AN_ACTION_PRIOR_AUTH_CAPTURE)) {
                $table->data[] = array("<b><font color='red'>{$strs->error}:</font></b>", $message);
            } else {
                if (empty($CFG->an_test)) {
                    $user = get_record('user', 'id', $order->userid);
                    if (enrol_into_course($course, $user, 'authorize')) {
                        if (!empty($CFG->enrol_mailstudents)) {
                            send_welcome_messages($order->id);
                        }
                        redirect("index.php?order={$orderno}");
                    } else {
                        $table->data[] = array("<b><font color='red'>{$strs->error}:</font></b>", "Error while trying to enrol " . fullname($user) . " in '" . format_string($course->shortname) . "'");
                    }
                } else {
                    $table->data[] = array(get_string('testmode', 'enrol_authorize'), get_string('testwarning', 'enrol_authorize'));
                }
            }
        }
        print_table($table);
    } elseif (!empty($cmdrefund) and confirm_sesskey()) {
        // REFUND
        if (!in_array(ORDER_REFUND, $status->actions)) {
            $a = new stdClass();
            $a->action = $authstrs->refund;
            print_error('youcantdo', 'enrol_authorize', '', $a);
        }
        $refunded = 0.0;
        $sql = "SELECT SUM(amount) AS refunded FROM {$CFG->prefix}enrol_authorize_refunds " . "WHERE (orderid = '" . $orderno . "') AND (status = '" . AN_STATUS_CREDIT . "')";
        if ($refundval = get_field_sql($sql)) {
            $refunded = floatval($refundval);
        }
        $upto = round($order->amount - $refunded, 2);
        if ($upto <= 0) {
            error("Refunded to original amount.");
//.........这里部分代码省略.........
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:101,代码来源:locallib.php


示例11: cc_submit


//.........这里部分代码省略.........
             // see also: admin/cron.php, $this->cron(), $CFG->an_capture_day...
             case AN_ACTION_AUTH_ONLY:
                 $a = new stdClass();
                 $a->url = "{$CFG->wwwroot}/enrol/authorize/index.php?order={$order->id}";
                 $a->orderid = $order->id;
                 $a->transid = $order->transid;
                 $a->amount = "{$order->currency} {$order->amount}";
                 $a->expireon = userdate(AuthorizeNet::getsettletime($timenow + 30 * 3600 * 24));
                 $a->captureon = userdate(AuthorizeNet::getsettletime($timenow + intval($CFG->an_capture_day) * 3600 * 24));
                 $a->course = $course->fullname;
                 $a->user = fullname($USER);
                 $a->acstatus = $CFG->an_capture_day > 0 ? get_string('yes') : get_string('no');
                 $emailmessage = get_string('adminneworder', 'enrol_authorize', $a);
                 $a = new stdClass();
                 $a->course = $course->shortname;
                 $a->orderid = $order->id;
                 $emailsubject = get_string('adminnewordersubject', 'enrol_authorize', $a);
                 $context = get_context_instance(CONTEXT_COURSE, $course->id);
                 if ($paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments')) {
                     foreach ($paymentmanagers as $paymentmanager) {
                         $eventdata = new object();
                         $eventdata->modulename = 'moodle';
                         $eventdata->userfrom = $USER;
                         $eventdata->userto = $paymentmanager;
                         $eventdata->subject = $emailsubject;
                         $eventdata->fullmessage = $emailmessage;
                         $eventdata->fullmessageformat = FORMAT_PLAIN;
                         $eventdata->fullmessagehtml = '';
                         $eventdata->smallmessage = '';
                         events_trigger('message_send', $eventdata);
                     }
                 }
                 redirect($CFG->wwwroot, get_string("reviewnotify", "enrol_authorize"), '30');
                 break;
             case AN_ACTION_CAPTURE_ONLY:
                 // auth code received via phone and the code accepted.
             // auth code received via phone and the code accepted.
             case AN_ACTION_AUTH_CAPTURE:
                 // Credit card captured, ENROL student now...
                 if (enrol_into_course($course, $USER, 'authorize')) {
                     if (!empty($CFG->enrol_mailstudents)) {
                         send_welcome_messages($order->id);
                     }
                     if (!empty($CFG->enrol_mailteachers)) {
                         $context = get_context_instance(CONTEXT_COURSE, $course->id);
                         $paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments', '', '', '0', '1');
                         $paymentmanager = array_shift($paymentmanagers);
                         $a = new stdClass();
                         $a->course = "{$course->fullname}";
                         $a->user = fullname($USER);
                         $eventdata = new object();
                         $eventdata->modulename = 'moodle';
                         $eventdata->userfrom = $USER;
                         $eventdata->userto = $paymentmanager;
                         $eventdata->subject = get_string("enrolmentnew", '', format_string($course->shortname));
                         $eventdata->fullmessage = get_string('enrolmentnewuser', '', $a);
                         $eventdata->fullmessageformat = FORMAT_PLAIN;
                         $eventdata->fullmessagehtml = '';
                         $eventdata->smallmessage = '';
                         events_trigger('message_send', $eventdata);
                     }
                     if (!empty($CFG->enrol_mailadmins)) {
                         $a = new stdClass();
                         $a->course = "{$course->fullname}";
                         $a->user = fullname($USER);
                         $admins = get_admins();
                         foreach ($admins as $admin) {
                             $eventdata = new object();
                             $eventdata->modulename = 'moodle';
                             $eventdata->userfrom = $USER;
                             $eventdata->userto = $admin;
                             $eventdata->subject = get_string("enrolmentnew", '', format_string($course->shortname));
                             $eventdata->fullmessage = get_string('enrolmentnewuser', '', $a);
                             $eventdata->fullmessageformat = FORMAT_PLAIN;
                             $eventdata->fullmessagehtml = '';
                             $eventdata->smallmessage = '';
                             events_trigger('message_send', $eventdata);
                         }
                     }
                 } else {
                     message_to_admin("Error while trying to enrol " . fullname($USER) . " in '{$course->fullname}'", $order);
                 }
                 load_all_capabilities();
                 echo $OUTPUT->box_start('generalbox notice');
                 echo '<p>' . get_string('paymentthanks', 'moodle', $course->fullname) . '</p>';
                 echo $OUTPUT->container_start('buttons');
                 echo $OUTPUT->button(html_form::make_button("{$CFG->wwwroot}/enrol/authorize/index.php", array('order' => $order->id), get_string('payments')));
                 echo $OUTPUT->button(html_form::make_button("{$CFG->wwwroot}/course/view.php", array('id' => $course->id), $course->fullname));
                 echo $OUTPUT->container_end();
                 echo $OUTPUT->box_end();
                 echo $OUTPUT->footer();
                 exit;
                 // break;
         }
         return NULL;
     } else {
         message_to_admin($message, $order);
         return $message;
     }
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:101,代码来源:enrol.php


示例12: authorize_print_order

/**
 * authorize_print_order
 *
 * @param object $order
 */
function authorize_print_order($orderid)
{
    global $CFG, $USER, $DB, $OUTPUT, $PAGE;
    global $strs, $authstrs;
    $plugin = enrol_get_plugin('authorize');
    $an_test = $plugin->get_config('an_test');
    $do = optional_param('do', '', PARAM_ALPHA);
    $unenrol = optional_param('unenrol', 0, PARAM_BOOL);
    $confirm = optional_param('confirm', 0, PARAM_BOOL);
    if (!($order = $DB->get_record('enrol_authorize', array('id' => $orderid)))) {
        print_error('orderidnotfound', '', "{$CFG->wwwroot}/enrol/authorize/index.php", $orderid);
    }
    if (!($course = $DB->get_record('course', array('id' => $order->courseid)))) {
        print_error('invalidcourseid', '', "{$CFG->wwwroot}/enrol/authorize/index.php");
    }
    if (!($user = $DB->get_record('user', array('id' => $order->userid)))) {
        print_error('nousers', '', "{$CFG->wwwroot}/enrol/authorize/index.php");
    }
    $coursecontext = context_course::instance($course->id);
    if ($USER->id != $order->userid) {
        // Current user viewing someone else's order
        require_capability('enrol/authorize:managepayments', $coursecontext);
    }
    $settled = AuthorizeNet::settled($order);
    $statusandactions = authorize_get_status_action($order);
    $color = authorize_get_status_color($statusandactions->status);
    $buttons = '';
    if (empty($do)) {
        if (empty($statusandactions->actions)) {
            if (AN_METHOD_ECHECK == $order->paymentmethod && has_capability('enrol/authorize:uploadcsv', context_user::instance($USER->id))) {
                $buttons .= "<form method='get' action='uploadcsv.php'><div><input type='submit' value='" . get_string('uploadcsv', 'enrol_authorize') . "' /></div></form>";
            }
        } else {
            foreach ($statusandactions->actions as $val) {
                $buttons .= authorize_print_action_button($orderid, $val);
            }
        }
    }
    if (SITEID != $course->id) {
        $shortname = format_string($course->shortname, true, array('context' => $coursecontext));
        $PAGE->navbar->add($shortname, new moodle_url('/course/view.php', array('id' => $course->id)));
    }
    $PAGE->navbar->add($authstrs->paymentmanagement, 'index.php?course=' . $course->id);
    $PAGE->navbar->add($authstrs->orderid . ': ' . $orderid, 'index.php');
    $PAGE->set_course($course);
    $PAGE->set_title("{$course->shortname}: {$authstrs->paymentmanagement}");
    $PAGE->set_heading($authstrs->orderdetails);
    $PAGE->set_cacheable(false);
    $PAGE->set_button($buttons);
    echo $OUTPUT->header();
    $table = new html_table();
    $table->width = '100%';
    $table->size = array('30%', '70%');
    $table->align = array('right', 'left');
    if (AN_METHOD_CC == $order->paymentmethod) {
        $table->data[] = array("<b>{$authstrs->paymentmethod}:</b>", $authstrs->methodcc);
        $table->data[] = array("<b>{$authstrs->nameoncard}:</b>", $order->ccname . ' (<b><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '">' . fullname($user) . '</a></b>)');
        $table->data[] = array("<b>{$authstrs->cclastfour}:</b>", $order->refundinfo);
    } else {
        $table->data[] = array("<b>{$authstrs->paymentmethod}:</b>", $authstrs->methodecheck);
        $table->data[] = array("<b>{$authstrs->echeckfirslasttname}:</b>", $order->ccname . ' (<b><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '">' . fullname($user) . '</a></b>)');
        $table->data[] = array("<b>{$authstrs->isbusinesschecking}:</b>", $order->refundinfo == 1 ? $strs->yes : $strs->no);
    }
    $table->data[] = array("<b>{$authstrs->amount}:</b>", "{$order->currency} {$order->amount}");
    $table->data[] = array("<b>{$authstrs->transid}:</b>", $order->transid);
    $table->data[] = array("<b>{$strs->time}:</b>", userdate($order->timecreated));
    $table->data[] = array("<b>{$authstrs->settlementdate}:</b>", $settled ? userdate($order->settletime) : $authstrs->notsettled);
    $table->data[] = array("<b>{$strs->status}:</b>", "<b><font style='color:{$color}'>" . $authstrs->{$statusandactions->status} . "</font></b>");
    if (ORDER_CAPTURE == $do && in_array(ORDER_CAPTURE, $statusandactions->actions)) {
        if ($confirm && confirm_sesskey()) {
            $message = '';
            $extra = NULL;
            if (AN_APPROVED == AuthorizeNet::process($order, $message, $extra, AN_ACTION_PRIOR_AUTH_CAPTURE)) {
                if (empty($an_test)) {
                    if (enrol_into_course($course, $user, 'authorize')) {
                        if ($plugin->get_config('enrol_mailstudents')) {
                            send_welcome_messages($orderid);
                        }
                        redirect("{$CFG->wwwroot}/enrol/authorize/index.php?order={$orderid}");
                    } else {
                        $shortname = format_string($course->shortname, true, array('context' => $coursecontext));
                        redirect("{$CFG->wwwroot}/enrol/authorize/index.php?order={$orderid}", "Error while trying to enrol " . fullname($user) . " in '" . $shortname . "'", 20);
                    }
                } else {
                    redirect("{$CFG->wwwroot}/enrol/authorize/index.php?order={$orderid}", get_string('testwarning', 'enrol_authorize'), 10);
                }
            } else {
                redirect("{$CFG->wwwroot}/enrol/authorize/index.php?order={$orderid}", $message, 20);
            }
        }
        $table->data[] = array("<b>{$strs->confirm}:</b>", get_string('captureyes', 'enrol_authorize') . '<br />' . authorize_print_action_button($orderid, ORDER_CAPTURE, 0, true, false, $strs->no));
        echo html_writer::table($table);
    } elseif (ORDER_REFUND == $do && in_array(ORDER_REFUND, $statusandactions->actions)) {
        $refunded = 0.0;
        $sql = "SELECT SUM(amount) AS refunded\n                  FROM {enrol_authorize_refunds}\n                 WHERE (orderid = ?)\n                   AND (status = ?)";
//.........这里部分代码省略.........
开发者ID:JP-Git,项目名称:moodle,代码行数:101,代码来源:locallib.php


示例13: enrol

 /**
  * Enrols the current user in the specified course
  * NOTE: a side effect of this is that it logs-in the user
  * @param object $sloodle_course A {@link SloodleCourse} object setup for the necessary course. If null, then the {@link $_session} member is queried instead.
  * @param bool True if successful (or the user was already enrolled), or false otherwise
  * @access public
  */
 function enrol($sloodle_course = null)
 {
     global $USER, $CFG;
     // Attempt to log-in the user
     if (!$this->login()) {
         return false;
     }
     // Was course data provided?
     if (empty($sloodle_course)) {
         // No - attempt to get some from the Sloodle session
         if (empty($this->_session)) {
             return false;
         }
         if (empty($this->_session->course)) {
             return false;
         }
         $sloodle_course = $this->_session->course;
     }
     // NOTE: much of this stuff was lifted from the Moodle 1.8 "course/enrol.php" script
     // Fetch the Moodle course data, and a course context
     $course = $sloodle_course->get_course_object();
     if (!($context = get_context_instance(CONTEXT_COURSE, $course->id))) {
         return false;
     }
     // Ensure we have up-to-date capabilities for the current user
     load_all_capabilities();
     // Check if the user can view the course, and does not simply have guest access to it
     // (No point trying to enrol somebody if they are already enrolled!)
     if (has_capability('moodle/course:view', $context) && !has_capability('moodle/legacy:guest', $context, NULL, false)) {
         return true;
     }
     // Make sure auto-registration is enabled for this site/course, and that the controller (if applicable) is enabled
     if (!$sloodle_course->check_autoreg()) {
         return false;
     }
     // Can't enrol users on meta courses or the site course
     if ($course->metacourse || $course->id == SITEID) {
         return false;
     }
     // Is there an enrolment period in effect?
     if ($course->enrolperiod) {
         if ($roles = get_user_roles($context, $USER->id)) {
             foreach ($roles as $role) {
                 if ($role->timestart && $role->timestart >= time()) {
                     return false;
                 }
             }
         }
     }
     // Make sure the course is enrollable
     if (!$course->enrollable || $course->enrollable == 2 && $course->enrolstartdate > 0 && $course->enrolstartdate > time() || $course->enrollable == 2 && $course->enrolenddate > 0 && $course->enrolenddate <= time()) {
         return false;
     }
     // Finally, after all that, enrol the user
     if (!enrol_into_course($course, $USER, 'manual')) {
         return false;
     }
     // Everything seems fine
     // Log the auto-enrolment
     add_to_log($course->id, 'sloodle', 'update', '', 'auto-enrolment');
     return true;
 }
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:69,代码来源:user.php



注:本文中的enrol_into_course函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP enrol_is_enabled函数代码示例发布时间:2022-05-15
下一篇:
PHP enrol_get_users_courses函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap