forked from extern/egroupware
*calendar: feature/fix to allow to preselect the group and category for sitemgr plannerview; by Chr.Fueller
This commit is contained in:
parent
71b71ac7c4
commit
850dfec770
@ -152,6 +152,7 @@ class module_calendar_list extends Module
|
|||||||
|
|
||||||
function get_user_interface()
|
function get_user_interface()
|
||||||
{
|
{
|
||||||
|
//_debug_array($GLOBALS['Common_BO']->sites->current_site);
|
||||||
// copied from bookmarks module.
|
// copied from bookmarks module.
|
||||||
$cat = createobject('phpgwapi.categories','','calendar');
|
$cat = createobject('phpgwapi.categories','','calendar');
|
||||||
$cats = $cat->return_array('all',0,False,'','cat_name','',True);
|
$cats = $cat->return_array('all',0,False,'','cat_name','',True);
|
||||||
@ -165,12 +166,12 @@ class module_calendar_list extends Module
|
|||||||
$this->arguments['category']['multiple'] = 5;
|
$this->arguments['category']['multiple'] = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($GLOBALS['egw']->accounts))
|
if (!isset($GLOBALS['egw']->accounts))
|
||||||
{
|
{
|
||||||
$GLOBALS['egw']->accounts = new accounts();
|
$GLOBALS['egw']->accounts = new accounts();
|
||||||
}
|
}
|
||||||
$this->accounts =& $GLOBALS['egw']->accounts;
|
$this->accounts =& $GLOBALS['egw']->accounts;
|
||||||
$search_params=array(
|
$search_params = array(
|
||||||
'type' => 'both',
|
'type' => 'both',
|
||||||
'app' => 'calendar',
|
'app' => 'calendar',
|
||||||
);
|
);
|
||||||
@ -178,39 +179,7 @@ class module_calendar_list extends Module
|
|||||||
$users = array();
|
$users = array();
|
||||||
$groups = array();
|
$groups = array();
|
||||||
// sort users and groups separately.
|
// sort users and groups separately.
|
||||||
if (isset($GLOBALS['sitemgr_info']['anonymous_user']))
|
$anon_user = $this->accounts->name2id($GLOBALS['Common_BO']->sites->current_site['anonymous_user'],'account_lid','u');
|
||||||
{
|
|
||||||
$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);
|
$anon_groups = $this->accounts->memberships($anon_user,true);
|
||||||
foreach ($accounts as $entry)
|
foreach ($accounts as $entry)
|
||||||
{
|
{
|
||||||
|
@ -42,6 +42,11 @@ class module_calendar_planner extends Module
|
|||||||
'options' => array(), // done by get_user_interface()
|
'options' => array(), // done by get_user_interface()
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
),
|
),
|
||||||
|
'users' => array(
|
||||||
|
'type' => 'select',
|
||||||
|
'label' => lang('Group(s) or user(s) to show'),
|
||||||
|
'options' => array(),
|
||||||
|
),
|
||||||
'filter' => array(
|
'filter' => array(
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'label' => lang('Filter'),
|
'label' => lang('Filter'),
|
||||||
@ -70,7 +75,7 @@ class module_calendar_planner extends Module
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reimplemented to fetch the cats
|
* Reimplemented to fetch the cats, groups and resources
|
||||||
*/
|
*/
|
||||||
function get_user_interface()
|
function get_user_interface()
|
||||||
{
|
{
|
||||||
@ -83,6 +88,75 @@ class module_calendar_planner extends Module
|
|||||||
{
|
{
|
||||||
$this->arguments['cat_id']['multiple'] = 5;
|
$this->arguments['cat_id']['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.
|
||||||
|
$anon_user = $this->accounts->name2id($GLOBALS['Common_BO']->sites->current_site['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();
|
return parent::get_user_interface();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +170,7 @@ class module_calendar_planner extends Module
|
|||||||
{
|
{
|
||||||
translation::add_app('calendar');
|
translation::add_app('calendar');
|
||||||
|
|
||||||
|
//_debug_array($arguments);
|
||||||
$arguments['view'] = 'planner';
|
$arguments['view'] = 'planner';
|
||||||
if (empty($arguments['date']))
|
if (empty($arguments['date']))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user