本文整理汇总了PHP中usergetmidnight函数的典型用法代码示例。如果您正苦于以下问题:PHP usergetmidnight函数的具体用法?PHP usergetmidnight怎么用?PHP usergetmidnight使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了usergetmidnight函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: report_participation_get_time_options
/**
* Return time options, which should be shown for record filtering.
*
* @param int $minlog Time of first log record available.
* @return array time options.
*/
function report_participation_get_time_options($minlog)
{
$timeoptions = array();
$now = usergetmidnight(time());
// Days.
for ($i = 1; $i < 7; $i++) {
if (strtotime('-' . $i . ' days', $now) >= $minlog) {
$timeoptions[strtotime('-' . $i . ' days', $now)] = get_string('numdays', 'moodle', $i);
}
}
// Weeks.
for ($i = 1; $i < 10; $i++) {
if (strtotime('-' . $i . ' weeks', $now) >= $minlog) {
$timeoptions[strtotime('-' . $i . ' weeks', $now)] = get_string('numweeks', 'moodle', $i);
}
}
// Months.
for ($i = 2; $i < 12; $i++) {
if (strtotime('-' . $i . ' months', $now) >= $minlog) {
$timeoptions[strtotime('-' . $i . ' months', $now)] = get_string('nummonths', 'moodle', $i);
}
}
// Try a year.
if (strtotime('-1 year', $now) >= $minlog) {
$timeoptions[strtotime('-1 year', $now)] = get_string('lastyear');
}
return $timeoptions;
}
开发者ID:evltuma,项目名称:moodle,代码行数:34,代码来源:locallib.php
示例2: __construct
function __construct($script, $value, $params, $extra)
{
$this->key = 'date_referred';
$this->value = $this->get_value_or_default($value);
$this->params = $params;
$this->script = $script;
$this->now = usergetmidnight(time()) + 60 * 60 * 23 + 3599;
}
开发者ID:rrusso,项目名称:EARS,代码行数:8,代码来源:lib.php
示例3: get_all_elements
function get_all_elements() {
$elements = array();
$components = cr_unserialize($this->config->components);
$config = (isset($components['timeline']['config'])) ? $components['timeline']['config'] : new stdclass();
if (isset($config->timemode)) {
$daysecs = 60 * 60 * 24;
if ($config->timemode == 'previous') {
$config->starttime = gmmktime() - $config->previousstart * $daysecs;
$config->endtime = gmmktime() - $config->previousend * $daysecs;
if (isset($config->forcemidnight)) {
$config->starttime = usergetmidnight($config->starttime);
$config->endtime = usergetmidnight($config->endtime) + ($daysecs - 1);
}
}
$filter_starttime = optional_param('filter_starttime', 0, PARAM_RAW);
$filter_endtime = optional_param('filter_endtime', 0, PARAM_RAW);
if ($filter_starttime and $filter_endtime) {
$filter_starttime = make_timestamp($filter_starttime['year'], $filter_starttime['month'], $filter_starttime['day']);
$filter_endtime = make_timestamp($filter_endtime['year'], $filter_endtime['month'], $filter_endtime['day']);
$config->starttime = usergetmidnight($filter_starttime);
$config->endtime = usergetmidnight($filter_endtime) + 24 * 60 * 60;
}
for ($i = $config->starttime; $i < $config->endtime; $i += $config->interval * $daysecs) {
$row = new stdclass();
$row->id = $i;
$row->starttime = $i;
$row->endtime = $row->starttime + ($config->interval * $daysecs - 1);
if ($row->endtime > $config->endtime)
$row->endtime = $config->endtime;
$this->timeline[$row->starttime] = $row;
$elements[] = $row->starttime;
}
if ($config->ordering == 'desc')
rsort($elements);
}
return $elements;
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:49,代码来源:report.class.php
示例4: min
if (!isset($hiddenfields['lastaccess'])) {
// Get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
// We need to make it diferently for normal courses and site course.
if (!$isfrontpage) {
$minlastaccess = $DB->get_field_sql('SELECT min(timeaccess)
FROM {user_lastaccess}
WHERE courseid = ?
AND timeaccess != 0', array($course->id));
$lastaccess0exists = $DB->record_exists('user_lastaccess', array('courseid' => $course->id, 'timeaccess' => 0));
} else {
$minlastaccess = $DB->get_field_sql('SELECT min(lastaccess)
FROM {user}
WHERE lastaccess != 0');
$lastaccess0exists = $DB->record_exists('user', array('lastaccess' => 0));
}
$now = usergetmidnight(time());
$timeaccess = array();
$baseurl->remove_params('accesssince');
// Makes sense for this to go first.
$timeoptions[0] = get_string('selectperiod');
// Days.
for ($i = 1; $i < 7; $i++) {
if (strtotime('-' . $i . ' days', $now) >= $minlastaccess) {
$timeoptions[strtotime('-' . $i . ' days', $now)] = get_string('numdays', 'moodle', $i);
}
}
// Weeks.
for ($i = 1; $i < 10; $i++) {
if (strtotime('-' . $i . ' weeks', $now) >= $minlastaccess) {
$timeoptions[strtotime('-' . $i . ' weeks', $now)] = get_string('numweeks', 'moodle', $i);
}
开发者ID:educakanchay,项目名称:campus,代码行数:31,代码来源:index.php
示例5: print_log_graph
if (empty($CFG->grade_profilereport) or !file_exists($CFG->dirroot . '/grade/report/' . $CFG->grade_profilereport . '/lib.php')) {
$CFG->grade_profilereport = 'user';
}
require_once $CFG->libdir . '/gradelib.php';
require_once $CFG->dirroot . '/grade/lib.php';
require_once $CFG->dirroot . '/grade/report/' . $CFG->grade_profilereport . '/lib.php';
$functionname = 'grade_report_' . $CFG->grade_profilereport . '_profilereport';
if (function_exists($functionname)) {
$functionname($course, $user);
}
break;
case "todaylogs":
echo '<div class="graph">';
print_log_graph($course, $user->id, "userday.png");
echo '</div>';
print_log($course, $user->id, usergetmidnight(time()), "l.time DESC", $page, $perpage, "user.php?id={$course->id}&user={$user->id}&mode={$mode}");
break;
case "alllogs":
echo '<div class="graph">';
print_log_graph($course, $user->id, "usercourse.png");
echo '</div>';
print_log($course, $user->id, 0, "l.time DESC", $page, $perpage, "user.php?id={$course->id}&user={$user->id}&mode={$mode}");
break;
case 'stats':
if (empty($CFG->enablestats)) {
error("Stats is not enabled.");
}
require_once $CFG->dirroot . '/lib/statslib.php';
$statsstatus = stats_check_uptodate($course->id);
if ($statsstatus !== NULL) {
notify($statsstatus);
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:31,代码来源:user.php
示例6: instance_config_print
function instance_config_print()
{
global $CFG, $DB;
if (!isset($this->config)) {
// ... teacher has not yet configured the block, let's put some default values here to explain things
$this->config->title = get_string('blockname', 'block_glossary_random');
$this->config->refresh = 0;
$this->config->showconcept = 1;
$this->config->cache = get_string('notyetconfigured', 'block_glossary_random');
$this->config->addentry = get_string('addentry', 'block_glossary_random');
$this->config->viewglossary = get_string('viewglossary', 'block_glossary_random');
$this->config->invisible = get_string('invisible', 'block_glossary_random');
}
// select glossaries to put in dropdown box ...
$glossaries = $DB->get_records_menu('glossary', array('course' => $this->course->id), 'name', 'id,name');
//format menu texts to avoid html and to filter multilang values
if (!empty($glossaries)) {
foreach ($glossaries as $key => $value) {
$glossaries[$key] = strip_tags(format_string($value, true));
}
}
// and select quotetypes to put in dropdown box
$type[0] = get_string('random', 'block_glossary_random');
$type[1] = get_string('lastmodified', 'block_glossary_random');
$type[2] = get_string('nextone', 'block_glossary_random');
$this->config->nexttime = usergetmidnight(time()) + DAYSECS * $this->config->refresh;
// display the form
if (is_file($CFG->dirroot . '/blocks/' . $this->name() . '/config_instance.html')) {
print_simple_box_start('center', '', '', 5, 'blockconfigglobal');
include $CFG->dirroot . '/blocks/' . $this->name() . '/config_instance.html';
print_simple_box_end();
} else {
notice(get_string('blockconfigbad'), str_replace('blockaction=', 'dummy=', qualified_me()));
}
return true;
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:36,代码来源:block_glossary_random.php
示例7: error_reporting
$graph->parameter['tick_length'] = 0;
$graph->parameter['shadow'] = 'none';
error_reporting(5);
// Ignore most warnings such as font problems etc.
$graph->draw_stack();
} else {
$site = get_site();
if ($course->id == $site->id) {
$courseselect = 0;
} else {
$courseselect = $course->id;
}
if ($date) {
$daystart = usergetmidnight($date);
} else {
$daystart = usergetmidnight(time());
}
$dayfinish = $daystart + 86400;
$hours = array();
for ($i = 0; $i <= 23; $i++) {
$logs[$i] = 0;
$hour = $daystart + $i * 3600;
$hours[$i] = $i;
}
$rawlogs = report_log_userday($user->id, $courseselect, $daystart, $logreader);
if (empty($rawlogs)) {
return;
}
foreach ($rawlogs as $rawlog) {
$logs[$rawlog->hour] = $rawlog->num;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:graph.php
示例8: forum_cron
//.........这里部分代码省略.........
}
mtrace('post ' . $post->id . ': ' . $post->subject);
}
// Mark processed posts as read.
if (get_user_preferences('forum_markasreadonnotification', 1, $userto->id) == 1) {
forum_tp_mark_posts_read($userto, $userto->markposts);
}
unset($userto);
}
}
if ($posts) {
foreach ($posts as $post) {
mtrace($mailcount[$post->id] . " users were sent post {$post->id}, '{$post->subject}'");
if ($errorcount[$post->id]) {
$DB->set_field('forum_posts', 'mailed', FORUM_MAILED_ERROR, array('id' => $post->id));
}
}
}
// release some memory
unset($subscribedusers);
unset($mailcount);
unset($errorcount);
cron_setup_user();
$sitetimezone = core_date::get_server_timezone();
// Now see if there are any digest mails waiting to be sent, and if we should send them
mtrace('Starting digest processing...');
core_php_time_limit::raise(300);
// terminate if not able to fetch all digests in 5 minutes
if (!isset($CFG->digestmailtimelast)) {
// To catch the first time
set_config('digestmailtimelast', 0);
}
$timenow = time();
$digesttime = usergetmidnight($timenow, $sitetimezone) + $CFG->digestmailtime * 3600;
// Delete any really old ones (normally there shouldn't be any)
$weekago = $timenow - 7 * 24 * 3600;
$DB->delete_records_select('forum_queue', "timemodified < ?", array($weekago));
mtrace('Cleaned old digest records');
if ($CFG->digestmailtimelast < $digesttime and $timenow > $digesttime) {
mtrace('Sending forum digests: ' . userdate($timenow, '', $sitetimezone));
$digestposts_rs = $DB->get_recordset_select('forum_queue', "timemodified < ?", array($digesttime));
if ($digestposts_rs->valid()) {
// We have work to do
$usermailcount = 0;
//caches - reuse the those filled before too
$discussionposts = array();
$userdiscussions = array();
foreach ($digestposts_rs as $digestpost) {
if (!isset($posts[$digestpost->postid])) {
if ($post = $DB->get_record('forum_posts', array('id' => $digestpost->postid))) {
$posts[$digestpost->postid] = $post;
} else {
continue;
}
}
$discussionid = $digestpost->discussionid;
if (!isset($discussions[$discussionid])) {
if ($discussion = $DB->get_record('forum_discussions', array('id' => $discussionid))) {
$discussions[$discussionid] = $discussion;
} else {
continue;
}
}
$forumid = $discussions[$discussionid]->forum;
if (!isset($forums[$forumid])) {
if ($forum = $DB->get_record('forum', array('id' => $forumid))) {
开发者ID:rezaies,项目名称:moodle,代码行数:67,代码来源:lib.php
示例9: reset_course_userdata
/**
* This function will empty a course of user data.
* It will retain the activities and the structure of the course.
*
* @param object $data an object containing all the settings including courseid (without magic quotes)
* @return array status array of array component, item, error
*/
function reset_course_userdata($data)
{
global $CFG, $DB;
require_once $CFG->libdir . '/gradelib.php';
require_once $CFG->libdir . '/completionlib.php';
require_once $CFG->dirroot . '/group/lib.php';
$data->courseid = $data->id;
$context = context_course::instance($data->courseid);
$eventparams = array('context' => $context, 'courseid' => $data->id, 'other' => array('reset_options' => (array) $data));
$event = \core\event\course_reset_started::create($eventparams);
$event->trigger();
// Calculate the time shift of dates.
if (!empty($data->reset_start_date)) {
// Time part of course startdate should be zero.
$data->timeshift = $data->reset_start_date - usergetmidnight($data->reset_start_date_old);
} else {
$data->timeshift = 0;
}
// Result array: component, item, error.
$status = array();
// Start the resetting.
$componentstr = get_string('general');
// Move the course start time.
if (!empty($data->reset_start_date) and $data->timeshift) {
// Change course start data.
$DB->set_field('course', 'startdate', $data->reset_start_date, array('id' => $data->courseid));
// Update all course and group events - do not move activity events.
$updatesql = "UPDATE {event}\n SET timestart = timestart + ?\n WHERE courseid=? AND instance=0";
$DB->execute($updatesql, array($data->timeshift, $data->courseid));
// Update any date activity restrictions.
if ($CFG->enableavailability) {
\availability_date\condition::update_all_dates($data->courseid, $data->timeshift);
}
$status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false);
}
if (!empty($data->reset_end_date)) {
// If the user set a end date value respect it.
$DB->set_field('course', 'enddate', $data->reset_end_date, array('id' => $data->courseid));
} else {
if ($data->timeshift > 0 && $data->reset_end_date_old) {
// If there is a time shift apply it to the end date as well.
$enddate = $data->reset_end_date_old + $data->timeshift;
$DB->set_field('course', 'enddate', $enddate, array('id' => $data->courseid));
}
}
if (!empty($data->reset_events)) {
$DB->delete_records('event', array('courseid' => $data->courseid));
$status[] = array('component' => $componentstr, 'item' => get_string('deleteevents', 'calendar'), 'error' => false);
}
if (!empty($data->reset_notes)) {
require_once $CFG->dirroot . '/notes/lib.php';
note_delete_all($data->courseid);
$status[] = array('component' => $componentstr, 'item' => get_string('deletenotes', 'notes'), 'error' => false);
}
if (!empty($data->delete_blog_associations)) {
require_once $CFG->dirroot . '/blog/lib.php';
blog_remove_associations_for_course($data->courseid);
$status[] = array('component' => $componentstr, 'item' => get_string('deleteblogassociations', 'blog'), 'error' => false);
}
if (!empty($data->reset_completion)) {
// Delete course and activity completion information.
$course = $DB->get_record('course', array('id' => $data->courseid));
$cc = new completion_info($course);
$cc->delete_all_completion_data();
$status[] = array('component' => $componentstr, 'item' => get_string('deletecompletiondata', 'completion'), 'error' => false);
}
if (!empty($data->reset_competency_ratings)) {
\core_competency\api::hook_course_reset_competency_ratings($data->courseid);
$status[] = array('component' => $componentstr, 'item' => get_string('deletecompetencyratings', 'core_competency'), 'error' => false);
}
$componentstr = get_string('roles');
if (!empty($data->reset_roles_overrides)) {
$children = $context->get_child_contexts();
foreach ($children as $child) {
$DB->delete_records('role_capabilities', array('contextid' => $child->id));
}
$DB->delete_records('role_capabilities', array('contextid' => $context->id));
// Force refresh for logged in users.
$context->mark_dirty();
$status[] = array('component' => $componentstr, 'item' => get_string('deletecourseoverrides', 'role'), 'error' => false);
}
if (!empty($data->reset_roles_local)) {
$children = $context->get_child_contexts();
foreach ($children as $child) {
role_unassign_all(array('contextid' => $child->id));
}
// Force refresh for logged in users.
$context->mark_dirty();
$status[] = array('component' => $componentstr, 'item' => get_string('deletelocalroles', 'role'), 'error' => false);
}
// First unenrol users - this cleans some of related user data too, such as forum subscriptions, tracking, etc.
$data->unenrolled = array();
if (!empty($data->unenrol_users)) {
//.........这里部分代码省略.........
开发者ID:lucaboesch,项目名称:moodle,代码行数:101,代码来源:moodlelib.php
示例10: get_today_sessions_for_copy
/**
* Returns today sessions suitable for copying attendance log
*
* Fetches data from {attendance_sessions}
*
* @return array of records or an empty array
*/
public function get_today_sessions_for_copy($sess) {
global $DB;
$count = sizeof($sess);
if ($count > 0) {
$start = usergetmidnight($sess->sessdate);
$sql = "SELECT *
FROM {local_attendance_sessions}
WHERE sessdate >= :start AND sessdate <= :end AND
(groupid = 0 OR groupid = :groupid) AND
lasttaken > 0 AND attendanceid = :aid";
$params = array(
'start' => $start,
'end' => $sess->sessdate,
'groupid' => $sess->groupid,
'aid' => $this->id);
return $DB->get_records_sql($sql, $params);
} else
return array();
}
开发者ID:anilch,项目名称:Personel,代码行数:29,代码来源:locallib.php
示例11: send_expiry_notifications
/**
* Send expiry notifications.
*
* Plugin that wants to have expiry notification MUST implement following:
* - expirynotifyhour plugin setting,
* - configuration options in instance edit form (expirynotify, notifyall and expirythreshold),
* - notification strings (expirymessageenrollersubject, expirymessageenrollerbody,
* expirymessageenrolledsubject and expirymessageenrolledbody),
* - expiry_notification provider in db/messages.php,
* - upgrade code that sets default thresholds for existing courses (should be 1 day),
* - something that calls this method, such as cron.
*
* @param bool $verbose verbose CLI output
*/
public function send_expiry_notifications($verbose = false)
{
global $DB, $CFG;
// Unfortunately this may take a long time, it should not be interrupted,
// otherwise users get duplicate notification.
@set_time_limit(0);
raise_memory_limit(MEMORY_HUGE);
$name = $this->get_name();
$expirynotifylast = $this->get_config('expirynotifylast', 0);
$expirynotifyhour = $this->get_config('expirynotifyhour');
if (is_null($expirynotifyhour)) {
debugging("send_expiry_notifications() in {$name} enrolment plugin needs expirynotifyhour setting");
return;
}
$timenow = time();
$notifytime = usergetmidnight($timenow, $CFG->timezone) + $expirynotifyhour * 3600;
if ($expirynotifylast > $notifytime) {
if ($verbose) {
mtrace($name . ' enrolment expiry notifications were already sent today at ' . userdate($expirynotifylast, '', $CFG->timezone) . '.');
}
return;
} else {
if ($timenow < $notifytime) {
if ($verbose) {
mtrace($name . ' enrolment expiry notifications will be sent at ' . userdate($notifytime, '', $CFG->timezone) . '.');
}
return;
}
}
if ($verbose) {
mtrace('Processing ' . $name . ' enrolment expiration notifications...');
}
// Notify users responsible for enrolment once every day.
$sql = "SELECT ue.*, e.expirynotify, e.notifyall, e.expirythreshold, e.courseid, c.fullname\n FROM {user_enrolments} ue\n JOIN {enrol} e ON (e.id = ue.enrolid AND e.enrol = :name AND e.expirynotify > 0 AND e.status = :enabled)\n JOIN {course} c ON (c.id = e.courseid)\n JOIN {user} u ON (u.id = ue.userid AND u.deleted = 0 AND u.suspended = 0)\n WHERE ue.status = :active AND ue.timeend > 0 AND ue.timeend > :now1 AND ue.timeend < (e.expirythreshold + :now2)\n ORDER BY ue.enrolid ASC, u.lastname ASC, u.firstname ASC, u.id ASC";
$params = array('enabled' => ENROL_INSTANCE_ENABLED, 'active' => ENROL_USER_ACTIVE, 'now1' => $timenow, 'now2' => $timenow, 'name' => $name);
$rs = $DB->get_recordset_sql($sql, $params);
$lastenrollid = 0;
$users = array();
foreach ($rs as $ue) {
if ($lastenrollid and $lastenrollid != $ue->enrolid) {
$this->notify_expiry_enroller($lastenrollid, $users, $verbose);
$users = array();
}
$lastenrollid = $ue->enrolid;
$enroller = $this->get_enroller($ue->enrolid);
$context = context_course::instance($ue->courseid);
$user = $DB->get_record('user', array('id' => $ue->userid));
$users[] = array('fullname' => fullname($user, has_capability('moodle/site:viewfullnames', $context, $enroller)), 'timeend' => $ue->timeend);
if (!$ue->notifyall) {
continue;
}
if ($ue->timeend - $ue->expirythreshold + 86400 < $timenow) {
// Notify enrolled users only once at the start of the threshold.
if ($verbose) {
mtrace(" user {$ue->userid} was already notified that enrolment in course {$ue->courseid} expires on " . userdate($ue->timeend, '', $CFG->timezone));
}
continue;
}
$this->notify_expiry_enrolled($user, $ue, $verbose);
}
$rs->close();
if ($lastenrollid and $users) {
$this->notify_expiry_enroller($lastenrollid, $users, $verbose);
}
if ($verbose) {
mtrace('...notification processing finished.');
}
$this->set_config('expirynotifylast', $timenow);
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:83,代码来源:enrollib.php
示例12: construct_sessions_data_for_add
function construct_sessions_data_for_add($formdata)
{
global $CFG;
$duration = $formdata->durtime['hours'] * HOURSECS + $formdata->durtime['minutes'] * MINSECS;
$now = time();
$sessions = array();
if (isset($formdata->addmultiply)) {
$startdate = $formdata->sessiondate;
$starttime = $startdate - usergetmidnight($startdate);
$enddate = $formdata->sessionenddate + DAYSECS;
// because enddate in 0:0am
if ($enddate < $startdate) {
return NULL;
}
$days = (int) ceil(($enddate - $startdate) / DAYSECS);
// Getting first day of week
$sdate = $startdate;
$dinfo = usergetdate($sdate);
if ($CFG->calendar_startwday === '0') {
//week start from sunday
$startweek = $startdate - $dinfo['wday'] * DAYSECS;
//call new variable
} else {
$wday = $dinfo['wday'] === 0 ? 7 : $dinfo['wday'];
$startweek = $startdate - ($wday - 1) * DAYSECS;
}
$wdaydesc = array(0 => 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
while ($sdate < $enddate) {
if ($sdate < $startweek + WEEKSECS) {
$dinfo = usergetdate($sdate);
if (key_exists($wdaydesc[$dinfo['wday']], $formdata->sdays)) {
$sess->sessdate = usergetmidnight($sdate) + $starttime;
$sess->duration = $duration;
$sess->descriptionitemid = $formdata->sdescription['itemid'];
$sess->description = $formdata->sdescription['text'];
$sess->descriptionformat = $formdata->sdescription['format'];
$sess->timemodified = $now;
fill_groupid($formdata, $sessions, $sess);
}
$sdate += DAYSECS;
} else {
$startweek += WEEKSECS * $formdata->period;
$sdate = $startweek;
}
}
} else {
$sess->sessdate = $formdata->sessiondate;
$sess->duration = $duration;
$sess->descriptionitemid = $formdata->sdescription['itemid'];
$sess->description = $formdata->sdescription['text'];
$sess->descriptionformat = $formdata->sdescription['format'];
$sess->timemodified = $now;
fill_groupid($formdata, $sessions, $sess);
}
return $sessions;
}
开发者ID:e-rasvet,项目名称:attforblockup,代码行数:56,代码来源:sessions.php
示例13: report_ncccscensus_generate_report
/**
* Performs the report function.
*
* @param array $formdata the form data
* @param int $type the report type
* @param string $saveto File to save the pdf report to.
* @return bool False on failure
* @uses $CFG, $DB
*/
function report_ncccscensus_generate_report($formdata, $type = REPORT_NCCCSCENSUS_ACTION_VIEW, $saveto = false)
{
global $CFG, $DB;
require_once $CFG->libdir . '/moodlelib.php';
$reportname = 'report_ncccscensus';
$cid = $formdata->id;
// In case the form is hacked, set a default startdate to today at midnight.
if (empty($formdata->startdate)) {
$formdata->startdate = usergetmidnight(time(), get_user_timezone());
}
// In case the form is hacked, set a default enddate to today at midnight.
if (empty($formdata->enddate)) {
$formdata->enddate = $formdata->startdate;
}
// Advance enddate to tomorrow's midnight.
$formdata->enddate += DAYSECS - 1;
// This flag determines if we should display grouped users or not.
$nogroups = isset($formdata->disablegroups) ? true : false;
if ($nogroups) {
$group = false;
} else {
// If group specified, do some validation.
$group = isset($formdata->group) ? $formdata->group : false;
// In case the form is hacked, the group could be invalid.
if ($group === false || $group < 0) {
throw new report_ncccscensus_exception('cannotfindgroup');
}
if ($group > 0) {
// Validate the group ID.
if (!groups_group_exists($group)) {
throw new report_ncccscensus_exception('cannotfindgroup');
}
// Validate the group ID with respect to the course ID.
$groupdata = groups_get_course_data($cid);
$groupfound = false;
foreach ($groupdata->groups as $groupobject) {
if ($groupobject->id == $group) {
$groupfound = true;
break;
}
}
if (!$groupfound) {
throw new report_ncccscensus_exception('invalidgroupid');
}
// User could still hack form to view a group that they don't have the capability to see.
$context = context_course::instance($cid);
if (has_capability('moodle/site:accessallgroups', $context)) {
$userid = 0;
} else {
if (has_capability('moodle/course:managegroups', $context)) {
$userid = $USER->id;
} else {
$userid = false;
}
}
if ($userid === false) {
throw new report_ncccscensus_exception('invalidgroupid');
}
if ($userid != 0) {
$grouprecs = groups_get_all_groups($course->id, $userid, 0, 'g.id, g.name');
$groupnotfound = true;
foreach ($grouprecs as $grouprec) {
if ($grouprec->id == $group) {
$groupnotfound = false;
break;
}
}
if ($groupnotfound) {
throw new report_ncccscensus_exception('invalidgroupid');
}
}
}
}
$users = array();
if ($nogroups) {
$users = report_ncccscensus_get_users($cid, REPORT_NCCCSCENSUS_EXCLUDE_GROUP_MEMBERS);
} else {
if ($group > 0) {
$users = report_ncccscensus_get_users($cid, $group);
} else {
$users = report_ncccscensus_get_users($cid);
}
}
$results = report_ncccscensus_build_grades_array($cid, $users, $formdata->startdate, $formdata->enddate);
if (empty($results)) {
return false;
}
if ($type == REPORT_NCCCSCENSUS_ACTION_VIEW) {
$headers = array('student' => get_string('studentfullnamehtml', $reportname));
$showstudentid = report_ncccscensus_check_field_status('showstudentid', 'html');
} else {
//.........这里部分代码省略.........
开发者ID:cbmegahan,项目名称:report_ncccscensus,代码行数:101,代码来源:lib.php
示例14: make_timestamp
// If a day, month and year were passed then convert it to a timestamp. If these were passed
// then we can assume the day, month and year are passed as Gregorian, as no where in core
// should we be passing these values rather than the time. This is done for BC.
if (!empty($day) && !empty($mon) && !empty($year)) {
if (checkdate($mon, $day, $year)) {
$time = make_timestamp($year, $mon, $day);
}
}
if (empty($time)) {
$time = time();
}
if ($courseid != SITEID) {
$url->param('course', $courseid);
}
if ($view !== 'upcoming') {
$time = usergetmidnight($time);
$url->param('view', $view);
}
$url->param('time', $time);
$PAGE->set_url($url);
if ($courseid != SITEID && !empty($courseid)) {
$course = $DB->get_record('course', array('id' => $courseid));
$courses = array($course->id => $course);
$issite = false;
navigation_node::override_active_url(new moodle_url('/course/view.php', array('id' => $course->id)));
} else {
$course = get_site();
$courses = calendar_get_default_courses();
$issite = true;
}
require_course_login($course);
开发者ID:janeklb,项目名称:moodle,代码行数:31,代码来源:view.php
示例15: array
if ($courseid == SITEID) {
$PAGE->set_heading(fullname($user));
} else {
$PAGE->set_heading($course->fullname);
}
// Trigger a user logs viewed event.
$event = \report_log\event\user_report_viewed::create(array('context' => $coursecontext, 'relateduserid' => $userid, 'other' => array('mode' => $mode)));
$event->trigger();
echo $OUTPUT->header();
if ($courseid != SITEID) {
$userheading = array('user' => $user, 'usercontext' => $personalcontext);
echo $OUTPUT->context_header($userheading, 2);
}
// Time to filter records from.
if ($mode === 'today') {
$timefrom = usergetmidnight(time());
} else {
$timefrom = 0;
}
$output = $PAGE->get_renderer('report_log');
$reportlog = new report_log_renderable($logreader, $course, $user->id, 0, '', -1, -1, false, false, true, false, $PAGE->url, $timefrom, '', $page, $perpage, 'timecreated DESC');
// Setup table if log reader is enabled.
if (!empty($reportlog->selectedlogreader)) {
$reportlog->setup_table();
$reportlog->tablelog->is_downloadable(false);
}
echo $output->reader_selector($reportlog);
if ($mode === 'all') {
$reportlog->selecteddate = 0;
}
// Print the graphic chart accordingly to the mode (all, today).
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:user.php
示例16: scorm_cron
/**
* Function to be run periodically according to the moodle cron
* This function searches for things that need to be done, such
* as sending out mail, toggling flags etc ...
*
* @global stdClass
* @global object
* @return boolean
*/
function scorm_cron () {
global $CFG, $DB;
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
$sitetimezone = $CFG->timezone;
// Now see if there are any scorm updates to be done.
if (!isset($CFG->scorm_updatetimelast)) { // To catch the first time.
set_config('scorm_updatetimelast', 0);
}
$timenow = time();
$updatetime = usergetmidnight($timenow, $sitetimezone);
if ($CFG->scorm_updatetimelast < $updatetime and $timenow > $updatetime) {
set_config('scorm_updatetimelast', $timenow);
mtrace('Updating scorm packages which require daily update');// We are updating.
$scormsupdate = $DB->get_records('scorm', array('updatefreq' => SCORM_UPDATE_EVERYDAY));
foreach ($scormsupdate as $scormupdate) {
scorm_parse($scormupdate, true);
}
// Now clear out AICC session table with old session data.
$cfgscorm = get_config('scorm');
if (!empty($cfgscorm->allowaicchacp)) {
$expiretime = time() - ($cfgscorm->aicchacpkeepsessiondata * 24 * 60 * 60);
$DB->delete_records_select('scorm_aicc_session', 'timemodified < ?', array($expiretime));
}
}
return true;
}
开发者ID:ruddj,项目名称:moodle,代码行数:45,代码来源:lib.php
示例17: scorm_cron
/**
* Function to be run periodically according to the moodle cron
* This function searches for things that need to be done, such
* as sending out mail, toggling flags etc ...
*
* @return boolean
*/
function scorm_cron()
{
global $CFG;
require_once 'locallib.php';
$sitetimezone = $CFG->timezone;
/// Now see if there are any digest mails waiting to be sent, and if we should send them
if (!isset($CFG->scorm_updatetimelast)) {
// To catch the first time
set_config('scorm_updatetimelast', 0);
}
$timenow = time();
$updatetime = usergetmidnight($timenow, $sitetimezone) + $CFG->scorm_updatetime * 3600;
if ($CFG->scorm_updatetimelast < $updatetime and $timenow > $updatetime) {
set_config('scorm_updatetimelast', $timenow);
mtrace('Updating scorm packages which require daily update');
//We are updating
$scormsupdate = get_records('scorm', 'updatefreq', UPDATE_EVERYDAY);
if (!empty($scormsupdate)) {
foreach ($scormsupdate as $scormupdate) {
$scormupdate->instance = $scormupdate->id;
$id = scorm_update_instance($scormupdate);
}
}
}
return true;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:33,代码来源:lib.php
示例18: reset_course_userdata
/**
* This function will empty a course of user data.
* It will retain the activities and the structure of the course.
*
* @param object $data an object containing all the settings including courseid (without magic quotes)
* @return array status array of array component, item, error
*/
function reset_course_userdata($data)
{
global $CFG, $USER, $DB;
require_once $CFG->libdir . '/gradelib.php';
require_once $CFG->libdir . '/completionlib.php';
require_once $CFG->dirroot . '/group/lib.php';
$data->courseid = $data->id;
$context = get_context_instance(CONTEXT_COURSE, $data->courseid);
// calculate the time shift of dates
if (!empty($data->reset_start_date)) {
// time part of course startdate should be zero
$data->timeshift = $data->reset_start_date - usergetmidnight($data->reset_start_date_old);
} else {
$data->timeshift = 0;
}
// result array: component, item, error
$status = array();
// start the resetting
$componentstr = get_string('general');
// move the course start time
if (!empty($data->reset_start_date) and $data->timeshift) {
// change course start data
$DB->set_field('course', 'startdate', $data->reset_start_date, array('id' => $data->courseid));
// update all course and group events - do not move activity events
$updatesql = "UPDATE {event}\n SET timestart = timestart + ?\n WHERE courseid=? AND instance=0";
$DB->execute($updatesql, array($data->timeshift, $data->courseid));
$status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false);
}
if (!empty($data->reset_logs)) {
$DB->delete_records('log', array('course' => $data->courseid));
$status[] = array('component' => $componentstr, 'item' => get_string('deletelogs'), 'error' => false);
}
if (!empty($data->reset_events)) {
$DB->delete_records('event', array('courseid' => $data->courseid));
$status[] = array('component' => $componentstr, 'item' => get_string('deleteevents', 'calendar'), 'error' => false);
}
if (!empty($data->reset_notes)) {
require_once $CFG->dirroot . '/notes/lib.php';
note_delete_all($data->courseid);
$status[] = array('component' => $componentstr, 'item' => get_string('deletenotes', 'notes'), 'error' => false);
}
if (!empty($data->delete_blog_associations)) {
require_once $CFG->dirroot . '/blog/lib.php';
blog_remove_associations_for_course($data->courseid);
$status[] = array('component' => $componentstr, 'item' => get_string('deleteblogassociations', 'blog'), 'error' => false);
}
if (!empty($data->reset_course_completion)) {
// Delete course completion information
$course = $DB->get_record('course', array('id' => $data->courseid));
$cc = new completion_info($course);
$cc->delete_course_completion_data();
$status[] = array('component' => $componentstr, 'item' => get_string('deletecoursecompletiondata', 'completion'), 'error' => false);
}
$componen
|
请发表评论