本文整理汇总了PHP中DateTimeValue::getDay方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeValue::getDay方法的具体用法?PHP DateTimeValue::getDay怎么用?PHP DateTimeValue::getDay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeValue
的用法示例。
在下文中一共展示了DateTimeValue::getDay方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRangeProjectEvents
/**
* Returns all events for the given range, tag and considers the active project
*
* @param DateTimeValue $date
* @param String $tags
* @return unknown
*/
static function getRangeProjectEvents(DateTimeValue $start_date, DateTimeValue $end_date, $tags = '', $project = null, $archived = false)
{
$start_year = date("Y", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$start_month = date("m", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$start_day = date("d", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$end_year = date("Y", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
$end_month = date("m", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
$end_day = date("d", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
if (!is_numeric($start_day) or !is_numeric($start_month) or !is_numeric($start_year) or !is_numeric($end_day) or !is_numeric($end_month) or !is_numeric($end_year)) {
return NULL;
}
//permission check
$permissions = ' AND ( ' . permissions_sql_for_listings(ProjectEvents::instance(), ACCESS_LEVEL_READ, logged_user()) . ')';
if ($project instanceof Project) {
$pids = $project->getAllSubWorkspacesQuery(!$archived);
$wsstring = " AND " . self::getWorkspaceString($pids);
} else {
$wsstring = "";
}
if (isset($tags) && $tags && $tags != '') {
$tag_str = " AND EXISTS (SELECT * FROM `" . TABLE_PREFIX . "tags` `t` WHERE `tag` IN (" . DB::escape($tags) . ") AND `" . TABLE_PREFIX . "project_events`.`id` = `t`.`rel_object_id` AND `t`.`rel_object_manager` = 'ProjectEvents') ";
} else {
$tag_str = "";
}
$invited = " AND `id` IN (SELECT `event_id` FROM `" . TABLE_PREFIX . "event_invitations` WHERE `user_id` = " . logged_user()->getId() . ")";
if ($archived) {
$archived_cond = " AND `archived_by_id` <> 0";
} else {
$archived_cond = " AND `archived_by_id` = 0";
}
$tz_hm = "'" . floor(logged_user()->getTimezone()) . ":" . abs(logged_user()->getTimezone()) % 1 * 60 . "'";
$s_date = new DateTimeValue($start_date->getTimestamp() - logged_user()->getTimezone() * 3600);
$e_date = new DateTimeValue($end_date->getTimestamp() - logged_user()->getTimezone() * 3600);
$e_date->add("d", 1);
$start_date_str = $s_date->format("Y-m-d H:i:s");
$end_date_str = $e_date->format("Y-m-d H:i:s");
$first_d = $start_day;
while ($first_d > 7) {
$first_d -= 7;
}
$week_of_first_day = date("W", mktime(0, 0, 0, $start_month, $first_d, $start_year));
$conditions = "\t((\n\t\t\t\t-- \n\t\t\t\t-- THIS RETURNS EVENTS ON THE ACTUAL DAY IT'S SET FOR (ONE TIME EVENTS)\n\t\t\t\t-- \n\t\t\t\t(\n\t\t\t\t\t`repeat_h` = 0 \n\t\t\t\t\tAND `duration` >= '{$start_date_str}' \n\t\t\t\t\tAND `start` < '{$end_date_str}' \n\t\t\t\t) \n\t\t\t\t-- \n\t\t\t\t-- THIS RETURNS REGULAR REPEATING EVENTS - DAILY, WEEKLY, MONTHLY, OR YEARLY.\n\t\t\t\t-- \n\t\t\t\tOR \n\t\t\t\t(\n\t\t\t\t\t`repeat_h` = 0 \n\t\t\t\t\tAND\n\t\t\t\t\tDATE(`start`) < '{$end_date_str}'\n\t\t\t\t\tAND\n\t\t\t\t\t(\t\t\t\t\t\t\t\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_d` DAY) >= '{$start_date_str}' \n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_forever = 1\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\n\t\t\t\t\t\t)\n\t\t\t\t\t\tOR\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_m` MONTH) >= '{$start_date_str}' \n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_forever = 1\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\n\t\t\t\t\t\t)\n\t\t\t\t\t\tOR\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_y` YEAR) >= '{$start_date_str}' \n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_forever = 1\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\n\t\t\t\t\t\t)\n\t\t\t\t\t)\t\t\n\t\t\t\t)\n\t\t\t\t-- \n\t\t\t\t-- THIS RETURNS EVENTS SET TO BE A CERTAIN DAY OF THE WEEK IN A CERTAIN WEEK EVERY CERTAIN AMOUNT OF MONTHS\n\t\t\t\t-- \n\t\t\t\tOR\n\t\t\t\t(\n\t\t\t\t\tDATE(`start`) <= '{$start_date_str}'\n\t\t\t\t\tAND\n\t\t\t\t\t`repeat_h` = 1 \n\t\t\t\t\tAND\n\t\t\t\t\t`repeat_dow` = DAYOFWEEK('{$start_date_str}') \n\t\t\t\t\tAND\n\t\t\t\t\t`repeat_wnum` + {$week_of_first_day} - 1 = WEEK('{$start_date_str}', 3) \n\t\t\t\t\tAND\n\t\t\t\t\tMOD( PERIOD_DIFF(DATE_FORMAT(`start`, '%Y%m'), DATE_FORMAT('{$start_date_str}', '%Y%m')), `repeat_mjump`) = 0\n\t\t\t\t)\t\t\t\t\n\t\t\t)\n\t\t\t{$wsstring}\n\t\t\t{$permissions} {$invited}\n\t\t\t{$tag_str} {$archived_cond} )";
$result_events = self::findAll(array('conditions' => $conditions, 'order' => '`start`'));
// Find invitations for events and logged user
ProjectEvents::addInvitations($result_events);
return $result_events;
}
示例2: lang
$img_url = image_url('/16x16/milestone.png');
$divtype = '<span class="italic">' . lang('milestone') . '</span> - ';
$tipBody = clean($event->getDescription());
} elseif ($event instanceof ProjectTask) {
$start_of_task = false;
$end_of_task = false;
if ($event->getDueDate() instanceof DateTimeValue) {
$due_date = new DateTimeValue($event->getDueDate()->getTimestamp() + logged_user()->getTimezone() * 3600);
if ($dtv->getTimestamp() == mktime(0, 0, 0, $due_date->getMonth(), $due_date->getDay(), $due_date->getYear())) {
$end_of_task = true;
$start_of_task = true;
}
}
if ($event->getStartDate() instanceof DateTimeValue) {
$start_date = new DateTimeValue($event->getStartDate()->getTimestamp() + logged_user()->getTimezone() * 3600);
if ($dtv->getTimestamp() == mktime(0, 0, 0, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear())) {
$start_of_task = true;
$end_of_task = true;
}
}
if ($start_of_task && $end_of_task) {
$tip_title = lang('task');
$img_url = image_url('/16x16/tasks.png');
$tip_pre = '';
} else {
if ($end_of_task) {
$tip_title = lang('end of task');
$img_url = image_url('/16x16/task_end.png');
$tip_pre = 'end_';
} else {
$tip_title = lang('start of task');
示例3: lang
$divtype = '<span class="italic">' . lang('event') . '</span> - ';
$tipBody = trim(clean($event->getDescription())) != '' ? '<br>' . clean($event->getDescription()) : '';
} elseif ($event instanceof Contact) {
$div_prefix = 'w5_bd_div_';
$objType = 'contact';
$subject = clean($event->getObjectName());
$img_url = image_url('/16x16/contacts.png');
$due_date = new DateTimeValue(mktime(0, 0, 0, $event->getOBirthday()->getMonth(), $event->getOBirthday()->getDay(), $dates[$day_of_week]->getYear()));
$divtype = '<span class="italic">' . lang('birthday') . '</span> - ';
}
$tipBody = str_replace("\r", '', $tipBody);
$tipBody = str_replace("\n", '<br>', $tipBody);
if (strlen_utf($tipBody) > 200) {
$tipBody = substr_utf($tipBody, 0, strpos($tipBody, ' ', 200)) . ' ...';
}
if ($event instanceof ProjectMilestone || $event instanceof ProjectEvent || $due_date instanceof DateTimeValue && $dates[$day_of_week]->getTimestamp() == mktime(0, 0, 0, $due_date->getMonth(), $due_date->getDay(), $due_date->getYear()) || $start_date instanceof DateTimeValue && $dates[$day_of_week]->getTimestamp() == mktime(0, 0, 0, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear())) {
$ws_color = $event->getObjectColor($event instanceof ProjectEvent ? 1 : 12);
cal_get_ws_color($ws_color, $ws_style, $ws_class, $txt_color, $border_color);
?>
<div id="<?php
echo $div_prefix . $event->getId();
?>
" class="adc" style="left: 4%; top: <?php
echo $top;
?>
px; z-index: 5;width: 92%;margin:1px;position:absolute;">
<div class="t3 <?php
echo $ws_class;
?>
" style="<?php
echo $ws_style;
示例4: DateTimeValue
$occup[$i][0][$posHoriz] = true;
$occup[$i][1][$posHoriz] = true;
}
if ($event_duration->getMinute() > 0) {
$occup[$event_duration->getHour()][0][$posHoriz] = true;
if ($event_duration->getMinute() > 30) {
$occup[$event_duration->getHour()][1][$posHoriz] = true;
}
}
//if ($posHoriz+1 == $evs_same_time) $width = $width - 0.75;
$procesados[$hr_start]++;
$event_duration->add('s', 1);
$ev_duration = DateTimeValueLib::get_time_difference($event_start->getTimestamp(), $event_duration->getTimestamp());
$real_start = new DateTimeValue($event->getStart()->getTimestamp() + 3600 * logged_user()->getTimezone());
$real_duration = new DateTimeValue($event->getDuration()->getTimestamp() + 3600 * logged_user()->getTimezone());
$pre_tf = $real_start->getDay() == $real_duration->getDay() ? '' : 'D j, ';
$ev_hour_text = format_date($real_start, $pre_tf . $timeformat, 0) . " - " . format_date($real_duration, $pre_tf . $timeformat, 0);
$tipBody = $ev_hour_text . (trim(clean($event->getDescription())) != '' ? '<br><br>' . clean($event->getDescription()) : '');
$tipBody = str_replace(array("\r", "\n"), array(' ', '<br>'), $tipBody);
if (strlen_utf($tipBody) > 200) {
$tipBody = substr_utf($tipBody, 0, strpos($tipBody, ' ', 200)) . ' ...';
}
?>
<script>
if (<?php
echo $top;
?>
< scroll_to || scroll_to == -1) {
scroll_to = <?php
echo $top;
?>
示例5: mktime
function move_event() {
if (logged_user()->isGuest()) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$event = ProjectEvents::findById(get_id());
if(!$event->canEdit(logged_user())){
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$is_read = $event->getIsRead(logged_user()->getId());
$year = array_var($_GET, 'year', $event->getStart()->getYear());
$month = array_var($_GET, 'month', $event->getStart()->getMonth());
$day = array_var($_GET, 'day', $event->getStart()->getDay());
$hour = array_var($_GET, 'hour', 0);
$min = array_var($_GET, 'min', 0);
if ($hour == -1) $hour = format_date($event->getStart(), 'H', logged_user()->getTimezone() );
if ($min == -1) $min = format_date($event->getStart(), 'i', logged_user()->getTimezone() );
if ($event->isRepetitive()) {
$orig_date = DateTimeValueLib::dateFromFormatAndString('Y-m-d H:i:s', array_var($_GET, 'orig_date'));
$diff = DateTimeValueLib::get_time_difference($orig_date->getTimestamp(), mktime($hour, $min, 0, $month, $day, $year));
$new_start = new DateTimeValue($event->getStart()->getTimestamp());
$new_start->add('d', $diff['days']);
$new_start->add('h', $diff['hours']);
$new_start->add('m', $diff['minutes']);
if ($event->getRepeatH()) {
$event->setRepeatDow(date("w", mktime($hour, $min, 0, $month, $day, $year))+1);
$wnum = 0;
$tmp_day = $new_start->getDay();
while ($tmp_day > 0) {
$tmp_day -= 7;
$wnum++;
}
$event->setRepeatWnum($wnum);
}
} else {
$new_start = new DateTimeValue(mktime($hour, $min, 0, $month, $day, $year) - logged_user()->getTimezone() * 3600);
}
$diff = DateTimeValueLib::get_time_difference($event->getStart()->getTimestamp(), $event->getDuration()->getTimestamp());
$new_duration = new DateTimeValue($new_start->getTimestamp());
$new_duration->add('d', $diff['days']);
$new_duration->add('h', $diff['hours']);
$new_duration->add('m', $diff['minutes']);
// see if we have to reload
$os = format_date($event->getStart(), 'd', logged_user()->getTimezone() );
$od = format_date($event->getDuration(), 'd', logged_user()->getTimezone() );
$ohm = format_date($event->getDuration(), 'H:i', logged_user()->getTimezone() );
$nd = format_date($new_duration, 'd', logged_user()->getTimezone() );
$nhm = format_date($new_duration, 'H:i', logged_user()->getTimezone() );
$different_days = ($os != $od && $ohm != '00:00') || ($day != $nd && $nhm != '00:00');
DB::beginWork();
$event->setStart($new_start->format("Y-m-d H:i:s"));
$event->setDuration($new_duration->format("Y-m-d H:i:s"));
$event->save();
$old_reminders = ObjectReminders::getByObject($event);
if($old_reminders != null){
$object_controller = new ObjectController();
$object_controller->update_reminders($event, $old_reminders); //updating the old ones
}else if(user_config_option("add_event_autoreminder")){
$reminder = new ObjectReminder();
$def = explode(",",user_config_option("reminders_events"));
$minutes = array_var($def, 2) * array_var($def, 1);
$reminder->setMinutesBefore($minutes);
$reminder->setType(array_var($def, 0));
$reminder->setContext("start");
$reminder->setObject($event);
$reminder->setUserId(0);
$date = $event->getStart();
if ($date instanceof DateTimeValue) {
$rdate = new DateTimeValue($date->getTimestamp() - $minutes * 60);
$reminder->setDate($rdate);
}
$reminder->save();
}
if (!$is_read) {
$event->setIsRead(logged_user()->getId(), false);
}
if($event->getSpecialID() != ""){
$this->sync_calendar_extern($event);
}
DB::commit();
ajx_extra_data($this->get_updated_event_data($event));
if ($different_days || $event->isRepetitive()) ajx_current("reload");
else ajx_current("empty");
}
示例6: pick_date_widget
/**
* Return pick date widget
*
* @access public
* @param string $name Name prefix
* @param DateTimeValue $value Can be DateTimeValue object, integer or string
* @param integer $year_from Start counting from this year. If NULL this value will be set
* to current year - 10
* @param integer $year_to Count to this year. If NULL this value will be set to current
* @deprecated
* year + 10
* @return null
*/
function pick_date_widget($name, $value = null, $year_from = null, $year_to = null, $attributes = null, $id = null)
{
require_javascript("og/DateField.js");
$oldValue = $value;
if (!$value instanceof DateTimeValue) {
$value = new DateTimeValue($value);
}
$month_options = array();
for ($i = 1; $i <= 12; $i++) {
$option_attributes = $i == $value->getMonth() ? array('selected' => 'selected') : null;
$month_options[] = option_tag(lang("month {$i}"), $i, $option_attributes);
}
// for
$day_options = array();
for ($i = 1; $i <= 31; $i++) {
$option_attributes = $i == $value->getDay() ? array('selected' => 'selected') : null;
$day_options[] = option_tag($i, $i, $option_attributes);
}
// for
$year_from = (int) $year_from < 1 ? $value->getYear() - 10 : (int) $year_from;
$year_to = (int) $year_to < 1 || (int) $year_to < $year_from ? $value->getYear() + 10 : (int) $year_to;
$year_options = array();
if ($year_from <= 1902) {
$option_attributes = is_null($oldValue) ? array('selected' => 'selected') : null;
$year_options[] = option_tag(lang('select'), 0, $option_attributes);
}
for ($i = $year_from; $i <= $year_to; $i++) {
$option_attributes = $i == $value->getYear() && !is_null($oldValue) ? array('selected' => 'selected') : null;
$year_options[] = option_tag($i, $i, $option_attributes);
}
// if
$attM = $attributes;
$attY = $attributes;
$attD = $attributes;
if ($attM['id']) {
$attM['id'] .= '_month';
}
if ($attY['id']) {
$attY['id'] .= '_year';
}
if ($attD['id']) {
$attD['id'] .= '_day';
}
if (strpos($name, "]")) {
$preName = substr_utf($name, 0, strpos_utf($name, "]"));
return select_box($preName . '_month]', $month_options, $attM) . select_box($preName . '_day]', $day_options, $attD) . select_box($preName . '_year]', $year_options, $attY);
} else {
return select_box($name . '_month', $month_options, $attM) . select_box($name . '_day', $day_options, $attD) . select_box($name . '_year', $year_options, $attY);
}
}
示例7: mktime
function move_event()
{
if (logged_user()->isGuest()) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$event = ProjectEvents::findById(get_id());
if (!$event->canEdit(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$is_read = $event->getIsRead(logged_user()->getId());
$year = array_var($_GET, 'year', $event->getStart()->getYear());
$month = array_var($_GET, 'month', $event->getStart()->getMonth());
$day = array_var($_GET, 'day', $event->getStart()->getDay());
$hour = array_var($_GET, 'hour', 0);
$min = array_var($_GET, 'min', 0);
if ($hour == -1) {
$hour = format_date($event->getStart(), 'H', logged_user()->getTimezone());
}
if ($min == -1) {
$min = format_date($event->getStart(), 'i', logged_user()->getTimezone());
}
if ($event->isRepetitive()) {
$orig_date = DateTimeValueLib::dateFromFormatAndString('Y-m-d H:i:s', array_var($_GET, 'orig_date'));
$diff = DateTimeValueLib::get_time_difference($orig_date->getTimestamp(), mktime($hour, $min, 0, $month, $day, $year));
$new_start = new DateTimeValue($event->getStart()->getTimestamp());
$new_start->add('d', $diff['days']);
$new_start->add('h', $diff['hours']);
$new_start->add('m', $diff['minutes']);
if ($event->getRepeatH()) {
$event->setRepeatDow(date("w", mktime($hour, $min, 0, $month, $day, $year)) + 1);
$wnum = 0;
$tmp_day = $new_start->getDay();
while ($tmp_day > 0) {
$tmp_day -= 7;
$wnum++;
}
$event->setRepeatWnum($wnum);
}
} else {
$new_start = new DateTimeValue(mktime($hour, $min, 0, $month, $day, $year) - logged_user()->getTimezone() * 3600);
}
$diff = DateTimeValueLib::get_time_difference($event->getStart()->getTimestamp(), $event->getDuration()->getTimestamp());
$new_duration = new DateTimeValue($new_start->getTimestamp());
$new_duration->add('d', $diff['days']);
$new_duration->add('h', $diff['hours']);
$new_duration->add('m', $diff['minutes']);
// see if we have to reload
$os = format_date($event->getStart(), 'd', logged_user()->getTimezone());
$od = format_date($event->getDuration(), 'd', logged_user()->getTimezone());
$ohm = format_date($event->getDuration(), 'H:i', logged_user()->getTimezone());
$nd = format_date($new_duration, 'd', logged_user()->getTimezone());
$nhm = format_date($new_duration, 'H:i', logged_user()->getTimezone());
$different_days = $os != $od && $ohm != '00:00' || $day != $nd && $nhm != '00:00';
DB::beginWork();
$event->setStart($new_start->format("Y-m-d H:i:s"));
$event->setDuration($new_duration->format("Y-m-d H:i:s"));
$event->save();
if (!$is_read) {
$event->setIsRead(logged_user()->getId(), false);
}
if ($event->getSpecialID() != "") {
$this->sync_calendar_extern($event);
}
DB::commit();
ajx_extra_data($this->get_updated_event_data($event));
if ($different_days || $event->isRepetitive()) {
ajx_current("reload");
} else {
ajx_current("empty");
}
}
示例8: getRangeProjectEvents
/**
* Returns all events for the given range, tag and considers the active project
*
* @param DateTimeValue $date
* @param String $tags
* @return unknown
*/
static function getRangeProjectEvents(DateTimeValue $start_date, DateTimeValue $end_date, $user_filter = null, $inv_state = null)
{
$start_year = date("Y", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$start_month = date("m", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$start_day = date("d", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$end_year = date("Y", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
$end_month = date("m", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
$end_day = date("d", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
if (!is_numeric($start_day) or !is_numeric($start_month) or !is_numeric($start_year) or !is_numeric($end_day) or !is_numeric($end_month) or !is_numeric($end_year)) {
return NULL;
}
$user = null;
if ($user_filter > 0) {
$user = Contacts::findById($user_filter);
}
if ($user_filter != -1 && !$user instanceof Contact) {
$user = logged_user();
}
$invited = "";
if ($user instanceof Contact) {
$invited = " AND o.`id` IN (SELECT `event_id` FROM `" . TABLE_PREFIX . "event_invitations` WHERE `contact_id` = " . $user->getId() . ")";
}
$tz_hm = "'" . floor(logged_user()->getTimezone()) . ":" . abs(logged_user()->getTimezone()) % 1 * 60 . "'";
$s_date = new DateTimeValue($start_date->getTimestamp() - logged_user()->getTimezone() * 3600);
$e_date = new DateTimeValue($end_date->getTimestamp() - logged_user()->getTimezone() * 3600);
$e_date->add("d", 1);
$start_date_str = $s_date->format("Y-m-d H:i:s");
$end_date_str = $e_date->format("Y-m-d H:i:s");
$first_d = $start_day;
while ($first_d > 7) {
$first_d -= 7;
}
$week_of_first_day = date("W", mktime(0, 0, 0, $start_month, $first_d, $start_year));
$conditions = "\r\n\t\t\tAND (type_id=2 OR type_id=1 AND `duration` > `start`)\r\n\t\t\tAND \r\n\t\t\t(\r\n\t\t\t (\r\n\t\t\t\t(\r\n\t\t\t\t\t`repeat_h` = 0\r\n\t\t\t\t\tAND `duration` >= '{$start_date_str}' \r\n\t\t\t\t\tAND `start` < '{$end_date_str}' \r\n\t\t\t\t) \r\n\t\t\t\tOR \r\n\t\t\t\t(\r\n\t\t\t\t\toriginal_event_id = 0\r\n\t\t\t\t\tAND\r\n\t\t\t\t\t`repeat_h` = 0 \r\n\t\t\t\t\tAND\r\n\t\t\t\t\tDATE(`start`) < '{$end_date_str}'\r\n\t\t\t\t\tAND\r\n\t\t\t\t\t(\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_d` DAY) >= '{$start_date_str}' \r\n\t\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t\trepeat_forever = 1\r\n\t\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_m` MONTH) >= '{$start_date_str}' \r\n\t\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t\trepeat_forever = 1\r\n\t\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_y` YEAR) >= '{$start_date_str}' \r\n\t\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t\trepeat_forever = 1\r\n\t\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t)\t\t\r\n\t\t\t\t)\r\n\t\t\t\tOR\r\n\t\t\t\t(\r\n\t\t\t\t\toriginal_event_id = 0\r\n\t\t\t\t\tAND\r\n\t\t\t\t\tDATE(`start`) <= '{$end_date_str}'\r\n\t\t\t\t\tAND\r\n\t\t\t\t\t`repeat_h` = 1 \t\t\t\t\t\r\n\t\t\t\t\tAND\r\n\t\t\t\t\tMOD( ABS(PERIOD_DIFF(DATE_FORMAT(`start`, '%Y%m'), DATE_FORMAT('{$start_date_str}', '%Y%m'))), `repeat_mjump`) = 0\t\t\t\t\t\r\n\t\t\t\t)\r\n\t\t\t )\r\n\t\t\t {$invited}\r\n\t\t\t)";
$result_events = self::instance()->listing(array("order" => 'start', "order_dir" => 'ASC', "extra_conditions" => $conditions))->objects;
// Find invitations for events and logged user
if (!($user_filter == null && $inv_state == null) && $user_filter != -1) {
ProjectEvents::addInvitations($result_events, $user->getId());
foreach ($result_events as $k => $event) {
$inv = $event->getInvitations();
if (!is_array($inv)) {
if ($inv == null || trim($inv_state) != '-1' && !strstr($inv_state, '' . $inv->getInvitationState()) && $inv->getContactId() == logged_user()->getId()) {
unset($result_events[$k]);
}
} else {
if (count($inv) > 0) {
foreach ($inv as $key => $v) {
if ($v == null || trim($inv_state) != '-1' && !strstr($inv_state, '' . $v->getInvitationState()) && $v->getContactId() == logged_user()->getId()) {
unset($result_events[$k]);
break;
}
}
} else {
unset($result_events[$k]);
}
}
}
}
return $result_events;
}
示例9: getRangeProjectEvents
/**
* Returns all events for the given range, tag and considers the active project
*
* @param DateTimeValue $date
* @param String $tags
* @return unknown
*/
static function getRangeProjectEvents(DateTimeValue $start_date, DateTimeValue $end_date, $tags = '', $project = null, $archived = false)
{
$start_year = date("Y", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$start_month = date("m", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$start_day = date("d", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear()));
$end_year = date("Y", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
$end_month = date("m", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
$end_day = date("d", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear()));
if (!is_numeric($start_day) or !is_numeric($start_month) or !is_numeric($start_year) or !is_numeric($end_day) or !is_numeric($end_month) or !is_numeric($end_year)) {
return NULL;
}
$invited = " AND `id` IN (SELECT `event_id` FROM `" . TABLE_PREFIX . "event_invitations` WHERE `contact_id` = " . logged_user()->getId() . ")";
$tz_hm = "'" . floor(logged_user()->getTimezone()) . ":" . abs(logged_user()->getTimezone()) % 1 * 60 . "'";
$s_date = new DateTimeValue($start_date->getTimestamp() - logged_user()->getTimezone() * 3600);
$e_date = new DateTimeValue($end_date->getTimestamp() - logged_user()->getTimezone() * 3600);
$e_date->add("d", 1);
$start_date_str = $s_date->format("Y-m-d H:i:s");
$end_date_str = $e_date->format("Y-m-d H:i:s");
$first_d = $start_day;
while ($first_d > 7) {
$first_d -= 7;
}
$week_of_first_day = date("W", mktime(0, 0, 0, $start_month, $first_d, $start_year));
$conditions = "\tAND ((\n\t\t\t\t(\n\t\t\t\t\t`repeat_h` = 0 \n\t\t\t\t\tAND `duration` >= '{$start_date_str}' \n\t\t\t\t\tAND `start` < '{$end_date_str}' \n\t\t\t\t) \n\t\t\t\tOR \n\t\t\t\t(\n\t\t\t\t\t`repeat_h` = 0 \n\t\t\t\t\tAND\n\t\t\t\t\tDATE(`start`) < '{$end_date_str}'\n\t\t\t\t\tAND\n\t\t\t\t\t(\t\t\t\t\t\t\t\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_d` DAY) >= '{$start_date_str}' \n\t\t\t\t\t\t\tOR\n repeat_forever = 1\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\n\t\t\t\t)\n\t\t\t\tOR\n\t\t\t\t(\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_m` MONTH) >= '{$start_date_str}' \n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_forever = 1\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\n\t\t\t\t\t\t)\n\t\t\t\t\t\tOR\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_y` YEAR) >= '{$start_date_str}' \n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_forever = 1\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\n\t\t\t\t\t\t)\n\t\t\t\t\t)\t\t\n\t\t\t\t)\n\t\t\t\tOR\n\t\t\t\t(\n\t\t\t\t\tDATE(`start`) <= '{$start_date_str}'\n\t\t\t\t\tAND\n\t\t\t\t\t`repeat_h` = 1 \n\t\t\t\t\tAND\n\t\t\t\t\t`repeat_dow` = DAYOFWEEK('{$start_date_str}') \n\t\t\t\t\tAND\n\t\t\t\t\t`repeat_wnum` + {$week_of_first_day} - 1 = WEEK('{$start_date_str}', 3) \n\t\t\t\t\tAND\n\t\t\t\t\tMOD( ABS(PERIOD_DIFF(DATE_FORMAT(`start`, '%Y%m'), DATE_FORMAT('{$start_date_str}', '%Y%m'))), `repeat_mjump`) = 0\t\t\t\t\t\n\t\t\t\t)\t\t\t\t\n\t\t\t)\n\t\t\t{$invited}\n\t\t)";
//$result_events = self::getContentObjects(active_context(), ObjectTypes::findById(self::instance()->getObjectTypeId()), '`start`', 'ASC', $conditions, null, false, false, $start, $limit);
$result_events = self::instance()->listing(array("order" => 'start', "order_dir" => 'ASC', "extra_conditions" => $conditions, "start" => $start, "limit" => $limit))->objects;
// Find invitations for events and logged user
ProjectEvents::addInvitations($result_events);
return $result_events;
}
示例10: pick_date_widget
/**
* Return pick date widget
*
* @access public
* @param string $name Name prefix
* @param DateTimeValue $value Can be DateTimeValue object, integer or string
* @param integer $year_from Start counting from this year. If NULL this value will be set
* to current year - 10
* @param integer $year_to Count to this year. If NULL this value will be set to current
* year + 10
* @return null
*/
function pick_date_widget($name, $value = null, $year_from = null, $year_to = null)
{
if (!$value instanceof DateTimeValue) {
$value = new DateTimeValue($value);
}
$month_options = array();
for ($i = 1; $i <= 12; $i++) {
$option_attributes = $i == $value->getMonth() ? array('selected' => 'selected') : null;
$month_options[] = option_tag(lang("month {$i}"), $i, $option_attributes);
}
// for
$day_options = array();
for ($i = 1; $i <= 31; $i++) {
$option_attributes = $i == $value->getDay() ? array('selected' => 'selected') : null;
$day_options[] = option_tag($i, $i, $option_attributes);
}
// for
$year_from = (int) $year_from < 1 ? $value->getYear() - 10 : (int) $year_from;
$year_to = (int) $year_to < 1 || (int) $year_to < $year_from ? $value->getYear() + 10 : (int) $year_to;
$year_options = array();
for ($i = $year_from; $i <= $year_to; $i++) {
$option_attributes = $i == $value->getYear() ? array('selected' => 'selected') : null;
$year_options[] = option_tag($i, $i, $option_attributes);
}
// if
return select_box($name . '_month', $month_options) . select_box($name . '_day', $day_options) . select_box($name . '_year', $year_options);
}
示例11: isToday
/**
* This function will return true if this day is today
* Date must be in GMT0
* @param void
* @return boolean
*/
function isToday()
{
$today = DateTimeValueLib::now();
if (logged_user() instanceof Contact) {
$date = new DateTimeValue($this->getTimestamp() + logged_user()->getTimezone() * 3600);
$today = new DateTimeValue($today->getTimestamp() + logged_user()->getTimezone() * 3600);
} else {
$date = $this;
}
return $date->getDay() == $today->getDay() && $date->getMonth() == $today->getMonth() && $date->getYear() == $today->getYear();
}
示例12: isToday
/**
* This function will return true if this day is today
*
* @param integer $offset
* @return boolean
*/
function isToday($offset = null)
{
$today = new DateTimeValue(time() + $offset);
$today->beginningOfDay();
return $this->getDay() == $today->getDay() && $this->getMonth() == $today->getMonth() && $this->getYear() == $today->getYear();
}
示例13: getLogs
/**
* Get log data
*
* @param integer $revision_to
* @param mixed $revision_from
* @return array
*/
function getLogs($revision_to, $revision_from = 'HEAD', $logs_per_query = 100)
{
// get multiple logs or a single one
if (!is_null($revision_from)) {
$r = $revision_from . ':' . $revision_to;
} else {
$r = $revision_to;
$this->triggerred_by_handler = true;
}
// if
$string = 'log -r ' . $r . ' --xml --verbose ' . $this->active_repository->getUrl();
$this->execute($string);
$log_data = xml2array(implode("\n", $this->output), 1, array('path', 'logentry'));
$insert_data = array();
$i = 1;
// this is because we get commits from SVN sorted from newest to oldest
$logs = is_array($log_data['log']['logentry']) ? array_reverse($log_data['log']['logentry']) : array();
// loop through array of log entries
foreach ($logs as $key => $log_entry) {
// prevent duplicate entries in case when there are two separate update processes
// (like, both scheduled task and aC user triggered the update
if (Commits::count("parent_id = '" . $this->active_repository->getId() . "' AND integer_field_1 = '" . $log_entry['attr']['revision'] . "'") > 0) {
continue;
}
// if
$paths = array();
$k = 0;
foreach ($log_entry['paths']['path'] as $path) {
$paths[$k]['path'] = mysql_real_escape_string($path['value']);
// paths can contain file names with characters that can break the query
$paths[$k]['action'] = $path['attr']['action'];
$k++;
}
// foreach
$date = new DateTimeValue($log_entry['date']['value']);
$log_date = $date->getYear() . "-" . $date->getMonth() . '-' . $date->getDay() . ' ' . $date->getHour() . ':' . $date->getMinute() . ':' . $date->getSecond();
$commit_message = Commit::analyze_message($log_entry['msg']['value'], $log_entry['author']['value'], $log_entry['attr']['revision'], $this->active_repository, $this->active_project);
$insert_data[$i][$key] = "('Commit','Source','" . $this->active_project->getId() . "','" . $this->active_repository->getId() . "','Repository','" . mysql_real_escape_string($commit_message) . "','" . $log_entry['attr']['revision'] . "','" . serialize($paths) . "','" . mysql_real_escape_string($log_entry['author']['value']) . "','{$log_date}', '" . STATE_VISIBLE . "', '" . $this->active_repository->getVisibility() . "')";
$i = count($insert_data[$i]) < $logs_per_query ? $i : $i + 1;
}
// foreach
return array('data' => $insert_data, 'total' => count($logs));
}