mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
A few more change for the new integration interface, probably not the
last ...
This commit is contained in:
parent
0e405049b3
commit
890125cab5
@ -441,7 +441,15 @@ class calendar_bo
|
||||
{
|
||||
$events[$id] = $event;
|
||||
}
|
||||
if (!$this->check_perms(EGW_ACL_READ,$event) || (!$event['public'] && $filter == 'hideprivate'))
|
||||
if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/',$event['id'],$matches))
|
||||
{
|
||||
$is_private = self::integration_get_private($matches[1],$matches[2],$event);
|
||||
}
|
||||
else
|
||||
{
|
||||
$is_private = !$this->check_perms(EGW_ACL_READ,$event);
|
||||
}
|
||||
if ($is_private || (!$event['public'] && $filter == 'hideprivate'))
|
||||
{
|
||||
if($params['query'])
|
||||
{
|
||||
@ -515,6 +523,59 @@ class calendar_bo
|
||||
return $events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get integration data for a given app of a part (value for a certain key) of it
|
||||
*
|
||||
* @param string $app
|
||||
* @param string $part
|
||||
* @return array
|
||||
*/
|
||||
static function integration_get_data($app,$part=null)
|
||||
{
|
||||
static $integration_data;
|
||||
|
||||
if (!isset($integration_data))
|
||||
{
|
||||
$integration_data = calendar_so::get_integration_data();
|
||||
}
|
||||
|
||||
if (!isset($integration_data[$app])) return null;
|
||||
|
||||
return $part ? $integration_data[$app][$part] : $integration_data[$app];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get private attribute for an integration event
|
||||
*
|
||||
* Attribute 'is_private' is either a boolean value, eg. false to make all events of $app public
|
||||
* or an ExecMethod callback with parameters $id,$event
|
||||
*
|
||||
* @param string $app
|
||||
* @param int|string $id
|
||||
* @return string
|
||||
*/
|
||||
static function integration_get_private($app,$id,$event)
|
||||
{
|
||||
$app_data = self::integration_get_data($app,'is_private');
|
||||
|
||||
// no method, fall back to link title
|
||||
if (is_null($app_data))
|
||||
{
|
||||
$is_private = !egw_link::title($app,$id);
|
||||
}
|
||||
// boolean value to make all events of $app public (false) or private (true)
|
||||
elseif (is_bool($app_data))
|
||||
{
|
||||
$is_private = $app_data;
|
||||
}
|
||||
else
|
||||
{
|
||||
$is_private = (bool)ExecMethod2($app_data,$id,$event);
|
||||
}
|
||||
//echo '<p>'.__METHOD__."($app,$id,) returning ".array2string($is_private)."</p>\n";
|
||||
return $is_private;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all non-private info from a privat event
|
||||
*
|
||||
|
@ -538,6 +538,11 @@ class calendar_so
|
||||
return $events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data returned by calendar_search_union hook
|
||||
*/
|
||||
private static $integration_data;
|
||||
|
||||
/**
|
||||
* Ask other apps if they want to participate in calendar search / display
|
||||
*
|
||||
@ -551,7 +556,7 @@ class calendar_so
|
||||
*/
|
||||
private static function get_union_selects(array &$selects,$start,$end,$users,$cat_id,$filter,$query)
|
||||
{
|
||||
$app_selects = $GLOBALS['egw']->hooks->process(array(
|
||||
self::$integration_data = $GLOBALS['egw']->hooks->process(array(
|
||||
'location' => 'calendar_search_union',
|
||||
'cols' => $selects[0]['cols'], // cols to return
|
||||
'start' => $start,
|
||||
@ -561,15 +566,26 @@ class calendar_so
|
||||
'filter'=> $filter,
|
||||
'query' => $query,
|
||||
));
|
||||
foreach($app_selects as $app => $data)
|
||||
foreach(self::$integration_data as $app => $data)
|
||||
{
|
||||
if (is_array($data['selects']))
|
||||
{
|
||||
//echo $app; _debug_array($data);
|
||||
$selects = array_merge($selects,$data['selects']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data from last 'calendar_search_union' hook call
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_integration_data()
|
||||
{
|
||||
return self::$integration_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for conflicts
|
||||
*/
|
||||
|
@ -1173,24 +1173,13 @@ class calendar_uiviews extends calendar_ui
|
||||
$app = $matches[1];
|
||||
$app_id = $matches[2];
|
||||
$icons = array();
|
||||
if (($is_private = !egw_link::title($app,$app_id)))
|
||||
if (($is_private = calendar_bo::integration_get_private($app,$app_id,$event)))
|
||||
{
|
||||
$icons[] = html::image('calendar','private');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($event['icons'])
|
||||
{
|
||||
foreach(explode(',',$event['icons']) as $icon)
|
||||
{
|
||||
list($icon_app,$icon) = explode(':',$icon);
|
||||
if (common::find_image($icon_app,$icon))
|
||||
{
|
||||
$icons[] = html::image($icon_app,$icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
$icons[] = html::image($app,'navbar');
|
||||
$icons = self::integration_get_icons($app,$app_id,$event);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1334,21 +1323,7 @@ class calendar_uiviews extends calendar_ui
|
||||
}
|
||||
elseif($app && $app_id)
|
||||
{
|
||||
$popup = '';
|
||||
if (($edit = egw_link::edit($app,$app_id,$popup_size)))
|
||||
{
|
||||
$view_link = egw::link('/index.php',$edit);
|
||||
|
||||
if ($popup_size)
|
||||
{
|
||||
list($w,$h) = explode('x',$popup_size);
|
||||
$popup = ' onclick="'.$this->popup($view_link,'_blank',$w,$h).'; return false;"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$popup = ' onclick="location.href=\''.$view_link.'\'; return false;"';
|
||||
}
|
||||
}
|
||||
$popup = $this->integration_get_popup($app,$app_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1429,7 +1404,7 @@ class calendar_uiviews extends calendar_ui
|
||||
'errorImage'=>addslashes(html::image('phpgwapi','dialog_error',false,'style="width: 16px;"')),
|
||||
'loaderImage'=>addslashes(html::image('phpgwapi','ajax-loader')),
|
||||
),
|
||||
'calendar.dragDropFunctions.dragEvent',
|
||||
'calend false to make all events of $app publicar.dragDropFunctions.dragEvent',
|
||||
'calendar.dragDropFunctions.dropEvent',
|
||||
'top center 2'
|
||||
);
|
||||
@ -1438,6 +1413,88 @@ class calendar_uiviews extends calendar_ui
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get onclick attribute to open integration item for edit
|
||||
*
|
||||
* Name of the attribute is 'edit_link' and it should be an array with values for keys:
|
||||
* - 'edit' => array('menuaction' => 'app.class.method')
|
||||
* - 'edit_id' => 'app_id'
|
||||
* - 'edit_popup' => '400x300' (optional)
|
||||
*
|
||||
* @param string $app
|
||||
* @param int|string $id
|
||||
* @return string
|
||||
*/
|
||||
function integration_get_popup($app,$id)
|
||||
{
|
||||
$app_data = calendar_bo::integration_get_data($app,'edit_link');
|
||||
|
||||
if (is_array($app_data) && isset($app_data['edit']))
|
||||
{
|
||||
$popup_size = $app_data['edit_popup'];
|
||||
$edit = $app_data['edit'];
|
||||
$edit[$app_data['edit_id']] = $id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$edit = egw_link::edit($app,$id,$popup_size);
|
||||
}
|
||||
if ($edit)
|
||||
{
|
||||
$view_link = egw::link('/index.php',$edit);
|
||||
|
||||
if ($popup_size)
|
||||
{
|
||||
list($w,$h) = explode('x',$popup_size);
|
||||
$popup = ' onclick="'.$this->popup($view_link,'_blank',$w,$h).'; return false;"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$popup = ' onclick="location.href=\''.$view_link.'\'; return false;"';
|
||||
}
|
||||
}
|
||||
return $popup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get icons for an integration event
|
||||
*
|
||||
* Attribute 'icons' is either null (--> navbar icon), false (--> no icon)
|
||||
* or a callback with parameters $id,$event
|
||||
*
|
||||
* Icons specified in $events['icons'] are always displayed!
|
||||
*
|
||||
* @param string $app
|
||||
* @param int|string $id
|
||||
* @param array $event
|
||||
* @return array
|
||||
*/
|
||||
static function integration_get_icons($app,$id,$event)
|
||||
{
|
||||
$icons = array();
|
||||
if ($event['icons'])
|
||||
{
|
||||
foreach(explode(',',$event['icons']) as $icon)
|
||||
{
|
||||
list($icon_app,$icon) = explode(':',$icon);
|
||||
if (common::find_image($icon_app,$icon))
|
||||
{
|
||||
$icons[] = html::image($icon_app,$icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
$app_data = calendar_bo::integration_get_data($app,'icons');
|
||||
if (is_null($app_data))
|
||||
{
|
||||
$icons[] = html::image($app,'navbar'); // use navbar icon
|
||||
}
|
||||
elseif ($app_data)
|
||||
{
|
||||
$icons += (array)ExecMethod2($app_data,$id,$event);
|
||||
}
|
||||
return $icons;
|
||||
}
|
||||
|
||||
function add_nonempty($content,$label,$one_per_line=False,$space = True)
|
||||
{
|
||||
if (is_array($content))
|
||||
|
Loading…
Reference in New Issue
Block a user