acl is 100% integrated

This commit is contained in:
skeeter 2001-02-18 22:33:10 +00:00
parent 7f551f895e
commit 6db8b326d2
13 changed files with 926 additions and 679 deletions

View File

@ -11,7 +11,14 @@
/* $Id$ */ /* $Id$ */
$phpgw_info['flags'] = array('currentapp' => 'calendar', 'enable_nextmatchs_class' => True, 'noappheader' => True, 'noappfooter' => True); $phpgw_flags = Array(
'currentapp' => 'calendar',
'enable_nextmatchs_class' => True,
'noappheader' => True,
'noappfooter' => True
);
$phpgw_info['flags'] = $phpgw_flags;
include('../header.inc.php'); include('../header.inc.php');
$private_acl = True; $private_acl = True;
@ -26,20 +33,20 @@
global $phpgw_info, $p; global $phpgw_info, $p;
$p->set_var($acl,$label.$phpgw_info['flags']['currentapp'].'['.$id.']['.$right.']'); $p->set_var($acl,$label.$phpgw_info['flags']['currentapp'].'['.$id.']['.$right.']');
if ($rights & $right) { if ($rights & $right)
{
$p->set_var($acl.'_selected',' checked'); $p->set_var($acl.'_selected',' checked');
} else { }
else
{
$p->set_var($acl.'_selected',''); $p->set_var($acl.'_selected','');
} }
} }
function display_row($bg_color,$label,$id,$name) { function display_row($bg_color,$label,$id,$name)
global $p; {
global $phpgw; global $phpgw_info, $acl, $private_acl, $p;
global $phpgw_info;
global $acl;
global $private_acl;
$p->set_var('row_color',$bg_color); $p->set_var('row_color',$bg_color);
$p->set_var('user',$name); $p->set_var('user',$name);
@ -61,25 +68,35 @@
$p->parse('row','acl_row',True); $p->parse('row','acl_row',True);
} }
if(!isset($owner) || !$phpgw_info['user']['apps']['admin']) { if(!isset($owner) || !$phpgw_info['user']['apps']['admin'])
{
$owner = $phpgw_info['user']['account_id']; $owner = $phpgw_info['user']['account_id'];
} }
$groups = $phpgw->accounts->memberships($owner);
$acct = CreateObject('phpgwapi.accounts',$owner);
$groups = $acct->memberships($owner);
unset($acct);
$acl = CreateObject('phpgwapi.acl',intval($owner)); $acl = CreateObject('phpgwapi.acl',intval($owner));
$acl->read_repository(); $acl->read_repository();
if ($submit) { if ($submit)
{
$to_remove = unserialize(urldecode($processed)); $to_remove = unserialize(urldecode($processed));
for($i=0;$i<count($to_remove);$i++) {
for($i=0;$i<count($to_remove);$i++)
{
$acl->delete($phpgw_info['flags']['currentapp'],$to_remove[$i]); $acl->delete($phpgw_info['flags']['currentapp'],$to_remove[$i]);
} }
// Group records // Group records
$group_variable = 'g_'.$phpgw_info['flags']['currentapp']; $group_variable = 'g_'.$phpgw_info['flags']['currentapp'];
@reset($$group_variable); @reset($$group_variable);
while(list($group_id,$acllist) = each($$group_variable)) { while(list($group_id,$acllist) = each($$group_variable))
{
$totalacl = 0; $totalacl = 0;
while(list($right,$permission) = each($acllist)) { while(list($right,$permission) = each($acllist))
{
$totalacl += $right; $totalacl += $right;
} }
$acl->add($phpgw_info['flags']['currentapp'],$group_id,$totalacl); $acl->add($phpgw_info['flags']['currentapp'],$group_id,$totalacl);
@ -89,9 +106,11 @@
$user_variable = 'u_'.$phpgw_info['flags']['currentapp']; $user_variable = 'u_'.$phpgw_info['flags']['currentapp'];
@reset($$user_variable); @reset($$user_variable);
while(list($user_id,$acllist) = each($$user_variable)) { while(list($user_id,$acllist) = each($$user_variable))
{
$totalacl = 0; $totalacl = 0;
while(list($right,$permission) = each($acllist)) { while(list($right,$permission) = each($acllist))
{
$totalacl += $right; $totalacl += $right;
} }
$acl->add($phpgw_info['flags']['currentapp'],$user_id,$totalacl); $acl->add($phpgw_info['flags']['currentapp'],$user_id,$totalacl);
@ -103,32 +122,39 @@
$total = 0; $total = 0;
if(!isset($start)) { if(!isset($start))
{
$start = 0; $start = 0;
} }
if(!$start) { if(!$start)
{
$s_groups = 0; $s_groups = 0;
$s_users = 0; $s_users = 0;
} }
if(!isset($s_groups)) { if(!isset($s_groups))
{
$s_groups = 0; $s_groups = 0;
} }
if(!isset($s_users)) { if(!isset($s_users))
{
$s_users = 0; $s_users = 0;
} }
if(!isset($query)) { if(!isset($query))
{
$query = ""; $query = "";
} }
if(!isset($maxm)) { if(!isset($maxm))
{
$maxm = $phpgw_info['user']['preferences']['common']['maxmatchs']; $maxm = $phpgw_info['user']['preferences']['common']['maxmatchs'];
} }
if(!isset($totalentries)) { if(!isset($totalentries))
{
$totalentries = count($groups); $totalentries = count($groups);
$db = $phpgw->db; $db = $phpgw->db;
$db->query("SELECT count(*) FROM phpgw_accounts WHERE account_type='u'"); $db->query("SELECT count(*) FROM phpgw_accounts WHERE account_type='u'");
@ -139,24 +165,23 @@
$p = CreateObject('phpgwapi.Template',$phpgw_info['server']['app_tpl']); $p = CreateObject('phpgwapi.Template',$phpgw_info['server']['app_tpl']);
if($private_acl == True) if($private_acl == True)
{ {
$p->set_file(array('preferences' => 'preference_acl.tpl', $templates = Array (
'preferences' => 'preference_acl.tpl',
'row_colspan' => 'preference_colspan_private.tpl', 'row_colspan' => 'preference_colspan_private.tpl',
'acl_row' => 'preference_acl_row_private.tpl')); 'acl_row' => 'preference_acl_row_private.tpl'
);
} }
else else
{ {
$p->set_file(array('preferences' => 'preference_acl.tpl', $templates = Array (
'preferences' => 'preference_acl.tpl',
'row_colspan' => 'preference_colspan.tpl', 'row_colspan' => 'preference_colspan.tpl',
'acl_row' => 'preference_acl_row.tpl')); 'acl_row' => 'preference_acl_row.tpl'
);
} }
$p->set_file($templates);
// $p->set_var('errors','<p><center><b>This does nothing at this time!<br>Strictly as a template for use!</b></center>'); // $p->set_var('errors','<p><center><b>This does nothing at this time!<br>Strictly as a template for use!</b></center>');
$p->set_var('errors','');
$p->set_var('title','<p><b>'.lang($phpgw_info["flags"]["currentapp"]." preferences").' - '.lang("acl").':</b><hr><p>');
$p->set_var('action_url',$phpgw->link(''));
$p->set_var('bg_color',$phpgw_info['theme']['th_bg']);
$p->set_var('submit_lang',lang('submit'));
$common_hidden_vars = ' <input type="hidden" name="s_groups" value="'.$s_groups.'">'."\n" $common_hidden_vars = ' <input type="hidden" name="s_groups" value="'.$s_groups.'">'."\n"
. ' <input type="hidden" name="s_users" value="'.$s_users.'">'."\n" . ' <input type="hidden" name="s_users" value="'.$s_users.'">'."\n"
@ -165,74 +190,113 @@
. ' <input type="hidden" name="start" value="'.$start.'">'."\n" . ' <input type="hidden" name="start" value="'.$start.'">'."\n"
. ' <input type="hidden" name="query" value="'.$query.'">'."\n" . ' <input type="hidden" name="query" value="'.$query.'">'."\n"
. ' <input type="hidden" name="owner" value="'.$owner.'">'."\n"; . ' <input type="hidden" name="owner" value="'.$owner.'">'."\n";
$p->set_var('common_hidden_vars_form',$common_hidden_vars);
$var = Array(
'errors' => '',
'title' => '<p><b>'.lang($phpgw_info['flags']['currentapp'].' preferences').' - '.lang('acl').':</b><hr><p>',
'action_url' => $phpgw->link(''),
'bg_color' => $phpgw_info['theme']['th_bg'],
'submit_lang' => lang('submit'),
'common_hidden_vars_form' => $common_hidden_vars
);
$p->set_var($var);
if(isset($query_result) && $query_result) if(isset($query_result) && $query_result)
{
$common_hidden_vars .= '<input type="hidden" name="query_result" value="'.$query_result.'">'."\n"; $common_hidden_vars .= '<input type="hidden" name="query_result" value="'.$query_result.'">'."\n";
}
$p->set_var('common_hidden_vars',$common_hidden_vars); $p->set_var('common_hidden_vars',$common_hidden_vars);
$p->set_var(array('read_lang' => lang('Read'),
$var = Array(
'read_lang' => lang('Read'),
'add_lang' => lang('Add'), 'add_lang' => lang('Add'),
'edit_lang' => lang('Edit'), 'edit_lang' => lang('Edit'),
'delete_lang' => lang('Delete'))); 'delete_lang' => lang('Delete')
);
$p->set_var($var);
if($private_acl == True) if($private_acl == True)
{ {
$p->set_var('private_lang',lang('Private')); $p->set_var('private_lang',lang('Private'));
} }
if(intval($s_groups) <> count($groups)) { if(intval($s_groups) <> count($groups))
{
$p->set_var('string',lang('Groups')); $p->set_var('string',lang('Groups'));
$p->parse('row','row_colspan',True); $p->parse('row','row_colspan',True);
reset($groups); reset($groups);
for($k=0;$k<count($groups);$k++) { for($k=0;$k<count($groups);$k++)
{
$group = $groups[$k]; $group = $groups[$k];
$go = True; $go = True;
if($query) {
if(!strpos(' '.$group['account_id'].' ',$query)) { if($query)
{
if(!strpos(' '.$group['account_id'].' ',$query))
{
$go = False; $go = False;
} }
} }
if($go) {
if($go)
{
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
display_row($tr_color,'g_',$group['account_id'],$group['account_name']); display_row($tr_color,'g_',$group['account_id'],$group['account_name']);
$s_groups++; $s_groups++;
$processed[] = $group['account_id']; $processed[] = $group['account_id'];
$total++; $total++;
if($total == $maxm) break; if($total == $maxm)
{
break;
}
} }
} }
} }
if($total <> $maxm) { if($total <> $maxm)
if(!is_object($db)) { {
if(!is_object($db))
{
$db = $phpgw->db; $db = $phpgw->db;
} }
$db->query("select account_id, account_firstname, account_lastname, account_lid FROM phpgw_accounts WHERE account_type='u' ORDER BY account_lastname, account_firstname, account_lid ".$db->limit(intval($s_users),$maxm),__LINE__,__FILE__); $db->query("select account_id, account_firstname, account_lastname, account_lid FROM phpgw_accounts WHERE account_type='u' ORDER BY account_lastname, account_firstname, account_lid ".$db->limit(intval($s_users),$maxm),__LINE__,__FILE__);
$users = $db->num_rows(); $users = $db->num_rows();
if($total <> $maxm) { if($total <> $maxm)
if($users) { {
if($users)
{
$p->set_var('string',ucfirst(lang('Users'))); $p->set_var('string',ucfirst(lang('Users')));
$p->parse('row','row_colspan',True); $p->parse('row','row_colspan',True);
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
while($db->next_record()) { while($db->next_record())
{
$go = True; $go = True;
if($query) { if($query)
{
$name = ' '.$db->f('account_firstname').' '.$db->f('account_lastname').' '.$db->f('account_lid').' '; $name = ' '.$db->f('account_firstname').' '.$db->f('account_lastname').' '.$db->f('account_lid').' ';
if(!strpos($name,$query)) { if(!strpos($name,$query))
{
$go = False; $go = False;
} }
} }
if($go) {
if($go)
{
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$id = $db->f('account_id'); $id = $db->f('account_id');
display_row($tr_color,'u_',$id,$phpgw->common->grab_owner_name($id)); display_row($tr_color,'u_',$id,$phpgw->common->grab_owner_name($id));
$s_users++; $s_users++;
$processed[] = $id; $processed[] = $id;
$total++; $total++;
if($total == $maxm) break; if($total == $maxm)
{
break;
}
} }
} }
} }
@ -241,13 +305,16 @@
$extra_parms = '&s_users='.$s_users.'&s_groups='.$s_groups.'&maxm='.$maxm.'&totalentries='.$totalentries.'&total='.($start + $total).'&owner='.$owner; $extra_parms = '&s_users='.$s_users.'&s_groups='.$s_groups.'&maxm='.$maxm.'&totalentries='.$totalentries.'&total='.($start + $total).'&owner='.$owner;
$p->set_var('nml',$phpgw->nextmatchs->left('',$start,$totalentries,$extra_parms)); $var = Array(
$p->set_var('nmr',$phpgw->nextmatchs->right('',$start,$totalentries,$extra_parms)); 'nml' => $phpgw->nextmatchs->left('',$start,$totalentries,$extra_parms),
'nmr' => $phpgw->nextmatchs->right('',$start,$totalentries,$extra_parms),
'search_value' => (isset($query) && $query?$query:''),
'search' => lang('search'),
'processed' => urlencode(serialize($processed))
);
$p->set_var('search_value',(isset($query) && $query?$query:'')); $p->set_var($var);
$p->set_var('search',lang('search'));
$p->set_var('processed',urlencode(serialize($processed)));
$p->pparse('out','preferences'); $p->pparse('out','preferences');
$phpgw->common->phpgw_footer(); $phpgw->common->phpgw_footer();
?> ?>

View File

@ -14,77 +14,104 @@
/* $Id$ */ /* $Id$ */
$phpgw_info["flags"] = array("currentapp" => "calendar", "enable_nextmatchs_class" => True); $phpgw_flags = Array(
'currentapp' => 'calendar',
'noheader' => True,
'nonavbar' => True,
'enable_nextmatchs_class' => True
);
include("../header.inc.php"); $phpgw_info['flags'] = $phpgw_flags;
$sb = CreateObject("phpgwapi.sbox"); include('../header.inc.php');
$sb = CreateObject('phpgwapi.sbox');
$cal_info = CreateObject('calendar.calendar_item'); $cal_info = CreateObject('calendar.calendar_item');
function display_item($field,$data) { function display_item($field,$data)
global $phpgw; {
global $p;
$phpgw->template->set_var("field",$field); $p->set_var('field',$field);
$phpgw->template->set_var("data",$data); $p->set_var('data',$data);
$phpgw->template->parse("output","list",True); $p->parse('output','list',True);
} }
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { if ($phpgw_info['user']['preferences']['common']['timeformat'] == '12')
$hourformat = "h"; {
} else { $hourformat = 'h';
$hourformat = "H"; }
else
{
$hourformat = 'H';
} }
if(!isset($owner)) { if ($id > 0)
$owner = $phpgw_info['user']['account_id']; {
} else {
$owner = $phpgw_info['user']['account_id'];
}
if ($id > 0) {
$cal = $phpgw->calendar->getevent(intval($id)); $cal = $phpgw->calendar->getevent(intval($id));
$cal_info = $cal[0]; $cal_info = $cal[0];
$can_edit = false; $can_edit = False;
if(($cal_info->owner == $phpgw_info["user"]["account_id"]) || $phpgw_info["user"]["apps"]["admin"])
$can_edit = true;
if(!$cal_info->rpt_end_use) { if(($cal_info->owner == $owner) || ($phpgw->calendar->check_perms(PHPGW_ACL_EDIT) == True))
{
$can_edit = True;
}
if($can_edit == False)
{
header('Location: '.$phpgw->link('view.php','id='.$id.'&owner='.$owner));
}
if($cal_info->rpt_end_use == False)
{
$cal_info->rpt_end = $cal_info->datetime + 86400; $cal_info->rpt_end = $cal_info->datetime + 86400;
} }
} else if(isset($readsess)) { }
$cal_info = $phpgw->common->appsession('entry','calendar'); elseif(isset($readsess))
if(!$cal_info->owner) $cal_info->owner = $owner; {
$can_edit = true; $data = $phpgw->session->appsession('entry','calendar');
} else { $cal_info = unserialize($data);
if($cal_info->owner == 0)
{
$cal_info->owner = $owner;
}
$can_edit = True;
}
else
{
if($phpgw->calendar->check_perms(PHPGW_ACL_ADD) == False)
{
header('Location: '.$phpgw->link('view.php','id='.$id.'&owner='.$owner));
}
$cal_info->id = 0; $cal_info->id = 0;
$cal_info->owner = $owner; $cal_info->owner = $owner;
$can_edit = true; $can_edit = True;
if (!isset($day) || !$day)
$thisday = (int)$phpgw->calendar->today["day"];
else
$thisday = $day;
if (!isset($month) || !$month)
$thismonth = (int)$phpgw->calendar->today["month"];
else
$thismonth = $month;
if (!isset($year) || !$year)
$thisyear = (int)$phpgw->calendar->today["year"];
else
$thisyear = $year;
if (!isset($hour)) if (!isset($hour))
{
$thishour = 0; $thishour = 0;
}
else else
{
$thishour = (int)$hour; $thishour = (int)$hour;
if (!isset($minute)) }
$thisminute = 00;
else
$thisminute = (int)$minute;
$cal_info->datetime = mktime($thishour,$thisminute,0,$thismonth,$thisday,$thisyear) - ((60 * 60) * $phpgw_info["user"]["preferences"]["common"]["tz_offset"]); if (!isset($minute))
{
$thisminute = 00;
}
else
{
$thisminute = (int)$minute;
}
$datetime = $phpgw->calendar->makegmttime($thishour,$thisminute,0,$thismonth,$thisday,$thisyear);
$cal_info->datetime = $datetime['raw'];
$cal_info->edatetime = $cal_info->datetime; $cal_info->edatetime = $cal_info->datetime;
$cal_info->name = ""; $cal_info->name = "";
$cal_info->description = ""; $cal_info->description = "";
@ -93,203 +120,269 @@
$cal_info->rpt_end = $cal_info->datetime + 86400; $cal_info->rpt_end = $cal_info->datetime + 86400;
} }
$phpgw->template->set_file(array("edit_entry_begin" => "edit.tpl", $phpgw->common->phpgw_header();
"list" => "list.tpl", echo parse_navbar();
"hr" => "hr.tpl",
"edit_entry_end" => "edit.tpl",
"form_button" => "form_button_script.tpl"));
$phpgw->template->set_block("edit_entry_begin","list","hr","edit_entry_end","form_button"); $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('calendar'));
$templates = Array(
'edit_entry_begin'=> 'edit.tpl',
'list' => 'list.tpl',
'hr' => 'hr.tpl',
'edit_entry_end' => 'edit.tpl',
'form_button' => 'form_button_script.tpl'
);
$p->set_file($templates);
$phpgw->template->set_var("bg_color",$phpgw_info["theme"]["bg_text"]); // $p->set_block('edit_entry_begin','list','hr','edit_entry_end','form_button');
if($id)
$phpgw->template->set_var("calendar_action",lang("Calendar - Edit")); if($id > 0)
{
$action = lang('Calendar - Edit');
}
else else
$phpgw->template->set_var("calendar_action",lang("Calendar - Add")); {
$action = lang('Calendar - Add');
}
if($can_edit) { $common_hidden = '<input type="hidden" name="cal[id]" value="'.$cal_info->id.'">'."\n"
$phpgw->template->set_var("action_url",$phpgw->link("edit_entry_handler.php")); . '<input type="hidden" name="cal[owner]" value="'.$owner.'">'."\n"
. '<input type="hidden" name="owner" value="'.$owner.'">'."\n";
$common_hidden = "<input type=\"hidden\" name=\"cal[id]\" value=\"".$cal_info->id."\">\n"; $vars = Array(
'bg_color' => $phpgw_info['theme']['bg_text'],
'calendar_action' => $action,
'action_url' => $phpgw->link('edit_entry_handler.php'),
'common_hidden' => $common_hidden
);
$phpgw->template->set_var("common_hidden",$common_hidden); $p->set_var($vars);
$p->parse('out','edit_entry_begin');
$phpgw->template->parse("out","edit_entry_begin");
// Brief Description // Brief Description
display_item(lang("Brief Description"),"<input name=\"cal[name]\" size=\"25\" value=\"".$cal_info->name."\">"); display_item(lang('Brief Description'),'<input name="cal[name]" size="25" value="'.$cal_info->name.'">');
// Full Description // Full Description
display_item(lang("Full Description"),"<textarea name=\"cal[description]\" rows=\"5\" cols=\"40\" wrap=\"virtual\">".$cal_info->description."</textarea>"); display_item(lang('Full Description'),'<textarea name="cal[description]" rows="5" cols="40" wrap="virtual">'.$cal_info->description.'</textarea>');
// Date // Date
$day_html = $sb->getDays("cal[day]",intval($phpgw->common->show_date($cal_info->datetime,"d"))); $day_html = $sb->getDays('cal[day]',intval($phpgw->common->show_date($cal_info->datetime,'d')));
$month_html = $sb->getMonthText("cal[month]",intval($phpgw->common->show_date($cal_info->datetime,"n"))); $month_html = $sb->getMonthText('cal[month]',intval($phpgw->common->show_date($cal_info->datetime,'n')));
$year_html = $sb->getYears("cal[year]",intval($phpgw->common->show_date($cal_info->datetime,"Y")),intval($phpgw->common->show_date($cal_info->datetime,"Y"))); $year_html = $sb->getYears('cal[year]',intval($phpgw->common->show_date($cal_info->datetime,'Y')),intval($phpgw->common->show_date($cal_info->datetime,'Y')));
display_item(lang("Start Date"),$phpgw->common->dateformatorder($year_html,$month_html,$day_html)); display_item(lang('Start Date'),$phpgw->common->dateformatorder($year_html,$month_html,$day_html));
// Time // Time
$amsel = "checked"; $pmsel = ""; $amsel = ' checked'; $pmsel = '';
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { if ($phpgw_info['user']['preferences']['common']['timeformat'] == '12')
if ($cal_info->ampm == "pm") { {
$amsel = ""; $pmsel = "checked"; if ($cal_info->ampm == 'pm')
} else { {
$amsel = "checked"; $pmsel = ""; $amsel = ''; $pmsel = ' checked';
} }
} }
$str = "<input name=\"cal[hour]\" size=\"2\" VALUE=\"".$phpgw->common->show_date($cal_info->datetime,$hourformat)."\" maxlength=\"2\">:<input name=\"cal[minute]\" size=\"2\" value=\"".$phpgw->common->show_date($cal_info->datetime,"i")."\" maxlength=\"2\">"; $str = '<input name="cal[hour]" size="2" VALUE="'.$phpgw->common->show_date($cal_info->datetime,$hourformat).'" maxlength="2">:<input name="cal[minute]" size="2" value="'.$phpgw->common->show_date($cal_info->datetime,'i').'" maxlength="2">';
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { if ($phpgw_info['user']['preferences']['common']['timeformat'] == '12')
$str .= "<input type=\"radio\" name=\"cal[ampm]\" value=\"am\" $amsel>am"; {
$str .= "<input type=\"radio\" name=\"cal[ampm]\" value=\"pm\" $pmsel>pm"; $str .= '<input type="radio" name="cal[ampm]" value="am"'.$amsel.'>am';
$str .= '<input type="radio" name="cal[ampm]" value="pm"'.$pmsel.'>pm';
} }
display_item(lang("Start Time"),$str); display_item(lang('Start Time'),$str);
// End Date // End Date
$day_html = $sb->getDays('cal[end_day]',intval($phpgw->common->show_date($cal_info->edatetime,'d')));
$day_html = $sb->getDays("cal[end_day]",intval($phpgw->common->show_date($cal_info->edatetime,"d"))); $month_html = $sb->getMonthText('cal[end_month]',intval($phpgw->common->show_date($cal_info->edatetime,'n')));
$month_html = $sb->getMonthText("cal[end_month]",intval($phpgw->common->show_date($cal_info->edatetime,"n"))); $year_html = $sb->getYears('cal[end_year]',intval($phpgw->common->show_date($cal_info->edatetime,'Y')),intval($phpgw->common->show_date($cal_info->edatetime,'Y')));
$year_html = $sb->getYears("cal[end_year]",intval($phpgw->common->show_date($cal_info->edatetime,"Y")),intval($phpgw->common->show_date($cal_info->edatetime,"Y"))); display_item(lang('End Date'),$phpgw->common->dateformatorder($year_html,$month_html,$day_html));
display_item(lang("End Date"),$phpgw->common->dateformatorder($year_html,$month_html,$day_html));
// End Time // End Time
$amsel = "checked"; $pmsel = ""; $amsel = ' checked'; $pmsel = '';
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { if ($phpgw_info['user']['preferences']['common']['timeformat'] == '12')
if ($cal_info->end_ampm == "pm") { {
$amsel = ""; $pmsel = "checked"; if ($cal_info->end_ampm == 'pm')
} else { {
$amsel = "checked"; $pmsel = ""; $amsel = ''; $pmsel = ' checked';
} }
} }
$str = "<input name=\"cal[end_hour]\" size=\"2\" VALUE=\"".$phpgw->common->show_date($cal_info->edatetime,$hourformat)."\" maxlength=\"2\">:<input name=\"cal[end_minute]\" size=\"2\" value=\"".$phpgw->common->show_date($cal_info->edatetime,"i")."\" maxlength=\"2\">";
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { $str = '<input name="cal[end_hour]" size="2" VALUE="'.$phpgw->common->show_date($cal_info->edatetime,$hourformat).'" maxlength="2">:<input name="cal[end_minute]" size="2" value="'.$phpgw->common->show_date($cal_info->edatetime,'i').'" maxlength="2">';
$str .= "<input type=\"radio\" name=\"cal[end_ampm]\" value=\"am\" $amsel>am"; if ($phpgw_info['user']['preferences']['common']['timeformat'] == '12')
$str .= "<input type=\"radio\" name=\"cal[end_ampm]\" value=\"pm\" $pmsel>pm"; {
$str .= '<input type="radio" name="cal[end_ampm]" value="am"'.$amsel.'>am';
$str .= '<input type="radio" name="cal[end_ampm]" value="pm"'.$pmsel.'>pm';
} }
display_item(lang("End Time"),$str); display_item(lang("End Time"),$str);
// Priority // Priority
display_item(lang("Priority"),$sb->getPriority("cal[priority]",$cal_info->priority)); display_item(lang('Priority'),$sb->getPriority('cal[priority]',$cal_info->priority));
// Access // Access
display_item(lang("Access"),$sb->getAccessList("cal[access]",$cal_info->access)); $str = '<input type="checkbox" name="cal[access]" value="private"';
if($cal_info->access=='private')
{
$str .= ' checked';
}
$str .= '>';
display_item(lang('Private'),$str);
// Groups // Groups
$user_groups = $phpgw->accounts->memberships(intval($owner)); // $user_groups = $phpgw->accounts->memberships(intval($owner));
display_item(lang("Groups"),$sb->getGroups($user_groups,$cal_info->groups,"cal[groups][]")); // display_item(lang('Groups'),$sb->getGroups($user_groups,$cal_info->groups,'cal[groups][]'));
// Participants // Participants
// Start Here.....
$accounts = $phpgw->acl->get_ids_for_location('run',1,'calendar'); $accounts = $phpgw->acl->get_ids_for_location('run',1,'calendar');
$users = Array(); $users = Array();
for($i=0;$i<count($accounts);$i++) { for($i=0;$i<count($accounts);$i++)
switch ($phpgw->accounts->get_type($accounts[$i])) { {
case 'u' : $user = $accounts[$i];
if($accounts[$i] != $owner && !$users[$accounts[$i]]) { if($user != $owner && !isset($users[$user]))
$users[$accounts[$i]] = $phpgw->common->grab_owner_name($accounts[$i]); {
} $users[$user] = $phpgw->common->grab_owner_name($user);
break; if($phpgw->accounts->get_type($user) == 'g')
case 'g' : {
$group_members = $phpgw->acl->get_ids_for_location($accounts[$i],1,'phpgw_group'); $group_members = $phpgw->acl->get_ids_for_location($user,1,'phpgw_group');
while($group_members && $user = each($group_members)) { if($group_members != False)
if($user[1] != $owner && !$users[$user[1]]) { {
$users[$user[1]] = $phpgw->common->grab_owner_name($user[1]); for($j=0;$j<count($group_members);$j++)
{
if($group_members[$j] != $owner && !isset($users[$group_members[$j]]))
{
$users[$group_members[$j]] = $phpgw->common->grab_owner_name($group_members[$j]);
}
}
} }
} }
break;
} }
} }
$num_users = count($users); if ($num_users > 50)
if ($num_users > 50) { {
$size = 15; $size = 15;
} else if ($num_users > 5) { }
elseif ($num_users > 5)
{
$size = 5; $size = 5;
} else { }
else
{
$size = $num_users; $size = $num_users;
} }
$str = "<select name=\"cal[participants][]\" multiple size=\"5\">"; $str = "\n".' <select name="cal[participants][]" multiple size="5">'."\n";
for ($l=0;$l<count($cal_info->participants);$l++) { for ($l=0;$l<count($cal_info->participants);$l++)
$parts[$cal_info->participants[$l]] = True; {
$parts[$cal_info->participants[$l]] = ' selected';
} }
@asort($users); @asort($users);
@reset($users); @reset($users);
while ($user = each($users)) { while ($user = each($users))
$str .= "<option value=\"" . $user[0] . "\""; {
if ($parts[$user[0]]) if($user[0] != $owner && $phpgw->accounts->exists($user[0]) == True)
$str .= " selected"; {
$str .= ">".$user[1]."</option>"; $str .= ' <option value="' . $user[0] . '"'.$parts[$user[0]].'>('.$phpgw->accounts->get_type($user[0]).') '.$user[1].'</option>'."\n";
} }
$str .= "</select>"; }
display_item(lang("Participants"),$str); $str .= ' </select>';
display_item(lang('Participants'),$str);
// I Participate // I Participate
$participate = False; $participate = False;
if($id) { if($id)
for($i=0;$i<count($cal_info->participants);$i++) { {
if($cal_info->participants[$i] == $phpgw_info["user"]["account_id"]) { for($i=0;$i<count($cal_info->participants);$i++)
{
if($cal_info->participants[$i] == $owner)
{
$participate = True; $participate = True;
} }
} }
} }
$str = "<input type=\"checkbox\" name=\"cal[participants][]\" value=\"".$phpgw_info["user"]["account_id"]."\""; $str = '<input type="checkbox" name="cal[participants][]" value="'.$owner.'"';
if(($id && $participate) || !$id) { if((($id > 0) && ($participate == True)) || !isset($id))
$str .= " checked"; {
$str .= ' checked';
} }
$str .= ">"; $str .= '>';
display_item(lang("I Participate"),$str); display_item($phpgw->common->grab_owner_name($owner).' '.lang('Participates'),$str);
// Repeat Type // Repeat Type
$phpgw->template->parse("output","hr",True); $p->set_var('hr_text','<hr>');
display_item("<hr>".lang("Repeating Event Information"),"<hr>"); $p->parse('output','hr',True);
$str = "<select name=\"cal[rpt_type]\">"; $p->set_var('hr_text','<center><b>'.lang('Repeating Event Information').'</b></center><br>');
$rpt_type_str = Array("none","daily","weekly","monthlybyday","monthlybydate","yearly"); $p->parse('output','hr',True);
$rpt_type_out = Array("none" => "None", "daily" => "Daily", "weekly" => "Weekly", "monthlybyday" => "Monthly (by day)", "monthlybydate" => "Monthly (by date)", "yearly" => "yearly"); $str = '<select name="cal[rpt_type]">';
for($l=0;$l<count($rpt_type_str);$l++) { $rpt_type_str = Array(
$str .= "<option value=\"".$rpt_type_str[$l]."\""; 'none',
if(!strcmp($cal_info->rpt_type,$rpt_type_str[$l])) $str .= " selected"; 'daily',
$str .= ">".lang($rpt_type_out[$rpt_type_str[$l]])."</option>"; 'weekly',
'monthlybyday',
'monthlybydate',
'yearly'
);
$rpt_type_out = Array(
'none' => 'None',
'daily' => 'Daily',
'weekly' => 'Weekly',
'monthlybyday' => 'Monthly (by day)',
'monthlybydate' => 'Monthly (by date)',
'yearly' => 'Yearly'
);
for($l=0;$l<count($rpt_type_str);$l++)
{
$str .= '<option value="'.$rpt_type_str[$l].'"';
if(!strcmp($cal_info->rpt_type,$rpt_type_str[$l]))
{
$str .= ' selected';
} }
$str .= "</select>"; $str .= '>'.lang($rpt_type_out[$rpt_type_str[$l]]).'</option>';
display_item(lang("Repeat Type"),$str); }
$str .= '</select>';
display_item(lang('Repeat Type'),$str);
$phpgw->template->set_var("field",lang("Repeat End Date")); $p->set_var('field',lang('Repeat End Date'));
$str = "<input type=\"checkbox\" name=\"cal[rpt_use_end]\" value=\"y\""; $str = '<input type="checkbox" name="cal[rpt_use_end]" value="y"';
if($cal_info->rpt_use_end) $str .= " checked";
$str .= ">".lang("Use End Date")." ";
$day_html = $sb->getDays("cal[rpt_day]",intval($phpgw->common->show_date($cal_info->rpt_end,"d"))); if($cal_info->rpt_use_end)
$month_html = $sb->getMonthText("cal[rpt_month]",intval($phpgw->common->show_date($cal_info->rpt_end,"n"))); {
$year_html = $sb->getYears("cal[rpt_year]",intval($phpgw->common->show_date($cal_info->rpt_end,"Y")),intval($phpgw->common->show_date($cal_info->rpt_end,"Y"))); $str .= ' checked';
}
$str .= '>'.lang('Use End Date').' ';
$day_html = $sb->getDays('cal[rpt_day]',intval($phpgw->common->show_date($cal_info->rpt_end,'d')));
$month_html = $sb->getMonthText('cal[rpt_month]',intval($phpgw->common->show_date($cal_info->rpt_end,'n')));
$year_html = $sb->getYears('cal[rpt_year]',intval($phpgw->common->show_date($cal_info->rpt_end,'Y')),intval($phpgw->common->show_date($cal_info->rpt_end,'Y')));
$str .= $phpgw->common->dateformatorder($year_html,$month_html,$day_html); $str .= $phpgw->common->dateformatorder($year_html,$month_html,$day_html);
display_item(lang("Repeat End Date"),$str); display_item(lang('Repeat End Date'),$str);
$str = "<input type=\"checkbox\" name=\"cal[rpt_sun]\" value=\"1\"".($cal_info->rpt_sun?"checked":"")."> ".lang("Sunday")." "; $str = '<input type="checkbox" name="cal[rpt_sun]" value="1"'.($cal_info->rpt_sun?' checked':'').'> '.lang('Sunday').' ';
$str .= "<input type=\"checkbox\" name=\"cal[rpt_mon]\" value=\"1\"".($cal_info->rpt_mon?"checked":"")."> ".lang("Monday")." "; $str .= '<input type="checkbox" name="cal[rpt_mon]" value="1"'.($cal_info->rpt_mon?' checked':'').'> '.lang('Monday').' ';
$str .= "<input type=\"checkbox\" name=\"cal[rpt_tue]\" value=\"1\"".($cal_info->rpt_tue?"checked":"")."> ".lang("Tuesday")." "; $str .= '<input type="checkbox" name="cal[rpt_tue]" value="1"'.($cal_info->rpt_tue?' checked':'').'> '.lang('Tuesday').' ';
$str .= "<input type=\"checkbox\" name=\"cal[rpt_wed]\" value=\"1\"".($cal_info->rpt_wed?"checked":"")."> ".lang("Wednesday")." "; $str .= '<input type="checkbox" name="cal[rpt_wed]" value="1"'.($cal_info->rpt_wed?' checked':'').'> '.lang('Wednesday').' ';
$str .= "<input type=\"checkbox\" name=\"cal[rpt_thu]\" value=\"1\"".($cal_info->rpt_thu?"checked":"")."> ".lang("Thursday")." "; $str .= '<input type="checkbox" name="cal[rpt_thu]" value="1"'.($cal_info->rpt_thu?' checked':'').'> '.lang('Thursday').' ';
$str .= "<input type=\"checkbox\" name=\"cal[rpt_fri]\" value=\"1\"".($cal_info->rpt_fri?"checked":"")."> ".lang("Friday")." "; $str .= '<input type="checkbox" name="cal[rpt_fri]" value="1"'.($cal_info->rpt_fri?' checked':'').'> '.lang('Friday').' ';
$str .= "<input type=\"checkbox\" name=\"cal[rpt_sat]\" value=\"1\"".($cal_info->rpt_sat?"checked":"")."> ".lang("Saturday")." "; $str .= '<input type="checkbox" name="cal[rpt_sat]" value="1"'.($cal_info->rpt_sat?' checked':'').'> '.lang('Saturday').' ';
display_item(lang("Repeat Day")."<br>".lang("(for weekly)"),$str); display_item(lang('Repeat Day').'<br>'.lang('(for weekly)'),$str);
display_item(lang("Frequency"),"<input name=\"cal[rpt_freq]\" size=\"4\" maxlength=\"4\" value=\"".$cal_info->rpt_freq."\">"); display_item(lang('Frequency'),'<input name="cal[rpt_freq]" size="4" maxlength="4" value="'.$cal_info->rpt_freq.'">');
$phpgw->template->set_var("submit_button",lang("Submit")); $p->set_var('submit_button',lang('Submit'));
if ($id > 0) { if ($id > 0)
$phpgw->template->set_var("action_url_button",$phpgw->link("delete.php","id=$id")); {
$phpgw->template->set_var("action_text_button",lang("Delete")); $p->set_var('action_url_button',$phpgw->link('delete.php','id='.$id));
$phpgw->template->set_var("action_confirm_button","onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."')\""); $p->set_var('action_text_button',lang('Delete'));
$phpgw->template->parse("delete_button","form_button"); $p->set_var('action_confirm_button',"onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."')\"");
$phpgw->template->pparse("out","edit_entry_end"); $p->parse('delete_button','form_button');
} else { $p->pparse('out','edit_entry_end');
$phpgw->template->set_var("delete_button",""); }
$phpgw->template->pparse("out","edit_entry_end"); else
{
$p->set_var('delete_button','');
$p->pparse('out','edit_entry_end');
} }
$phpgw->common->phpgw_footer(); $phpgw->common->phpgw_footer();
}
?> ?>

View File

@ -14,150 +14,238 @@
/* $Id$ */ /* $Id$ */
$phpgw_info["flags"] = array("currentapp" => "calendar", "noheader" => True, "nonavbar" => True, "enable_nextmatchs_class" => True, "noappheader" => True, "noappfooter" => True); $phpgw_flags = Array(
include("../header.inc.php"); 'currentapp' => 'calendar',
'noheader' => True,
'nonavbar' => True,
'enable_nextmatchs_class' => True,
'noappheader' => True,
'noappfooter' => True
);
$phpgw_info['flags'] = $phpgw_flags;
include('../header.inc.php');
$cal_info = CreateObject('calendar.calendar_item'); $cal_info = CreateObject('calendar.calendar_item');
function validate($cal_info) { function validate($cal_info)
{
$error = 0; $error = 0;
// do a little form verifying // do a little form verifying
if ($cal_info->name == "") { if ($cal_info->name == '')
{
$error = 40; $error = 40;
} elseif (($cal_info->hour < 0 || $cal_info->hour > 23) || ($cal_info->end_hour < 0 || $cal_info->end_hour > 23)) { }
elseif (($cal_info->hour < 0 || $cal_info->hour > 23) || ($cal_info->end_hour < 0 || $cal_info->end_hour > 23))
{
$error = 41; $error = 41;
} elseif (($cal_info->minute < 0 || $cal_info->minute > 59) || ($cal_info->end_minute < 0 || $cal_info->minute > 59)) { }
elseif (($cal_info->minute < 0 || $cal_info->minute > 59) || ($cal_info->end_minute < 0 || $cal_info->minute > 59))
{
$error = 41; $error = 41;
} elseif(!checkdate($cal_info->month,$cal_info->day,$cal_info->year) || !checkdate($cal_info->end_month,$cal_info->end_day,$cal_info->end_year)) { }
$error = 42; elseif(!checkdate($cal_info->month,$cal_info->day,$cal_info->year) || !checkdate($cal_info->end_month,$cal_info->end_day,$cal_info->end_year))
} elseif (($cal_info->year == $cal_info->end_year) && ($cal_info->month == $cal_info->end_month) && ($cal_info->day == $cal_info->end_day)) { {
if ($cal_info->hour > $cal_info->end_hour) {
$error = 42;
} elseif (($cal_info->hour == $cal_info->end_hour) && ($cal_info->minute > $cal_info->end_minute)) {
$error = 42; $error = 42;
} }
} elseif (($cal_info->year == $cal_info->end_year) && ($cal_info->month == $cal_info->end_month) && ($cal_info->day > $cal_info->end_day)) { elseif (($cal_info->year == $cal_info->end_year) && ($cal_info->month == $cal_info->end_month) && ($cal_info->day == $cal_info->end_day))
$error = 42; {
} elseif (($cal_info->year == $cal_info->end_year) && ($cal_info->month > $cal_info->end_month)) { if ($cal_info->hour > $cal_info->end_hour)
$error = 42; {
} elseif ($cal_info->year > $cal_info->end_year) {
$error = 42; $error = 42;
} }
elseif (($cal_info->hour == $cal_info->end_hour) && ($cal_info->minute > $cal_info->end_minute))
{
$error = 42;
}
}
elseif (($cal_info->year == $cal_info->end_year) && ($cal_info->month == $cal_info->end_month) && ($cal_info->day > $cal_info->end_day))
{
$error = 42;
}
elseif (($cal_info->year == $cal_info->end_year) && ($cal_info->month > $cal_info->end_month))
{
$error = 42;
}
elseif ($cal_info->year > $cal_info->end_year)
{
$error = 42;
}
return $error; return $error;
} }
if(!isset($readsess)) { if(!isset($readsess))
for(reset($cal);$key=key($cal);next($cal)) { {
for(reset($cal);$key=key($cal);next($cal))
{
$data = $cal[$key]; $data = $cal[$key];
$cal_info->set($key,$data); $cal_info->set($key,$data);
} }
$participating = False; $cal_info->owner=$owner;
if($phpgw_info["user"]["account_id"] == $cal_info->participants[count($cal_info->participants) - 1]) {
$participating = True; if ($phpgw_info['user']['preferences']['common']['timeformat'] == '12')
} {
if(!$participating && count($cal_info->participants) == 1) { if ($cal_info->ampm == 'pm')
$cal_info->owner = $cal_info->participants[0]; {
} if ($cal_info->hour <> 12)
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { {
if ($cal_info->ampm == "pm") {
if ($cal_info->hour <> 12) {
$cal_info->hour += 12; $cal_info->hour += 12;
} }
} elseif ($cal_info->ampm == "am") { }
if ($cal_info->hour == 12) { elseif ($cal_info->ampm == 'am')
{
if ($cal_info->hour == 12)
{
$cal_info->hour -= 12; $cal_info->hour -= 12;
} }
} }
if ($cal_info->end_ampm == "pm") {
if ($cal_info->end_hour <> 12) { if ($cal_info->end_ampm == 'pm')
{
if ($cal_info->end_hour <> 12)
{
$cal_info->end_hour += 12; $cal_info->end_hour += 12;
} }
} elseif ($cal_info->end_ampm == "am") { }
if ($cal_info->end_hour == 12) { elseif ($cal_info->end_ampm == 'am')
{
if ($cal_info->end_hour == 12)
{
$cal_info->end_hour -= 12; $cal_info->end_hour -= 12;
} }
} }
} }
$cal_info->datetime = mktime($cal_info->hour,$cal_info->minute,0,$cal_info->month,$cal_info->day,$cal_info->year) - ((60 * 60) * $phpgw_info["user"]["preferences"]["common"]["tz_offset"]); $datetime = $phpgw->calendar->makegmttime($cal_info->hour,$cal_info->minute,0,$cal_info->month,$cal_info->day,$cal_info->year);
$cal_info->edatetime = mktime($cal_info->end_hour,$cal_info->end_minute,0,$cal_info->end_month,$cal_info->end_day,$cal_info->end_year) - ((60 * 60) * $phpgw_info["user"]["preferences"]["common"]["tz_offset"]); $cal_info->datetime = $datetime['raw'];
$cal_info->rpt_end = mktime(12,0,0,$cal_info->rpt_month,$cal_info->rpt_day,$cal_info->rpt_year) - ((60 * 60) * $phpgw_info["user"]["preferences"]["common"]["tz_offset"]); $datetime = $phpgw->calendar->makegmttime($cal_info->end_hour,$cal_info->end_minute,0,$cal_info->end_month,$cal_info->end_day,$cal_info->end_year);
$cal_info->edatetime = $datetime['raw'];
$datetime = $phpgw->calendar->makegmttime(0,0,0,$cal_info->rpt_month,$cal_info->rpt_day,$cal_info->rpt_year);
$cal_info->rpt_end = $datetime['raw'];
$phpgw->common->appsession('entry','calendar',$cal_info); $phpgw->session->appsession('entry','calendar',$cal_info);
$datetime_check = validate($cal_info); $datetime_check = validate($cal_info);
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { if ($phpgw_info['user']['preferences']['common']['timeformat'] == '12')
if ($cal_info->hour >= 12) { {
$cal_info->ampm = ""; if ($cal_info->hour >= 12)
} {
if ($cal_info->end_hour >= 12) { $cal_info->ampm = '';
$cal_info->end_ampm = "";
}
}
$cal_info->datetime += ((60 * 60) * $phpgw_info["user"]["preferences"]["common"]["tz_offset"]);
$cal_info->edatetime += ((60 * 60) * $phpgw_info["user"]["preferences"]["common"]["tz_offset"]);
$overlapping_events = $phpgw->calendar->overlap($cal_info->datetime,$cal_info->edatetime,$cal_info->participants,$cal_info->groups,$cal_info->owner,$cal_info->id);
} else {
$cal_info = $phpgw->common->appsession('entry','calendar');
} }
if($datetime_check) { if ($cal_info->end_hour >= 12)
Header("Location: ".$phpgw->link("edit_entry.php","readsess=".$cal_info->id."&cd=".$datetime_check)); {
$cal_info->end_ampm = '';
}
}
$tz_offset = intval(((60 * 60) * intval($phpgw_info['user']['preferences']['common']['tz_offset'])));
$cal_info->datetime += $tz_offset;
$cal_info->edatetime += $tz_offset;
$overlapping_events = $phpgw->calendar->overlap($cal_info->datetime,$cal_info->edatetime,$cal_info->participants,$cal_info->groups,$cal_info->owner,$cal_info->id);
}
else
{
$data = $phpgw->session->appsession('entry','calendar');
$cal_info = unserialize($data);
}
if($datetime_check)
{
Header('Location: '.$phpgw->link('edit_entry.php','readsess='.$cal_info->id.'&cd='.$datetime_check));
$phpgw->common->phpgw_exit(); $phpgw->common->phpgw_exit();
} elseif($overlapping_events) { }
elseif($overlapping_events)
{
$phpgw->common->phpgw_header(); $phpgw->common->phpgw_header();
echo parse_navbar(); echo parse_navbar();
$phpgw->template->set_file(array("overlap" => "overlap.tpl",
"form_button" => "form_button_script.tpl"));
$phpgw->template->set_block("overlap","form_button"); $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('calendar'));
$templates = Array(
'overlap' => 'overlap.tpl',
'form_button' => 'form_button_script.tpl'
);
$p->set_file($templates);
$phpgw->template->set_var("color",$phpgw_info["theme"]["bg_text"]); $p->set_var('color',$phpgw_info['theme']['bg_text']);
$calendar_overlaps = $phpgw->calendar->getevent($overlapping_events); $calendar_overlaps = $phpgw->calendar->getevent($overlapping_events);
$format = $phpgw_info["user"]["preferences"]["common"]["dateformat"] . " - "; $format = $phpgw_info['user']['preferences']['common']['dateformat'] . ' - ';
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$format .= "h:i:s a";
} else {
$format .= "H:i:s";
}
$overlap = ""; if ($phpgw_info['user']['preferences']['common']['timeformat'] == '12')
for($i=0;$i<count($calendar_overlaps);$i++) { {
$cal_over = $calendar_overlaps[$i]; $format .= 'h:i:s a';
if($cal_over) { }
$overlap .= "<li>";
$private = $phpgw->calendar->is_private($cal_over,$cal_over->owner);
if(strtoupper($private) == "PRIVATE")
$overlap .= "(PRIVATE)";
else else
$overlap .= $phpgw->calendar->link_to_entry($cal_over->id,"circle.gif",$cal_over->description).$cal_over->name; {
$overlap .= " (".$phpgw->common->show_date($cal_over->datetime)." - ".$phpgw->common->show_date($cal_over->edatetime).")<br>"; $format .= 'H:i:s';
}
}
if(strlen($overlap)) {
$phpgw->template->set_var("overlap_text",lang("Your suggested time of <B> x - x </B> conflicts with the following existing calendar entries:",date($format,$cal_info->datetime),date($format,$cal_info->edatetime)));
$phpgw->template->set_var("overlap_list",$overlap);
} else {
$phpgw->template->set_var("overlap_text","");
$phpgw->template->set_var("overlap_list","");
} }
$phpgw->template->set_var("action_url_button",$phpgw->link("","readsess=".$cal_info->id)); $overlap = '';
$phpgw->template->set_var("action_text_button",lang("Ignore Conflict")); for($i=0;$i<count($calendar_overlaps);$i++)
$phpgw->template->set_var("action_confirm_button",""); {
$phpgw->template->parse("resubmit_button","form_button"); $cal_over = $calendar_overlaps[$i];
if($cal_over)
{
$overlap .= '<li>';
$private = $phpgw->calendar->is_private($cal_over,$cal_over->owner);
$phpgw->template->set_var("action_url_button",$phpgw->link("edit_entry.php","readsess=".$cal_info->id)); if(strtoupper($private) == 'PRIVATE')
$phpgw->template->set_var("action_text_button",lang("Re-Edit Event")); {
$phpgw->template->set_var("action_confirm_button",""); $overlap .= '(PRIVATE)';
$phpgw->template->parse("reedit_button","form_button"); }
else
{
$overlap .= $phpgw->calendar->link_to_entry($cal_over->id,'circle.gif',$cal_over->description).$cal_over->name;
}
$phpgw->template->pparse("out","overlap"); $overlap .= ' ('.$phpgw->common->show_date($cal_over->datetime).' - '.$phpgw->common->show_date($cal_over->edatetime).')<br>';
} else { }
}
if(strlen($overlap))
{
$var = Array(
'overlap_text' => lang('Your suggested time of <B> x - x </B> conflicts with the following existing calendar entries:',date($format,$cal_info->datetime),date($format,$cal_info->edatetime)),
'overlap_list' => $overlap
);
}
else
{
$var = Array(
'overlap_text' => '',
'overlap_list' => ''
);
}
$p->set_var($var);
$var = Array(
'action_url_button' => $phpgw->link('','readsess='.$cal_info->id),
'action_text_button' => lang('Ignore Conflict'),
'action_confirm_button' => ''
);
$p->set_var($var);
$p->parse('resubmit_button','form_button');
$var = Array(
'action_url_button' => $phpgw->link('edit_entry.php','readsess='.$cal_info->id),
'action_text_button' => lang('Re-Edit Event'),
'action_confirm_button' => ''
);
$p->set_var($var);
$p->parse('reedit_button','form_button');
$p->pparse('out','overlap');
}
else
{
$phpgw->calendar->add($cal_info,$cal_info->id); $phpgw->calendar->add($cal_info,$cal_info->id);
Header("Location: ".$phpgw->link("index.php","year=$year&month=$month&cd=14")); Header('Location: '.$phpgw->link('index.php','year='.$year.'&month='.$month.'&cd=14&owner='.$owner));
} }
$phpgw->common->phpgw_footer(); $phpgw->common->phpgw_footer();
?> ?>

View File

@ -60,6 +60,7 @@
{ {
$this->user = $phpgw->accounts->name2id($user); $this->user = $phpgw->accounts->name2id($user);
} }
return $this->stream; return $this->stream;
} }
@ -103,6 +104,7 @@
$this->stream->lock(array('calendar_entry','calendar_entry_user','calendar_entry_repeats')); $this->stream->lock(array('calendar_entry','calendar_entry_user','calendar_entry_repeats'));
$this->stream->query('SELECT * FROM calendar_entry WHERE cal_id='.$event_id,__LINE__,__FILE__); $this->stream->query('SELECT * FROM calendar_entry WHERE cal_id='.$event_id,__LINE__,__FILE__);
if($this->stream->num_rows() > 0) if($this->stream->num_rows() > 0)
{ {
$this->cal_event = CreateObject('calendar.calendar_item'); $this->cal_event = CreateObject('calendar.calendar_item');
@ -133,7 +135,7 @@
} }
else else
{ {
if (! $phpgw_info['user']['preferences']['calendar']['defaultfilter']) if (!isset($phpgw_info['user']['preferences']['calendar']['defaultfilter']))
{ {
$phpgw->preferences->add('calendar','defaultfilter','all'); $phpgw->preferences->add('calendar','defaultfilter','all');
$phpgw->preferences->save_repository(True); $phpgw->preferences->save_repository(True);
@ -668,8 +670,8 @@
$p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('calendar')); $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('calendar'));
$p->set_unknowns('remove'); $p->set_unknowns('remove');
$p->set_file(array('link_pict' => 'link_pict.tpl')); $p->set_file(array('link_pict' => 'link_pict.tpl'));
$p->set_block('link_pict','link_pict'); // $p->set_block('link_pict','link_pict');
$p->set_var('link_link',$phpgw->link($phpgw_info['server']['webserver_url'].'/calendar/view.php','id='.$id)); $p->set_var('link_link',$phpgw->link($phpgw_info['server']['webserver_url'].'/calendar/view.php','id='.$id.'&owner='.$this->owner));
$p->set_var('lang_view',lang('View this entry')); $p->set_var('lang_view',lang('View this entry'));
$p->set_var('pic_image',$phpgw->common->get_image_path('calendar').'/'.$pic); $p->set_var('pic_image',$phpgw->common->get_image_path('calendar').'/'.$pic);
$p->set_var('description',$description); $p->set_var('description',$description);
@ -1062,20 +1064,10 @@
if($this->check_perms(PHPGW_ACL_ADD) == True) if($this->check_perms(PHPGW_ACL_ADD) == True)
{ {
$str .= '<a href="'.$phpgw->link($phpgw_info['server']['webserver_url'].'/calendar/edit_entry.php','year='.$date_year.'&month='.$date['month'].'&day='.$date['day']).'">'; $str .= '<a href="'.$phpgw->link($phpgw_info['server']['webserver_url'].'/calendar/edit_entry.php','year='.$date_year.'&month='.$date['month'].'&day='.$date['day'].'&owner='.$this->owner).'">';
}
$str .= '<img src="'.$phpgw->common->get_image_path('calendar').'/new.gif" width="10" height="10" '; $str .= '<img src="'.$phpgw->common->get_image_path('calendar').'/new.gif" width="10" height="10" ';
if($this->check_perms(PHPGW_ACL_ADD) == True)
{
$str .= 'alt="'.lang('New Entry').'" '; $str .= 'alt="'.lang('New Entry').'" ';
}
$str .= 'border="0" align="right">'; $str .= 'border="0" align="right">';
if($this->check_perms(PHPGW_ACL_ADD) == True)
{
$str .= '</a>'; $str .= '</a>';
} }
@ -1709,15 +1701,15 @@
$this->read_repeated_events($owner); $this->read_repeated_events($owner);
$p = new Template($phpgw->common->get_tpl_dir('calendar')); $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('calendar'));
$p->set_unknowns('remove'); $p->set_unknowns('remove');
$templates = Array( $templates = Array(
'day_cal' => 'day_cal.tpl', 'day_cal' => 'day_cal.tpl',
'mini_week' => 'mini_week.tpl', 'mini_week' => 'mini_week.tpl',
'day_row_99' => 'day_row_99.tpl', // 'day_row' => 'day_row.tpl',
'day_row_event' => 'day_row_event.tpl', 'day_row_event' => 'day_row_event.tpl',
'day_row_time' => 'day_tow_time.tpl' 'day_row_time' => 'day_row_time.tpl'
); );
$p->set_file($templates); $p->set_file($templates);
@ -2066,8 +2058,8 @@
} }
$query = 'UPDATE calendar_entry SET cal_owner='.$owner.", cal_name='".addslashes($calinfo->name)."', " $query = 'UPDATE calendar_entry SET cal_owner='.$owner.", cal_name='".addslashes($calinfo->name)."', "
. "cal_description='".addslashes($calinfo->description)."', cal_datetime=".$date.', ' . "cal_description='".addslashes($calinfo->description)."', cal_datetime=".$date['raw'].', '
. 'cal_mdatetime='.$today.', cal_edatetime='.$enddate.', ' . 'cal_mdatetime='.$today['raw'].', cal_edatetime='.$enddate['raw'].', '
. 'cal_priority='.$calinfo->priority.", cal_type='".$rpt_type."' "; . 'cal_priority='.$calinfo->priority.", cal_type='".$rpt_type."' ";
if(($calinfo->access == 'public' || $calinfo->access == 'group') && count($calinfo->groups)) if(($calinfo->access == 'public' || $calinfo->access == 'group') && count($calinfo->groups))
@ -2092,7 +2084,7 @@
while ($participant = each($calinfo->participants)) while ($participant = each($calinfo->participants))
{ {
$phpgw->db->query('INSERT INTO calendar_entry_user(cal_id,cal_login,cal_status) ' $phpgw->db->query('INSERT INTO calendar_entry_user(cal_id,cal_login,cal_status) '
. "VALUES($calid,".$participant[1].",'A')",__LINE__,__FILE__); . 'VALUES('.$calid.','.$participant[1].",'A')",__LINE__,__FILE__);
} }
if(strcmp($calinfo->rpt_type,'none') <> 0) if(strcmp($calinfo->rpt_type,'none') <> 0)
@ -2136,7 +2128,7 @@
else else
{ {
$db2->query("UPDATE calendar_entry_repeats SET cal_type='".$calinfo->rpt_type."', cal_use_end=".$use_end.', ' $db2->query("UPDATE calendar_entry_repeats SET cal_type='".$calinfo->rpt_type."', cal_use_end=".$use_end.', '
."cal_end='".$end."', cal_days='".$days."', cal_frequency=".$freq.' ' ."cal_end='".$end['raw']."', cal_days='".$days."', cal_frequency=".$freq.' '
.'WHERE cal_id='.$calid,__LINE__,__FILE__); .'WHERE cal_id='.$calid,__LINE__,__FILE__);
} }
} }

View File

@ -1,4 +1,3 @@
<!-- $Id$ --> <!-- $Id$ -->
<!-- BEGIN day_row_event -->
<td class="event" bgcolor="{bgcolor}"{extras}>{event}</td> <td class="event" bgcolor="{bgcolor}"{extras}>{event}</td>
<!-- END day_row_event -->

View File

@ -1,4 +1,3 @@
<!-- $Id$ --> <!-- $Id$ -->
<!-- BEGIN day_row_time -->
<td class="time"><table width="100%" border="1" cellspacing="0" cellpadding="0"><tr><td class="time">{open_link}{time}{close_link}</td></tr></table></td> <td class="time"><table width="100%" border="1" cellspacing="0" cellpadding="0"><tr><td class="time">{open_link}{time}{close_link}</td></tr></table></td>
<!-- END day_row_time -->

View File

@ -7,6 +7,11 @@
<form action="{action_url}" method="post" name="addform"> <form action="{action_url}" method="post" name="addform">
{common_hidden} {common_hidden}
<table border="0" width="75%"> <table border="0" width="75%">
<tr>
<td colspan="2">
<hr>
</td>
</tr>
<!-- END edit_entry_begin --> <!-- END edit_entry_begin -->
{output} {output}

View File

@ -1,6 +1,7 @@
<!-- $Id$ --> <!-- $Id$ -->
<!- BEGIN hr -->
<tr> <tr>
<hr> <td colspan="2">
{hr_text}
</td>
</tr> </tr>
<!-- END hr -->

View File

@ -1,4 +1,3 @@
<!-- $Id$ --> <!-- $Id$ -->
<!-- BEGIN day_row_event -->
<td class="event" bgcolor="{bgcolor}"{extras}>{event}</td> <td class="event" bgcolor="{bgcolor}"{extras}>{event}</td>
<!-- END day_row_event -->

View File

@ -1,4 +1,3 @@
<!-- $Id$ --> <!-- $Id$ -->
<!-- BEGIN day_row_time -->
<td class="time"><table width="100%" border="1" cellspacing="0" cellpadding="0"><tr><td class="time">{open_link}{time}{close_link}</td></tr></table></td> <td class="time"><table width="100%" border="1" cellspacing="0" cellpadding="0"><tr><td class="time">{open_link}{time}{close_link}</td></tr></table></td>
<!-- END day_row_time -->

View File

@ -7,6 +7,11 @@
<form action="{action_url}" method="post" name="addform"> <form action="{action_url}" method="post" name="addform">
{common_hidden} {common_hidden}
<table border="0" width="75%"> <table border="0" width="75%">
<tr>
<td colspan="2">
<hr>
</td>
</tr>
<!-- END edit_entry_begin --> <!-- END edit_entry_begin -->
{output} {output}

View File

@ -1,6 +1,7 @@
<!-- $Id$ --> <!-- $Id$ -->
<!- BEGIN hr -->
<tr> <tr>
<hr> <td colspan="2">
{hr_text}
</td>
</tr> </tr>
<!-- END hr -->

View File

@ -18,25 +18,25 @@
'currentapp' => 'calendar', 'currentapp' => 'calendar',
'enable_nextmatchs_class' => True 'enable_nextmatchs_class' => True
); );
$phpgw_info["flags"] = $phpgw_flags; $phpgw_info['flags'] = $phpgw_flags;
include('../header.inc.php'); include('../header.inc.php');
if(! ($rights & PHPGW_ACL_READ)) if(! ($rights & PHPGW_ACL_READ))
{ {
echo lang('You do not have permission to read this record'); echo lang('You do not have permission to read this record!');
$phpgw->common->phpgw_exit(); $phpgw->common->phpgw_exit();
} }
if ($id < 1) if ($id < 1)
{ {
echo lang("Invalid entry id."); echo lang('Invalid entry id.');
$phpgw->common->phpgw_exit(); $phpgw->common->phpgw_exit();
} }
function add_day(&$repeat_days,$day) function add_day(&$repeat_days,$day)
{ {
if($repeat_days) $repeat_days .= ", "; if($repeat_days) $repeat_days .= ', ';
$repeat_days .= $day; $repeat_days .= $day;
} }
@ -64,18 +64,17 @@
reset($cal_info->participants); reset($cal_info->participants);
$participating = False; $participating = False;
while($participant = each($cal_info->participants)) for($j=0;$j<count($cal_info->participants);$j++)
{ {
if($participant[1] == $owner) if($cal_info->participants[$j] == $owner)
{ {
$participating = True; $participating = True;
break;
} }
} }
if($cal_info->owner != $phpgw_info['user']['account_id'] || $participating == False) if($participating == False)
{ {
echo lang('You do not have permission to read this record'); echo lang('You do not have permission to read this record.');
$phpgw->common->phpgw_exit(); $phpgw->common->phpgw_exit();
} }
@ -89,7 +88,7 @@
); );
$phpgw->template->set_file($templates); $phpgw->template->set_file($templates);
$phpgw->template->set_block('view_begin','list','view_end','form_button'); // $phpgw->template->set_block('view_begin','list','view_end','form_button');
$phpgw->template->set_var('bg_text',$phpgw_info['theme']['bg_text']); $phpgw->template->set_var('bg_text',$phpgw_info['theme']['bg_text']);
$phpgw->template->set_var('name',$cal_info->name); $phpgw->template->set_var('name',$cal_info->name);
@ -195,7 +194,7 @@
display_item(lang('Repetition'),$str); display_item(lang('Repetition'),$str);
} }
if ($rights & PHPGW_ACL_EDIT) if (($cal_info->owner == $owner) && ($rights & PHPGW_ACL_EDIT))
{ {
$phpgw->template->set_var('action_url_button',$phpgw->link('edit_entry.php','id='.$id.'&owner='.$owner)); $phpgw->template->set_var('action_url_button',$phpgw->link('edit_entry.php','id='.$id.'&owner='.$owner));
$phpgw->template->set_var('action_text_button',' '.lang('Edit').' '); $phpgw->template->set_var('action_text_button',' '.lang('Edit').' ');
@ -207,7 +206,7 @@
$phpgw->template->set_var('edit_button',''); $phpgw->template->set_var('edit_button','');
} }
if ($rights & PHPGW_ACL_DELETE) if (($cal_info->owner == $owner) && ($rights & PHPGW_ACL_DELETE))
{ {
$phpgw->template->set_var('action_url_button',$phpgw->link('delete.php','id='.$id.'&owner='.$owner)); $phpgw->template->set_var('action_url_button',$phpgw->link('delete.php','id='.$id.'&owner='.$owner));
$phpgw->template->set_var('action_text_button',lang('Delete')); $phpgw->template->set_var('action_text_button',lang('Delete'));