function icalendar_export() {
		$this->setTemplate('cal_export');
		$calendar_name = array_var($_POST, 'calendar_name');			
		if ($calendar_name != '') {
			$from = getDateValue(array_var($_POST, 'from_date'));
			$to = getDateValue(array_var($_POST, 'to_date'));
			
			$events = ProjectEvents::getRangeProjectEvents($from, $to);
			
			$buffer = CalFormatUtilities::generateICalInfo($events, $calendar_name);
			
			$filename = rand().'.tmp';
			$handle = fopen(ROOT.'/tmp/'.$filename, 'wb');
			fwrite($handle, $buffer);
			fclose($handle);
			
			$_SESSION['calendar_export_filename'] = $filename;
			$_SESSION['calendar_name'] = $calendar_name;
			flash_success(lang('success export calendar', count($events)));
			ajx_current("empty");
		} else {
			unset($_SESSION['calendar_export_filename']);
			unset($_SESSION['calendar_name']);
			return;
		}
	}
Exemple #2
0
} else {
    $birthdays = array();
}
$result = array();
if ($milestones) {
    $result = array_merge($result, $milestones);
}
if (isset($tasks)) {
    foreach ($tasks as $task) {
        $result = array_merge($result, replicateRepetitiveTaskForCalendar($task, $date_start, $date_end));
    }
}
if (is_array($birthdays) && count($birthdays) > 0) {
    $result = array_merge($result, $birthdays);
}
$all_events = ProjectEvents::getRangeProjectEvents($date_start, $date_end, $user_filter, $status_filter);
$all_event_ids = array();
foreach ($all_events as $aev) {
    $all_event_ids[] = $aev->getId();
}
$read_events = array();
if (count($all_event_ids) > 0) {
    $read_rows = DB::executeAll("SELECT rel_object_id FROM " . TABLE_PREFIX . "read_objects WHERE is_read=1 AND contact_id=" . logged_user()->getId() . " AND rel_object_id IN (" . implode(",", $all_event_ids) . ")");
    if (is_array($read_rows)) {
        foreach ($read_rows as $rr) {
            $read_events[$rr['rel_object_id']] = 1;
        }
    }
}
// generate repetitive event instances
$repeated_instances = array();
Exemple #3
0
    $output .= "<tr>";
    if (!user_config_option("start_monday")) {
        $output .= "    <th width='12.5%' align='center'>" . lang('sunday short') . '</th>' . "\n";
    }
    $output .= '
	<th width="15%">' . lang('monday short') . '</th>
	<th width="15%">' . lang('tuesday short') . '</th>
	<th width="15%">' . lang('wednesday short') . '</th>
	<th width="15%">' . lang('thursday short') . '</th>
	<th width="15%">' . lang('friday short') . '</th>
	<th width="12.5%">' . lang('saturday short') . '</th>';
    if (user_config_option("start_monday")) {
        $output .= '<th width="12.5%">' . lang('sunday short') . '</th>';
    }
    $output .= '</tr>';
    $result = ProjectEvents::getRangeProjectEvents($date_start, $date_end, $user_filter instanceof Contact ? $user_filter->getId() : -1, ' 0 1 3');
    foreach ($result as $ev) {
        $result = array_merge($result, $ev->getRepetitiveInstances($date_start, $date_end));
    }
    if (!$result) {
        $result = array();
    }
    if (!empty($milestones)) {
        $result = array_merge($result, $milestones);
    }
    if (!empty($tasks)) {
        $result = array_merge($result, $tasks);
    }
    if (!empty($birthdays)) {
        $result = array_merge($result, $birthdays);
    }