another try at beginning acl support

This commit is contained in:
skeeter 2001-02-11 19:11:35 +00:00
parent d5aa7d2fe1
commit ac5d17af78
3 changed files with 57 additions and 74 deletions

View File

@ -14,23 +14,23 @@
/* $Id$ */
$phpgw_info["flags"] = array("currentapp" => "calendar", "enable_nextmatchs_class" => True);
$phpgw_info['flags'] = array('currentapp' => 'calendar', 'enable_nextmatchs_class' => True);
if (isset($friendly) && $friendly){
$phpgw_info["flags"]["noheader"] = True;
$phpgw_info["flags"]["nonavbar"] = True;
$phpgw_info["flags"]["noappheader"] = True;
$phpgw_info["flags"]["noappfooter"] = True;
$phpgw_info["flags"]["nofooter"] = True;
$phpgw_info['flags']['noheader'] = True;
$phpgw_info['flags']['nonavbar'] = True;
$phpgw_info['flags']['noappheader'] = True;
$phpgw_info['flags']['noappfooter'] = True;
$phpgw_info['flags']['nofooter'] = True;
} else {
$friendly = 0;
}
include("../header.inc.php");
include('../header.inc.php');
if(isset($friendly) && $friendly) {
if(!isset($phpgw_info["user"]["preferences"]["calendar"]["weekdaystarts"]))
$phpgw_info["user"]["preferences"]["calendar"]["weekdaystarts"] = "Sunday";
if(!isset($phpgw_info['user']['preferences']['calendar']['weekdaystarts']))
$phpgw_info['user']['preferences']['calendar']['weekdaystarts'] = 'Sunday';
if (isset($date) && strlen($date) > 0) {
$thisyear = intval(substr($date, 0, 4));
@ -38,22 +38,36 @@
$thisday = intval(substr($date, 6, 2));
} else {
if (!isset($day) || !$day)
$thisday = $phpgw->calendar->today["day"];
$thisday = $phpgw->calendar->today['day'];
else
$thisday = $day;
if (!isset($month) || !$month)
$thismonth = $phpgw->calendar->today["month"];
$thismonth = $phpgw->calendar->today['month'];
else
$thismonth = $month;
if (!isset($year) || !$year)
$thisyear = $phpgw->calendar->today["year"];
$thisyear = $phpgw->calendar->today['year'];
else
$thisyear = $year;
}
}
if(!isset($owner)) { $owner = $phpgw_info["user"]["account_id"]; }
// unset($owner);
if(!isset($owner)) { $owner = 0; }
if(!isset($owner) || !$owner) {
$owner = $phpgw_info['user']['account_id'];
$rights = PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
} else {
$grants = $phpgw->acl->get_grants('calendar');
if($grants[$owner])
{
$rights = $grants[$owner];
if (!($rights & PHPGW_ACL_READ))
{
$owner = $phpgw_info['user']['account_id'];
}
}
}
$next = $phpgw->calendar->splitdate(mktime(2,0,0,$thismonth + 1,1,$thisyear));
@ -63,36 +77,36 @@
$p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('calendar'));
$p->set_file(array("index_t" => "index.tpl"));
$p->set_file(array('index_t' => 'index.tpl'));
$p->set_block("index_t","index");
$p->set_block('index_t','index');
if ($friendly) {
$p->set_var("printer_friendly","<body bgcolor=\"".$phpgw_info["theme"]["bg_color"]."\">");
$p->set_var('printer_friendly','<body bgcolor="'.$phpgw_info['theme']['bg_color'].'">');
} else {
$p->set_var("printer_friendly","");
$p->set_var('printer_friendly','');
}
$p->set_var("bg_text",$phpgw_info["theme"]["bg_text"]);
$p->set_var('bg_text',$phpgw_info['theme']['bg_text']);
$p->set_var("small_calendar_prev",$phpgw->calendar->mini_calendar(1,$prev["month"],$prev["year"],"day.php"));
$p->set_var('small_calendar_prev',$phpgw->calendar->mini_calendar(1,$prev['month'],$prev['year'],'day.php'));
$m = mktime(2,0,0,$thismonth,1,$thisyear);
$p->set_var("month_identifier",lang(strftime("%B",$m)) . " " . $thisyear);
$p->set_var("username",$phpgw->common->grab_owner_name($owner));
$p->set_var("small_calendar_next",$phpgw->calendar->mini_calendar(1,$next["month"],$next["year"],"day.php"));
$p->set_var('month_identifier',lang(strftime("%B",$m)) . ' ' . $thisyear);
$p->set_var('username',$phpgw->common->grab_owner_name($owner));
$p->set_var('small_calendar_next',$phpgw->calendar->mini_calendar(1,$next['month'],$next['year'],'day.php'));
flush();
$p->set_var("large_month",$phpgw->calendar->display_large_month($thismonth,$thisyear,True,$owner));
$p->set_var('large_month',$phpgw->calendar->display_large_month($thismonth,$thisyear,True,$owner));
if (!$friendly) {
$param = 'year='.$thisyear.'&month='.$thismonth.'&friendly=1&filter='.$filter;
$p->set_var("print","<a href=\"".$phpgw->link("",$param)."\" TARGET=\"cal_printer_friendly\" onMouseOver=\"window."
. "status = '" . lang("Generate printer-friendly version"). "'\">[". lang("Printer Friendly") . "]</a>");
$p->parse("out","index_t");
$p->pparse("out","index_t");
$p->set_var('print','<a href="'.$phpgw->link('',$param).'" TARGET="cal_printer_friendly" onMouseOver="window.'
. "status = '" . lang('Generate printer-friendly version'). "'\">[". lang('Printer Friendly') . ']</a>');
$p->parse('out','index_t');
$p->pparse('out','index_t');
} else {
$p->set_var("print","");
$p->parse("out","index_t");
$p->pparse("out","index_t");
$p->set_var('print','');
$p->parse('out','index_t');
$p->pparse('out','index_t');
}
$phpgw->common->phpgw_footer();
?>

View File

@ -55,49 +55,18 @@
if(!isset($owner) || !$owner) {
$owner = $phpgw_info['user']['account_id'];
$rights = PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
} else {
$grants = $phpgw->acl->get_location_list_for_id('calendar',PHPGW_ACL_READ,$owner);
$memberships = $phpgw->accounts->memberships($phpgw_info['user']['account_id']);
while($grants && $granted = each($grants)){
if($granted[1] == 'u_'.$phpgw_info['user']['account_id']){
$can_read = True;
break;
}else{
reset($memberships);
while($group = each($memberships)) {
if($granted[1] == 'g_'.$group[1]['account_id']){
$can_read = True;
break 2;
}
}
}
}
// if(!$can_read){
// $my_groups = $phpgw->accounts->memberships($phpgw_info['user']['account_id']);
// $their_groups = $phpgw->accounts->memberships($owner);
// for($j=0;$j<count($my_groups);$j++){
//echo 'My Group ('.$my_groups[$j]['account_name'].') '.$my_groups[$j]['account_id']."<br>\n";
// if($can_read){ break; }
// for($k=0;$k<count($their_groups);$k++){
//echo 'Their Group ('.$their_groups[$k]['account_name'].') '.$their_groups[$k]['account_id']."<br>\n";
// if($can_read){ break 2; }
// if($my_groups[$j] == $their_groups[$k]){
//echo 'Match Group ('.$my_groups[$j]['account_name'].') '.$my_groups[$j]['account_id']."<br>\n";
// $users = $phpgw->acl->get_ids_for_location('g_'.$my_groups[$j]['account_id'],PHPGW_ACL_READ,'calendar');
// for($l=0;$l<count($users);$l++){
// if($users[$l] == $owner){
// $can_read = True;
// break 3;
// }
// }
// }
// }
// }
// }
if(!$can_read) {
$grants = $phpgw->acl->get_grants('calendar');
if($grants[$owner])
{
$rights = $grants[$owner];
if (!($rights & PHPGW_ACL_READ))
{
$owner = $phpgw_info['user']['account_id'];
}
}
}
$next = $phpgw->calendar->splitdate(mktime(2,0,0,$thismonth,$thisday + 7,$thisyear));
$prev = $phpgw->calendar->splitdate(mktime(2,0,0,$thismonth,$thisday - 7,$thisyear));