diff --git a/calendar/inc/class.calendar.inc.php b/calendar/inc/class.calendar.inc.php index 31e06c74ae..dab5dcb873 100755 --- a/calendar/inc/class.calendar.inc.php +++ b/calendar/inc/class.calendar.inc.php @@ -14,11 +14,11 @@ /* $Id$ */ - $phpgw_info['server']['calendar_type'] = 'sql'; - include(PHPGW_INCLUDE_ROOT.'/calendar/inc/class.calendar_'.$phpgw_info['server']['calendar_type'].'.inc.php'); +$phpgw_info['server']['calendar_type'] = 'sql'; +include(PHPGW_INCLUDE_ROOT.'/calendar/inc/class.calendar_'.$phpgw_info['server']['calendar_type'].'.inc.php'); - class calendar extends calendar_ - { +class calendar extends calendar_ +{ function calendar($params=False) { global $phpgw_info; @@ -47,5 +47,165 @@ $this->today = $this->localdates(time()); } - } + + function timematrix($date,$starttime,$endtime,$participants) + { + global $phpgw, $phpgw_info; + + if(!isset($phpgw_info['user']['preferences']['calendar']['interval']) || + !$phpgw_info['user']['preferences']['calendar']['interval']) + { + $phpgw_info['user']['preferences']['calendar']['interval'] = 15; + } + $datetime = $this->gmtdate($date['raw']); + $increment = $phpgw_info['user']['preferences']['calendar']['interval']; + $interval = (int)(60 / $increment); + + $str = '
'.$phpgw->common->show_date($datetime['raw'],'l, F d, Y').'
'; + $str .= ''; + $str .= ''; + $str .= ''; + for($i=0;$i<24;$i++) + { + for($j=0;$j<$interval;$j++) + { + switch($j) + { + case 0: + if($interval == 4) + { + $k = ($i<=9?'0':substr($i,0,1)); + } + $str .= ''; + break; + case 1: + if($interval == 4) + { + $k = ($i<=9?substr($i,0,1):substr($i,1,2)); + } + $str .= ''; + break; + default: + $str .= ''; + break; + } + } + } + $str .= ''; + $str .= ''; + if(!$endtime) + { + $endtime = $starttime; + } + for($i=0;$iread_repeated_events($participants[$i]); + $str .= ''; + $str .= ''; + $events = $this->get_sorted_by_date($datetime['raw'],$participants[$i]); + if(!$this->sorted_re) + { + for($j=0;$j<24;$j++) + { + for($k=0;$k<$interval;$k++) + { + $str .= ''; + } + } + } + else + { + for($h=0;$h<24;$h++) + { + for($m=0;$m<$interval;$m++) + { + $index = (($h * 10000) + (($m * $increment) * 100)); + $time_slice[$index]['marker'] = ' '; + $time_slice[$index]['color'] = $phpgw_info['theme']['bg_color']; + $time_slice[$index]['description'] = ''; + } + } + for($k=0;$k<$this->sorted_re;$k++) + { + $event = $events[$k]; + $eventstart = $this->localdates($event->datetime); + $eventend = $this->localdates($event->edatetime); + $start = ($eventstart['hour'] * 10000) + ($eventstart['minute'] * 100); + $starttemp = $this->splittime("$start"); + $subminute = 0; + for($m=0;$m<$interval;$m++) + { + $minutes = $increment * $m; + if(intval($starttemp['minute']) > $minutes && intval($starttemp['minute']) < ($minutes + $increment)) + { + $subminute = ($starttemp['minute'] - $minutes) * 100; + } + } + $start -= $subminute; + $end = ($eventend['hour'] * 10000) + ($eventend['minute'] * 100); + $endtemp = $this->splittime("$end"); + $addminute = 0; + for($m=0;$m<$interval;$m++) + { + $minutes = ($increment * $m); + if($endtemp['minute'] < ($minutes + $increment) && $endtemp['minute'] > $minutes) + { + $addminute = ($minutes + $increment - $endtemp['minute']) * 100; + } + } + $end += $addminute; + $starttemp = $this->splittime("$start"); + $endtemp = $this->splittime("$end"); +// Do not display All-Day events in this free/busy time + if((($starttemp['hour'] == 0) && ($starttemp['minute'] == 0)) && (($endtemp['hour'] == 23) && ($endtemp['minute'] == 59))) + { + } + else + { + for($h=$starttemp['hour'];$h<=$endtemp['hour'];$h++) + { + $startminute = 0; + $endminute = $interval; + $hour = $h * 10000; + if($h == intval($starttemp['hour'])) + { + $startminute = ($starttemp['minute'] / $increment); + } + if($h == intval($endtemp['hour'])) + { + $endminute = ($endtemp['minute'] / $increment); + } + for($m=$startminute;$m<=$endminute;$m++) + { + $index = ($hour + (($m * $increment) * 100)); + $time_slice[$index]['marker'] = '-'; + $time_slice[$index]['color'] = $phpgw_info['theme']['bg01']; + $time_slice[$index]['description'] = $this->is_private($event,$participants[$i]); + } + } + } + } + for($h=0;$h<24;$h++) + { + $hour = $h * 10000; + for($m=0;$m<$interval;$m++) + { + $index = ($hour + (($m * $increment) * 100)); + $str .= ''; + } + } + } + $str .= ''; + $str .= ''; + } + $str .= '
Participant'; + $str .= '"; + $str .= $k.''; + $str .= '"; + $str .= $k.''; + $str .= '"; + $str .= ' 
'.$phpgw->common->grab_owner_name($participants[$i]).' ".$time_slice[$index]['marker'].'
'; + return $str; + } +} ?> diff --git a/calendar/inc/class.calendar_sql.inc.php b/calendar/inc/class.calendar_sql.inc.php index a558351fe1..29edfdfabd 100755 --- a/calendar/inc/class.calendar_sql.inc.php +++ b/calendar/inc/class.calendar_sql.inc.php @@ -430,166 +430,6 @@ class calendar_ return $str; } - function timematrix($date,$starttime,$endtime,$participants) - { - global $phpgw, $phpgw_info; - - if(!isset($phpgw_info['user']['preferences']['calendar']['interval']) || - !$phpgw_info['user']['preferences']['calendar']['interval']) - { - $phpgw_info['user']['preferences']['calendar']['interval'] = 15; - } - $datetime = $this->gmtdate($date['raw']); - $increment = $phpgw_info['user']['preferences']['calendar']['interval']; - $interval = (int)(60 / $increment); - - $str = '
'.$phpgw->common->show_date($datetime['raw'],'l, F d, Y').'
'; - $str .= ''; - $str .= ''; - $str .= ''; - for($i=0;$i<24;$i++) - { - for($j=0;$j<$interval;$j++) - { - switch($j) - { - case 0: - if($interval == 4) - { - $k = ($i<=9?'0':substr($i,0,1)); - } - $str .= ''; - break; - case 1: - if($interval == 4) - { - $k = ($i<=9?substr($i,0,1):substr($i,1,2)); - } - $str .= ''; - break; - default: - $str .= ''; - break; - } - } - } - $str .= ''; - $str .= ''; - if(!$endtime) - { - $endtime = $starttime; - } - for($i=0;$iread_repeated_events($participants[$i]); - $str .= ''; - $str .= ''; - $events = $this->get_sorted_by_date($datetime['raw'],$participants[$i]); - if(!$this->sorted_re) - { - for($j=0;$j<24;$j++) - { - for($k=0;$k<$interval;$k++) - { - $str .= ''; - } - } - } - else - { - for($h=0;$h<24;$h++) - { - for($m=0;$m<$interval;$m++) - { - $index = (($h * 10000) + (($m * $increment) * 100)); - $time_slice[$index]['marker'] = ' '; - $time_slice[$index]['color'] = $phpgw_info['theme']['bg_color']; - $time_slice[$index]['description'] = ''; - } - } - for($k=0;$k<$this->sorted_re;$k++) - { - $event = $events[$k]; - $eventstart = $this->localdates($event->datetime); - $eventend = $this->localdates($event->edatetime); - $start = ($eventstart['hour'] * 10000) + ($eventstart['minute'] * 100); - $starttemp = $this->splittime("$start"); - $subminute = 0; - for($m=0;$m<$interval;$m++) - { - $minutes = $increment * $m; - if(intval($starttemp['minute']) > $minutes && intval($starttemp['minute']) < ($minutes + $increment)) - { - $subminute = ($starttemp['minute'] - $minutes) * 100; - } - } - $start -= $subminute; - $end = ($eventend['hour'] * 10000) + ($eventend['minute'] * 100); - $endtemp = $this->splittime("$end"); - $addminute = 0; - for($m=0;$m<$interval;$m++) - { - $minutes = ($increment * $m); - if($endtemp['minute'] < ($minutes + $increment) && $endtemp['minute'] > $minutes) - { - $addminute = ($minutes + $increment - $endtemp['minute']) * 100; - } - } - $end += $addminute; - $starttemp = $this->splittime("$start"); - $endtemp = $this->splittime("$end"); -// Do not display All-Day events in this free/busy time - if((($starttemp['hour'] == 0) && ($starttemp['minute'] == 0)) && (($endtemp['hour'] == 23) && ($endtemp['minute'] == 59))) - { - } - else - { - for($h=$starttemp['hour'];$h<=$endtemp['hour'];$h++) - { - $startminute = 0; - $endminute = $interval; - $hour = $h * 10000; - if($h == intval($starttemp['hour'])) - { - $startminute = ($starttemp['minute'] / $increment); - } - if($h == intval($endtemp['hour'])) - { - $endminute = ($endtemp['minute'] / $increment); - } - for($m=$startminute;$m<=$endminute;$m++) - { - $index = ($hour + (($m * $increment) * 100)); - $time_slice[$index]['marker'] = '-'; - $time_slice[$index]['color'] = $phpgw_info['theme']['bg01']; - $time_slice[$index]['description'] = $this->is_private($event,$participants[$i]); - } - } - } - } - for($h=0;$h<24;$h++) - { - $hour = $h * 10000; - for($m=0;$m<$interval;$m++) - { - $index = ($hour + (($m * $increment) * 100)); - $str .= ''; - } - } - } - $str .= ''; - $str .= ''; - } - $str .= '
Participant'; - $str .= '"; - $str .= $k.''; - $str .= '"; - $str .= $k.''; - $str .= '"; - $str .= ' 
'.$phpgw->common->grab_owner_name($participants[$i]).' ".$time_slice[$index]['marker'].'
'; - return $str; - } - function read_repeated_events($owner=0) { global $phpgw, $phpgw_info; diff --git a/calendar/matrixselect.php b/calendar/matrixselect.php index 81376e99bd..2544509acd 100755 --- a/calendar/matrixselect.php +++ b/calendar/matrixselect.php @@ -12,127 +12,150 @@ * option) any later version. * \**************************************************************************/ - /* $Id$ */ + /* $Id$ */ - $phpgw_info["flags"] = array("currentapp" => "calendar", "enable_nextmatchs_class" => True, "parent_page" => "index.php"); + $phpgw_flags = Array( + 'currentapp' => 'calendar', + 'enable_nextmatchs_class' => True, + ); - include("../header.inc.php"); + $phpgw_info['flags'] = $phpgw_flags; - if(isset($friendly) && $friendly) { - if(!isset($phpgw_info["user"]["preferences"]["calendar"]["weekdaystarts"])) - $phpgw_info["user"]["preferences"]["calendar"]["weekdaystarts"] = "Sunday"; + include('../header.inc.php'); - if (isset($date) && strlen($date) > 0) { - $thisyear = substr($date, 0, 4); - $thismonth = substr($date, 4, 2); - $thisday = substr($date, 6, 2); - } else { - if (!isset($day) || !$day) - $thisday = $phpgw->calendar->today["day"]; - else - $thisday = $day; - if (!isset($month) || !$month) - $thismonth = $phpgw->calendar->today["month"]; - else - $thismonth = $month; - if (!isset($year) || !$year) - $thisyear = $phpgw->calendar->today["year"]; - else - $thisyear = $year; - } - } + $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('calendar')); - $phpgw->template->set_file(array("matrix_query_begin" => "matrix_query.tpl", - "list" => "list.tpl", - "matrix_query_end" => "matrix_query.tpl", - "form_button" => "form_button_script.tpl")); + $templates = Array( + 'matrix_query_begin' => 'matrix_query.tpl', + 'list' => 'list.tpl', + 'matrix_query_end' => 'matrix_query.tpl', + 'form_button' => 'form_button_script.tpl' + ); - $phpgw->template->set_block("matrix_query_begin","list","matrix_query_end","form_button"); + $p->set_file($templates); - $phpgw->template->set_var("matrix_action",lang("Daily Matrix View")); - $phpgw->template->set_var("action_url",$phpgw->link("viewmatrix.php")); + $var = Array( + 'matrix_action' => lang('Daily Matrix View'), + 'action_url' => $phpgw->link('viewmatrix.php') + ); - $phpgw->template->parse("out","matrix_query_begin"); + $p->set_var($var); + $p->parse('out','matrix_query_begin'); - $phpgw->template->set_var("field",lang("Date")); +// Date + $day_html = ''; - $day_html = ""; + $month_html = ''; - $month_html = ""; - - $year_html = ""; - - $phpgw->template->set_var("data",$phpgw->common->dateformatorder($year_html,$month_html,$day_html)); - $phpgw->template->parse("output","list",True); + $year_html = ''; + $var = Array( + 'field' => lang('Date'), + 'data' => $phpgw->common->dateformatorder($year_html,$month_html,$day_html) + ); + + $p->set_var($var); + $p->parse('output','list',True); + // View type - $phpgw->template->set_var("field",lang("View")); - $str = "\n"; - $phpgw->template->set_var("data",$str); - $phpgw->template->parse("output","list",True); + $str = ''."\n"; + + $var = Array( + 'field' => lang('View'), + 'data' => $str + ); + + $p->set_var($var); + $p->parse('output','list',True); // Participants - $phpgw->template->set_var("field",lang("Participants")); - $db2 = $phpgw->db; - $db2->query("select account_id,account_lastname,account_firstname " - . "from accounts where account_status !='L' and " - . "account_id != ".$phpgw_info["user"]["account_id"]." " - . "and account_permissions like '%:calendar:%' " - . "order by account_lastname,account_firstname"); + $accounts = $phpgw->acl->get_ids_for_location('run',1,'calendar'); + $users = Array(); + for($i=0;$icommon->grab_owner_name($user); + if($phpgw->accounts->get_type($user) == 'g') + { + $group_members = $phpgw->acl->get_ids_for_location($user,1,'phpgw_group'); + if($group_members != False) + { + for($j=0;$jcommon->grab_owner_name($group_members[$j]); + } + } + } + } + } + } - $num_rows = $db2->num_rows(); - if ($num_rows > 50) - $size = 15; - elseif ($num_rows > 5) - $size = 5; - else - $size = $num_rows; - $str = "'."\n"; + @asort($users); + @reset($users); + while ($user = each($users)) + { + if((($phpgw->accounts->exists($user[0]) == True) && ($grants[$user[0]] && PHPGW_ACL_READ)) || ($user[0] == $owner) || $phpgw->accounts->get_type($user[0]) == 'g') + { + $str .= ' '."\n"; + } + } + $str .= ' '; - while($db2->next_record()) { - $id = $db2->f("account_id"); - $str .= "\n"; - } - $str .= ""; - $str .= ""; - $phpgw->template->set_var("data",$str); - $phpgw->template->parse("output","list",True); + $var = Array( + 'field' => lang('Participants'), + 'data' => $str + ); -// Groups - $phpgw->template->set_var("field",lang("Groups")); - $str = ""; - $phpgw->template->set_var("data",$str); - $phpgw->template->parse("output","list",True); + $p->set_var($var); + $p->parse('output','list',True); - $phpgw->template->set_var("submit_button",lang("Submit")); + $var = Array( + 'submit_button' => lang('Submit'), + 'action_url_button' => '', + 'action_text_button' => lang('Cancel'), + 'action_confirm_button' => 'onClick="history.back(-1)"' + ); - $phpgw->template->set_var("action_url_button",""); - $phpgw->template->set_var("action_text_button",lang("Cancel")); - $phpgw->template->set_var("action_confirm_button","onClick=\"history.back(-1)\""); + $p->set_var($var); + $p->parse('cancel_button','form_button'); - $phpgw->template->parse("cancel_button","form_button"); + $p->pparse('out','matrix_query_end'); - $phpgw->template->pparse("out","matrix_query_end"); - - $phpgw->common->phpgw_footer(); + $phpgw->common->phpgw_footer(); ?> diff --git a/calendar/viewmatrix.php b/calendar/viewmatrix.php index ea0b3f0f92..938aca8fc3 100755 --- a/calendar/viewmatrix.php +++ b/calendar/viewmatrix.php @@ -12,76 +12,80 @@ * option) any later version. * \**************************************************************************/ - /* $Id$ */ + /* $Id$ */ - $matrix = $matrixtype; + $phpgw_flags = Array( + 'currentapp' => 'calendar', + 'enable_nextmatchs_class' => True, + ); - $phpgw_info["flags"] = array("currentapp" => "calendar", "enable_nextmatchs_class" => True, "parent_page" => "matrixselect.php"); + $phpgw_info['flags'] = $phpgw_flags; - include("../header.inc.php"); + include('../header.inc.php'); - if (isset($date) && strlen($date) > 0) { - $thisyear = substr($date, 0, 4); - $thismonth = substr($date, 4, 2); - $thisday = substr($date, 6, 2); - } else { - if (!isset($day) || !$day) - $thisday = $phpgw->calendar->today["day"]; - else - $thisday = $day; - if (!isset($month) || !$month) - $thismonth = $phpgw->calendar->today["month"]; - else - $thismonth = $month; - if (!isset($year) || !$year) - $thisyear = $phpgw->calendar->today["year"]; - else - $thisyear = $year; - $date = $thisyear; - $date .= ($thismonth<=9?"0":"").$thismonth; - $date .= ($thisday<=9?"0":"").$thisday; + $date = $thisyear; + $date .= ($thismonth<=9?"0":"").$thismonth; + $date .= ($thisday<=9?"0":"").$thisday; - } - -// $date = $thisyear.$thismonth.$thisday; - - if(isset($groups) && $groups) { - for($i=0;$idb->query("SELECT account_id FROM accounts WHERE account_groups LIKE '%,".$groups[$i].":%'"); - while($phpgw->db->next_record()) { - $participating = False; - for($j=0;$jdb->f("account_id")) { - $participating = True; - } + $parts = Array(); + for($i=0;$iaccounts->get_type($participants[$i])) + { + case 'g': + $acct = CreateObject('phpgwapi.accounts',$participants[$i]); + $members = $acct->members(intval($participants[$i])); + while($members != False && $member = each($members)) + { + if(($grants[$member[1]['account_id']] & PHPGW_ACL_READ) && !isset($parts[$member[1]['account_id']])) + { + $parts[$member[1]['account_id']] = 1; + } + } + unset($acct); + break; + case 'u': + if(($grants[$participants[$i]] & PHPGW_ACL_READ) && !isset($parts[$participants[$i]])) + { + $parts[$participants[$i]] = 1; + } + break; + } } - if(!$participating) $participants[] = $phpgw->db->f("account_id"); - } - } - } - reset($participants); + $participants = Array(); + reset($parts); + while($part = each($parts)) + { + $participants[] = $part[0]; + } - switch($matrixtype) { - case "free/busy" : - echo $phpgw->calendar->timematrix($phpgw->calendar->date_to_epoch($date),$phpgw->calendar->splittime("000000"),0,$participants); - break; - case "weekly" : - echo $phpgw->calendar->display_large_week($thisday,$thismonth,$thisyear,true,$participants); - break; - } - echo "
"; - echo "
link("viewmatrix.php")."\" method=\"post\" name=\"matrixform\" target=\"viewmatrix\">"; - echo ""; - echo ""; - for ($i=0;$i"; - if(isset($filter) && $filter) { - echo ""; - } - echo ""; - echo ""; - echo "
"; + reset($participants); - $phpgw->common->phpgw_footer(); + switch($matrixtype) + { + case 'free/busy': + echo $phpgw->calendar->timematrix($phpgw->calendar->date_to_epoch($date),$phpgw->calendar->splittime('000000'),0,$participants); + break; + case 'weekly': + echo $phpgw->calendar->display_large_week($thisday,$thismonth,$thisyear,true,$participants); + break; + } + echo '
'; + echo '
'; + echo ''; + echo ''; + for ($i=0;$i'; + } + if(isset($filter) && $filter) + { + echo ''; + } + echo ''; + echo ''; + echo '
'; + + $phpgw->common->phpgw_footer(); ?>