当前位置: 首页>>代码示例>>PHP>>正文


PHP course_setup函数代码示例

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


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

示例1: cron

 /**
 * Notify users about enrolments that are going to expire soon!
 * This function is run by admin/cron.php
 * @return void
 */
 function cron()
 {
     global $CFG, $USER, $SITE;
     if (!isset($CFG->lastexpirynotify)) {
         set_config('lastexpirynotify', 0);
     }
     // notify once a day only - TODO: add some tz handling here, maybe use timestamps
     if ($CFG->lastexpirynotify == date('Ymd')) {
         return;
     }
     if ($rs = get_recordset_select('course', 'enrolperiod > 0 AND expirynotify > 0 AND expirythreshold > 0')) {
         $cronuser = clone $USER;
         $admin = get_admin();
         while ($course = rs_fetch_next_record($rs)) {
             $a = new object();
             $a->coursename = $course->shortname . '/' . $course->fullname;
             // must be processed by format_string later
             $a->threshold = $course->expirythreshold / 86400;
             $a->extendurl = $CFG->wwwroot . '/user/index.php?id=' . $course->id;
             $a->current = array();
             $a->past = array();
             $expiry = time() + $course->expirythreshold;
             $cname = $course->fullname;
             /// Get all the manual role assignments for this course that have expired.
             if (!($context = get_context_instance(CONTEXT_COURSE, $course->id))) {
                 continue;
             }
             if ($oldenrolments = get_records_sql("\n                      SELECT u.*, ra.timeend\n                        FROM {$CFG->prefix}user u\n                             JOIN {$CFG->prefix}role_assignments ra ON (ra.userid = u.id)\n                        WHERE ra.contextid = {$context->id}\n                              AND ra.timeend > 0 AND ra.timeend <= {$expiry}\n                              AND ra.enrol = 'manual'")) {
                 // inform user who can assign roles or admin
                 if ($teachers = get_users_by_capability($context, 'moodle/role:assign', '', '', '', '', '', '', false)) {
                     $teachers = sort_by_roleassignment_authority($teachers, $context);
                     $teacher = reset($teachers);
                 } else {
                     $teachers = array($admin);
                     $teacher = $admin;
                 }
                 $a->teacherstr = fullname($teacher, true);
                 foreach ($oldenrolments as $user) {
                     /// Email all users about to expire
                     $a->studentstr = fullname($user, true);
                     if ($user->timeend < $expiry - 86400) {
                         $a->past[] = fullname($user) . " <{$user->email}>";
                     } else {
                         $a->current[] = fullname($user) . " <{$user->email}>";
                         if ($course->notifystudents) {
                             // Send this guy notice
                             // setup global $COURSE properly - needed for languages
                             $USER = $user;
                             course_setup($course);
                             $a->coursename = format_string($cname);
                             $a->course = $a->coursename;
                             $strexpirynotifystudentsemail = get_string('expirynotifystudentsemail', '', $a);
                             $strexpirynotify = get_string('expirynotify');
                             email_to_user($user, $teacher, format_string($SITE->fullname) . ' ' . $strexpirynotify, $strexpirynotifystudentsemail);
                         }
                     }
                 }
                 $a->current = implode("\n", $a->current);
                 $a->past = implode("\n", $a->past);
                 if ($a->current || $a->past) {
                     foreach ($teachers as $teacher) {
                         // setup global $COURSE properly - needed for languages
                         $USER = $teacher;
                         course_setup($course);
                         $a->coursename = format_string($cname);
                         $strexpirynotifyemail = get_string('expirynotifyemail', '', $a);
                         $strexpirynotify = get_string('expirynotify');
                         email_to_user($teacher, $admin, $a->coursename . ' ' . $strexpirynotify, $strexpirynotifyemail);
                     }
                 }
             }
         }
         $USER = $cronuser;
         course_setup($SITE);
         // More environment
     }
     set_config('lastexpirynotify', date('Ymd'));
 }
开发者ID:kai707,项目名称:ITSA-backup,代码行数:83,代码来源:enrol.php

示例2: optional_param

// user id
$mode = optional_param('mode', "todaylogs", PARAM_ALPHA);
$page = optional_param('page', 0, PARAM_INT);
$perpage = optional_param('perpage', 100, PARAM_INT);
if (!($course = get_record("course", "id", $id))) {
    error("Course id is incorrect.");
}
if (!($user = get_record("user", "id", $user))) {
    error("User ID is incorrect");
}
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$personalcontext = get_context_instance(CONTEXT_USER, $user->id);
require_login();
if (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext) and !has_capability('moodle/course:view', $coursecontext)) {
    // do not require parents to be enrolled in courses ;-)
    course_setup($course);
} else {
    require_login($course);
}
if ($user->deleted) {
    print_header();
    print_heading(get_string('userdeleted'));
    print_footer();
    die;
}
// prepare list of allowed modes
$myreports = ($course->showreports and $USER->id == $user->id);
$anyreport = has_capability('moodle/user:viewuseractivitiesreport', $personalcontext);
$modes = array();
if ($myreports or $anyreport or has_capability('coursereport/outline:view', $coursecontext)) {
    $modes[] = 'outline';
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:31,代码来源:user.php

示例3: required_param

<?php

// $Id: chatinput.php,v 1.11.4.3 2008/10/08 06:41:55 dongsheng Exp $
$nomoodlecookie = true;
// Session not needed!
require '../../../config.php';
require '../lib.php';
$chat_sid = required_param('chat_sid', PARAM_ALPHANUM);
if (!($chatuser = get_record('chat_users', 'sid', $chat_sid))) {
    error('Not logged in!');
}
//Get the user theme
$USER = get_record('user', 'id', $chatuser->userid);
//Setup course, lang and theme
course_setup($chatuser->course);
ob_start();
?>
<script type="text/javascript">
scroll_active = true;
function empty_field_and_submit() {
    var cf   = document.getElementById('sendform');
    var inpf = document.getElementById('inputform');
    cf.chat_msgidnr.value = parseInt(cf.chat_msgidnr.value) + 1;
    cf.chat_message.value = inpf.chat_message.value;
    inpf.chat_message.value='';
    cf.submit();
    inpf.chat_message.focus();
    return false;
}
function setfocus() {
    document.getElementsByName("chat_message")[0].focus(); 
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:31,代码来源:chatinput.php

示例4: assignment_cron

/**
 * Function to be run periodically according to the moodle cron
 *
 * Finds all assignment notifications that have yet to be mailed out, and mails them
 */
function assignment_cron()
{
    global $CFG, $USER;
    /// first execute all crons in plugins
    if ($plugins = get_list_of_plugins('mod/assignment/type')) {
        foreach ($plugins as $plugin) {
            require_once "{$CFG->dirroot}/mod/assignment/type/{$plugin}/assignment.class.php";
            $assignmentclass = "assignment_{$plugin}";
            $ass = new $assignmentclass();
            $ass->cron();
        }
    }
    /// Notices older than 1 day will not be mailed.  This is to avoid the problem where
    /// cron has not been running for a long time, and then suddenly people are flooded
    /// with mail from the past few weeks or months
    $timenow = time();
    $endtime = $timenow - $CFG->maxeditingtime;
    $starttime = $endtime - 24 * 3600;
    /// One day earlier
    if ($submissions = assignment_get_unmailed_submissions($starttime, $endtime)) {
        $CFG->enablerecordcache = true;
        // We want all the caching we can get
        $realuser = clone $USER;
        foreach ($submissions as $key => $submission) {
            if (!set_field("assignment_submissions", "mailed", "1", "id", "{$submission->id}")) {
                echo "Could not update the mailed field for id {$submission->id}.  Not mailed.\n";
                unset($submissions[$key]);
            }
        }
        $timenow = time();
        foreach ($submissions as $submission) {
            echo "Processing assignment submission {$submission->id}\n";
            if (!($user = get_record("user", "id", "{$submission->userid}"))) {
                echo "Could not find user {$post->userid}\n";
                continue;
            }
            if (!($course = get_record("course", "id", "{$submission->course}"))) {
                echo "Could not find course {$submission->course}\n";
                continue;
            }
            /// Override the language and timezone of the "current" user, so that
            /// mail is customised for the receiver.
            $USER = $user;
            course_setup($course);
            if (!has_capability('moodle/course:view', get_context_instance(CONTEXT_COURSE, $submission->course), $user->id)) {
                echo fullname($user) . " not an active participant in " . format_string($course->shortname) . "\n";
                continue;
            }
            if (!($teacher = get_record("user", "id", "{$submission->teacher}"))) {
                echo "Could not find teacher {$submission->teacher}\n";
                continue;
            }
            if (!($mod = get_coursemodule_from_instance("assignment", $submission->assignment, $course->id))) {
                echo "Could not find course module for assignment id {$submission->assignment}\n";
                continue;
            }
            if (!$mod->visible) {
                /// Hold mail notification for hidden assignments until later
                continue;
            }
            $strassignments = get_string("modulenameplural", "assignment");
            $strassignment = get_string("modulename", "assignment");
            $assignmentinfo = new object();
            $assignmentinfo->teacher = fullname($teacher);
            $assignmentinfo->assignment = format_string($submission->name, true);
            $assignmentinfo->url = "{$CFG->wwwroot}/mod/assignment/view.php?id={$mod->id}";
            $postsubject = "{$course->shortname}: {$strassignments}: " . format_string($submission->name, true);
            $posttext = "{$course->shortname} -> {$strassignments} -> " . format_string($submission->name, true) . "\n";
            $posttext .= "---------------------------------------------------------------------\n";
            $posttext .= get_string("assignmentmail", "assignment", $assignmentinfo) . "\n";
            $posttext .= "---------------------------------------------------------------------\n";
            if ($user->mailformat == 1) {
                // HTML
                $posthtml = "<p><font face=\"sans-serif\">" . "<a href=\"{$CFG->wwwroot}/course/view.php?id={$course->id}\">{$course->shortname}</a> ->" . "<a href=\"{$CFG->wwwroot}/mod/assignment/index.php?id={$course->id}\">{$strassignments}</a> ->" . "<a href=\"{$CFG->wwwroot}/mod/assignment/view.php?id={$mod->id}\">" . format_string($submission->name, true) . "</a></font></p>";
                $posthtml .= "<hr /><font face=\"sans-serif\">";
                $posthtml .= "<p>" . get_string("assignmentmailhtml", "assignment", $assignmentinfo) . "</p>";
                $posthtml .= "</font><hr />";
            } else {
                $posthtml = "";
            }
            if (!email_to_user($user, $teacher, $postsubject, $posttext, $posthtml)) {
                echo "Error: assignment cron: Could not send out mail for id {$submission->id} to user {$user->id} ({$user->email})\n";
            }
        }
        $USER = $realuser;
        course_setup(SITEID);
        // reset cron user language, theme and timezone settings
    }
    return true;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:95,代码来源:lib.php

示例5: require_login

/**
 * This function checks that the current user is logged in and has the
 * required privileges
 *
 * This function checks that the current user is logged in, and optionally
 * whether they are allowed to be in a particular course and view a particular
 * course module.
 * If they are not logged in, then it redirects them to the site login unless
 * $autologinguest is set and {@link $CFG}->autologinguests is set to 1 in which
 * case they are automatically logged in as guests.
 * If $courseid is given and the user is not enrolled in that course then the
 * user is redirected to the course enrolment page.
 * If $cm is given and the coursemodule is hidden and the user is not a teacher
 * in the course then the user is redirected to the course home page.
 *
 * @uses $CFG
 * @uses $SESSION
 * @uses $USER
 * @uses $FULLME
 * @uses SITEID
 * @uses $COURSE
 * @param mixed $courseorid id of the course or course object
 * @param bool $autologinguest
 * @param object $cm course module object
 * @param bool $setwantsurltome Define if we want to set $SESSION->wantsurl, defaults to
 *             true. Used to avoid (=false) some scripts (file.php...) to set that variable,
 *             in order to keep redirects working properly. MDL-14495
 */
function require_login($courseorid = 0, $autologinguest = true, $cm = null, $setwantsurltome = true)
{
    global $CFG, $SESSION, $USER, $COURSE, $FULLME;
    /// setup global $COURSE, themes, language and locale
    course_setup($courseorid);
    /// If the user is not even logged in yet then make sure they are
    if (!isloggedin()) {
        //NOTE: $USER->site check was obsoleted by session test cookie,
        //      $USER->confirmed test is in login/index.php
        if ($setwantsurltome) {
            $SESSION->wantsurl = $FULLME;
        }
        if (!empty($_SERVER['HTTP_REFERER'])) {
            $SESSION->fromurl = $_SERVER['HTTP_REFERER'];
        }
        if ($autologinguest and !empty($CFG->guestloginbutton) and !empty($CFG->autologinguests) and ($COURSE->id == SITEID or $COURSE->guest)) {
            $loginguest = '?loginguest=true';
        } else {
            $loginguest = '';
        }
        if (empty($CFG->loginhttps) or $loginguest) {
            //do not require https for guest logins
            redirect($CFG->wwwroot . '/login/index.php' . $loginguest);
        } else {
            $wwwroot = str_replace('http:', 'https:', $CFG->wwwroot);
            redirect($wwwroot . '/login/index.php');
        }
        exit;
    }
    /// loginas as redirection if needed
    if ($COURSE->id != SITEID and !empty($USER->realuser)) {
        if ($USER->loginascontext->contextlevel == CONTEXT_COURSE) {
            if ($USER->loginascontext->instanceid != $COURSE->id) {
                print_error('loginasonecourse', '', $CFG->wwwroot . '/course/view.php?id=' . $USER->loginascontext->instanceid);
            }
        }
    }
    /// check whether the user should be changing password (but only if it is REALLY them)
    if (get_user_preferences('auth_forcepasswordchange') && empty($USER->realuser)) {
        $userauth = get_auth_plugin($USER->auth);
        if ($userauth->can_change_password()) {
            $SESSION->wantsurl = $FULLME;
            if ($changeurl = $userauth->change_password_url()) {
                //use plugin custom url
                redirect($changeurl);
            } else {
                //use moodle internal method
                if (empty($CFG->loginhttps)) {
                    redirect($CFG->wwwroot . '/login/change_password.php');
                } else {
                    $wwwroot = str_replace('http:', 'https:', $CFG->wwwroot);
                    redirect($wwwroot . '/login/change_password.php');
                }
            }
        } else {
            print_error('nopasswordchangeforced', 'auth');
        }
    }
    /// Check that the user account is properly set up
    if (user_not_fully_set_up($USER)) {
        $SESSION->wantsurl = $FULLME;
        redirect($CFG->wwwroot . '/user/edit.php?id=' . $USER->id . '&amp;course=' . SITEID);
    }
    /// Make sure current IP matches the one for this session (if required)
    if (!empty($CFG->tracksessionip)) {
        if ($USER->sessionIP != md5(getremoteaddr())) {
            print_error('sessionipnomatch', 'error');
        }
    }
    /// Make sure the USER has a sesskey set up.  Used for checking script parameters.
    sesskey();
    // Check that the user has agreed to a site policy if there is one
//.........这里部分代码省略.........
开发者ID:nadavkav,项目名称:rtlMoodle,代码行数:101,代码来源:moodlelib.php

示例6: get_context_instance

            }
        }
    }
}
if (!isset($coursecontext)) {
    // Has not yet been set by post.php.
    $coursecontext = get_context_instance(CONTEXT_COURSE, $forum->course);
}
if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $course->id))) {
    // For the logs
    error('Could not get the course module for the forum instance.');
}
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
// setup course variable to force form language
// fix for MDL-6926
course_setup($course->id);
require_once 'post_form.php';
$mform_post = new mod_forum_post_form('post.php', array('course' => $course, 'coursecontext' => $coursecontext, 'modcontext' => $modcontext, 'forum' => $forum, 'post' => $post));
if ($fromform = $mform_post->get_data()) {
    require_login($course, false, $cm);
    if (empty($SESSION->fromurl)) {
        $errordestination = "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}";
    } else {
        $errordestination = $SESSION->fromurl;
    }
    // TODO add attachment processing
    //$fromform->attachment = isset($_FILES['attachment']) ? $_FILES['attachment'] : NULL;
    trusttext_after_edit($fromform->message, $modcontext);
    if ($fromform->edit) {
        // Updating a post
        $fromform->id = $fromform->edit;
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:post.php

示例7: forum_cron


//.........这里部分代码省略.........
            foreach ($posts as $pid => $post) {
                // Set up the environment for the post, discussion, forum, course
                $discussion = $discussions[$post->discussion];
                $forum = $forums[$discussion->forum];
                $course = $courses[$forum->course];
                $cm =& $coursemodules[$forum->id];
                // Do some checks  to see if we can bail out now
                if (!isset($subscribedusers[$forum->id][$userto->id])) {
                    continue;
                    // user does not subscribe to this forum
                }
                // Verify user is enrollend in course - if not do not send any email
                if (!isset($userto->enrolledin[$course->id])) {
                    $userto->enrolledin[$course->id] = has_capability('moodle/course:view', get_context_instance(CONTEXT_COURSE, $course->id));
                }
                if (!$userto->enrolledin[$course->id]) {
                    // oops - this user should not receive anything from this course
                    continue;
                }
                // Get info about the sending user
                if (array_key_exists($post->userid, $users)) {
                    // we might know him/her already
                    $userfrom = $users[$post->userid];
                } else {
                    if ($userfrom = get_record('user', 'id', $post->userid)) {
                        $users[$userfrom->id] = $userfrom;
                        // fetch only once, we can add it to user list, it will be skipped anyway
                    } else {
                        mtrace('Could not find user ' . $post->userid);
                        continue;
                    }
                }
                // setup global $COURSE properly - needed for roles and languages
                course_setup($course);
                // More environment
                // Fill caches
                if (!isset($userto->viewfullnames[$forum->id])) {
                    $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
                    $userto->viewfullnames[$forum->id] = has_capability('moodle/site:viewfullnames', $modcontext);
                }
                if (!isset($userto->canpost[$discussion->id])) {
                    $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
                    $userto->canpost[$discussion->id] = forum_user_can_post($forum, $discussion, $userto, $cm, $course, $modcontext);
                }
                if (!isset($userfrom->groups[$forum->id])) {
                    if (!isset($userfrom->groups)) {
                        $userfrom->groups = array();
                        $users[$userfrom->id]->groups = array();
                    }
                    $userfrom->groups[$forum->id] = groups_get_all_groups($course->id, $userfrom->id, $cm->groupingid);
                    $users[$userfrom->id]->groups[$forum->id] = $userfrom->groups[$forum->id];
                }
                // Make sure groups allow this user to see this email
                if ($discussion->groupid > 0 and $groupmode = groups_get_activity_groupmode($cm, $course)) {
                    // Groups are being used
                    if (!groups_group_exists($discussion->groupid)) {
                        // Can't find group
                        continue;
                        // Be safe and don't send it to anyone
                    }
                    if (!groups_is_member($discussion->groupid) and !has_capability('moodle/site:accessallgroups', $modcontext)) {
                        // do not send posts from other groups when in SEPARATEGROUPS or VISIBLEGROUPS
                        continue;
                    }
                }
                // Make sure we're allowed to see it...
开发者ID:r007,项目名称:PMoodle,代码行数:67,代码来源:lib.php

示例8: setup_lang_from_browser

        if (file_exists($CFG->dataroot . '/lang/' . $lang . '_utf8') or file_exists($CFG->dirroot . '/lang/' . $lang . '_utf8')) {
            $SESSION->lang = $lang . '_utf8';
        }
    }
}
setup_lang_from_browser();
unset($lang);
if (empty($CFG->lang)) {
    if (empty($SESSION->lang)) {
        $CFG->lang = 'en_utf8';
    } else {
        $CFG->lang = $SESSION->lang;
    }
}
// set default locale and themes - might be changed again later from require_login()
course_setup();
if (!empty($CFG->opentogoogle)) {
    if (empty($USER->id)) {
        // Ignore anyone logged in
        if (!empty($_SERVER['HTTP_USER_AGENT'])) {
            if (strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot') !== false) {
                $USER = guest_user();
            } else {
                if (strpos($_SERVER['HTTP_USER_AGENT'], 'google.com') !== false) {
                    // Google
                    $USER = guest_user();
                } else {
                    if (strpos($_SERVER['HTTP_USER_AGENT'], 'Yahoo! Slurp') !== false) {
                        // Yahoo
                        $USER = guest_user();
                    } else {
开发者ID:r007,项目名称:PMoodle,代码行数:31,代码来源:setup.php

示例9: dialogue_cron


//.........这里部分代码省略.........
    $rs = get_recordset_select('dialogue_conversations', 'grouping != 0 AND grouping IS NOT NULL', 'dialogueid, grouping');
    $dialogueid = 0;
    $grouping = 0;
    $groupid = null;
    $inconversation = array();
    $newusers = array();
    while ($conversation = rs_fetch_next_record($rs)) {
        if ($dialogueid != $conversation->dialogueid || $groupid != $conversation->groupid || $grouping != $conversation->grouping) {
            if ($dialogueid == 0 || $groupid === null) {
                $dialogueid = $conversation->dialogueid;
                $groupid = $conversation->groupid;
            }
            $cm = get_coursemodule_from_instance('dialogue', $dialogueid);
            $context = get_context_instance(CONTEXT_MODULE, $cm->id);
            $users = (array) get_users_by_capability($context, 'mod/dialogue:participate', 'u.id, u.firstname, u.lastname', null, null, null, empty($groupid) ? null : $groupid, null, null, null, false);
            $managers = (array) get_users_by_capability($context, 'mod/dialogue:manage', 'u.id, u.firstname, u.lastname', null, null, null, null, null, null, null, false);
            $dialogueid = $conversation->dialogueid;
            $groupid = $conversation->groupid;
        }
        if ($grouping != $conversation->grouping) {
            if ($grouping) {
                if ($userdiff = array_diff_key($users, $inconversation, $managers)) {
                    foreach ($userdiff as $userid => $value) {
                        $newusers[$userid . ',' . $grouping] = array('userid' => $userid, 'courseid' => $cm->course, 'grouping' => $grouping);
                    }
                }
            }
            $inconversation = array();
            $grouping = $conversation->grouping;
        }
        $inconversation[$conversation->recipientid] = true;
    }
    if (!empty($dialogueid)) {
        // Finish of any remaing users
        $cm = get_coursemodule_from_instance('dialogue', $dialogueid);
        $context = get_context_instance(CONTEXT_MODULE, $cm->id);
        $users = (array) get_users_by_capability($context, 'mod/dialogue:participate', 'u.id, u.firstname, u.lastname', null, null, null, empty($groupid) ? null : $groupid, null, null, null, false);
        $managers = (array) get_users_by_capability($context, 'mod/dialogue:manage', 'u.id, u.firstname, u.lastname', null, null, null, null, null, null, null, false);
        if ($userdiff = array_diff_key($users, $inconversation, $managers)) {
            foreach ($userdiff as $userid => $value) {
                $newusers[$userid . ',' . $grouping] = array('userid' => $userid, 'courseid' => $cm->course, 'grouping' => $grouping);
            }
        }
    }
    rs_close($rs);
    if (!empty($newusers)) {
        foreach ($newusers as $key => $newuser) {
            begin_sql();
            course_setup($newuser['courseid']);
            if ($conversations = get_records('dialogue_conversations', 'grouping', $newuser['grouping'], 'id', '*', 0, 1)) {
                $conversation = array_pop($conversations);
                // we only need one to get the common field values
                if ($entry = get_records('dialogue_entries', 'conversationid', $conversation->id, 'id', '*', 0, 1)) {
                    unset($conversation->id);
                    $conversation->recipientid = $newuser['userid'];
                    $conversation->lastrecipientid = $newuser['userid'];
                    $conversation->timemodified = time();
                    $conversation->seenon = false;
                    $conversation->closed = 0;
                    $conversation = addslashes_object($conversation);
                    if (!($conversationid = insert_record('dialogue_conversations', $conversation))) {
                        rollback_sql();
                        continue;
                    }
                    $entry = array_pop($entry);
                    $srcentry = clone $entry;
                    unset($entry->id);
                    $entry->conversationid = $conversationid;
                    $entry->timecreated = $conversation->timemodified;
                    $entry->recipientid = $conversation->recipientid;
                    $entry->mailed = false;
                    $entry = addslashes_object($entry);
                    if (!($entry->id = insert_record('dialogue_entries', $entry))) {
                        rollback_sql();
                        continue;
                    }
                    $read = new stdClass();
                    $lastread = time();
                    $read->conversationid = $conversationid;
                    $read->entryid = $entry->id;
                    $read->userid = $conversation->userid;
                    $read->firstread = $lastread;
                    $read->lastread = $lastread;
                    insert_record('dialogue_read', $read);
                    if ($entry->attachment) {
                        $srcdir = dialogue_file_area($srcentry);
                        $dstdir = dialogue_file_area($entry);
                        copy($srcdir . '/' . $entry->attachment, $dstdir . '/' . $entry->attachment);
                    }
                } else {
                    mtrace('Failed to find entry for conversation: ' . $conversation->id);
                }
            } else {
                mtrace('Failed to find conversation: ' . $conversation->id);
            }
            commit_sql();
        }
    }
    return true;
}
开发者ID:netspotau,项目名称:moodle-mod_dialogue,代码行数:101,代码来源:lib.php

示例10: message_broadcast

 function message_broadcast($message, $sender)
 {
     if (empty($this->conn_sets)) {
         return true;
     }
     $now = time();
     // First of all, mark this chatroom as having had activity now
     $this->chatrooms[$message->chatid]['lastactivity'] = $now;
     foreach ($this->sets_info as $sessionid => $info) {
         // We need to get handles from users that are in the same chatroom, same group
         if ($info['chatid'] == $message->chatid && ($info['groupid'] == $message->groupid || $message->groupid == 0)) {
             // Simply give them the message
             course_setup($info['course'], $info['user']);
             $output = chat_format_message_manually($message, $info['courseid'], $sender, $info['user']);
             $this->trace('Delivering message "' . $output->text . '" to ' . $this->conn_sets[$sessionid][CHAT_CONNECTION_CHANNEL]);
             if ($output->beep) {
                 $this->write_data($this->conn_sets[$sessionid][CHAT_CONNECTION_CHANNEL], '<embed src="' . $this->_beepsoundsrc . '" autostart="true" hidden="true" />');
             }
             if ($info['quirks'] & QUIRK_CHUNK_UPDATE) {
                 $output->html .= $GLOBALS['CHAT_DUMMY_DATA'];
                 $output->html .= $GLOBALS['CHAT_DUMMY_DATA'];
                 $output->html .= $GLOBALS['CHAT_DUMMY_DATA'];
             }
             if (!$this->write_data($this->conn_sets[$sessionid][CHAT_CONNECTION_CHANNEL], $output->html)) {
                 $this->disconnect_session($sessionid);
             }
             //$this->trace('Sent to UID '.$this->sets_info[$sessionid]['userid'].': '.$message->text_);
         }
     }
 }
开发者ID:veritech,项目名称:pare-project,代码行数:30,代码来源:chatd.php

示例11: filemtime

<?php

// $Id: en.php,v 1.4.10.2 2010/01/14 10:20:29 mudrd8mz Exp $
include "../../../../config.php";
$lastmodified = filemtime("en.php");
$lifetime = 1800;
// Commenting this out since it's creating problems
// where solution seem to be hard to find...
// http://moodle.org/mod/forum/discuss.php?d=34376
//if ( function_exists('ob_gzhandler') ) {
//    ob_start("ob_gzhandler");
//}
// use course language
$courseid = optional_param('id', 1, PARAM_INT);
course_setup($courseid);
header("Content-type: application/x-javascript; charset: utf-8");
// Correct MIME type
header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT");
// See Bug #2387
header("Cache-control: max_age = -1");
header("Pragma: no-cache");
?>
// I18N constants

// LANG: "en", ENCODING: UTF-8 | ISO-8859-1
// Author: Mihai Bazon, <mishoo@infoiasi.ro>

// FOR TRANSLATORS:
//
//   1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:31,代码来源:en.php

示例12: oublog_check_view_permissions

/**
 * Checks if a user is allowed to view a blog. If not, will not return (calls
 * an error function and exits).
 *
 * @param object $oublog
 * @param object $context
 * @param object $cm
 * @return bool
 */
function oublog_check_view_permissions($oublog, $context, $cm = null)
{
    global $COURSE;
    $capability = $oublog->global ? 'mod/oublog:viewpersonal' : 'mod/oublog:view';
    switch ($oublog->maxvisibility) {
        case OUBLOG_VISIBILITY_PUBLIC:
            course_setup($oublog->course);
            return;
        case OUBLOG_VISIBILITY_LOGGEDINUSER:
            require_login(SITEID, false);
            course_setup($oublog->course);
            // Check oublog:view cap
            if (!has_capability($capability, $context)) {
                error(get_string('accessdenied', 'oublog'));
            }
            return;
        case OUBLOG_VISIBILITY_COURSEUSER:
            require_course_login($oublog->course, false, $cm);
            // Check oublog:view cap
            if (!has_capability($capability, $context)) {
                error(get_string('accessdenied', 'oublog'));
            }
            return;
        default:
            error('Unkown visibility level');
    }
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:36,代码来源:locallib.php

示例13: email_digest

 function email_digest()
 {
     global $CFG, $PERF;
     // Do digest mails if required. Note this is based on server time not
     // user time.
     $nextdigest = get_config('forumng', 'nextdigest');
     if (!$nextdigest) {
         // Run digest at next occurrence of the requested time
         $nextdigest = strtotime($CFG->digestmailtime . ':00');
         if ($nextdigest <= time()) {
             $nextdigest = strtotime('+1 day', $nextdigest);
         }
         set_config('nextdigest', $nextdigest, 'forumng');
     }
     if (time() < $nextdigest) {
         self::debug("DEBUG: Not yet time for digest");
         return;
     }
     // Run digest again next day at specified time (note: best to
     // get time again, as they may have changed it)
     $nextdigest = strtotime($CFG->digestmailtime . ':00');
     if ($nextdigest <= time()) {
         $nextdigest = strtotime('+1 day', $nextdigest);
     }
     set_config('nextdigest', $nextdigest, 'forumng');
     // OK, now build current digest
     mtrace("Beginning forum digest processing...");
     if (!empty($PERF->dbqueries)) {
         $beforequeries = $PERF->dbqueries;
     }
     $before = microtime(true);
     mtrace('Initial query: ', '');
     $list = new forum_digest_list(true);
     mtrace(round(microtime(true) - $before, 1) . 's');
     $userdigests = array();
     $oldcourse = null;
     // Forum loop
     while ($list->next_forum($forum, $cm, $context, $course)) {
         self::debug("DEBUG: Forum " . $forum->get_name() . " on course {$course->shortname} " . "(cmid {$cm->id} contextid {$context->id})");
         if (!$oldcourse || $course->id != $oldcourse->id) {
             // Finish off and clear users
             if ($oldcourse) {
                 self::digest_finish_course($oldcourse, $userdigests);
             }
             // Set up new course details
             course_setup($course);
             $oldcourse = clone $course;
         }
         // Count posts just for logging
         $postcount = 0;
         // Get subscribers to forum
         $subscribers = $forum->get_subscribers();
         self::debug("DEBUG: Subscribers before filter " . count($subscribers), '');
         self::email_filter_subscribers($course, $cm, $forum, $subscribers, true);
         self::debug(", after " . count($subscribers));
         if (count($subscribers) == 0) {
             continue;
         }
         while ($list->next_discussion($discussion)) {
             self::debug("DEBUG: Discussion " . $discussion->get_subject() . ' (' . $discussion->get_id() . ')');
             // Evaluate list of users based on this discussion (which holds
             // group info). Organise list by language, timezone and email
             // type.
             $discussionusers = array();
             foreach ($subscribers as $subscriber) {
                 if (self::subscriber_receives_discussion($forum, $discussion, $subscriber)) {
                     $discussionusers[$subscriber->id] = $subscriber;
                 }
             }
             while ($list->next_post($post, $inreplyto)) {
                 // Loop through all digest users
                 foreach ($discussionusers as $user) {
                     // Add to digest. (This will set up the user's
                     // digest if they don't already have one)
                     self::digest_add_post_for_user($user, $userdigests, $post, $inreplyto, $discussion, $forum, $cm, $course, $context);
                 }
                 $postcount++;
             }
         }
     }
     if ($oldcourse) {
         self::digest_finish_course($oldcourse, $userdigests);
     }
     $queryinfo = '';
     if (!empty($PERF->dbqueries)) {
         $queryinfo = ', ' . ($PERF->dbqueries - $beforequeries) . ' queries';
     }
     $totalpostcount = $list->get_post_count_so_far();
     mtrace("Digest processing ({$totalpostcount} new digest posts) complete, total: " . round(microtime(true) - $before, 1) . 's' . $queryinfo);
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:90,代码来源:forum_cron.php


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