本文整理汇总了PHP中api_get_local_time函数的典型用法代码示例。如果您正苦于以下问题:PHP api_get_local_time函数的具体用法?PHP api_get_local_time怎么用?PHP api_get_local_time使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了api_get_local_time函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Creates the mPDF object
* @param string $pageFormat format A4 A4-L see http://mpdf1.com/manual/index.php?tid=184&searchstring=format
* @param string $orientation orientation "P" = Portrait "L" = Landscape
* @param array $params
* @param Template $template
*/
public function __construct($pageFormat = 'A4', $orientation = 'P', $params = array(), $template = null)
{
$this->template = $template;
/* More info @ http://mpdf1.com/manual/index.php?tid=184&searchstring=mPDF
* mPDF ([ string $mode [, mixed $format [, float $default_font_size [, string $default_font [, float $margin_left , float $margin_right , float $margin_top , float $margin_bottom , float $margin_header , float $margin_footer [, string $orientation ]]]]]])
*/
if (!in_array($orientation, array('P', 'L'))) {
$orientation = 'P';
}
//$this->pdf = $pdf = new mPDF('UTF-8', $pageFormat, '', '', 30, 20, 27, 25, 16, 13, $orientation);
//left, right, top, bottom, margin_header, margin footer
$params['left'] = isset($params['left']) ? $params['left'] : 15;
$params['right'] = isset($params['right']) ? $params['right'] : 15;
$params['top'] = isset($params['top']) ? $params['top'] : 20;
$params['bottom'] = isset($params['bottom']) ? $params['bottom'] : 15;
$this->params['filename'] = isset($params['filename']) ? $params['filename'] : api_get_local_time();
$this->params['pdf_title'] = isset($params['pdf_title']) ? $params['pdf_title'] : get_lang('Untitled');
$this->params['course_info'] = isset($params['course_info']) ? $params['course_info'] : api_get_course_info();
$this->params['session_info'] = isset($params['session_info']) ? $params['session_info'] : api_get_session_info(api_get_session_id());
$this->params['course_code'] = isset($params['course_code']) ? $params['course_code'] : api_get_course_id();
$this->params['add_signatures'] = isset($params['add_signatures']) ? $params['add_signatures'] : false;
$this->params['show_real_course_teachers'] = isset($params['show_real_course_teachers']) ? $params['show_real_course_teachers'] : false;
$this->params['student_info'] = isset($params['student_info']) ? $params['student_info'] : false;
$this->params['show_grade_generated_date'] = isset($params['show_grade_generated_date']) ? $params['show_grade_generated_date'] : false;
$this->params['show_teacher_as_myself'] = isset($params['show_teacher_as_myself']) ? $params['show_teacher_as_myself'] : true;
$this->params['pdf_date'] = isset($params['pdf_date']) ? $params['pdf_date'] : api_format_date(api_get_local_time(), DATE_TIME_FORMAT_LONG);
$this->pdf = new mPDF('UTF-8', $pageFormat, '', '', $params['left'], $params['right'], $params['top'], $params['bottom'], 8, 8, $orientation);
}
示例2: get_request_data
/**
* Get course data to display
*/
function get_request_data($from, $number_of_items, $column, $direction)
{
global $keyword;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
$sql = "SELECT id AS col0,\n code AS col1,\n title AS col2,\n category_code AS col3,\n tutor_name AS col4,\n request_date AS col5,\n id AS col6\n FROM {$course_request_table}\n WHERE status = " . COURSE_REQUEST_ACCEPTED;
if ($keyword != '') {
$sql .= " AND (title LIKE '%" . $keyword . "%' OR code LIKE '%" . $keyword . "%' OR visual_code LIKE '%" . $keyword . "%')";
}
$sql .= " ORDER BY col{$column} {$direction} ";
$sql .= " LIMIT {$from},{$number_of_items}";
$res = Database::query($sql);
$course_requests = array();
while ($course_request = Database::fetch_row($res)) {
$course_request[5] = api_get_local_time($course_request[5]);
$course_requests[] = $course_request;
}
return $course_requests;
}
示例3: __construct
/**
* Creates the mPDF object
* @param string format A4 A4-L see http://mpdf1.com/manual/index.php?tid=184&searchstring=format
* @param string orientation "P" = Portrait "L" = Landscape
*/
public function __construct($page_format = 'A4', $orientation = 'P', $params = array())
{
/* More info @ http://mpdf1.com/manual/index.php?tid=184&searchstring=mPDF
* mPDF ([ string $mode [, mixed $format [, float $default_font_size [, string $default_font [, float $margin_left , float $margin_right , float $margin_top , float $margin_bottom , float $margin_header , float $margin_footer [, string $orientation ]]]]]])
*/
if (!in_array($orientation, array('P', 'L'))) {
$orientation = 'P';
}
//$this->pdf = $pdf = new mPDF('UTF-8', $page_format, '', '', 30, 20, 27, 25, 16, 13, $orientation);
//left, right, top, bottom, margin_header, margin footer
$params['left'] = isset($params['left']) ? $params['left'] : 15;
$params['right'] = isset($params['right']) ? $params['right'] : 15;
$params['top'] = isset($params['top']) ? $params['top'] : 20;
$params['bottom'] = isset($params['bottom']) ? $params['bottom'] : 15;
$this->params['filename'] = isset($params['filename']) ? $params['filename'] : api_get_local_time();
$this->params['pdf_title'] = isset($params['pdf_title']) ? $params['pdf_title'] : get_lang('Untitled');
$this->params['course_code'] = isset($params['course_code']) ? $params['course_code'] : api_get_course_id();
$this->params['add_signatures'] = isset($params['add_signatures']) ? $params['add_signatures'] : false;
$this->pdf = new mPDF('UTF-8', $page_format, '', '', $params['left'], $params['right'], $params['top'], $params['bottom'], 8, 8, $orientation);
}
示例4: get_request_data
/**
* Get course data to display
*/
function get_request_data($from, $number_of_items, $column, $direction)
{
$keyword = isset($_GET['keyword']) ? Database::escape_string(trim($_GET['keyword'])) : null;
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
$from = intval($from);
$number_of_items = intval($number_of_items);
$column = intval($column);
$direction = !in_array(strtolower(trim($direction)), ['asc', 'desc']) ? 'asc' : $direction;
$sql = "SELECT\n id AS col0,\n code AS col1,\n title AS col2,\n category_code AS col3,\n tutor_name AS col4,\n request_date AS col5,\n id AS col6\n FROM {$course_request_table}\n WHERE status = " . COURSE_REQUEST_ACCEPTED;
if ($keyword != '') {
$sql .= " AND (\n title LIKE '%" . $keyword . "%' OR\n code LIKE '%" . $keyword . "%' OR\n visual_code LIKE '%" . $keyword . "%'\n )";
}
$sql .= " ORDER BY col{$column} {$direction} ";
$sql .= " LIMIT {$from},{$number_of_items}";
$res = Database::query($sql);
$course_requests = array();
while ($course_request = Database::fetch_row($res)) {
$course_request[5] = api_get_local_time($course_request[5]);
$course_requests[] = $course_request;
}
return $course_requests;
}
示例5: get_lang
$form->addElement('html_editor', 'glossary_comment', get_lang('TermDefinition'), null, array('ToolbarSet' => 'Glossary', 'Width' => '90%', 'Height' => '300'));
$element = $form->addElement('text', 'insert_date', get_lang('CreationDate'), array('size' => '100'));
$element->freeze();
$element = $form->addElement('text', 'update_date', get_lang('UpdateDate'), array('size' => '100'));
$element->freeze();
$form->addElement('style_submit_button', 'SubmitGlossary', get_lang('TermUpdateButton'), 'class="save"');
// setting the defaults
$glossary_data = GlossaryManager::get_glossary_information($_GET['glossary_id']);
// Date treatment for timezones
if (!empty($glossary_data['insert_date']) && $glossary_data['insert_date'] != '0000-00-00 00:00:00:') {
$glossary_data['insert_date'] = api_get_local_time($glossary_data['insert_date']);
} else {
$glossary_data['insert_date'] = '';
}
if (!empty($glossary_data['update_date']) && $glossary_data['update_date'] != '0000-00-00 00:00:00:') {
$glossary_data['update_date'] = api_get_local_time($glossary_data['update_date']);
} else {
$glossary_data['update_date'] = '';
}
$form->setDefaults($glossary_data);
// setting the rules
$form->addRule('glossary_title', get_lang('ThisFieldIsRequired'), 'required');
// The validation or display
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
$values = $form->exportValues();
GlossaryManager::update_glossary($values);
}
Security::clear_token();
GlossaryManager::display_glossary();
示例6: parse_session_dates
/**
* Returns a human readable string
* @params array An array with all the session dates
* @return string
*/
static function parse_session_dates($session_info)
{
//This will clean the variables if 0000-00-00 00:00:00 the variable will be empty
$start_date = null;
$end_date = null;
if (isset($session_info['display_start_date'])) {
$start_date = api_get_local_time($session_info['display_start_date'], null, null, true);
}
if (isset($session_info['display_end_date'])) {
$end_date = api_get_local_time($session_info['display_end_date'], null, null, true);
}
$msg_date = null;
if (!empty($start_date) && !empty($end_date)) {
//$msg_date = get_lang('From').' '.$start_date.' '.get_lang('To').' '.$end_date;
$msg_date = sprintf(get_lang('FromDateXToDateY'), $start_date, $end_date);
} else {
if (!empty($start_date)) {
$msg_date = get_lang('From') . ' ' . $start_date;
}
if (!empty($end_date)) {
$msg_date = get_lang('Until') . ' ' . $end_date;
}
}
return $msg_date;
}
示例7: delete_inactive_student
/**
*
* @param int student id
* @param int years
* @param bool show warning_message
* @param bool return_timestamp
*/
public static function delete_inactive_student($student_id, $years = 2, $warning_message = false, $return_timestamp = false)
{
$tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = 'SELECT login_date FROM ' . $tbl_track_login . '
WHERE login_user_id = ' . intval($student_id) . '
ORDER BY login_date DESC LIMIT 0,1';
if (empty($years)) {
$years = 1;
}
$inactive_time = $years * 31536000;
//1 year
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
if ($last_login_date = Database::result($rs, 0, 0)) {
$last_login_date = api_get_local_time($last_login_date, null, date_default_timezone_get());
if ($return_timestamp) {
return api_strtotime($last_login_date);
} else {
if (!$warning_message) {
return api_format_date($last_login_date, DATE_FORMAT_SHORT);
} else {
$timestamp = api_strtotime($last_login_date);
$currentTimestamp = time();
//If the last connection is > than 7 days, the text is red
//345600 = 7 days in seconds 63072000= 2 ans
// if ($currentTimestamp - $timestamp > 184590 )
if ($currentTimestamp - $timestamp > $inactive_time && UserManager::delete_user($student_id)) {
Display::display_normal_message(get_lang('UserDeleted'));
echo '<p>', 'id', $student_id, ':', $last_login_date, '</p>';
}
}
}
}
}
return false;
}
示例8: show_message_box
/**
* display message box in the inbox
* @param int the message id
* @param string inbox or outbox strings are available
* @todo replace numbers with letters in the $row array pff...
* @return string html with the message content
*/
public static function show_message_box($message_id, $source = 'inbox')
{
$table_message = Database::get_main_table(TABLE_MESSAGE);
$message_id = intval($message_id);
if ($source == 'outbox') {
if (isset($message_id) && is_numeric($message_id)) {
$query = "SELECT * FROM {$table_message}\n WHERE\n user_sender_id = " . api_get_user_id() . " AND\n id = " . $message_id . " AND\n msg_status = 4;";
$result = Database::query($query);
}
} else {
if (is_numeric($message_id) && !empty($message_id)) {
$query = "UPDATE {$table_message} SET\n msg_status = '" . MESSAGE_STATUS_NEW . "'\n WHERE\n user_receiver_id=" . api_get_user_id() . " AND\n id='" . $message_id . "'";
Database::query($query);
$query = "SELECT * FROM {$table_message}\n WHERE\n msg_status<>4 AND\n user_receiver_id=" . api_get_user_id() . " AND\n id='" . $message_id . "'";
$result = Database::query($query);
}
}
$row = Database::fetch_array($result, 'ASSOC');
$user_sender_id = $row['user_sender_id'];
// get file attachments by message id
$files_attachments = self::get_links_message_attachment_files($message_id, $source);
$user_con = self::users_connected_by_id();
$band = 0;
for ($i = 0; $i < count($user_con); $i++) {
if ($user_sender_id == $user_con[$i]) {
$band = 1;
}
}
$title = Security::remove_XSS($row['title'], STUDENT, true);
$content = Security::remove_XSS($row['content'], STUDENT, true);
$from_user = api_get_user_info($user_sender_id);
$name = $from_user['complete_name'];
$user_image = Display::img($from_user['avatar'], $name, array('title' => $name));
$message_content = Display::page_subheader(str_replace("\\", "", $title));
if (api_get_setting('social.allow_social_tool') == 'true') {
$message_content .= $user_image . ' ';
}
$receiverUserInfo = api_get_user_info($row['user_receiver_id']);
$message_content .= '<tr>';
if (api_get_setting('social.allow_social_tool') == 'true') {
if ($source == 'outbox') {
$message_content .= get_lang('From') . ': <a href="' . api_get_path(WEB_PATH) . 'main/social/profile.php?u=' . $user_sender_id . '">' . $name . '</a> ' . api_strtolower(get_lang('To')) . ' <b>' . $receiverUserInfo['complete_name'] . '</b>';
} else {
$message_content .= get_lang('From') . ' <a href="' . api_get_path(WEB_PATH) . 'main/social/profile.php?u=' . $user_sender_id . '">' . $name . '</a> ' . api_strtolower(get_lang('To')) . ' <b>' . get_lang('Me') . '</b>';
}
} else {
if ($source == 'outbox') {
$message_content .= get_lang('From') . ': ' . $name . '</b> ' . api_strtolower(get_lang('To')) . ' <b>' . $receiverUserInfo['complete_name'] . '</b>';
} else {
$message_content .= get_lang('From') . ': ' . $name . '</b> ' . api_strtolower(get_lang('To')) . ' <b>' . get_lang('Me') . '</b>';
}
}
$message_content .= ' ' . get_lang('Date') . ': ' . api_get_local_time($row['send_date']) . '
<br />
<hr style="color:#ddd" />
<table height="209px" width="100%">
<tr>
<td valign=top class="view-message-content">' . str_replace("\\", "", $content) . '</td>
</tr>
</table>
<div id="message-attach">' . (!empty($files_attachments) ? implode('<br />', $files_attachments) : '') . '</div>
<div style="padding: 15px 0px 5px 0px">';
$social_link = '';
if (isset($_GET['f']) && $_GET['f'] == 'social') {
$social_link = 'f=social';
}
if ($source == 'outbox') {
$message_content .= '<a href="outbox.php?' . $social_link . '">' . Display::return_icon('back.png', get_lang('ReturnToOutbox')) . '</a>  ';
} else {
$message_content .= '<a href="inbox.php?' . $social_link . '">' . Display::return_icon('back.png', get_lang('ReturnToInbox')) . '</a>  ';
$message_content .= '<a href="new_message.php?re_id=' . $message_id . '&' . $social_link . '">' . Display::return_icon('message_reply.png', get_lang('ReplyToMessage')) . '</a>  ';
}
$message_content .= '<a href="inbox.php?action=deleteone&id=' . $message_id . '&' . $social_link . '" >' . Display::return_icon('delete.png', get_lang('DeleteMessage')) . '</a> ';
$message_content .= '</div></td>
<td width=10></td>
</tr>
</table>';
return $message_content;
}
示例9: createForm
//.........这里部分代码省略.........
$form->addElement('text', $specific_field['code'], $specific_field['name']);
$filter = array('c_id' => "'" . api_get_course_int_id() . "'", 'field_id' => $specific_field['id'], 'ref_id' => $this->id, 'tool_id' => '\'' . TOOL_QUIZ . '\'');
$values = get_specific_field_values_list($filter, array('value'));
if (!empty($values)) {
$arr_str_values = array();
foreach ($values as $value) {
$arr_str_values[] = $value['value'];
}
$defaults[$specific_field['code']] = implode(', ', $arr_str_values);
}
}
//$form->addElement ('html','</div>');
}
$form->addElement('html', '</div>');
//End advanced setting
$form->addElement('html', '</div>');
}
// submit
if (isset($_GET['exerciseId'])) {
$form->addButtonSave(get_lang('ModifyExercise'), 'submitExercise');
} else {
$form->addButtonUpdate(get_lang('ProcedToQuestions'), 'submitExercise');
}
$form->addRule('exerciseTitle', get_lang('GiveExerciseName'), 'required');
if ($type == 'full') {
// rules
$form->addRule('exerciseAttempts', get_lang('Numeric'), 'numeric');
$form->addRule('start_time', get_lang('InvalidDate'), 'datetime');
$form->addRule('end_time', get_lang('InvalidDate'), 'datetime');
}
// defaults
if ($type == 'full') {
if ($this->id > 0) {
if ($this->random > $this->selectNbrQuestions()) {
$defaults['randomQuestions'] = $this->selectNbrQuestions();
} else {
$defaults['randomQuestions'] = $this->random;
}
$defaults['randomAnswers'] = $this->selectRandomAnswers();
$defaults['exerciseType'] = $this->selectType();
$defaults['exerciseTitle'] = $this->get_formated_title();
$defaults['exerciseDescription'] = $this->selectDescription();
$defaults['exerciseAttempts'] = $this->selectAttempts();
$defaults['exerciseFeedbackType'] = $this->selectFeedbackType();
$defaults['results_disabled'] = $this->selectResultsDisabled();
$defaults['propagate_neg'] = $this->selectPropagateNeg();
$defaults['review_answers'] = $this->review_answers;
$defaults['randomByCat'] = $this->selectRandomByCat();
$defaults['text_when_finished'] = $this->selectTextWhenFinished();
$defaults['display_category_name'] = $this->selectDisplayCategoryName();
$defaults['pass_percentage'] = $this->selectPassPercentage();
if ($this->start_time != '0000-00-00 00:00:00') {
$defaults['activate_start_date_check'] = 1;
}
if ($this->end_time != '0000-00-00 00:00:00') {
$defaults['activate_end_date_check'] = 1;
}
$defaults['start_time'] = $this->start_time != '0000-00-00 00:00:00' ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00');
$defaults['end_time'] = $this->end_time != '0000-00-00 00:00:00' ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time() + 84600);
// Get expired time
if ($this->expired_time != '0') {
$defaults['enabletimercontrol'] = 1;
$defaults['enabletimercontroltotalminutes'] = $this->expired_time;
} else {
$defaults['enabletimercontroltotalminutes'] = 0;
}
} else {
$defaults['exerciseType'] = 2;
$defaults['exerciseAttempts'] = 0;
$defaults['randomQuestions'] = 0;
$defaults['randomAnswers'] = 0;
$defaults['exerciseDescription'] = '';
$defaults['exerciseFeedbackType'] = 0;
$defaults['results_disabled'] = 0;
$defaults['randomByCat'] = 0;
$defaults['text_when_finished'] = "";
$defaults['start_time'] = date('Y-m-d 12:00:00');
$defaults['display_category_name'] = 1;
$defaults['end_time'] = date('Y-m-d 12:00:00', time() + 84600);
$defaults['pass_percentage'] = '';
}
} else {
$defaults['exerciseTitle'] = $this->selectTitle();
$defaults['exerciseDescription'] = $this->selectDescription();
}
if (api_get_setting('search.search_enabled') === 'true') {
$defaults['index_document'] = 'checked="checked"';
}
$form->setDefaults($defaults);
// Freeze some elements.
if ($this->id != 0 && $this->edit_exercise_in_lp == false) {
$elementsToFreeze = array('randomQuestions', 'exerciseAttempts', 'propagate_neg', 'enabletimercontrol', 'review_answers');
foreach ($elementsToFreeze as $elementName) {
/** @var HTML_QuickForm_element $element */
$element = $form->getElement($elementName);
$element->freeze();
}
$radioCatGroup->freeze();
}
}
示例10: switch
switch ($_GET['class']) {
case 'public':
$vevent->setClass('PUBLIC');
break;
case 'private':
$vevent->setClass('PRIVATE');
break;
case 'confidential':
$vevent->setClass('CONFIDENTIAL');
break;
default:
$vevent->setClass('PRIVATE');
break;
}
$event['start_date'] = api_get_local_time($event['start_date']);
$event['end_date'] = api_get_local_time($event['end_date']);
switch ($type) {
case 'personal':
case 'platform':
$vevent->setProperty('summary', api_convert_encoding($event['title'], 'UTF-8', $charset));
if (empty($event['start_date'])) {
header('location:' . Security::remove_XSS($_SERVER['HTTP_REFERER']));
}
list($y, $m, $d, $h, $M, $s) = preg_split('/[\\s:-]/', $event['start_date']);
$vevent->setProperty('dtstart', array('year' => $y, 'month' => $m, 'day' => $d, 'hour' => $h, 'min' => $M, 'sec' => $s));
if (empty($event['end_date'])) {
$y2 = $y;
$m2 = $m;
$d2 = $d;
$h2 = $h;
$M2 = $M + 15;
示例11: api_get_path
$row++;
$column = 0;
$url = api_get_path(WEB_CODE_PATH) . 'work/';
foreach ($workPerUser as $work) {
$work = $work['work'];
$scoreWeight = intval($work->qualification) == 0 ? null : $work->qualification;
$workId = $work->id;
$workExtraData = get_work_assignment_by_id($workId);
foreach ($work->user_results as $userResult) {
$itemId = $userResult['id'];
$table->setCellContents($row, $column, $work->title . ' [' . trim(strip_tags($userResult['title'])) . ']');
$table->setCellAttributes($row, $column, array('width' => '300px'));
$column++;
$table->setCellContents($row, $column, $userResult['sent_date']);
$column++;
$dateQualification = !empty($workExtraData['expires_on']) ? api_get_local_time($workExtraData['expires_on']) : '-';
$table->setCellContents($row, $column, $dateQualification);
$column++;
$score = null;
$score = $userResult['qualification'];
$table->setCellContents($row, $column, $score);
$column++;
// Actions
$links = null;
// is a text
$url = api_get_path(WEB_CODE_PATH) . 'work/view.php?' . api_get_cidreq() . '&id=' . $itemId;
$links .= Display::url(Display::return_icon('default.png', get_lang('View')), $url);
if (!empty($userResult['url'])) {
$url = api_get_path(WEB_CODE_PATH) . 'work/download.php?' . api_get_cidreq() . '&id=' . $itemId;
$links .= Display::url(Display::return_icon('save.png', get_lang('Download')), $url);
}
示例12: get_personal_agenda_items
/**
* This function retrieves all the personal agenda items and add them to the agenda items found by the other functions.
*/
public static function get_personal_agenda_items($user_id, $agendaitems, $day = "", $month = "", $year = "", $week = "", $type)
{
$tbl_personal_agenda = Database::get_main_table(TABLE_PERSONAL_AGENDA);
$user_id = intval($user_id);
// 1. creating the SQL statement for getting the personal agenda items in MONTH view
if ($type == "month_view" or $type == "") {
// we are in month view
$sql = "SELECT * FROM " . $tbl_personal_agenda . " WHERE user='" . $user_id . "' and MONTH(date)='" . $month . "' AND YEAR(date) = '" . $year . "' ORDER BY date ASC";
}
// 2. creating the SQL statement for getting the personal agenda items in WEEK view
// we are in week view
if ($type == "week_view") {
$start_end_day_of_week = self::calculate_start_end_of_week($week, $year);
$start_day = $start_end_day_of_week['start']['day'];
$start_month = $start_end_day_of_week['start']['month'];
$start_year = $start_end_day_of_week['start']['year'];
$end_day = $start_end_day_of_week['end']['day'];
$end_month = $start_end_day_of_week['end']['month'];
$end_year = $start_end_day_of_week['end']['year'];
// in sql statements you have to use year-month-day for date calculations
$start_filter = $start_year . "-" . $start_month . "-" . $start_day . " 00:00:00";
$start_filter = api_get_utc_datetime($start_filter);
$end_filter = $end_year . "-" . $end_month . "-" . $end_day . " 23:59:59";
$end_filter = api_get_utc_datetime($end_filter);
$sql = " SELECT * FROM " . $tbl_personal_agenda . " WHERE user='" . $user_id . "' AND date>='" . $start_filter . "' AND date<='" . $end_filter . "'";
}
// 3. creating the SQL statement for getting the personal agenda items in DAY view
if ($type == "day_view") {
// we are in day view
// we could use mysql date() function but this is only available from 4.1 and higher
$start_filter = $year . "-" . $month . "-" . $day . " 00:00:00";
$start_filter = api_get_utc_datetime($start_filter);
$end_filter = $year . "-" . $month . "-" . $day . " 23:59:59";
$end_filter = api_get_utc_datetime($end_filter);
$sql = " SELECT * FROM " . $tbl_personal_agenda . " WHERE user='" . $user_id . "' AND date>='" . $start_filter . "' AND date<='" . $end_filter . "'";
}
$result = Database::query($sql);
while ($item = Database::fetch_array($result, 'ASSOC')) {
$time_minute = api_convert_and_format_date($item['date'], TIME_NO_SEC_FORMAT);
$item['date'] = api_get_local_time($item['date']);
$item['start_date_tms'] = api_strtotime($item['date']);
$item['content'] = $item['text'];
// we break the date field in the database into a date and a time part
$agenda_db_date = explode(" ", $item['date']);
$date = $agenda_db_date[0];
$time = $agenda_db_date[1];
// we divide the date part into a day, a month and a year
$agendadate = explode("-", $item['date']);
$year = intval($agendadate[0]);
$month = intval($agendadate[1]);
$day = intval($agendadate[2]);
// we divide the time part into hour, minutes, seconds
$agendatime = explode(":", $time);
$hour = $agendatime[0];
$minute = $agendatime[1];
$second = $agendatime[2];
if ($type == 'month_view') {
$item['calendar_type'] = 'personal';
$item['start_date'] = $item['date'];
$agendaitems[$day][] = $item;
continue;
}
// if the student has specified a course we a add a link to that course
if ($item['course'] != "") {
$url = api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?cidReq=" . urlencode($item['course']) . "&day={$day}&month={$month}&year={$year}#{$day}";
// RH //Patrick Cool: to highlight the relevant agenda item
$course_link = "<a href=\"{$url}\" title=\"" . $item['course'] . "\">" . $item['course'] . "</a>";
} else {
$course_link = "";
}
// Creating the array that will be returned. If we have week or month view we have an array with the date as the key
// if we have a day_view we use a half hour as index => key 33 = 16h30
if ($type !== "day_view") {
// This is the array construction for the WEEK or MONTH view
//Display events in agenda
$agendaitems[$day] .= "<div><i>{$time_minute}</i> {$course_link} <a href=\"myagenda.php?action=view&view=personal&day={$day}&month={$month}&year={$year}&id=" . $item['id'] . "#" . $item['id'] . "\" class=\"personal_agenda\">" . $item['title'] . "</a></div><br />";
} else {
// this is the array construction for the DAY view
$halfhour = 2 * $agendatime['0'];
if ($agendatime['1'] >= '30') {
$halfhour = $halfhour + 1;
}
//Display events by list
$agendaitems[$halfhour] .= "<div><i>{$time_minute}</i> {$course_link} <a href=\"myagenda.php?action=view&view=personal&day={$day}&month={$month}&year={$year}&id=" . $item['id'] . "#" . $item['id'] . "\" class=\"personal_agenda\">" . $item['title'] . "</a></div>";
}
}
return $agendaitems;
}
示例13: set_extra_fields_in_form
//.........这里部分代码省略.........
}
if ($get_lang_variables) {
$field_details['field_display_text'] = get_lang($field_details['field_display_text']);
}
// chzn-select doesn't work for sessions??
$form->addElement('select', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], $options, array('id' => 'extra_' . $field_details['field_variable']));
if ($optionsExists && $field_details['field_loggeable'] && !empty($defaultValueId)) {
$form->addElement('textarea', 'extra_' . $field_details['field_variable'] . '_comment', $field_details['field_display_text'] . ' ' . get_lang('Comment'));
$em = Database::getManager();
$extraFieldValue = new ExtraFieldValue($this->type);
$repo = $em->getRepository($extraFieldValue->entityName);
$repoLog = $em->getRepository('Gedmo\\Loggable\\Entity\\LogEntry');
$newEntity = $repo->findOneBy(array($this->handlerEntityId => $itemId, 'fieldId' => $field_details['id']));
// @todo move this in a function inside the class
if ($newEntity) {
$logs = $repoLog->getLogEntries($newEntity);
if (!empty($logs)) {
$html = '<b>' . get_lang('LatestChanges') . '</b><br /><br />';
$table = new HTML_Table(array('class' => 'data_table'));
$table->setHeaderContents(0, 0, get_lang('Value'));
$table->setHeaderContents(0, 1, get_lang('Comment'));
$table->setHeaderContents(0, 2, get_lang('ModifyDate'));
$table->setHeaderContents(0, 3, get_lang('Username'));
$row = 1;
foreach ($logs as $log) {
$column = 0;
$data = $log->getData();
$fieldValue = isset($data['fieldValue']) ? $data['fieldValue'] : null;
$comment = isset($data['comment']) ? $data['comment'] : null;
$table->setCellContents($row, $column, $fieldValue);
$column++;
$table->setCellContents($row, $column, $comment);
$column++;
$table->setCellContents($row, $column, api_get_local_time($log->getLoggedAt()->format('Y-m-d H:i:s')));
$column++;
$table->setCellContents($row, $column, $log->getUsername());
$row++;
}
$form->addElement('label', null, $html . $table->toHtml());
}
}
}
if (!$admin_permissions) {
if ($field_details['field_visible'] == 0) {
$form->freeze('extra_' . $field_details['field_variable']);
}
}
break;
case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
$options = array();
foreach ($field_details['options'] as $option_id => $option_details) {
$options[$option_details['option_value']] = $option_details['option_display_text'];
}
$form->addElement('select', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], $options, array('multiple' => 'multiple'));
if (!$admin_permissions) {
if ($field_details['field_visible'] == 0) {
$form->freeze('extra_' . $field_details['field_variable']);
}
}
break;
case ExtraField::FIELD_TYPE_DATE:
$form->addElement('datepickerdate', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], array('form_name' => $form_name));
$form->_elements[$form->_elementIndex['extra_' . $field_details['field_variable']]]->setLocalOption('minYear', 1900);
$defaults['extra_' . $field_details['field_variable']] = date('Y-m-d 12:00:00');
if (!isset($form->_defaultValues['extra_' . $field_details['field_variable']])) {
$form->setDefaults($defaults);
示例14: get_last_connection_date
/**
* Get las connection date for a student
* @param int $student_id
* @param bool $warning_message Show a warning message (optional)
* @param bool $return_timestamp True for returning results in timestamp (optional)
* @return string|int|bool Date format long without day, false if there are no connections or
* timestamp if parameter $return_timestamp is true
*/
public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
{
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = 'SELECT login_date
FROM ' . $table . '
WHERE login_user_id = ' . intval($student_id) . '
ORDER BY login_date
DESC LIMIT 0,1';
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
if ($last_login_date = Database::result($rs, 0, 0)) {
$last_login_date = api_get_local_time($last_login_date);
if ($return_timestamp) {
return api_strtotime($last_login_date, 'UTC');
} else {
if (!$warning_message) {
return api_format_date($last_login_date, DATE_FORMAT_SHORT);
} else {
$timestamp = api_strtotime($last_login_date, 'UTC');
$currentTimestamp = time();
//If the last connection is > than 7 days, the text is red
//345600 = 7 days in seconds
if ($currentTimestamp - $timestamp > 604800) {
return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
} else {
return api_format_date($last_login_date, DATE_FORMAT_SHORT);
}
}
}
}
}
return false;
}
示例15: get_activities_data
/**
* Get activities data to display
*/
static function get_activities_data($from, $number_of_items, $column, $direction)
{
global $dateTimeFormatLong;
$track_e_default = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
$column = intval($column);
$from = intval($from);
$number_of_items = intval($number_of_items);
if (!in_array($direction, array('ASC', 'DESC'))) {
$direction = 'DESC';
}
if (api_is_multiple_url_enabled()) {
$sql = "SELECT " . "default_event_type as col0, " . "default_value_type as col1, " . "default_value as col2, " . "user.username as col3, " . "user.user_id as col4, " . "default_date as col5 " . "FROM {$track_e_default} as track_default, {$table_user} as user, {$access_url_rel_user_table} as url " . "WHERE track_default.default_user_id = user.user_id AND url.user_id=user.user_id AND access_url_id='" . $current_url_id . "'";
} else {
$sql = "SELECT " . "default_event_type as col0, " . "default_value_type as col1, " . "default_value as col2, " . "user.username as col3, " . "user.user_id as col4, " . "default_date as col5 " . "FROM {$track_e_default} track_default, {$table_user} user " . "WHERE track_default.default_user_id = user.user_id ";
}
if (isset($_GET['keyword'])) {
$keyword = Database::escape_string(trim($_GET['keyword']));
$sql .= " AND (user.username LIKE '%" . $keyword . "%' OR default_event_type LIKE '%" . $keyword . "%' OR default_value_type LIKE '%" . $keyword . "%' OR default_value LIKE '%" . $keyword . "%') ";
}
if (!empty($column) && !empty($direction)) {
$sql .= " ORDER BY col{$column} {$direction}";
} else {
$sql .= " ORDER BY col5 DESC ";
}
$sql .= " LIMIT {$from}, {$number_of_items} ";
$res = Database::query($sql);
$activities = array();
while ($row = Database::fetch_row($res)) {
if (strpos($row[1], '_object') === false) {
$row[2] = $row[2];
} else {
if (!empty($row[2])) {
$row[2] = unserialize($row[2]);
if (is_array($row[2]) && !empty($row[2])) {
$row[2] = Text::implode_with_key(', ', $row[2]);
}
}
}
if (!empty($row['default_date']) && $row['default_date'] != '0000-00-00 00:00:00') {
$row['default_date'] = api_get_local_time($row['default_date']);
} else {
$row['default_date'] = '-';
}
if (!empty($row[4])) {
//user ID
$row[3] = Display::url($row[3], api_get_path(WEB_CODE_PATH) . 'admin/user_information?user_id=' . $row[5], array('title' => get_lang('UserInfo')));
$row[4] = TrackingUserLog::get_ip_from_user_event($row[4], $row[5], true);
if (empty($row[4])) {
$row[4] = get_lang('Unknown');
}
}
$activities[] = $row;
}
return $activities;
}