• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP usergetdate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: write_message_div

 /**
  * This function writes out the message div so the message can be viewed.
  *
  * @param object $record This is the DB record for the message to write out
  * @param string $outputbuffer The output html code will be written here.
  *
  */
 private function write_message_div($record, &$outputbuffer)
 {
     global $DB, $USER;
     $timesent = $record->timesent;
     $time = userdate($timesent, '%H:%M');
     $dates = usergetdate($timesent);
     $userfrom = block_course_message_map_ids_to_names($record->useridfrom, 'inbox');
     $userto = block_course_message_map_ids_to_names($record->recipients, 'sent');
     $outputbuffer .= "<div class='message_div_bar'><div class='message_bar_to'><span class='label'>To:</span>\n                          <span class='field'> {$userto}</span></div>";
     if ($record->carboncopy !== null) {
         $carboncopy = block_course_message_map_ids_to_names($record->carboncopy, 'sent');
         $outputbuffer .= "<div class='message_bar_to'><span class='label'>CC:</span>\n                              <span class='field'> {$carboncopy}</span></div>";
     }
     $outputbuffer .= "<div class='message_bar_from'><span class='label'>From:</span><span class='field'> {$userfrom}</span>\n                          </div><div class='message_bar_time'>{$time} {$dates['month']} {$dates['mday']}</div>";
     $outputbuffer .= "<div class='clear'></div></div>";
     $outputbuffer .= "<div class='message_container";
     if ($USER->id == $record->useridfrom) {
         $outputbuffer .= " usersent'>";
     } else {
         $outputbuffer .= " userrecieved'>";
     }
     // Message has already been cleaned when sent.
     $outputbuffer .= "<div class='message_div_body'>{$record->message}</div>";
     $this->process_attachment($record, $outputbuffer);
     // Close the message container div.
     $outputbuffer .= "</div>";
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:34,代码来源:mail_view.class.php


示例2: definition

 function definition()
 {
     global $CFG, $USER, $DB, $COURSE;
     $mform =& $this->_form;
     // Don't forget the underscore!
     //check reportend make sure that if $this->userid != $USER->id that they have
     //the correct capability TODO
     /*
     $canmanage = false;
     if(has_capability('block/timetracker:manageworkers',$this->context)){
         $canmanage = true;
     }
     */
     //$userinfo = $DB->get_record('block_timetracker_workerinfo',
     //    array('id'=>$this->userid));
     /*
     $index  = new moodle_url($CFG->wwwroot.'/blocks/timetracker/index.php',
         array('id'=>$this->courseid,'userid'=>$this->userid));
     */
     $index = new moodle_url($CFG->wwwroot . 'blocks/timetracker/');
     /*
     if(!$canmanage && $USER->id != $userinfo->mdluserid){
         redirect($nextpage,'You do not have permission to generate this report.',1);
     }
     */
     $categoryinfo = $DB->get_record('course_categories', array('id' => $this->catid));
     if (!$categoryinfo) {
         $mform->addElement('header', 'general', 'Report Generator');
     } else {
         $mform->addElement('header', 'general', 'Report Generator for ' . $categoryinfo->name);
     }
     $now = time();
     if ($this->reportstart == 0 || $this->reportend == 0) {
         $starttime = usergetdate($now);
         $starttime_mid = make_timestamp($starttime['year'], $starttime['mon'] - 1, $starttime['mday']);
         $this->reportstart = $starttime_mid;
         $endtime = usergetdate($now);
         $endtime_mid = make_timestamp($endtime['year'], $endtime['mon'], $endtime['mday']);
         $this->reportend = $endtime_mid;
     }
     $buttonarray = array();
     $buttonarray[] =& $mform->createElement('submit', 'conflicts', 'Conflicts');
     $buttonarray[] =& $mform->createElement('submit', 'earningsactive', 'Earnings - active workers only');
     $buttonarray[] =& $mform->createElement('submit', 'earningsall', 'Earnings - all workers');
     $mform->addElement('html', 'Please provide a date and time range for the report(s) you
             wish to generate.');
     $mform->addElement('date_selector', 'reportstart', 'Start Date: ', array('optional' => false, 'step' => 1));
     $mform->setDefault('reportstart', $this->reportstart);
     $mform->addElement('date_selector', 'reportend', 'End Date: ', array('optional' => false, 'step' => 1));
     $mform->setDefault('reportend', $this->reportend);
     $mform->addElement('hidden', 'catid', $this->catid);
     //$mform->addElement('hidden','userid', $this->userid);
     $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
     $mform->closeHeaderBefore('buttonar');
 }
开发者ID:hughesbradc,项目名称:TimeTracker,代码行数:55,代码来源:timetracker_reportgenerator_form.php


示例3: __construct

    public function __construct(local_attendance $att) {
        global $PAGE;

        $this->pageparams = $att->pageparams;


        $this->curdate = $att->pageparams->curdate;

        $date = usergetdate($att->pageparams->curdate);
        $mday = $date['mday'];
        $wday = $date['wday'];
        $mon = $date['mon'];
        $year = $date['year'];

        switch ($this->pageparams->view) {
            case LOCAL_ATT_VIEW_DAYS:
                $format = get_string('strftimedm', 'local_attendance');
                $this->prevcur = make_timestamp($year, $mon, $mday - 1);
                $this->nextcur = make_timestamp($year, $mon, $mday + 1);
                $this->curdatetxt = userdate($att->pageparams->startdate, $format);
                break;
            case LOCAL_ATT_VIEW_WEEKS:
                $format = get_string('strftimedm', 'local_attendance');
                $this->prevcur = $att->pageparams->startdate - WEEKSECS;
                $this->nextcur = $att->pageparams->startdate + WEEKSECS;
                $this->curdatetxt = userdate($att->pageparams->startdate, $format) .
                        " - " . userdate($att->pageparams->enddate, $format);
                break;
            case LOCAL_ATT_VIEW_MONTHS:
                $format = '%B';
                $this->prevcur = make_timestamp($year, $mon - 1);
                $this->nextcur = make_timestamp($year, $mon + 1);
                $this->curdatetxt = userdate($att->pageparams->startdate, $format);
                break;
        }

        $this->urlpath = $PAGE->url->out_omit_querystring();
        $params = $att->pageparams->get_significant_params();
        $params['id'] = $att->id;
        $this->urlparams = $params;

        $this->att = $att;
    }
开发者ID:anilch,项目名称:Personel,代码行数:43,代码来源:renderables.php


示例4: organizer_add_calendar

function organizer_add_calendar()
{
    global $PAGE, $DB;
    $courseid = optional_param('course', SITEID, PARAM_INT);
    if ($courseid != SITEID && !empty($courseid)) {
        $course = $DB->get_record('course', array('id' => $courseid));
        $courses = array($course->id => $course);
        $issite = false;
    } else {
        $course = get_site();
        $courses = calendar_get_default_courses();
        $issite = true;
    }
    $now = usergetdate(time());
    $calendar = new calendar_information($now['mday'], $now['mon'], $now['year']);
    $calendar->prepare_for_view($course, $courses);
    $renderer = $PAGE->get_renderer('core_calendar');
    $calendar->add_sidecalendar_blocks($renderer, true, 'month');
    $PAGE->requires->js_init_call('M.mod_organizer.fix_calendar_styles');
}
开发者ID:nmisic,项目名称:moodle-mod_organizer,代码行数:20,代码来源:view_lib.php


示例5: get_content

 public function get_content()
 {
     global $COURSE;
     if ($this->content !== null) {
         return $this->content;
     }
     // Create empty content.
     $this->content = new stdClass();
     $this->content->text = '';
     // Use Strict as this block should only ever be in a course context.
     $context = context_course::instance($this->page->course->id);
     if (!has_capability('block/eclass_course_management:canseeblock', $context)) {
         return $this->content->text = '';
     }
     $open = EclassCourseManager::get_course_open($context->instanceid);
     $close = EclassCourseManager::get_course_close($context->instanceid);
     if ($open) {
         $date = usergetdate($open);
         $this->content->text .= '<br/>' . get_string('open_label', 'block_eclass_course_management') . ' ' . "{$date['month']} {$date['mday']}, {$date['year']}";
     } else {
         $this->content->text .= '<br/>' . get_string('nostartdate', 'block_eclass_course_management');
     }
     if ($close) {
         $date = usergetdate($close);
         $this->content->text .= '<br/>' . get_string('close_label', 'block_eclass_course_management') . ' ' . "{$date['month']} {$date['mday']}, {$date['year']}";
     } else {
         $this->content->text .= '<br/>' . get_string('noenddate', 'block_eclass_course_management');
     }
     if ($COURSE->visible) {
         $this->content->text .= '<br/>' . get_string('status_label', 'block_eclass_course_management') . ' ' . get_string('visible', 'block_eclass_course_management');
     } else {
         $this->content->text .= '<br/>' . get_string('status_label', 'block_eclass_course_management') . ' ' . get_string('notvisible', 'block_eclass_course_management');
     }
     if (!empty($this->content->text)) {
         $this->content->text = get_string('blockpreamble', 'block_eclass_course_management') . '<br/>' . $this->content->text;
     }
     if (has_capability('moodle/course:update', $context)) {
         $this->content->text .= "<br/><a href='/blocks/eclass_course_management/configure.php?course={$COURSE->id}'>Edit</a>";
     }
     return $this->content;
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:41,代码来源:block_eclass_course_management.php


示例6: create_messages

 /**
  * Helper function to return an array of messages.
  *
  * @param int $userid
  * @param array $messages
  * @return array
  */
 public static function create_messages($userid, $messages)
 {
     // Store the messages.
     $arrmessages = array();
     // We always view messages from oldest to newest, ensure we have it in that order.
     $lastmessage = end($messages);
     $firstmessage = reset($messages);
     if ($lastmessage->timecreated < $firstmessage->timecreated) {
         $messages = array_reverse($messages);
     }
     // Keeps track of the last day, month and year combo we were viewing.
     $day = '';
     $month = '';
     $year = '';
     foreach ($messages as $message) {
         // Check if we are now viewing a different block period.
         $displayblocktime = false;
         $date = usergetdate($message->timecreated);
         if ($day != $date['mday'] || $month != $date['month'] || $year != $date['year']) {
             $day = $date['mday'];
             $month = $date['month'];
             $year = $date['year'];
             $displayblocktime = true;
         }
         // Store the message to pass to the renderable.
         $msg = new \stdClass();
         $msg->id = $message->id;
         $msg->text = message_format_message_text($message);
         $msg->currentuserid = $userid;
         $msg->useridfrom = $message->useridfrom;
         $msg->useridto = $message->useridto;
         $msg->displayblocktime = $displayblocktime;
         $msg->timecreated = $message->timecreated;
         $msg->timeread = $message->timeread;
         $arrmessages[] = $msg;
     }
     return $arrmessages;
 }
开发者ID:dg711,项目名称:moodle,代码行数:45,代码来源:helper.php


示例7: select_time

 /**
  * This is a shortcut for making an hour selector menu.
  *
  * @param string $type The type of selector (years, months, days, hours, minutes)
  * @param string $name fieldname
  * @param int $currenttime A default timestamp in GMT
  * @param int $step minute spacing
  * @param array $attributes - html select element attributes
  * @return HTML fragment
  */
 public static function select_time($type, $name, $currenttime = 0, $step = 5, array $attributes = null)
 {
     if (!$currenttime) {
         $currenttime = time();
     }
     $currentdate = usergetdate($currenttime);
     $userdatetype = $type;
     $timeunits = array();
     switch ($type) {
         case 'years':
             for ($i = 1970; $i <= 2020; $i++) {
                 $timeunits[$i] = $i;
             }
             $userdatetype = 'year';
             break;
         case 'months':
             for ($i = 1; $i <= 12; $i++) {
                 $timeunits[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), "%B");
             }
             $userdatetype = 'month';
             $currentdate['month'] = (int) $currentdate['mon'];
             break;
         case 'days':
             for ($i = 1; $i <= 31; $i++) {
                 $timeunits[$i] = $i;
             }
             $userdatetype = 'mday';
             break;
         case 'hours':
             for ($i = 0; $i <= 23; $i++) {
                 $timeunits[$i] = sprintf("%02d", $i);
             }
             break;
         case 'minutes':
             if ($step != 1) {
                 $currentdate['minutes'] = ceil($currentdate['minutes'] / $step) * $step;
             }
             for ($i = 0; $i <= 59; $i += $step) {
                 $timeunits[$i] = sprintf("%02d", $i);
             }
             break;
         default:
             throw new coding_exception("Time type {$type} is not supported by html_writer::select_time().");
     }
     if (empty($attributes['id'])) {
         $attributes['id'] = self::random_id('ts_');
     }
     $timerselector = self::select($timeunits, $name, $currentdate[$userdatetype], null, $attributes);
     $label = self::tag('label', get_string(substr($type, 0, -1), 'form'), array('for' => $attributes['id'], 'class' => 'accesshide'));
     return $label . $timerselector;
 }
开发者ID:jtibbetts,项目名称:moodle,代码行数:61,代码来源:outputcomponents.php


示例8: calendar_format_event_time

function calendar_format_event_time($event, $now, $morehref, $usecommonwords = true, $showtime = 0)
{
    $startdate = usergetdate($event->timestart);
    $enddate = usergetdate($event->timestart + $event->timeduration);
    $usermidnightstart = usergetmidnight($event->timestart);
    if ($event->timeduration) {
        // To avoid doing the math if one IF is enough :)
        $usermidnightend = usergetmidnight($event->timestart + $event->timeduration);
    } else {
        $usermidnightend = $usermidnightstart;
    }
    // OK, now to get a meaningful display...
    // First of all we have to construct a human-readable date/time representation
    if ($event->timeduration) {
        // It has a duration
        if ($usermidnightstart == $usermidnightend || $event->timestart == $usermidnightstart && ($event->timeduration == 86400 || $event->timeduration == 86399) || $event->timestart + $event->timeduration <= $usermidnightstart + 86400) {
            // But it's all on the same day
            $timestart = calendar_time_representation($event->timestart);
            $timeend = calendar_time_representation($event->timestart + $event->timeduration);
            $time = $timestart . ' <strong>&raquo;</strong> ' . $timeend;
            if ($event->timestart == $usermidnightstart && ($event->timeduration == 86400 || $event->timeduration == 86399)) {
                $time = get_string('allday', 'calendar');
            }
            // Set printable representation
            if (!$showtime) {
                $day = calendar_day_representation($event->timestart, $now, $usecommonwords);
                $eventtime = calendar_get_link_tag($day, CALENDAR_URL . 'view.php?view=day' . $morehref . '&amp;', $enddate['mday'], $enddate['mon'], $enddate['year']) . ', ' . $time;
            } else {
                $eventtime = $time;
            }
        } else {
            // It spans two or more days
            $daystart = calendar_day_representation($event->timestart, $now, $usecommonwords) . ', ';
            if ($showtime == $usermidnightstart) {
                $daystart = '';
            }
            $timestart = calendar_time_representation($event->timestart);
            $dayend = calendar_day_representation($event->timestart + $event->timeduration, $now, $usecommonwords) . ', ';
            if ($showtime == $usermidnightend) {
                $dayend = '';
            }
            $timeend = calendar_time_representation($event->timestart + $event->timeduration);
            // Set printable representation
            if ($now >= $usermidnightstart && $now < $usermidnightstart + 86400) {
                $eventtime = $timestart . ' <strong>&raquo;</strong> ' . calendar_get_link_tag($dayend, CALENDAR_URL . 'view.php?view=day' . $morehref . '&amp;', $enddate['mday'], $enddate['mon'], $enddate['year']) . $timeend;
            } else {
                $eventtime = calendar_get_link_tag($daystart, CALENDAR_URL . 'view.php?view=day' . $morehref . '&amp;', $startdate['mday'], $startdate['mon'], $startdate['year']) . $timestart . ' <strong>&raquo;</strong> ' . calendar_get_link_tag($dayend, CALENDAR_URL . 'view.php?view=day' . $morehref . '&amp;', $enddate['mday'], $enddate['mon'], $enddate['year']) . $timeend;
            }
        }
    } else {
        $time = ' ';
        // Set printable representation
        if (!$showtime) {
            $day = calendar_day_representation($event->timestart, $now, $usecommonwords);
            $eventtime = calendar_get_link_tag($day, CALENDAR_URL . 'view.php?view=day' . $morehref . '&amp;', $startdate['mday'], $startdate['mon'], $startdate['year']) . trim($time);
        } else {
            $eventtime = $time;
        }
    }
    if ($event->timestart + $event->timeduration < $now) {
        // It has expired
        $eventtime = '<span class="dimmed_text">' . str_replace(' href=', ' class="dimmed" href=', $eventtime) . '</span>';
    }
    return $eventtime;
}
开发者ID:kai707,项目名称:ITSA-backup,代码行数:65,代码来源:lib.php


示例9: init_start_end_date

 public function init_start_end_date()
 {
     global $CFG;
     // HOURSECS solves issue for weeks view with Daylight saving time and clocks adjusting by one hour backward.
     $date = usergetdate($this->curdate + HOURSECS);
     $mday = $date['mday'];
     $wday = $date['wday'] - $CFG->calendar_startwday;
     if ($wday < 0) {
         $wday += 7;
     }
     $mon = $date['mon'];
     $year = $date['year'];
     switch ($this->view) {
         case ATT_VIEW_DAYS:
             $this->startdate = make_timestamp($year, $mon, $mday);
             $this->enddate = make_timestamp($year, $mon, $mday + 1);
             break;
         case ATT_VIEW_WEEKS:
             $this->startdate = make_timestamp($year, $mon, $mday - $wday);
             $this->enddate = make_timestamp($year, $mon, $mday + 7 - $wday) - 1;
             break;
         case ATT_VIEW_MONTHS:
             $this->startdate = make_timestamp($year, $mon);
             $this->enddate = make_timestamp($year, $mon + 1);
             break;
         case ATT_VIEW_ALLPAST:
             $this->startdate = 1;
             $this->enddate = time();
             break;
         case ATT_VIEW_ALL:
             $this->startdate = 0;
             $this->enddate = 0;
             break;
     }
 }
开发者ID:webcursosuai,项目名称:moodle-mod_attendance,代码行数:35,代码来源:locallib.php


示例10: array

}
$PAGE->set_url($url);
if ($courseid != SITEID && !empty($courseid)) {
    $course = $DB->get_record('course', array('id' => $courseid));
    $courses = array($course->id => $course);
    $issite = false;
    navigation_node::override_active_url(new moodle_url('/course/view.php', array('id' => $course->id)));
} else {
    $course = get_site();
    $courses = calendar_get_default_courses();
    $issite = true;
}
require_course_login($course);
$calendar = new calendar_information($day, $mon, $yr);
$calendar->prepare_for_view($course, $courses);
$now = usergetdate(time());
$pagetitle = '';
$strcalendar = get_string('calendar', 'calendar');
if (!checkdate($mon, $day, $yr)) {
    $day = intval($now['mday']);
    $mon = intval($now['mon']);
    $yr = intval($now['year']);
}
$time = make_timestamp($yr, $mon, $day);
switch ($view) {
    case 'day':
        $PAGE->navbar->add(userdate($time, get_string('strftimedate')));
        $pagetitle = get_string('dayview', 'calendar');
        break;
    case 'month':
        $PAGE->navbar->add(userdate($time, get_string('strftimemonthyear')));
开发者ID:nigeldaley,项目名称:moodle,代码行数:31,代码来源:view.php


示例11: print_user_picture

echo '</td>';
echo '<td align="center">';
echo print_user_picture($user2->id, SITEID, $user2->picture, 100, true, true, 'userwindow') . '<br />';
echo fullname($user2);
echo '</td>';
echo '</tr></table>';
print_simple_box_end();
/// Get all the messages and print them
if ($messages = message_get_history($user1, $user2)) {
    $current->mday = '';
    $current->month = '';
    $current->year = '';
    $messagedate = get_string('strftimetime');
    $blockdate = get_string('strftimedaydate');
    foreach ($messages as $message) {
        $date = usergetdate($message->timecreated);
        if ($current->mday != $date['mday'] | $current->month != $date['month'] | $current->year != $date['year']) {
            $current->mday = $date['mday'];
            $current->month = $date['month'];
            $current->year = $date['year'];
            echo '<a name="' . $date['year'] . $date['mon'] . $date['mday'] . '"></a>';
            print_heading(userdate($message->timecreated, $blockdate), 'center', 4);
        }
        if ($message->useridfrom == $user1->id) {
            echo message_format_message($message, $user1, $messagedate, $search, 'other');
        } else {
            echo message_format_message($message, $user2, $messagedate, $search, 'me');
        }
    }
} else {
    print_heading(get_string('nomessagesfound', 'message'));
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:history.php


示例12: message_print_message_history

/**
 * Print the message history between two users
 * @param object $user1 the current user
 * @param object $user2 the other user
 * @param string $search search terms to highlight
 * @param int $messagelimit maximum number of messages to return
 * @param string $messagehistorylink the html for the message history link or false
 * @param bool $viewingnewmessages are we currently viewing new messages?
 */
function message_print_message_history($user1,$user2,$search='',$messagelimit=0, $messagehistorylink=false, $viewingnewmessages=false) {
    global $CFG, $OUTPUT;

    echo $OUTPUT->box_start('center');
    echo html_writer::start_tag('table', array('cellpadding' => '10', 'class' => 'message_user_pictures'));
    echo html_writer::start_tag('tr');

    echo html_writer::start_tag('td', array('align' => 'center', 'id' => 'user1'));
    echo $OUTPUT->user_picture($user1, array('size' => 100, 'courseid' => SITEID));
    echo html_writer::tag('div', fullname($user1), array('class' => 'heading'));
    echo html_writer::end_tag('td');

    echo html_writer::start_tag('td', array('align' => 'center'));
    echo html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/left'), 'alt' => get_string('from')));
    echo html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/right'), 'alt' => get_string('to')));
    echo html_writer::end_tag('td');

    echo html_writer::start_tag('td', array('align' => 'center', 'id' => 'user2'));
    echo $OUTPUT->user_picture($user2, array('size' => 100, 'courseid' => SITEID));
    echo html_writer::tag('div', fullname($user2), array('class' => 'heading'));

    if (isset($user2->iscontact) && isset($user2->isblocked)) {
        $incontactlist = $user2->iscontact;
        $isblocked = $user2->isblocked;

        $script = null;
        $text = true;
        $icon = false;

        $strcontact = message_get_contact_add_remove_link($incontactlist, $isblocked, $user2, $script, $text, $icon);
        $strblock   = message_get_contact_block_link($incontactlist, $isblocked, $user2, $script, $text, $icon);
        $useractionlinks = $strcontact.'&nbsp;|'.$strblock;

        echo html_writer::tag('div', $useractionlinks, array('class' => 'useractionlinks'));
    }

    echo html_writer::end_tag('td');
    echo html_writer::end_tag('tr');
    echo html_writer::end_tag('table');
    echo $OUTPUT->box_end();

    if (!empty($messagehistorylink)) {
        echo $messagehistorylink;
    }

    /// Get all the messages and print them
    if ($messages = message_get_history($user1, $user2, $messagelimit, $viewingnewmessages)) {
        $tablecontents = '';

        $current = new stdClass();
        $current->mday = '';
        $current->month = '';
        $current->year = '';
        $messagedate = get_string('strftimetime');
        $blockdate   = get_string('strftimedaydate');
        foreach ($messages as $message) {
            if ($message->notification) {
                $notificationclass = ' notification';
            } else {
                $notificationclass = null;
            }
            $date = usergetdate($message->timecreated);
            if ($current->mday != $date['mday'] | $current->month != $date['month'] | $current->year != $date['year']) {
                $current->mday = $date['mday'];
                $current->month = $date['month'];
                $current->year = $date['year'];

                $datestring = html_writer::empty_tag('a', array('name' => $date['year'].$date['mon'].$date['mday']));
                $tablecontents .= html_writer::tag('div', $datestring, array('class' => 'mdl-align heading'));

                $tablecontents .= $OUTPUT->heading(userdate($message->timecreated, $blockdate), 4, 'mdl-align');
            }

            $formatted_message = $side = null;
            if ($message->useridfrom == $user1->id) {
                $formatted_message = message_format_message($message, $messagedate, $search, 'me');
                $side = 'left';
            } else {
                $formatted_message = message_format_message($message, $messagedate, $search, 'other');
                $side = 'right';
            }
            $tablecontents .= html_writer::tag('div', $formatted_message, array('class' => "mdl-left $side $notificationclass"));
        }

        echo html_writer::nonempty_tag('div', $tablecontents, array('class' => 'mdl-left messagehistory'));
    } else {
        echo html_writer::nonempty_tag('div', '('.get_string('nomessagesfound', 'message').')', array('class' => 'mdl-align messagehistory'));
    }
}
开发者ID:nfreear,项目名称:moodle,代码行数:98,代码来源:lib.php


示例13: calendar_show_month_detailed

function calendar_show_month_detailed($m, $y, $courses, $groups, $users, $courseid)
{
    global $CFG, $SESSION, $USER, $CALENDARDAYS;
    global $day, $mon, $yr;
    $getvars = 'from=month&amp;cal_d=' . $day . '&amp;cal_m=' . $mon . '&amp;cal_y=' . $yr;
    // For filtering
    $display =& new stdClass();
    $display->minwday = get_user_preferences('calendar_startwday', CALENDAR_STARTING_WEEKDAY);
    $display->maxwday = $display->minwday + 6;
    if (!empty($m) && !empty($y)) {
        $thisdate = usergetdate(time());
        // Time and day at the user's location
        if ($m == $thisdate['mon'] && $y == $thisdate['year']) {
            // Navigated to this month
            $date = $thisdate;
            $display->thismonth = true;
        } else {
            // Navigated to other month, let's do a nice trick and save us a lot of work...
            if (!checkdate($m, 1, $y)) {
                $date = array('mday' => 1, 'mon' => $thisdate['mon'], 'year' => $thisdate['year']);
                $display->thismonth = true;
            } else {
                $date = array('mday' => 1, 'mon' => $m, 'year' => $y);
                $display->thismonth = false;
            }
        }
    } else {
        $date = usergetdate(time());
        $display->thismonth = true;
    }
    // Fill in the variables we 're going to use, nice and tidy
    list($d, $m, $y) = array($date['mday'], $date['mon'], $date['year']);
    // This is what we want to display
    $display->maxdays = calendar_days_in_month($m, $y);
    $startwday = 0;
    if (get_user_timezone_offset() < 99) {
        // We 'll keep these values as GMT here, and offset them when the time comes to query the db
        $display->tstart = gmmktime(0, 0, 0, $m, 1, $y);
        // This is GMT
        $display->tend = gmmktime(23, 59, 59, $m, $display->maxdays, $y);
        // GMT
        $startwday = gmdate('w', $display->tstart);
        // $display->tstart is already GMT, so don't use date(): messes with server's TZ
    } else {
        // no timezone info specified
        $display->tstart = mktime(0, 0, 0, $m, 1, $y);
        $display->tend = mktime(23, 59, 59, $m, $display->maxdays, $y);
        $startwday = date('w', $display->tstart);
        // $display->tstart not necessarily GMT, so use date()
    }
    // Align the starting weekday to fall in our display range
    if ($startwday < $display->minwday) {
        $startwday += 7;
    }
    // Get events from database
    $events = calendar_get_events(usertime($display->tstart), usertime($display->tend), $users, $groups, $courses);
    if (!empty($events)) {
        foreach ($events as $eventid => $event) {
            if (!empty($event->modulename)) {
                $cm = get_coursemodule_from_instance($event->modulename, $event->instance);
                if (!groups_course_module_visible($cm)) {
                    unset($events[$eventid]);
                }
            }
        }
    }
    // Extract information: events vs. time
    calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday, $courses);
    $text = '';
    if (!isguest() && !empty($USER->id) && calendar_user_can_add_event()) {
        $text .= '<div class="buttons"><form action="' . CALENDAR_URL . 'event.php" method="get">';
        $text .= '<div>';
        $text .= '<input type="hidden" name="action" value="new" />';
        $text .= '<input type="hidden" name="course" value="' . $courseid . '" />';
        $text .= '<input type="hidden" name="cal_m" value="' . $m . '" />';
        $text .= '<input type="hidden" name="cal_y" value="' . $y . '" />';
        $text .= '<input type="submit" value="' . get_string('newevent', 'calendar') . '" />';
        $text .= '</div></form></div>';
    }
    $text .= '<label for="cal_course_flt_jump">' . get_string('detailedmonthview', 'calendar') . ':</label>' . calendar_course_filter_selector($getvars);
    echo '<div class="header">' . $text . '</div>';
    echo '<div class="controls">';
    echo calendar_top_controls('month', array('id' => $courseid, 'm' => $m, 'y' => $y));
    echo '</div>';
    // Start calendar display
    echo '<table class="calendarmonth"><tr class="weekdays">';
    // Begin table. First row: day names
    // Print out the names of the weekdays
    for ($i = $display->minwday; $i <= $display->maxwday; ++$i) {
        // This uses the % operator to get the correct weekday no matter what shift we have
        // applied to the $display->minwday : $display->maxwday range from the default 0 : 6
        echo '<th scope="col">' . get_string($CALENDARDAYS[$i % 7], 'calendar') . '</th>';
    }
    echo '</tr><tr>';
    // End of day names; prepare for day numbers
    // For the table display. $week is the row; $dayweek is the column.
    $week = 1;
    $dayweek = $startwday;
    // Paddding (the first week may have blank days in the beginning)
    for ($i = $display->minwday; $i < $startwday; ++$i) {
//.........这里部分代码省略.........
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:101,代码来源:view.php


示例14: construct_sessions_data_for_add

function construct_sessions_data_for_add($formdata)
{
    global $CFG;
    $duration = $formdata->durtime['hours'] * HOURSECS + $formdata->durtime['minutes'] * MINSECS;
    $now = time();
    $sessions = array();
    if (isset($formdata->addmultiply)) {
        $startdate = $formdata->sessiondate;
        $starttime = $startdate - usergetmidnight($startdate);
        $enddate = $formdata->sessionenddate + DAYSECS;
        // because enddate in 0:0am
        if ($enddate < $startdate) {
            return NULL;
        }
        $days = (int) ceil(($enddate - $startdate) / DAYSECS);
        // Getting first day of week
        $sdate = $startdate;
        $dinfo = usergetdate($sdate);
        if ($CFG->calendar_startwday === '0') {
            //week start from sunday
            $startweek = $startdate - $dinfo['wday'] * DAYSECS;
            //call new variable
        } else {
            $wday = $dinfo['wday'] === 0 ? 7 : $dinfo['wday'];
            $startweek = $startdate - ($wday - 1) * DAYSECS;
        }
        $wdaydesc = array(0 => 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
        while ($sdate < $enddate) {
            if ($sdate < $startweek + WEEKSECS) {
                $dinfo = usergetdate($sdate);
                if (key_exists($wdaydesc[$dinfo['wday']], $formdata->sdays)) {
                    $sess->sessdate = usergetmidnight($sdate) + $starttime;
                    $sess->duration = $duration;
                    $sess->descriptionitemid = $formdata->sdescription['itemid'];
                    $sess->description = $formdata->sdescription['text'];
                    $sess->descriptionformat = $formdata->sdescription['format'];
                    $sess->timemodified = $now;
                    fill_groupid($formdata, $sessions, $sess);
                }
                $sdate += DAYSECS;
            } else {
                $startweek += WEEKSECS * $formdata->period;
                $sdate = $startweek;
            }
        }
    } else {
        $sess->sessdate = $formdata->sessiondate;
        $sess->duration = $duration;
        $sess->descriptionitemid = $formdata->sdescription['itemid'];
        $sess->description = $formdata->sdescription['text'];
        $sess->descriptionformat = $formdata->sdescription['format'];
        $sess->timemodified = $now;
        fill_groupid($formdata, $sessions, $sess);
    }
    return $sessions;
}
开发者ID:e-rasvet,项目名称:attforblockup,代码行数:56,代码来源:sessions.php


示例15: test_usergetdate

 public function test_usergetdate()
 {
     global $USER, $CFG, $DB;
     $this->resetAfterTest();
     $this->setAdminUser();
     $USER->timezone = 2;
     // Set the timezone to a known state.
     $ts = 1261540267;
     // The time this function was created.
     $arr = usergetdate($ts, 1);
     // Specify the timezone as an argument.
     $arr = array_values($arr);
     list($seconds, $minutes, $hours, $mday, $wday, $mon, $year, $yday, $weekday, $month) = $arr;
     $this->assertSame(7, $seconds);
     $this->assertSame(51, $minutes);
     $this->assertSame(4, $hours);
     $this->assertSame(23, $mday);
     $this->assertSame(3, $wday);
     $this->assertSame(12, $mon);
     $this->assertSame(2009, $year);
     $this->assertSame(356, $yday);
     $this->assertSame('Wednesday', $weekday);
     $this->assertSame('December', $month);
     $arr = usergetdate($ts);
     // Gets the timezone from the $USER object.
     $arr = array_values($arr);
     list($seconds, $minutes, $hours, $mday, $wday, $mon, $year, $yday, $weekday, $month) = $arr;
     $this->assertSame(7, $seconds);
     $this->assertSame(51, $minutes);
     $this->assertSame(5, $hours);
     $this->assertSame(23, $mday);
     $this->assertSame(3, $wday);
     $this->assertSame(12, $mon);
     $this->assertSame(2009, $year);
     $this->assertSame(356, $yday);
     $this->assertSame('Wednesday', $weekday);
     $this->assertSame('December', $month);
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:38,代码来源:moodlelib_test.php


示例16: restore_log_date_changes

function restore_log_date_changes($recordtype, &$restore, &$xml, $TAGS, $NAMETAG = 'NAME')
{
    global $CFG;
    $openlog = false;
    // loop through time fields in $TAGS
    foreach ($TAGS as $TAG) {
        // check $TAG has a sensible value
        if (!empty($xml[$TAG][0]['#']) && is_string($xml[$TAG][0]['#']) && is_numeric($xml[$TAG][0]['#'])) {
            if ($openlog == false) {
                $openlog = true;
                // only come through here once
                // open file for writing
                $course_dir = "{$CFG->dataroot}/{$restore->course_id}/backupdata";
                check_dir_exists($course_dir, true);
                $restorelog = fopen("{$course_dir}/restorelog.html", "a");
                // start output for this record
                $msg = new stdClass();
                $msg->recordtype = $recordtype;
                $msg->recordname = $xml[$NAMETAG][0]['#'];
                fwrite($restorelog, get_string("backupdaterecordtype", "moodle", $msg));
            }
            // write old date to $restorelog
            $value = $xml[$TAG][0]['#'];
            $date = usergetdate($value);
            $msg = new stdClass();
            $msg->TAG = $TAG;
            $msg->weekday = $date['weekday'];
            $msg->mday = $date['mday'];
            $msg->month = $date['month'];
            $msg->year = $date['year'];
            fwrite($restorelog, get_string("backupdateold", "moodle", $msg));
            // write new date to $restorelog
            $value += $restore->course_startdateoffset;
            $date = usergetdate($value);
            $msg = new stdClass();
            $msg->TAG = $TAG;
            $msg->weekday = $date['weekday'];
            $msg->mday = $date['mday'];
            $msg->month = $date['month'];
            $msg->year = $date['year'];
            fwrite($restorelog, get_string("backupdatenew", "moodle", $msg));
            // update $value in $xml tree for calling module
            $xml[$TAG][0]['#'] = "{$value}";
        }
    }
    // close the restore log, if it was opened
    if ($openlog) {
        fclose($restorelog);
    }
}
开发者ID:kai707,项目名称:ITSA-backup,代码行数:50,代码来源:restorelib.php


示例17: message_print_message_history

/**
 * Print the message history between two users
 *
 * @param object $user1 the current user
 * @param object $user2 the other user
 * @param string $search search terms to highlight
 * @param int $messagelimit maximum number of messages to return
 * @param string $messagehistorylink the html for the message history link or false
 * @param bool $viewingnewmessages are we currently viewing new messages?
 */
function message_print_message_history($user1, $user2 ,$search = '', $messagelimit = 0, $messagehistorylink = false, $viewingnewmessages = false, $showactionlinks = true) {
    global $OUTPUT, $PAGE;

    $PAGE->requires->yui_module(
        array('moodle-core_message-toolbox'),
        'M.core_message.toolbox.deletemsg.init',
        array(array())
    );

    echo $OUTPUT->box_start('center', 'message_user_pictures');
    echo $OUTPUT->box_start('user');
    echo $OUTPUT->box_start('generalbox', 'user1');
    echo $OUTPUT->user_picture($user1, array('size' => 100, 'courseid' => SITEID));
    echo html_writer::tag('div', fullname($user1), array('class' => 'heading'));
    echo $OUTPUT->box_end();
    echo $OUTPUT->box_end();

    $imgattr = array('src' => $OUTPUT->pix_url('i/twoway'), 'alt' => '', 'width' => 16, 'height' => 16);
    echo $OUTPUT->box(html_writer::empty_tag('img', $imgattr), 'between');

    echo $OUTPUT->box_start('user');
    echo $OUTPUT->box_start('generalbox', 'user2');
    // Show user picture with link is real user else without link.
    if (core_user::is_real_user($user2->id)) {
        echo $OUTPUT->user_picture($user2, array('size' => 100, 'courseid' => SITEID));
    } else {
        echo $OUTPUT->user_picture($user2, array('size' => 100, 'courseid' => SITEID, 'link' => false));
    }
    echo html_writer::tag('div', fullname($user2), array('class' => 'heading'));

    if ($showactionlin 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP usergetmidnight函数代码示例发布时间:2022-05-23
下一篇:
PHP userfiles_path函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap