forked from extern/egroupware
API: introduce register_single_app_hook to be able to add or update one hook for an required app. register added/updated hooks with ->location; calendar and addressbook are using this to insert export_limit hook if not available. use app hook to fetch app specific export limit with import_export side_menu additions too
This commit is contained in:
parent
93b7e6885c
commit
f616b34f58
@ -84,7 +84,7 @@ class addressbook_ui extends addressbook_bo
|
||||
}
|
||||
|
||||
// make sure the hook for export_limit is registered
|
||||
if (!$GLOBALS['egw']->hooks->hook_exists('export_limit','addressbook')) $GLOBALS['egw']->hooks->register_all_hooks();//register_hooks('addressbook');
|
||||
if (!$GLOBALS['egw']->hooks->hook_exists('export_limit','addressbook')) $GLOBALS['egw']->hooks->register_single_app_hook('addressbook','export_limit');
|
||||
|
||||
$this->config =& $GLOBALS['egw_info']['server'];
|
||||
|
||||
|
@ -165,7 +165,7 @@ class calendar_ui
|
||||
unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
|
||||
|
||||
// make sure the hook for export_limit is registered
|
||||
if (!$GLOBALS['egw']->hooks->hook_exists('export_limit','calendar')) $GLOBALS['egw']->hooks->register_all_hooks(); //register_hooks('calendar');
|
||||
if (!$GLOBALS['egw']->hooks->hook_exists('export_limit','calendar')) $GLOBALS['egw']->hooks->register_single_app_hook('calendar','export_limit');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,7 +121,8 @@ class importexport_admin_prefs_sidebox_hooks
|
||||
$file['Import CSV']['link'] = '';
|
||||
}
|
||||
}
|
||||
$export_limit = bo_merge::getExportLimit();
|
||||
$export_limit = $GLOBALS['egw']->hooks->single('export_limit',$appname);
|
||||
//error_log(__METHOD__.__LINE__.$appname.$export_limit);
|
||||
if ((bo_merge::is_export_limit_excepted() || bo_merge::hasExportLimit($export_limit,'ISALLOWED')) && $cache[$appname]['export'])
|
||||
{
|
||||
$file['Export CSV'] = array('link' => "javascript:egw_openWindowCentered2('".
|
||||
@ -140,7 +141,7 @@ class importexport_admin_prefs_sidebox_hooks
|
||||
if(($file_list = bo_merge::get_documents($GLOBALS['egw_info']['user']['preferences'][$appname]['document_dir'], '', array(
|
||||
'application/vnd.oasis.opendocument.spreadsheet',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
))))
|
||||
),$appname)))
|
||||
{
|
||||
$prefix = 'document_';
|
||||
|
||||
|
@ -241,10 +241,67 @@ class hooks
|
||||
'hook_appname' => $appname,
|
||||
'hook_location' => $location,
|
||||
),__LINE__,__FILE__);
|
||||
$this->locations[$location][$appname] = $filename;
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or/update a single application hook
|
||||
*
|
||||
* setup file of app will be included and the hook required will be added/or updated
|
||||
*
|
||||
* @param string $appname Application 'name'
|
||||
* @param string $location is required, the hook itself
|
||||
* @return boolean|int false on error, true if new hooks are supplied and registed or number of removed hooks
|
||||
*/
|
||||
function register_single_app_hook($appname, $location)
|
||||
{
|
||||
if(!$appname || empty($location))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
$SEP = filesystem_separator();
|
||||
// now register the rest again
|
||||
$f = EGW_SERVER_ROOT . $SEP . $appname . $SEP . 'setup' . $SEP . 'setup.inc.php';
|
||||
$setup_info = array($appname => array());
|
||||
if(@file_exists($f)) include($f);
|
||||
// some apps have setup_info for more then themselfs (eg. phpgwapi for groupdav)
|
||||
foreach($setup_info as $appname => $data)
|
||||
{
|
||||
if ($data['hooks'])
|
||||
{
|
||||
if ($hdata[$appname])
|
||||
{
|
||||
$hdata[$appname]['hooks'] = array_merge($hdata[$appname]['hooks'],$data['hooks']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$hdata[$appname]['hooks'] = $data['hooks'];
|
||||
}
|
||||
}
|
||||
}
|
||||
//error_log(__METHOD__.__LINE__.array2string($hdata));
|
||||
foreach((array)$hdata as $appname => $data)
|
||||
{
|
||||
if (array_key_exists($location,$data['hooks'])) $method = $data['hooks'][$location];
|
||||
}
|
||||
if (!empty($method))
|
||||
{
|
||||
//echo "<p>ADDING hooks for: $appname</p>";
|
||||
$this->db->insert($this->table,array(
|
||||
'hook_appname' => $appname,
|
||||
'hook_filename' => $method,
|
||||
'hook_location' => $location,
|
||||
),array(
|
||||
'hook_appname' => $appname,
|
||||
'hook_location' => $location,
|
||||
),__LINE__,__FILE__);
|
||||
$this->locations[$location][$appname] = $method;
|
||||
return True;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the hooks of all applications (used by admin)
|
||||
|
Loading…
Reference in New Issue
Block a user