mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:07 +01:00
calendar integration from H.J.Tappe Listview/Multiple Weekview, to show Calendar events in sitemanager sites. Simple Demo http://213.183.76.121/TrunkWebSeite/?category_id=45; Some documentation of abilities and howto available with egroupware.org Tracker Patches Sitemgr #1991, 1993 and 1994
This commit is contained in:
parent
8e9eb0aa2e
commit
4a7c8737bb
@ -115,6 +115,12 @@ class calendar_uiviews extends calendar_ui
|
||||
*/
|
||||
var $wholeDayPosCounter=1;
|
||||
|
||||
/**
|
||||
* Switch to disable private data and possibility to view and edit events
|
||||
* in case of a public view (sitemgr)
|
||||
*/
|
||||
var $allowEdit = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -344,7 +350,10 @@ class calendar_uiviews extends calendar_ui
|
||||
'date' => $this->bo->date2string($week_start),
|
||||
);
|
||||
$title = lang('Wk').' '.adodb_date('W',$week_start);
|
||||
$title = html::a_href($title,$week_view,'',' title="'.lang('Weekview').'"');
|
||||
if ($this->allowEdit)
|
||||
{
|
||||
$title = html::a_href($title,$week_view,'',' title="'.lang('Weekview').'"');
|
||||
}
|
||||
|
||||
$content .= $this->timeGridWidget($this->tagWholeDayOnTop($week),$weeks == 2 ? 30 : 60,200,'',$title,0,$week_start+WEEK_s >= $this->last);
|
||||
}
|
||||
@ -933,16 +942,33 @@ class calendar_uiviews extends calendar_ui
|
||||
|
||||
if ($short_title === true)
|
||||
{
|
||||
$title = html::a_href($title,$day_view,'',
|
||||
!isset($this->holidays[$day_ymd])?' title="'.lang('Dayview').'"':'');
|
||||
if ($this->allowEdit)
|
||||
{
|
||||
$title = html::a_href($title,$day_view,'',
|
||||
!isset($this->holidays[$day_ymd])?' title="'.lang('Dayview').'"':'');
|
||||
}
|
||||
}
|
||||
elseif ($short_title === false)
|
||||
{
|
||||
// add arrows to go to the previous and next day (dayview only)
|
||||
$day_view['date'] = $this->bo->date2string($ts -= 12*HOUR_s);
|
||||
$title = html::a_href(html::image('phpgwapi','left',$this->bo->long_date($ts)),$day_view).' '.$title;
|
||||
if ($this->allowEdit)
|
||||
{
|
||||
$title = html::a_href(html::image('phpgwapi','left',$this->bo->long_date($ts)),$day_view).' '.$title;
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = $day_view.' '.$title;
|
||||
}
|
||||
$day_view['date'] = $this->bo->date2string($ts += 48*HOUR_s);
|
||||
$title .= ' '.html::a_href(html::image('phpgwapi','right',$this->bo->long_date($ts)),$day_view);
|
||||
if ($this->allowEdit)
|
||||
{
|
||||
$title .= ' '.html::a_href(html::image('phpgwapi','right',$this->bo->long_date($ts)),$day_view);
|
||||
}
|
||||
else
|
||||
{
|
||||
$title .= ' '.$day_view;
|
||||
}
|
||||
}
|
||||
$html .= $indent."\t".'<div style="height: '. $this->rowHeight .'%;" class="calDayColHeader '.$class.'"'.($holidays ? ' title="'.$holidays.'"':'').'>'.
|
||||
$title."</div>\n";
|
||||
@ -978,8 +1004,12 @@ class calendar_uiviews extends calendar_ui
|
||||
$droppableID='drop_'.$droppableDateTime.'_O'.$owner;
|
||||
|
||||
$html .= $indent."\t".'<div id="' . $droppableID . '" style="height:'. $this->rowHeight .'%; top: '. $i*$this->rowHeight .
|
||||
'%;" class="calAddEvent" onclick="'.$this->popup($GLOBALS['egw']->link('/index.php',$linkData)).';return false;"></div>'."\n";
|
||||
|
||||
'%;" class="calAddEvent"';
|
||||
if ($this->allowEdit)
|
||||
{
|
||||
$html .= ' onclick="'.$this->popup($GLOBALS['egw']->link('/index.php',$linkData)).';return false;"';
|
||||
}
|
||||
$html .= '></div>'."\n";
|
||||
if(is_object($this->dragdrop) && $dropPermission)
|
||||
{
|
||||
$this->dragdrop->addDroppable(
|
||||
@ -1147,21 +1177,24 @@ class calendar_uiviews extends calendar_ui
|
||||
|
||||
// seperate each participant types
|
||||
$part_array = array();
|
||||
foreach($this->bo->participants($event) as $part_key => $participant)
|
||||
{
|
||||
if(is_numeric($part_key))
|
||||
{
|
||||
$part_array[lang('Participants')][$part_key] = $participant;
|
||||
}
|
||||
elseif(isset($this->bo->resources[$part_key{0}]))
|
||||
{
|
||||
$part_array[((isset($this->bo->resources[$part_key{0}]['participants_header'])) ? $this->bo->resources[$part_key{0}]['participants_header'] : lang($this->bo->resources[$part_key{0}]['app']))][$part_key] = $participant;
|
||||
}
|
||||
}
|
||||
foreach($part_array as $part_group => $participant)
|
||||
{
|
||||
$participants .= $this->add_nonempty($participant,$part_group,True,False);
|
||||
}
|
||||
if ($this->allowEdit)
|
||||
{
|
||||
foreach($this->bo->participants($event) as $part_key => $participant)
|
||||
{
|
||||
if(is_numeric($part_key))
|
||||
{
|
||||
$part_array[lang('Participants')][$part_key] = $participant;
|
||||
}
|
||||
elseif(isset($this->bo->resources[$part_key{0}]))
|
||||
{
|
||||
$part_array[((isset($this->bo->resources[$part_key{0}]['participants_header'])) ? $this->bo->resources[$part_key{0}]['participants_header'] : lang($this->bo->resources[$part_key{0}]['app']))][$part_key] = $participant;
|
||||
}
|
||||
}
|
||||
foreach($part_array as $part_group => $participant)
|
||||
{
|
||||
$participants .= $this->add_nonempty($participant,$part_group,True,False);
|
||||
}
|
||||
}
|
||||
// as we only deal with percentual widht, we consider only the full dayview (1 colum) as NOT small
|
||||
$small = $this->view != 'day' || $width < 50;
|
||||
// $small = $width <= $small_trigger_width
|
||||
@ -1231,12 +1264,11 @@ class calendar_uiviews extends calendar_ui
|
||||
{
|
||||
$view_link_confirm_abort = $GLOBALS['egw']->link('/index.php',array('menuaction'=>'calendar.calendar_uiforms.edit','cal_id'=>$event['id'],'date'=>$this->bo->date2string($event['start']),'exception'=>1));
|
||||
$view_link_confirm_text=lang('do you want to edit serialevent als exception? - Ok = Edit Exception, Abort = Edit Serial');
|
||||
$popup = $is_private ? '' : ' onclick="'.$this->popup($view_link_confirm_abort,null,750,410,$view_link,$view_link_confirm_text).'; return false;"';
|
||||
|
||||
$popup = ($is_private || ! $this->allowEdit) ? '' : ' onclick="'.$this->popup($view_link_confirm_abort,null,750,410,$view_link,$view_link_confirm_text).'; return false;"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$popup = $is_private ? '' : ' onclick="'.$this->popup($view_link).'; return false;"';
|
||||
$popup = ($is_private || ! $this->allowEdit) ? '' : ' onclick="'.$this->popup($view_link).'; return false;"';
|
||||
}
|
||||
//_debug_array($event);
|
||||
//echo $event['id']."?<br>";
|
||||
|
@ -9,13 +9,18 @@
|
||||
* option) any later version. *
|
||||
\**************************************************************************/
|
||||
|
||||
/* $Id: class.module_calendar.inc.php 19554 2005-11-02 14:37:42Z ralfbecker $ */
|
||||
/* $Id: class.module_calendar.inc.php,v 1.4 2008-12-29 19:01:26 hjtappe Exp $ */
|
||||
|
||||
class module_calendar extends Module
|
||||
{
|
||||
function module_calendar()
|
||||
{
|
||||
$this->arguments = array();
|
||||
$this->arguments = array(
|
||||
'redirect' => array(
|
||||
'type' => 'textfield',
|
||||
'label' => lang('Specify where URL of the day links to'),
|
||||
),
|
||||
);
|
||||
|
||||
$this->title = lang('Calendar');
|
||||
$this->description = lang('This module displays the current month');
|
||||
@ -23,6 +28,12 @@ class module_calendar extends Module
|
||||
|
||||
function get_content(&$arguments,$properties)
|
||||
{
|
||||
return $GLOBALS['egw']->jscalendar->flat('#');
|
||||
if (!is_object($GLOBALS['egw']->jscalendar))
|
||||
{
|
||||
$GLOBALS['egw']->jscalendar =& CreateObject('phpgwapi.jscalendar');
|
||||
}
|
||||
$date = (int) (strtotime(get_var('date',array('POST','GET'))));
|
||||
$redirect = $arguments['redirect'] ? $arguments['redirect'] : '#';
|
||||
return $GLOBALS['egw']->jscalendar->flat($redirect,$date);
|
||||
}
|
||||
}
|
||||
|
383
calendar/sitemgr/class.module_calendar_list.inc.php
Normal file
383
calendar/sitemgr/class.module_calendar_list.inc.php
Normal file
@ -0,0 +1,383 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* eGroupWare SiteMgr - Web Content Management *
|
||||
* http://www.egroupware.org *
|
||||
* -------------------------------------------- *
|
||||
* 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.module_calendar_list.inc.php,v 1.9 2008-12-30 17:56:19 hjtappe Exp $ */
|
||||
|
||||
/*
|
||||
// AN EXAMPLE STYLESHEET
|
||||
.cal_list_event {
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
.cal_list_title {
|
||||
clear: both;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.cal_list_date {
|
||||
clear: both;
|
||||
padding-left:15px;
|
||||
}
|
||||
|
||||
.cal_list_weekday {
|
||||
}
|
||||
|
||||
.cal_list_descr {
|
||||
clear: both;
|
||||
padding-left: 15px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.cal_list_end {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.cal_event_even {
|
||||
background: #F1F1F1;
|
||||
}
|
||||
|
||||
.cal_event_uneven {
|
||||
}
|
||||
|
||||
.cal_list_weeksplit {
|
||||
width = 80%;
|
||||
vertical-align: center;
|
||||
border-top-width: 1px;
|
||||
}
|
||||
|
||||
.cal_list_weektop {
|
||||
}
|
||||
|
||||
.cal_list_weeksplit {
|
||||
width: 100%;
|
||||
border-top: 1px;
|
||||
border-top-style: solid;
|
||||
}
|
||||
|
||||
.cal_list_weekbottom {
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
class module_calendar_list extends Module
|
||||
{
|
||||
/**
|
||||
* Instance of the business object of calendar
|
||||
*
|
||||
* @var bo
|
||||
*/
|
||||
var $bo;
|
||||
/**
|
||||
* Instance of the user interface object of calendar
|
||||
*
|
||||
* @var ui
|
||||
*/
|
||||
var $ui;
|
||||
|
||||
function module_calendar_list()
|
||||
{
|
||||
$this->arguments = array(
|
||||
'category' => array(
|
||||
'type' => 'select',
|
||||
'label' => lang('Choose a category'),
|
||||
'options' => array(), // specification of options is postponed into the get_user_interface function
|
||||
'multiple' => true,
|
||||
),
|
||||
'numWeeks' => array(
|
||||
'type' => 'textfield',
|
||||
'label' => lang('Number of weeks to show'),
|
||||
'default' => '4',
|
||||
'params' => array('size' => 1),
|
||||
),
|
||||
'showTitle' => array(
|
||||
'type' => 'checkbox',
|
||||
'label' => lang('Show a calendar title'),
|
||||
'default' => false,
|
||||
),
|
||||
'offset' => array(
|
||||
'type' => 'textfield',
|
||||
'label' => lang('Weeks offset (for multi-column display)'),
|
||||
'default' => '0',
|
||||
'params' => array('size' => 1),
|
||||
),
|
||||
'search' => array(
|
||||
'type' => 'textfield',
|
||||
'label' => lang('Search string for the events'),
|
||||
),
|
||||
'numEntries' => array(
|
||||
'type' => 'textfield',
|
||||
'label' => lang('Max. Number of entries to show (leave empty for no restriction)'),
|
||||
'default' => '',
|
||||
'params' => array('size' => 1),
|
||||
),
|
||||
'entryOffset' => array(
|
||||
'type' => 'textfield',
|
||||
'label' => lang('How much entries to skip'),
|
||||
'default' => '0',
|
||||
'params' => array('size' => 1),
|
||||
),
|
||||
'users' => array(
|
||||
'type' => 'select',
|
||||
'options' => array(),
|
||||
'label' => lang('Group(s) or user(s) whose calendars to show (if ACL exists)'),
|
||||
// 'multiple' => true, is set in the get_user_interface function.
|
||||
),
|
||||
'showWeeks' => array(
|
||||
'type' => 'checkbox',
|
||||
'label' => lang('Should the number of weeks be shown on top of the calendar (only if offset = 0)'),
|
||||
'default' => false,
|
||||
),
|
||||
'acceptDateParam' => array(
|
||||
'type' => 'checkbox',
|
||||
'label' => lang('Shall the date parameter be accepted (e.g. from calendar module)?'),
|
||||
'default' => false,
|
||||
),
|
||||
);
|
||||
$this->title = lang('Calendar - List');
|
||||
$this->description = lang("This module displays calendar events as a list.");
|
||||
}
|
||||
|
||||
function get_user_interface()
|
||||
{
|
||||
// copied from bookmarks module.
|
||||
$cat = createobject('phpgwapi.categories','','calendar');
|
||||
$cats = $cat->return_array('all',0,False,'','cat_name','',True);
|
||||
$cat_ids = array();
|
||||
while (list(,$category) = @each($cats))
|
||||
{
|
||||
$cat_ids[$category['id']] = $GLOBALS['egw']->strip_html($category['name']);
|
||||
}
|
||||
$this->arguments['category']['options'] = $cat_ids;
|
||||
if (count($cat_ids) > 5) {
|
||||
$this->arguments['category']['multiple'] = 5;
|
||||
}
|
||||
|
||||
if (! isset($GLOBALS['egw']->accounts))
|
||||
{
|
||||
$GLOBALS['egw']->accounts = new accounts();
|
||||
}
|
||||
$this->accounts =& $GLOBALS['egw']->accounts;
|
||||
$search_params=array(
|
||||
'type' => 'both',
|
||||
'app' => 'calendar',
|
||||
);
|
||||
$accounts = $this->accounts->search($search_params);
|
||||
$users = array();
|
||||
$groups = array();
|
||||
// sort users and groups separately.
|
||||
if (isset($GLOBALS['sitemgr_info']['anonymous_user']))
|
||||
{
|
||||
$anon_user = $this->accounts->name2id($GLOBALS['sitemgr_info']['anonymous_user'],'account_lid','u');
|
||||
}
|
||||
else
|
||||
{
|
||||
// sitemgr is not in global variables. Get it.
|
||||
/*
|
||||
* Get possible sitemgr paths from the HTTP_REFERRER in order to unreveal the
|
||||
* anonymous user for the correct site.
|
||||
*/
|
||||
$sitemgr_path = preg_replace('/^[^\/]+:\/\/[^\/]+\/([^\?]*)(\?.*)*$/',"/\${1}",$_SERVER['HTTP_REFERER']);
|
||||
// Remove the trailing file- / pathname if any
|
||||
$sitemgr_path = preg_replace('/[^\/]*$/', '', $sitemgr_path);
|
||||
// Add leading slash if it has been lost.
|
||||
if (strncmp('/', $sitemgr_path, 1) != 0)
|
||||
{
|
||||
$sitemgr_path = '/'.$sitemgr_path;
|
||||
}
|
||||
|
||||
// Code adapted from sitemgr-site/index.php
|
||||
$site_urls = array();
|
||||
$site_urls[] = $sitemgr_path;
|
||||
$site_urls[] = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_ADDR'] . $sitemgr_path;
|
||||
$site_urls[] = $site_url = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . $sitemgr_path;
|
||||
|
||||
$GLOBALS['egw']->db->select('egw_sitemgr_sites','anonymous_user,anonymous_passwd,site_id',
|
||||
array('site_url' => $site_urls),__LINE__,__FILE__,false,'','sitemgr');
|
||||
|
||||
$GLOBALS['egw']->db->next_record();
|
||||
$anon_user = $this->accounts->name2id($GLOBALS['egw']->db->f('anonymous_user'),'account_lid','u');
|
||||
}
|
||||
|
||||
$anon_groups = $this->accounts->memberships($anon_user,true);
|
||||
foreach ($accounts as $entry)
|
||||
{
|
||||
$is_group = false;
|
||||
$has_read_permissions = false;
|
||||
$acl =& new acl($entry['account_id']);
|
||||
$acl->read_repository();
|
||||
// get the rights for each account to check whether the anon user has read permissions.
|
||||
$rights = $acl->get_rights($anon_user,'calendar');
|
||||
// also add the anon user if it's his own calendar.
|
||||
if (($rights & EGW_ACL_READ) || ($entry['account_id'] == $anon_user))
|
||||
{
|
||||
$has_read_permissions = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// scan the groups which pass on permissions to the anon user group member
|
||||
// or ass permissions if this is the anon group's calendar.
|
||||
foreach ($anon_groups as $parent_group)
|
||||
{
|
||||
$rights = $acl->get_rights($parent_group,'calendar');
|
||||
if (($rights & EGW_ACL_READ) || ($entry['account_id'] == $parent_group))
|
||||
{
|
||||
$has_read_permissions = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($has_read_permissions)
|
||||
{
|
||||
// Separate groups from users for improved readability.
|
||||
if ($is_group)
|
||||
{
|
||||
$groups[$entry['account_id']] = $entry['account_lid'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$users[$entry['account_id']] = $GLOBALS['egw']->common->display_fullname($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']);
|
||||
}
|
||||
}
|
||||
}
|
||||
asort($groups);
|
||||
asort($users);
|
||||
// concat users and groups to the option array.
|
||||
$this->arguments['users']['options'] = $groups + $users;
|
||||
if (count($this->arguments['users']['options']) > 10)
|
||||
{
|
||||
$this->arguments['users']['multiple'] = 10;
|
||||
}
|
||||
else if (count($this->arguments['users']['options']) > 0)
|
||||
{
|
||||
$this->arguments['users']['multiple'] = true;
|
||||
}
|
||||
|
||||
return parent::get_user_interface();
|
||||
}
|
||||
|
||||
function get_content(&$arguments,$properties)
|
||||
{
|
||||
$html = "";
|
||||
$GLOBALS['egw']->translation->add_app('calendar');
|
||||
$this->bo =& new calendar_bo();
|
||||
$this->ui =& new calendar_uiviews();
|
||||
$this->ui->allowEdit = false;
|
||||
$this->ui->use_time_grid = isset($arguments['grid']) ? $arguments['grid'] : false;
|
||||
|
||||
$weeks = $arguments['numWeeks'] ? (float) $arguments['numWeeks'] : 4;
|
||||
$dateOffset = $arguments['offset'] ? (float) $arguments['offset'] : 0;
|
||||
|
||||
if (($arguments['acceptDateParam']) && (get_var('date',array('POST','GET'))))
|
||||
{
|
||||
$first = (int) (strtotime(get_var('date',array('POST','GET'))) +
|
||||
(60 * 60 * 24 * 7 * $dateOffset));
|
||||
}
|
||||
else
|
||||
{
|
||||
$first = (int) ($this->bo->now_su +
|
||||
(60 * 60 * 24 * 7 * $dateOffset));
|
||||
}
|
||||
$last = (int) ($first +
|
||||
(60 * 60 * 24 * 7 * $weeks) +
|
||||
(60 * 60 * 24 * 7 * $dateOffset));
|
||||
|
||||
if ($arguments['showTitle'])
|
||||
{
|
||||
$html .= '<div id="divAppboxHeader">'.$GLOBALS['egw_info']['apps']['calendar']['title'].' - '.lang('Listview').": ";
|
||||
$html .= lang('After %1',$this->bo->long_date($first));
|
||||
$html .= "</div>";
|
||||
}
|
||||
|
||||
// set the search parameters
|
||||
$search_params = Array
|
||||
(
|
||||
'offset' => $arguments['entryOffset'] ? (int) $arguments['entryOffset'] : 0,
|
||||
'order' => 'cal_start ASC',
|
||||
'start' => $first,
|
||||
'end' => $last,
|
||||
);
|
||||
$search_string = trim($arguments['search']);
|
||||
if ($search_string != "")
|
||||
{
|
||||
$search_params['query'] = $search_string;
|
||||
}
|
||||
if (count($arguments['category']) > 0)
|
||||
{
|
||||
$search_params['cat_id'] = $arguments['category'];
|
||||
}
|
||||
if ((is_array($arguments['users'])) && (count($arguments['users']) > 0))
|
||||
{
|
||||
$search_params['users'] = $arguments['users'];
|
||||
}
|
||||
if ($arguments['numEntries'])
|
||||
{
|
||||
$search_params['num_rows'] = (int) $arguments['numEntries'];
|
||||
}
|
||||
$rows = array();
|
||||
foreach((array) $this->bo->search($search_params) as $event)
|
||||
{
|
||||
$event['date'] = $this->bo->date2string($event['start']);
|
||||
if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment
|
||||
if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment
|
||||
$rows[] = $event;
|
||||
}
|
||||
if (($arguments['showWeeks']) && ($arguments['offset'] == 0))
|
||||
{
|
||||
$html .= "<div>".lang('Next')." ".lang('%1 weeks', $weeks).":</div>\n";
|
||||
}
|
||||
if ($this->bo->total == 0)
|
||||
{
|
||||
$html .= "<div>".lang("no events found")."</div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$event_count = 0;
|
||||
$last_week = 0;
|
||||
|
||||
$html .= "\n<div>\n";
|
||||
$html .= ' <div class="cal_list_weektop"></div>'."\n";
|
||||
foreach ($rows as $event)
|
||||
{
|
||||
if (($last_week != 0) && (adodb_date('W-Y',$event['start']) != $last_week))
|
||||
{
|
||||
$html .= ' <div class="cal_list_weeksplit"></div>'."\n";
|
||||
}
|
||||
$last_week = adodb_date('W-Y',$event['start']);
|
||||
$html .= " <!-- Event -->\n";
|
||||
if ($event_count % 2 == 0) {
|
||||
$html .= ' <div class="cal_list_event cal_event_even">'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$html .= ' <div class="cal_list_event cal_event_uneven">'."\n";
|
||||
}
|
||||
$html .= ' <div class="cal_list_title">'.$event['title']."</div>\n";
|
||||
$html .= ' <div class="cal_list_date">';
|
||||
$html .= '<span class="cal_list_start">';
|
||||
$html .= '<span class="cal_list_weekday">'.lang(adodb_date('D',$event['start'])).".".($this->bo->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ')."</span>";
|
||||
$html .= $this->bo->format_date($event['start'])."</span>";
|
||||
$html .= '<span class="cal_list_end"> - ';
|
||||
$html .= '<span class="cal_list_weekday">'.lang(adodb_date('D',$event['end'])).".".($this->bo->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ')."</span>";
|
||||
$html .= $this->bo->format_date($event['end'])."</span></div>\n";
|
||||
$descr = trim($event['description']);
|
||||
if (! empty($descr)) {
|
||||
$html .= " <div class=\"cal_list_descr\">\n".preg_replace('/\\n/',"<br>\n",$event['description'])."</div>\n";
|
||||
}
|
||||
$html .= " </div><!-- cal_list_event -->\n";
|
||||
$event_count ++;
|
||||
}
|
||||
$html .= ' <div class="cal_list_weekbottom"></div>'."\n";
|
||||
$html .= "<!-- End module -->\n";
|
||||
$html .= "</div>\n";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
317
calendar/sitemgr/class.module_calendar_month.inc.php
Normal file
317
calendar/sitemgr/class.module_calendar_month.inc.php
Normal file
@ -0,0 +1,317 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* eGroupWare SiteMgr - Web Content Management *
|
||||
* http://www.egroupware.org *
|
||||
* -------------------------------------------- *
|
||||
* 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.module_calendar_month.inc.php,v 1.7 2008-12-30 15:38:33 hjtappe Exp $ */
|
||||
|
||||
class module_calendar_month extends Module
|
||||
{
|
||||
/**
|
||||
* Instance of the business object of calendar
|
||||
*
|
||||
* @var bo
|
||||
*/
|
||||
var $bo;
|
||||
/**
|
||||
* Instance of the user interface object of calendar
|
||||
*
|
||||
* @var ui
|
||||
*/
|
||||
var $ui;
|
||||
/**
|
||||
* Instance of the user interface object of calendar
|
||||
*
|
||||
* @var ui
|
||||
*/
|
||||
var $uiviews;
|
||||
/**
|
||||
* Instance of the accounts object
|
||||
*
|
||||
* @var accounts
|
||||
*/
|
||||
var $accounts;
|
||||
/**
|
||||
* Default CSS style
|
||||
*
|
||||
* @var default_css
|
||||
*/
|
||||
var $default_css = '/calendar/templates/default/app.css';
|
||||
|
||||
function module_calendar_month()
|
||||
{
|
||||
$this->bo =& new calendar_bo();
|
||||
$this->arguments = array(
|
||||
'category' => array(
|
||||
'type' => 'select',
|
||||
'label' => lang('Choose a category'),
|
||||
'options' => array(), // specification of options is postponed into the get_user_interface function
|
||||
'multiple' => true,
|
||||
),
|
||||
'numWeeks' => array(
|
||||
'type' => 'textfield',
|
||||
'label' => lang('Number of weeks to show'),
|
||||
'default' => 2,
|
||||
'params' => array('size' => 1)
|
||||
),
|
||||
'showWeeks' => array(
|
||||
'type' => 'checkbox',
|
||||
'label' => lang('Should the number of weeks be shown on top of the calendar'),
|
||||
'default' => false,
|
||||
),
|
||||
'showTitle' => array(
|
||||
'type' => 'checkbox',
|
||||
'label' => lang('Show a calendar title'),
|
||||
'default' => false,
|
||||
),
|
||||
'search' => array(
|
||||
'type' => 'textfield',
|
||||
'label' => lang('Search string for the events'),
|
||||
),
|
||||
'users' => array(
|
||||
'type' => 'select',
|
||||
'options' => array(),
|
||||
'label' => lang('Group(s) or user(s) whose calendars to show (if ACL exists)'),
|
||||
// 'multiple' => true, is set in the get_user_interface function.
|
||||
),
|
||||
'grid' => array(
|
||||
'type' => 'checkbox',
|
||||
'label' => lang('Should the grid be shown in the calendar'),
|
||||
'default' => false,
|
||||
),
|
||||
'css' => array(
|
||||
'type' => 'textfield',
|
||||
'label' => lang('User selectable CSS file for the calendar setup'),
|
||||
'default' => $this->default_css,
|
||||
),
|
||||
'acceptDateParam' => array(
|
||||
'type' => 'checkbox',
|
||||
'label' => lang('Shall the date parameter be accepted (e.g. from calendar module)?'),
|
||||
'default' => false,
|
||||
),
|
||||
);
|
||||
$this->title = lang('Calendar - Multi-Weekly');
|
||||
$this->description = lang("This module displays a user's calendar as multiple weeks. Don't give calendar application access to the anon user!");
|
||||
}
|
||||
|
||||
function get_user_interface()
|
||||
{
|
||||
// copied from bookmarks module.
|
||||
$cat = createobject('phpgwapi.categories','','calendar');
|
||||
$cats = $cat->return_array('all',0,False,'','cat_name','',True);
|
||||
$cat_ids = array();
|
||||
while (list(,$category) = @each($cats))
|
||||
{
|
||||
$cat_ids[$category['id']] = $GLOBALS['egw']->strip_html($category['name']);
|
||||
}
|
||||
$this->arguments['category']['options'] = $cat_ids;
|
||||
if (count($cat_ids) > 5) {
|
||||
$this->arguments['category']['multiple'] = 5;
|
||||
}
|
||||
|
||||
if (! isset($GLOBALS['egw']->accounts))
|
||||
{
|
||||
$GLOBALS['egw']->accounts = new accounts();
|
||||
}
|
||||
$this->accounts =& $GLOBALS['egw']->accounts;
|
||||
$search_params=array(
|
||||
'type' => 'both',
|
||||
'app' => 'calendar',
|
||||
);
|
||||
$accounts = $this->accounts->search($search_params);
|
||||
$users = array();
|
||||
$groups = array();
|
||||
// sort users and groups separately.
|
||||
if (isset($GLOBALS['sitemgr_info']['anonymous_user']))
|
||||
{
|
||||
$anon_user = $this->accounts->name2id($GLOBALS['sitemgr_info']['anonymous_user'],'account_lid','u');
|
||||
}
|
||||
else
|
||||
{
|
||||
// sitemgr is not in global variables. Get it.
|
||||
/*
|
||||
* Get possible sitemgr paths from the HTTP_REFERRER in order to unreveal the
|
||||
* anonymous user for the correct site.
|
||||
*/
|
||||
$sitemgr_path = preg_replace('/^[^\/]+:\/\/[^\/]+\/([^\?]*)(\?.*)*$/',"/\${1}",$_SERVER['HTTP_REFERER']);
|
||||
// Remove the trailing file- / pathname if any
|
||||
$sitemgr_path = preg_replace('/[^\/]*$/', '', $sitemgr_path);
|
||||
// Add leading slash if it has been lost.
|
||||
if (strncmp('/', $sitemgr_path, 1) != 0)
|
||||
{
|
||||
$sitemgr_path = '/'.$sitemgr_path;
|
||||
}
|
||||
|
||||
// Code adapted from sitemgr-site/index.php
|
||||
$site_urls = array();
|
||||
$site_urls[] = $sitemgr_path;
|
||||
$site_urls[] = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_ADDR'] . $sitemgr_path;
|
||||
$site_urls[] = $site_url = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . $sitemgr_path;
|
||||
|
||||
$GLOBALS['egw']->db->select('egw_sitemgr_sites','anonymous_user,anonymous_passwd,site_id',
|
||||
array('site_url' => $site_urls),__LINE__,__FILE__,false,'','sitemgr');
|
||||
|
||||
$GLOBALS['egw']->db->next_record();
|
||||
$anon_user = $this->accounts->name2id($GLOBALS['egw']->db->f('anonymous_user'),'account_lid','u');
|
||||
}
|
||||
|
||||
$anon_groups = $this->accounts->memberships($anon_user,true);
|
||||
foreach ($accounts as $entry)
|
||||
{
|
||||
$is_group = false;
|
||||
$has_read_permissions = false;
|
||||
$acl =& new acl($entry['account_id']);
|
||||
$acl->read_repository();
|
||||
// get the rights for each account to check whether the anon user has read permissions.
|
||||
$rights = $acl->get_rights($anon_user,'calendar');
|
||||
// also add the anon user if it's his own calendar.
|
||||
if (($rights & EGW_ACL_READ) || ($entry['account_id'] == $anon_user))
|
||||
{
|
||||
$has_read_permissions = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// scan the groups which pass on permissions to the anon user group member
|
||||
// or ass permissions if this is the anon group's calendar.
|
||||
foreach ($anon_groups as $parent_group)
|
||||
{
|
||||
$rights = $acl->get_rights($parent_group,'calendar');
|
||||
if (($rights & EGW_ACL_READ) || ($entry['account_id'] == $parent_group))
|
||||
{
|
||||
$has_read_permissions = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($has_read_permissions)
|
||||
{
|
||||
// Separate groups from users for improved readability.
|
||||
if ($is_group)
|
||||
{
|
||||
$groups[$entry['account_id']] = $entry['account_lid'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$users[$entry['account_id']] = $GLOBALS['egw']->common->display_fullname($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']);
|
||||
}
|
||||
}
|
||||
}
|
||||
asort($groups);
|
||||
asort($users);
|
||||
// concat users and groups to the option array.
|
||||
$this->arguments['users']['options'] = $groups + $users;
|
||||
if (count($this->arguments['users']['options']) > 10)
|
||||
{
|
||||
$this->arguments['users']['multiple'] = 10;
|
||||
}
|
||||
else if (count($this->arguments['users']['options']) > 0)
|
||||
{
|
||||
$this->arguments['users']['multiple'] = true;
|
||||
}
|
||||
|
||||
return parent::get_user_interface();
|
||||
}
|
||||
|
||||
function get_content(&$arguments,$properties)
|
||||
{
|
||||
$html = "";
|
||||
$GLOBALS['egw']->translation->add_app('calendar');
|
||||
$this->ui =& new calendar_uiviews();
|
||||
$this->ui->allowEdit = false;
|
||||
$this->ui->use_time_grid = isset($arguments['grid']) ? $arguments['grid'] : false;
|
||||
|
||||
$weeks = $arguments['numWeeks'] ? (int) $arguments['numWeeks'] : 4;
|
||||
|
||||
if (($arguments['acceptDateParam']) && (get_var('date',array('POST','GET'))))
|
||||
{
|
||||
$start = (int) (strtotime(get_var('date',array('POST','GET'))) +
|
||||
(60 * 60 * 24 * 7 * $dateOffset));
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = (int) ($this->bo->now_su +
|
||||
(60 * 60 * 24 * 7 * $dateOffset));
|
||||
}
|
||||
$first = $this->ui->datetime->get_weekday_start(
|
||||
adodb_date('Y',$start),
|
||||
adodb_date('m',$start),
|
||||
adodb_date('d',$start));
|
||||
$last = (int) ($first +
|
||||
(60 * 60 * 24 * 7 * $weeks) +
|
||||
(60 * 60 * 24 * 7 * $dateOffset));
|
||||
|
||||
if ($arguments['showTitle'])
|
||||
{
|
||||
$html .= '<div id="divAppboxHeader">'.$GLOBALS['egw_info']['apps']['calendar']['title'].' - '.lang('Weekview').": ";
|
||||
$html .= lang('After %1',$this->bo->long_date($first));
|
||||
$html .= "</div>";
|
||||
}
|
||||
|
||||
// set the search parameters
|
||||
$search_params = Array
|
||||
(
|
||||
'offset' => 0,
|
||||
'order' => 'cal_start ASC',
|
||||
'start' => $first,
|
||||
'end' => $last,
|
||||
'daywise' => true,
|
||||
);
|
||||
$search_string = trim($arguments['search']);
|
||||
if ($search_string != "")
|
||||
{
|
||||
$search_params['query'] = $search_string;
|
||||
}
|
||||
if (count($arguments['category']) > 0)
|
||||
{
|
||||
$search_params['cat_id'] = $arguments['category'];
|
||||
}
|
||||
if ((is_array($arguments['users'])) && (count($arguments['users']) > 0))
|
||||
{
|
||||
$search_params['users'] = $arguments['users'];
|
||||
}
|
||||
$rows = $this->bo->search($search_params);
|
||||
if ($arguments['showWeeks'])
|
||||
{
|
||||
$html .= "<div>".lang('Next')." ".lang('%1 weeks', $weeks).":</div>\n";
|
||||
}
|
||||
$css_file = isset($arguments['css']) ? $arguments['css'] : $this->default_css;
|
||||
$html .= '<!-- BEGIN Calendar info -->'."\n";
|
||||
$html .= '<style type="text/css">'."\n";
|
||||
$html .= '<!--'."\n";
|
||||
$html .= '@import url('.$GLOBALS['egw_info']['server']['webserver_url'].$css_file.");\n";
|
||||
$html .= '-->'."\n";
|
||||
$html .= '</style>'."\n";
|
||||
$html .= '<!-- END Calendar info -->'."\n";
|
||||
unset($css_file);
|
||||
// we add DAY_s/2 to $this->first (using 12h), to deal with daylight saving changes
|
||||
for ($week_start = $first; $week_start < $last; $week_start = strtotime("+1 week",$week_start))
|
||||
{
|
||||
$week = array();
|
||||
for ($i = 0; $i < 7; ++$i)
|
||||
{
|
||||
$day_ymd = $this->bo->date2string($i ? strtotime("+$i days",$week_start) : $week_start);
|
||||
$week[$day_ymd] = array_shift($rows);
|
||||
}
|
||||
$week_view = array(
|
||||
'menuaction' => false,
|
||||
'date' => $this->bo->date2string($week_start),
|
||||
);
|
||||
$title = lang('Wk').' '.adodb_date('W',$week_start);
|
||||
if (!isset($GLOBALS['egw']->template))
|
||||
{
|
||||
$GLOBALS['egw']->template = new Template;
|
||||
}
|
||||
$html .= $this->ui->timeGridWidget($this->ui->tagWholeDayOnTop($week),$weeks == 2 ? 30 : 60,200,'',$title,0,$week_start+WEEK_s >= $this->last);
|
||||
}
|
||||
// Initialize Tooltips
|
||||
$html .= '<script language="JavaScript" type="text/javascript" src="'.$GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/js/wz_tooltip/wz_tooltip.js"></script>'."\n";
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user