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

PHP force_current_language函数代码示例

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

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



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

示例1: login_lock_account

/**
 * Lockout user and send notification email.
 *
 * @param stdClass $user
 */
function login_lock_account($user)
{
    global $CFG;
    if ($user->mnethostid != $CFG->mnet_localhost_id) {
        return;
    }
    if (isguestuser($user)) {
        return;
    }
    if (get_user_preferences('login_lockout_ignored', 0, $user)) {
        // This user can not be locked out.
        return;
    }
    $alreadylockedout = get_user_preferences('login_lockout', 0, $user);
    set_user_preference('login_lockout', time(), $user);
    if ($alreadylockedout == 0) {
        $secret = random_string(15);
        set_user_preference('login_lockout_secret', $secret, $user);
        $oldforcelang = force_current_language($user->lang);
        $site = get_site();
        $supportuser = core_user::get_support_user();
        $data = new stdClass();
        $data->firstname = $user->firstname;
        $data->lastname = $user->lastname;
        $data->username = $user->username;
        $data->sitename = format_string($site->fullname);
        $data->link = $CFG->wwwroot . '/login/unlock_account.php?u=' . $user->id . '&s=' . $secret;
        $data->admin = generate_email_signoff();
        $message = get_string('lockoutemailbody', 'admin', $data);
        $subject = get_string('lockoutemailsubject', 'admin', format_string($site->fullname));
        if ($message) {
            // Directly email rather than using the messaging system to ensure its not routed to a popup or jabber.
            email_to_user($user, $supportuser, $subject, $message);
        }
        force_current_language($oldforcelang);
    }
}
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:42,代码来源:authlib.php


示例2: get_parent_language

/**
 * Returns parent language of current active language if defined
 *
 * @category string
 * @param string $lang null means current language
 * @return string
 */
function get_parent_language($lang = null)
{
    // Let's hack around the current language.
    if (!empty($lang)) {
        $oldforcelang = force_current_language($lang);
    }
    $parentlang = get_string('parentlanguage', 'langconfig');
    if ($parentlang === 'en') {
        $parentlang = '';
    }
    // Let's hack around the current language.
    if (!empty($lang)) {
        force_current_language($oldforcelang);
    }
    return $parentlang;
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:23,代码来源:moodlelib.php


示例3: notify_expiry_enroller

    /**
     * Notify person responsible for enrolments that some user enrolments will be expired soon,
     * it is called only if notification of enrollers (aka teachers) is enabled in course.
     *
     * This is called repeatedly every day for each course if there are any pending expiration
     * in the expiration threshold.
     *
     * @param int $eid
     * @param array $users
     * @param progress_trace $trace
     */
    protected function notify_expiry_enroller($eid, $users, progress_trace $trace) {
        global $DB;

        $name = $this->get_name();

        $instance = $DB->get_record('enrol', array('id'=>$eid, 'enrol'=>$name));
        $context = context_course::instance($instance->courseid);
        $course = $DB->get_record('course', array('id'=>$instance->courseid));

        $enroller = $this->get_enroller($instance->id);
        $admin = get_admin();

        $oldforcelang = force_current_language($enroller->lang);

        foreach($users as $key=>$info) {
            $users[$key] = '* '.$info['fullname'].' - '.userdate($info['timeend'], '', $enroller->timezone);
        }

        $a = new stdClass();
        $a->course    = format_string($course->fullname, true, array('context'=>$context));
        $a->threshold = get_string('numdays', '', $instance->expirythreshold / (60*60*24));
        $a->users     = implode("\n", $users);
        $a->extendurl = (string)new moodle_url('/enrol/users.php', array('id'=>$instance->courseid));

        $subject = get_string('expirymessageenrollersubject', 'enrol_'.$name, $a);
        $body = get_string('expirymessageenrollerbody', 'enrol_'.$name, $a);

        $message = new stdClass();
        $message->notification      = 1;
        $message->component         = 'enrol_'.$name;
        $message->name              = 'expiry_notification';
        $message->userfrom          = $admin;
        $message->userto            = $enroller;
        $message->subject           = $subject;
        $message->fullmessage       = $body;
        $message->fullmessageformat = FORMAT_MARKDOWN;
        $message->fullmessagehtml   = markdown_to_html($body);
        $message->smallmessage      = $subject;
        $message->contexturlname    = $a->course;
        $message->contexturl        = $a->extendurl;

        if (message_send($message)) {
            $trace->output("notifying user $enroller->id about all expiring $name enrolments in course $instance->courseid", 1);
        } else {
            $trace->output("error notifying user $enroller->id about all expiring $name enrolments in course $instance->courseid", 1);
        }

        force_current_language($oldforcelang);
    }
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:60,代码来源:enrollib.php


示例4: process_records

 /**
  * Process user enrolment line.
  *
  * @param progress_trace $trace
  * @param string $action
  * @param int $roleid
  * @param stdClass $user
  * @param stdClass $course
  * @param int $timestart
  * @param int $timeend
  * @param bool $buffer_if_future
  */
 protected function process_records(progress_trace $trace, $action, $roleid, $user, $course, $timestart, $timeend, $buffer_if_future = true)
 {
     global $CFG, $DB;
     // Check if timestart is for future processing.
     if ($timestart > time() and $buffer_if_future) {
         // Populate into enrol_flatfile table as a future role to be assigned by cron.
         // Note: since 2.0 future enrolments do not cause problems if you disable guest access.
         $future_en = new stdClass();
         $future_en->action = $action;
         $future_en->roleid = $roleid;
         $future_en->userid = $user->id;
         $future_en->courseid = $course->id;
         $future_en->timestart = $timestart;
         $future_en->timeend = $timeend;
         $future_en->timemodified = time();
         $DB->insert_record('enrol_flatfile', $future_en);
         $trace->output("User {$user->id} will be enrolled later into course {$course->id} using role {$roleid} ({$timestart}, {$timeend})", 1);
         return;
     }
     $context = context_course::instance($course->id);
     if ($action === 'add') {
         // Clear the buffer just in case there were some future enrolments.
         $DB->delete_records('enrol_flatfile', array('userid' => $user->id, 'courseid' => $course->id, 'roleid' => $roleid));
         $instance = $DB->get_record('enrol', array('courseid' => $course->id, 'enrol' => 'flatfile'));
         if (empty($instance)) {
             // Only add an enrol instance to the course if non-existent.
             $enrolid = $this->add_instance($course);
             $instance = $DB->get_record('enrol', array('id' => $enrolid));
         }
         $notify = false;
         if ($ue = $DB->get_record('user_enrolments', array('enrolid' => $instance->id, 'userid' => $user->id))) {
             // Update only.
             $this->update_user_enrol($instance, $user->id, ENROL_USER_ACTIVE, $timestart, $timeend);
             if (!$DB->record_exists('role_assignments', array('contextid' => $context->id, 'roleid' => $roleid, 'userid' => $user->id, 'component' => 'enrol_flatfile', 'itemid' => $instance->id))) {
                 role_assign($roleid, $user->id, $context->id, 'enrol_flatfile', $instance->id);
             }
             $trace->output("User {$user->id} enrolment updated in course {$course->id} using role {$roleid} ({$timestart}, {$timeend})", 1);
         } else {
             // Enrol the user with this plugin instance.
             $this->enrol_user($instance, $user->id, $roleid, $timestart, $timeend);
             $trace->output("User {$user->id} enrolled in course {$course->id} using role {$roleid} ({$timestart}, {$timeend})", 1);
             $notify = true;
         }
         if ($notify and $this->get_config('mailstudents')) {
             $oldforcelang = force_current_language($user->lang);
             // Send welcome notification to enrolled users.
             $a = new stdClass();
             $a->coursename = format_string($course->fullname, true, array('context' => $context));
             $a->profileurl = "{$CFG->wwwroot}/user/view.php?id={$user->id}&course={$course->id}";
             $subject = get_string('enrolmentnew', 'enrol', format_string($course->shortname, true, array('context' => $context)));
             $eventdata = new stdClass();
             $eventdata->modulename = 'moodle';
             $eventdata->component = 'enrol_flatfile';
             $eventdata->name = 'flatfile_enrolment';
             $eventdata->userfrom = $this->get_enroller($course->id);
             $eventdata->userto = $user;
             $eventdata->subject = $subject;
             $eventdata->fullmessage = get_string('welcometocoursetext', '', $a);
             $eventdata->fullmessageformat = FORMAT_PLAIN;
             $eventdata->fullmessagehtml = '';
             $eventdata->smallmessage = '';
             if (message_send($eventdata)) {
                 $trace->output("Notified enrolled user", 1);
             } else {
                 $trace->output("Failed to notify enrolled user", 1);
             }
             force_current_language($oldforcelang);
         }
         if ($notify and $this->get_config('mailteachers', 0)) {
             // Notify person responsible for enrolments.
             $enroller = $this->get_enroller($course->id);
             $oldforcelang = force_current_language($enroller->lang);
             $a = new stdClass();
             $a->course = format_string($course->fullname, true, array('context' => $context));
             $a->user = fullname($user);
             $subject = get_string('enrolmentnew', 'enrol', format_string($course->shortname, true, array('context' => $context)));
             $eventdata = new stdClass();
             $eventdata->modulename = 'moodle';
             $eventdata->component = 'enrol_flatfile';
             $eventdata->name = 'flatfile_enrolment';
             $eventdata->userfrom = get_admin();
             $eventdata->userto = $enroller;
             $eventdata->subject = $subject;
             $eventdata->fullmessage = get_string('enrolmentnewuser', 'enrol', $a);
             $eventdata->fullmessageformat = FORMAT_PLAIN;
             $eventdata->fullmessagehtml = '';
             $eventdata->smallmessage = '';
             if (message_send($eventdata)) {
//.........这里部分代码省略.........
开发者ID:evltuma,项目名称:moodle,代码行数:101,代码来源:lib.php


示例5: scheduler_get_mail_variables

/**
 * Construct an array with subtitution rules for mail templates, relating to
 * a single appointment. Any of the parameters can be null.
 * @param scheduler_instance $scheduler The scheduler instance
 * @param scheduler_slot $slot The slot data as an MVC object
 * @param user $attendant A {@link $USER} object describing the attendant (teacher)
 * @param user $attendee A {@link $USER} object describing the attendee (student)
 * @param object $course A course object relating to the ontext of the message
 * @param object $recipient A {@link $USER} object describing the recipient of the message (used for determining the message language)
 * @return array A hash with mail template substitutions
 */
function scheduler_get_mail_variables(scheduler_instance $scheduler, scheduler_slot $slot, $attendant, $attendee, $course, $recipient)
{
    global $CFG;
    $lang = scheduler_get_message_language($recipient, $course);
    // Force any string formatting to happen in the target language.
    $oldlang = force_current_language($lang);
    $tz = core_date::get_user_timezone($recipient);
    $vars = array();
    if ($scheduler) {
        $vars['MODULE'] = $scheduler->name;
        $vars['STAFFROLE'] = $scheduler->get_teacher_name();
        $vars['SCHEDULER_URL'] = $CFG->wwwroot . '/mod/scheduler/view.php?id=' . $scheduler->cmid;
    }
    if ($slot) {
        $vars['DATE'] = userdate($slot->starttime, get_string('strftimedate'), $tz);
        $vars['TIME'] = userdate($slot->starttime, get_string('strftimetime'), $tz);
        $vars['ENDTIME'] = userdate($slot->endtime, get_string('strftimetime'), $tz);
        $vars['LOCATION'] = format_string($slot->appointmentlocation);
    }
    if ($attendant) {
        $vars['ATTENDANT'] = fullname($attendant);
        $vars['ATTENDANT_URL'] = $CFG->wwwroot . '/user/view.php?id=' . $attendant->id . '&course=' . $scheduler->course;
    }
    if ($attendee) {
        $vars['ATTENDEE'] = fullname($attendee);
        $vars['ATTENDEE_URL'] = $CFG->wwwroot . '/user/view.php?id=' . $attendee->id . '&course=' . $scheduler->course;
    }
    // Reset language settings.
    force_current_language($oldlang);
    return $vars;
}
开发者ID:ninelanterns,项目名称:moodle-mod_scheduler,代码行数:42,代码来源:locallib.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP force_download函数代码示例发布时间:2022-05-15
下一篇:
PHP force_balance_tags函数代码示例发布时间: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