mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 08:34:29 +01:00
Admin: Push for categories
This commit is contained in:
parent
ce5e30dc4c
commit
166168b5bf
@ -74,9 +74,16 @@ class admin_cmd_customfield extends admin_cmd
|
||||
if(array_keys($this->set) == array('id','name'))
|
||||
{
|
||||
// Delete
|
||||
$so = new Api\Storage\Base('phpgwapi','egw_customfields',null,'',true);
|
||||
$so = new Api\Storage\Base('phpgwapi', 'egw_customfields', null, '', true);
|
||||
$so->delete($this->set['id']);
|
||||
$deleted = true;
|
||||
|
||||
$push = new Api\Json\Push(Api\Json\Push::ALL);
|
||||
$push->apply("egw.push", [[
|
||||
'app' => Api\Storage\Customfields::PUSH_APP,
|
||||
'id' => $this->set['id'],
|
||||
'type' => 'delete'
|
||||
]]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -205,14 +205,15 @@ class admin_customfields
|
||||
{
|
||||
// Initialize nextmatch
|
||||
$content['nm'] = array(
|
||||
'get_rows' => 'admin.admin_customfields.get_rows',
|
||||
'no_cat' => 'true',
|
||||
'no_filter' => 'true',
|
||||
'no_filter2' => 'true',
|
||||
'row_id' => 'cf_id',
|
||||
'order' => 'cf_order',// IO name of the column to sort
|
||||
'sort' => 'ASC',// IO direction of the sort: 'ASC' or 'DESC'
|
||||
'actions' => $this->get_actions()
|
||||
'get_rows' => 'admin.admin_customfields.get_rows',
|
||||
'no_cat' => 'true',
|
||||
'no_filter' => 'true',
|
||||
'no_filter2' => 'true',
|
||||
'row_id' => 'cf_id',
|
||||
'order' => 'cf_order',// IO name of the column to sort
|
||||
'sort' => 'ASC',// IO direction of the sort: 'ASC' or 'DESC'
|
||||
'actions' => $this->get_actions(),
|
||||
'dataStorePrefix' => 'customfield'
|
||||
);
|
||||
}
|
||||
$content['nm']['appname'] = $this->appname;
|
||||
|
@ -326,12 +326,13 @@ class AdminApp extends EgwApp
|
||||
push(pushData : PushData)
|
||||
{
|
||||
// Filter out what we're not interested in
|
||||
if([this.appname, "api-cats"].indexOf(pushData.app) == -1)
|
||||
if([this.appname, "api-cats", "api-cf"].indexOf(pushData.app) == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const cat_template = "admin.categories.index";
|
||||
const cf_template = "admin.customfields";
|
||||
|
||||
if(this.appname.indexOf(pushData.app) != -1 && pushData.id > 0)
|
||||
{
|
||||
@ -349,6 +350,10 @@ class AdminApp extends EgwApp
|
||||
{
|
||||
(<et2_nextmatch>etemplate2.getByTemplate(cat_template)[0].widgetContainer.getWidgetById("nm")).refresh(pushData.id, pushData.type);
|
||||
}
|
||||
else if(pushData.app == "api-cf" && etemplate2.getByTemplate(cf_template).length == 1)
|
||||
{
|
||||
(<et2_nextmatch>etemplate2.getByTemplate(cf_template)[0].widgetContainer.getWidgetById("nm")).refresh(pushData.id, pushData.type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,6 +13,7 @@
|
||||
namespace EGroupware\Api\Storage;
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Json\Push;
|
||||
|
||||
/**
|
||||
* Managing custom-field definitions
|
||||
@ -51,6 +52,11 @@ class Customfields implements \IteratorAggregate
|
||||
*/
|
||||
protected $iterator;
|
||||
|
||||
/**
|
||||
* App name used to push custom field changes
|
||||
*/
|
||||
const PUSH_APP = 'api-cf';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -441,6 +447,35 @@ class Customfields implements \IteratorAggregate
|
||||
}
|
||||
|
||||
self::invalidate_cache($cf['app']);
|
||||
|
||||
// push category change
|
||||
$type = 'update';
|
||||
if(!$cf['id'])
|
||||
{
|
||||
$cfs = self::get($cf['app'], true);
|
||||
$cf = $cfs[$cf['name']];
|
||||
$type = 'add';
|
||||
}
|
||||
$accounts = Push::ALL;
|
||||
if(count($cf['private']) > 0)
|
||||
{
|
||||
$accounts = [];
|
||||
foreach($cf['private'] as $account_id)
|
||||
{
|
||||
$accounts = array_merge(
|
||||
$account_id > 0 ? [$account_id] :
|
||||
$GLOBALS['egw']->accounts->members($account_id, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
$push = new Push($accounts);
|
||||
$push->apply("egw.push", [[
|
||||
'app' => self::PUSH_APP,
|
||||
'id' => $cf['id'],
|
||||
'type' => $type,
|
||||
'acl' => ['private' => $cf['private']],
|
||||
'account_id' => $GLOBALS['egw_info']['user']['account_id']
|
||||
]]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user