2014-03-27 20:00:52 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* EGroupware Admin: Hooks
|
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Stefan Becker <StefanBecker-AT-outdoor-training.de>
|
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
|
|
|
* @package admin
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
2016-03-05 16:32:49 +01:00
|
|
|
use EGroupware\Api;
|
2016-04-27 21:12:20 +02:00
|
|
|
use EGroupware\Api\Egw;
|
2016-03-05 16:32:49 +01:00
|
|
|
|
2014-03-27 20:00:52 +01:00
|
|
|
/**
|
|
|
|
* Static hooks for admin application
|
|
|
|
*/
|
|
|
|
class admin_hooks
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Functions callable via menuaction
|
|
|
|
*
|
2016-04-02 16:16:20 +02:00
|
|
|
* @var array
|
2014-03-27 20:00:52 +01:00
|
|
|
*/
|
|
|
|
var $public_functions = array(
|
2016-04-02 16:16:20 +02:00
|
|
|
'ajax_clear_cache' => True,
|
2014-03-27 20:00:52 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hooks to build projectmanager's sidebox-menu
|
|
|
|
*
|
|
|
|
* @param string/array $args hook args
|
|
|
|
*/
|
|
|
|
static function all_hooks($args)
|
|
|
|
{
|
|
|
|
unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
|
|
|
|
|
|
|
|
$appname = 'admin';
|
|
|
|
$location = is_array($args) ? $args['location'] : $args;
|
|
|
|
|
|
|
|
if ($location == 'sidebox_menu')
|
|
|
|
{
|
|
|
|
// Destination div for folder tree
|
|
|
|
$file[] = array(
|
|
|
|
'no_lang' => true,
|
2014-05-27 00:46:49 +02:00
|
|
|
// Tree has about 20 leaves (or more) in it, but the sidebox starts
|
|
|
|
// with no content. Set some minimum height to make sure scrolling is triggered.
|
|
|
|
'text' => '<div id="admin_tree_target" class="admin_tree" style="min-height:20em"/>',
|
2014-03-27 20:00:52 +01:00
|
|
|
'link' => false,
|
|
|
|
'icon' => false
|
|
|
|
);
|
|
|
|
display_sidebox($appname,lang('Admin'),$file);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ($GLOBALS['egw_info']['user']['apps']['admin'])
|
|
|
|
{
|
|
|
|
|
2015-08-04 11:55:29 +02:00
|
|
|
if (! $GLOBALS['egw']->acl->check('site_config_acce',1,'admin'))
|
2014-03-27 20:00:52 +01:00
|
|
|
{
|
2016-04-27 21:12:20 +02:00
|
|
|
$file['Site Configuration'] = Egw::link('/index.php','menuaction=admin.admin_config.index&appname=admin&ajax=true');
|
2014-03-27 20:00:52 +01:00
|
|
|
}
|
|
|
|
|
2014-04-01 09:49:32 +02:00
|
|
|
if (! $GLOBALS['egw']->acl->check('account_access',1,'admin'))
|
|
|
|
{
|
|
|
|
$file['User Accounts'] = array(
|
|
|
|
'id' => '/accounts',
|
2016-03-05 16:32:49 +01:00
|
|
|
'icon' => Api\Image::find('addressbook', 'accounts'),
|
2014-04-01 09:49:32 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-03-27 20:00:52 +01:00
|
|
|
if (! $GLOBALS['egw']->acl->check('account_access',16,'admin'))
|
|
|
|
{
|
2016-04-27 21:12:20 +02:00
|
|
|
$file['Bulk password reset'] = Egw::link('/index.php','menuaction=admin.admin_passwordreset.index&ajax=true');
|
2014-03-27 20:00:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (! $GLOBALS['egw']->acl->check('group_access',1,'admin'))
|
|
|
|
{
|
|
|
|
$file['User Groups'] = array(
|
|
|
|
'id' => '/groups',
|
2016-03-05 16:32:49 +01:00
|
|
|
'icon' => Api\Image::find('addressbook', 'group'),
|
2014-03-27 20:00:52 +01:00
|
|
|
'child' => 1,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-08-04 11:55:29 +02:00
|
|
|
if (! $GLOBALS['egw']->acl->check('global_categorie',1,'admin'))
|
2014-03-27 20:00:52 +01:00
|
|
|
{
|
2016-04-27 21:12:20 +02:00
|
|
|
$file['Global Categories'] = Egw::link('/index.php','menuaction=admin.admin_categories.index&appname=phpgw&ajax=true');
|
2014-03-27 20:00:52 +01:00
|
|
|
}
|
|
|
|
|
2015-08-04 11:55:29 +02:00
|
|
|
if (!$GLOBALS['egw']->acl->check('mainscreen_messa',1,'admin') || !$GLOBALS['egw']->acl->check('mainscreen_messa',2,'admin'))
|
2014-03-27 20:00:52 +01:00
|
|
|
{
|
2016-05-14 21:04:03 +02:00
|
|
|
$file['Change Main Screen Message'] = Egw::link('/index.php','menuaction=admin.admin_messages.index');
|
2014-03-27 20:00:52 +01:00
|
|
|
}
|
|
|
|
|
2015-08-04 11:55:29 +02:00
|
|
|
if (! $GLOBALS['egw']->acl->check('current_sessions',1,'admin'))
|
2014-03-27 20:00:52 +01:00
|
|
|
{
|
2016-04-27 21:12:20 +02:00
|
|
|
$file['View Sessions'] = Egw::link('/index.php','menuaction=admin.admin_accesslog.sessions&ajax=true');
|
2014-03-27 20:00:52 +01:00
|
|
|
}
|
|
|
|
|
2015-08-04 11:55:29 +02:00
|
|
|
if (! $GLOBALS['egw']->acl->check('access_log_acces',1,'admin'))
|
2014-03-27 20:00:52 +01:00
|
|
|
{
|
2016-04-27 21:12:20 +02:00
|
|
|
$file['View Access Log'] = Egw::link('/index.php','menuaction=admin.admin_accesslog.index&ajax=true');
|
2014-03-27 20:00:52 +01:00
|
|
|
}
|
|
|
|
|
2014-07-04 16:11:32 +02:00
|
|
|
/* disable old EGroupware error_log, as it is not used anymore
|
2014-03-27 20:00:52 +01:00
|
|
|
if (! $GLOBALS['egw']->acl->check('error_log_access',1,'admin'))
|
|
|
|
{
|
2016-04-27 21:12:20 +02:00
|
|
|
$file['View Error Log'] = Egw::link('/index.php','menuaction=admin.uilog.list_log');
|
2014-07-04 16:11:32 +02:00
|
|
|
}*/
|
2014-03-27 20:00:52 +01:00
|
|
|
|
2015-08-04 11:55:29 +02:00
|
|
|
if (! $GLOBALS['egw']->acl->check('applications_acc',16,'admin'))
|
2014-03-27 20:00:52 +01:00
|
|
|
{
|
2015-09-10 01:57:07 +02:00
|
|
|
$file['Clear cache and register hooks'] = array(
|
|
|
|
'id' => 'admin/clear_cache',
|
|
|
|
'no_lang' => true,
|
2016-07-28 12:02:01 +02:00
|
|
|
'link' => "javascript:app.admin.clear_cache();",
|
2015-09-10 01:57:07 +02:00
|
|
|
);
|
2014-03-27 20:00:52 +01:00
|
|
|
}
|
|
|
|
|
2015-08-04 11:55:29 +02:00
|
|
|
if (! $GLOBALS['egw']->acl->check('asyncservice_acc',1,'admin'))
|
2014-03-27 20:00:52 +01:00
|
|
|
{
|
2016-05-14 21:04:03 +02:00
|
|
|
$file['Asynchronous timed services'] = Egw::link('/index.php','menuaction=admin.admin_asyncservice.index');
|
2014-03-27 20:00:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (! $GLOBALS['egw']->acl->check('db_backup_access',1,'admin'))
|
|
|
|
{
|
2016-04-27 21:12:20 +02:00
|
|
|
$file['DB backup and restore'] = Egw::link('/index.php','menuaction=admin.admin_db_backup.index');
|
2014-03-27 20:00:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (! $GLOBALS['egw']->acl->check('info_access',1,'admin'))
|
|
|
|
{
|
2016-04-27 21:12:20 +02:00
|
|
|
$file['phpInfo'] = "javascript:egw.openPopup('" . Egw::link('/admin/phpinfo.php','',false) . "',960,600,'phpinfoWindow')";
|
2014-03-27 20:00:52 +01:00
|
|
|
}
|
2016-05-07 18:57:18 +02:00
|
|
|
$file['Admin queue and history'] = Egw::link('/index.php','menuaction=admin.admin_cmds.index&ajax=true');
|
|
|
|
$file['Remote administration instances'] = Egw::link('/index.php','menuaction=admin.admin_cmds.remotes&ajax=true');
|
2016-04-27 21:12:20 +02:00
|
|
|
$file['Custom translation'] = Egw::link('/index.php','menuaction=admin.admin_customtranslation.index');
|
2016-05-16 16:27:33 +02:00
|
|
|
$file['Changelog and versions'] = Egw::link('/index.php','menuaction=api.EGroupware\\Api\\Framework\\About.index&ajax=true');
|
2014-03-27 20:00:52 +01:00
|
|
|
|
2016-04-27 21:12:20 +02:00
|
|
|
$file['Submit statistic information'] = Egw::link('/index.php','menuaction=admin.admin_statistics.submit');
|
2014-03-27 20:00:52 +01:00
|
|
|
|
|
|
|
if ($location == 'admin')
|
|
|
|
{
|
|
|
|
display_section($appname,$file);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
foreach($file as &$url)
|
|
|
|
{
|
|
|
|
if (is_array($url) && $url['link']) $url = $url['link'];
|
|
|
|
}
|
|
|
|
display_sidebox($appname,lang('Admin'),$file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-04-02 16:16:20 +02:00
|
|
|
* Clears instance cache (and thereby also refreshes hooks)
|
2014-03-27 20:00:52 +01:00
|
|
|
*/
|
2016-04-02 16:16:20 +02:00
|
|
|
function ajax_clear_cache()
|
2014-03-27 20:00:52 +01:00
|
|
|
{
|
2015-08-04 11:55:29 +02:00
|
|
|
if ($GLOBALS['egw']->acl->check('applications_acc',16,'admin'))
|
2014-03-27 20:00:52 +01:00
|
|
|
{
|
|
|
|
$GLOBALS['egw']->redirect_link('/index.php');
|
|
|
|
}
|
2016-07-28 12:02:01 +02:00
|
|
|
Api\Cache::flush(Api\Cache::INSTANCE, !empty($_GET['errored']) ? "all" : null);
|
2014-03-27 20:00:52 +01:00
|
|
|
|
2016-03-05 16:32:49 +01:00
|
|
|
Api\Image::invalidate();
|
2014-03-27 20:00:52 +01:00
|
|
|
|
2016-04-27 21:12:20 +02:00
|
|
|
if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) // Egw object in setup is limited
|
2014-03-27 20:00:52 +01:00
|
|
|
{
|
|
|
|
$GLOBALS['egw']->invalidate_session_cache(); // in case with cache the egw_info array in the session
|
|
|
|
}
|
|
|
|
// allow apps to hook into "Admin >> Clear cache and register hooks"
|
2016-04-02 16:16:20 +02:00
|
|
|
Api\Hooks::process('clear_cache', array(), true);
|
2014-03-27 20:00:52 +01:00
|
|
|
|
2016-04-02 16:16:20 +02:00
|
|
|
Api\Json\Response::get()->apply('egw.message', array(lang('Done'), 'success'));
|
2014-03-27 20:00:52 +01:00
|
|
|
}
|
2014-03-28 19:54:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Actions for context menu of users
|
|
|
|
*
|
|
|
|
* @return array of actions
|
|
|
|
*/
|
|
|
|
public static function edit_user()
|
|
|
|
{
|
|
|
|
$actions = array();
|
|
|
|
|
2014-04-01 17:49:08 +02:00
|
|
|
$actions[] = array(
|
|
|
|
'id' => 'acl',
|
|
|
|
'caption' => 'Access control',
|
|
|
|
'url' => 'menuaction=admin.admin_acl.index&account_id=$id',
|
|
|
|
'popup' => '900x450',
|
|
|
|
'icon' => 'lock',
|
|
|
|
);
|
|
|
|
|
2015-08-04 11:55:29 +02:00
|
|
|
if (!$GLOBALS['egw']->acl->check('current_sessions',1,'admin')) // no rights to view
|
2014-03-28 19:54:40 +01:00
|
|
|
{
|
|
|
|
$actions[] = array(
|
|
|
|
'description' => 'Login History',
|
|
|
|
'url' => '/index.php',
|
2014-04-01 17:49:08 +02:00
|
|
|
'extradata' => 'menuaction=admin.admin_accesslog.index',
|
|
|
|
'icon' => 'timesheet',
|
2014-03-28 19:54:40 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$GLOBALS['egw']->acl->check('account_access',64,'admin')) // no rights to set ACL-rights
|
|
|
|
{
|
|
|
|
$actions[] = array(
|
|
|
|
'description' => 'Deny access',
|
|
|
|
'url' => '/index.php',
|
2016-05-14 21:04:03 +02:00
|
|
|
'extradata' => 'menuaction=admin.admin_denyaccess.list_apps',
|
2014-04-01 17:49:08 +02:00
|
|
|
'icon' => 'cancel',
|
2014-03-28 19:54:40 +01:00
|
|
|
);
|
|
|
|
}
|
2016-03-28 20:51:38 +02:00
|
|
|
|
|
|
|
// currently no way to deny Admins access to administrate mail
|
|
|
|
// we could add a deny check as for other admin functionality
|
|
|
|
{
|
|
|
|
$actions[] = array(
|
|
|
|
'id' => 'mail_account',
|
|
|
|
'caption' => 'mail account',
|
|
|
|
'url' => 'menuaction=admin.admin_mail.edit&account_id=$id',
|
|
|
|
'popup' => '720x530',
|
|
|
|
'icon' => 'mail/navbar',
|
|
|
|
);
|
|
|
|
|
|
|
|
$emailadmin = Api\Mail\Account::get_default();
|
|
|
|
if ($emailadmin->acc_smtp_type && $emailadmin->acc_smtp_type !== 'EGroupware\Api\Mail\Smtp')
|
|
|
|
{
|
|
|
|
$actions[] = array (
|
|
|
|
'id' => 'mail_activeAccounts',
|
|
|
|
'caption' => '(de)activate mail accounts',
|
|
|
|
'icon' => 'mail/navbar',
|
|
|
|
'children' => array (
|
|
|
|
'active' => array (
|
|
|
|
'caption' => 'activate',
|
|
|
|
'onExecute' => 'javaScript:app.admin.emailadminActiveAccounts',
|
|
|
|
'icon' => 'check',
|
|
|
|
'allowOnMultiple' => true
|
|
|
|
),
|
|
|
|
'inactive' => array (
|
|
|
|
'caption' => 'deactivate',
|
|
|
|
'onExecute' => 'javaScript:app.admin.emailadminActiveAccounts',
|
|
|
|
'icon' => 'bullet',
|
|
|
|
'allowOnMultiple' => true
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2014-03-28 19:54:40 +01:00
|
|
|
return $actions;
|
|
|
|
}
|
2016-04-21 18:39:59 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called before displaying site configuration
|
|
|
|
*
|
|
|
|
* @param array $config
|
2016-04-27 21:12:20 +02:00
|
|
|
* @return array with additional Api\Config to merge
|
2016-04-21 18:39:59 +02:00
|
|
|
*/
|
|
|
|
public static function config(array $config)
|
|
|
|
{
|
|
|
|
$ret = array();
|
2016-07-08 16:37:15 +02:00
|
|
|
if (empty($config['fw_mobile_app_list']))
|
2016-04-21 18:39:59 +02:00
|
|
|
{
|
2016-07-08 16:37:15 +02:00
|
|
|
$ret['fw_mobile_app_list'] = Api\Framework\Ajax::DEFAULT_MOBILE_APPS;
|
2016-04-21 18:39:59 +02:00
|
|
|
}
|
|
|
|
return $ret;
|
|
|
|
}
|
2014-03-27 20:00:52 +01:00
|
|
|
}
|