本文整理汇总了PHP中usertime函数的典型用法代码示例。如果您正苦于以下问题:PHP usertime函数的具体用法?PHP usertime怎么用?PHP usertime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了usertime函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: post
/**
* Render a single post
*
* @param \stdClass $cm The forum course module
* @param \stdClass $discussion The post's discussion
* @param \stdClass $post The post to render
* @param bool $canreply
* @param null|object $parent Optional, parent post
* @param array $commands Override default post commands
* @param int $depth Depth of the post
* @return string
*/
public function post($cm, $discussion, $post, $canreply = false, $parent = null, $commands = array(), $depth = 0, $search = '')
{
global $USER, $CFG, $DB;
$forum = hsuforum_get_cm_forum($cm);
if (!hsuforum_user_can_see_post($forum, $discussion, $post, null, $cm)) {
// Return a message about why you cannot see the post
return "<div class='hsuforum-post-content-hidden'>" . get_string('forumbodyhidden', 'hsuforum') . "</div>";
}
if ($commands === false) {
$commands = array();
} else {
if (empty($commands)) {
$commands = $this->post_get_commands($post, $discussion, $cm, $canreply, false);
} else {
if (!is_array($commands)) {
throw new coding_exception('$commands must be false, empty or populated array');
}
}
}
$postuser = hsuforum_extract_postuser($post, $forum, context_module::instance($cm->id));
$postuser->user_picture->size = 100;
// $post->breadcrumb comes from search btw.
$data = new stdClass();
$data->id = $post->id;
$data->discussionid = $discussion->id;
$data->fullname = $postuser->fullname;
$data->subject = property_exists($post, 'breadcrumb') ? $post->breadcrumb : $this->raw_post_subject($post);
$data->message = $this->post_message($post, $cm, $search);
$data->created = userdate($post->created, get_string('articledateformat', 'hsuforum'));
$data->rawcreated = $post->created;
$data->datetime = date(DATE_W3C, usertime($post->created));
$data->privatereply = $post->privatereply;
$data->imagesrc = $postuser->user_picture->get_url($this->page)->out();
$data->userurl = $this->get_post_user_url($cm, $postuser);
$data->unread = empty($post->postread) ? true : false;
$data->permalink = new moodle_url('/mod/hsuforum/discuss.php#p' . $post->id, array('d' => $discussion->id));
$data->isreply = false;
$data->parentfullname = '';
$data->parentuserurl = '';
$data->tools = implode(' ', $commands);
$data->postflags = implode(' ', $this->post_get_flags($post, $cm, $discussion->id, false));
$data->depth = $depth;
$data->revealed = false;
if ($forum->anonymous && $postuser->id === $USER->id && $post->reveal) {
$data->revealed = true;
}
if (!empty($post->children)) {
$post->replycount = count($post->children);
}
$data->replycount = '';
// Only show reply count if replies and not first post
if (!empty($post->replycount) && $post->replycount > 0 && $post->parent) {
$data->replycount = hsuforum_xreplies($post->replycount);
}
// Mark post as read.
if ($data->unread) {
hsuforum_mark_post_read($USER->id, $post, $forum->id);
}
if (!empty($parent)) {
$parentuser = hsuforum_extract_postuser($parent, $forum, context_module::instance($cm->id));
$data->parenturl = $CFG->wwwroot . '/mod/hsuforum/discuss.php?d=' . $parent->discussion . '#p' . $parent->id;
$data->parentfullname = $parentuser->fullname;
if (!empty($parentuser->user_picture)) {
$parentuser->user_picture->size = 100;
$data->parentuserurl = $this->get_post_user_url($cm, $parentuser);
$data->parentuserpic = $this->output->user_picture($parentuser, array('link' => false, 'size' => 100, 'alttext' => false));
}
}
if ($depth > 0) {
// Top level responses don't count.
$data->isreply = true;
}
return $this->post_template($data);
}
开发者ID:cdsmith-umn,项目名称:moodle-mod_hsuforum,代码行数:86,代码来源:renderer.php
示例2: foreach
}
// Merge Moodle users last - higher priority in linking than other contact type
if (count($moodleUserGroups) > 0) {
foreach ($moodleUserGroups as $userGroup) {
$destinations += $userDAO->getUsersInGroup($userGroup, 'phone');
}
}
if (count($moodleUsers) > 0) {
$destinations += $userDAO->getUsersById($moodleUsers, 'phone');
}
// If there are valid destinations, send the message
if (count($destinations) > 0) {
$txttoolsAccount = $accountDAO->getTxttoolsAccountById($formData->txttoolsaccount);
$thisUser = new MoodletxtBiteSizedUser($USER->id, $USER->username, $USER->firstname, $USER->lastname);
if ($formData->schedule == 'schedule') {
$scheduletime = usertime(gmmktime($formData->scheduletime['H'], $formData->scheduletime['i'], 0, $formData->scheduletime['M'], $formData->scheduletime['d'], $formData->scheduletime['Y']));
} else {
$scheduletime = time();
}
$outboundMessage = new MoodletxtOutboundMessage($txttoolsAccount, $thisUser, $formData->messageText, time(), MoodletxtOutboundMessage::$MESSAGE_CHARGE_TYPE_BULK, $scheduletime, $formData->suppressUnicode);
$outboundMessage->setMessageRecipients($destinations);
try {
$connector = MoodletxtOutboundControllerFactory::getOutboundController(MoodletxtOutboundControllerFactory::$CONTROLLER_TYPE_XML);
$outboundMessage->setSentSMSMessages($connector->sendMessage($outboundMessage));
$messageDAO->saveSentMessage($outboundMessage);
$statsDAO->incrementUserOutboundStatsById($txttoolsAccount->getId(), $USER->id, 1);
// Stub for later expansion
$sentPageUrl = new moodle_url('/blocks/moodletxt/sent.php', array('course' => $courseId, 'instance' => $instanceId));
redirect($sentPageUrl, get_string('redirectmessagesent', 'block_moodletxt'));
} catch (MoodletxtRemoteProcessingException $ex) {
// Uh-oh, couldn't send! Display error, please
开发者ID:educacionbe,项目名称:campus,代码行数:31,代码来源:send.php
示例3: array
// CSS classes for each column in the table.
$examstable->colclasses = array("exams_examname", null);
$examstable->data[] = array(get_string("examname", "mod_emarking"), $exam->name);
$details = html_writer::start_tag("div", array("class" => "printdetails"));
if ($exam->headerqr) {
$details .= html_writer::div($OUTPUT->pix_icon("qr-icon", get_string("headerqr", "mod_emarking"), "mod_emarking"));
}
if ($exam->printlist) {
$details .= html_writer::div($OUTPUT->pix_icon("i/grades", get_string("printlist", "mod_emarking")));
}
if ($exam->printrandom) {
$details .= html_writer::div($OUTPUT->pix_icon("shuffle", get_string("printrandom", "mod_emarking"), "mod_emarking"));
}
$details .= emarking_enrolments_div($exam);
$details .= html_writer::end_tag("div");
$examstable->data[] = array(get_string("examdate", "mod_emarking"), date("l jS F Y, g:ia", usertime($exam->examdate)));
if ($usercangrade) {
$examstatus = emarking_exam_status_string($exam);
$examstable->data[] = array(get_string("comment", "mod_emarking"), $exam->comment);
$examstable->data[] = array(get_string("status", "mod_emarking"), $examstatus);
$examstable->data[] = array(get_string("details", "mod_emarking"), $details);
$examstable->data[] = array(get_string("sent", "mod_emarking"), emarking_time_ago($exam->timecreated));
$originals = $exam->totalpages + $exam->extrasheets;
$copies = $exam->totalstudents + $exam->extraexams;
$totalsheets = $originals * $copies;
$examstable->data[] = array(get_string('originals', 'mod_emarking'), $originals);
$examstable->data[] = array(get_string('copies', 'mod_emarking'), $copies);
$examstable->data[] = array(get_string('totalpagesprint', 'mod_emarking'), $totalsheets);
$user = $DB->get_record("user", array("id" => $exam->requestedby));
$examstable->data[] = array(get_string('requestedby', 'mod_emarking'), $user->firstname . ' ' . $user->lastname);
$examstable->data[] = array(get_string("multicourse", "mod_emarking"), $multicourse ? $multicourse : get_string("no"));
开发者ID:hansnok,项目名称:emarking,代码行数:31,代码来源:exam.php
示例4: report_ncccscensus_course_search
/**
* Searches for courses using a substring match and optionally limits by category.
*
* @param string $query The substring to search for.
* @param array $categoryquery Array of categories to search for.
* @return array Matching courses or returns no matches found.
*/
function report_ncccscensus_course_search($query, $categoryquery)
{
global $DB;
$time = usertime(time(), get_user_timezone());
$param = array($time, $time, "%{$query}%");
$categorysql = "";
if (is_array($categoryquery) && count($categoryquery) > 0) {
$tempcategories = array();
foreach ($categoryquery as $category) {
array_push($tempcategories, $category['id']);
}
$categories = $DB->get_in_or_equal($tempcategories);
$categorysql = " AND category {$categories['0']} ";
foreach ($categories[1] as $temp) {
array_push($param, $temp);
}
}
$sqlquery = 'SELECT DISTINCT c.id, c.fullname FROM {course} c, {enrol} e, {user_enrolments} ue WHERE';
$sqlquery .= ' e.courseid = c.id AND ue.enrolid = e.id ';
$sqlquery .= ' AND ue.timestart < ? AND (ue.timeend > ? OR ue.timeend = 0)';
$sqlquery .= ' AND c.fullname LIKE ? ' . $categorysql;
$courses = $DB->get_records_sql($sqlquery, $param);
$results = array();
foreach ($courses as $course) {
array_push($results, array('id' => $course->id, 'name' => $course->fullname));
}
if (count($results) === 0) {
array_push($results, array('name' => get_string('noresults', 'report_ncccscensus') . " {$query}"));
}
return $results;
}
开发者ID:cbmegahan,项目名称:report_ncccscensus,代码行数:38,代码来源:lib.php
示例5: make_timestamp
/**
* Given date parts in user time produce a GMT timestamp.
*
* @param int $year The year part to create timestamp of
* @param int $month The month part to create timestamp of
* @param int $day The day part to create timestamp of
* @param int $hour The hour part to create timestamp of
* @param int $minute The minute part to create timestamp of
* @param int $second The second part to create timestamp of
* @param float $timezone ?
* @param bool $applydst ?
* @return int timestamp
* @todo Finish documenting this function
*/
function make_timestamp($year, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $timezone = 99, $applydst = true)
{
$strtimezone = NULL;
if (!is_numeric($timezone)) {
$strtimezone = $timezone;
}
$timezone = get_user_timezone_offset($timezone);
if (abs($timezone) > 13) {
$time = mktime((int) $hour, (int) $minute, (int) $second, (int) $month, (int) $day, (int) $year);
} else {
$time = gmmktime((int) $hour, (int) $minute, (int) $second, (int) $month, (int) $day, (int) $year);
$time = usertime($time, $timezone);
if ($applydst) {
$time -= dst_offset_on($time, $strtimezone);
}
}
return $time;
}
开发者ID:nadavkav,项目名称:rtlMoodle,代码行数:32,代码来源:moodlelib.php
示例6: data_check_text_access
/**
* this function handles the access policy to contents indexed as searchable documents. If this
* function does not exist, the search engine assumes access is allowed.
* When this point is reached, we already know that :
* - user is legitimate in the surrounding context
* - user may be guest and guest access is allowed to the module
* - the function may perform local checks within the module information logic
* @param string $path the access path to the module script code
* @param string $itemtype the information subclassing (usefull for complex modules, defaults to 'standard')
* @param int $this_id the item id within the information class denoted by itemtype. In databases, this id
* points out an indexed data record page.
* @param object $user the user record denoting the user who searches
* @param int $group_id the current group used by the user when searching
* @uses $CFG, $DB
* @return true if access is allowed, false elsewhere
*/
function data_check_text_access($path, $itemtype, $this_id, $user, $group_id, $context_id)
{
global $CFG, $DB;
// get the database object and all related stuff
if ($itemtype == 'record') {
$record = $DB->get_record('data_records', array('id' => $this_id));
} elseif ($itemtype == 'comment') {
$comment = $DB->get_record('data_comments', array('id' => $this_id));
$record = $DB->get_record('data_records', array('id' => $comment->recordid));
} else {
// we do not know what type of information is required
return false;
}
$data = $DB->get_record('data', array('id' => $record->dataid));
$context = $DB->get_record('context', array('id' => $context_id));
$cm = $DB->get_record('course_modules', array('id' => $context->instanceid));
if (empty($cm)) {
return false;
}
// Shirai 20090530 - MDL19342 - course module might have been delete
if (!$cm->visible && !has_capability('moodle/course:viewhiddenactivities', $context)) {
if (!empty($CFG->search_access_debug)) {
echo "search reject : hidden database ";
}
return false;
}
//group consistency check : checks the following situations about groups
// trap if user is not same group and groups are separated
$course = $DB->get_record('course', 'id', $data->course);
if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
$groupmode = $cm->groupmode;
} else {
$groupmode = $course->groupmode;
}
if ($groupmode == SEPARATEGROUPS && !ismember($group_id) && !has_capability('moodle/site:accessallgroups', $context)) {
if (!empty($CFG->search_access_debug)) {
echo "search reject : separated group owned resource ";
}
return false;
}
//ownership check : checks the following situations about user
// trap if user is not owner and has cannot see other's entries
if ($itemtype == 'record') {
if ($user->id != $record->userid && !has_capability('mod/data:viewentry', $context) && !has_capability('mod/data:manageentries', $context)) {
if (!empty($CFG->search_access_debug)) {
echo "search reject : not owned resource ";
}
return false;
}
}
//approval check
// trap if unapproved and has not approval capabilities
// TODO : report a potential capability lack of : mod/data:approve
$approval = $DB->get_field('data_records', 'approved', array('id' => $record->id));
if (!$approval && !has_capability('mod/data:manageentries', $context)) {
if (!empty($CFG->search_access_debug)) {
echo "search reject : unapproved resource ";
}
return false;
}
//minimum records to view check
// trap if too few records
// TODO : report a potential capability lack of : mod/data:viewhiddenentries
$recordsAmount = $DB->count_records('data_records', array('dataid' => $data->id));
if ($data->requiredentriestoview > $recordsAmount && !has_capability('mod/data:manageentries', $context)) {
if (!empty($CFG->search_access_debug)) {
echo "search reject : not enough records to view ";
}
return false;
}
//opening periods check
// trap if user has not capability to see hidden records and date is out of opening range
// TODO : report a potential capability lack of : mod/data:viewhiddenentries
$now = usertime(time());
if ($data->timeviewfrom > 0) {
if ($now < $data->timeviewfrom && !has_capability('mod/data:manageentries', $context)) {
if (!empty($CFG->search_access_debug)) {
echo "search reject : still not open activity ";
}
return false;
}
}
if ($data->timeviewto > 0) {
if ($now > $data->timeviewto && !has_capability('mod/data:manageentries', $context)) {
//.........这里部分代码省略.........
开发者ID:vuchannguyen,项目名称:web,代码行数:101,代码来源:data_document.php
示例7: write_date
/**
* Write one date somewhere in the worksheet
* @param integer $row Zero indexed row
* @param integer $col Zero indexed column
* @param string $date The date to write in UNIX timestamp format
* @param mixed $format The XF format for the cell
*/
function write_date($row, $col, $date, $format=null) {
/// Calculate the internal PEAR format
$format = $this->MoodleExcelFormat2PearExcelFormat($format);
/// Convert the date to Excel format
$timezone = get_user_timezone_offset();
if ($timezone == 99) {
// system timezone offset in seconds
$offset = (int)date('Z');
} else {
$offset = (int)($timezone * HOURSECS * 2);
}
$value = ((usertime($date) + $offset) / 86400) + 25569;
/// Add the date safely to the PEAR Worksheet
$this->pear_excel_worksheet->writeNumber($row, $col, $value, $format);
}
开发者ID:nuckey,项目名称:moodle,代码行数:22,代码来源:excellib.class.php
示例8: get_sessions_by_course
function get_sessions_by_course($sessionids, $displayinfo, $waitlistedsessions) {
global $DB, $activefilters, $hasvalue;
if (empty($sessionids) && empty($waitlistedsessions)) {
return array();
}
// Add IDs of wait-listed sessions.
foreach ($waitlistedsessions as $session) {
// If no date has been selected then add the sessionid.
if (!$hasvalue['timestart'] && !$hasvalue['timefinish']) {
$sessionids[] = $session->id;
}
}
list($insql, $params) = $DB->get_in_or_equal($sessionids);
// If timestart/timefinish has a date, it uses that date. It uses the current month otherwise.
$timestart = $hasvalue['timestart'] ? $activefilters['defaultfields']['unixtimestart'] : usertime($displayinfo->tstart);
$timeend = $hasvalue['timefinish'] ? $activefilters['defaultfields']['unixtimefinish'] : usertime($displayinfo->tend);
$params[] = $timestart;
$params[] = $timeend;
$sessions = $DB->get_records_sql("SELECT d.id, s.id AS sessionid, f.id AS facetofaceid, f.name, s.datetimeknown, d.timestart, d.timefinish, d.sessiontimezone
FROM {facetoface} f
JOIN {facetoface_sessions} s ON f.id = s.facetoface
JOIN {facetoface_sessions_dates} d ON d.sessionid = s.id
WHERE s.id {$insql} AND ((d.timestart >= ? AND d.timestart <= ?) OR s.datetimeknown = 0)
ORDER BY f.name, d.timestart", $params);
return $sessions;
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:32,代码来源:calendar.php
示例9: process_gdoc
public static function process_gdoc($gdoc)
{
global $OUTPUT;
if (isset($gdoc->explicitlyTrashed) && $gdoc->explicitlyTrashed) {
return false;
}
$title = !empty($gdoc->originalFilename) ? $gdoc->originalFilename : $gdoc->title;
$owner = !empty($gdoc->ownerNames) ? implode(', ', $gdoc->ownerNames) : '';
$download = null;
if ($gdoc->mimeType == 'application/vnd.google-apps.drawing') {
$download = self::get_link($gdoc);
} else {
if ($gdoc->mimeType == 'application/vnd.google-apps.spreadsheet') {
if (isset($gdoc->exportLinks)) {
$links = (array) $gdoc->exportLinks;
$download = $links['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];
$title .= '.xlsx';
}
} else {
if ($gdoc->mimeType == 'application/vnd.google-apps.fusiontable') {
$download = $gdoc->alternateLink;
} else {
$download = !empty($gdoc->selfUrl) ? $gdoc->selfUrl : (!empty($gdoc->downloadUrl) ? $gdoc->downloadUrl : $gdoc->alternateLink);
}
}
}
$url = !empty($gdoc->downloadUrl) ? $gdoc->downloadUrl : '';
$size = (!empty($gdoc->fileSize) ? $gdoc->fileSize : (!empty($gdoc->quotaBytesUsed) ? $gdoc->quotaBytesUsed : 'Unknown')) . ' Bytes';
$thumb = !empty($gdoc->thumbnailLink) ? $gdoc->thumbnailLink : (string) $OUTPUT->pix_url(file_extension_icon($title, 32));
// todo: make sure there's nothing else out there reliant on the $source being the URL
$file = array('title' => $title, 'url' => $url, 'source' => $gdoc->id, 'date' => usertime(strtotime($gdoc->modifiedDate)), 'thumbnail' => $thumb, 'author' => $owner, 'size' => $size, 'mimetype' => $gdoc->mimeType, 'webContentLink' => isset($gdoc->webContentLink) ? $gdoc->webContentLink : '', 'selfUrl' => isset($gdoc->selfUrl) ? $gdoc->selfUrl : '', 'downloadUrl' => isset($gdoc->downloadUrl) ? $gdoc->downloadUrl : '', 'alternateLink' => $gdoc->alternateLink, 'download' => $url);
return $file;
}
开发者ID:stefanotirati,项目名称:moodle-google-apps,代码行数:33,代码来源:lib.php
示例10: get_file_list
public function get_file_list($search = '')
{
global $CFG;
$url = google_docs::DOCUMENTFEED_URL;
if ($search) {
$url .= '?q=' . urlencode($search);
}
$content = $this->google_curl->get($url);
$xml = new SimpleXMLElement($content);
$files = array();
foreach ($xml->entry as $gdoc) {
// there doesn't seem to to be cleaner way of getting the id/type
// than spliting this..
if (preg_match('/^http:\\/\\/docs.google.com\\/feeds\\/documents\\/private\\/full\\/([^%]*)%3A(.*)$/', $gdoc->id, $matches)) {
$docid = $matches[2];
// FIXME: We're making hard-coded choices about format here.
// If the repo api can support it, we could let the user
// chose.
switch ($matches[1]) {
case 'document':
$title = $gdoc->title . '.rtf';
$source = 'http://docs.google.com/feeds/download/documents/Export?docID=' . $docid . '&exportFormat=rtf';
break;
case 'presentation':
$title = $gdoc->title . '.ppt';
$source = 'http://docs.google.com/feeds/download/presentations/Export?docID=' . $docid . '&exportFormat=ppt';
break;
case 'spreadsheet':
$title = $gdoc->title . '.xls';
$source = 'http://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=' . $docid . '&fmcmd=4';
break;
}
$files[] = array('title' => $title, 'url' => "{$gdoc->link[0]->attributes()->href}", 'source' => $source, 'date' => usertime(strtotime($gdoc->updated)), 'thumbnail' => $CFG->wwwroot . '/pix/f/' . mimeinfo('icon32', $title));
}
}
return $files;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:37,代码来源:googleapi.php
示例11: validation
function validation($data, $files)
{
global $CFG, $COURSE, $USER, $DB;
require_once $CFG->dirroot . "/mod/emarking/print/locallib.php";
if ($data["type"] < 0 || $data["type"] > 5) {
return array("type" => get_string("markingtypemandatory", "mod_emarking"));
}
// Calculates context for validating permissions
// If we have the module available, we use it, otherwise we fallback to course
$ctx = context_course::instance($COURSE->id);
if ($this->current && $this->current->coursemodule) {
$cm = get_coursemodule_from_id('emarking', $this->current->module, $COURSE->id);
if ($cm) {
$ctx = context_module::instance($cm->id);
}
}
$errors = array();
// Verify that we have enough markers
if ($data['type'] == EMARKING_TYPE_MARKER_TRAINING) {
// Get all users with permission to grade in emarking
$markers = get_enrolled_users($ctx, 'mod/emarking:grade');
$totalmarkers = 0;
foreach ($markers as $marker) {
if (has_capability('mod/emarking:supervisegrading', $ctx, $marker)) {
continue;
}
$totalmarkers++;
}
if ($totalmarkers < 2) {
$errors['type'] = get_string('notenoughmarkersfortraining', 'mod_emarking');
return $errors;
}
return $errors;
}
// Get the exam if we are updating an emarking activity
$exam = null;
if (isset($data['exam']) && $data['exam'] > 0) {
if (!($exam = $DB->get_record("emarking_exams", array("id" => $data["exam"])))) {
$errors["exam"] = "Invalid data from form";
}
}
// If there is no associated exam yet
if (!$exam) {
// The exam date comes from the date selector
$examdate = new DateTime();
$examdate->setTimestamp(usertime($data['examdate']));
// Day of week from 0 Sunday to 6 Saturday
$examw = date("w", $examdate->getTimestamp());
// Hour of the day un 00 to 23 format
$examh = date("H", $examdate->getTimestamp());
// If minimum days for printing is enabled
if (isset($CFG->emarking_minimumdaysbeforeprinting) && $CFG->emarking_minimumdaysbeforeprinting > 0) {
// Sundays are forbidden, saturdays from 6am to 4pm TODO: Move this settings to eMarking settings
if ($examw == 0 || $examw == 6 && ($examh < 6 || $examh > 16)) {
$errors['examdate'] = get_string('examdateinvaliddayofweek', 'mod_emarking');
}
// User date. Important because the user sees a date selector based on her timezone settings, not the server's
$date = usertime(time());
// Today is the date according to the user's timezone
$today = new DateTime();
$today->setTimestamp($date);
// We have a minimum difference otherwise we wouldn't be in this part of the code
$mindiff = intval($CFG->emarking_minimumdaysbeforeprinting);
// If today is saturday or sunday, demand for a bigger difference
$todayw = date("w", $today->getTimestamp());
$todayw = $todayw ? $todayw : 7;
if ($todayw > 5) {
$mindiff += $todayw - 5;
}
// DateInterval calculated with diff
$diff = $today->diff($examdate, false);
// The difference using the invert from DateInterval so we know it is in the past
$realdiff = $diff->days * ($diff->invert ? -1 : 1);
// If the difference is not enough, show an error
if ($realdiff < $mindiff) {
$a = new stdClass();
$a->mindays = $mindiff;
$errors['examdate'] = get_string('examdateinvalid', 'mod_emarking', $a);
}
}
}
// If there's no previous exam to associate, and we are creating a new
// e-marking, we need the PDF file
if ($data["exam"] == 0 && !$this->_instance) {
// We get the draftid from the form
$draftid = file_get_submitted_draft_itemid('exam_files');
$usercontext = context_user::instance($USER->id);
$fs = get_file_storage();
$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftid);
$tempdir = emarking_get_temp_dir_path($COURSE->id);
emarking_initialize_directory($tempdir, true);
$numpagesprevious = -1;
$exampdfs = array();
foreach ($files as $uploadedfile) {
if ($uploadedfile->get_mimetype() !== 'application/pdf') {
continue;
}
$filename = $uploadedfile->get_filename();
$filename = emarking_clean_filename($filename);
$newfilename = $tempdir . '/' . $filename;
//.........这里部分代码省略.........
开发者ID:mandrato1,项目名称:emarking,代码行数:101,代码来源:mod_form.php
示例12: get_file_list
public function get_file_list($search = '', $repo = null)
{
// require_once('constants.php');
global $CFG, $OUTPUT;
$url = get_morsle_url($search);
if (array_key_exists('path', $search)) {
$path = $search['path'] . '/';
unset($search['path']);
} else {
$path = null;
}
foreach ($search as $key => $param) {
if ($key === 'q') {
$param = urlencode($param);
}
$params[$key] = trim($param);
}
// $url .= '?' . implode_assoc('=', '&', $params);
$content = twolegged($url, $params, 'GET');
// $content = $this->get($url, $params, null);
$xml = new SimpleXMLElement($content->response);
$files = array();
$repolink = "{$CFG->wwwroot}/repository/repository_ajax.php?action=list&p=";
foreach ($xml->entry as $gdoc) {
$docid = (string) $gdoc->children('http://schemas.google.com/g/2005')->resourceId;
list($type, $docid) = explode(':', $docid);
$title = (string) $gdoc->title;
$source = '';
// FIXME: We're making hard-coded choices about format here.
// If the repo api can support it, we could let the user
// chose.
switch ($type) {
case 'folder':
break;
case 'document':
$temptitle = 'temp.doc';
break;
case 'presentation':
$temptitle = 'temp.ppt';
break;
case 'spreadsheet':
$temptitle = 'temp.xls';
break;
case 'pdf':
$temptitle = 'temp.pdf';
break;
default:
$temptitle = $gdoc->title;
}
$source = (string) get_href_noentry($gdoc, GDOC_ALT_REL);
// TODO: get this thumbnail working with the display
$iconlink = '<img src="' . (string) get_href_noentry($gdoc, GDOC_THUMB_REL) . '" />';
if (!empty($source)) {
if ($type == 'folder') {
echo null;
$files[] = array('title' => $title, 'url' => "{$gdoc->link[0]->attributes()->href}", 'source' => $source, 'date' => usertime(strtotime($gdoc->updated)), 'children' => array(), 'path' => base64_encode($docid . '|' . $path . $title), 'thumbnail' => (string) $OUTPUT->pix_url('f/folder-64'));
} else {
$files[] = array('title' => $title, 'url' => $source, 'source' => $source, 'date' => usertime(strtotime($gdoc->updated)), 'thumbnail' => (string) $OUTPUT->pix_url(file_extension_icon($temptitle, 64)));
}
}
}
return $files;
}
开发者ID:kamoti01,项目名称:moodle-repository_morsle,代码行数:63,代码来源:locallib.php
示例13: validation
function validation($data, $files)
{
global $CFG;
$errors = array();
// The exam date comes from the date selector
$examdate = new DateTime();
$examdate->setTimestamp(usertime($data['examdate']));
// Day of week from 0 Sunday to 6 Saturday
$examw = date("w", $examdate->getTimestamp());
// Hour of the day un 00 to 23 format
$examh = date("H", $examdate->getTimestamp());
// Sundays are forbidden, saturdays from 6am to 4pm TODO: Move this settings to eMarking settings
if ($examw == 0 || $examw == 6 && ($examh < 6 || $examh > 16)) {
$errors['examdate'] = get_string('examdateinvaliddayofweek', 'mod_emarking');
}
// If minimum days for printing is enabled
if (isset($CFG->emarking_minimumdaysbeforeprinting) && $CFG->emarking_minimumdaysbeforeprinting > 0) {
// User date. Important because the user sees a date selector based on her timezone settings, not the server's
$date = usertime(time());
// Today is the date according to the user's timezone
$today = new DateTime();
$today->setTimestamp($date);
// We have a minimum difference otherwise we wouldn't be in this part of the code
$mindiff = intval($CFG->emarking_minimumdaysbeforeprinting);
// If today is saturday or sunday, demand for a bigger difference
$todayw = date("w", $today->getTimestamp());
$todayw = $todayw ? $todayw : 7;
if ($todayw > 5) {
$mindiff += $todayw - 5;
}
// DateInterval calculated with diff
$diff = $today->diff($examdate, false);
// The difference using the invert from DateInterval so we know it is in the past
$realdiff = $diff->days * ($diff->invert ? -1 : 1);
// If the difference is not enough, show an error
if ($realdiff < $mindiff) {
$a = new stdClass();
$a->mindays = $mindiff;
$errors['examdate'] = get_string('examdateinvalid', 'mod_emarking', $a);
}
}
// If print random order within groups
if (isset($data['printrandom']) && $data['printrandom'] === '1') {
$groups = groups_get_all_groups($data["course"]);
if (count($groups) == 0) {
$errors['printrandom'] = get_string('printrandominvalid', 'mod_emarking');
}
}
return $errors;
}
开发者ID:eduagdo,项目名称:emarking,代码行数:50,代码来源:exam_form.php
示例14: facetofaceb_date_parse_from_format
/**
* returns unix timestamp from a date string depending on the date format
*
* @param string $format e.g. "d/m/Y" - see date_parse_from_format for supported formats
* @param string $date a date to be converted e.g. "12/06/12"
* @return int unix timestamp (0 if fails to parse)
*/
function facetofaceb_date_parse_from_format($format, $date) {
global $CFG;
$tz = isset($CFG->timezone) ? $CFG->timezone : 99;
$timezone = get_user_timezone_offset($tz);
$dateArray = array();
$dateArray = date_parse_from_format($format, $date);
if (is_array($dateArray) && isset($dateArray['error_count']) &&
$dateArray['error_count'] == 0) {
if (abs($timezone) > 13) {
$time = mktime($dateArray['hour'], $dateArray['minute'], $dateArray['second'], $dateArray['month'], $dateArray['day'], $dateArray['year']);
} else {
$time = gmmktime($dateArray['hour'], $dateArray['minute'], $dateArray['second'], $dateArray['month'], $dateArray['day'], $dateArray['year']);
$time = usertime($time, $timezone);
}
return $time;
} else {
return 0;
}
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:27,代码来源:lib.php
示例15: get_exam_date_errors
private function get_exam_date_errors($data)
{
global $CFG;
$errors = array();
if (!isset($data['examdate'])) {
$a = new stdClass();
$a->mindays = 2;
$errors['examdate'] = get_string('examdateinvalid', 'mod_emarking', $a);
return $errors;
}
// The exam date comes from the date selector.
$examdate = new DateTime();
$examdate->setTimestamp(usertime($data['examdate']));
// Day of week from 0 Sunday to 6 Saturday.
$examw = date("w", $examdate->getTimestamp());
// Hour of the day un 00 to 23 format.
$examh = date("H", $examdate->getTimestamp());
// We have a minimum difference otherwise we wouldn't be in this part of the code.
if (isset($CFG->emarking_minimumdaysbeforeprinting) && $CFG->emarking_minimumdaysbeforeprinting > 0) {
$mindiff = intval($CFG->emarking_minimumdaysbeforeprinting);
} else {
return $errors;
}
// Sundays are forbidden, saturdays from 6am to 4pm TODO: Move this settings to eMarking settings.
if ($examw == 0 || $examw == 6 && ($examh < 6 || $examh > 16)) {
$errors['examdate'] = get_string('examdateinvaliddayofweek', 'mod_emarking');
}
// User date. Important because the user sees a date selector based on her timezone settings, not the server's.
$date = usertime(time());
// Today is the date according to the user's timezone.
$today = new DateTime();
$today->setTimestamp($date);
// If today is saturday or sunday, demand for a bigger difference.
$todayw = date("w", $today->getTimestamp());
$todayw = $todayw ? $todayw : 7;
if ($todayw > 5) {
$mindiff += $todayw - 5;
}
// DateInterval calculated with diff.
$diff = $today->diff($examdate, false);
// The difference using the invert from DateInterval so we know it is in the past.
$realdiff = $diff->days * ($diff->invert ? -1 : 1);
// If the difference is not enough, show an error.
if ($realdiff < $mindiff) {
$a = new stdClass();
$a->mindays = $mindiff;
$errors['examdate'] = get_string('examdateinvalid', 'mod_emarking', $a);
}
return $errors;
}
开发者ID:hansnok,项目名称:emarking,代码行数:50,代码来源:mod_form.php
示例16: write_date
/**
* Write one date somewhere in the worksheet
* @param integer $row Zero indexed row
* @param integer $col Zero indexed column
* @param string $date The date to write in UNIX timestamp format
* @param mixed $format The XF format for the cell
*/
function write_date($row, $col, $date, $format = null)
{
/// Calculate the internal PEAR format
$format = $this->MoodleExcelFormat2PearExcelFormat($format);
/// Convert the date to Excel format
$timezone = get_user_timezone_offset();
$value = (usertime($date) + (int) ($timezone * HOURSECS * 2)) / 86400 + 25569;
/// Add the date safely to the PEAR Worksheet
$this->pear_excel_worksheet->writeNumber($row, $col, $value, $format);
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:17,代码来源:excellib.class.php
示例17: show_month_detailed
/**
* Displays a month in detail
*
* @param calendar_information $calendar
* @return string
*/
public function show_month_detailed(calendar_information $calendar, moodle_url $returnurl = null)
{
global $CFG;
if (empty($returnurl)) {
$returnurl = $this->page->url;
}
$date = usergetdate(time());
$display = new stdClass();
$display->minwday = get_user_preferences('calendar_startwday', calendar_get_starting_weekday());
$display->maxwday = $display->minwday + 6;
$display->thismonth = $date['mon'] == $calendar->month;
$display->maxdays = calendar_days_in_month($calendar->month, $calendar->year);
$startwday = 0;
if (get_user_timezone_offset() < 99) {
// We 'll keep these values as GMT here, and offset them when the time comes to query the db
$display->tstart = gmmktime(0, 0, 0, $calendar->month, 1, $calendar->year);
// This is GMT
$display->tend = gmmktime(23, 59, 59, $calendar->month, $display->maxdays, $calendar->year);
// GMT
$startwday = gmdate('w', $display->tstart);
// $display->tstart is already GMT, so don't use date(): messes with server's TZ
} else {
// no timezone info specified
$display->tstart = mktime(0, 0, 0, $calendar->month, 1, $calendar->year);
$display->tend = mktime(23, 59, 59, $calendar->month, $display->maxdays, $calendar->year);
$startwday = date('w', $display->tstart);
// $display->tstart not necessarily GMT, so use date()
}
// Align the starting weekday to fall in our display range
if ($startwday < $display->minwday) {
$startwday += 7;
}
// Get events from database
$events = calendar_get_events(usertime($display->tstart), usertime($display->tend), $calendar->users, $calendar->groups, $calendar->courses);
if (!empty($events)) {
foreach ($events as $eventid => $event) {
$event = new calendar_event($event);
if (!empty($event->modulename)) {
$cm = get_coursemodule_from_instance($event->modulename, $event->instance);
if (!groups_course_module_visible
|
请发表评论