mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 09:09:04 +01:00
allow integration apps to delete their entries through calendar
This commit is contained in:
parent
46c4e0e118
commit
c18e1107dd
@ -731,15 +731,16 @@ class calendar_bo
|
||||
*
|
||||
* @param string $app
|
||||
* @param string $part
|
||||
* @param boole $try_load=false true: load if not yet loaded
|
||||
* @return array
|
||||
*/
|
||||
static function integration_get_data($app,$part=null)
|
||||
static function integration_get_data($app, $part=null, $try_load=false)
|
||||
{
|
||||
static $integration_data=null;
|
||||
|
||||
if (!isset($integration_data))
|
||||
{
|
||||
$integration_data = calendar_so::get_integration_data();
|
||||
$integration_data = calendar_so::get_integration_data($try_load);
|
||||
}
|
||||
|
||||
if (!isset($integration_data[$app])) return null;
|
||||
@ -747,6 +748,25 @@ class calendar_bo
|
||||
return $part ? $integration_data[$app][$part] : $integration_data[$app];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an integration event is deletable
|
||||
*
|
||||
* @param string $app
|
||||
* @param array $event
|
||||
* @return bool
|
||||
*/
|
||||
static function integration_deletable($app, array $event)
|
||||
{
|
||||
$app_data = self::integration_get_data($app,'deletable');
|
||||
|
||||
if (empty($app_data) || is_bool($app_data))
|
||||
{
|
||||
return (bool)$app_data;
|
||||
}
|
||||
|
||||
return (bool)(is_callable($app_data) ? $app_data($event) : ExecMethod2($app_data, $event));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get private attribute for an integration event
|
||||
*
|
||||
|
@ -1244,10 +1244,16 @@ class calendar_so
|
||||
/**
|
||||
* Get data from last 'calendar_search_union' hook call
|
||||
*
|
||||
* @return array
|
||||
* @param boole $try_load=false true: load if not yet loaded
|
||||
* @return ?array
|
||||
*/
|
||||
public static function get_integration_data()
|
||||
public static function get_integration_data($try_load=false)
|
||||
{
|
||||
if (!isset(self::$integration_data) && $try_load)
|
||||
{
|
||||
$selects = [];
|
||||
self::get_union_selects($selects, 0, 0, [$GLOBALS['egw_info']['user']['account_id']], 0, [], '', [$GLOBALS['egw_info']['user']['account_id']]);
|
||||
}
|
||||
return self::$integration_data;
|
||||
}
|
||||
|
||||
|
@ -731,13 +731,12 @@ class calendar_ui
|
||||
|
||||
static $sent_groups = array();
|
||||
|
||||
if (!$this->bo->check_perms(Acl::EDIT,$event))
|
||||
if (!is_numeric($event['id']) || !$this->bo->check_perms(Acl::EDIT,$event))
|
||||
{
|
||||
$event['class'] .= 'rowNoEdit ';
|
||||
}
|
||||
|
||||
// Delete disabled for other applications
|
||||
if (!$this->bo->check_perms(Acl::DELETE,$event) || !is_numeric($event['id']))
|
||||
if (is_numeric($event['id']) && !$this->bo->check_perms(Acl::DELETE, $event))
|
||||
{
|
||||
$event['class'] .= 'rowNoDelete ';
|
||||
}
|
||||
@ -772,6 +771,11 @@ class calendar_ui
|
||||
}
|
||||
$event['app'] = $app;
|
||||
$event['app_id'] = $app_id;
|
||||
// check if integration-app allows/supports delete
|
||||
if (!calendar_bo::integration_deletable($app, $event))
|
||||
{
|
||||
$event['class'] .= 'rowNoDelete';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3261,9 +3261,22 @@ class calendar_uiforms extends calendar_ui
|
||||
*/
|
||||
public function ajax_delete($eventId)
|
||||
{
|
||||
list($id, $date) = explode(':',$eventId);
|
||||
$event=$this->bo->read($id);
|
||||
$response = Api\Json\Response::get();
|
||||
list($id, $date) = explode(':',$eventId);
|
||||
// let integration take care of delete for integration-events
|
||||
if (!is_numeric($id) && preg_match('/^([^\d]+)(\d+)$/', $id, $matches) &&
|
||||
!empty($app_data = calendar_bo::integration_get_data($matches[1], 'delete', true)))
|
||||
{
|
||||
try {
|
||||
$msg = is_callable($app_data) ? $app_data($matches[2]) : ExecMethod2($app_data, $matches[2]);
|
||||
$response->call('egw.refresh', $msg, 'calendar', $eventId, 'delete');
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$response->apply('egw.message', $e->getMessage(), 'error');
|
||||
}
|
||||
return;
|
||||
}
|
||||
$event=$this->bo->read($id);
|
||||
|
||||
if ($this->bo->delete($event['id'], (int)$date))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user