本文整理汇总了PHP中DateTimeValue::getYear方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeValue::getYear方法的具体用法?PHP DateTimeValue::getYear怎么用?PHP DateTimeValue::getYear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeValue
的用法示例。
在下文中一共展示了DateTimeValue::getYear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Index
*
* @param voi
* @return null
*/
function index()
{
require_once CALENDAR_MODULE_PATH . '/models/generators/ProjectCalendarGenerator.class.php';
$today = new DateTimeValue(time() + get_user_gmt_offset());
if ($this->request->get('month') && $this->request->get('year')) {
$month = $this->request->get('month');
$year = $this->request->get('year');
} else {
$month = $today->getMonth();
$year = $today->getYear();
}
// if
$first_weekday = UserConfigOptions::getValue('time_first_week_day', $this->logged_user);
$generator = new ProjectCalendarGenerator($month, $year, $first_weekday);
$generator->setProject($this->active_project);
$generator->setData(Calendar::getProjectData($this->logged_user, $this->active_project, $month, $year));
$this->smarty->assign(array('month' => $month, 'year' => $year, 'calendar' => $generator, 'page_tab' => 'calendar', 'navigation_pattern' => Calendar::getProjectMonthUrl($this->active_project, '-YEAR-', '-MONTH-')));
}
示例2: index
/**
* Calendar
*
* @param void
* @return null
*/
function index()
{
require_once CALENDAR_MODULE_PATH . '/models/generators/DashboardCalendarGenerator.class.php';
if ($this->request->get('month') && $this->request->get('year')) {
$month = $this->request->get('month');
$year = $this->request->get('year');
} else {
$today = new DateTimeValue(time() + get_user_gmt_offset());
$month = $today->getMonth();
$year = $today->getYear();
}
// if
$first_weekday = UserConfigOptions::getValue('time_first_week_day', $this->logged_user);
$generator = new DashboardCalendarGenerator($month, $year, $first_weekday);
$generator->setData(Calendar::getActiveProjectsData($this->logged_user, $month, $year));
$this->smarty->assign(array('month' => $month, 'year' => $year, 'calendar' => $generator, 'navigation_pattern' => Calendar::getDashboardMonthUrl('-YEAR-', '-MONTH-')));
//BOF:mod 20110623
$tabs = new NamedList();
$tabs->add('dashboard', array('text' => 'Active Teams', 'url' => assemble_url('dashboard')));
$tabs->add('home_page', array('text' => 'Home Page', 'url' => assemble_url('goto_home_tab')));
$this->smarty->assign('page_tabs', $tabs);
//EOF:mod 20110623
}
示例3: 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');
示例4: 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;
}
示例5: 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;
示例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: getData
function getData($event_data){
// get the day
if (array_var($event_data, 'start_value') != '') {
$date_from_widget = array_var($event_data, 'start_value');
$dtv = getDateValue($date_from_widget);
$day = $dtv->getDay();
$month = $dtv->getMonth();
$year = $dtv->getYear();
} else {
$month = isset($event_data['month'])?$event_data['month']:date('n', DateTimeValueLib::now()->getTimestamp());
$day = isset($event_data['day'])?$event_data['day']:date('j', DateTimeValueLib::now()->getTimestamp());
$year = isset($event_data['year'])?$event_data['year']:date('Y', DateTimeValueLib::now()->getTimestamp());
}
if (array_var($event_data, 'start_time') != '') {
$this->parseTime(array_var($event_data, 'start_time'), $hour, $minute);
} else {
$hour = array_var($event_data, 'hour');
$minute = array_var($event_data, 'minute');
if(array_var($event_data, 'pm') == 1) $hour += 12;
}
if (array_var($event_data, 'type_id') == 2 && $hour == 24) $hour = 23;
// repeat defaults
$repeat_d = 0;
$repeat_m = 0;
$repeat_y = 0;
$repeat_h = 0;
$repeat_h_params = array('dow' => 0, 'wnum' => 0, 'mjump' => 0);
$rend = '';
// get the options
$forever = 0;
$jump = array_var($event_data,'occurance_jump');
if(array_var($event_data,'repeat_option') == 1) $forever = 1;
elseif(array_var($event_data,'repeat_option') == 2) $rnum = array_var($event_data,'repeat_num');
elseif(array_var($event_data,'repeat_option') == 3) $rend = getDateValue(array_var($event_data,'repeat_end'));
// verify the options above are valid
if(isset($rnum) && $rnum !="") {
if(!is_numeric($rnum) || $rnum < 1 || $rnum > 1000) {
throw new Exception(CAL_EVENT_COUNT_ERROR);
}
} else $rnum = 0;
if($jump != ""){
if(!is_numeric($jump) || $jump < 1 || $jump > 1000) {
throw new Exception(CAL_REPEAT_EVERY_ERROR);
}
} else $jump = 1;
// check for repeating options
// 1=repeat once, 2=repeat daily, 3=weekly, 4=monthy, 5=yearly, 6=holiday repeating
$oend = null;
switch(array_var($event_data,'occurance')){
case "1":
$forever = 0;
$repeat_d = 0;
$repeat_m = 0;
$repeat_y = 0;
$repeat_h = 0;
break;
case "2":
$repeat_d = $jump;
if(isset($forever) && $forever == 1) $oend = null;
else $oend = $rend;
break;
case "3":
$repeat_d = 7 * $jump;
if(isset($forever) && $forever == 1) $oend = null;
else $oend = $rend;
break;
case "4":
$repeat_m = $jump;
if(isset($forever) && $forever == 1) $oend = null;
else $oend = $rend;
break;
case "5":
$repeat_y = $jump;
if(isset($forever) && $forever == 1) $oend = null;
else $oend = $rend;
break;
case "6":
$repeat_h = 1;
$repeat_h_params = array(
'dow' => array_var($event_data, 'repeat_dow'),
'wnum' => array_var($event_data, 'repeat_wnum'),
'mjump' => array_var($event_data, 'repeat_mjump'),
);
break;
}
$repeat_number = $rnum;
// get duration
$durationhour = array_var($event_data,'durationhour');
$durationmin = array_var($event_data,'durationmin');
// get event type: 2=full day, 3=time/duratin not specified, 4=time not specified
$typeofevent = array_var($event_data,'type_id');
if(!is_numeric($typeofevent) OR ($typeofevent!=1 AND $typeofevent!=2 AND $typeofevent!=3)) $typeofevent = 1;
//.........这里部分代码省略.........
示例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: getRangeContactsByBirthday
function getRangeContactsByBirthday($from, $to, $tags = '', $project = null)
{
if (!$from instanceof DateTimeValue || !$to instanceof DateTimeValue || $from->getTimestamp() > $to->getTimestamp()) {
return array();
}
$from = new DateTimeValue($from->getTimestamp());
$from->beginningOfDay();
$to = new DateTimeValue($to->getTimestamp());
$to->endOfDay();
$year1 = $from->getYear();
$year2 = $to->getYear();
if ($year1 == $year2) {
$condition = 'DAYOFYEAR(`birthday`) >= DAYOFYEAR(' . DB::escape($from) . ')' . ' AND DAYOFYEAR(`birthday`) <= DAYOFYEAR(' . DB::escape($to) . ')';
} else {
if ($year2 - $year1 == 1) {
$condition = 'DAYOFYEAR(`birthday`) >= DAYOFYEAR(' . DB::escape($from) . ')' . ' OR DAYOFYEAR(`birthday`) <= DAYOFYEAR(' . DB::escape($to) . ')';
} else {
$condition = "`birthday` <> '0000-00-00 00:00:00'";
}
}
return $this->getAllowedContacts($condition);
}
示例11: 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);
}
示例12: 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();
}
示例13: 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();
}
示例14: getRangeContactsByBirthday
function getRangeContactsByBirthday($from, $to, $member_ids = null)
{
if (!$from instanceof DateTimeValue || !$to instanceof DateTimeValue || $from->getTimestamp() > $to->getTimestamp()) {
return array();
}
$from = new DateTimeValue($from->getTimestamp());
$from->beginningOfDay();
$to = new DateTimeValue($to->getTimestamp());
$to->endOfDay();
$year1 = $from->getYear();
$year2 = $to->getYear();
if ($year1 == $year2) {
$condition = 'DAYOFYEAR(`birthday`) >= DAYOFYEAR(' . DB::escape($from) . ')' . ' AND DAYOFYEAR(`birthday`) <= DAYOFYEAR(' . DB::escape($to) . ')';
} else {
if ($year2 - $year1 == 1) {
$condition = '(DAYOFYEAR(`birthday`) >= DAYOFYEAR(' . DB::escape($from) . ')' . ' OR DAYOFYEAR(`birthday`) <= DAYOFYEAR(' . DB::escape($to) . '))';
} else {
$condition = "`birthday` <> '0000-00-00 00:00:00'";
}
}
if (!is_null($member_ids) && count($member_ids) > 0) {
$condition .= " AND object_id IN (SELECT om.object_id FROM " . TABLE_PREFIX . "object_members om WHERE om.member_id IN (" . implode(',', $member_ids) . "))";
}
return $this->getAllowedContacts($condition);
}
示例15: 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));
}