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,243 +11,310 @@
/* $Id$ */ /* $Id$ */
$phpgw_info['flags'] = array('currentapp' => 'calendar', 'enable_nextmatchs_class' => True, 'noappheader' => True, 'noappfooter' => True); $phpgw_flags = Array(
include('../header.inc.php'); 'currentapp' => 'calendar',
'enable_nextmatchs_class' => True,
'noappheader' => True,
'noappfooter' => True
);
$private_acl = True; $phpgw_info['flags'] = $phpgw_flags;
include('../header.inc.php');
if($private_acl == True) $private_acl = True;
{
define(PHPGW_ACL_PRIVATE,16);
}
function check_acl($label,$id,$acl,$rights,$right) if($private_acl == True)
{ {
global $phpgw_info, $p; define(PHPGW_ACL_PRIVATE,16);
}
$p->set_var($acl,$label.$phpgw_info['flags']['currentapp'].'['.$id.']['.$right.']'); function check_acl($label,$id,$acl,$rights,$right)
if ($rights & $right) { {
$p->set_var($acl.'_selected',' checked'); global $phpgw_info, $p;
} else {
$p->set_var($acl.'_selected',''); $p->set_var($acl,$label.$phpgw_info['flags']['currentapp'].'['.$id.']['.$right.']');
} if ($rights & $right)
} {
$p->set_var($acl.'_selected',' checked');
}
else
{
$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);
$rights = $acl->get_rights($id,$phpgw_info['flags']['currentapp']); $rights = $acl->get_rights($id,$phpgw_info['flags']['currentapp']);
check_acl($label,$id,'read',$rights,PHPGW_ACL_READ); check_acl($label,$id,'read',$rights,PHPGW_ACL_READ);
check_acl($label,$id,'add',$rights,PHPGW_ACL_ADD); check_acl($label,$id,'add',$rights,PHPGW_ACL_ADD);
check_acl($label,$id,'edit',$rights,PHPGW_ACL_EDIT); check_acl($label,$id,'edit',$rights,PHPGW_ACL_EDIT);
check_acl($label,$id,'delete',$rights,PHPGW_ACL_DELETE); check_acl($label,$id,'delete',$rights,PHPGW_ACL_DELETE);
if($private_acl == True) if($private_acl == True)
{ {
check_acl($label,$id,'private',$rights,PHPGW_ACL_PRIVATE); check_acl($label,$id,'private',$rights,PHPGW_ACL_PRIVATE);
} }
$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); }
$acl = CreateObject('phpgwapi.acl',intval($owner));
$acl->read_repository(); $acct = CreateObject('phpgwapi.accounts',$owner);
$groups = $acct->memberships($owner);
unset($acct);
$acl = CreateObject('phpgwapi.acl',intval($owner));
$acl->read_repository();
if ($submit) { if ($submit)
$to_remove = unserialize(urldecode($processed)); {
for($i=0;$i<count($to_remove);$i++) { $to_remove = unserialize(urldecode($processed));
$acl->delete($phpgw_info['flags']['currentapp'],$to_remove[$i]);
} for($i=0;$i<count($to_remove);$i++)
// Group records {
$group_variable = 'g_'.$phpgw_info['flags']['currentapp']; $acl->delete($phpgw_info['flags']['currentapp'],$to_remove[$i]);
}
// Group records
$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; {
while(list($right,$permission) = each($acllist)) { $totalacl = 0;
$totalacl += $right; while(list($right,$permission) = each($acllist))
} {
$acl->add($phpgw_info['flags']['currentapp'],$group_id,$totalacl); $totalacl += $right;
} }
$acl->add($phpgw_info['flags']['currentapp'],$group_id,$totalacl);
}
// User records // User records
$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; {
while(list($right,$permission) = each($acllist)) { $totalacl = 0;
$totalacl += $right; while(list($right,$permission) = each($acllist))
} {
$acl->add($phpgw_info['flags']['currentapp'],$user_id,$totalacl); $totalacl += $right;
} }
$acl->save_repository(); $acl->add($phpgw_info['flags']['currentapp'],$user_id,$totalacl);
} }
$acl->save_repository();
}
$processed = Array(); $processed = Array();
$total = 0; $total = 0;
if(!isset($start)) { if(!isset($start))
$start = 0; {
} $start = 0;
}
if(!$start) { if(!$start)
$s_groups = 0; {
$s_users = 0; $s_groups = 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); {
$db = $phpgw->db; $totalentries = count($groups);
$db->query("SELECT count(*) FROM phpgw_accounts WHERE account_type='u'"); $db = $phpgw->db;
$db->next_record(); $db->query("SELECT count(*) FROM phpgw_accounts WHERE account_type='u'");
$totalentries += intval($db->f(0)); $db->next_record();
} $totalentries += intval($db->f(0));
}
$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 (
'row_colspan' => 'preference_colspan_private.tpl', 'preferences' => 'preference_acl.tpl',
'acl_row' => 'preference_acl_row_private.tpl')); 'row_colspan' => 'preference_colspan_private.tpl',
'acl_row' => 'preference_acl_row_private.tpl'
);
} }
else else
{ {
$p->set_file(array('preferences' => 'preference_acl.tpl', $templates = Array (
'row_colspan' => 'preference_colspan.tpl', 'preferences' => 'preference_acl.tpl',
'acl_row' => 'preference_acl_row.tpl')); 'row_colspan' => 'preference_colspan.tpl',
'acl_row' => 'preference_acl_row.tpl'
);
} }
// $p->set_var('errors','<p><center><b>This does nothing at this time!<br>Strictly as a template for use!</b></center>'); $p->set_file($templates);
$p->set_var('errors',''); // $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('title','<p><b>'.lang($phpgw_info["flags"]["currentapp"]." preferences").' - '.lang("acl").':</b><hr><p>');
$p->set_var('action_url',$phpgw->link('')); $common_hidden_vars = ' <input type="hidden" name="s_groups" value="'.$s_groups.'">'."\n"
$p->set_var('bg_color',$phpgw_info['theme']['th_bg']); . ' <input type="hidden" name="s_users" value="'.$s_users.'">'."\n"
$p->set_var('submit_lang',lang('submit')); . ' <input type="hidden" name="maxm" value="'.$maxm.'">'."\n"
. ' <input type="hidden" name="totalentries" value="'.$totalentries.'">'."\n"
. ' <input type="hidden" name="start" value="'.$start.'">'."\n"
. ' <input type="hidden" name="query" value="'.$query.'">'."\n"
. ' <input type="hidden" name="owner" value="'.$owner.'">'."\n";
$common_hidden_vars = ' <input type="hidden" name="s_groups" value="'.$s_groups.'">'."\n" $var = Array(
. ' <input type="hidden" name="s_users" value="'.$s_users.'">'."\n" 'errors' => '',
. ' <input type="hidden" name="maxm" value="'.$maxm.'">'."\n" 'title' => '<p><b>'.lang($phpgw_info['flags']['currentapp'].' preferences').' - '.lang('acl').':</b><hr><p>',
. ' <input type="hidden" name="totalentries" value="'.$totalentries.'">'."\n" 'action_url' => $phpgw->link(''),
. ' <input type="hidden" name="start" value="'.$start.'">'."\n" 'bg_color' => $phpgw_info['theme']['th_bg'],
. ' <input type="hidden" name="query" value="'.$query.'">'."\n" 'submit_lang' => lang('submit'),
. ' <input type="hidden" name="owner" value="'.$owner.'">'."\n"; 'common_hidden_vars_form' => $common_hidden_vars
$p->set_var('common_hidden_vars_form',$common_hidden_vars); );
if(isset($query_result) && $query_result) $p->set_var($var);
$common_hidden_vars .= '<input type="hidden" name="query_result" value="'.$query_result.'">'."\n";
$p->set_var('common_hidden_vars',$common_hidden_vars); if(isset($query_result) && $query_result)
$p->set_var(array('read_lang' => lang('Read'), {
'add_lang' => lang('Add'), $common_hidden_vars .= '<input type="hidden" name="query_result" value="'.$query_result.'">'."\n";
'edit_lang' => lang('Edit'), }
'delete_lang' => lang('Delete')));
$p->set_var('common_hidden_vars',$common_hidden_vars);
$var = Array(
'read_lang' => lang('Read'),
'add_lang' => lang('Add'),
'edit_lang' => lang('Edit'),
'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->parse('row','row_colspan',True); $p->set_var('string',lang('Groups'));
$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]; {
$go = True; $group = $groups[$k];
if($query) { $go = True;
if(!strpos(' '.$group['account_id'].' ',$query)) {
$go = False; if($query)
} {
} if(!strpos(' '.$group['account_id'].' ',$query))
if($go) { {
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); $go = False;
display_row($tr_color,'g_',$group['account_id'],$group['account_name']); }
$s_groups++; }
$processed[] = $group['account_id'];
$total++; if($go)
if($total == $maxm) break; {
} $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
} display_row($tr_color,'g_',$group['account_id'],$group['account_name']);
} $s_groups++;
$processed[] = $group['account_id'];
$total++;
if($total == $maxm)
{
break;
}
}
}
}
if($total <> $maxm) { if($total <> $maxm)
if(!is_object($db)) { {
$db = $phpgw->db; if(!is_object($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) { {
$p->set_var('string',ucfirst(lang('Users'))); if($users)
$p->parse('row','row_colspan',True); {
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); $p->set_var('string',ucfirst(lang('Users')));
while($db->next_record()) { $p->parse('row','row_colspan',True);
$go = True; $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
if($query) { while($db->next_record())
$name = ' '.$db->f('account_firstname').' '.$db->f('account_lastname').' '.$db->f('account_lid').' '; {
if(!strpos($name,$query)) { $go = True;
$go = False; if($query)
} {
} $name = ' '.$db->f('account_firstname').' '.$db->f('account_lastname').' '.$db->f('account_lid').' ';
if($go) { if(!strpos($name,$query))
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); {
$id = $db->f('account_id'); $go = False;
display_row($tr_color,'u_',$id,$phpgw->common->grab_owner_name($id)); }
$s_users++; }
$processed[] = $id;
$total++; if($go)
if($total == $maxm) break; {
} $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
} $id = $db->f('account_id');
} display_row($tr_color,'u_',$id,$phpgw->common->grab_owner_name($id));
} $s_users++;
} $processed[] = $id;
$total++;
if($total == $maxm)
{
break;
}
}
}
}
}
}
$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));
$p->set_var('nmr',$phpgw->nextmatchs->right('',$start,$totalentries,$extra_parms));
$p->set_var('search_value',(isset($query) && $query?$query:'')); $var = Array(
$p->set_var('search',lang('search')); '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($var);
$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,282 +14,375 @@
/* $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
);
$phpgw_info['flags'] = $phpgw_flags;
include("../header.inc.php"); include('../header.inc.php');
$sb = CreateObject("phpgwapi.sbox"); $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;
$p->set_var('field',$field);
$p->set_var('data',$data);
$p->parse('output','list',True);
}
$phpgw->template->set_var("field",$field); if ($phpgw_info['user']['preferences']['common']['timeformat'] == '12')
$phpgw->template->set_var("data",$data); {
$phpgw->template->parse("output","list",True); $hourformat = 'h';
} }
else
{
$hourformat = 'H';
}
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { if ($id > 0)
$hourformat = "h"; {
} else { $cal = $phpgw->calendar->getevent(intval($id));
$hourformat = "H"; $cal_info = $cal[0];
}
if(!isset($owner)) { $can_edit = False;
$owner = $phpgw_info['user']['account_id'];
} else { if(($cal_info->owner == $owner) || ($phpgw->calendar->check_perms(PHPGW_ACL_EDIT) == True))
$owner = $phpgw_info['user']['account_id']; {
} $can_edit = True;
}
if ($id > 0) { if($can_edit == False)
$cal = $phpgw->calendar->getevent(intval($id)); {
$cal_info = $cal[0]; header('Location: '.$phpgw->link('view.php','id='.$id.'&owner='.$owner));
}
$can_edit = false; if($cal_info->rpt_end_use == False)
if(($cal_info->owner == $phpgw_info["user"]["account_id"]) || $phpgw_info["user"]["apps"]["admin"]) {
$can_edit = true; $cal_info->rpt_end = $cal_info->datetime + 86400;
}
}
elseif(isset($readsess))
{
$data = $phpgw->session->appsession('entry','calendar');
$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));
}
if(!$cal_info->rpt_end_use) { $cal_info->id = 0;
$cal_info->rpt_end = $cal_info->datetime + 86400; $cal_info->owner = $owner;
} $can_edit = True;
} else if(isset($readsess)) {
$cal_info = $phpgw->common->appsession('entry','calendar');
if(!$cal_info->owner) $cal_info->owner = $owner;
$can_edit = true;
} else {
$cal_info->id = 0;
$cal_info->owner = $owner;
$can_edit = true;
if (!isset($day) || !$day) if (!isset($hour))
$thisday = (int)$phpgw->calendar->today["day"]; {
else $thishour = 0;
$thisday = $day; }
if (!isset($month) || !$month) else
$thismonth = (int)$phpgw->calendar->today["month"]; {
else $thishour = (int)$hour;
$thismonth = $month; }
if (!isset($year) || !$year)
$thisyear = (int)$phpgw->calendar->today["year"]; if (!isset($minute))
else {
$thisyear = $year; $thisminute = 00;
}
else
{
$thisminute = (int)$minute;
}
if (!isset($hour)) $datetime = $phpgw->calendar->makegmttime($thishour,$thisminute,0,$thismonth,$thisday,$thisyear);
$thishour = 0; $cal_info->datetime = $datetime['raw'];
else $cal_info->edatetime = $cal_info->datetime;
$thishour = (int)$hour; $cal_info->name = "";
if (!isset($minute)) $cal_info->description = "";
$thisminute = 00; $cal_info->priority = 2;
else
$thisminute = (int)$minute;
$cal_info->datetime = mktime($thishour,$thisminute,0,$thismonth,$thisday,$thisyear) - ((60 * 60) * $phpgw_info["user"]["preferences"]["common"]["tz_offset"]); $cal_info->rpt_end = $cal_info->datetime + 86400;
$cal_info->edatetime = $cal_info->datetime; }
$cal_info->name = "";
$cal_info->description = "";
$cal_info->priority = 2;
$cal_info->rpt_end = $cal_info->datetime + 86400; $phpgw->common->phpgw_header();
} echo parse_navbar();
$phpgw->template->set_file(array("edit_entry_begin" => "edit.tpl", $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('calendar'));
"list" => "list.tpl", $templates = Array(
"hr" => "hr.tpl", 'edit_entry_begin'=> 'edit.tpl',
"edit_entry_end" => "edit.tpl", 'list' => 'list.tpl',
"form_button" => "form_button_script.tpl")); 'hr' => 'hr.tpl',
'edit_entry_end' => 'edit.tpl',
'form_button' => 'form_button_script.tpl'
);
$p->set_file($templates);
$phpgw->template->set_block("edit_entry_begin","list","hr","edit_entry_end","form_button"); // $p->set_block('edit_entry_begin','list','hr','edit_entry_end','form_button');
$phpgw->template->set_var("bg_color",$phpgw_info["theme"]["bg_text"]); if($id > 0)
if($id) {
$phpgw->template->set_var("calendar_action",lang("Calendar - Edit")); $action = lang('Calendar - Edit');
else }
$phpgw->template->set_var("calendar_action",lang("Calendar - Add")); else
{
$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(
$phpgw->template->set_var("common_hidden",$common_hidden); 'bg_color' => $phpgw_info['theme']['bg_text'],
'calendar_action' => $action,
$phpgw->template->parse("out","edit_entry_begin"); 'action_url' => $phpgw->link('edit_entry_handler.php'),
'common_hidden' => $common_hidden
);
$p->set_var($vars);
$p->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
$accounts = $phpgw->acl->get_ids_for_location('run',1,'calendar'); // Start Here.....
$users = Array(); $accounts = $phpgw->acl->get_ids_for_location('run',1,'calendar');
for($i=0;$i<count($accounts);$i++) { $users = Array();
switch ($phpgw->accounts->get_type($accounts[$i])) { for($i=0;$i<count($accounts);$i++)
case 'u' : {
if($accounts[$i] != $owner && !$users[$accounts[$i]]) { $user = $accounts[$i];
$users[$accounts[$i]] = $phpgw->common->grab_owner_name($accounts[$i]); if($user != $owner && !isset($users[$user]))
} {
break; $users[$user] = $phpgw->common->grab_owner_name($user);
case 'g' : if($phpgw->accounts->get_type($user) == 'g')
$group_members = $phpgw->acl->get_ids_for_location($accounts[$i],1,'phpgw_group'); {
while($group_members && $user = each($group_members)) { $group_members = $phpgw->acl->get_ids_for_location($user,1,'phpgw_group');
if($user[1] != $owner && !$users[$user[1]]) { if($group_members != False)
$users[$user[1]] = $phpgw->common->grab_owner_name($user[1]); {
} for($j=0;$j<count($group_members);$j++)
} {
break; if($group_members[$j] != $owner && !isset($users[$group_members[$j]]))
} {
} $users[$group_members[$j]] = $phpgw->common->grab_owner_name($group_members[$j]);
}
}
}
}
}
}
$num_users = count($users); if ($num_users > 50)
if ($num_users > 50) { {
$size = 15; $size = 15;
} else if ($num_users > 5) { }
$size = 5; elseif ($num_users > 5)
} else { {
$size = $num_users; $size = 5;
} }
$str = "<select name=\"cal[participants][]\" multiple size=\"5\">"; else
for ($l=0;$l<count($cal_info->participants);$l++) { {
$parts[$cal_info->participants[$l]] = True; $size = $num_users;
} }
$str = "\n".' <select name="cal[participants][]" multiple size="5">'."\n";
for ($l=0;$l<count($cal_info->participants);$l++)
{
$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++)
$participate = True; {
if($cal_info->participants[$i] == $owner)
{
$participate = True;
}
}
} }
} $str = '<input type="checkbox" name="cal[participants][]" value="'.$owner.'"';
} if((($id > 0) && ($participate == True)) || !isset($id))
$str = "<input type=\"checkbox\" name=\"cal[participants][]\" value=\"".$phpgw_info["user"]["account_id"]."\""; {
if(($id && $participate) || !$id) { $str .= ' checked';
$str .= " checked"; }
} $str .= '>';
$str .= ">"; display_item($phpgw->common->grab_owner_name($owner).' '.lang('Participates'),$str);
display_item(lang("I Participate"),$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',
$str .= "</select>"; 'monthlybydate',
display_item(lang("Repeat Type"),$str); '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 .= '>'.lang($rpt_type_out[$rpt_type_str[$l]]).'</option>';
}
$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")." "; 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"))); $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"))); $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"))); $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
} {
$phpgw->common->phpgw_footer(); $p->set_var('delete_button','');
} $p->pparse('out','edit_entry_end');
}
$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; {
// do a little form verifying $error = 0;
if ($cal_info->name == "") { // do a little form verifying
$error = 40; if ($cal_info->name == '')
} elseif (($cal_info->hour < 0 || $cal_info->hour > 23) || ($cal_info->end_hour < 0 || $cal_info->end_hour > 23)) { {
$error = 41; $error = 40;
} elseif (($cal_info->minute < 0 || $cal_info->minute > 59) || ($cal_info->end_minute < 0 || $cal_info->minute > 59)) { }
$error = 41; elseif (($cal_info->hour < 0 || $cal_info->hour > 23) || ($cal_info->end_hour < 0 || $cal_info->end_hour > 23))
} 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; $error = 41;
} 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) { elseif (($cal_info->minute < 0 || $cal_info->minute > 59) || ($cal_info->end_minute < 0 || $cal_info->minute > 59))
$error = 42; {
} elseif (($cal_info->hour == $cal_info->end_hour) && ($cal_info->minute > $cal_info->end_minute)) { $error = 41;
$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)) { {
$error = 42; $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) && ($cal_info->month == $cal_info->end_month) && ($cal_info->day == $cal_info->end_day))
} elseif ($cal_info->year > $cal_info->end_year) { {
$error = 42; if ($cal_info->hour > $cal_info->end_hour)
} {
return $error; $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;
}
if(!isset($readsess)) { if(!isset($readsess))
for(reset($cal);$key=key($cal);next($cal)) { {
$data = $cal[$key]; for(reset($cal);$key=key($cal);next($cal))
$cal_info->set($key,$data); {
} $data = $cal[$key];
$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") { $cal_info->hour += 12;
if ($cal_info->hour <> 12) { }
$cal_info->hour += 12; }
} elseif ($cal_info->ampm == 'am')
} elseif ($cal_info->ampm == "am") { {
if ($cal_info->hour == 12) { 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) {
$cal_info->end_hour += 12; if ($cal_info->end_ampm == 'pm')
} {
} elseif ($cal_info->end_ampm == "am") { if ($cal_info->end_hour <> 12)
if ($cal_info->end_hour == 12) { {
$cal_info->end_hour -= 12; $cal_info->end_hour += 12;
} }
} }
} elseif ($cal_info->end_ampm == 'am')
$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"]); {
$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"]); if ($cal_info->end_hour == 12)
$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"]); {
$cal_info->end_hour -= 12;
}
}
}
$datetime = $phpgw->calendar->makegmttime($cal_info->hour,$cal_info->minute,0,$cal_info->month,$cal_info->day,$cal_info->year);
$cal_info->datetime = $datetime['raw'];
$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 = ""; }
}
} if ($cal_info->end_hour >= 12)
$cal_info->datetime += ((60 * 60) * $phpgw_info["user"]["preferences"]["common"]["tz_offset"]); {
$cal_info->edatetime += ((60 * 60) * $phpgw_info["user"]["preferences"]["common"]["tz_offset"]); $cal_info->end_ampm = '';
$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');
} $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) { if($datetime_check)
Header("Location: ".$phpgw->link("edit_entry.php","readsess=".$cal_info->id."&cd=".$datetime_check)); {
$phpgw->common->phpgw_exit(); Header('Location: '.$phpgw->link('edit_entry.php','readsess='.$cal_info->id.'&cd='.$datetime_check));
} elseif($overlapping_events) { $phpgw->common->phpgw_exit();
$phpgw->common->phpgw_header(); }
echo parse_navbar(); elseif($overlapping_events)
$phpgw->template->set_file(array("overlap" => "overlap.tpl", {
"form_button" => "form_button_script.tpl")); $phpgw->common->phpgw_header();
echo parse_navbar();
$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"; if ($phpgw_info['user']['preferences']['common']['timeformat'] == '12')
} else { {
$format .= "H:i:s"; $format .= 'h:i:s a';
} }
else
{
$format .= 'H:i:s';
}
$overlap = ""; $overlap = '';
for($i=0;$i<count($calendar_overlaps);$i++) { for($i=0;$i<count($calendar_overlaps);$i++)
$cal_over = $calendar_overlaps[$i]; {
if($cal_over) { $cal_over = $calendar_overlaps[$i];
$overlap .= "<li>"; if($cal_over)
$private = $phpgw->calendar->is_private($cal_over,$cal_over->owner); {
if(strtoupper($private) == "PRIVATE") $overlap .= '<li>';
$overlap .= "(PRIVATE)"; $private = $phpgw->calendar->is_private($cal_over,$cal_over->owner);
else
$overlap .= $phpgw->calendar->link_to_entry($cal_over->id,"circle.gif",$cal_over->description).$cal_over->name; if(strtoupper($private) == 'PRIVATE')
$overlap .= " (".$phpgw->common->show_date($cal_over->datetime)." - ".$phpgw->common->show_date($cal_over->edatetime).")<br>"; {
} $overlap .= '(PRIVATE)';
} }
if(strlen($overlap)) { else
$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); $overlap .= $phpgw->calendar->link_to_entry($cal_over->id,'circle.gif',$cal_over->description).$cal_over->name;
} else { }
$phpgw->template->set_var("overlap_text","");
$phpgw->template->set_var("overlap_list",""); $overlap .= ' ('.$phpgw->common->show_date($cal_over->datetime).' - '.$phpgw->common->show_date($cal_over->edatetime).')<br>';
} }
}
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' => ''
);
}
$phpgw->template->set_var("action_url_button",$phpgw->link("","readsess=".$cal_info->id)); $p->set_var($var);
$phpgw->template->set_var("action_text_button",lang("Ignore Conflict"));
$phpgw->template->set_var("action_confirm_button","");
$phpgw->template->parse("resubmit_button","form_button");
$phpgw->template->set_var("action_url_button",$phpgw->link("edit_entry.php","readsess=".$cal_info->id)); $var = Array(
$phpgw->template->set_var("action_text_button",lang("Re-Edit Event")); 'action_url_button' => $phpgw->link('','readsess='.$cal_info->id),
$phpgw->template->set_var("action_confirm_button",""); 'action_text_button' => lang('Ignore Conflict'),
$phpgw->template->parse("reedit_button","form_button"); 'action_confirm_button' => ''
);
$p->set_var($var);
$phpgw->template->pparse("out","overlap"); $p->parse('resubmit_button','form_button');
} else {
$phpgw->calendar->add($cal_info,$cal_info->id); $var = Array(
Header("Location: ".$phpgw->link("index.php","year=$year&month=$month&cd=14")); 'action_url_button' => $phpgw->link('edit_entry.php','readsess='.$cal_info->id),
} 'action_text_button' => lang('Re-Edit Event'),
$phpgw->common->phpgw_footer(); '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);
Header('Location: '.$phpgw->link('index.php','year='.$year.'&month='.$month.'&cd=14&owner='.$owner));
}
$phpgw->common->phpgw_footer();
?> ?>

View File

@ -14,110 +14,112 @@
/* $Id$ */ /* $Id$ */
class calendar_ class calendar_
{ {
var $stream; var $stream;
var $user; var $user;
var $printer_friendly = False; var $printer_friendly = False;
var $owner; var $owner;
var $rights; var $rights;
var $cal_event; var $cal_event;
var $today = Array('raw','day','month','year','full','dow','dm','bd'); var $today = Array('raw','day','month','year','full','dow','dm','bd');
var $repeated_events; var $repeated_events;
var $checked_events; var $checked_events;
var $re = 0; var $re = 0;
var $checkd_re = 0; var $checkd_re = 0;
var $sorted_re = 0; var $sorted_re = 0;
var $hour_arr = Array(); var $hour_arr = Array();
var $rowspan_arr = Array(); var $rowspan_arr = Array();
var $days = Array(); var $days = Array();
var $first_hour; var $first_hour;
var $last_hour; var $last_hour;
var $rowspan; var $rowspan;
var $weekstarttime; var $weekstarttime;
var $daysinweek = 7; var $daysinweek = 7;
var $filter; var $filter;
var $tempyear; var $tempyear;
var $tempmonth; var $tempmonth;
var $tempday; var $tempday;
function open($calendar='',$user='',$passwd='',$options='') function open($calendar='',$user='',$passwd='',$options='')
{ {
global $phpgw, $phpgw_info; global $phpgw, $phpgw_info;
$this->stream = $phpgw->db; $this->stream = $phpgw->db;
if($user=='') if($user=='')
{ {
$this->user = $phpgw_info['user']['account_id']; $this->user = $phpgw_info['user']['account_id'];
} }
elseif(is_int($user)) elseif(is_int($user))
{ {
$this->user = $user; $this->user = $user;
} }
elseif(is_string($user)) elseif(is_string($user))
{ {
$this->user = $phpgw->accounts->name2id($user); $this->user = $phpgw->accounts->name2id($user);
} }
return $this->stream;
} return $this->stream;
function popen($calendar='',$user='',$passwd='',$options='')
{
return $this->open($calendar,$user,$passwd,$options);
} }
function reopen($calendar,$options='') function popen($calendar='',$user='',$passwd='',$options='')
{ {
return $this->stream; return $this->open($calendar,$user,$passwd,$options);
} }
function reopen($calendar,$options='')
{
return $this->stream;
}
function close($mcal_stream,$options='') function close($mcal_stream,$options='')
{ {
return True; return True;
} }
function create_calendar($stream='',$calendar='') function create_calendar($stream='',$calendar='')
{ {
return $calendar; return $calendar;
} }
function rename_calendar($stream='',$old_name='',$new_name='') function rename_calendar($stream='',$old_name='',$new_name='')
{ {
return $new_name; return $new_name;
} }
function delete_calendar($stream='',$calendar='') function delete_calendar($stream='',$calendar='')
{ {
return $calendar; return $calendar;
} }
function fetch_event($mcal_stream,$event_id,$options='') function fetch_event($mcal_stream,$event_id,$options='')
{ {
if(!isset($this->stream)) if(!isset($this->stream))
{ {
return False; return False;
} }
$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->stream->next_record(); $this->cal_event = CreateObject('calendar.calendar_item');
// Load the calendar event data from the db into the cal_event structure $this->stream->next_record();
// Use http://www.php.net/manual/en/function.mcal-fetch-event.php as the reference // Load the calendar event data from the db into the cal_event structure
} // Use http://www.php.net/manual/en/function.mcal-fetch-event.php as the reference
else }
{ else
$this->cal_event = False; {
} $this->cal_event = False;
}
$this->stream->unlock(); $this->stream->unlock();
return $this->cal_event; return $this->cal_event;
} }
// End of ICal style support....... // End of ICal style support.......
@ -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'));