예제 #1
0
	function decode_ical_file($filename) {
		$parsed_data = parse_ical($filename);
		
		if (isset($parsed_data[0]['tzoffsetfrom'])){
			$tz_diff = ($parsed_data[0]['tzoffsetfrom'] / 100);
                }else
			$tz_diff = logged_user()->getTimezone();
		unset($parsed_data[0]);
                
		$events_data = CalFormatUtilities::build_events_data($parsed_data, $tz_diff);
		return $events_data;
	}
 function ical_export()
 {
     $this->setLayout('ical');
     require_once ROOT . '/environment/classes/event/CalFormatUtilities.php';
     if (!isset($_GET['t']) || !isset($_GET['cal'])) {
         header('HTTP/1.0 404 Not Found');
         die;
     }
     $token = $_GET['t'];
     $cal = $_GET['cal'];
     $inc_sub = isset($_GET['isw']) && $_GET['isw'] == 1;
     if (Users::tokenExists($token)) {
         $user = Users::getByToken($token);
         if ($cal == 0) {
             $project = null;
         } else {
             $project = Projects::findById($cal);
         }
         $events = ProjectEvents::getAllEventsByProject($project, false, $inc_sub, $user);
         $calendar_name = isset($_GET['n']) ? $_GET['n'] : $user->getDisplayName();
         tpl_assign('content', CalFormatUtilities::generateICalInfo($events, $calendar_name, $user));
     } else {
         header('HTTP/1.0 404 Not Found');
         die;
     }
 }
예제 #3
0
	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;
		}
	}
예제 #4
0
 function ical_export()
 {
     $this->setLayout('ical');
     require_once ROOT . '/environment/classes/event/CalFormatUtilities.php';
     if (!isset($_GET['t']) || !isset($_GET['cal'])) {
         header('HTTP/1.0 404 Not Found');
         die;
     }
     $token = $_GET['t'];
     $cal = $_GET['cal'];
     if (Contacts::tokenExists($token)) {
         $user = Contacts::findOne(array('conditions' => "token='{$token}'"));
         $conditions = " AND EXISTS (SELECT i.contact_id FROM " . TABLE_PREFIX . "event_invitations i WHERE i.event_id=e.object_id AND  i.contact_id=" . $user->getId() . ")";
         if (array_var($_GET, 'cal') != "") {
             $mem_cond = "e.object_id IN (SELECT object_id FROM " . TABLE_PREFIX . "object_members WHERE member_id IN (" . array_var($_GET, 'cal') . "))";
         } else {
             $mem_cond = "true";
         }
         $user_pgs = $user->getPermissionGroupIds();
         $perm_cond = " AND EXISTS (SELECT st.object_id FROM " . TABLE_PREFIX . "sharing_table st WHERE st.object_id=e.object_id AND st.group_id IN (" . implode(',', $user_pgs) . "))";
         $events = ProjectEvents::findAll(array('conditions' => "{$mem_cond} {$perm_cond} {$conditions}"));
         $calendar_name = isset($_GET['n']) ? $_GET['n'] : $user->getObjectName();
         $calendar_name = str_replace(' ', '_', $calendar_name);
         $content = CalFormatUtilities::generateICalInfo($events, $calendar_name, $user);
         tpl_assign('content', $content);
     } else {
         header('HTTP/1.0 404 Not Found');
         die;
     }
 }