/** * @return string */ public function getValue() { $value = $this->fetchRawValueFromDataSource(); if (empty($value)) { return null; } if (function_exists('get_user_timezone')) { $timezone = get_user_timezone(); if (!$timezone instanceof \DateTimeZone) { return $value; } if ($value instanceof \DateTime) { $value->setTimezone($timezone); return $value->format($this->format); } } try { $date = new \DateTime($value); return $date->format($this->format); } catch (\Exception $e) { return $e->getMessage(); } }
vertical-align: middle; width: 100%; } </style> <!-- End of the page scripts -- <script type="text/javascript"> // Current Server Time script (SSI or PHP)- By JavaScriptKit.com (http://www.javascriptkit.com) // For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/ // This notice must stay intact for use. //Depending on whether your page supports SSI (.shtml) or PHP (.php), UNCOMMENT the line below your page supports and COMMENT the one it does not: //Default is that SSI method is uncommented, and PHP is commented: var currenttime = '<?php echo date("F d, Y H:i:s", get_user_time(local_to_gmt(), get_user_timezone())); ?> ' //PHP method of getting server date ///////////Stop editting here///////////////////////////////// var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December") var serverdate=new Date(currenttime) function padlength(what){ var output=(what.toString().length==1)? "0"+what : what return output } function displaytime(){ serverdate.setSeconds(serverdate.getSeconds()+1)
?> </td> <td><?php echo word_limiter($city->known, 4); ?> </td> <td><?php if ($city->is_home == 0) { echo translate_admin('No'); } else { echo translate_admin('Yes'); } ?> </td> <td><?php echo get_user_times($city->created, get_user_timezone()); ?> </td> <td><a href="<?php echo admin_url('neighbourhoods/editcity/' . $city->id); ?> "> <img src="<?php echo base_url(); ?> images/edit-new.png" alt="Edit" title="Edit" /></a> <a href="<?php echo admin_url('neighbourhoods/deletecity/' . $city->id); ?> " onclick="return confirm('Are you sure want to delete??');"><img src="<?php echo base_url();
/** * @global object * @param object $message message to be displayed. * @param mixed $chatuser user chat data * @param object $currentuser current user for whom the message should be displayed. * @param int $groupingid course module grouping id * @param string $theme name of the chat theme. * @return bool|string Returns HTML or false */ function chat_format_message_theme($message, $chatuser, $currentuser, $groupingid, $theme = 'bubble') { global $CFG, $USER, $OUTPUT, $COURSE, $DB, $PAGE; require_once $CFG->dirroot . '/mod/chat/locallib.php'; static $users; // Cache user lookups $result = new stdClass(); if (file_exists($CFG->dirroot . '/mod/chat/gui_ajax/theme/' . $theme . '/config.php')) { include $CFG->dirroot . '/mod/chat/gui_ajax/theme/' . $theme . '/config.php'; } if (isset($users[$message->userid])) { $sender = $users[$message->userid]; } else { if ($sender = $DB->get_record('user', array('id' => $message->userid), user_picture::fields())) { $users[$message->userid] = $sender; } else { return NULL; } } $USER->timezone = 99; $tz = get_user_timezone($currentuser->timezone); $USER->timezone = $tz; if (empty($chatuser->course)) { $courseid = $COURSE->id; } else { $courseid = $chatuser->course; } $message->strtime = userdate($message->timestamp, get_string('strftimemessage', 'chat'), $tz); $message->picture = $OUTPUT->user_picture($sender, array('courseid' => $courseid)); $message->picture = "<a target='_blank' href=\"{$CFG->wwwroot}/user/view.php?id={$sender->id}&course={$courseid}\">{$message->picture}</a>"; // Start processing the message if (!empty($message->system)) { $result->type = 'system'; $senderprofile = $CFG->wwwroot . '/user/view.php?id=' . $sender->id . '&course=' . $courseid; $event = get_string('message' . $message->message, 'chat', fullname($sender)); $eventmessage = new event_message($senderprofile, fullname($sender), $message->strtime, $event, $theme); $output = $PAGE->get_renderer('mod_chat'); $result->html = $output->render($eventmessage); return $result; } // It's not a system event $text = trim($message->message); /// Parse the text to clean and filter it $options = new stdClass(); $options->para = false; $text = format_text($text, FORMAT_MOODLE, $options, $courseid); // And now check for special cases $special = false; $outtime = $message->strtime; // Initialise variables. $outmain = ''; $patternTo = '#^\\s*To\\s([^:]+):(.*)#'; if (substr($text, 0, 5) == 'beep ') { $special = true; /// It's a beep! $result->type = 'beep'; $beepwho = trim(substr($text, 5)); if ($beepwho == 'all') { // everyone $outmain = get_string('messagebeepseveryone', 'chat', fullname($sender)); } else { if ($beepwho == $currentuser->id) { // current user $outmain = get_string('messagebeepsyou', 'chat', fullname($sender)); } else { if ($sender->id == $currentuser->id) { //something is not caught? //allow beep for a active chat user only, else user can beep anyone and get fullname if (!empty($chatuser) && is_numeric($beepwho)) { $chatusers = chat_get_users($chatuser->chatid, $chatuser->groupid, $groupingid); if (array_key_exists($beepwho, $chatusers)) { $outmain = get_string('messageyoubeep', 'chat', fullname($chatusers[$beepwho])); } else { $outmain = get_string('messageyoubeep', 'chat', $beepwho); } } else { $outmain = get_string('messageyoubeep', 'chat', $beepwho); } } } } } else { if (substr($text, 0, 1) == '/') { /// It's a user command $special = true; $result->type = 'command'; $pattern = '#(^\\/)(\\w+).*#'; preg_match($pattern, $text, $matches); $command = isset($matches[2]) ? $matches[2] : false; // Support some IRC commands. switch ($command) { case 'me': $outmain = '*** <b>' . $sender->firstname . ' ' . substr($text, 4) . '</b>'; break; default: // Error, we set special back to false to use the classic message output. $special = false; break; } } else { if (preg_match($patternTo, $text)) { $special = true; $result->type = 'dialogue'; $matches = array(); preg_match($patternTo, $text, $matches); if (isset($matches[1]) && isset($matches[2])) { $outmain = $sender->firstname . ' <b>' . get_string('saidto', 'chat') . '</b> <i>' . $matches[1] . '</i>: ' . $matches[2]; } else { // Error, we set special back to false to use the classic message output. $special = false; } } } } if (!$special) { $outmain = $text; } $result->text = strip_tags($outtime . ': ' . $outmain); $mymessageclass = ''; if ($sender->id == $USER->id) { $mymessageclass = 'chat-message-mymessage'; } $senderprofile = $CFG->wwwroot . '/user/view.php?id=' . $sender->id . '&course=' . $courseid; $usermessage = new user_message($senderprofile, fullname($sender), $message->picture, $mymessageclass, $outtime, $outmain, $theme); $output = $PAGE->get_renderer('mod_chat'); $result->html = $output->render($usermessage); //When user beeps other user, then don't show any timestamp to other users in chat. if ('' === $outmain && $special) { return false; } else { return $result; } }
/** * Build and store the users Daylight Saving Time (DST) table * * @package core * @param int $fromyear Start year for the table, defaults to 1971 * @param int $toyear End year for the table, defaults to 2035 * @param int|float|string $strtimezone timezone to check if dst should be applied. * @return bool */ function calculate_user_dst_table($fromyear = null, $toyear = null, $strtimezone = null) { global $SESSION, $DB; $usertz = get_user_timezone($strtimezone); if (is_float($usertz)) { // Trivial timezone, no DST. return false; } if (!empty($SESSION->dst_offsettz) && $SESSION->dst_offsettz != $usertz) { // We have pre-calculated values, but the user's effective TZ has changed in the meantime, so reset. unset($SESSION->dst_offsets); unset($SESSION->dst_range); } if (!empty($SESSION->dst_offsets) && empty($fromyear) && empty($toyear)) { // Repeat calls which do not request specific year ranges stop here, we have already calculated the table. // This will be the return path most of the time, pretty light computationally. return true; } // Reaching here means we either need to extend our table or create it from scratch. // Remember which TZ we calculated these changes for. $SESSION->dst_offsettz = $usertz; if (empty($SESSION->dst_offsets)) { // If we 're creating from scratch, put the two guard elements in there. $SESSION->dst_offsets = array(1 => null, 0 => null); } if (empty($SESSION->dst_range)) { // If creating from scratch. $from = max((empty($fromyear) ? intval(date('Y')) - 3 : $fromyear), 1971); $to = min((empty($toyear) ? intval(date('Y')) + 3 : $toyear), 2035); // Fill in the array with the extra years we need to process. $yearstoprocess = array(); for ($i = $from; $i <= $to; ++$i) { $yearstoprocess[] = $i; } // Take note of which years we have processed for future calls. $SESSION->dst_range = array($from, $to); } else { // If needing to extend the table, do the same. $yearstoprocess = array(); $from = max((empty($fromyear) ? $SESSION->dst_range[0] : $fromyear), 1971); $to = min((empty($toyear) ? $SESSION->dst_range[1] : $toyear), 2035); if ($from < $SESSION->dst_range[0]) { // Take note of which years we need to process and then note that we have processed them for future calls. for ($i = $from; $i < $SESSION->dst_range[0]; ++$i) { $yearstoprocess[] = $i; } $SESSION->dst_range[0] = $from; } if ($to > $SESSION->dst_range[1]) { // Take note of which years we need to process and then note that we have processed them for future calls. for ($i = $SESSION->dst_range[1] + 1; $i <= $to; ++$i) { $yearstoprocess[] = $i; } $SESSION->dst_range[1] = $to; } } if (empty($yearstoprocess)) { // This means that there was a call requesting a SMALLER range than we have already calculated. return true; } // From now on, we know that the array has at least the two guard elements, and $yearstoprocess has the years we need // Also, the array is sorted in descending timestamp order! // Get DB data. static $presetscache = array(); if (!isset($presetscache[$usertz])) { $presetscache[$usertz] = $DB->get_records('timezone', array('name' => $usertz), 'year DESC', 'year, gmtoff, dstoff, dst_month, dst_startday, dst_weekday, dst_skipweeks, dst_time, std_month, '. 'std_startday, std_weekday, std_skipweeks, std_time'); } if (empty($presetscache[$usertz])) { return false; } // Remove ending guard (first element of the array). reset($SESSION->dst_offsets); unset($SESSION->dst_offsets[key($SESSION->dst_offsets)]); // Add all required change timestamps. foreach ($yearstoprocess as $y) { // Find the record which is in effect for the year $y. foreach ($presetscache[$usertz] as $year => $preset) { if ($year <= $y) { break; } } $changes = dst_changes_for_year($y, $preset); if ($changes === null) { continue; } if ($changes['dst'] != 0) { $SESSION->dst_offsets[$changes['dst']] = $preset->dstoff * MINSECS; } if ($changes['std'] != 0) { $SESSION->dst_offsets[$changes['std']] = 0; } } // Put in a guard element at the top. $maxtimestamp = max(array_keys($SESSION->dst_offsets)); $SESSION->dst_offsets[($maxtimestamp + DAYSECS)] = null; // DAYSECS is arbitrary, any "small" number will do. // Sort again. krsort($SESSION->dst_offsets); return true; }
echo translate("Details"); ?> </th> </tr> <?php foreach ($result->result() as $row) { ?> <tr> <td width="15%"> <p class="View_my_Accept_Bg"><span><?php echo $row->name; ?> </span></p> </td> <td width="30%"> <p> <?php echo get_user_times($row->checkin, get_user_timezone()) . ' - ' . get_user_times($row->checkout, get_user_timezone()); ?> </p> <br /> <p class="clsBold"> <?php echo anchor('rooms/' . $row->list_id, get_list_by_id($row->list_id)->title); ?> </p> <p> <?php echo get_list_by_id($row->list_id)->address; ?> </p> </td> <td width="25%"> <p> <img height="50" width="50" alt="image" style="float:left; margin:0 10px 10px 0;" src="<?php echo $this->Gallery->profilepic($row->userby, 2); ?>
public function test_get_user_timezone() { global $CFG, $USER; $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); $this->setUser($user); // All set to something. $this->setTimezone('Pacific/Auckland', 'Pacific/Auckland'); $USER->timezone = 'Europe/Prague'; $tz = get_user_timezone(); $this->assertSame('Europe/Prague', $tz); $tz = get_user_timezone(99); $this->assertSame('Europe/Prague', $tz); $tz = get_user_timezone('99'); $this->assertSame('Europe/Prague', $tz); $tz = get_user_timezone('Europe/Berlin'); $this->assertSame('Europe/Berlin', $tz); // User timezone not set. $this->setTimezone('Pacific/Auckland', 'Pacific/Auckland'); $USER->timezone = '99'; $tz = get_user_timezone(); $this->assertSame('Pacific/Auckland', $tz); $tz = get_user_timezone(99); $this->assertSame('Pacific/Auckland', $tz); $tz = get_user_timezone('99'); $this->assertSame('Pacific/Auckland', $tz); $tz = get_user_timezone('Europe/Berlin'); $this->assertSame('Europe/Berlin', $tz); // Server timezone not set. $this->setTimezone('99', 'Pacific/Auckland'); $USER->timezone = 'Europe/Prague'; $tz = get_user_timezone(); $this->assertSame('Europe/Prague', $tz); $tz = get_user_timezone(99); $this->assertSame('Europe/Prague', $tz); $tz = get_user_timezone('99'); $this->assertSame('Europe/Prague', $tz); $tz = get_user_timezone('Europe/Berlin'); $this->assertSame('Europe/Berlin', $tz); // Server and user timezone not set. $this->setTimezone('99', 'Pacific/Auckland'); $USER->timezone = '99'; $tz = get_user_timezone(); $this->assertSame(99.0, $tz); $tz = get_user_timezone(99); $this->assertSame(99.0, $tz); $tz = get_user_timezone('99'); $this->assertSame(99.0, $tz); $tz = get_user_timezone('Europe/Berlin'); $this->assertSame('Europe/Berlin', $tz); }
<div> <div class="clsH1_long_Border"> <?php //print_r($user->username);exit; ?> <h1> <?php echo ucfirst($user->username); ?> <?php if ($this->dx_auth->is_logged_in() || $this->facebook_lib->logged_in()) { ?> <span style="float:right;"><?php echo translate("Member from"); ?> <?php echo get_user_times($user->created, get_user_timezone()); ?> </span> <?php } ?> </h1> </div> <div style="clear:both"></div> </div> <div style="clear:both"></div> <div id="left"> <div id="user_box" class="Box"> <div class="Box_Content"> <div id="user_pic" onClick="show_ajax_image_box();" style="text-align:center; padding:0 0 10px 0;">
echo translate("Decline"); ?> </a> <div id="expired" style="display: none"><?php echo translate('Expired'); ?> </div> <div id="accept" style="display:none"> <form name="accept_req" action="<?php echo site_url('trips/accept'); ?> " method="post"> <p> <input type="checkbox" id="block_date" name="block_date" /> <?php echo translate("Block my calendar from") . " " . get_user_times($result->checkin, get_user_timezone()) . " " . translate("through") . " " . get_user_times($result->checkout, get_user_timezone()); ?> </p> <p><?php echo translate("Type optional message to guest") . "..."; ?> </p> <p><textarea name="comment" id="comment"></textarea></p> <p> <input type="hidden" id="checkout" name="reservation_id" value="<?php echo $result->id; ?> " />
?> </td> <td><?php echo $booker_name; ?> </td> <td><?php echo $hotelier_name; ?> </td> <td><?php echo get_user_times($row->checkin, get_user_timezone()); ?> </td> <td><?php echo get_user_times($row->checkout, get_user_timezone()); ?> </td> <td><?php echo get_currency_symbol($row->list_id) . get_currency_value1($row->list_id, $row->price); ?> </td> <td><?php echo $row->name; ?> </tr> <?php } ?> </tbody>
// @NOTE: if the user doesn't have permission to view users // it should be log out // see: https://github.com/directus/directus/issues/1268 if (!$users) { AuthProvider::logout(); $_SESSION['error_message'] = 'Your user doesn\'t have permission to log in'; header('Location: ' . DIRECTUS_PATH . 'login.php'); exit; } $currentUserInfo = getCurrentUserInfo($users); // Cache buster $git = __DIR__ . '/.git'; $cacheBuster = Directus\Util\Git::getCloneHash($git); $tableSchema = TableSchema::getAllSchemas($currentUserInfo['group']['id'], $cacheBuster); // $tabPrivileges = getTabPrivileges(($currentUserInfo['group']['id'])); $groupId = $currentUserInfo['group']['id']; $groups = getGroups(); $currentUserGroup = []; if (isset($groups['rows']) && count($groups['rows'] > 0)) { foreach ($groups['rows'] as $group) { if ($group['id'] === $groupId) { $currentUserGroup = $group; break; } } } $statusMapping = ['active_num' => STATUS_ACTIVE_NUM, 'deleted_num' => STATUS_DELETED_NUM, 'status_name' => STATUS_COLUMN_NAME]; $statusMapping['mapping'] = $config['statusMapping']; $data = ['cacheBuster' => $cacheBuster, 'nonces' => getNonces(), 'storage_adapters' => getStorageAdapters(), 'path' => DIRECTUS_PATH, 'page' => '#tables', 'tables' => parseTables($tableSchema), 'preferences' => parsePreferences($tableSchema), 'users' => $users, 'groups' => $groups, 'settings' => getSettings(), 'active_files' => getActiveFiles(), 'authenticatedUser' => $authenticatedUser, 'extensions' => getExtensions($currentUserGroup), 'privileges' => getPrivileges($groupId), 'ui' => getUI(), 'locale' => get_user_locale(), 'localesAvailable' => parseLocalesAvailable(get_locales_available()), 'phrases' => get_phrases(get_user_locale()), 'timezone' => get_user_timezone(), 'timezones' => get_timezone_list(), 'listViews' => getListViews(), 'messages' => getInbox(), 'user_notifications' => getLoginNotification(), 'bookmarks' => getBookmarks(), 'extendedUserColumns' => getExtendedUserColumns($tableSchema), 'statusMapping' => $statusMapping]; $templateVars = ['cacheBuster' => $cacheBuster, 'data' => json_encode($data), 'path' => DIRECTUS_PATH, 'locale' => get_user_locale(), 'dir' => 'ltr', 'customFooterHTML' => getCusomFooterHTML(), 'cssFilePath' => getCSSFilePath()]; echo template(file_get_contents('main.html'), $templateVars);
<td width="17%">--> <?php if (date('m/d/Y', get_user_time($row->checkin, get_user_timezone())) == date('m/d/Y', get_user_time(local_to_gmt(), get_user_timezone()))) { ?> <p class="clsBold"><?php if ($row->status == 3) { echo anchor('travelling/checkin/' . $row->id, translate("Checkin"), array('id' => 'checkin')); } ?> </p> <?php } ?> <?php if (date('m/d/Y', get_user_time($row->checkout, get_user_timezone())) <= date('m/d/Y', get_user_time(local_to_gmt(), get_user_timezone()))) { ?> <p class="clsBold"><?php if ($row->status == 7) { echo anchor('travelling/checkout/' . $row->id, translate("Checkout"), array('id' => 'checkout')); } ?> </p> <?php } ?> <p class="clsBold"><?php echo anchor('travelling/billing/' . $row->id, translate("View Billing")); ?> </p> <?php
echo $reset_message; } // Show error echo validation_errors(); $tmpl = array('table_open' => '<table class="table" border="0" cellpadding="4" cellspacing="0">', 'heading_row_start' => '<tr>', 'heading_row_end' => '</tr>', 'heading_cell_start' => '<th>', 'heading_cell_end' => '</th>', 'row_start' => '<tr>', 'row_end' => '</tr>', 'cell_start' => '<td>', 'cell_end' => '</td>', 'row_alt_start' => '<tr>', 'row_alt_end' => '</tr>', 'cell_alt_start' => '<td>', 'cell_alt_end' => '</td>', 'table_close' => '</table>'); $this->table->set_template($tmpl); $this->table->set_heading('', translate_admin('Username'), translate_admin('Email'), translate_admin('Role'), translate_admin('Banned'), translate_admin('Last IP'), translate_admin('Last login'), translate_admin('Created'), translate_admin('Edit'), translate_admin('Change Password')); foreach ($users as $user) { if ($this->db->where('id', $user->id)->get('profiles')->num_rows() != 0) { if ($user->role_id == 2) { $role = 'admin'; } else { $role = 'user'; } $banned = $user->banned == 1 ? 'Yes' : 'No'; $this->table->add_row(form_checkbox('checkbox_' . $user->id, $user->id), $user->username, $user->email, $role, $banned, $user->last_ip, get_user_times($user->last_login, get_user_timezone()), get_user_times($user->created, get_user_timezone()), anchor('administrator/members/edit/' . $user->id, translate_admin('Edit')), anchor('administrator/members/changepassword/' . $user->id, translate_admin('change passwords'))); } } echo '<div class="clsFloatRight">'; echo '<form name="myform" action="' . site_url('administrator/members/getusers') . '" method="post">'; ?> <!-- //echo '<b>Search Username / Email</b><input type="text" name="usersearch" id="usersearch" style="margin:0 10px; height:23px;">'; --> <b><?php echo translate_admin('Search Username / Email'); ?> </b><input type="text" name="usersearch" id="usersearch" style="margin:0 10px; height:23px;"> <!-- echo '<input type="submit" name="search" value="Search">'; --> <input type="submit" name="search" value="<?php echo translate_admin('Search'); ?>
/** * @method get_clean_timezone * @todo Gets a clean timezone attempting to compensate for some Moodle 'special' timezones * where the returned zone is compatible with PHP DateTime, DateTimeZone etc functions * @param string/float $tz either a location identifier string or, in some Moodle special cases, a number * @return string a clean timezone that can be used safely */ function get_clean_timezone($tz = null) { global $CFG, $DB; $cleanzones = DateTimeZone::listIdentifiers(); if (empty($tz)) { $tz = get_user_timezone(); } //if already a good zone, return if (in_array($tz, $cleanzones, true)) { return $tz; } //for when all else fails $default = 'Europe/London'; //try to handle UTC offsets, and numbers including '99' (server local time) //note: some old versions of moodle had GMT offsets stored as floats if (is_numeric($tz)) { if (intval($tz) == 99) { //check various config settings to try and resolve to something useful if (isset($CFG->forcetimezone) && $CFG->forcetimezone != 99) { $tz = $CFG->forcetimezone; } else if (isset($CFG->timezone) && $CFG->timezone != 99) { $tz = $CFG->timezone; } } if (intval($tz) == 99) { //no useful CFG settings, try a system call $tz = date_default_timezone_get(); } //do we have something useful yet? if (in_array($tz, $cleanzones, true)) { return $tz; } //check the bad timezone replacement list if (is_float($tz)) { $tz = number_format($tz, 1); } $badzones = $this->get_bad_timezone_list(); //does this exist in our replacement list? if (in_array($tz, array_keys($badzones))) { return $badzones[$tz]; } } //everything has failed, set to London return $default; }
function dimdim_format_message_manually($message, $courseid, $sender, $currentuser, $dimdim_lastrow = NULL) { global $CFG, $USER; $output = new stdClass(); $output->beep = false; // by default $output->refreshusers = false; // by default // Use get_user_timezone() to find the correct timezone for displaying this message: // It's either the current user's timezone or else decided by some Moodle config setting // First, "reset" $USER->timezone (which could have been set by a previous call to here) // because otherwise the value for the previous $currentuser will take precedence over $CFG->timezone $USER->timezone = 99; $tz = get_user_timezone($currentuser->timezone); // Before formatting the message time string, set $USER->timezone to the above. // This will allow dst_offset_on (called by userdate) to work correctly, otherwise the // message times appear off because DST is not taken into account when it should be. $USER->timezone = $tz; $message->strtime = userdate($message->timestamp, get_string('strftimemessage', 'dimdim'), $tz); $message->picture = print_user_picture($sender->id, 0, $sender->picture, false, true, false); if ($courseid) { $message->picture = "<a target=\"_new\" href=\"{$CFG->wwwroot}/user/view.php?id={$sender->id}&course={$courseid}\">{$message->picture}</a>"; } //Calculate the row class if ($dimdim_lastrow !== NULL) { $rowclass = ' class="r' . $dimdim_lastrow . '" '; } else { $rowclass = ''; } // Start processing the message if (!empty($message->system)) { // System event $output->text = $message->strtime . ': ' . get_string('message' . $message->message, 'dimdim', fullname($sender)); $output->html = '<table class="dimdim-event"><tr' . $rowclass . '><td class="picture">' . $message->picture . '</td><td class="text">'; $output->html .= '<span class="event">' . $output->text . '</span></td></tr></table>'; if ($message->message == 'exit' or $message->message == 'enter') { $output->refreshusers = true; //force user panel refresh ASAP } return $output; } // It's not a system event $text = $message->message; /// Parse the text to clean and filter it $options->para = false; $text = format_text($text, FORMAT_MOODLE, $options, $courseid); // And now check for special cases if (substr($text, 0, 5) == 'beep ') { /// It's a beep! $beepwho = trim(substr($text, 5)); if ($beepwho == 'all') { // everyone $outinfo = $message->strtime . ': ' . get_string('messagebeepseveryone', 'dimdim', fullname($sender)); $outmain = ''; $output->beep = true; // (eventually this should be set to // to a filename uploaded by the user) } else { if ($beepwho == $currentuser->id) { // current user $outinfo = $message->strtime . ': ' . get_string('messagebeepsyou', 'dimdim', fullname($sender)); $outmain = ''; $output->beep = true; } else { return false; } } } else { if (substr($text, 0, 1) == ':') { /// It's an MOO emote $outinfo = $message->strtime; $outmain = $sender->firstname . ' ' . substr($text, 1); } else { if (substr($text, 0, 1) == '/') { /// It's a user command if (substr($text, 0, 4) == "/me ") { $outinfo = $message->strtime; $outmain = $sender->firstname . ' ' . substr($text, 4); } else { $outinfo = $message->strtime; $outmain = $text; } } else { /// It's a normal message $outinfo = $message->strtime . ' ' . $sender->firstname; $outmain = $text; } } } /// Format the message as a small table $output->text = strip_tags($outinfo . ': ' . $outmain); $output->html = "<table class=\"dimdim-message\"><tr{$rowclass}><td class=\"picture\">{$message->picture}</td><td class=\"text\">"; $output->html .= "<span class=\"title\">{$outinfo}</span>"; if ($outmain) { $output->html .= ": {$outmain}"; } $output->html .= "</td></tr></table>"; return $output; }
<li class="top col-md-12 col-sm-12 col-xs-12 padding-zero"> <span class="label col-md-3 col-sm-3 col-xs-12"><span class="inner"><span class="checkout_icon" id="icon_check_in"></span><?php echo translate("Check in"); ?> </span></span> <span class="data col-md-9 col-sm-9 col-xs-12"><span class="inner"> <?php echo get_user_times(get_gmt_time(strtotime($checkin)), get_user_timezone()); ?> <em class="check_in_out_time"><?php echo translate("(Flexible check in time)"); ?> </em></span></span> </li> <li class="col-md-12 col-sm-12 col-xs-12 padding-zero"> <span class="label col-md-3 col-sm-3 col-xs-12"><span class="inner"><span class="checkout_icon" id="icon_check_out"></span><?php echo translate("Check out"); ?> </span></span> <span class="data col-md-9 col-sm-9 col-xs-12"><span class="inner"> <?php echo get_user_times(get_gmt_time(strtotime($checkout)), get_user_timezone()); ?> <em class="check_in_out_time"><?php echo translate("(Flexible check out time)"); ?> </em></span></span> </li> <li class=" col-md-12 col-sm-12 col-xs-12 padding-zero"> <span class="label col-md-3 col-sm-3 col-xs-12"><span class="inner"><span class="checkout_icon" id="icon_nights"></span><?php echo translate("Nights"); ?> </span></span> <span class="data col-md-9 col-sm-9 col-xs-12"><span class="inner"><?php echo $days; ?> </span></span> </li> <li class="bottom col-md-12 col-sm-12 col-xs-12 padding-zero"> <span class="label col-md-3 col-sm-3 col-xs-12"><span class="inner"><span class="checkout_icon" id="icon_person"></span><?php
/** * @global object * @param object $message message to be displayed. * @param mixed $chatuser user chat data * @param object $currentuser current user for whom the message should be displayed. * @param int $groupingid course module grouping id * @param string $theme name of the chat theme. * @return bool|string Returns HTML or false */ function chat_format_message_theme ($message, $chatuser, $currentuser, $groupingid, $theme = 'bubble') { global $CFG, $USER, $OUTPUT, $COURSE, $DB; static $users; // Cache user lookups $result = new stdClass(); if (file_exists($CFG->dirroot . '/mod/chat/gui_ajax/theme/'.$theme.'/config.php')) { include($CFG->dirroot . '/mod/chat/gui_ajax/theme/'.$theme.'/config.php'); } if (isset($users[$message->userid])) { $sender = $users[$message->userid]; } else if ($sender = $DB->get_record('user', array('id'=>$message->userid), user_picture::fields())) { $users[$message->userid] = $sender; } else { return NULL; } $USER->timezone = 99; $tz = get_user_timezone($currentuser->timezone); $USER->timezone = $tz; if (empty($chatuser->course)) { $courseid = $COURSE->id; } else { $courseid = $chatuser->course; } $message->strtime = userdate($message->timestamp, get_string('strftimemessage', 'chat'), $tz); $message->picture = $OUTPUT->user_picture($sender, array('courseid'=>$courseid)); $message->picture = "<a target='_blank' href=\"$CFG->wwwroot/user/view.php?id=$sender->id&course=$courseid\">$message->picture</a>"; // Start processing the message if(!empty($message->system)) { $result->type = 'system'; $userlink = new moodle_url('/user/view.php', array('id'=>$message->userid,'course'=>$courseid)); $patterns = array(); $replacements = array(); $patterns[] = '___senderprofile___'; $patterns[] = '___sender___'; $patterns[] = '___time___'; $patterns[] = '___event___'; $replacements[] = $CFG->wwwroot.'/user/view.php?id='.$sender->id.'&course='.$courseid; $replacements[] = fullname($sender); $replacements[] = $message->strtime; $replacements[] = get_string('message'.$message->message, 'chat', fullname($sender)); $result->html = str_replace($patterns, $replacements, $chattheme_cfg->event_message); return $result; } // It's not a system event $text = $message->message; /// Parse the text to clean and filter it $options = new stdClass(); $options->para = false; $text = format_text($text, FORMAT_MOODLE, $options, $courseid); // And now check for special cases $special = false; $outtime = $message->strtime; //Initilise output variable. $outmain = ''; if (substr($text, 0, 5) == 'beep ') { $special = true; /// It's a beep! $result->type = 'beep'; $beepwho = trim(substr($text, 5)); if ($beepwho == 'all') { // everyone $outmain = get_string('messagebeepseveryone', 'chat', fullname($sender)); } else if ($beepwho == $currentuser->id) { // current user $outmain = get_string('messagebeepsyou', 'chat', fullname($sender)); } else if ($sender->id == $currentuser->id) { //something is not caught? //allow beep for a active chat user only, else user can beep anyone and get fullname if (!empty($chatuser) && is_numeric($beepwho)) { $chatusers = chat_get_users($chatuser->chatid, $chatuser->groupid, $groupingid); if (array_key_exists($beepwho, $chatusers)) { $outmain = get_string('messageyoubeep', 'chat', fullname($chatusers[$beepwho])); } else { $outmain = get_string('messageyoubeep', 'chat', $beepwho); } } else { $outmain = get_string('messageyoubeep', 'chat', $beepwho); } } } else if (substr($text, 0, 1) == '/') { /// It's a user command $special = true; $result->type = 'command'; // support some IRC commands $pattern = '#(^\/)(\w+).*#'; preg_match($pattern, trim($text), $matches); $command = $matches[2]; $special = true; switch ($command){ case 'me': $outmain = '*** <b>'.$sender->firstname.' '.substr($text, 4).'</b>'; break; } } elseif (substr($text, 0, 2) == 'To') { $special = true; $result->type = 'dialogue'; $pattern = '#To[[:space:]](.*):(.*)#'; preg_match($pattern, trim($text), $matches); $special = true; $outmain = $sender->firstname.' <b>'.get_string('saidto', 'chat').'</b> <i>'.$matches[1].'</i>: '.$matches[2]; } if(!$special) { $outmain = $text; } $result->text = strip_tags($outtime.': '.$outmain); $ismymessage = ''; $rightalign = ''; if ($sender->id == $USER->id) { $ismymessage = ' class="mymessage"'; $rightalign = ' align="right"'; } $patterns = array(); $replacements = array(); $patterns[] = '___avatar___'; $patterns[] = '___sender___'; $patterns[] = '___senderprofile___'; $patterns[] = '___time___'; $patterns[] = '___message___'; $patterns[] = '___mymessageclass___'; $patterns[] = '___tablealign___'; $replacements[] = $message->picture; $replacements[] = fullname($sender); $replacements[] = $CFG->wwwroot.'/user/view.php?id='.$sender->id.'&course='.$courseid; $replacements[] = $outtime; $replacements[] = $outmain; $replacements[] = $ismymessage; $replacements[] = $rightalign; if (!empty($chattheme_cfg->avatar) and !empty($chattheme_cfg->align)) { if (!empty($ismymessage)) { $result->html = str_replace($patterns, $replacements, $chattheme_cfg->user_message_right); } else { $result->html = str_replace($patterns, $replacements, $chattheme_cfg->user_message_left); } } else { $result->html = str_replace($patterns, $replacements, $chattheme_cfg->user_message); } //When user beeps other user, then don't show any timestamp to other users in chat. if (('' === $outmain) && $special) { return false; } else { return $result; } }
public static function getTable($tbl_name) { $acl = Bootstrap::get('acl'); $zendDb = Bootstrap::get('ZendDb'); // TODO: getTable should return an empty object // or and empty array instead of false // in any given situation that the table // can be find or used. if (!self::canGroupViewTable($tbl_name)) { return false; } $info = SchemaManager::getTable($tbl_name); if (!$info) { return false; } if ($info) { $info['count'] = (int) $info['count']; $info['date_created'] = DateUtils::convertToISOFormat($info['date_created'], 'UTC', get_user_timezone()); $info['hidden'] = (bool) $info['hidden']; $info['single'] = (bool) $info['single']; $info['footer'] = (bool) $info['footer']; } $relationalTableGateway = new RelationalTableGateway($acl, $tbl_name, $zendDb); $info = array_merge($info, $relationalTableGateway->countActiveOld()); $info['columns'] = self::getSchemaArray($tbl_name); $directusPreferencesTableGateway = new DirectusPreferencesTableGateway($acl, $zendDb); $currentUser = Auth::getUserInfo(); $info['preferences'] = $directusPreferencesTableGateway->fetchByUserAndTable($currentUser['id'], $tbl_name); return $info; }
/** * 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; }
public function sync_cal($ical_id) { require_once "app/views/templates/blue/rooms/codebase/class.php"; $exporter = new ICalExporter(); $ical_urls = $this->db->where('id', $ical_id)->get('ical_import'); if ($ical_urls->num_rows() != 0) { foreach ($ical_urls->result() as $row) { $ical_content = file_get_contents($row->url); $events = $exporter->toHash($ical_content); $success_num = 0; $error_num = 0; $id = $row->list_id; /*! inserting events in database */ $check_tb = $this->db->select('group_id')->where('list_id', $id)->order_by('id', 'desc')->limit(1)->get('calendar'); //$query = $this->db->last_query(); //echo $query;exit; //print_r($check_tb->num_rows());exit; if ($check_tb->num_rows() != 0) { $i1 = $check_tb->row()->group_id; } else { $i1 = 1; } for ($i = 1; $i <= count($events); $i++) { $event = $events[$i]; $days = (strtotime($event["end_date"]) - strtotime($event["start_date"])) / (60 * 60 * 24); $created = $event["start_date"]; for ($j = 1; $j <= $days; $j++) { if ($days == 1) { $direct = 'single'; } else { if ($days > 1) { if ($j == 1) { $direct = 'left'; } else { if ($days == $j) { $direct = 'right'; } else { $direct = 'both'; } } } } $startdate1 = $event["start_date"]; $check_dates = $this->db->where('list_id', $id)->where('booked_days', strtotime($startdate1))->get('calendar'); if ($check_dates->num_rows() != 0) { $conflict = $i; } else { $data = array('id' => NULL, 'list_id' => $id, 'group_id' => $i + $i1, 'availability' => "Booked", 'value' => 0, 'currency' => "EUR", 'notes' => "Not Available", 'style' => $direct, 'booked_using' => 0, 'booked_days' => strtotime($startdate1), 'created' => strtotime($created)); $this->Common_model->insertData('calendar', $data); } // if(isset($conflict)) // { // $this->db->where('list_id',$id)->where('group_id',$conflict)->delete('calendar'); // } $abc = $event["start_date"]; $newdate = strtotime('+1 day', strtotime($abc)); $event["start_date"] = date("m/d/Y", $newdate); } $success_num++; } //for loop end $update_sync['last_sync'] = date('d M Y, g:i a', gmt_to_local(time(), get_user_timezone(), false)); $this->db->where('id', $row->id)->update('ical_import', $update_sync); } } redirect('rooms/lys_next/edit/' . $ical_urls->row()->list_id); }
$cm = get_coursemodule_from_instance("turnitintooltwo", $assignmentid); if (has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id))) { $fieldname = required_param('name', PARAM_ALPHA); switch ($fieldname) { case 'partname': $fieldvalue = required_param('value', PARAM_TEXT); break; case "maxmarks": $fieldvalue = required_param('value', PARAM_RAW); break; case "dtstart": case "dtdue": case "dtpost": $fieldvalue = required_param('value', PARAM_RAW); // We need to work out the users timezone or GMT offset. $usertimezone = get_user_timezone(); if (is_numeric($usertimezone)) { if ($usertimezone > 13) { $usertimezone = ""; } else { if ($usertimezone <= 13 && $usertimezone > 0) { $usertimezone = "GMT+{$usertimezone}"; } else { if ($usertimezone < 0) { $usertimezone = "GMT{$usertimezone}"; } else { $usertimezone = 'GMT'; } } } }
?> </td> <td><?php echo $photographer->photographer_web; ?> </td> <td><?php if ($photographer->is_featured == 0) { echo translate_admin('No'); } else { echo translate_admin('Yes'); } ?> </td> <td><?php echo get_user_times($photographer->created, get_user_timezone()); ?> </td> <td><a href="<?php echo admin_url('neighbourhoods/editphotographer/' . $photographer->id); ?> "> <img src="<?php echo base_url(); ?> images/edit-new.png" alt="Edit" title="Edit" /></a> <a href="<?php echo admin_url('neighbourhoods/deletephotographer/' . $photographer->id); ?> " onclick="return confirm('Are you sure want to delete??');"><img src="<?php echo base_url();
<?php echo $message->name; ?> <?php echo translate("about"); ?> "<?php echo anchor('rooms/' . $message->list_id, get_list_by_id($message->list_id)->title); ?> " </p> <!--<?php if ($message->message_type != 6) { ?> <p><label><?php echo get_user_times($message->checkin, get_user_timezone()) . ' - ' . get_user_times($message->checkout, get_user_timezone()); ?> </label><label><?php echo $message->no_quest . ' ' . translate("guest"); ?> </label></p> <?php } ?> --> <span class="clsTypeConver_Arow1"></span> </div> <?php } ?>
echo $Admin_key->id; ?> " />  <?php echo $i++; ?> </td> <td><?php echo $Admin_key->page_key; ?> </td> <!--<td><?php echo $Admin_key->page_refer; ?> </td>--> <td><?php echo get_user_times($Admin_key->created, get_user_timezone()); ?> </td> <?php if ($Admin_key->status == '0') { $status = translate_admin('Active'); } else { $status = translate_admin('In Active'); } ?> <td><?php echo $status; ?> </td> <td><a href="<?php echo admin_url('admin_key/editAdmin_key/' . $Admin_key->id);
<?php session_name('socialclick'); session_start(); include 'Lib/harryd_error_handler.php'; require 'Lib/db.php'; include 'Lib/function.php'; //Global Function and Must On the top include_once 'Lib/visitor.php'; require 'Lib/user.php'; include 'Lib/page.php'; include 'Lib/shorturl.php'; include 'Lib/link.php'; include 'Lib/StatsUrl.php'; $db = new db(); //init mysqli db if (basename($_SERVER["SCRIPT_FILENAME"], '') !== 's.php') { // xpaya set kalau script s.php get_user_timezone(); date_default_timezone_set($_SESSION['timezone']); }
foreach ($result->result() as $row) { echo $this->db->where('id', $row->category_id)->get('neigh_category')->row()->category . ','; } } ?> </td> <td><?php if ($place->is_featured == 0) { echo translate_admin('No'); } else { echo translate_admin('Yes'); } ?> </td> <td><?php echo get_user_times($place->created, get_user_timezone()); ?> </td> <td><a href="<?php echo admin_url('neighbourhoods/editcity_place/' . $place->id); ?> "> <img src="<?php echo base_url(); ?> images/edit-new.png" alt="Edit" title="Edit" /></a> <a href="<?php echo admin_url('neighbourhoods/deletecity_place/' . $place->id); ?> " onclick="return confirm('Are you sure want to delete??');"><img src="<?php echo base_url();
/** * Processes the data passed by the part update form from the summary page * * @param object $cm The moodle course module object for this instance * @param object $turnitintool The turnitintool object is for this activity * @param array $post The post array from the part update form * @return array A notice array contains error details for display on page load in the case of an error nothing returned if no errors occur */ function turnitintool_update_partnames($cm, $turnitintool, $post) { global $CFG, $USER; if (has_capability('mod/turnitintool:grade', turnitintool_get_context('MODULE', $cm->id))) { $notice['message'] = ''; $error = false; $dtstart = make_timestamp($post["dtstart"]["year"], $post["dtstart"]["month"], $post["dtstart"]["day"], $post["dtstart"]["hour"], $post["dtstart"]["minute"], 0, get_user_timezone()); $dtdue = make_timestamp($post["dtdue"]["year"], $post["dtdue"]["month"], $post["dtdue"]["day"], $post["dtdue"]["hour"], $post["dtdue"]["minute"], 0, get_user_timezone()); $dtpost = make_timestamp($post["dtpost"]["year"], $post["dtpost"]["month"], $post["dtpost"]["day"], $post["dtpost"]["hour"], $post["dtpost"]["minute"], 0, get_user_timezone()); if ($dtstart >= $dtdue) { $notice['message'] .= get_string('partstarterror', 'turnitintool'); $error = true; } if ($dtpost < $dtstart) { $notice['message'] .= get_string('partdueerror', 'turnitintool'); $error = true; } if (empty($post['partname'])) { $notice['message'] .= get_string('partnameerror', 'turnitintool'); $error = true; } if (strlen($post['partname']) > 35) { $input = new stdClass(); $input->length = 35; $input->field = get_string('partname', 'turnitintool'); $notice['message'] .= get_string('maxlength', 'turnitintool', $input); $error = true; } if (!preg_match("/^[-]?[0-9]+([\\.][0-9]+)?\$/", $post['maxmarks'])) { // ENTRY IS NOT A NUMBER $notice['message'] .= get_string('partmarkserror', 'turnitintool'); $error = true; } if ($error) { $notice['error'] = $post['submitted']; $notice['post'] = $post; } if (!$error) { // Update Turnitin Assignment via the API [[[[ $tiipost = new stdClass(); $tiipost->ctl = turnitintool_getCTL($turnitintool->course); $tiipost->dtstart = $dtstart; $tiipost->dtdue = $dtdue; $tiipost->dtpost = $dtpost; if (turnitintool_is_owner($turnitintool->course)) { $owner = $USER; } else { $owner = turnitintool_get_owner($turnitintool->course); } if (!($course = turnitintool_get_record('course', 'id', $turnitintool->course))) { turnitintool_print_error('coursegeterror', 'turnitintool', NULL, NULL, __FILE__, __LINE__); exit; } $loaderbar = new turnitintool_loaderbarclass(3); $tii = new turnitintool_commclass(turnitintool_getUID($owner), $owner->firstname, $owner->lastname, $owner->email, 2, $loaderbar); $tii->startSession(); turnitintool_usersetup($owner, get_string('userprocess', 'turnitintool'), $tii, $loaderbar); turnitintool_classsetup($course, $owner, get_string('classprocess', 'turnitintool'), $tii, $loaderbar); if ($tii->getRerror()) { if ($tii->getAPIunavailable()) { turnitintool_print_error('apiunavailable', 'turnitintool', NULL, NULL, __FILE__, __LINE__); } else { turnitintool_print_error($tii->getRmessage(), NULL, NULL, NULL, __FILE__, __LINE__); } exit; } $tiipost->cid = turnitintool_getCID($turnitintool->course); $tiipost->assignid = turnitintool_getAID($post['submitted']); $tiipost->s_view_report = $turnitintool->studentreports; $tiipost->max_points = $post['maxmarks']; $tiipost->anon = $turnitintool->anon; $tiipost->report_gen_speed = $turnitintool->reportgenspeed; $tiipost->late_accept_flag = $turnitintool->allowlate; $tiipost->submit_papers_to = $turnitintool->submitpapersto; $tiipost->s_paper_check = $turnitintool->spapercheck; $tiipost->internet_check = $turnitintool->internetcheck; $tiipost->journal_check = $turnitintool->journalcheck; // Add in Exclude small matches, biblio, quoted etc 20102009 $tiipost->exclude_biblio = $turnitintool->excludebiblio; $tiipost->exclude_quoted = $turnitintool->excludequoted; $tiipost->exclude_value = $turnitintool->excludevalue; $tiipost->exclude_type = $turnitintool->excludetype; // Add in the erater settings $tiipost->erater = $turnitintool->erater; $tiipost->erater_handbook = $turnitintool->erater_handbook; $tiipost->erater_dictionary = $turnitintool->erater_dictionary; $tiipost->erater_spelling = $turnitintool->erater_spelling; $tiipost->erater_grammar = $turnitintool->erater_grammar; $tiipost->erater_usage = $turnitintool->erater_usage; $tiipost->erater_mechanics = $turnitintool->erater_mechanics; $tiipost->erater_style = $turnitintool->erater_style; $tiipost->transmatch = $turnitintool->transmatch; $tiipost->name = $turnitintool->name . ' - ' . $post['partname'] . ' (Moodle ' . $tiipost->assignid . ')'; $tiipost->currentassign = $turnitintool->name . ' - ' . turnitintool_partnamefromnum($post['submitted']) . ' (Moodle ' . $tiipost->assignid . ')'; $tii->createAssignment($tiipost, 'UPDATE', get_string('assignmentupdate', 'turnitintool', '')); if ($tii->getRerror()) { if ($tii->getRcode() == TURNITINTOOL_DB_UNIQUEID_ERROR) { $reason = get_string('assignmentdoesnotexist', 'turnitintool'); } else { $reason = $tii->getAPIunavailable() ? get_string('apiunavailable', 'turnitintool') : $tii->getRmessage(); } turnitintool_print_error('<strong>' . get_string('updateerror', 'turnitintool') . '</strong><br />' . $reason); exit; } $part = new stdClass(); $part->id = $post['submitted']; $part->dtstart = $dtstart; $part->dtdue = $dtdue; $part->dtpost = $dtpost; $part->partname = $post['partname']; $part->maxmarks = $post['maxmarks']; $part->deleted = 0; $event = new stdClass(); $event->timestart = $part->dtdue; $event->name = $turnitintool->name . ' - ' . $part->partname; $currentevent = $turnitintool->name . ' - ' . turnitintool_partnamefromnum($post['submitted']); if (!($dbpart = turnitintool_update_record('turnitintool_parts', $part, false))) { turnitintool_print_error('partdberror', 'turnitintool', NULL, NULL, __FILE__, __LINE__); } if ($events = turnitintool_get_record_select('event', "modulename='turnitintool' AND instance = ? AND name = ?", array($turnitintool->id, $currentevent))) { $event->id = $events->id; if (method_exists('calendar_event', 'update')) { $calendarevent = calendar_event::load($event->id); $calendarevent->update($event); } else { update_event($event); } } @(include_once $CFG->dirroot . "/lib/gradelib.php"); // Set the view time for Grade Book viewing if (function_exists('grade_update')) { $lastpart = turnitintool_get_record('turnitintool_parts', 'turnitintoolid', $turnitintool->id, '', '', '', '', 'max(dtpost)'); $lastpart = current($lastpart); $params['hidden'] = $lastpart; grade_update('mod/turnitintool', $turnitintool->course, 'mod', 'turnitintool', $turnitintool->id, 0, NULL, $params); } $tii->endSession(); turnitintool_redirect($CFG->wwwroot . '/mod/turnitintool/view.php' . '?id=' . $cm->id . '&do=intro'); exit; } else { return $notice; } } else { turnitintool_print_error('permissiondeniederror', 'turnitintool', NULL, NULL, __FILE__, __LINE__); } }
/** * @global object * @param object $message message to be displayed. * @param mixed $chatuser user chat data * @param object $currentuser current user for whom the message should be displayed. * @param int $groupingid course module grouping id * @param string $theme name of the chat theme. * @return bool|string Returns HTML or false */ function chat_format_message_theme($message, $chatuser, $currentuser, $groupingid, $theme = 'bubble') { global $CFG, $USER, $OUTPUT, $COURSE, $DB, $PAGE; require_once $CFG->dirroot . '/mod/chat/locallib.php'; static $users; // Cache user lookups $result = new stdClass(); $config = get_config('project'); $msgcount = $DB->get_record_sql("SELECT count(*) as msgcnt FROM `mdl_chat_messages_current` WHERE system = 0 AND groupid = ?", array($chatuser->groupid))->msgcnt; $mbrcount = $DB->get_record_sql("SELECT count(*) as mbrcnt FROM `mdl_groups_members` WHERE groupid = ?", array($chatuser->groupid))->mbrcnt; if ($msgcount > $mbrcount * 3) { //check to see if no alert has happened AND theres a little bit of conversation (3 times per # of group members) before analyzing //Added by Jeff Kurcz Apr 20, 2015 to check the last time an alert occurred for a specific user $lastalert = $DB->get_record_sql('SELECT substring(message,7,3) as alert, timestamp FROM `mdl_chat_messages_current` WHERE userid = ? AND system = 1 AND message LIKE ? ORDER BY timestamp DESC LIMIT 1', array($message->userid, 'alert%')); if ($lastalert->alert == 'low') { $alert_type = 'lowchatalertsfreq'; } else { $alert_type = 'highchatalertsfreq'; } $wait_until = $lastalert->timestamp + $config->{$alert_type} * 60; if (time() > $wait_until || !isset($lastalert)) { //If last alert happened over X minutes, we can check for new alerts. checkChatAlerts($chatuser); } //end if } //end if if (file_exists($CFG->dirroot . '/mod/chat/gui_ajax/theme/' . $theme . '/config.php')) { include $CFG->dirroot . '/mod/chat/gui_ajax/theme/' . $theme . '/config.php'; } if (isset($users[$message->userid])) { $sender = $users[$message->userid]; } else { if ($sender = $DB->get_record('user', array('id' => $message->userid), user_picture::fields())) { $users[$message->userid] = $sender; } else { return NULL; } } $USER->timezone = 99; $tz = get_user_timezone($currentuser->timezone); $USER->timezone = $tz; if (empty($chatuser->course)) { $courseid = $COURSE->id; } else { $courseid = $chatuser->course; } $message->strtime = userdate($message->timestamp, get_string('strftimemessage', 'chat'), $tz); $message->picture = $OUTPUT->user_picture($sender, array('courseid' => $courseid)); $message->picture = "<a target='_blank' href=\"{$CFG->wwwroot}/user/view.php?id={$sender->id}&course={$courseid}\">{$message->picture}</a>"; // Start processing the message if (!empty($message->system)) { $result->type = 'system'; $senderprofile = $CFG->wwwroot . '/user/view.php?id=' . $sender->id . '&course=' . $courseid; //Added by Jeff Kurcz Apr 18, 2015 to check if system message is an alert. if (substr($message->message, 0, 9) == 'alert-low') { $event = get_string(substr($message->message, 0, 9), 'chat', fullname($sender)); $eventmessage = new event_message(null, null, $message->strtime, $event, $theme); } else { if (substr($message->message, 0, 10) == 'alert-high') { $event = get_string(substr($message->message, 0, 10), 'chat', fullname($sender)); //Get low participator names $low = getLowParticipators($chatuser->groupid, $message->timestamp); if (strlen($low) > 1) { $event .= "Such as: " . $low . "<br />"; } $eventmessage = new event_message(null, null, $message->strtime, $event, $theme); } else { $event = get_string('message' . $message->message, 'chat', fullname($sender)); $eventmessage = new event_message($senderprofile, fullname($sender), $message->strtime, $event, $theme); } } $output = $PAGE->get_renderer('mod_chat'); $result->html = $output->render($eventmessage); //Added by Jeff Kurcz Apr 18, 2015 to only display alert to intended user. if (substr($message->message, 0, 5) == 'alert' && $USER->id == $sender->id) { return $result; } else { return false; } } // It's not a system event $text = trim($message->message); /// Parse the text to clean and filter it $options = new stdClass(); $options->para = false; $text = format_text($text, FORMAT_MOODLE, $options, $courseid); // And now check for special cases $special = false; $outtime = $message->strtime; // Initialise variables. $outmain = ''; $patternTo = '#^\\s*To\\s([^:]+):(.*)#'; if (substr($text, 0, 5) == 'beep ') { $special = true; /// It's a beep! $result->type = 'beep'; $beepwho = trim(substr($text, 5)); if ($beepwho == 'all') { // everyone $outmain = get_string('messagebeepseveryone', 'chat', fullname($sender)); } else { if ($beepwho == $currentuser->id) { // current user $outmain = get_string('messagebeepsyou', 'chat', fullname($sender)); } else { if ($sender->id == $currentuser->id) { //something is not caught? //allow beep for a active chat user only, else user can beep anyone and get fullname if (!empty($chatuser) && is_numeric($beepwho)) { $chatusers = chat_get_users($chatuser->chatid, $chatuser->groupid, $groupingid); if (array_key_exists($beepwho, $chatusers)) { $outmain = get_string('messageyoubeep', 'chat', fullname($chatusers[$beepwho])); } else { $outmain = get_string('messageyoubeep', 'chat', $beepwho); } } else { $outmain = get_string('messageyoubeep', 'chat', $beepwho); } } } } } else { if (substr($text, 0, 1) == '/') { /// It's a user command $special = true; $result->type = 'command'; $pattern = '#(^\\/)(\\w+).*#'; preg_match($pattern, $text, $matches); $command = isset($matches[2]) ? $matches[2] : false; // Support some IRC commands. switch ($command) { case 'me': $outmain = '*** <b>' . $sender->firstname . ' ' . substr($text, 4) . '</b>'; break; default: // Error, we set special back to false to use the classic message output. $special = false; break; } } else { if (preg_match($patternTo, $text)) { $special = true; $result->type = 'dialogue'; $matches = array(); preg_match($patternTo, $text, $matches); if (isset($matches[1]) && isset($matches[2])) { $outmain = $sender->firstname . ' <b>' . get_string('saidto', 'chat') . '</b> <i>' . $matches[1] . '</i>: ' . $matches[2]; } else { // Error, we set special back to false to use the classic message output. $special = false; } } } } if (!$special) { $outmain = $text; } $result->text = strip_tags($outtime . ': ' . $outmain); $mymessageclass = ''; if ($sender->id == $USER->id) { $mymessageclass = 'chat-message-mymessage'; } $senderprofile = $CFG->wwwroot . '/user/view.php?id=' . $sender->id . '&course=' . $courseid; $usermessage = new user_message($senderprofile, fullname($sender), $message->picture, $mymessageclass, $outtime, $outmain, $theme); $output = $PAGE->get_renderer('mod_chat'); $result->html = $output->render($usermessage); //When user beeps other user, then don't show any timestamp to other users in chat. if ('' === $outmain && $special) { return false; } else { return $result; } }
/** * @global object * @global object * @param object $message * @param int $courseid * @param object $sender * @param object $currentuser * @param string $chat_lastrow * @return bool|string Returns HTML or false */ function chat_format_message_manually($message, $courseid, $sender, $currentuser, $chat_lastrow = NULL) { global $CFG, $USER, $OUTPUT; $output = new object(); $output->beep = false; // by default $output->refreshusers = false; // by default // Use get_user_timezone() to find the correct timezone for displaying this message: // It's either the current user's timezone or else decided by some Moodle config setting // First, "reset" $USER->timezone (which could have been set by a previous call to here) // because otherwise the value for the previous $currentuser will take precedence over $CFG->timezone $USER->timezone = 99; $tz = get_user_timezone($currentuser->timezone); // Before formatting the message time string, set $USER->timezone to the above. // This will allow dst_offset_on (called by userdate) to work correctly, otherwise the // message times appear off because DST is not taken into account when it should be. $USER->timezone = $tz; $message->strtime = userdate($message->timestamp, get_string('strftimemessage', 'chat'), $tz); $message->picture = $OUTPUT->user_picture(moodle_user_picture::make($sender, $courseid)); if ($courseid) { $message->picture = "<a onclick=\"window.open('{$CFG->wwwroot}/user/view.php?id={$sender->id}&course={$courseid}')\" href=\"{$CFG->wwwroot}/user/view.php?id={$sender->id}&course={$courseid}\">{$message->picture}</a>"; } //Calculate the row class if ($chat_lastrow !== NULL) { $rowclass = ' class="r' . $chat_lastrow . '" '; } else { $rowclass = ''; } // Start processing the message if (!empty($message->system)) { // System event $output->text = $message->strtime . ': ' . get_string('message' . $message->message, 'chat', fullname($sender)); $output->html = '<table class="chat-event"><tr' . $rowclass . '><td class="picture">' . $message->picture . '</td><td class="text">'; $output->html .= '<span class="event">' . $output->text . '</span></td></tr></table>'; $output->basic = '<dl><dt class="event">' . $message->strtime . ': ' . get_string('message' . $message->message, 'chat', fullname($sender)) . '</dt></dl>'; if ($message->message == 'exit' or $message->message == 'enter') { $output->refreshusers = true; //force user panel refresh ASAP } return $output; } // It's not a system event $text = $message->message; /// Parse the text to clean and filter it $options = new object(); $options->para = false; $text = format_text($text, FORMAT_MOODLE, $options, $courseid); // And now check for special cases $special = false; if (substr($text, 0, 5) == 'beep ') { /// It's a beep! $special = true; $beepwho = trim(substr($text, 5)); if ($beepwho == 'all') { // everyone $outinfo = $message->strtime . ': ' . get_string('messagebeepseveryone', 'chat', fullname($sender)); $outmain = ''; $output->beep = true; // (eventually this should be set to // to a filename uploaded by the user) } else { if ($beepwho == $currentuser->id) { // current user $outinfo = $message->strtime . ': ' . get_string('messagebeepsyou', 'chat', fullname($sender)); $outmain = ''; $output->beep = true; } else { //something is not caught? return false; } } } else { if (substr($text, 0, 1) == '/') { /// It's a user command // support some IRC commands $pattern = '#(^\\/)(\\w+).*#'; preg_match($pattern, trim($text), $matches); $command = $matches[2]; switch ($command) { case 'me': $special = true; $outinfo = $message->strtime; $outmain = '*** <b>' . $sender->firstname . ' ' . substr($text, 4) . '</b>'; break; } } elseif (substr($text, 0, 2) == 'To') { $pattern = '#To[[:space:]](.*):(.*)#'; preg_match($pattern, trim($text), $matches); $special = true; $outinfo = $message->strtime; $outmain = $sender->firstname . ' ' . get_string('saidto', 'chat') . ' <i>' . $matches[1] . '</i>: ' . $matches[2]; } } if (!$special) { $outinfo = $message->strtime . ' ' . $sender->firstname; $outmain = $text; } /// Format the message as a small table $output->text = strip_tags($outinfo . ': ' . $outmain); $output->html = "<table class=\"chat-message\"><tr{$rowclass}><td class=\"picture\" valign=\"top\">{$message->picture}</td><td class=\"text\">"; $output->html .= "<span class=\"title\">{$outinfo}</span>"; if ($outmain) { $output->html .= ": {$outmain}"; $output->basic = '<dl><dt class="title">' . $outinfo . ':</dt><dd class="text">' . $outmain . '</dd></dl>'; } else { $output->basic = '<dl><dt class="title">' . $outinfo . '</dt></dl>'; } $output->html .= "</td></tr></table>"; return $output; }
public function convertDates(array $records, array $schemaArray, $tableName = null) { $tableName = $tableName === null ? $this->table : $tableName; if (!SchemaManager::isDirectusTable($tableName)) { return $records; } // ========================================================================== // hotfix: records sometimes are no set as an array of rows. // NOTE: this code is duplicate @see: AbstractSchema::parseRecordValuesByType // ========================================================================== $singleRecord = false; if (!is_numeric_keys_array($records)) { $records = [$records]; $singleRecord = true; } foreach ($records as $index => $row) { foreach ($schemaArray as $column) { if (in_array(strtolower($column['type']), ['timestamp', 'datetime'])) { $columnName = $column['id']; if (array_key_exists($columnName, $row)) { $records[$index][$columnName] = DateUtils::convertToISOFormat($row[$columnName], 'UTC', get_user_timezone()); } } } } return $singleRecord ? reset($records) : $records; }