$smarty->assign('day', $daystart);

$firstDay = false;

for ($i = 0; $i <= $numberofweeks; $i++) {
	$weeks[] = $weekNumbers[] = $curtikidate->getWeekOfYear();
	require_once('lib/smarty_tiki/modifier.userlink.php');

	$registeredIndexes = array();
	foreach ($weekdays as $w) {
		$leday = array();
		if ($calendarViewMode['casedefault'] == 'day') {
			$dday = $daystart;
		} else {
			$dday = $curtikidate->getTime();
			$curtikidate->addDays(1);
		}

		// skip events that are not to be displayed
		if ( !in_array($w, $viewdays) ) {
			continue;
		}

		$cell[$i][$w]['day'] = $dday;

		if ($calendarViewMode['casedefault'] == 'day' or ($dday>=$daystart && $dday<=$dayend)) {
			if (!$firstDay) {
				$firstDay = true;
				$smarty->assign('currMonth', $dday);
				$cell[$i][$w]['firstDay'] = true;
Exemple #2
0
 function make_time($hour, $minute, $second, $month, $day, $year)
 {
     global $tikidate, $tikilib, $prefs;
     if (!is_object($tikidate)) {
         require_once 'lib/tikidate.php';
         $tikidate = new TikiDate();
         $display_tz = $tikilib->get_display_timezone();
         if ($display_tz == '') {
             $display_tz = 'UTC';
         }
     }
     $tikidate->setTZbyID('PST');
     /// DEBUG HACK!!
     $tikidate->setLocalTime($day, $month, $year, $hour, $minute, $second, 0);
     return $tikidate->getTime();
 }
Exemple #3
0
 /**
  * Get calendar and its events
  *
  * @param $calIds
  * @param $viewstart
  * @param $viewend
  * @param $group_by
  * @param $item_name
  * @param bool $listmode if set to true populate listevents key of the returned array
  * @return array
  */
 function getCalendar($calIds, &$viewstart, &$viewend, $group_by = '', $item_name = 'events', $listmode = false)
 {
     global $user, $prefs;
     // Global vars used by tiki-calendar_setup.php (this has to be changed)
     global $calendarViewMode, $request_day, $request_month;
     global $request_year, $dayend, $myurl;
     global $weekdays, $daysnames, $daysnames_abr;
     include 'tiki-calendar_setup.php';
     $smarty = TikiLib::lib('smarty');
     $tikilib = TikiLib::lib('tiki');
     //FIXME : maxrecords = 50
     $listtikievents = $this->list_items_by_day($calIds, $user, $viewstart, $viewend, 0, 50);
     $mloop = TikiLib::date_format('%m', $viewstart);
     $dloop = TikiLib::date_format('%d', $viewstart);
     $yloop = TikiLib::date_format('%Y', $viewstart);
     $curtikidate = new TikiDate();
     $display_tz = $tikilib->get_display_timezone();
     if ($display_tz == '') {
         $display_tz = 'UTC';
     }
     $curtikidate->setTZbyID($display_tz);
     $curtikidate->setLocalTime($dloop, $mloop, $yloop, 0, 0, 0, 0);
     $listevents = array();
     // note that number of weeks starts at ZERO (i.e., zero = 1 week to display).
     for ($i = 0; $i <= $numberofweeks; $i++) {
         $weeks[] = $curtikidate->getWeekOfYear();
         foreach ($weekdays as $w) {
             $leday = array();
             if ($group_by == 'day') {
                 $key = 0;
             }
             if ($calendarViewMode['casedefault'] == 'day') {
                 $dday = $daystart;
             } else {
                 $dday = $curtikidate->getTime();
                 $curtikidate->addDays(1);
             }
             $cell[$i][$w]['day'] = $dday;
             if ($calendarViewMode['casedefault'] == 'day' or $dday >= $daystart && $dday <= $dayend) {
                 $cell[$i][$w]['focus'] = true;
             } else {
                 $cell[$i][$w]['focus'] = false;
             }
             if (isset($listtikievents["{$dday}"])) {
                 $e = -1;
                 foreach ($listtikievents["{$dday}"] as $lte) {
                     $lte['desc_name'] = $lte['name'];
                     if ($group_by_item != 'n') {
                         if ($group_by != 'day') {
                             $key = $lte['id'] . '|' . $lte['type'];
                         }
                         if (!isset($leday[$key])) {
                             $leday[$key] = $lte;
                             if ($group_by == 'day') {
                                 $leday[$key]['description'] = array($lte['where'] => array($lte['group_description']));
                                 $leday[$key]['head'] = TikiLib::date_format($prefs['short_date_format'], $cell[$i][$w]['day']);
                             } else {
                                 $leday[$key]['description'] = ' - <b>' . $lte['when'] . '</b> : ' . tra($lte['action']) . ' ' . $lte['description'];
                                 $leday[$key]['head'] = $lte['name'] . ', <i>' . tra('in') . ' ' . $lte['where'] . '</i>';
                             }
                             $leday[$key]['desc_name'] = '';
                         } else {
                             $leday_item =& $leday[$key];
                             $leday_item['user'] .= ', ' . $lte['user'];
                             if (!isset($leday_item['action']) || !is_integer($leday_item['action'])) {
                                 $leday_item['action'] = 1;
                             }
                             $leday_item['action']++;
                             if ($group_by == 'day') {
                                 $leday_item['name'] .= '<br />' . $lte['name'];
                                 $leday_item['desc_name'] = $leday_item['action'] . ' ' . tra($item_name) . ': ';
                                 $leday_item['description'][$lte['where']][] = $lte['group_description'];
                             } else {
                                 $leday_item['name'] = $lte['name'] . ' (x<b>' . $leday_item['action'] . '</b>)';
                                 $leday_item['desc_name'] = $leday_item['action'] . ' ' . tra($item_name);
                                 if ($lte['show_description'] == 'y' && !empty($lte['description'])) {
                                     $leday_item['description'] .= ",\n<br /> - <b>" . $lte['when'] . '</b> : ' . tra($lte['action']) . ' ' . $lte['description'];
                                     $leday_item['show_description'] = 'y';
                                 }
                             }
                         }
                     } else {
                         $e++;
                         $key = "{$lte['time']}{$e}";
                         $leday[$key] = $lte;
                         $lte['desc_name'] .= tra($lte['action']);
                     }
                 }
                 foreach ($leday as $key => $lte) {
                     if ($group_by == 'day') {
                         $desc = '';
                         foreach ($lte['description'] as $desc_where => $desc_items) {
                             $desc_items = array_unique($desc_items);
                             foreach ($desc_items as $desc_item) {
                                 if ($desc != '') {
                                     $desc .= '<br />';
                                 }
                                 $desc .= '- ' . $desc_item;
                                 if (!empty($lte['show_location']) && $lte['show_location'] == 'y' && $desc_where != '') {
                                     $desc .= ' <i>[' . $desc_where . ']</i>';
                                 }
                             }
                         }
                         $lte['description'] = $desc;
                     }
                     $smarty->assign('calendar_type', $myurl == 'tiki-action_calendar.php' ? 'tiki_actions' : 'calendar');
                     $smarty->assign_by_ref('item_url', $lte["url"]);
                     $smarty->assign_by_ref('cellhead', $lte["head"]);
                     $smarty->assign_by_ref('cellprio', $lte["prio"]);
                     $smarty->assign_by_ref('cellcalname', $lte["calname"]);
                     $smarty->assign('celllocation', "");
                     $smarty->assign('cellcategory', "");
                     $smarty->assign_by_ref('cellname', $lte["desc_name"]);
                     $smarty->assign('cellid', "");
                     $smarty->assign_by_ref('celldescription', $lte["description"]);
                     $smarty->assign('show_description', $lte["show_description"]);
                     if (!isset($leday[$key]["over"])) {
                         $leday[$key]["over"] = '';
                     } else {
                         $leday[$key]["over"] .= "<br />\n";
                     }
                     $leday[$key]["over"] .= $smarty->fetch("tiki-calendar_box.tpl");
                 }
             }
             if (is_array($leday)) {
                 ksort($leday);
                 $cell[$i][$w]['items'] = array_values($leday);
             }
         }
     }
     if (isset($_SESSION['CalendarViewList']) && $_SESSION['CalendarViewList'] == 'list' || $listmode) {
         if (is_array($listtikievents)) {
             foreach ($listtikievents as $le) {
                 if (is_array($le)) {
                     foreach ($le as $e) {
                         $listevents[] = $e;
                     }
                 }
             }
         }
     }
     return array('cell' => $cell, 'listevents' => $listevents, 'weeks' => $weeks, 'weekdays' => $weekdays, 'daysnames' => $daysnames, 'daysnames_abr' => $daysnames_abr, 'trunc' => $trunc);
 }
    $startTime = $_REQUEST["tstart"];
}
$endDate = new TikiDate();
$endDate->setDate($startTime);
if ($calendarViewMode['casedefault'] == 'month') {
    $stopTime = $endDate->addMonths(1);
} elseif ($calendarViewMode['casedefault'] == 'quarter') {
    $stopTime = $endDate->addMonths(3);
} elseif ($calendarViewMode['casedefault'] == 'semester') {
    $stopTime = $endDate->addMonths(6);
} elseif ($calendarViewMode['casedefault'] == 'year') {
    $stopTime = $endDate->addMonths(12);
} else {
    $stopTime = $endDate->addMonths(1);
}
$stopTime = $endDate->getTime();
if (isset($_REQUEST['stop_date_Month'])) {
    $stopTime = TikiLib::make_time(0, 0, 0, $_REQUEST['stop_date_Month'], $_REQUEST['stop_date_Day'], $_REQUEST['stop_date_Year']);
} elseif (isset($_REQUEST["tstop"])) {
    $stopTime = $_REQUEST["tstop"];
}
$calendarIds = array();
if (isset($_REQUEST['calendarIds'])) {
    $calendarIds = $_REQUEST['calendarIds'];
    foreach ($calendarIds as $anId) {
        $smarty->assign('individual_' . $anId, $userlib->object_has_one_permission($anId, 'calendar'));
    }
} else {
    if (!isset($_REQUEST["calendarId"])) {
        $_REQUEST["calendarId"] = 0;
    } else {