This now adds the ability to view an entire groups calendar events.

This commit is contained in:
skeeter 2001-10-23 10:58:53 +00:00
parent b1007c337b
commit b1d090de44
9 changed files with 173 additions and 29 deletions

View File

@ -98,6 +98,8 @@
var $printer_friendly = False;
var $cached_holidays;
var $g_owner = 0;
var $filter;
var $cat_id;
@ -107,6 +109,8 @@
var $deleted;
var $added;
var $is_group = False;
var $soap = False;
var $use_session = False;
@ -131,10 +135,15 @@
echo "Owner : ".$this->owner."<br>\n";
}
$owner = (isset($GLOBALS['HTTP_GET_VARS']['owner'])?$GLOBALS['HTTP_GET_VARS']['owner']:'');
$owner = (isset($GLOBALS['owner'])?$GLOBALS['owner']:'');
$owner = (isset($GLOBALS['HTTP_GET_VARS']['owner'])?$GLOBALS['HTTP_GET_VARS']['owner']:$owner);
$owner = ($owner=='' && isset($GLOBALS['HTTP_POST_VARS']['owner'])?$GLOBALS['HTTP_POST_VARS']['owner']:$owner);
if(isset($owner) && $owner!='')
if(isset($owner) && $owner!='' && substr($owner,0,2) == 'g_')
{
$this->set_owner_to_group(substr($owner,2));
}
elseif(isset($owner) && $owner!='')
{
$this->owner = intval($owner);
}
@ -142,6 +151,10 @@
{
$this->owner = intval($GLOBALS['phpgw_info']['user']['account_id']);
}
elseif(isset($this->owner) && $GLOBALS['phpgw']->accounts->get_type($this->owner) == 'g')
{
$this->set_owner_to_group($this->owner);
}
$this->prefs['common'] = $GLOBALS['phpgw_info']['user']['preferences']['common'];
$this->prefs['calendar'] = $GLOBALS['phpgw_info']['user']['preferences']['calendar'];
@ -170,7 +183,8 @@
$this->filter = ' '.$this->prefs['calendar']['defaultfilter'].' ';
}
$date = (isset($GLOBALS['HTTP_GET_VARS']['date'])?$GLOBALS['HTTP_GET_VARS']['date']:'');
$date = (isset($GLOBALS['date'])?$GLOBALS['date']:'');
$date = (isset($GLOBALS['HTTP_GET_VARS']['date'])?$GLOBALS['HTTP_GET_VARS']['date']:$date);
$date = ($date=='' && isset($GLOBALS['HTTP_POST_VARS']['date'])?$GLOBALS['HTTP_POST_VARS']['date']:$date);
$year = (isset($GLOBALS['HTTP_GET_VARS']['year'])?$GLOBALS['HTTP_GET_VARS']['year']:'');
@ -220,7 +234,8 @@
Array(
'owner' => $this->owner,
'filter' => $this->filter,
'category' => $this->cat_id
'category' => $this->cat_id,
'g_owner' => $this->g_owner
)
);
$this->datetime = $this->so->datetime;
@ -301,6 +316,19 @@
}
}
function set_owner_to_group($owner)
{
$this->owner = intval($owner);
$this->is_group = True;
settype($this->g_owner,'array');
$this->g_owner = Array();
$group_owners = $GLOBALS['phpgw']->accounts->member($owner);
while($group_owners && list($index,$group_info) = each($group_owners))
{
$this->g_owner[] = $group_info['account_id'];
}
}
function save_sessiondata($data)
{
if ($this->use_session)
@ -520,7 +548,7 @@
/* This pulls ALL users of a group and makes them as participants to the event */
/* I would like to turn this back into a group thing. */
$acct = CreateObject('phpgwapi.accounts',intval($parts[$i]));
$members = $acct->members(intval($parts[$i]));
$members = $acct->member(intval($parts[$i]));
unset($acct);
if($members == False)
{
@ -873,7 +901,7 @@
{
$owner = $this->owner;
}
if ($owner == $GLOBALS['phpgw_info']['user']['account_id'] || ($event['public']==1) || ($this->check_perms(PHPGW_ACL_PRIVATE,$owner) && $event['public']==0))
if ($owner == $GLOBALS['phpgw_info']['user']['account_id'] || ($event['public']==1) || ($this->check_perms(PHPGW_ACL_PRIVATE,$owner) && $event['public']==0) || $event['owner'] == $GLOBALS['phpgw_info']['user']['account_id'])
{
return False;
}
@ -1190,6 +1218,13 @@
$eyear = (isset($params['eyear'])?$params['eyear']:0);
$emonth = (isset($params['emonth'])?$params['emonth']:0);
$eday = (isset($params['eday'])?$params['eday']:0);
$owner_id = (isset($params['owner'])?$params['owner']:0);
if($owner_id==0 && $this->is_group)
{
unset($owner_id);
$owner_id = $this->g_owner;
echo '<!-- owner_id in ('.implode($owner_id,',').') -->'."\n";
}
if(!$eyear && !$emonth && !$eday)
{
@ -1226,8 +1261,16 @@
echo "End Date : ".sprintf("%04d%02d%02d",$eyear,$emonth,$eday)."<br>\n";
}
$cached_event_ids = $this->so->list_events($syear,$smonth,$sday,$eyear,$emonth,$eday);
$cached_event_ids_repeating = $this->so->list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday);
if($owner_id)
{
$cached_event_ids = $this->so->list_events($syear,$smonth,$sday,$eyear,$emonth,$eday,$owner_id);
$cached_event_ids_repeating = $this->so->list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday,$owner_id);
}
else
{
$cached_event_ids = $this->so->list_events($syear,$smonth,$sday,$eyear,$emonth,$eday);
$cached_event_ids_repeating = $this->so->list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday);
}
$c_cached_ids = count($cached_event_ids);
$c_cached_ids_repeating = count($cached_event_ids_repeating);

View File

@ -20,6 +20,8 @@
var $cal;
var $db;
var $owner;
var $g_owner;
var $is_group = False;
var $datetime;
var $filter;
var $cat_id;
@ -32,6 +34,11 @@
$this->owner = (!isset($param['owner']) || $param['owner'] == 0?$GLOBALS['phpgw_info']['user']['account_id']:$param['owner']);
$this->filter = (isset($param['filter']) && $param['filter'] != ''?$param['filter']:$this->filter);
$this->cat_id = (isset($param['category']) && $param['category'] != ''?$param['category']:$this->cat_id);
if(isset($param['g_owner']) && is_array($param['g_owner']))
{
$this->is_group = True;
$this->g_owner = $param['g_owner'];
}
if($this->debug)
{
echo 'SO Filter : '.$this->filter."<br>\n";
@ -51,15 +58,22 @@
return $this->cal->fetch_event($id);
}
function list_events($startYear,$startMonth,$startDay,$endYear=0,$endMonth=0,$endDay=0)
function list_events($startYear,$startMonth,$startDay,$endYear=0,$endMonth=0,$endDay=0,$owner_id=0)
{
$extra = '';
$extra .= (strpos($this->filter,'private')?'AND phpgw_cal.is_public=0 ':'');
$extra .= ($this->cat_id?"AND phpgw_cal.category like '%".$this->cat_id."%' ":'');
return $this->cal->list_events($startYear,$startMonth,$startDay,$endYear,$endMonth,$endDay,$extra,$this->datetime->tz_offset);
if($owner_id)
{
return $this->cal->list_events($startYear,$startMonth,$startDay,$endYear,$endMonth,$endDay,$extra,$this->datetime->tz_offset,$owner_id);
}
else
{
return $this->cal->list_events($startYear,$startMonth,$startDay,$endYear,$endMonth,$endDay,$extra,$this->datetime->tz_offset);
}
}
function list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday)
function list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday,$owner_id=0)
{
if($GLOBALS['phpgw_info']['server']['calendar_type'] != 'sql')
{
@ -70,16 +84,21 @@
$endtime = mktime(23,59,59,$emonth,$eday,$eyear) - $this->datetime->tz_offset;
// $starttime = mktime(0,0,0,$smonth,$sday,$syear);
// $endtime = mktime(23,59,59,$emonth,$eday,$eyear);
$sql = "AND (phpgw_cal.cal_type='M') "
. 'AND (phpgw_cal_user.cal_login='.$this->owner.' '
// . 'AND (phpgw_cal.datetime <= '.$starttime.') '
. 'AND (((phpgw_cal_repeats.recur_enddate >= '.$starttime.') AND (phpgw_cal_repeats.recur_enddate <= '.$endtime.')) OR (phpgw_cal_repeats.recur_enddate=0))) ';
$sql .= (strpos($this->filter,'private')?'AND phpgw_cal.is_public=0 ':'');
$sql .= ($this->cat_id?"AND phpgw_cal.category like '%".$this->cat_id."%' ":'');
$sql .= 'ORDER BY phpgw_cal.datetime ASC, phpgw_cal.edatetime ASC, phpgw_cal.priority ASC';
$sql = "AND (phpgw_cal.cal_type='M') ";
if($owner_id)
{
$sql .= 'AND (phpgw_cal_user.cal_login in ('.implode(',',$owner_id).') ';
}
else
{
$sql .= 'AND (phpgw_cal_user.cal_login'.(!$this->is_group?' = '.$this->owner:' in ('.implode(',',$this->g_owner).')').' ';
}
// $sql .= 'AND (phpgw_cal.datetime <= '.$starttime.') '
$sql .= 'AND (((phpgw_cal_repeats.recur_enddate >= '.$starttime.') AND (phpgw_cal_repeats.recur_enddate <= '.$endtime.')) OR (phpgw_cal_repeats.recur_enddate=0))) '
. (strpos($this->filter,'private')?'AND phpgw_cal.is_public=0 ':'')
. ($this->cat_id?"AND phpgw_cal.category like '%".$this->cat_id."%' ":'')
. 'ORDER BY phpgw_cal.datetime ASC, phpgw_cal.edatetime ASC, phpgw_cal.priority ASC';
if($this->debug)
{

View File

@ -221,7 +221,7 @@ class socalendar_ extends socalendar__
return $this->event;
}
function list_events($startYear,$startMonth,$startDay,$endYear=0,$endMonth=0,$endDay=0,$extra='',$tz_offset=0)
function list_events($startYear,$startMonth,$startDay,$endYear=0,$endMonth=0,$endDay=0,$extra='',$tz_offset=0,$owner_id=0)
{
if(!isset($this->stream))
{
@ -229,7 +229,16 @@ class socalendar_ extends socalendar__
}
$datetime = mktime(0,0,0,$startMonth,$startDay,$startYear) - $tz_offset;
$user_where = ' AND (phpgw_cal_user.cal_login = '.$this->user.') ';
if($owner_id)
{
$user_where = ' AND (phpgw_cal_user.cal_login in ('.implode(',',$owner_id).')) ';
echo '<!-- owner_id in ('.implode(',',$owner_id).') -->'."\n";
}
else
{
$user_where = ' AND (phpgw_cal_user.cal_login = '.$this->user.') ';
}
$startDate = 'AND ( ( (phpgw_cal.datetime >= '.$datetime.') ';
$enddate = '';

View File

@ -822,7 +822,7 @@
),
'small_calendar' => $minical,
'date' => lang(date('F',$m)).' '.sprintf("%02d",$this->bo->day).', '.$this->bo->year,
'username' => $GLOBALS['phpgw']->common->grab_owner_name($owner),
'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner),
'print' => $print
);
@ -1208,7 +1208,7 @@
switch ($GLOBALS['phpgw']->accounts->get_type($participants[$i]))
{
case 'g':
$members = $acct->members(intval($participants[$i]));
$members = $acct->member(intval($participants[$i]));
while($members != False && list($index,$member) = each($members))
{
if($this->bo->check_perms(PHPGW_ACL_READ,$member['account_id']) && !isset($parts[$member['account_id']]))

View File

@ -163,6 +163,7 @@
{
$hidden_vars .= ' <input type="hidden" name="cal_id" value="'.$GLOBALS['HTTP_GET_VARS']['cal_id'].'">'."\n";
}
$hidden_vars .= ' <!-- BO Owner = '.$this->bo->owner.' -->'."\n";
$form_options = '';
reset($this->bo->grants);
while(list($grantor,$temp_rights) = each($this->bo->grants))
@ -170,14 +171,30 @@
$GLOBALS['phpgw']->accounts->get_account_name($grantor,$lid,$fname,$lname);
$drop_down[$lname.' '.$fname] = Array(
'grantor' => $grantor,
'value' => $grantor,
'name' => $GLOBALS['phpgw']->common->display_fullname($lid,$fname,$lname)
);
}
$memberships = $GLOBALS['phpgw']->accounts->membership($GLOBALS['phpgw_info']['user']['account_id']);
while(list($key,$group_info) = each($memberships))
{
$account_perms = $GLOBALS['phpgw']->acl->get_ids_for_location($group_info['account_id'],PHPGW_ACL_READ,'calendar');
while($account_perms && list($key,$group_id) = each($account_perms))
{
$GLOBALS['phpgw']->accounts->get_account_name($group_id,$lid,$fname,$lname);
$drop_down[$lname.' '.$fname] = Array(
'grantor' => $group_id,
'value' => 'g_'.$group_id,
'name' => $GLOBALS['phpgw']->common->display_fullname($lid,$fname,$lname)
);
}
}
@reset($drop_down);
@ksort($drop_down);
while(list($key,$grant) = each($drop_down))
{
$form_options .= ' <option value="'.$grant['grantor'].'"'.($grant['grantor']==$this->bo->owner?' selected':'').'>'.$grant['name'].'</option>'."\n";
$form_options .= ' <option value="'.$grant['value'].'"'.($grant['grantor']==$this->bo->owner?' selected':'').'>'.$grant['name'].'</option>'."\n";
}
reset($this->bo->grants);

View File

@ -163,6 +163,7 @@
{
$hidden_vars .= ' <input type="hidden" name="cal_id" value="'.$GLOBALS['HTTP_GET_VARS']['cal_id'].'">'."\n";
}
$hidden_vars .= ' <!-- BO Owner = '.$this->bo->owner.' -->'."\n";
$form_options = '';
reset($this->bo->grants);
while(list($grantor,$temp_rights) = each($this->bo->grants))
@ -170,14 +171,30 @@
$GLOBALS['phpgw']->accounts->get_account_name($grantor,$lid,$fname,$lname);
$drop_down[$lname.' '.$fname] = Array(
'grantor' => $grantor,
'value' => $grantor,
'name' => $GLOBALS['phpgw']->common->display_fullname($lid,$fname,$lname)
);
}
$memberships = $GLOBALS['phpgw']->accounts->membership($GLOBALS['phpgw_info']['user']['account_id']);
while(list($key,$group_info) = each($memberships))
{
$account_perms = $GLOBALS['phpgw']->acl->get_ids_for_location($group_info['account_id'],PHPGW_ACL_READ,'calendar');
while($account_perms && list($key,$group_id) = each($account_perms))
{
$GLOBALS['phpgw']->accounts->get_account_name($group_id,$lid,$fname,$lname);
$drop_down[$lname.' '.$fname] = Array(
'grantor' => $group_id,
'value' => 'g_'.$group_id,
'name' => $GLOBALS['phpgw']->common->display_fullname($lid,$fname,$lname)
);
}
}
@reset($drop_down);
@ksort($drop_down);
while(list($key,$grant) = each($drop_down))
{
$form_options .= ' <option value="'.$grant['grantor'].'"'.($grant['grantor']==$this->bo->owner?' selected':'').'>'.$grant['name'].'</option>'."\n";
$form_options .= ' <option value="'.$grant['value'].'"'.($grant['grantor']==$this->bo->owner?' selected':'').'>'.$grant['name'].'</option>'."\n";
}
reset($this->bo->grants);

View File

@ -163,6 +163,7 @@
{
$hidden_vars .= ' <input type="hidden" name="cal_id" value="'.$GLOBALS['HTTP_GET_VARS']['cal_id'].'">'."\n";
}
$hidden_vars .= ' <!-- BO Owner = '.$this->bo->owner.' -->'."\n";
$form_options = '';
reset($this->bo->grants);
while(list($grantor,$temp_rights) = each($this->bo->grants))
@ -170,14 +171,30 @@
$GLOBALS['phpgw']->accounts->get_account_name($grantor,$lid,$fname,$lname);
$drop_down[$lname.' '.$fname] = Array(
'grantor' => $grantor,
'value' => $grantor,
'name' => $GLOBALS['phpgw']->common->display_fullname($lid,$fname,$lname)
);
}
$memberships = $GLOBALS['phpgw']->accounts->membership($GLOBALS['phpgw_info']['user']['account_id']);
while(list($key,$group_info) = each($memberships))
{
$account_perms = $GLOBALS['phpgw']->acl->get_ids_for_location($group_info['account_id'],PHPGW_ACL_READ,'calendar');
while($account_perms && list($key,$group_id) = each($account_perms))
{
$GLOBALS['phpgw']->accounts->get_account_name($group_id,$lid,$fname,$lname);
$drop_down[$lname.' '.$fname] = Array(
'grantor' => $group_id,
'value' => 'g_'.$group_id,
'name' => $GLOBALS['phpgw']->common->display_fullname($lid,$fname,$lname)
);
}
}
@reset($drop_down);
@ksort($drop_down);
while(list($key,$grant) = each($drop_down))
{
$form_options .= ' <option value="'.$grant['grantor'].'"'.($grant['grantor']==$this->bo->owner?' selected':'').'>'.$grant['name'].'</option>'."\n";
$form_options .= ' <option value="'.$grant['value'].'"'.($grant['grantor']==$this->bo->owner?' selected':'').'>'.$grant['name'].'</option>'."\n";
}
reset($this->bo->grants);

View File

@ -163,6 +163,7 @@
{
$hidden_vars .= ' <input type="hidden" name="cal_id" value="'.$GLOBALS['HTTP_GET_VARS']['cal_id'].'">'."\n";
}
$hidden_vars .= ' <!-- BO Owner = '.$this->bo->owner.' -->'."\n";
$form_options = '';
reset($this->bo->grants);
while(list($grantor,$temp_rights) = each($this->bo->grants))
@ -170,14 +171,30 @@
$GLOBALS['phpgw']->accounts->get_account_name($grantor,$lid,$fname,$lname);
$drop_down[$lname.' '.$fname] = Array(
'grantor' => $grantor,
'value' => $grantor,
'name' => $GLOBALS['phpgw']->common->display_fullname($lid,$fname,$lname)
);
}
$memberships = $GLOBALS['phpgw']->accounts->membership($GLOBALS['phpgw_info']['user']['account_id']);
while(list($key,$group_info) = each($memberships))
{
$account_perms = $GLOBALS['phpgw']->acl->get_ids_for_location($group_info['account_id'],PHPGW_ACL_READ,'calendar');
while($account_perms && list($key,$group_id) = each($account_perms))
{
$GLOBALS['phpgw']->accounts->get_account_name($group_id,$lid,$fname,$lname);
$drop_down[$lname.' '.$fname] = Array(
'grantor' => $group_id,
'value' => 'g_'.$group_id,
'name' => $GLOBALS['phpgw']->common->display_fullname($lid,$fname,$lname)
);
}
}
@reset($drop_down);
@ksort($drop_down);
while(list($key,$grant) = each($drop_down))
{
$form_options .= ' <option value="'.$grant['grantor'].'"'.($grant['grantor']==$this->bo->owner?' selected':'').'>'.$grant['name'].'</option>'."\n";
$form_options .= ' <option value="'.$grant['value'].'"'.($grant['grantor']==$this->bo->owner?' selected':'').'>'.$grant['name'].'</option>'."\n";
}
reset($this->bo->grants);

View File

@ -640,6 +640,11 @@
{
// Don't allow to override private!
$rights &= (~ PHPGW_ACL_PRIVATE);
if(!isset($grants[$grantor]))
{
$grants[$grantor] = 0;
}
$grants[$grantor] |= $rights;
}
while(list($nul,$grantors) = each($accounts[$grantor]))
{