Remove some unused code

This commit is contained in:
Nathan Gray 2016-03-14 19:36:22 +00:00
parent 87edf6608c
commit 70b00c8d70
5 changed files with 9 additions and 578 deletions

View File

@ -214,28 +214,6 @@ class calendar_ui
return false;
}
/**
* show the egw-framework plus evtl. $this->group_warning from check_owner_access
*/
function do_header()
{
// Include the jQuery-UI CSS - many more complex widgets use it
$theme = 'redmond';
egw_framework::includeCSS("/phpgwapi/js/jquery/jquery-ui/$theme/jquery-ui-1.10.3.custom.css");
// Load our CSS after jQuery-UI, so we can override it
egw_framework::includeCSS('/etemplate/templates/default/etemplate2.css');
// load etemplate2
egw_framework::validate_file('/etemplate/js/etemplate2.js');
// load our app.js file
egw_framework::validate_file('/calendar/js/app.js');
common::egw_header();
if ($this->bo->warnings) echo '<pre class="message" align="center">'.html::htmlspecialchars(implode("\n",$this->bo->warnings))."</pre>\n";
}
/**
* Manages the states of certain controls in the UI: date shown, category selected, ...
*
@ -473,24 +451,6 @@ class calendar_ui
return $icons;
}
/**
* Create a select-box item in the sidebox-menu
* @privat used only by sidebox_menu !
*/
function _select_box($title,$name,$options,$width='99%')
{
$select = " <select style=\"width: $width;\" name=\"".$name.'" id="calendar_'.$name.'" title="'.
lang('Select a %1',lang($title)).'">'.
$options."</select>\n";
return array(
'text' => $select,
'no_lang' => True,
'link' => False,
'icon' => false,
);
}
/**
* Generate a link to add an event, incl. the necessary popup
*
@ -515,21 +475,6 @@ class calendar_ui
. '" title="'.html::htmlspecialchars(lang('Add')).'"');
}
/**
* returns javascript to open a popup window: window.open(...)
*
* @param string $link link or this.href
* @param string $target name of target or this.target
* @param int $width width of the window
* @param int $height height of the window
* @return string javascript (using single quotes)
*/
function popup($link,$target='_blank',$width=750,$height=410)
{
return 'egw_openWindowCentered2('.($link == 'this.href' ? $link : "'".$link."'").','.
($target == 'this.target' ? $target : "'".$target."'").",$width,$height,'yes')";
}
/**
* creates the content for the sidebox-menu, called as hook
*/
@ -793,6 +738,14 @@ class calendar_ui
}
}
/**
* Merge calendar events into a document
*
* Checks $_GET['merge'] for the document, and $timespan for the date range.
* If timespan is not provided, we try to guess based on the document name.
*
* @param Array $timespan
*/
public function merge($timespan = array())
{
// Merge print

View File

@ -2414,110 +2414,6 @@ class calendar_uiforms extends calendar_ui
return $freetime_daywise;
}
/**
* Export events as vCalendar version 2.0 files (iCal)
*
* @param int|array $content numeric cal_id or submitted content from etempalte::exec
* @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
* @return string error-msg if $return_error
*/
function export($content=0,$return_error=false)
{
$boical = new calendar_ical();
#error_log(__METHOD__.print_r($content,true));
if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id']))
{
if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false)))
{
$msg = lang('Permission denied');
if ($return_error) return $msg;
}
else
{
html::content_header('event.ics','text/calendar',bytes($ical));
echo $ical;
common::egw_exit();
}
}
if (is_array($content))
{
$events =& $this->bo->search(array(
'start' => $content['start'],
'end' => $content['end'],
'enum_recuring' => false,
'daywise' => false,
'owner' => $this->owner,
'date_format' => 'server', // timestamp in server time for boical class
));
if (!$events)
{
$msg = lang('No events found');
}
else
{
$ical =& $boical->exportVCal($events,'2.0','PUBLISH',false);
html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical));
echo $ical;
common::egw_exit();
}
}
if (!is_array($content))
{
$content = array(
'start' => $this->bo->date2ts($_REQUEST['start'] ? $_REQUEST['start'] : $this->date),
'end' => $this->bo->date2ts($_REQUEST['end'] ? $_REQUEST['end'] : $this->date),
'file' => 'event.ics',
'version' => '2.0',
);
}
$content['msg'] = $msg;
$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export');
$etpl = new etemplate_new('calendar.export');
$etpl->exec('calendar.calendar_uiforms.export',$content);
}
/**
* Import events as vCalendar version 2.0 files (iCal)
*
* @param array $content submitted content from etempalte::exec
*/
function import($content=null)
{
if (is_array($content))
{
if (is_array($content['ical_file']) && is_uploaded_file($content['ical_file']['tmp_name']))
{
@set_time_limit(0); // try switching execution time limit off
$start = microtime(true);
$calendar_ical = new calendar_ical;
$calendar_ical->setSupportedFields('file', '');
if (!$calendar_ical->importVCal($f=fopen($content['ical_file']['tmp_name'],'r')))
{
$msg = lang('Error: importing the iCal');
}
else
{
$msg = lang('iCal successful imported').' '.lang('(%1 events in %2 seconds)',
$calendar_ical->events_imported,number_format(microtime(true)-$start,1));
}
if ($f) fclose($f);
}
else
{
$msg = lang('You need to select an iCal file first');
}
}
$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Import');
$etpl = new etemplate_new('calendar.import');
$etpl->exec('calendar.calendar_uiforms.import', array(
'msg' => $msg,
));
}
/**
* Edit category ACL (admin only)
*

View File

@ -65,27 +65,6 @@ class calendar_uilist extends calendar_ui
$this->check_owners_access();
}
/**
* Show the calendar on the home page
*
* @return string with content
*/
function &home()
{
// set the defaults for the home-page
$this->__construct(array(
'date' => $this->bo->date2string($this->bo->now_su),
'cat_id' => 0,
'filter' => 'default',
'owner' => $this->user,
'multiple' => 0,
'view' => $this->bo->cal_prefs['mainscreen_showevents'],
));
egw_session::appsession('calendar_list','calendar',''); // in case there's already something set
return $this->listview(null,'',true);
}
/**
* Show the listview
*/
@ -460,13 +439,11 @@ class calendar_uilist extends calendar_ui
}
elseif ($event['recur_type'] != MCAL_RECUR_NONE)
{
$event['edit_link'] = "edit_series({$event['id']}, {$event['start']});return false;";
$event['app_id'] .= ':'.egw_time::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts');
}
else
{
$view_link = egw::link('/index.php',array('menuaction'=>'calendar.calendar_uiforms.edit','cal_id'=>$event['id'],'date'=>$this->bo->date2string($event['start'])));
$event['edit_link'] = $this->popup($view_link).'; return false;';
}
// Format start and end with timezone

View File

@ -27,12 +27,6 @@
class calendar_uiviews extends calendar_ui
{
var $public_functions = array(
'day' => True,
'day4' => True,
'week' => True,
'weekN' => True,
'month' => True,
'planner' => True,
'index' => True,
);
@ -43,13 +37,6 @@ class calendar_uiviews extends calendar_ui
*/
var $debug=false;
/**
* minimum width for an event
*
* @var int
*/
var $eventCol_min_width = 80;
/**
* extra rows above and below the workday
*
@ -202,7 +189,7 @@ class calendar_uiviews extends calendar_ui
}
/**
* Show the last view or the default one, if no last
* Load all views used by calendar, client side switches between them as needed
*/
function index($content=array())
{
@ -405,59 +392,6 @@ class calendar_uiviews extends calendar_ui
return $actions;
}
/**
* Show the calendar on the home page
*
* @return string with content
*/
function &home()
{
// set some stuff for the home-page
$this->__construct(array(
'date' => $this->bo->date2string($this->bo->now_su),
'cat_id' => 0,
'filter' => 'default',
'owner' => $this->user,
'multiple' => 0,
'view' => $this->bo->cal_prefs['mainscreen_showevents'],
));
if (($error = $this->check_owners_access()))
{
return $error;
}
if ($this->group_warning)
{
$group_warning = '<p class="message" align="center">'.$this->group_warning."</p>\n";
}
switch($this->cal_prefs['mainscreen_showevents'])
{
case 'planner_user':
case 'planner_cat':
case 'planner':
return $group_warning.$this->planner(true);
case 'year':
return $group_warning.$this->year(true);
case 'month':
return $group_warning.$this->month(0,true);
case 'weekN':
return $group_warning.$this->weekN(true);
default:
case 'week':
return $group_warning.$this->week(0,true);
case 'day':
return $group_warning.$this->day(true);
case 'day4':
return $group_warning.$this->week(4,true);
}
}
/**
* Displays the planner view
*
@ -538,18 +472,6 @@ class calendar_uiviews extends calendar_ui
$tmpl->exec(__METHOD__, $content);
}
/**
* Displays a multiple week-view
*
* @param boolean|etemplate2 $home = false if not false return content suitable for home-page
*/
function &weekN($home=false)
{
if (($num = (int)$this->cal_prefs['multiple_weeks']) < 2) $num = 3; // default 3 weeks
return $this->month($num,$home);
}
/**
* Displays the monthview or a multiple week-view
*
@ -658,38 +580,6 @@ class calendar_uiviews extends calendar_ui
$last = $this->bo->date2ts($last);
}
/**
* Get start and end of a year aligned to full months
*
* @param int &$first timestamp 0h of first day of week containing the first of the current year
* @param int &$last timestamp 23:59:59 of last day of week containg the last day of the current year
*/
function _month_align_year(&$first,&$last)
{
$first = $this->datetime->get_weekday_start($this->year,$this->month=1,$this->day=1);
$last = $this->datetime->get_weekday_start($this->year,$this->month+12,
$this->datetime->days_in_month($this->month+12,$this->year));
// now we need to calculate the end of the last day of that week
// as simple $last += WEEK_s - 1; does NOT work, if daylight saving changes in that week!!!
$last = $this->bo->date2array($last);
$last['day'] += 6;
$last['hour'] = 23;
$last['min'] = $last['sec'] = 59;
unset($last['raw']); // otherwise date2ts does not calc raw new, but uses it
$last = $this->bo->date2ts($last);
}
/**
* Four days view, everythings done by the week-view code ...
*
* @param boolean $home = false if true return content suitable for home-page
* @return string
*/
function day4($home=false)
{
return $this->week(4,$home);
}
/**
* Display a button to close one of multiple calendars shown
*
@ -820,128 +710,6 @@ class calendar_uiviews extends calendar_ui
$tmpl->exec(__METHOD__, $content);
}
/**
* Displays the dayview
*
* @param boolean $home = false if true return content suitable for home-page
*/
function &day($home=false)
{
if ($this->debug > 0) $this->bo->debug_message('uiviews::day() date=%1',True,$this->date);
$this->last = $this->first = $this->bo->date2ts((string)$this->date);
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.$this->bo->long_date($this->first,0,false,true);
$this->use_time_grid = true; // day-view always uses a time-grid, independent what's set in the prefs!
$this->search_params['end'] = $this->last = $this->first+DAY_s-1;
$merge = $this->merge();
if($merge)
{
egw::redirect_link('/index.php',array(
'menuaction' => 'calendar.calendar_uiviews.index',
'msg' => $merge,
));
}
if (!$home)
{
$this->do_header();
$users = $this->search_params['users'];
if (!is_array($users)) $users = array($users);
// for more then X users, show all in one row
if (count($users) == 1 || count($users) >= $this->cal_prefs['day_consolidate'])
{
$dayEvents =& $this->bo->search($this->search_params);
$owner = 0;
}
else
{
$dayEvents = $owner = array();
$search_params = $this->search_params;
foreach($this->_get_planner_users(false) as $uid => $label)
{
$search_params['users'] = $uid;
list(,$dayEvents['<b>'.$label.'</b>'.$this->close_button($uid)]) = each($this->bo->search($search_params));
$owner[] = $uid;
}
}
$cols = array();
//Load the ""show holiday as event" preference here and set the event
//types mask accordingly.
$display_holidays_event = $GLOBALS['egw_info']['user']['preferences']['calendar']['display_holidays_event'];
$this->display_holiday_event_types = array(
'bdays' => ((int)$display_holidays_event & 1) != 0,
'hdays' => ((int)$display_holidays_event & 2) != 0
);
//Add the holiday events
$holidays = $this->_get_holiday_events($this->date, $this->display_holiday_event_types);
foreach($dayEvents as &$events)
{
$events = array_merge($events,$holidays);
}
unset($events);
unset($holidays);
$cols[0] =& $this->timeGridWidget($this->tagWholeDayOnTop($dayEvents),$this->cal_prefs['interval'],450,'','',$owner);
if (count($users) > 1)
{
$navHeader = '<div class="calendar_calWeek calendar_calWeekNavHeader">'
.html::a_href(html::image('phpgwapi','left',lang('previous'),$options=' alt="<<"'),array(
'menuaction' => $this->view_menuaction,
'date' => date('Ymd',$this->first-1),
)). '<span>'.$this->bo->long_date($this->first,0,false,true);
$navHeader = $navHeader.'</span>'.html::a_href(html::image('phpgwapi','right',lang('next'),$options=' alt=">>"'),array(
'menuaction' => $this->view_menuaction,
'date' => date('Ymd',$this->last+1),
)).'</div>';
}
// only show todo's for a single user
if (count($users) == 1 && ($todos = $this->get_todos($todo_label)) !== false)
{
if ($GLOBALS['egw_info']['user']['apps']['infolog'])
{
foreach(array('task','phone','note') as $type)
{
$todo_label .= '&nbsp;'.html::a_href( html::image('infolog',$type,lang('Add')),'infolog.infolog_ui.edit',array(
'type' => $type,
'start_time' => $ts,
),' data-todo="app|750x590"');
}
}
$cols[1] = html::div(
html::div($todo_label,'','calendar_calDayTodosHeader th')."\n".
html::div($todos,'','calendar_calDayTodosTable'),'','calendar_calDayTodos');
$cols['.1'] = 'width=30%';
echo html::table(array(
0 => $cols,
'.0' => 'valign="top"'
),'class="calendar_calDayView"');
}
else
{
$cols[0] = $navHeader . $cols[0];
echo $cols[0];
}
}
else
{
$content = $this->timeGridWidget($this->bo->search($this->search_params),$this->cal_prefs['interval'],300);
return $content;
}
}
/**
* Get todos via AJAX
*/
@ -1950,29 +1718,6 @@ class calendar_uiviews extends calendar_ui
return '';
}
/**
* Calculates a brighter color for a given color
*
* @param $rgb string color as #rrggbb value
* @param $decr int value to add to each component, default 64
* @return string the brighter color
*/
static function brighter($rgb,$decr=64)
{
if (!preg_match('/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/',$rgb,$components))
{
return '#ffffff';
}
$brighter = '#';
for ($i = 1; $i <=3; ++$i)
{
$val = hexdec($components[$i]) + $decr;
if ($val > 255) $val = 255;
$brighter .= sprintf('%02x',$val);
}
//echo "brighter($rgb=".print_r($components,True).")=$brighter</p>\n";
return $brighter;
}
/**
* Calculates the brightness of a hexadecimal rgb color (median of the r, g and b components)

View File

@ -864,65 +864,6 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend(
}
},
/**
* Function to help calendar resizable event, to fetch the right droppable cell
*
* @param {int} _X position left of draggable element
* @param {int} _Y position top of draggable element
*
* @return {jquery object|boolean} return selected jquery if not return false
*/
resizeHelper: function(_X,_Y)
{
var $drops = jQuery("div[id^='drop_']");
var top = Math.round(_Y);
var left = Math.round(_X);
for (var i=0;i < $drops.length;i++)
{
if (top >= Math.round($drops[i].getBoundingClientRect().top)
&& top <= Math.round($drops[i].getBoundingClientRect().bottom)
&& left >= Math.round($drops[i].getBoundingClientRect().left)
&& left <= Math.round($drops[i].getBoundingClientRect().right))
return $drops[i];
}
return false;
},
/**
* Convert AM/PM dateTime format to 24h
*
* @param {string} _date dnd date format: dateTtime{am|pm}, eg. 121214T1205 am
*
* @return {string} 24h format date
*/
cal_dnd_tZone_converter : function (_date)
{
var date = _date;
if (_date !='undefined')
{
var tZone = _date.split('T')[1];
if (tZone.search('am') > 0)
{
tZone = tZone.replace(' am','');
var tAm = tZone.substr(0,2);
if (tAm == '12')
{
tZone = tZone.replace('12','00');
}
date = _date.split('T')[0] + 'T' + tZone;
}
if (tZone.search('pm') > 0)
{
var pmTime = tZone.replace(' pm','');
var H = parseInt(pmTime.substring(0,2)) + 12;
pmTime = H.toString() + pmTime.substr(2,2);
date = _date.split('T')[0] + 'T' + pmTime;
}
}
return date;
},
/**
* Handler for changes generated by internal user interactions, like
* drag & drop inside calendar and resize.
@ -1195,43 +1136,6 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend(
}
},
/**
* In edit popup, search for calendar participants.
* Resources need to have the start & duration (etc.)
* passed along in the query.
*
* @param {Object} request
* @param {et2_link_entry} widget
*
* @returns {boolean} True to continue with the search
*/
edit_participant_search: function(request, widget)
{
if(widget.app_select.val() == 'resources')
{
// Resources search is expecting exec
var values = widget.getInstanceManager().getValues(widget.getRoot());
if(typeof request.options != 'object' || request.options == null)
{
request.options = {};
}
request.options.exec = {
start: values.start,
end: values.end,
duration: values.duration,
participants: values.participants,
recur_type: values.recur_type,
event_id: values.link_to.to_id, // cal_id, if available
show_conflict: (egw.preference('defaultresource_sel','calendar') == 'resources_without_conflict') ? '0' : '1'
};
if(values.whole_day)
{
request.options.exec.whole_date = true;
}
}
return true;
},
/**
* Handles to select freetime, and replace the selected one on Start,
* and End date&time in edit calendar entry popup.
@ -1311,7 +1215,6 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend(
*/
action_open: function(_action, _events)
{
debugger;
var id = _events[0].id.split('::');
if(_action.data.open)
{
@ -1640,49 +1543,6 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend(
}
},
/**
* Create edit exception dialog for recurrence entries
*
* @param {object} event
* @param {string} id cal_id
* @param {integer} date timestamp
*/
edit_series: function(event,id,date)
{
// Coming from list, there is no event
if(arguments.length == 2)
{
date = id;
id = event;
event = null;
}
var edit_id = id;
var edit_date = date;
var that = this;
var buttons = [
{text: this.egw.lang("Edit exception"), id: "exception", class: "ui-priority-primary", "default": true},
{text: this.egw.lang("Edit series"), id:"series"},
{text: this.egw.lang("Cancel"), id:"cancel"}
];
et2_dialog.show_dialog(function(_button_id)
{
switch(_button_id)
{
case 'exception':
that.egw.open(edit_id, 'calendar', 'edit', '&date='+edit_date+'&exception=1');
break;
case 'series':
that.egw.open(edit_id, 'calendar', 'edit', '&date='+edit_date);
break;
case 'cancel':
default:
break;
}
},this.egw.lang("Do you want to edit this event as an exception or the whole series?"),
this.egw.lang("This event is part of a series"), {}, buttons, et2_dialog.WARNING_MESSAGE);
},
/**
* Sidebox merge
*