diff --git a/calendar/inc/class.boalarm.inc.php b/calendar/inc/class.boalarm.inc.php index 678afd34ec..8ec2a4f3d5 100755 --- a/calendar/inc/class.boalarm.inc.php +++ b/calendar/inc/class.boalarm.inc.php @@ -85,6 +85,7 @@ */ function add(&$event,$time,$owner) { + //echo "

boalarm::add(event="; print_r($event); ",time=$time,owner=$owner)

\n"; if (!$this->check_perms(PHPGW_ACL_SETALARM,$owner) || !($cal_id = $event['id'])) { return False; @@ -96,7 +97,6 @@ 'enabled' => 1 ); $alarm['id'] = $this->so->save_alarm($cal_id,$alarm); - $event['alarm'][$alarm['id']] = $alarm; return $alarm; diff --git a/calendar/inc/class.html.inc.php b/calendar/inc/class.html.inc.php deleted file mode 100755 index 17c8513a4f..0000000000 --- a/calendar/inc/class.html.inc.php +++ /dev/null @@ -1,382 +0,0 @@ - * - * -------------------------------------------- * - * This program is free software; you can redistribute it and/or modify it * - * under the terms of the GNU General Public License as published by the * - * Free Software Foundation; either version 2 of the License, or (at your * - * option) any later version. * - \**************************************************************************/ - - /* $Id$ */ - -class html -{ - var $user_agent,$ua_version; // 'mozilla','msie','konqueror' - var $prefered_img_title; - - function html() - { // should be Ok for all HTML 4 compatible browsers - if (!eregi('compatible; ([a-z_]+)[/ ]+([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts)) - { - eregi('^([a-z_]+)/([0-9.]+)',$_SERVER['HTTP_USER_AGENT'],$parts); - } - list(,$this->user_agent,$this->ua_version) = $parts; - $this->user_agent = strtolower($this->user_agent); - - $this->prefered_img_title = $this->user_agent == 'mozilla' && $this->ua_version < 5 ? 'ALT' : 'TITLE'; - //echo "

HTTP_USER_AGENT='$GLOBALS[HTTP_USER_AGENT]', UserAgent: '$this->user_agent', Version: '$this->ua_version', img_title: '$this->prefered_img_title'

\n"; - } - - /* - * Function: Allows to show and select one item from an array - * Parameters: $name string with name of the submitted var which holds the key of the selected item form array - * $key key(s) of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys - * $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe'); - * $no_lang if !$no_lang send items through lang() - * $options additional options (e.g. 'multiple') - * On submit $XXX is the key of the selected item (XXX is the content of $name) - * Returns: string to set for a template or to echo into html page - */ - function select($name, $key, $arr=0,$no_lang=0,$options='',$multiple=0) - { - // should be in class common.sbox - if (!is_array($arr)) - { - $arr = array('no','yes'); - } - if (intval($multiple) > 0) - { - $options .= ' MULTIPLE SIZE="'.intval($multiple).'"'; - if (substr($name,-2) != '[]') - { - $name .= '[]'; - } - } - $out = "\n"; - - return $out; - } - - function div($content,$options='') - { - return "
\n$content
\n"; - } - - function input_hidden($vars,$value='',$ignore_empty=True) - { - if (!is_array($vars)) - { - $vars = array( $vars => $value ); - } - foreach($vars as $name => $value) - { - if (is_array($value)) - { - $value = serialize($value); - } - if (!$ignore_empty || $value && !($name == 'filter' && $value == 'none')) // dont need to send all the empty vars - { - $html .= "\n"; - } - } - return $html; - } - - function textarea($name,$value='',$options='' ) - { - return "\n"; - } - - function input($name,$value='',$type='',$options='' ) - { - if ($type) - { - $type = 'TYPE="'.$type.'"'; - } - return "\n"; - } - - function submit_button($name,$lang,$onClick='',$no_lang=0,$options='',$image='',$app='') - { - if ($image != '') - { - if (strpos($image,'.')) - { - $image = substr($image,0,strpos($image,'.')); - } - if (!($path = $GLOBALS['phpgw']->common->image($app,$image)) && - !($path = $GLOBALS['phpgw']->common->image('phpgwapi',$image))) - { - $path = $image; // name may already contain absolut path - } - $image = ' SRC="'.$path.'"'; - } - if (!$no_lang) - { - $lang = lang($lang); - } - if (($accesskey = strstr($lang,'&')) && $accesskey[1] != ' ' && - (($pos = strpos($accesskey,';')) === False || $pos > 5)) - { - $lang_u = str_replace('&'.$accesskey[1],''.$accesskey[1].'',$lang); - $lang = str_replace('&','',$lang); - $options = 'ACCESSKEY="'.$accesskey[1].'" '.$options; - } - else - { - $accesskey = ''; - $lang_u = $lang; - } - if ($onClick) $options .= " onClick=\"$onClick\""; - - // '; - } - - /*! - @function link - @abstract creates an absolut link + the query / get-variables - @param $url phpgw-relative link, may include query / get-vars - @parm $vars query or array ('name' => 'value', ...) with query - @example link('/index.php?menuaction=infolog.uiinfolog.get_list',array('info_id' => 123)) - @example = 'http://domain/phpgw-path/index.php?menuaction=infolog.uiinfolog.get_list&info_id=123' - @result absolut link already run through $phpgw->link - */ - function link($url,$vars='') - { - if (!is_array($vars)) - { - $vars = explode('&',$vars); - } - list($url,$v) = explode('?',$url); // url may contain additional vars - if ($v) - { - $vars += explode('&',$v); - } - return $GLOBALS['phpgw']->link($url,$vars); - } - - function checkbox($name,$value='') - { - return "\n"; - } - - function form($content,$hidden_vars,$url,$url_vars='',$name='',$options='',$method='POST') - { - $html = "
link($url,$url_vars)."\" $options>\n"; - $html .= $this->input_hidden($hidden_vars); - - if ($content) - { - $html .= $content; - $html .= "
\n"; - } - return $html; - } - - function form_1button($name,$lang,$hidden_vars,$url,$url_vars='',$form_name='',$method='POST') - { - return $this->form($this->submit_button($name,$lang), - $hidden_vars,$url,$url_vars,$form_name,'',$method); - } - - /*! - @function table - @abstracts creates table from array with rows - @discussion abstract the html stuff - @param $rows array with rows, each row is an array of the cols - @param $options options for the table-tag - @example $rows = array ( '1' => array( 1 => 'cell1', '.1' => 'colspan=3', - @example 2 => 'cell2', 3 => 'cell3', '.3' => 'width="10%"' ), - @example '.1' => 'BGCOLOR="#0000FF"' ); - @example table($rows,'WIDTH="100%"') = '
cell1cell2cell3
' - @result string with html-code of the table - */ - function table($rows,$options = '',$no_table_tr=False) - { - $html = $no_table_tr ? '' : "\n"; - - foreach($rows as $key => $row) - { - if (!is_array($row)) - { - continue; // parameter - } - $html .= $no_table_tr && $key == 1 ? '' : "\t\n"; - - foreach($row as $key => $cell) - { - if ($key[0] == '.') - { - continue; // parameter - } - $table_pos = strpos($cell,'$cell\n"; - } - } - $html .= "\t\n"; - } - $html .= "
\n"; - - if ($no_table_tr) - { - $html = substr($html,0,-16); - } - return $html; - } - - function sbox_submit( $sbox,$no_script=0 ) - { - $html = str_replace('submit_button('send','>').''; - } - return $html; - } - - function image( $app,$name,$title='',$options='' ) - { - if (strstr($name,'.') === False) - { - $name .= '.gif'; - } - if (!($path = $GLOBALS['phpgw']->common->image($app,$name))) - { - $path = $name; // name may already contain absolut path - } - if (!@is_readable($_SERVER['DOCUMENT_ROOT'] . $path)) - { - return $title; - } - if ($title) - { - $options .= " $this->prefered_img_title=\"".htmlspecialchars($title).'"'; - } - return ""; - } - - function a_href( $content,$url,$vars='',$options='') - { - if (!strstr($url,'/') && count(explode('.',$url)) == 3) - { - $url = "/index.php?menuaction=$url"; - } - if (is_array($url)) - { - $vars = $url; - $url = '/index.php'; - } - return ''.$content.''; - } - - function bold($content) - { - return ''.$content.''; - } - - function italic($content) - { - return ''.$content.''; - } - - function hr($width,$options='') - { - if ($width) - $options .= " WIDTH=$width"; - return "
\n"; - } - - /*! - @function formatOptions - @abstract formats option-string for most of the above functions - @param $options String (or Array) with option-values eg. '100%,,1' - @param $names String (or Array) with the option-names eg. 'WIDTH,HEIGHT,BORDER' - @example formatOptions('100%,,1','WIDTH,HEIGHT,BORDER') = ' WIDTH="100%" BORDER="1"' - @result option string - */ - function formatOptions($options,$names) - { - if (!is_array($options)) $options = explode(',',$options); - if (!is_array($names)) $names = explode(',',$names); - - while (list($n,$val) = each($options)) - if ($val != '' && $names[$n] != '') - $html .= ' '.$names[$n].'="'.$val.'"'; - - return $html; - } - - /*! - @function themeStyles - @abstract returns simple stylesheet (incl. " : ''; - } - - function label($content,$id='',$accesskey='',$options='') - { - if ($id != '') - { - $id = " FOR=\"$id\""; - } - if ($accesskey != '') - { - $accesskey = " ACCESSKEY=\"$accesskey\""; - } - return "$content"; - } -} diff --git a/calendar/inc/class.socalendar.inc.php b/calendar/inc/class.socalendar.inc.php index 782ff2d86a..2ef632ab8d 100755 --- a/calendar/inc/class.socalendar.inc.php +++ b/calendar/inc/class.socalendar.inc.php @@ -203,17 +203,17 @@ function save_alarm($cal_id,$alarm,$id=0) { - $this->cal->save_alarm($cal_id,$alarm,$id); + return $this->cal->save_alarm($cal_id,$alarm,$id); } function delete_alarm($id) { - $this->cal->delete_alarm($id); + return $this->cal->delete_alarm($id); } function delete_entry($id) { - $this->cal->delete_event($id); + return $this->cal->delete_event($id); } function expunge() diff --git a/calendar/inc/class.socalendar_sql.inc.php b/calendar/inc/class.socalendar_sql.inc.php index 1321793fa0..1751cb4ac8 100755 --- a/calendar/inc/class.socalendar_sql.inc.php +++ b/calendar/inc/class.socalendar_sql.inc.php @@ -153,6 +153,7 @@ class socalendar_ extends socalendar__ @syntax save_alarm($cal_id,$alarm,$id=False) @param $cal_id Id of the calendar-entry @param $alarm array with fields: text, owner, enabled, .. + @returns the id of the alarm */ function save_alarm($cal_id,$alarm) { diff --git a/calendar/inc/class.uialarm.inc.php b/calendar/inc/class.uialarm.inc.php index 55b3c82b1a..aedf25028a 100755 --- a/calendar/inc/class.uialarm.inc.php +++ b/calendar/inc/class.uialarm.inc.php @@ -47,7 +47,11 @@ } $this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir('calendar'); - $this->html = CreateObject('calendar.html'); + if (!is_object($GLOBALS['phpgw']->html)) + { + $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html'); + } + $this->html = &$GLOBALS['phpgw']->html; } function prep_page() @@ -94,6 +98,10 @@ function manager() { + if ($_POST['cancel']) + { + $GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.($_POST['return_to'] ? $_POST['return_to'] : 'calendar.uicalendar.index')); + } if ($_POST['delete'] && count($_POST['alarm'])) { if ($this->bo->delete($_POST['alarm']) < 0) @@ -159,9 +167,8 @@ //'data' => $alarm['text'], 'data' => lang('Email Notification'), 'owner' => $GLOBALS['phpgw']->common->grab_owner_name($alarm['owner']), - 'enabled' => ($alarm['enabled']?'': - ''), - 'select' => '' + 'enabled' => $this->html->image('calendar',$alarm['enabled']?'enabled':'disabled',$alarm['enabled']?'enabled':'disabled','width="13" height="13"'), + 'select' => $this->html->checkbox("alarm[$alarm[id]]") ); if ($this->bo->check_perms(PHPGW_ACL_DELETEALARM,$alarm['owner'])) { @@ -189,9 +196,13 @@ } $this->template->set_var(Array( 'action_url' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uialarm.manager')), - 'hidden_vars' => $this->html->input_hidden('cal_id',$this->bo->cal_id), + 'hidden_vars' => $this->html->input_hidden(array( + 'cal_id' => $this->bo->cal_id, + 'return_to' => $_POST['return_to'] + )), 'lang_enable' => lang('Enable'), - 'lang_disable' => lang('Disable') + 'lang_disable' => lang('Disable'), + 'input_cancel' => $this->html->submit_button('cancel','Cancel') )); //echo "

alarm_management='".htmlspecialchars($this->template->get_var('alarm_management'))."'

\n"; $this->template->pfp('out','alarm_management'); diff --git a/calendar/inc/class.uicalendar.inc.php b/calendar/inc/class.uicalendar.inc.php index 38f210cea3..ccd5a0e639 100755 --- a/calendar/inc/class.uicalendar.inc.php +++ b/calendar/inc/class.uicalendar.inc.php @@ -33,8 +33,6 @@ var $link_tpl; // planner related variables - var $planner_html; - var $planner_header; var $planner_rows; @@ -133,6 +131,12 @@ $this->always_app_header = $this->bo->prefs['common']['template_set'] == 'idots'; print_debug('UI',$this->_debug_sqsof()); + + if (!is_object($GLOBALS['phpgw']->html)) + { + $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html'); + } + $this->html = &$GLOBALS['phpgw']->html; } /* Public functions */ @@ -730,8 +734,10 @@ 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), 'action_text_button' => lang('Edit Single'), 'action_confirm_button' => '', - 'action_extra_field' => ''."\n" - . '' + 'action_extra_field' => $this->html->input_hidden(array( + 'edit_type' => 'single', + 'date' => sprintf('%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day) + )) ); $p->set_var($var); $button_left .= ''.$p->fp('button','form_button').''; @@ -740,7 +746,7 @@ 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), 'action_text_button' => lang('Edit Series'), 'action_confirm_button' => '', - 'action_extra_field' => '' + 'action_extra_field' => $this->html->input_hidden('edit_type','series') ); $p->set_var($var); $button_left .= ''.$p->fp('button','form_button').''; @@ -761,7 +767,10 @@ 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), 'action_text_button' => lang('Alarm Management'), 'action_confirm_button' => '', - 'action_extra_field' => '' + 'action_extra_field' => $this->html->input_hidden(array( + 'cal_id' => $cal_id, + 'return_to' => $this->bo->return_to + )) ); $p->set_var($var); $button_center .= ''.$p->fp('button','form_button').''; @@ -775,8 +784,10 @@ 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), 'action_text_button' => lang('Delete Single'), 'action_confirm_button' => "onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this single occurence ?\\n\\nThis will delete\\nthis entry for all users.")."')\"", - 'action_extra_field' => '' - . '' + 'action_extra_field' => $this->html->input_hidden(array( + 'delete_type' => 'single', + 'date' => sprintf('%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day) + )) ); $p->set_var($var); $button_right .= ''.$p->fp('button','form_button').''; @@ -785,7 +796,7 @@ 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), 'action_text_button' => lang('Delete Series'), '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.")."')\"", - 'action_extra_field' => '' + 'action_extra_field' => $this->html->input_hidden('delete_type','series') ); $p->set_var($var); $button_right .= ''.$p->fp('button','form_button').''; @@ -827,7 +838,10 @@ 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), 'action_text_button' => lang('Alarm Management'), 'action_confirm_button' => '', - 'action_extra_field' => '' + 'action_extra_field' => $this->html->input_hidden(array( + 'cal_id' => $cal_id, + 'return_to' => $this->bo->return_to + )) ); $p->set_var($var); echo $p->fp('out','form_button'); @@ -839,7 +853,7 @@ 'action_url_button' => $this->page('export'), 'action_text_button' => lang('Export'), 'action_confirm_button' => '', - 'action_extra_field' => '' + 'action_extra_field' => $this->html->input_hidden('cal_id',$cal_id) ); $p->set_var($var); $button_center .= ''.$p->fp('button','form_button').''; @@ -993,11 +1007,11 @@ } if ($this->bo->return_to) { - Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); + $GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->bo->return_to); } else { - Header('Location: '.$this->index()); + $GLOBALS['phpgw']->redirect($this->index()); } $GLOBALS['phpgw']->common->phpgw_exit(); } @@ -1320,10 +1334,6 @@ { if (is_array($todos) && count($todos)) { - if (!is_object($GLOBALS['phpgw']->html)) - { - $GLOBALS['phpgw']->html = CreateObject('calendar.html'); - } foreach($todos as $todo) { $icons = ''; @@ -1332,7 +1342,7 @@ $icons .= ($icons?' ':'').$GLOBALS['phpgw']->html->image($app,$name,lang($name),'border="0" width="15" height="15"'); } $class = $class == 'row_on' ? 'row_off' : 'row_on'; - $content .= " \n ". + $content .= " \n ". ($this->bo->printer_friendly?$icons:$GLOBALS['phpgw']->html->a_href($icons,$todo['view'])). "\n ".($this->bo->printer_friendly?$todo['title']: $GLOBALS['phpgw']->html->a_href($todo['title'],$todo['view']))."\n \n"; @@ -1342,8 +1352,7 @@ } if (!empty($content)) { - //echo "todos=\n$content
\n"; - return "\n$content
\n"; + return "\n$content
\n"; } return False; } @@ -1510,7 +1519,6 @@ // create/initialize variables directly used for HTML code generation // - $this->planner_html = CreateObject('calendar.html'); $this->planner_header = array(); $this->planner_rows = array(); @@ -1582,7 +1590,7 @@ $hdr[2]['.'.$index] .= " bgcolor=\"$color\""; - $hdr[2][$index] = 'html->link('/index.php', array( 'menuaction' => 'calendar.uicalendar.add', 'date' => $date @@ -1661,7 +1669,7 @@ $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; $is_private = !$this->bo->check_perms(PHPGW_ACL_READ,$event); - $view = $this->planner_html->link('/index.php', + $view = $this->html->link('/index.php', array( 'menuaction' => 'calendar.uicalendar.view', 'cal_id' => $event['id'], @@ -1782,13 +1790,13 @@ if ($event['priority'] == 3) { - $cel .= $this->planner_html->image('calendar','mini-calendar-bar.gif','','border="0"'); + $cel .= $this->html->image('calendar','mini-calendar-bar.gif','','border="0"'); } if ($event['recur_type']) { - $cel .= $this->planner_html->image('calendar','recur.gif','','border="0"'); + $cel .= $this->html->image('calendar','recur.gif','','border="0"'); } - $cel .= $this->planner_html->image('calendar',count($event['participants'])>1?'multi_3.gif':'single.gif',$this->planner_participants($event['participants']),'border="0"'); + $cel .= $this->html->image('calendar',count($event['participants'])>1?'multi_3.gif':'single.gif',$this->planner_participants($event['participants']),'border="0"'); $cel .= ''; if (isset($event['print_title']) && $event['print_title'] == 'yes') @@ -1948,7 +1956,7 @@ _debug_array($this->planner_rows); reset($this->planner_rows); } - return $this->planner_html->table( + return $this->html->table( array( '_hdr0' => $this->planner_header[0], '._hdr0' => $bgcolor, diff --git a/calendar/templates/default/alarm.tpl b/calendar/templates/default/alarm.tpl index 7f30c013d3..568028dfa5 100755 --- a/calendar/templates/default/alarm.tpl +++ b/calendar/templates/default/alarm.tpl @@ -4,8 +4,10 @@ {hidden_vars} {rows} -
-
 {input_days} {input_hours} {input_minutes} {input_owner} {input_add}
  +
+
 {input_days} {input_hours} {input_minutes} {input_owner} {input_add}
  +
+ {input_cancel}