using new api for admin, though 3 classes still use old etemplate

This commit is contained in:
Ralf Becker 2016-04-27 19:12:20 +00:00
parent b6403e336e
commit 01c396e5d3
38 changed files with 646 additions and 723 deletions

View File

@ -1,15 +1,18 @@
<?php
/**
* EGgroupware admin - access- and session-log
* EGroupware admin - access- and session-log
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin
* @copyright (c) 2009-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2009-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Etemplate;
/**
* Show EGroupware access- and session-log
*/
@ -28,7 +31,7 @@ class admin_accesslog
/**
* Our storage object
*
* @var so_sql
* @var Api\Storage\Base
*/
protected $so;
@ -47,7 +50,7 @@ class admin_accesslog
*/
function __construct()
{
$this->so = new so_sql(self::APP,self::TABLE,null,'',true);
$this->so = new Api\Storage\Base(self::APP,self::TABLE,null,'',true);
$this->so->timestamps = array('li', 'lo', 'session_dla', 'notification_heartbeat');
}
@ -62,7 +65,7 @@ class admin_accesslog
*/
function get_rows($query,&$rows,&$readonlys)
{
$heartbeat_limit = egw_session::heartbeat_limit();
$heartbeat_limit = Api\Session::heartbeat_limit();
if ($query['session_list']) // filter active sessions
{
@ -82,7 +85,7 @@ class admin_accesslog
}
$total = $this->so->get_rows($query,$rows,$readonlys);
$heartbeat_limit_user = egw_time::server2user($heartbeat_limit, 'ts');
$heartbeat_limit_user = Api\DateTime::server2user($heartbeat_limit, 'ts');
foreach($rows as &$row)
{
@ -124,7 +127,7 @@ class admin_accesslog
}
$GLOBALS['egw_info']['flags']['app_header'] = lang('Admin').' - '.
($query['session_list'] ? lang('View sessions') : lang('View Access Log')).
($query['col_filter']['account_id'] ? ': '.common::grab_owner_name($query['col_filter']['account_id']) : '');
($query['col_filter']['account_id'] ? ': '.Api\Accounts::username($query['col_filter']['account_id']) : '');
return $total;
}
@ -241,7 +244,7 @@ class admin_accesslog
'SELECT ((SELECT COUNT(*) FROM '.self::TABLE.' WHERE lo != 0) / COUNT(*)) FROM '.self::TABLE,
__LINE__,__FILE__)->fetchColumn();
$tmpl = new etemplate_new('admin.accesslog');
$tmpl = new Etemplate('admin.accesslog');
$tmpl->exec('admin.admin_accesslog.index', $content, array(), $readonlys, array(
'nm' => $content['nm'],
));

View File

@ -10,6 +10,11 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Acl;
use EGroupware\Api\Etemplate;
/**
* UI for admin: edit/add account
*/
@ -29,7 +34,7 @@ class admin_account
*
* @param array $content
* @return array
* @throws egw_exception_not_found
* @throws Api\Exception\NotFound
*/
public function addressbook_edit(array $content)
{
@ -39,27 +44,27 @@ class admin_account
$GLOBALS['egw']->acl->check('account_access', 4, 'admin');
//error_log(__METHOD__."() contact_id=$content[contact_id], account_id=$content[account_id], deny_edit=".array2string($deny_edit));
if (!$content['account_id'] && $deny_edit) return; // no right to add new accounts, should not happen by AB ACL
if (!$content['account_id'] && $deny_edit) return; // no right to add new Api\Accounts, should not happen by AB ACL
// load our translations
translation::add_app('admin');
Api\Translation::add_app('admin');
if ($content['id']) // existing account
{
// invalidate account, before reading it, to code with changed to DB or LDAP outside EGw
accounts::cache_invalidate((int)$content['account_id']);
Api\Accounts::cache_invalidate((int)$content['account_id']);
if (!($account = $GLOBALS['egw']->accounts->read($content['account_id'])))
{
throw new egw_exception_not_found('Account data NOT found!');
throw new Api\Exception\NotFound('Account data NOT found!');
}
if ($account['account_expires'] == -1) $account['account_expires'] = '';
unset($account['account_pwd']); // do NOT send to client
$account['memberships'] = array_keys($account['memberships']);
$acl = new acl($content['account_id']);
$acl = new Acl($content['account_id']);
$acl->read_repository();
$account['anonymous'] = $acl->check('anonymous', 1, 'phpgwapi');
$account['changepassword'] = !$acl->check('nopasswordchange', 1, 'preferences');
$auth = new auth();
$auth = new Api\Auth();
if (($account['account_lastpwd_change'] = $auth->getLastPwdChange($account['account_lid'])) === false)
{
$account['account_lastpwd_change'] = null;
@ -174,13 +179,13 @@ class admin_account
$cmd = new admin_cmd_edit_user((int)$content['account_id'], $account);
$cmd->run();
egw_json_response::get()->call('egw.refresh', '', 'admin', $cmd->account, $content['account_id'] ? 'edit' : 'add');
Api\Json\Response::get()->call('egw.refresh', '', 'admin', $cmd->account, $content['account_id'] ? 'edit' : 'add');
$addressbook_bo = new addressbook_bo();
if (!($content['id'] = accounts::id2name($cmd->account, 'person_id')) ||
$addressbook_bo = new Api\Contacts();
if (!($content['id'] = Api\Accounts::id2name($cmd->account, 'person_id')) ||
!($contact = $addressbook_bo->read($content['id'])))
{
throw new egw_exception_assertion_failed("Can't find contact of just created account!");
throw new Api\Exception\AssertionFailed("Can't find contact of just created account!");
}
// for a new account a new contact was created, need to merge that data with $content
if (!$content['account_id'])
@ -219,7 +224,7 @@ class admin_account
if ($GLOBALS['egw']->acl->check('account_access',32,'admin') || !($content['account_id'] > 0) ||
$GLOBALS['egw_info']['user']['account_id'] == $content['account_id'])
{
egw_framework::window_close(lang('Permission denied!!!'));
Framework::window_close(lang('Permission denied!!!'));
}
if ($content['delete'])
{
@ -227,15 +232,15 @@ class admin_account
$msg = $cmd->run();
if ($content['contact_id'])
{
egw_framework::refresh_opener($msg, 'addressbook', $content['contact_id'], 'delete');
Framework::refresh_opener($msg, 'addressbook', $content['contact_id'], 'delete');
}
else
{
egw_framework::refresh_opener($msg, 'admin', $content['account_id'], 'delete');
Framework::refresh_opener($msg, 'admin', $content['account_id'], 'delete');
}
egw_framework::window_close();
Framework::window_close();
}
$tpl = new etemplate_new('admin.account.delete');
$tpl = new Etemplate('admin.account.delete');
$tpl->exec('admin_account::delete', $content, array(), array(), $content, 2);
}
@ -246,10 +251,10 @@ class admin_account
*/
public static function ajax_delete_group($account_id)
{
$cmd = new admin_cmd_delete_account(accounts::id2name(accounts::id2name($account_id)), null, false);
$cmd = new admin_cmd_delete_account(Api\Accounts::id2name(Api\Accounts::id2name($account_id)), null, false);
$msg = $cmd->run();
egw_json_response::get()->call('egw.refresh', $msg, 'admin', $account_id, 'delete');
Api\Json\Response::get()->call('egw.refresh', $msg, 'admin', $account_id, 'delete');
}
/**
@ -260,26 +265,26 @@ class admin_account
*/
public static function ajax_check(array $data, $changed)
{
// generate default email address, but only for new accounts
// generate default email address, but only for new Api\Accounts
if (!$data['account_id'] && in_array($changed, array('n_given', 'n_family', 'account_lid')))
{
$email = common::email_address($data['account_firstname'], $data['account_lastname'], $data['account_lid']);
$email = Api\Accounts::email($data['account_firstname'], $data['account_lastname'], $data['account_lid']);
if ($email && $email[0] != '@' && strpos($email, '@')) // only add valid email addresses
{
egw_json_response::get()->assign('addressbook-edit_email', 'value', $email);
Api\Json\Response::get()->assign('addressbook-edit_email', 'value', $email);
}
}
if (!$data['account_lid'] && !$data['account_id']) return; // makes no sense to check before
// set home-directory when account_lid is entered, but only for new accounts
// set home-directory when account_lid is entered, but only for new Api\Accounts
if ($changed == 'account_lid' && !$data['account_id'] &&
$GLOBALS['egw_info']['server']['ldap_extra_attributes'] &&
$GLOBALS['egw_info']['server']['ldap_account_home'])
{
egw_json_response::get()->assign('addressbook-edit_homedirectory', 'value',
Api\Json\Response::get()->assign('addressbook-edit_homedirectory', 'value',
$GLOBALS['egw_info']['server']['ldap_account_home'].'/'.preg_replace('/[^a-z0-9_.-]/i', '',
common::transliterate($data['account_lid'])));
Api\Translation::to_ascii($data['account_lid'])));
}
// set dummy membership to get no error about no members yet
@ -291,7 +296,7 @@ class admin_account
}
catch(Exception $e)
{
egw_json_response::get()->data($e->getMessage());
Api\Json\Response::get()->data($e->getMessage());
}
}
}

View File

@ -10,6 +10,11 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Acl;
use EGroupware\Api\Etemplate;
/**
* UI for admin ACL
*
@ -26,9 +31,9 @@ class admin_acl
);
/**
* Reference to global acl class (instanciated for current user)
* Reference to global Acl class (instanciated for current user)
*
* @var acl
* @var Acl
*/
protected $acl;
@ -70,15 +75,15 @@ class admin_acl
}
elseif (!$old_apps)
{
egw_framework::refresh_opener(lang('ACL added.'), 'admin', null, 'add');
Framework::refresh_opener(lang('ACL added.'), 'admin', null, 'add');
}
elseif (!$added_apps)
{
egw_framework::refresh_opener(lang('ACL deleted.'), 'admin', $deleted_ids, 'delete');
Framework::refresh_opener(lang('ACL deleted.'), 'admin', $deleted_ids, 'delete');
}
else
{
egw_framework::refresh_opener(lang('ACL updated.'), 'admin', null, 'edit');
Framework::refresh_opener(lang('ACL updated.'), 'admin', null, 'edit');
}
}
@ -106,24 +111,24 @@ class admin_acl
elseif (!$rights) // all rights removed --> delete it
{
$this->acl->delete_repository($content['acl_appname'], $content['acl_location'], $content['acl_account']);
egw_framework::refresh_opener(lang('ACL deleted.'), 'admin', $id, 'delete');
Framework::refresh_opener(lang('ACL deleted.'), 'admin', $id, 'delete');
}
else
{
$this->acl->add_repository($content['acl_appname'], $content['acl_location'], $content['acl_account'], $rights);
if ($content['id'])
{
egw_framework::refresh_opener(lang('ACL updated.'), 'admin', $id, 'edit');
Framework::refresh_opener(lang('ACL updated.'), 'admin', $id, 'edit');
}
else
{
egw_framework::refresh_opener(lang('ACL added.'), 'admin', $id, 'add');
Framework::refresh_opener(lang('ACL added.'), 'admin', $id, 'add');
}
}
}
/**
* Callback for nextmatch to fetch acl
* Callback for nextmatch to fetch Acl
*
* @param array $query
* @param array &$rows=null
@ -131,7 +136,7 @@ class admin_acl
*/
public static function get_rows(array $query, array &$rows=null)
{
$so_sql = new so_sql('phpgwapi', acl::TABLE, null, '', true);
$so_sql = new Api\Storage\Base('phpgwapi', Acl::TABLE, null, '', true);
// client queries destinct rows by their row-id
if (isset($query['col_filter']['id']))
@ -145,7 +150,7 @@ class admin_acl
$memberships = $GLOBALS['egw']->accounts->memberships($query['account_id'], true);
$memberships[] = $query['account_id'];
egw_cache::setSession(__CLASS__, 'state', array(
Api\Cache::setSession(__CLASS__, 'state', array(
'account_id' => $query['account_id'],
'filter' => $query['filter'],
'acl_appname' => $query['filter2'],
@ -175,7 +180,7 @@ class admin_acl
$query['col_filter'][] = "acl_location SIMILAR TO '-?[0-9]+'";
}
// get apps not using group-acl (eg. Addressbook) or using it only partialy (eg. InfoLog)
$not_enum_group_acls = $GLOBALS['egw']->hooks->process('not_enum_group_acls', array(), true);
$not_enum_group_acls = Api\Hooks::process('not_enum_group_acls', array(), true);
//error_log(__METHOD__."(filter=$query[filter]) not_enum_group_acl=".array2string($not_enum_group_acls));
if ($not_enum_group_acls)
{
@ -192,13 +197,13 @@ class admin_acl
//error_log(__METHOD__."() app=$app, array_diff(memberships=".array2string($memberships).", groups=".array2string($groups).")=".array2string($check));
if (!$check) continue; // would give sql error otherwise!
}
$sql .= ' WHEN '.$GLOBALS['egw']->db->quote($app).' THEN '.$GLOBALS['egw']->db->expression(acl::TABLE, array(
$sql .= ' WHEN '.$GLOBALS['egw']->db->quote($app).' THEN '.$GLOBALS['egw']->db->expression(Acl::TABLE, array(
'acl_account' => $check,
));
}
$sql .= ' ELSE ';
}
$sql .= $GLOBALS['egw']->db->expression(acl::TABLE, array(
$sql .= $GLOBALS['egw']->db->expression(Acl::TABLE, array(
'acl_account' => $memberships,
));
if ($not_enum_group_acls) $sql .= ' END)';
@ -231,7 +236,7 @@ class admin_acl
}
else
{
if ($app !== $row['acl_appname']) translation::add_app($row['app_name']);
if ($app !== $row['acl_appname']) Api\Translation::add_app($row['app_name']);
foreach($query['acl_rights'][$row['acl_appname']] as $val => $label)
{
if ($row['acl_rights'] & $val)
@ -260,7 +265,7 @@ class admin_acl
$rows['sel_options']['filter2'] = array(
array('value' => '', 'label' => lang('All applications'))
);
$apps = $GLOBALS['egw']->hooks->process(array(
$apps = Api\Hooks::process(array(
'location' => 'acl_rights',
'owner' => $query['account_id'],
), array(), true);
@ -286,7 +291,7 @@ class admin_acl
* @param int|string $location =null numeric account-id or "run"
* @param boolean $throw =true if true, throw an exception if no access, instead of just returning false
* @return boolean true if access is granted, false if notification_bo
* @throws egw_exception_no_permission
* @throws Api\Exception\NoPermission
*/
public static function check_access($account_id, $location=null, $throw=true)
{
@ -301,7 +306,7 @@ class admin_acl
if (!(int)$account_id || !((int)$account_id == (int)$GLOBALS['egw_info']['user']['account_id'] && $location !== 'run' ?
$own_access : $admin_access))
{
if ($throw) throw new egw_exception_no_permission(lang('Permission denied!!!'));
if ($throw) throw new Api\Exception\NoPermission(lang('Permission denied!!!'));
return false;
}
return true;
@ -321,7 +326,7 @@ class admin_acl
{
$list = array_keys($GLOBALS['egw']->acl->get_user_applications((int)$account_id,false,false));
}
egw_json_response::get()->data($list);
Api\Json\Response::get()->data($list);
}
/**
@ -331,7 +336,7 @@ class admin_acl
*
* @param string|array $ids "$app:$account:$location" string used as row-id in list
* @param int $rights =null null to delete, or new rights
* @throws egw_exception_no_permission
* @throws Api\Exception\NoPermission
*/
public static function ajax_change_acl($ids, $rights=null)
{
@ -368,14 +373,14 @@ class admin_acl
{
$msg = lang('ACL updated');
}
egw_json_response::get()->data(array(
Api\Json\Response::get()->data(array(
'msg' => $msg,
'ids' => $ids,
'type' => !(int)$rights ? 'delete' : 'add',
));
}
catch (Exception $e) {
egw_json_response::get()->call('egw.message', $e->getMessage(), 'error');
Api\Json\Response::get()->call('egw.message', $e->getMessage(), 'error');
}
}
@ -388,7 +393,7 @@ class admin_acl
{
unset($_content); // not used, required by function signature
$tpl = new etemplate_new('admin.acl');
$tpl = new Etemplate('admin.acl');
$content = array();
$account_id = isset($_GET['account_id']) && (int)$_GET['account_id'] ?
@ -406,12 +411,12 @@ class admin_acl
'row_id' => 'id',
'account_id' => $account_id,
'actions' => self::get_actions(),
'acl_rights' => $GLOBALS['egw']->hooks->process(array(
'acl_rights' => Api\Hooks::process(array(
'location' => 'acl_rights',
'owner' => $account_id,
), array(), true),
);
$user = common::grab_owner_name($content['nm']['account_id']);
$user = Api\Accounts::username($content['nm']['account_id']);
$sel_options = array(
'filter' => array(
'other' => lang('Access to %1 data by others', $user),

View File

@ -1,15 +1,21 @@
<?php
/**
* EGgroupware admin - Edit global categories
* EGroupware admin - Edit global categories
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin
* @copyright (c) 2010-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2010-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Acl;
use EGroupware\Api\Etemplate;
use EGroupware\Api\Categories;
/**
* Edit global categories
*/
@ -55,7 +61,7 @@ class admin_categories
{
if (!isset($GLOBALS['egw_info']['user']['apps']['admin']))
{
throw new egw_exception_no_permission_admin();
throw new Api\Exception\NoPermission\Admin();
}
if ($GLOBALS['egw']->acl->check('global_categorie',1,'admin'))
{
@ -90,19 +96,19 @@ class admin_categories
{
// read the session, as the global_cats param is stored with it.
$appname = $content['appname'] ? $content['appname'] : ($_GET['appname']?$_GET['appname']:categories::GLOBAL_APPNAME);
$session = egw_cache::getSession(__CLASS__.$appname,'nm');
$session = Api\Cache::getSession(__CLASS__.$appname,'nm');
unset($session);
if (!isset($content))
{
if (!(isset($_GET['cat_id']) && $_GET['cat_id'] > 0 &&
($content = categories::read($_GET['cat_id']))))
($content = Categories::read($_GET['cat_id']))))
{
$content = array('data' => array());
if(isset($_GET['parent']) && $_GET['parent'] > 0)
{
// Sub-category - set some defaults from parent
$content['parent'] = (int)$_GET['parent'];
$parent_cat = categories::read($content['parent']);
$parent_cat = Categories::read($content['parent']);
$content['owner'] = $parent_cat['owner'];
}
if (isset($_GET['appname']) && isset($GLOBALS['egw_info']['apps'][$_GET['appname']]))
@ -111,7 +117,7 @@ class admin_categories
}
else
{
$appname = categories::GLOBAL_APPNAME;
$appname = Categories::GLOBAL_APPNAME;
}
}
elseif ($content['appname'] != $appname || !self::$acl_edit || ( $content['owner'] != $GLOBALS['egw_info']['user']['account_id'] && $this->appname != 'admin'))
@ -124,7 +130,7 @@ class admin_categories
}
elseif ($content['button'] || $content['delete'])
{
$cats = new categories($content['owner'] ? $content['owner'] : categories::GLOBAL_ACCOUNT,$content['appname']);
$cats = new Categories($content['owner'] ? $content['owner'] : Categories::GLOBAL_ACCOUNT,$content['appname']);
if ($content['delete']['delete'] || $content['delete']['subs'])
{
@ -154,7 +160,7 @@ class admin_categories
$cats->edit($content);
$msg = lang('Category saved.');
}
catch (egw_exception_wrong_userinput $e)
catch (Api\Exception\WrongUserinput $e)
{
$msg = lang('Unwilling to save category with current settings. Check for inconsistency:').$e->getMessage(); // display conflicts etc.
}
@ -177,24 +183,24 @@ class admin_categories
// Nicely reload just the category window / iframe
if($change_color)
{
if(egw_json_response::isJSONResponse())
if(Api\Json\Response::isJSONResponse())
{
// Update category styles
egw_json_response::get()->apply('opener.egw.includeCSS',array(categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app)));
Api\Json\Response::get()->apply('opener.egw.includeCSS',array(Categories::css($refresh_app == 'admin' ? Categories::GLOBAL_APPNAME : $refresh_app)));
if($this->appname != 'admin')
{
egw_json_response::get()->apply('opener.egw.show_preferences',array(
Api\Json\Response::get()->apply('opener.egw.show_preferences',array(
'cats',
$this->appname == 'admin' ? categories::GLOBAL_APPNAME : array($refresh_app)
$this->appname == 'admin' ? Categories::GLOBAL_APPNAME : array($refresh_app)
));
$change_color = false;
}
else
{
categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app);
Categories::css($refresh_app == 'admin' ? Categories::GLOBAL_APPNAME : $refresh_app);
// Need to forcably re-load the iframe to avoid smart etemplate refresh
egw_json_response::get()->apply('opener.app.admin.load',array(
egw_framework::link('/index.php', array(
Api\Json\Response::get()->apply('opener.app.admin.load',array(
Framework::link('/index.php', array(
'menuaction' => $this->list_link,
'appname' => $appname
)
@ -203,11 +209,11 @@ class admin_categories
}
else
{
categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app);
egw_framework::refresh_opener('', null, null);
Categories::css($refresh_app == 'admin' ? Categories::GLOBAL_APPNAME : $refresh_app);
Framework::refresh_opener('', null, null);
if ($button == 'save')
{
egw_framework::window_close();
Framework::window_close();
}
return;
}
@ -215,8 +221,8 @@ class admin_categories
if ($button == 'save')
{
egw_framework::refresh_opener($msg, $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname);
egw_framework::window_close();
Framework::refresh_opener($msg, $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname);
Framework::window_close();
}
break;
@ -226,8 +232,8 @@ class admin_categories
$cats->delete($content['id'],$delete_subs,!$delete_subs);
$msg = lang('Category deleted.');
egw_framework::refresh_opener($msg, $refresh_app, $content['id'],'delete', $this->appname);
egw_framework::window_close();
Framework::refresh_opener($msg, $refresh_app, $content['id'],'delete', $this->appname);
Framework::window_close();
return;
}
else
@ -238,7 +244,7 @@ class admin_categories
break;
}
// This should probably refresh the application $this->appname in the target tab $refresh_app, but that breaks pretty much everything
egw_framework::refresh_opener($msg, $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname);
Framework::refresh_opener($msg, $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname);
}
$content['msg'] = $msg;
if(!$content['appname']) $content['appname'] = $appname;
@ -265,7 +271,7 @@ class admin_categories
if($this->appname != 'admin' && $content['owner'] > 0 )
{
$sel_options['owner'][$content['owner']] = common::grab_owner_name($content['owner']);
$sel_options['owner'][$content['owner']] = Api\Accounts::username($content['owner']);
}
// Add 'All users', in case owner is readonlys
if($content['id'] && $content['owner'] == 0)
@ -276,7 +282,7 @@ class admin_categories
{
if($content['owner'] > 0)
{
$content['msg'] .= "\n".lang('owner "%1" removed, please select group-owner', common::grab_owner_name($content['owner']));
$content['msg'] .= "\n".lang('owner "%1" removed, please select group-owner', Api\Accounts::username($content['owner']));
$content['owner'] = 0;
}
$sel_options['owner'][0] = lang('All users');
@ -285,7 +291,7 @@ class admin_categories
{
if ($acc['account_type'] == 'g')
{
$sel_options['owner'][$acc['account_id']] = ExecMethod2('etemplate.select_widget.accountInfo',$acc['account_id'],$acc);
$sel_options['owner'][$acc['account_id']] = Etemplate\Widget\Select::accountInfo($acc['account_id'], $acc);
}
}
$content['no_private'] = true;
@ -302,14 +308,14 @@ class admin_categories
$readonlys['access'] = $content['owner'] != $GLOBALS['egw_info']['user']['account_id'];
}
egw_framework::validate_file('.','global_categories','admin');
Framework::includeJS('.','global_categories','admin');
$readonlys['button[delete]'] = !$content['id'] || !self::$acl_delete || // cant delete not yet saved category
$appname != $content['appname'] || // Can't edit a category from a different app
($this->appname != 'admin' && $content['owner'] != $GLOBALS['egw_info']['user']['account_id']);
// Make sure $content['owner'] is an array otherwise it wont show up values in the multiselectbox
if (!is_array($content['owner'])) $content['owner'] = explode(',',$content['owner']);
$tmpl = new etemplate_new('admin.categories.edit');
$tmpl = new Etemplate('admin.categories.edit');
$tmpl->exec($this->edit_link,$content,$sel_options,$readonlys,$content+array(
'old_parent' => $content['old_parent'] ? $content['old_parent'] : $content['parent'], 'appname' => $appname
),2);
@ -354,7 +360,7 @@ class admin_categories
*
* @param array $query with keys 'start', 'search', 'order', 'sort', 'col_filter'
* @param array &$rows returned rows/competitions
* @param array &$readonlys eg. to disable buttons based on acl, not use here, maybe in a derived class
* @param array &$readonlys eg. to disable buttons based on Acl, not use here, maybe in a derived class
* @return int total number of rows
*/
public function get_rows(&$query,&$rows,&$readonlys)
@ -362,7 +368,7 @@ class admin_categories
self::init_static();
$filter = array();
$globalcat = ($query['filter'] === categories::GLOBAL_ACCOUNT || !$query['filter']);
$globalcat = ($query['filter'] === Categories::GLOBAL_ACCOUNT || !$query['filter']);
if (isset($query['global_cats']) && $query['global_cats']===false)
{
$globalcat = false;
@ -371,7 +377,7 @@ class admin_categories
// new column-filter access has highest priority
if (!empty($query['col_filter']['access']))$filter['access'] = $query['col_filter']['access'];
egw_cache::setSession(__CLASS__.$query['appname'],'nm',$query);
Api\Cache::setSession(__CLASS__.$query['appname'],'nm',$query);
if($query['filter'] > 0 || $query['col_filter']['owner'])
{
@ -381,8 +387,8 @@ class admin_categories
{
$filter['appname'] = $query['col_filter']['app'];
}
$GLOBALS['egw']->categories = $cats = new categories($filter['owner'],$query['appname']);
$globals = isset($GLOBALS['egw_info']['user']['apps']['admin']) ? 'all_no_acl' : $globalcat; // ignore acl only for admins
$GLOBALS['egw']->categories = $cats = new Categories($filter['owner'],$query['appname']);
$globals = isset($GLOBALS['egw_info']['user']['apps']['admin']) ? 'all_no_acl' : $globalcat; // ignore Acl only for admins
$parent = $query['search'] ? false : 0;
$rows = $cats->return_sorted_array($query['start'],false,$query['search'],$query['sort'],$query['order'],$globals,$parent,true,$filter);
$count = $cats->total_records;
@ -409,18 +415,18 @@ class admin_categories
}
else if (!$GLOBALS['egw_info']['user']['apps']['admin'])
{
if(!$cats->check_perms(EGW_ACL_EDIT, $row['id']) || !self::$acl_edit)
if(!$cats->check_perms(Acl::EDIT, $row['id']) || !self::$acl_edit)
{
$row['class'] .= ' rowNoEdit';
}
if(!$cats->check_perms(EGW_ACL_DELETE, $row['id']) || !self::$acl_delete ||
if(!$cats->check_perms(Acl::DELETE, $row['id']) || !self::$acl_delete ||
// Only admins can delete globals
$cats->is_global($row['id']) && !$GLOBALS['egw_info']['user']['apps']['admin'])
{
$row['class'] .= ' rowNoDelete';
}
}
// Can only edit (via context menu) categories for the selected app (backend restriction)
// Can only edit (via context menu) Categories for the selected app (backend restriction)
if($row['appname'] != $query['appname'] || (array_sum($row['owner']) > 0))
{
$row['class'] .= ' rowNoEdit ';
@ -434,11 +440,11 @@ class admin_categories
$rows['appname'] = $query['appname'];
$rows['edit_link'] = $this->edit_link;
// disable access column for global categories
// disable access column for global Categories
if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin') $rows['no_access'] = true;
$GLOBALS['egw_info']['flags']['app_header'] = lang($this->appname).' - '.lang('categories').
($query['appname'] != categories::GLOBAL_APPNAME ? ': '.lang($query['appname']) : '');
($query['appname'] != Categories::GLOBAL_APPNAME ? ': '.lang($query['appname']) : '');
return $count;
}
@ -452,13 +458,13 @@ class admin_categories
public function index(array $content=null,$msg='')
{
//_debug_array($_GET);
if ($this->appname != 'admin') translation::add_app('admin'); // need admin translations
if ($this->appname != 'admin') Api\Translation::add_app('admin'); // need admin translations
if(!isset($content))
{
if (isset($_GET['msg'])) $msg = $_GET['msg'];
$appname = categories::GLOBAL_APPNAME;
$appname = Categories::GLOBAL_APPNAME;
foreach(array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field)
{
if($field)
@ -467,14 +473,14 @@ class admin_categories
break;
}
}
$content['nm'] = egw_cache::getSession(__CLASS__.$appname,'nm');
$content['nm'] = Api\Cache::getSession(__CLASS__.$appname,'nm');
if (!is_array($content['nm']))
{
$content['nm'] = array(
'get_rows' => $this->get_rows, // I method/callback to request the data for the rows eg. 'notes.bo.get_rows'
'options-filter' => array(
'' => lang('All categories'),
categories::GLOBAL_ACCOUNT => lang('Global categories'),
Categories::GLOBAL_ACCOUNT => lang('Global categories'),
$GLOBALS['egw_info']['user']['account_id'] => lang('Own categories'),
),
'no_filter2' => True, // I disable the 2. filter (params are the same as for filter)
@ -506,7 +512,7 @@ class admin_categories
{
$content['nm']['no_filter'] = true;
// Make sure filter is set properly, could be different if user was looking at something else
$content['nm']['filter'] = categories::GLOBAL_ACCOUNT;
$content['nm']['filter'] = Categories::GLOBAL_ACCOUNT;
}
$content['nm']['global_cats'] = true;
@ -562,12 +568,12 @@ class admin_categories
{
$msg .= lang('%1 category(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
}
egw_framework::refresh_opener($msg, $this->appname);
Framework::refresh_opener($msg, $this->appname);
$msg = '';
}
}
$content['msg'] = $msg;
$content['nm']['add_link']= egw_framework::link('/index.php','menuaction='.$this->add_link . '&cat_id=&appname='.$appname);
$content['nm']['add_link']= Framework::link('/index.php','menuaction='.$this->add_link . '&cat_id=&appname='.$appname);
$content['edit_link']= $this->edit_link.'&appname='.$appname;
$content['owner'] = '';
@ -597,15 +603,15 @@ class admin_categories
$readonlys['nm']['rows']['owner'] = true;
$readonlys['nm']['col_filter']['owner'] = true;
}
if($appname == categories::GLOBAL_APPNAME) {
if($appname == Categories::GLOBAL_APPNAME) {
$sel_options['app'] = array(''=>'');
$readonlys['nm']['rows']['app'] = true;
}
$tmpl = new etemplate_new('admin.categories.index');
$tmpl = new Etemplate('admin.categories.index');
// Category styles
categories::css($appname);
Categories::css($appname);
$tmpl->exec($this->list_link,$content,$sel_options,$readonlys,array(
'nm' => $content['nm'],
@ -697,7 +703,7 @@ class admin_categories
}
$owner = $query['col_filter']['owner'] ? $query['col_filter']['owner'] : $query['filter'];
$app = $query['col_filter']['app'] ? $query['col_filter']['app'] : $query['appname'];
$cats = new categories($owner,$app);
$cats = new Categories($owner,$app);
list($action, $settings) = explode('_', $_action, 2);
@ -707,7 +713,7 @@ class admin_categories
$action_msg = lang('deleted');
foreach($checked as $id)
{
if($cats->check_perms(EGW_ACL_DELETE, $id, (boolean)$GLOBALS['egw_info']['user']['apps']['admin']))
if($cats->check_perms(Acl::DELETE, $id, (boolean)$GLOBALS['egw_info']['user']['apps']['admin']))
{
$cats->delete($id,$settings == 'sub',$settings != 'sub');
$success++;
@ -723,18 +729,18 @@ class admin_categories
list($add_remove, $ids_csv) = explode('_', $settings, 2);
$ids = explode(',', $ids_csv);
// Adding 'All users' removes all the others
if($add_remove == 'add' && array_search(categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(categories::GLOBAL_ACCOUNT);
if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(Categories::GLOBAL_ACCOUNT);
foreach($checked as $id)
{
if (!$data = $cats->read($id)) continue;
$data['owner'] = explode(',',$data['owner']);
if(array_search(categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0)
if(array_search(Categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0)
{
$data['owner'] = array();
}
$data['owner'] = $add_remove == 'add' ?
$ids == array(categories::GLOBAL_ACCOUNT) ? $ids : array_merge($data['owner'],$ids) :
$ids == array(Categories::GLOBAL_ACCOUNT) ? $ids : array_merge($data['owner'],$ids) :
array_diff($data['owner'],$ids);
$data['owner'] = implode(',',array_unique($data['owner']));
@ -766,7 +772,7 @@ class admin_categories
$apps['phpgw'] = lang('Global');
continue;
}
// Skip apps that don't show in the app bar, they [usually] don't have categories
// Skip apps that don't show in the app bar, they [usually] don't have Categories
if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) continue;
if ($GLOBALS['egw_info']['user']['apps'][$app])
{

View File

@ -1,15 +1,18 @@
<?php
/**
* eGgroupWare admin - admin command base class
* EGroupware admin - admin command base class
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin
* @copyright (c) 2007-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Acl;
/**
* admin comand base class
*/
@ -63,37 +66,37 @@ abstract class admin_cmd
private $data = array();
/**
* Instance of the accounts class, after calling instanciate_accounts!
* Instance of the Api\Accounts class, after calling instanciate_accounts!
*
* @var accounts
* @var Api\Accounts
*/
static protected $accounts;
/**
* Instance of the acl class, after calling instanciate_acl!
* Instance of the Acl class, after calling instanciate_acl!
*
* @var acl
* @var Acl
*/
static protected $acl;
/**
* Instance of so_sql for egw_admin_queue
* Instance of Api\Storage\Base for egw_admin_queue
*
* @var so_sql
* @var Api\Storage\Base
*/
static private $sql;
/**
* Instance of so_sql for egw_admin_remote
* Instance of Api\Storage\Base for egw_admin_remote
*
* @var so_sql
* @var Api\Storage\Base
*/
static private $remote;
/**
* Executes the command
*
* @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself
* @param boolean $check_only =false only run the checks (and throw the exceptions), but not the command itself
* @return string success message
* @throws Exception()
*/
@ -134,10 +137,10 @@ abstract class admin_cmd
*
* The command will be written to the database queue, incl. its scheduled start time or execution status
*
* @param int $time=null timestamp to run the command or null to run it immediatly
* @param boolean $set_modifier=null should the current user be set as modifier, default true
* @param booelan $skip_checks=false do not yet run the checks for a scheduled command
* @param boolean $dry_run=false only run checks, NOT command itself
* @param int $time =null timestamp to run the command or null to run it immediatly
* @param boolean $set_modifier =null should the current user be set as modifier, default true
* @param booelan $skip_checks =false do not yet run the checks for a scheduled command
* @param boolean $dry_run =false only run checks, NOT command itself
* @return mixed return value of the command
* @throws Exceptions on error
*/
@ -183,7 +186,7 @@ abstract class admin_cmd
}
if (!$dont_save && !$dry_run && !$this->save($set_modifier))
{
throw new egw_exception_db(lang('Error saving the command!'));
throw new Api\Db\Exception(lang('Error saving the command!'));
}
if ($e instanceof Exception)
{
@ -204,13 +207,13 @@ abstract class admin_cmd
* of the md5 hash of the config password and the install_id (egw_admin_remote.remote_hash)
*
* @return string sussess message
* @throws Exception(lang('Invalid remote id or name "%1"!',$id_or_name),997) or other Exceptions reported from remote
* @throws Exception(lang('Invalid remote id or name "%1"!',$this->remote_id),997) or other Exceptions reported from remote
*/
protected function remote_exec()
{
if (!($remote = $this->read_remote($this->remote_id)))
{
throw new egw_exception_wrong_userinput(lang('Invalid remote id or name "%1"!',$id_or_name),997);
throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!',$this->remote_id),997);
}
if (!$this->uid)
{
@ -221,7 +224,7 @@ abstract class admin_cmd
$postdata = $this->as_array();
if (is_object($GLOBALS['egw']->translation))
{
$postdata = $GLOBALS['egw']->translation->convert($postdata,$GLOBALS['egw']->translation->charset(),'utf-8');
$postdata = Api\Translation::convert($postdata,Api\Translation::charset(),'utf-8');
}
// dont send the id's which have no meaning on the remote install
foreach(array('id','creator','modifier','requested','remote_id') as $name)
@ -237,9 +240,10 @@ abstract class admin_cmd
);
$url = $remote['remote_url'].'/admin/remote.php?domain='.urlencode($remote['remote_domain']).'&secret='.urlencode($secret);
//echo "sending command to $url\n"; _debug_array($opts);
$http_response_header = null;
if (!($message = @file_get_contents($url, false, stream_context_create($opts))))
{
throw new egw_exception(lang('Could not remote execute the command').': '.$http_response_header[0]);
throw new Api\Exception(lang('Could not remote execute the command').': '.$http_response_header[0]);
}
//echo "got: $message\n";
@ -249,11 +253,12 @@ abstract class admin_cmd
}
if (is_object($GLOBALS['egw']->translation))
{
$message = $GLOBALS['egw']->translation->convert($message,'utf-8');
$message = Api\Translation::convert($message,'utf-8');
}
$matches = null;
if (is_string($message) && preg_match('/^([0-9]+) (.*)$/',$message,$matches))
{
throw new egw_exception($matches[2],(int)$matches[1]);
throw new Api\Exception($matches[2],(int)$matches[1]);
}
return $message;
}
@ -275,7 +280,7 @@ abstract class admin_cmd
/**
* Saving the object to the database
*
* @param boolean $set_modifier=true set the current user as modifier or 0 (= run by the system)
* @param boolean $set_modifier =true set the current user as modifier or 0 (= run by the system)
* @return boolean true on success, false otherwise
*/
function save($set_modifier=true)
@ -333,7 +338,7 @@ abstract class admin_cmd
* reading a command from the queue returning the comand object
*
* @static
* @param int/string $id id or uid of the command
* @param int|string $id id or uid of the command
* @return admin_cmd or null if record not found
* @throws Exception(lang('Unknown command %1!',$class),0);
*/
@ -355,7 +360,7 @@ abstract class admin_cmd
* @static
* @param array $data
* @return admin_cmd
* @throws egw_exception_wrong_parameter if class does not exist or is no instance of admin_cmd
* @throws Api\Exception\WrongParameter if class does not exist or is no instance of admin_cmd
*/
static function instanciate(array $data)
{
@ -365,7 +370,7 @@ abstract class admin_cmd
}
if (!class_exists($class = $data['type']) || $class == 'admin_cmd')
{
throw new egw_exception_wrong_parameter(lang('Unknown command %1!',$class),0);
throw new Api\Exception\WrongParameter(lang('Unknown command %1!',$class),0);
}
$cmd = new $class($data);
@ -373,11 +378,11 @@ abstract class admin_cmd
{
return $cmd;
}
throw new egw_exception_wrong_parameter(lang('%1 is no command!',$class),0);
throw new Api\Exception\WrongParameter(lang('%1 is no command!',$class),0);
}
/**
* calling get_rows of our static so_sql instance
* calling get_rows of our static Api\Storage\Base instance
*
* @static
* @param array $query
@ -397,19 +402,19 @@ abstract class admin_cmd
}
/**
* calling search method of our static so_sql instance
* calling search method of our static Api\Storage\Base instance
*
* @static
* @param array/string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!)
* @param boolean/string/array $only_keys=true True returns only keys, False returns all cols. or
* @param array|string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!)
* @param boolean|string|array $only_keys =true True returns only keys, False returns all cols. or
* comma seperated list or array of columns to return
* @param string $order_by='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY)
* @param string/array $extra_cols='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
* @param string $wildcard='' appended befor and after each criteria
* @param boolean $empty=false False=empty criteria are ignored in query, True=empty have to be empty in row
* @param string $op='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together
* @param mixed $start=false if != false, return only maxmatch rows begining with start, or array($start,$num), or 'UNION' for a part of a union query
* @param array $filter=null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards
* @param string $order_by ='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY)
* @param string|array $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
* @param string $wildcard ='' appended befor and after each criteria
* @param boolean $empty =false False=empty criteria are ignored in query, True=empty have to be empty in row
* @param string $op ='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together
* @param mixed $start =false if != false, return only maxmatch rows begining with start, or array($start,$num), or 'UNION' for a part of a union query
* @param array $filter =null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards
* @return array
*/
static function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null)
@ -420,7 +425,7 @@ abstract class admin_cmd
}
/**
* Instanciate our static so_sql object for egw_admin_queue
* Instanciate our static Api\Storage\Base object for egw_admin_queue
*
* @static
*/
@ -428,12 +433,12 @@ abstract class admin_cmd
{
if (is_null(admin_cmd::$sql))
{
admin_cmd::$sql = new so_sql('admin','egw_admin_queue',null,'cmd_');
admin_cmd::$sql = new Api\Storage\Base('admin','egw_admin_queue',null,'cmd_');
}
}
/**
* Instanciate our static so_sql object for egw_admin_remote
* Instanciate our static Api\Storage\Base object for egw_admin_remote
*
* @static
*/
@ -441,7 +446,7 @@ abstract class admin_cmd
{
if (is_null(admin_cmd::$remote))
{
admin_cmd::$remote = new so_sql('admin','egw_admin_remote');
admin_cmd::$remote = new Api\Storage\Base('admin','egw_admin_remote');
}
}
@ -530,9 +535,9 @@ abstract class admin_cmd
/**
* Check if the creator is still admin and has the neccessary admin rights
*
* @param string $extra_acl=null further admin rights to check, eg. 'account_access'
* @param int $extra_deny=null further admin rights to check, eg. 16 = deny edit accounts
* @throws egw_exception_no_admin
* @param string $extra_acl =null further admin rights to check, eg. 'account_access'
* @param int $extra_deny =null further admin rights to check, eg. 16 = deny edit Api\Accounts
* @throws Api\Exception\NoPermission\Admin
*/
protected function _check_admin($extra_acl=null,$extra_deny=null)
{
@ -543,7 +548,7 @@ abstract class admin_cmd
if (!admin_cmd::$acl->check('run',1,'admin') && // creator is no longer admin
$extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin')) // creator is explicitly forbidden to do something
{
throw new egw_exception_no_permission_admin();
throw new Api\Exception\NoPermission\Admin();
}
}
}
@ -553,7 +558,7 @@ abstract class admin_cmd
*
* @param array $apps names, titles or localised names
* @return array of app-names
* @throws egw_exception_wrong_userinput lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8
* @throws Api\Exception\WrongUserinput lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8
*/
static function parse_apps(array $apps)
{
@ -572,7 +577,7 @@ abstract class admin_cmd
}
if (!isset($GLOBALS['egw_info']['apps'][$name]))
{
throw new egw_exception_wrong_userinput(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8);
throw new Api\Exception\WrongUserinput(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8);
}
}
return $apps;
@ -581,11 +586,11 @@ abstract class admin_cmd
/**
* parse account name or id
*
* @param string/int $account account_id or account_lid
* @param boolean $allow_only_user=null true=only user, false=only groups, default both
* @param string|int $account account_id or account_lid
* @param boolean $allow_only_user =null true=only user, false=only groups, default both
* @return int/array account_id
* @throws egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$account),15);
* @throws egw_exception_wrong_userinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15);
* @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$account),15);
* @throws Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15);
*/
static function parse_account($account,$allow_only_user=null)
{
@ -594,11 +599,11 @@ abstract class admin_cmd
if (!($type = admin_cmd::$accounts->exists($account)) ||
!is_numeric($id=$account) && !($id = admin_cmd::$accounts->name2id($account)))
{
throw new egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$account),15);
throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$account),15);
}
if (!is_null($allow_only_user) && $allow_only_user !== ($type == 1))
{
throw new egw_exception_wrong_userinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15);
throw new Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15);
}
if ($type == 2 && $id > 0) $id = -$id; // groups use negative id's internally, fix it, if user given the wrong sign
@ -608,11 +613,11 @@ abstract class admin_cmd
/**
* parse account names or ids
*
* @param string/int/array $accounts array or comma-separated account_id's or account_lid's
* @param boolean $allow_only_user=null true=only user, false=only groups, default both
* @param string|int|array $accounts array or comma-separated account_id's or account_lid's
* @param boolean $allow_only_user =null true=only user, false=only groups, default both
* @return array of account_id's or null if none specified
* @throws egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$account),15);
* @throws egw_exception_wrong_userinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only?lang('user'):lang('group')),15);
* @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$account),15);
* @throws Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only?lang('user'):lang('group')),15);
*/
static function parse_accounts($accounts,$allow_only_user=null)
{
@ -631,7 +636,7 @@ abstract class admin_cmd
*
* @param string $date
* @return int timestamp
* @throws egw_exception_wrong_userinput(lang('Invalid formated date "%1"!',$datein),6);
* @throws Api\Exception\WrongUserinput(lang('Invalid formated date "%1"!',$datein),6);
*/
static function parse_date($date)
{
@ -643,7 +648,7 @@ abstract class admin_cmd
if (($date = strtotime($date)) === false)
{
throw new egw_exception_wrong_userinput(lang('Invalid formated date "%1"!',$datein),6);
throw new Api\Exception\WrongUserinput(lang('Invalid formated date "%1"!',$datein),6);
}
}
return (int)$date;
@ -653,9 +658,9 @@ abstract class admin_cmd
* Parse a boolean value
*
* @param string|boolean|int $value
* @param boolean $default=null
* @param boolean $default =null
* @return boolean
* @throws egw_exception_wrong_userinput(lang('Invalid value "%1" use yes or no!',$value),998);
* @throws Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!',$value),998);
*/
static function parse_boolean($value,$default=null)
{
@ -675,7 +680,7 @@ abstract class admin_cmd
{
return false;
}
throw new egw_exception_wrong_userinput(lang('Invalid value "%1" use yes or no!',$value),998);
throw new Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!',$value),998);
}
/**
@ -683,7 +688,7 @@ abstract class admin_cmd
*
* @param string $id_or_name
* @return int remote_id
* @throws egw_exception_wrong_userinput(lang('Invalid remote id or name "%1"!',$id_or_name),997);
* @throws Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!',$id_or_name),997);
*/
static function parse_remote($id_or_name)
{
@ -695,16 +700,16 @@ abstract class admin_cmd
'remote_domain' => $id_or_name,
),true,'','','',false,'OR')) || count($remotes) != 1)
{
throw new egw_exception_wrong_userinput(lang('Invalid remote id or name "%1"!',$id_or_name),997);
throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!',$id_or_name),997);
}
return $remotes[0]['remote_id'];
}
/**
* Instanciated accounts class
* Instanciated Api\Accounts class
*
* @todo accounts class instanciation for setup
* @throws egw_exception_assertion_failed(lang('%1 class not instanciated','accounts'),999);
* @todo Api\Accounts class instanciation for setup
* @throws Api\Exception\AssertionFailed(lang('%1 class not instanciated','accounts'),999);
*/
static function _instanciate_accounts()
{
@ -712,18 +717,18 @@ abstract class admin_cmd
{
if (!is_object($GLOBALS['egw']->accounts))
{
throw new egw_exception_assertion_failed(lang('%1 class not instanciated','accounts'),999);
throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated','accounts'),999);
}
admin_cmd::$accounts = $GLOBALS['egw']->accounts;
}
}
/**
* Instanciated acl class
* Instanciated Acl class
*
* @todo acl class instanciation for setup
* @param int $account=null account_id the class needs to be instanciated for, default need only account-independent methods
* @throws egw_exception_assertion_failed(lang('%1 class not instanciated','acl'),999);
* @todo Acl class instanciation for setup
* @param int $account =null account_id the class needs to be instanciated for, default need only account-independent methods
* @throws Api\Exception\AssertionFailed(lang('%1 class not instanciated','acl'),999);
*/
protected function _instanciate_acl($account=null)
{
@ -731,11 +736,11 @@ abstract class admin_cmd
{
if (!is_object($GLOBALS['egw']->acl))
{
throw new egw_exception_assertion_failed(lang('%1 class not instanciated','acl'),999);
throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated','acl'),999);
}
if ($account && $GLOBALS['egw']->acl->account_id != $account)
{
admin_cmd::$acl = new acl($account);
admin_cmd::$acl = new Acl($account);
admin_cmd::$acl->read_repository();
}
else
@ -748,7 +753,7 @@ abstract class admin_cmd
/**
* RFC822 email address of the an account, eg. "Ralf Becker <RalfBecker@egroupware.org>"
*
* @param $account_id=null account_id, default current user
* @param $account_id =null account_id, default current user
* @return string
*/
static function user_email($account_id=null)
@ -799,8 +804,7 @@ abstract class admin_cmd
{
return admin_cmd::run_queued_jobs();
}
include_once(EGW_API_INC.'/class.asyncservice.inc.php');
$async = new asyncservice();
$async = new Api\AsyncService();
// we cant use this class as callback, as it's abstract and ExecMethod used by the async service instanciated the class!
list($app) = explode('_',$class=$next['type']);
@ -833,6 +837,7 @@ abstract class admin_cmd
$cmd->run(null,false); // false = dont set current user as modifier, as job is run by the queue/system itself
}
catch (Exception $e) { // we need to mark that command as failed, to prevent further execution
unset($e);
admin_cmd::$sql->init($job);
admin_cmd::$sql->save(array(
'status' => admin_cmd::failed,
@ -856,7 +861,7 @@ abstract class admin_cmd
admin_cmd::_instanciate_remote();
$sites = array(lang('local'));
if ($remote = admin_cmd::$remote->query_list('remote_name','remote_id'))
if (($remote = admin_cmd::$remote->query_list('remote_name','remote_id')))
{
$sites = array_merge($sites,$remote);
}
@ -881,7 +886,7 @@ abstract class admin_cmd
/**
* Read data of a remote instance
*
* @param array/int $keys
* @param array|int $keys
* @return array
*/
static function read_remote($keys)
@ -907,7 +912,7 @@ abstract class admin_cmd
}
elseif (!$data['remote_hash'] && !($data['install_id'] && $data['config_passwd']))
{
throw new egw_exception_wrong_userinput(lang('Either Install ID AND config password needed OR the remote hash!'));
throw new Api\Exception\WrongUserinput(lang('Either Install ID AND Api\Config password needed OR the remote hash!'));
}
//_debug_array($data);
admin_cmd::$remote->init($data);
@ -920,7 +925,7 @@ abstract class admin_cmd
}
if (admin_cmd::$remote->save() != 0)
{
throw new egw_exception_db(lang('Error saving to db:').' '.$this->sql->db->Error.' ('.$this->sql->db->Errno.')',$this->sql->db->Errno);
throw new Api\Db\Exception(lang('Error saving to db:').' '.$this->sql->db->Error.' ('.$this->sql->db->Errno.')',$this->sql->db->Errno);
}
return admin_cmd::$remote->data['remote_id'];
}
@ -936,7 +941,7 @@ abstract class admin_cmd
{
if (empty($config_passwd) || !self::is_md5($install_id))
{
throw new egw_exception_wrong_parameter(empty($config_passwd)?'Empty config password':'install_id no md5 hash');
throw new Api\Exception\WrongParameter(empty($config_passwd)?'Empty Api\Config password':'install_id no md5 hash');
}
if (!self::is_md5($config_passwd)) $config_passwd = md5($config_passwd);
@ -948,14 +953,14 @@ abstract class admin_cmd
*
* We show the value given by the user, plus the full name in brackets.
*
* @param int/string $account
* @param int|string $account
* @return string
*/
static function display_account($account)
{
$id = is_numeric($account) ? $account : $GLOBALS['egw']->accounts->id2name($account);
return $account.' ('.$GLOBALS['egw']->common->grab_owner_name($id).')';
return $account.' ('.Api\Accounts::username($id).')';
}
/**
@ -977,11 +982,11 @@ abstract class admin_cmd
* This default implementation use a secret to authenticate with the installation,
* which is a md5 hash build from the uid of the command (to not allow to send new
* commands with an earsdroped secret) and the md5 hash of the md5 hash of the
* config password and the install_id (egw_admin_remote.remote_hash)
* Api\Config password and the install_id (egw_admin_remote.remote_hash)
*
* @param string $secret hash used to authenticate the command (
* @param string $config_passwd of the current domain
* @throws egw_exception_no_permission
* @throws Api\Exception\NoPermission
*/
function check_remote_access($secret,$config_passwd)
{
@ -991,42 +996,29 @@ abstract class admin_cmd
// to authenticate with the installation we use a secret, which is a md5 hash build from the uid
// of the command (to not allow to send new commands with an earsdroped secret) and the md5 hash
// of the md5 hash of the config password and the install_id (egw_admin_remote.remote_hash)
// of the md5 hash of the Api\Config password and the install_id (egw_admin_remote.remote_hash)
if (is_null($config_passwd) || is_numeric($this->uid) || !in_array($remote_admin_install_id,$allowed_remote_admin_ids) ||
$secret != ($md5=md5($this->uid.$this->remote_hash($GLOBALS['egw_info']['server']['install_id'],$config_passwd))))
{
//die("secret='$secret' != '$md5', is_null($config_passwd)=".is_null($config_passwd).", uid=$this->uid, remote_install_id=$remote_admin_install_id, allowed: ".implode(', ',$allowed_remote_admin_ids));
unset($md5);
$msg = lang('Permission denied!');
if (!in_array($remote_admin_install_id,$allowed_remote_admin_ids))
{
$msg .= "\n".lang('Remote administration need to be enabled in the remote instance under Admin > Site configuration!');
}
throw new egw_exception_no_permission($msg,0);
throw new Api\Exception\NoPermission($msg,0);
}
}
/**
* Return a rand string, eg. to generate passwords
*
* @param int $len=16
* @param int $len =16
* @return string
*/
static function randomstring($len=16)
{
static $usedchars = array(
'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f',
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'@','!','$','%','&','/','(',')','=','?',';',':','#','_','-','<',
'>','|','{','[',']','}', // dont add \,'" as we have problems dealing with them
);
$str = '';
for($i=0; $i < $len; $i++)
{
$str .= $usedchars[mt_rand(0,count($usedchars)-1)];
}
return $str;
return Api\Auth::randomstring($len);
}
}

View File

@ -1,26 +1,28 @@
<?php
/**
* eGgroupWare admin - admin command: give or remove run rights from a given account and application
* EGroupware admin - admin command: give or remove run rights from a given account and application
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin
* @copyright (c) 2007 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
* @version $Id$
*/
use EGroupware\Api;
/**
* admin command: give or remove run rights from a given account and application
*/
class admin_cmd_account_app extends admin_cmd
class admin_cmd_account_app extends admin_cmd
{
/**
* Constructor
*
* @param boolean/array $allow true=give rights, false=remove rights, or array with all 3 params
* @param string/int $account=null account name or id
* @param array/string $apps=null app-names
* @param boolean|array $allow true=give rights, false=remove rights, or array with all 3 params
* @param string|int $account =null account name or id
* @param array|string $apps =null app-names
*/
function __construct($allow,$account=null,$apps=null)
{
@ -41,21 +43,21 @@ class admin_cmd_account_app extends admin_cmd
/**
* give or remove run rights from a given account and application
*
* @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself
*
* @param boolean $check_only =false only run the checks (and throw the exceptions), but not the command itself
* @return string success message
* @throws egw_exception_no_admin
* @throws egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$this->account),15);
* @throws egw_exception_wrong_userinput(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8);
* @throws Api\Exception\NoPermission\Admin
* @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15);
* @throws Api\Exception\WrongUserinput(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8);
*/
protected function exec($check_only=false)
{
$account_id = admin_cmd::parse_account($this->account);
// check creator is still admin and not explicitly forbidden to edit accounts/groups
if ($this->creator) $this->_check_admin($account_id > 0 ? 'account_access' : 'group_access',16);
$apps = admin_cmd::parse_apps($this->apps);
if ($check_only) return true;
//echo "account=$this->account, account_id=$account_id, apps: ".implode(', ',$apps)."\n";

View File

@ -1,15 +1,17 @@
<?php
/**
* eGgroupWare admin - admin command: change an account_id
* EGgroupware admin - admin command: change an account_id
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin
* @copyright (c) 2007-15 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
/**
* admin command: change an account_id
@ -44,7 +46,7 @@ class admin_cmd_change_account_id extends admin_cmd
// happens if one used "root_admin" and config-password
if (empty($GLOBALS['egw_info']['apps']))
{
$apps = new applications();
$apps = new Api\Egw\Applications();
$apps->read_installed_apps();
}
$changes = $setup_info = array();
@ -83,7 +85,7 @@ class admin_cmd_change_account_id extends admin_cmd
}
// we have a custom field table and cfs containing accounts
if ($cf && !empty($cf['cfname']) && !empty($cf['cfvalue']) &&
($account_cfs = egw_customfields::get_account_cfs($app == 'phpgwapi' ? 'addressbook' : $app)))
($account_cfs = Api\Storage\Customfields::get_account_cfs($app == 'phpgwapi' ? 'addressbook' : $app)))
{
foreach($account_cfs as $type => $names)
{
@ -108,9 +110,9 @@ class admin_cmd_change_account_id extends admin_cmd
*
* @param boolean $check_only =false only run the checks (and throw the exceptions), but not the command itself
* @return string success message
* @throws egw_exception_no_admin
* @throws egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$this->account),15);
* @throws egw_exception_wrong_userinput(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8);
* @throws Api\Exception\Permission\NoAdmin
* @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15);
* @throws Api\Exception\WrongUserinput(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8);
*/
protected function exec($check_only=false)
{
@ -118,23 +120,23 @@ class admin_cmd_change_account_id extends admin_cmd
{
if (!(int)$from || !(int)$to)
{
throw new egw_exception_wrong_userinput(lang("Account-id's have to be integers!"),16);
throw new Api\Exception\WrongUserinput(lang("Account-id's have to be integers!"),16);
}
if (($from < 0) != ($to < 0))
{
throw new egw_exception_wrong_userinput(lang("Can NOT change users into groups, same sign required!"),17);
throw new Api\Exception\WrongUserinput(lang("Can NOT change users into groups, same sign required!"),17);
}
if (!($from_exists = $GLOBALS['egw']->accounts->exists($from)))
{
throw new egw_exception_wrong_userinput(lang("Source account #%1 does NOT exist!", $from),18);
throw new Api\Exception\WrongUserinput(lang("Source account #%1 does NOT exist!", $from),18);
}
if ($from_exists !== ($from > 0 ? 1 : 2))
{
throw new egw_exception_wrong_userinput(lang("Group #%1 must have negative sign!", $from),19);
throw new Api\Exception\WrongUserinput(lang("Group #%1 must have negative sign!", $from),19);
}
if ($GLOBALS['egw']->accounts->exists($to) && !isset($this->change[$to]))
{
throw new egw_exception_wrong_userinput(lang("Destination account #%1 does exist and is NOT renamed itself! Can not merge accounts, it will violate unique contains. Delete with transfer of data instead.", $to),20);
throw new Api\Exception\WrongUserinput(lang("Destination account #%1 does exist and is NOT renamed itself! Can not merge Api\Accounts, it will violate unique contains. Delete with transfer of data instead.", $to),20);
}
}
$columns2change = $this->get_changes();
@ -177,11 +179,11 @@ class admin_cmd_change_account_id extends admin_cmd
{
foreach($GLOBALS['egw_info']['apps'] as $app => $data)
{
$total += ($changed = egw_customfields::change_account_ids($app, $this->change));
$total += ($changed = Api\Storage\Customfields::change_account_ids($app, $this->change));
if ($changed) echo "$app:\t$changed id's in definition of private custom fields changed\n";
}
}
if ($total) egw_cache::flush(egw_cache::INSTANCE);
if ($total) Api\Cache::flush(Api\Cache::INSTANCE);
return lang("Total of %1 id's changed.",$total)."\n";
}
@ -190,14 +192,14 @@ class admin_cmd_change_account_id extends admin_cmd
* Update DB with changed account ids
*
* @param array $ids2change from-id => to-id pairs
* @param egw_db $db
* @param Api\Db $db
* @param string $table
* @param string $column
* @param array $where
* @param string $type
* @return int number of changed ids
*/
private static function _update_account_id(array $ids2change,egw_db $db,$table,$column,array $where=null,$type=null)
private static function _update_account_id(array $ids2change,Api\Db $db,$table,$column,array $where=null,$type=null)
{
$update_sql = '';
foreach($ids2change as $from => $to)

View File

@ -1,15 +1,17 @@
<?php
/**
* eGgroupWare admin - admin command: change the password of a given user
* EGgroupware admin - admin command: change the password of a given user
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin
* @copyright (c) 2007 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
/**
* admin command: change the password of a given user
*/
@ -18,8 +20,8 @@ class admin_cmd_change_pw extends admin_cmd
/**
* Constructor
*
* @param string/int/array $account account name or id, or array with all parameters
* @param string $password=null password
* @param string|int|array $account account name or id, or array with all parameters
* @param string $password =null password
*/
function __construct($account,$password=null)
{
@ -36,25 +38,25 @@ class admin_cmd_change_pw extends admin_cmd
/**
* change the password of a given user
*
* @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself
* @param boolean $check_only =false only run the checks (and throw the exceptions), but not the command itself
* @return string success message
* @throws egw_exception_no_admin
* @throws egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$this->account),15);
* @throws egw_exception_wrong_userinput(lang('Error changing the password for %1 !!!',$this->account),99);
* @throws Api\Exception\NoPermission\Admin
* @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15);
* @throws Api\Exception\WrongUserinput(lang('Error changing the password for %1 !!!',$this->account),99);
*/
protected function exec($check_only=false)
{
$account_id = admin_cmd::parse_account($this->account,true); // true = user, no group
// check creator is still admin and not explicitly forbidden to edit accounts
// check creator is still admin and not explicitly forbidden to edit Api\Accounts
if ($this->creator) $this->_check_admin('account_access',16);
if ($check_only) return true;
$auth = new auth;
$auth = new Api\Auth;
if (!$auth->change_password(null, $this->password, $account_id))
{
// as long as the auth class is not throwing itself ...
// as long as the Api\Auth class is not throwing itself ...
throw new Exception(lang('Error changing the password for %1 !!!',$this->account),99);
}
return lang('Password updated');

View File

@ -1,24 +1,24 @@
<?php
/**
* eGgroupWare admin - admin command: check ACL for entries of deleted accounts
* EGroupWare admin - admin command: check ACL for entries of deleted Api\Accounts
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin
* @copyright (c) 2007 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
* @version $Id$
*/
/**
* admin command: check ACL for entries of deleted accounts
*/
class admin_cmd_check_acl extends admin_cmd
class admin_cmd_check_acl extends admin_cmd
{
/**
* Constructor
*
* @param array $data=array() default parm from parent class, no real parameters
* @param array $data =array() default parm from parent class, no real parameters
*/
function __construct($data=array())
{
@ -27,8 +27,8 @@ class admin_cmd_check_acl extends admin_cmd
/**
* give or remove run rights from a given account and application
*
* @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself
*
* @param boolean $check_only =false only run the checks (and throw the exceptions), but not the command itself
* @return string success message
* @throws Exception(lang("Permission denied !!!"),2)
* @throws Exception(lang("Unknown account: %1 !!!",$this->account),15);
@ -50,7 +50,7 @@ class admin_cmd_check_acl extends admin_cmd
$GLOBALS['egw']->db->query("DELETE FROM egw_acl WHERE acl_account NOT IN (".implode(',',$ids).") OR acl_appname='phpgw_group' AND acl_location NOT IN ('".implode("','",$ids)."')",__LINE__,__FILE__);
$deleted = $GLOBALS['egw']->db->affected_rows();
}
return lang("%1 ACL records of not (longer) existing accounts deleted.",$deleted);
return lang("%1 ACL records of not (longer) existing Api\Accounts deleted.",$deleted);
}
/**

View File

@ -5,11 +5,13 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin
* @copyright (c) 2012 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2012-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
/**
* admin command: check categories for not (longer) existing accounts
*/
@ -20,7 +22,7 @@ class admin_cmd_check_cats extends admin_cmd
/**
* Constructor
*
* @param array $data=array() default parm from parent class, no real parameters
* @param array $data =array() default parm from parent class, no real parameters
*/
function __construct($data=array())
{
@ -30,7 +32,7 @@ class admin_cmd_check_cats extends admin_cmd
/**
* give or remove run rights from a given account and application
*
* @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself
* @param boolean $check_only =false only run the checks (and throw the exceptions), but not the command itself
* @return string success message
*/
protected function exec($check_only=false)
@ -39,7 +41,7 @@ class admin_cmd_check_cats extends admin_cmd
admin_cmd::_instanciate_accounts();
return lang("%1 categories of not (longer) existing accounts deleted.", categories::delete_orphans());
return lang("%1 Api\Categories of not (longer) existing Api\Accounts deleted.", Api\Categories::delete_orphans());
}
/**
@ -49,6 +51,6 @@ class admin_cmd_check_cats extends admin_cmd
*/
function __tostring()
{
return lang('Check categories for not (longer) existing accounts');
return lang('Check Api\Categories for not (longer) existing accounts');
}
}

View File

@ -1,15 +1,17 @@
<?php
/**
* eGgroupWare admin - admin command: delete an account (user or group)
* EGroupware admin - admin command: delete an account (user or group)
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin
* @copyright (c) 2007 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
/**
* admin command: delete an account (user or group)
*/
@ -18,9 +20,9 @@ class admin_cmd_delete_account extends admin_cmd
/**
* Constructor
*
* @param string/int/array $account account name or id, or array with all parameters
* @param string $new_user=null if specified, account to transfer the data to (users only)
* @param string $is_user=true type of the account: true=user, false=group
* @param string|int|array $account account name or id, or array with all parameters
* @param string $new_user =null if specified, account to transfer the data to (users only)
* @param string $is_user =true type of the account: true=user, false=group
*/
function __construct($account,$new_user=null,$is_user=true)
{
@ -38,11 +40,11 @@ class admin_cmd_delete_account extends admin_cmd
/**
* delete an account (user or group)
*
* @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself
* @param boolean $check_only =false only run the checks (and throw the exceptions), but not the command itself
* @return string success message
* @throws egw_exception_no_admin
* @throws egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$this->account),15);
* @throws egw_exception_wrong_userinput(lang('Error changing the password for %1 !!!',$this->account),99);
* @throws Api\Exception\NoPermission\Admin
* @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15);
* @throws Api\Exception\WrongUserinput(lang('Error changing the password for %1 !!!',$this->account),99);
*/
protected function exec($check_only=false)
{
@ -70,7 +72,7 @@ class admin_cmd_delete_account extends admin_cmd
// first all other apps, then preferences and admin
foreach(array_merge(array_diff(array_keys($GLOBALS['egw_info']['apps']),array('preferences','admin')),array('preferences','admin')) as $app)
{
$GLOBALS['egw']->hooks->single($GLOBALS['hook_values'],$app);
Api\Hooks::single($GLOBALS['hook_values'],$app);
}
$GLOBALS['egw']->accounts->delete($account_id);

View File

@ -1,15 +1,17 @@
<?php
/**
* eGgroupWare admin - admin command: edit/add a group
* EGgroupware admin - admin command: edit/add a group
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin
* @copyright (c) 2007-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
/**
* admin command: edit/add a user
*/
@ -18,8 +20,8 @@ class admin_cmd_edit_group extends admin_cmd
/**
* Constructor
*
* @param string/int/array $account account name or id (!$account to add a new account), or array with all parameters
* @param array $set=null array with all data to change
* @param string|int|array $account account name or id (!$account to add a new account), or array with all parameters
* @param array $set =null array with all data to change
*/
function __construct($account,$set=null)
{
@ -36,10 +38,10 @@ class admin_cmd_edit_group extends admin_cmd
/**
* change the password of a given user
*
* @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself
* @param boolean $check_only =false only run the checks (and throw the exceptions), but not the command itself
* @return string success message
* @throws egw_exception_no_admin
* @throws egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$this->account),15);
* @throws Api\Exception\NoPermission\Admin
* @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15);
*/
protected function exec($check_only=false)
{
@ -64,16 +66,16 @@ class admin_cmd_edit_group extends admin_cmd
}
if (!$data['account_lid'] && (!$this->account || !is_null($data['account_lid'])))
{
throw new egw_exception_wrong_userinput(lang('You must enter a group name.'),9);
throw new Api\Exception\WrongUserinput(lang('You must enter a group name.'),9);
}
if (!is_null($data['account_lid']) && ($id = admin_cmd::$accounts->name2id($data['account_lid'],'account_lid','g')) &&
$id !== $data['account_id'])
{
throw new egw_exception_wrong_userinput(lang('That loginid has already been taken'),999);
throw new Api\Exception\WrongUserinput(lang('That loginid has already been taken'),999);
}
if (!$data['account_members'] && !$this->account)
{
throw new egw_exception_wrong_userinput(lang('You must select at least one group member.'),9);
throw new Api\Exception\WrongUserinput(lang('You must select at least one group member.'),9);
}
if ($data['account_members'])
{
@ -84,10 +86,10 @@ class admin_cmd_edit_group extends admin_cmd
if (($update = $this->account))
{
// invalidate account, before reading it, to code with changed to DB or LDAP outside EGw
accounts::cache_invalidate($data['account_id']);
Api\Accounts::cache_invalidate($data['account_id']);
if (!($old = admin_cmd::$accounts->read($data['account_id'])))
{
throw new egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$this->account),15);
throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15);
}
// as the current account class always sets all values, we have to add the not specified ones
foreach($data as $name => &$value)
@ -98,12 +100,12 @@ class admin_cmd_edit_group extends admin_cmd
if (!($data['account_id'] = admin_cmd::$accounts->save($data)))
{
//_debug_array($data);
throw new egw_exception_db(lang("Error saving account!"),11);
throw new Api\Db\Exception(lang("Error saving account!"),11);
}
$data['account_name'] = $data['account_lid']; // also set deprecated name
if ($update) $data['old_name'] = $old['account_lid']; // make old name available for hooks
$GLOBALS['hook_values'] =& $data;
$GLOBALS['egw']->hooks->process($GLOBALS['hook_values']+array(
Api\Hooks::process($GLOBALS['hook_values']+array(
'location' => $update ? 'editgroup' : 'addgroup'
),False,True); // called for every app now, not only enabled ones)
@ -114,7 +116,7 @@ class admin_cmd_edit_group extends admin_cmd
// make new account_id available to caller
$this->account = $data['account_id'];
return lang("Group %1 %2", $data['account_lid'] ? $data['account_lid'] : accounts::id2name($this->account),
return lang("Group %1 %2", $data['account_lid'] ? $data['account_lid'] : Api\Accounts::id2name($this->account),
$update ? lang('updated') : lang("created with id #%1", $this->account));
}

View File

@ -1,15 +1,17 @@
<?php
/**
* eGgroupWare admin - admin command: edit/add a user
* EGgroupware admin - admin command: edit/add a user
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin
* @copyright (c) 2007-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
/**
* admin command: edit/add a user
*/
@ -18,10 +20,10 @@ class admin_cmd_edit_user extends admin_cmd_change_pw
/**
* Constructor
*
* @param string/int/array $account account name or id (!$account to add a new account), or array with all parameters
* @param string|int|array $account account name or id (!$account to add a new account), or array with all parameters
* @param array $set =null array with all data to change
* @param string $password =null password
* @param boolean $run_addaccount_hook =null default run addaccount for new accounts and editaccount for existing ones
* @param boolean $run_addaccount_hook =null default run addaccount for new Api\Accounts and editaccount for existing ones
*/
function __construct($account,$set=null,$password=null,$run_addaccount_hook=null)
{
@ -43,9 +45,9 @@ class admin_cmd_edit_user extends admin_cmd_change_pw
*
* @param boolean $check_only =false only run the checks (and throw the exceptions), but not the command itself
* @return string success message
* @throws egw_exception_no_admin
* @throws egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$this->account),15);
* @throws egw_exception_wrong_userinput(lang('Error changing the password for %1 !!!',$this->account),99);
* @throws Api\Exception\NoPermission\Admin
* @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15);
* @throws Api\Exception\WrongUserinput(lang('Error changing the password for %1 !!!',$this->account),99);
*/
protected function exec($check_only=false)
{
@ -66,27 +68,27 @@ class admin_cmd_edit_user extends admin_cmd_change_pw
}
if (!$data['account_lid'] && (!$this->account || !is_null($data['account_lid'])))
{
throw new egw_exception_wrong_userinput(lang('You must enter a loginid'),9);
throw new Api\Exception\WrongUserinput(lang('You must enter a loginid'),9);
}
// Check if an account already exists as system user, and if it does deny creation
if ($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' &&
!$GLOBALS['egw_info']['server']['ldap_allow_systemusernames'] && !$data['account_id'] &&
function_exists('posix_getpwnam') && posix_getpwnam($data['account_lid']))
{
throw new egw_exception_wrong_userinput(lang('There already is a system-user with this name. User\'s should not have the same name as a systemuser'),99);
throw new Api\Exception\WrongUserinput(lang('There already is a system-user with this name. User\'s should not have the same name as a systemuser'),99);
}
if (!$data['account_lastname'] && (!$this->account || !is_null($data['account_lastname'])))
{
throw new egw_exception_wrong_userinput(lang('You must enter a lastname'),9);
throw new Api\Exception\WrongUserinput(lang('You must enter a lastname'),9);
}
if (!is_null($data['account_lid']) && ($id = admin_cmd::$accounts->name2id($data['account_lid'],'account_lid','u')) &&
(string)$id !== (string)$data['account_id'])
{
throw new egw_exception_wrong_userinput(lang('That loginid has already been taken'),999);
throw new Api\Exception\WrongUserinput(lang('That loginid has already been taken'),999);
}
if (isset($data['account_passwd_2']) && $data['account_passwd'] != $data['account_passwd_2'])
{
throw new egw_exception_wrong_userinput(lang('The two passwords are not the same'),0);
throw new Api\Exception\WrongUserinput(lang('The two passwords are not the same'),0);
}
$expires = self::_parse_expired($data['account_expires'],(boolean)$this->account);
if ($expires === 0) // deactivated
@ -136,10 +138,10 @@ class admin_cmd_edit_user extends admin_cmd_change_pw
if ($this->account)
{
// invalidate account, before reading it, to code with changed to DB or LDAP outside EGw
accounts::cache_invalidate($data['account_id']);
Api\Accounts::cache_invalidate($data['account_id']);
if (!($old = admin_cmd::$accounts->read($data['account_id'])))
{
throw new egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$this->account),15);
throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15);
}
// as the current account class always sets all values, we have to add the not specified ones
foreach($data as $name => &$value)
@ -151,15 +153,15 @@ class admin_cmd_edit_user extends admin_cmd_change_pw
{
unset($data['account_id']); // otherwise add will fail under postgres
}
// hook allowing apps to intercept adding/editing accounts before saving them
$GLOBALS['egw']->hooks->process($data+array(
// hook allowing apps to intercept adding/editing Api\Accounts before saving them
Api\Hooks::process($data+array(
'location' => $this->account ? 'pre_editaccount' : 'pre_addaccount',
),False,True); // called for every app now, not only enabled ones)
if (!($data['account_id'] = admin_cmd::$accounts->save($data)))
{
//_debug_array($data);
throw new egw_exception_db(lang("Error saving account!"),11);
throw new Api\Db\Exception(lang("Error saving account!"),11);
}
// make new account_id available to caller
$update = (boolean)$this->account;
@ -202,11 +204,11 @@ class admin_cmd_edit_user extends admin_cmd_change_pw
}
$data['account_passwd'] = $this->password;
$GLOBALS['hook_values'] =& $data;
$GLOBALS['egw']->hooks->process($GLOBALS['hook_values']+array(
Api\Hooks::process($GLOBALS['hook_values']+array(
'location' => $update && $this->run_addaccount_hook !== true ? 'editaccount' : 'addaccount'
),False,True); // called for every app now, not only enabled ones)
return lang("Account %1 %2", $data['account_lid'] ? $data['account_lid'] : accounts::id2name($this->account),
return lang("Account %1 %2", $data['account_lid'] ? $data['account_lid'] : Api\Accounts::id2name($this->account),
$update ? lang('updated') : lang("created with id #%1", $this->account));
}
@ -224,10 +226,10 @@ class admin_cmd_edit_user extends admin_cmd_change_pw
/**
* parse the expired string and return the expired date as timestamp
*
* @param string $str date, 'never', 'already' or '' (=dont change, or default of never of new accounts)
* @param string $str date, 'never', 'already' or '' (=dont change, or default of never of new Api\Accounts)
* @param boolean $existing
* @return int timestamp, 0 for already, -1 for never or null for dont change
* @throws egw_exception_wrong_userinput(lang('Invalid formated date "%1"!',$datein),6);
* @throws Api\Exception\WrongUserinput(lang('Invalid formated date "%1"!',$datein),6);
*/
private function _parse_expired($str,$existing)
{
@ -235,7 +237,7 @@ class admin_cmd_edit_user extends admin_cmd_change_pw
{
case '':
if ($existing) return null;
// fall through --> default for new accounts is never
// fall through --> default for new Api\Accounts is never
case 'never':
return -1;
case 'already':

View File

@ -1,15 +1,17 @@
<?php
/**
* eGgroupWare admin - UI for the command queue
* EGgroupware admin - UI for the command queue
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin
* @copyright (c) 2007 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
* @version $Id$
*/
use EGroupware\Api;
/**
* UI for the admin comand queue
*/
@ -19,9 +21,9 @@ class admin_cmds
'index' => true,
'remotes' => true,
);
/**
* calling get_rows of our static so_sql instance
* calling get_rows of our static Api\Storage\Base instance
*
* @param array $query
* @param array &$rows
@ -30,10 +32,10 @@ class admin_cmds
*/
static function get_rows(array $query,&$rows,&$readonlys)
{
$GLOBALS['egw']->session->appsession('cmds','admin',$query);
Api\Cache::setSession('admin', 'cmds', $query);
$total = admin_cmd::get_rows($query,$rows,$readonlys);
if (!$rows) return array();
foreach($rows as &$row)
@ -50,11 +52,11 @@ class admin_cmds
//_debug_array($rows);
return $total;
}
/**
* Showing the command history and the scheduled commands
*
* @param array $content=null
* @param array $content =null
*/
static function index(array $content=null)
{
@ -62,7 +64,7 @@ class admin_cmds
if (!is_array($content))
{
$content['nm'] = $GLOBALS['egw']->session->appsession('cmds','admin');
$content['nm'] = Api\Cache::getSession('admin', 'cmds');
if (!is_array($content['nm']))
{
$content['nm'] = array(
@ -72,14 +74,14 @@ class admin_cmds
'no_cat' => true, // I disable the cat-selectbox
'order' => 'cmd_created',
'sort' => 'DESC',
);
);
}
}
elseif ($content['nm']['rows']['delete'])
{
list($id) = each($content['nm']['rows']['delete']);
unset($content['nm']['rows']);
if (($cmd = admin_cmd::read($id)))
{
$cmd->delete();
@ -91,7 +93,7 @@ class admin_cmds
'remote_id' => admin_cmd::remote_sites(),
),array(),$content);
}
/**
* get_rows for remote instances
*
@ -108,7 +110,7 @@ class admin_cmds
/**
* Showing remote administration instances
*
* @param array $content=null
* @param array $content =null
*/
static function remotes(array $content=null)
{
@ -116,7 +118,7 @@ class admin_cmds
if (!is_array($content))
{
$content['nm'] = $GLOBALS['egw']->session->appsession('remotes','admin');
$content['nm'] = Api\Cache::getSession('admin', 'remotes');
if (!is_array($content['nm']))
{
$content['nm'] = array(
@ -139,7 +141,7 @@ class admin_cmds
{
list($id) = each($content['nm']['rows']['edit']);
unset($content['nm']['rows']);
$content['remote'] = admin_cmd::read_remote($id);
}
elseif($content['remote']['button'])
@ -150,8 +152,8 @@ class admin_cmds
{
case 'save':
case 'apply':
if ($content['remote']['install_id'] && !$content['remote']['config_passwd'] ||
!$content['remote']['install_id'] && $content['remote']['config_passwd'] ||
if ($content['remote']['install_id'] && !$content['remote']['config_passwd'] ||
!$content['remote']['install_id'] && $content['remote']['config_passwd'] ||
!$content['remote']['remote_hash'] && !$content['remote']['install_id'] && !$content['remote']['config_passwd'])
{
$content['msg'] = lang('You need to enter Install ID AND Password!');
@ -178,6 +180,6 @@ class admin_cmds
}
}
$tpl->exec('admin.admin_cmds.remotes',$content,array(),array(),$content);
}
}

View File

@ -5,11 +5,14 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin
* @copyright (c) 2011 by Ralf Becker <rb@stylite.de>
* @copyright (c) 2011-16 by Ralf Becker <rb@stylite.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Egw;
/**
* Custom - instance specific - translations
*/
@ -27,34 +30,34 @@ class admin_customtranslation
/**
* Add, modify, delete custom translations
*
* @param array $content=null
* @param string $msg=''
* @param array $_content =null
* @param string $msg =''
*/
function index(array $content=null, $msg='')
function index(array $_content=null, $msg='')
{
if (is_array($content))
if (is_array($_content))
{
//_debug_array($content);
if (isset($content['button']))
//_debug_array($_content);
if (isset($_content['button']))
{
list($action) = each($content['button']);
unset($content['button']);
list($action) = each($_content['button']);
unset($_content['button']);
}
elseif($content['rows']['delete'])
elseif($_content['rows']['delete'])
{
list($action) = each($content['rows']['delete']);
unset($content['rows']['delete']);
list($action) = each($_content['rows']['delete']);
unset($_content['rows']['delete']);
}
switch($action)
{
case 'save':
case 'apply':
$saved = 0;
foreach($content['rows'] as $n => $data)
foreach($_content['rows'] as $data)
{
if (!empty($data['phrase']))
{
translation::write('en', 'custom', strtolower(trim($data['phrase'])), $data['translation']);
Api\Translation::write('en', 'custom', strtolower(trim($data['phrase'])), $data['translation']);
++$saved;
}
}
@ -62,20 +65,20 @@ class admin_customtranslation
if ($action == 'apply') break;
// fall through
case 'cancel':
egw::redirect_link('/admin/index.php');
Egw::redirect_link('/admin/index.php');
break;
default: // line to delete;
if (!empty($content['rows'][$action]['phrase']))
if (!empty($_content['rows'][$action]['phrase']))
{
translation::write('en', 'custom', strtolower(trim($content['rows'][$action]['phrase'])), null);
Api\Translation::write('en', 'custom', strtolower(trim($_content['rows'][$action]['phrase'])), null);
$msg = lang('Phrase deleted');
}
break;
}
}
$content = array('rows' => array());
foreach(translation::load_app('custom', 'en') as $phrase => $translation)
foreach(Api\Translation::load_app('custom', 'en') as $phrase => $translation)
{
$content['rows'][++$row] = array(
'phrase' => $phrase,
@ -92,6 +95,6 @@ class admin_customtranslation
$GLOBALS['egw_info']['flags']['app_header'] = lang('Custom translation');
$tpl = new etemplate('admin.customtranslation');
$tpl->exec('admin.admin_customtranslation.index', $content, $sel_options, $readonlys, $preserv);
$tpl->exec('admin.admin_customtranslation.index', $content, array(), $readonlys);
}
}

View File

@ -42,12 +42,12 @@ class admin_db_backup
{
$tpl_root = EGW_SERVER_ROOT.'/setup/templates/default';
$self = $GLOBALS['egw']->link('/index.php',array('menuaction'=>'admin.admin_db_backup.index'));
translation::add_app('setup');
egw_framework::csp_script_src_attrs('unsafe-inline');
Api\Translation::add_app('setup');
Api\Header\ContentSecurityPolicy::add('script-src', 'unsafe-inline');
include EGW_SERVER_ROOT.'/setup/db_backup.php';
unset($tpl_root, $self);
common::egw_footer();
$GLOBALS['egw']->framework->footer();
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare - Admin - importexport
* EGroup2are - Admin - importexport
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package admin
@ -11,13 +11,14 @@
* @version $Id$
*/
use EGroupware\Api;
/**
* class admin_egw_group_record
* Record class needed for export
*/
class admin_egw_group_record implements importexport_iface_egw_record
{
private $identifier = '';
private $group = array();
@ -27,8 +28,6 @@ class admin_egw_group_record implements importexport_iface_egw_record
'select' => array('account_status'),
);
/**
* constructor
* reads record from backend if identifier is given.
@ -81,7 +80,7 @@ class admin_egw_group_record implements importexport_iface_egw_record
*@return string title
*/
public function get_title() {
return common::grab_owner_name($this->identifier);
return Api\Accounts::username($this->identifier);
}
/**
@ -113,14 +112,14 @@ class admin_egw_group_record implements importexport_iface_egw_record
public function get_icon() {
return 'group';
}
/**
* saves record into backend
*
* @return string identifier
*/
public function save ( $_dst_identifier ) {
unset($_dst_identifier); // not used, but require by function signature
}
/**
@ -130,7 +129,7 @@ class admin_egw_group_record implements importexport_iface_egw_record
* @return string dst_identifier
*/
public function copy ( $_dst_identifier ) {
unset($_dst_identifier); // not used, but require by function signature
}
/**
@ -141,7 +140,7 @@ class admin_egw_group_record implements importexport_iface_egw_record
* @return string dst_identifier
*/
public function move ( $_dst_identifier ) {
unset($_dst_identifier); // not used, but require by function signature
}
/**
@ -159,5 +158,4 @@ class admin_egw_group_record implements importexport_iface_egw_record
public function __destruct() {
unset ($this->group);
}
} // end of egw_timesheet_record
}

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare - Admin - importexport
* EGroupware - Admin - importexport
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package admin
@ -11,13 +11,14 @@
* @version $Id$
*/
use EGroupware\Api;
/**
* class admin_egw_user_record
* Record class needed for export
*/
class admin_egw_user_record implements importexport_iface_egw_record
{
private $identifier = '';
private $user = array();
@ -28,8 +29,6 @@ class admin_egw_user_record implements importexport_iface_egw_record
'select' => array('account_status'),
);
/**
* constructor
* reads record from backend if identifier is given.
@ -82,7 +81,7 @@ class admin_egw_user_record implements importexport_iface_egw_record
*@return string title
*/
public function get_title() {
return common::grab_owner_name($this->identifier);
return Api\Accounts::username($this->identifier);
}
/**
@ -114,14 +113,14 @@ class admin_egw_user_record implements importexport_iface_egw_record
public function get_icon() {
return 'user';
}
/**
* saves record into backend
*
* @return string identifier
*/
public function save ( $_dst_identifier ) {
unset($_dst_identifier); // not used, but require by function signature
}
/**
@ -131,7 +130,7 @@ class admin_egw_user_record implements importexport_iface_egw_record
* @return string dst_identifier
*/
public function copy ( $_dst_identifier ) {
unset($_dst_identifier); // not used, but require by function signature
}
/**
@ -142,7 +141,7 @@ class admin_egw_user_record implements importexport_iface_egw_record
* @return string dst_identifier
*/
public function move ( $_dst_identifier ) {
unset($_dst_identifier); // not used, but require by function signature
}
/**
@ -160,5 +159,4 @@ class admin_egw_user_record implements importexport_iface_egw_record
public function __destruct() {
unset ($this->user);
}
} // end of egw_timesheet_record
}

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare - Export plugin for groups
* EGroupware - Export plugin for groups
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package admin
@ -14,8 +14,8 @@
/**
* Export users plugin
*/
class admin_export_groups_csv implements importexport_iface_export_plugin {
class admin_export_groups_csv implements importexport_iface_export_plugin
{
/**
* Exports records as defined in $_definition
*
@ -24,8 +24,6 @@ class admin_export_groups_csv implements importexport_iface_export_plugin {
public function export( $_stream, importexport_definition $_definition) {
$options = $_definition->plugin_options;
$selection = array();
$query = array(
'type' => 'groups',
);

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare - Export plugin for users
* EGroupware - Export plugin for users
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package admin
@ -14,8 +14,8 @@
/**
* Export users plugin
*/
class admin_export_users_csv implements importexport_iface_export_plugin {
class admin_export_users_csv implements importexport_iface_export_plugin
{
/**
* Exports records as defined in $_definition
*
@ -24,8 +24,6 @@ class admin_export_users_csv implements importexport_iface_export_plugin {
public function export( $_stream, importexport_definition $_definition) {
$options = $_definition->plugin_options;
$selection = array();
$query = array(
'type' => 'accounts',
);

View File

@ -11,6 +11,7 @@
*/
use EGroupware\Api;
use EGroupware\Api\Egw;
/**
* Static hooks for admin application
@ -57,7 +58,7 @@ class admin_hooks
if (! $GLOBALS['egw']->acl->check('site_config_acce',1,'admin'))
{
$file['Site Configuration'] = egw::link('/index.php','menuaction=admin.admin_config.index&appname=admin&ajax=true');
$file['Site Configuration'] = Egw::link('/index.php','menuaction=admin.admin_config.index&appname=admin&ajax=true');
}
if (! $GLOBALS['egw']->acl->check('account_access',1,'admin'))
@ -70,7 +71,7 @@ class admin_hooks
if (! $GLOBALS['egw']->acl->check('account_access',16,'admin'))
{
$file['Bulk password reset'] = egw::link('/index.php','menuaction=admin.admin_passwordreset.index&ajax=true');
$file['Bulk password reset'] = Egw::link('/index.php','menuaction=admin.admin_passwordreset.index&ajax=true');
}
if (! $GLOBALS['egw']->acl->check('group_access',1,'admin'))
@ -84,28 +85,28 @@ class admin_hooks
if (! $GLOBALS['egw']->acl->check('global_categorie',1,'admin'))
{
$file['Global Categories'] = egw::link('/index.php','menuaction=admin.admin_categories.index&appname=phpgw&ajax=true');
$file['Global Categories'] = Egw::link('/index.php','menuaction=admin.admin_categories.index&appname=phpgw&ajax=true');
}
if (!$GLOBALS['egw']->acl->check('mainscreen_messa',1,'admin') || !$GLOBALS['egw']->acl->check('mainscreen_messa',2,'admin'))
{
$file['Change Main Screen Message'] = egw::link('/index.php','menuaction=admin.uimainscreen.index');
$file['Change Main Screen Message'] = Egw::link('/index.php','menuaction=admin.uimainscreen.index');
}
if (! $GLOBALS['egw']->acl->check('current_sessions',1,'admin'))
{
$file['View Sessions'] = egw::link('/index.php','menuaction=admin.admin_accesslog.sessions&ajax=true');
$file['View Sessions'] = Egw::link('/index.php','menuaction=admin.admin_accesslog.sessions&ajax=true');
}
if (! $GLOBALS['egw']->acl->check('access_log_acces',1,'admin'))
{
$file['View Access Log'] = egw::link('/index.php','menuaction=admin.admin_accesslog.index&ajax=true');
$file['View Access Log'] = Egw::link('/index.php','menuaction=admin.admin_accesslog.index&ajax=true');
}
/* disable old EGroupware error_log, as it is not used anymore
if (! $GLOBALS['egw']->acl->check('error_log_access',1,'admin'))
{
$file['View Error Log'] = egw::link('/index.php','menuaction=admin.uilog.list_log');
$file['View Error Log'] = Egw::link('/index.php','menuaction=admin.uilog.list_log');
}*/
if (! $GLOBALS['egw']->acl->check('applications_acc',16,'admin'))
@ -120,24 +121,24 @@ class admin_hooks
if (! $GLOBALS['egw']->acl->check('asyncservice_acc',1,'admin'))
{
$file['Asynchronous timed services'] = egw::link('/index.php','menuaction=admin.uiasyncservice.index');
$file['Asynchronous timed services'] = Egw::link('/index.php','menuaction=admin.uiasyncservice.index');
}
if (! $GLOBALS['egw']->acl->check('db_backup_access',1,'admin'))
{
$file['DB backup and restore'] = egw::link('/index.php','menuaction=admin.admin_db_backup.index');
$file['DB backup and restore'] = Egw::link('/index.php','menuaction=admin.admin_db_backup.index');
}
if (! $GLOBALS['egw']->acl->check('info_access',1,'admin'))
{
$file['phpInfo'] = "javascript:egw.openPopup('" . egw::link('/admin/phpinfo.php','',false) . "',960,600,'phpinfoWindow')";
$file['phpInfo'] = "javascript:egw.openPopup('" . Egw::link('/admin/phpinfo.php','',false) . "',960,600,'phpinfoWindow')";
}
$file['Admin queue and history'] = egw::link('/index.php','menuaction=admin.admin_cmds.index');
$file['Remote administration instances'] = egw::link('/index.php','menuaction=admin.admin_cmds.remotes');
$file['Custom translation'] = egw::link('/index.php','menuaction=admin.admin_customtranslation.index');
$file['Changelog and versions'] = egw::link('/about.php');
$file['Admin queue and history'] = Egw::link('/index.php','menuaction=admin.admin_cmds.index');
$file['Remote administration instances'] = Egw::link('/index.php','menuaction=admin.admin_cmds.remotes');
$file['Custom translation'] = Egw::link('/index.php','menuaction=admin.admin_customtranslation.index');
$file['Changelog and versions'] = Egw::link('/about.php');
$file['Submit statistic information'] = egw::link('/index.php','menuaction=admin.admin_statistics.submit');
$file['Submit statistic information'] = Egw::link('/index.php','menuaction=admin.admin_statistics.submit');
if ($location == 'admin')
{
@ -167,7 +168,7 @@ class admin_hooks
Api\Image::invalidate();
if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited
if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) // Egw object in setup is limited
{
$GLOBALS['egw']->invalidate_session_cache(); // in case with cache the egw_info array in the session
}
@ -256,7 +257,7 @@ class admin_hooks
* Called before displaying site configuration
*
* @param array $config
* @return array with additional config to merge
* @return array with additional Api\Config to merge
*/
public static function config(array $config)
{

View File

@ -1,15 +1,16 @@
<?php
/**
* eGroupWare
* EGroupware admin
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package admin
* @link http://www.egroupware.org
* @author Nathan Gray
* @copyright Nathan Gray
* @version $Id: $
* @version $Id$
*/
use EGroupware\Api;
/**
* class import_csv for admin (groups)
@ -69,9 +70,9 @@ class admin_import_groups_csv implements importexport_iface_import_plugin {
protected $errors = array();
/**
* List of actions, and how many times that action was taken
*/
protected $results = array();
* List of actions, and how many times that action was taken
*/
protected $results = array();
/**
* imports entries according to given definition object.
@ -127,7 +128,7 @@ class admin_import_groups_csv implements importexport_iface_import_plugin {
// Skip the search if the field is empty
if($record[$condition['string']] !== '') {
$accounts = $GLOBALS['egw']->accounts->search(array(
'type' => 'groups',
'query' => $record[$condition['string']],
@ -204,8 +205,8 @@ class admin_import_groups_csv implements importexport_iface_import_plugin {
$this->results[$_action]++;
return true;
default:
throw new egw_exception('Unsupported action');
throw new Api\Exception('Unsupported action');
}
}
@ -262,39 +263,38 @@ class admin_import_groups_csv implements importexport_iface_import_plugin {
}
/**
* Returns warnings that were encountered during importing
* Maximum of one warning message per record, but you can concatenate them if you need to
*
* @return Array (
* record_# => warning message
* )
*/
* Returns warnings that were encountered during importing
* Maximum of one warning message per record, but you can concatenate them if you need to
*
* @return Array (
* record_# => warning message
* )
*/
public function get_warnings() {
return $this->warnings;
}
/**
* Returns errors that were encountered during importing
* Maximum of one error message per record, but you can append if you need to
*
* @return Array (
* record_# => error message
* )
*/
public function get_errors() {
* Returns errors that were encountered during importing
* Maximum of one error message per record, but you can append if you need to
*
* @return Array (
* record_# => error message
* )
*/
public function get_errors() {
return $this->errors;
}
/**
* Returns a list of actions taken, and the number of records for that action.
* Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
*
* @return Array (
* action => record count
* )
*/
public function get_results() {
return $this->results;
}
} // end of iface_export_plugin
?>
* Returns a list of actions taken, and the number of records for that action.
* Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
*
* @return Array (
* action => record count
* )
*/
public function get_results() {
return $this->results;
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare
* EGroupware admin
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package admin
@ -10,6 +10,7 @@
* @version $Id$
*/
use EGroupware\Api;
/**
* class import_csv for admin (users)
@ -216,7 +217,7 @@ class admin_import_users_csv implements importexport_iface_import_plugin {
$this->results[$_action]++;
return true;
default:
throw new egw_exception('Unsupported action');
throw new Api\Exception('Unsupported action');
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
* EGroupware EMailAdmin: Wizard to create mail accounts
* EGroupware EMailAdmin: Wizard to create mail Api\Accounts
*
* @link http://www.stylite.de
* @package emailadmin
@ -11,6 +11,9 @@
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Acl;
use EGroupware\Api\Etemplate;
use EGroupware\Api\Mail;
/**
@ -170,7 +173,7 @@ class admin_mail
// otherwise we cant switch to ckeditor in edit
Api\Html\CkEditorConfig::set_csp_script_src_attrs();
$tpl = new Api\Etemplate('admin.mailwizard');
$tpl = new Etemplate('admin.mailwizard');
if (empty($content['account_id']))
{
$content['account_id'] = $GLOBALS['egw_info']['user']['account_id'];
@ -182,7 +185,7 @@ class admin_mail
'acc_imap_port' => 993,
'manual_class' => 'emailadmin_manual',
);
egw_framework::message($msg ? $msg : (string)$_GET['msg'], $msg_type);
Framework::message($msg ? $msg : (string)$_GET['msg'], $msg_type);
if (!empty($content['acc_imap_host']) || !empty($content['acc_imap_username']))
{
@ -326,19 +329,19 @@ class admin_mail
switch($e->getCode())
{
case Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED:
Api\Etemplate::set_validation_error('acc_imap_username', lang($e->getMessage()));
Api\Etemplate::set_validation_error('acc_imap_password', lang($e->getMessage()));
Etemplate::set_validation_error('acc_imap_username', lang($e->getMessage()));
Etemplate::set_validation_error('acc_imap_password', lang($e->getMessage()));
break;
case Horde_Imap_Client_Exception::SERVER_CONNECT:
Api\Etemplate::set_validation_error('acc_imap_host', lang($e->getMessage()));
Etemplate::set_validation_error('acc_imap_host', lang($e->getMessage()));
break;
}
}
$readonlys['button[manual]'] = true;
unset($content['manual_class']);
$sel_options['acc_imap_ssl'] = self::$ssl_types;
$tpl = new Api\Etemplate('admin.mailwizard');
$tpl = new Etemplate('admin.mailwizard');
$tpl->exec(static::APP_CLASS.'autoconfig', $content, $sel_options, $readonlys, $content, 2);
}
@ -378,7 +381,7 @@ class admin_mail
if (self::$debug) _egw_log_exception($e);
}
$tpl = new Api\Etemplate('admin.mailwizard.folder');
$tpl = new Etemplate('admin.mailwizard.folder');
$tpl->exec(static::APP_CLASS.'folder', $content, $sel_options, array(), $content);
}
@ -578,15 +581,15 @@ class admin_mail
case 61: // connection refused
case 60: // connection timed out (imap.googlemail.com returns that for none-ssl/4190/2000)
case 65: // no route ot host (imap.googlemail.com returns that for ssl/5190)
Api\Etemplate::set_validation_error('acc_sieve_host', lang($e->getMessage()));
Api\Etemplate::set_validation_error('acc_sieve_port', lang($e->getMessage()));
Etemplate::set_validation_error('acc_sieve_host', lang($e->getMessage()));
Etemplate::set_validation_error('acc_sieve_port', lang($e->getMessage()));
break;
}
$content['msg'] = lang('No sieve support detected, either fix configuration manually or leave it switched off.');
$content['acc_sieve_enabled'] = 0;
}
$sel_options['acc_sieve_ssl'] = self::$ssl_types;
$tpl = new Api\Etemplate('admin.mailwizard.sieve');
$tpl = new Etemplate('admin.mailwizard.sieve');
$tpl->exec(static::APP_CLASS.'sieve', $content, $sel_options, $readonlys, $content, 2);
}
@ -776,18 +779,18 @@ class admin_mail
case Horde_Smtp_Exception::LOGIN_AUTHENTICATIONFAILED:
case Horde_Smtp_Exception::LOGIN_REQUIREAUTHENTICATION:
case Horde_Smtp_Exception::UNSPECIFIED:
Api\Etemplate::set_validation_error('acc_smtp_username', lang($e->getMessage()));
Api\Etemplate::set_validation_error('acc_smtp_password', lang($e->getMessage()));
Etemplate::set_validation_error('acc_smtp_username', lang($e->getMessage()));
Etemplate::set_validation_error('acc_smtp_password', lang($e->getMessage()));
break;
case Horde_Smtp_Exception::SERVER_CONNECT:
Api\Etemplate::set_validation_error('acc_smtp_host', lang($e->getMessage()));
Api\Etemplate::set_validation_error('acc_smtp_port', lang($e->getMessage()));
Etemplate::set_validation_error('acc_smtp_host', lang($e->getMessage()));
Etemplate::set_validation_error('acc_smtp_port', lang($e->getMessage()));
break;
}
}
$sel_options['acc_smtp_ssl'] = self::$ssl_types;
$tpl = new Api\Etemplate('admin.mailwizard.smtp');
$tpl = new Etemplate('admin.mailwizard.smtp');
$tpl->exec(static::APP_CLASS.'smtp', $content, $sel_options, $readonlys, $content, 2);
}
@ -813,7 +816,7 @@ class admin_mail
if (stripos($_GET['msg'],'fatal error:')!==false || $_GET['msg_type'] == 'error') $msg_type = 'error';
}
if ($content['acc_id'] || (isset($_GET['acc_id']) && (int)$_GET['acc_id'] > 0) ) Mail::unsetCachedObjects($content['acc_id']?$content['acc_id']:$_GET['acc_id']);
$tpl = new Api\Etemplate('admin.mailaccount');
$tpl = new Etemplate('admin.mailaccount');
if (!is_array($content) || !empty($content['acc_id']) && isset($content['old_acc_id']) && $content['acc_id'] != $content['old_acc_id'])
{
@ -879,11 +882,11 @@ class admin_mail
}
catch(Api\Exception\NotFound $e) {
if (self::$debug) _egw_log_exception($e);
egw_framework::window_close(lang('Account not found!'));
Framework::window_close(lang('Account not found!'));
}
catch(Exception $e) {
if (self::$debug) _egw_log_exception($e);
egw_framework::window_close($e->getMessage().' ('.get_class($e).': '.$e->getCode().')');
Framework::window_close($e->getMessage().' ('.get_class($e).': '.$e->getCode().')');
}
}
elseif ($content['acc_id'] === 'new')
@ -925,7 +928,7 @@ class admin_mail
unset($content['acc_smtp_auth_session']);
unset($content['notify_use_default']);
}
$edit_access = Mail\Account::check_access(EGW_ACL_EDIT, $content);
$edit_access = Mail\Account::check_access(Acl::EDIT, $content);
// disable notification save-default and use-default, if only one account or no edit-rights
$tpl->disableElement('notify_save_default', !$is_multiple || !$edit_access);
@ -993,7 +996,7 @@ class admin_mail
$content['deliveryMode'] == Mail\Smtp::FORWARD_ONLY &&
empty($content['mailForwardingAddress']))
{
Api\Etemplate::set_validation_error('mailForwardingAddress', lang('Field must not be empty !!!'));
Etemplate::set_validation_error('mailForwardingAddress', lang('Field must not be empty !!!'));
throw new Api\Exception\WrongUserinput(lang('You need to specify a forwarding address, when checking "%1"!', lang('Forward only')));
}
// set notifications to store according to checkboxes
@ -1092,12 +1095,12 @@ class admin_mail
}
if ($content['acc_id']) Mail::unsetCachedObjects($content['acc_id']);
if (stripos($msg,'fatal error:')!==false) $msg_type = 'error';
egw_framework::refresh_opener($msg, 'emailadmin', $content['acc_id'], $new_account ? 'add' : 'update', null, null, null, $msg_type);
if ($button == 'save') egw_framework::window_close();
Framework::refresh_opener($msg, 'emailadmin', $content['acc_id'], $new_account ? 'add' : 'update', null, null, null, $msg_type);
if ($button == 'save') Framework::window_close();
break;
case 'delete':
if (!Mail\Account::check_access(EGW_ACL_DELETE, $content))
if (!Mail\Account::check_access(Acl::DELETE, $content))
{
$msg = lang('Permission denied!');
$msg_type = 'error';
@ -1105,8 +1108,8 @@ class admin_mail
elseif (Mail\Account::delete($content['acc_id']) > 0)
{
if ($content['acc_id']) Mail::unsetCachedObjects($content['acc_id']);
egw_framework::refresh_opener(lang('Account deleted.'), 'emailadmin', $content['acc_id'], 'delete');
egw_framework::window_close();
Framework::refresh_opener(lang('Account deleted.'), 'emailadmin', $content['acc_id'], 'delete');
Framework::window_close();
}
else
{
@ -1118,7 +1121,7 @@ class admin_mail
// disable delete button for new, not yet saved entries, if no delete rights or a non-standard identity selected
$readonlys['button[delete]'] = empty($content['acc_id']) ||
!Mail\Account::check_access(EGW_ACL_DELETE, $content) ||
!Mail\Account::check_access(Acl::DELETE, $content) ||
$content['ident_id'] != $content['std_ident_id'];
// if account is for multiple user, change delete confirmation to reflect that
@ -1249,7 +1252,7 @@ class admin_mail
'tabs' => array_merge((array)$readonlys['tabs'], (array)$imap_ro['tabs']),
));
}
egw_framework::message($msg ? $msg : (string)$_GET['msg'], $msg_type);
Framework::message($msg ? $msg : (string)$_GET['msg'], $msg_type);
if (count($content['account_id']) > 1)
{
@ -1260,7 +1263,7 @@ class admin_mail
if ($content['called_for'] && $content['acc_id'] > 0)
{
$admin_actions = array();
foreach($GLOBALS['egw']->hooks->process(array(
foreach(Api\Hooks::process(array(
'location' => 'emailadmin_edit',
'account_id' => $content['called_for'],
'acc_id' => $content['acc_id'],
@ -1453,7 +1456,7 @@ class admin_mail
public function ajax_activeAccounts($_data)
{
if (!$this->is_admin) die('no rights to be here!');
$response = egw_json_response::get();
$response = Api\Json\Response::get();
if (($account = $GLOBALS['egw']->accounts->read($_data['id'])))
{
if ($_data['quota'] !== '' || $_data['accountStatus'] !== ''

View File

@ -1,19 +0,0 @@
<?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
* @deprecated use standard admin_hooks class
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
/**
* Old class-name to ease updates
*
* @deprecated use standard admin_hooks class
*/
class admin_prefs_sidebox_hooks extends admin_hooks {}

View File

@ -5,11 +5,14 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin
* @copyright (c) 2009-11 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2009-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Egw;
/**
* Submit statistical data to egroupware.org
*/
@ -40,29 +43,29 @@ class admin_statistics
/**
* Display and allow to submit statistical data
*
* @param array $content=null
* @param array $_content =null
*/
public function submit($content=null)
public function submit($_content=null)
{
if (is_array($content))
if (is_array($_content))
{
$config = new config(self::CONFIG_APP);
if ($content['postpone'])
$config = new Api\Config(self::CONFIG_APP);
if ($_content['postpone'])
{
config::save_value(self::CONFIG_POSTPONE_SUBMIT,time()+$content['postpone'],self::CONFIG_APP);
Api\Config::save_value(self::CONFIG_POSTPONE_SUBMIT,time()+$_content['postpone'],self::CONFIG_APP);
$what = 'postpone';
}
elseif(!$content['cancel'])
elseif(!$_content['cancel'])
{
config::save_value(self::CONFIG_LAST_SUBMIT,time(),self::CONFIG_APP);
config::save_value(self::CONFIG_SUBMIT_ID,empty($content['submit_id']) ? '***none***' : $content['submit_id'],self::CONFIG_APP);
config::save_value(self::CONFIG_COUNTRY,empty($content['country']) ? '***multinational***' : $content['country'],self::CONFIG_APP);
config::save_value(self::CONFIG_USAGE_TYPE,$content['usage_type'],self::CONFIG_APP);
config::save_value(self::CONFIG_INSTALL_TYPE,$content['install_type'],self::CONFIG_APP);
config::save_value(self::CONFIG_POSTPONE_SUBMIT,null,self::CONFIG_APP); // remove evtl. postpone time
Api\Config::save_value(self::CONFIG_LAST_SUBMIT,time(),self::CONFIG_APP);
Api\Config::save_value(self::CONFIG_SUBMIT_ID,empty($_content['submit_id']) ? '***none***' : $_content['submit_id'],self::CONFIG_APP);
Api\Config::save_value(self::CONFIG_COUNTRY,empty($_content['country']) ? '***multinational***' : $_content['country'],self::CONFIG_APP);
Api\Config::save_value(self::CONFIG_USAGE_TYPE,$_content['usage_type'],self::CONFIG_APP);
Api\Config::save_value(self::CONFIG_INSTALL_TYPE,$_content['install_type'],self::CONFIG_APP);
Api\Config::save_value(self::CONFIG_POSTPONE_SUBMIT,null,self::CONFIG_APP); // remove evtl. postpone time
$what = 'submited';
}
egw::redirect_link('/admin/index.php','statistics='.($what ? $what : 'cancled'));
Egw::redirect_link('/admin/index.php','statistics='.($what ? $what : 'cancled'));
}
$sel_options['usage_type'] = array(
'commercial' => lang('Commercial: all sorts of companies'),
@ -89,10 +92,10 @@ class admin_statistics
30*24*3600 => lang('one month'),
60*24*3600 => lang('two months'),
);
$config = config::read(self::CONFIG_APP);
$config = Api\Config::read(self::CONFIG_APP);
//_debug_array($config);
$content = array_merge(self::gather_data(),array(
'statistic_url' => html::a_href(self::STATISTIC_URL,self::STATISTIC_URL,'',' target="_blank"'),
'statistic_url' => Api\Html::a_href(self::STATISTIC_URL,self::STATISTIC_URL,'',' target="_blank"'),
'submit_host' => parse_url(self::SUBMIT_URL,PHP_URL_HOST),
'submit_url' => self::SUBMIT_URL,
'last_submitted' => $config[self::CONFIG_LAST_SUBMIT],
@ -104,7 +107,7 @@ class admin_statistics
{
$content['submit_id'] = $config['statistics_submit_id'] == '***none***' ? '' : $config['statistics_submit_id'];
}
// show previous country
// show previous Api\Country
if ($config[self::CONFIG_COUNTRY])
{
$content['country'] = $config[self::CONFIG_COUNTRY] == '***multinational***' ? '' : $config[self::CONFIG_COUNTRY];
@ -138,7 +141,7 @@ class admin_statistics
}
$GLOBALS['egw_info']['flags']['app_header'] = lang('Submit statistic information');
$tmpl = new etemplate('admin.statistics');
$tmpl->exec('admin.admin_statistics.submit',$content,$sel_options,$readonlys,$preserv);
$tmpl->exec('admin.admin_statistics.submit',$content,$sel_options,$readonlys);
}
/**
@ -185,11 +188,11 @@ class admin_statistics
{
$data['install_type'] = 'package';
}
foreach($GLOBALS['egw_info']['apps'] as $app => $app_data)
foreach(array_keys($GLOBALS['egw_info']['apps']) as $app)
{
if (in_array($app,array(
'admin','phpgwapi','emailadmin','sambaadmin','developer_tools',
'home','preferences','etemplate','registration','manual','egw-pear',
'admin','phpgwapi','api','sambaadmin','developer_tools',
'home','preferences','etemplate','registration','manual',
)))
{
continue; // --> ignore to not submit too much
@ -270,7 +273,8 @@ class admin_statistics
$entries = (int)$GLOBALS['egw']->db->query('SELECT COUNT(*) FROM '.$table)->fetchColumn();
//echo "$app ($table): $entries<br />\n";
}
catch(egw_exception_db $e) {
catch(Api\Db\Exception $e) {
unset($e);
$entries = null;
}
}
@ -285,7 +289,7 @@ class admin_statistics
*/
public static function check($redirect=true)
{
$config = config::read(self::CONFIG_APP);
$config = Api\Config::read(self::CONFIG_APP);
if (isset($config[self::CONFIG_POSTPONE_SUBMIT]) && $config[self::CONFIG_POSTPONE_SUBMIT] > time() ||
isset($config[self::CONFIG_LAST_SUBMIT ]) && $config[self::CONFIG_LAST_SUBMIT ] > time()-self::SUBMISION_RATE)
@ -295,7 +299,7 @@ class admin_statistics
if (!$redirect) return true;
//die('Due for new statistics submission: last_submit='.$config[self::CONFIG_LAST_SUBMIT ].', postpone='.$config[self::CONFIG_POSTPONE_SUBMIT].', '.function_backtrace());
egw::redirect_link('/index.php',array(
Egw::redirect_link('/index.php',array(
'menuaction' => 'admin.admin_ui.index',
'ajax' => 'true',
'load' => 'admin.admin_statistics.submit',

View File

@ -11,6 +11,9 @@
*/
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Egw;
use EGroupware\Api\Etemplate;
/**
* UI for admin
@ -28,7 +31,7 @@ class admin_ui
/**
* Reference to global accounts object
*
* @var accounts
* @var Api\Accounts
*/
private static $accounts;
@ -43,7 +46,7 @@ class admin_ui
{
$_GET['load'] = 'admin.admin_statistics.submit';
}
$tpl = new Api\Etemplate('admin.index');
$tpl = new Etemplate('admin.index');
if (!is_array($content)) $content = array();
$content['nm'] = array(
@ -89,7 +92,7 @@ class admin_ui
$vars['menuaction'] = $vars['load'];
unset($vars['ajax']);
unset($vars['load']);
$content['iframe'] = egw::link('/index.php', $vars);
$content['iframe'] = Egw::link('/index.php', $vars);
}
else
{
@ -142,11 +145,11 @@ class admin_ui
}
$group = 5; // allow to place actions in different groups by hook, this is the default
// supporting both old way using $GLOBALS['menuData'] and new just returning data in hook
$apps = array_unique(array_merge(array('admin'), $GLOBALS['egw']->hooks->hook_implemented('edit_group')));
$apps = array_unique(array_merge(array('admin'), Api\Hooks::implemented('edit_group')));
foreach($apps as $app)
{
$GLOBALS['menuData'] = $data = array();
$data = $GLOBALS['egw']->hooks->single('edit_group', $app);
$data = Api\Hooks::single('edit_group', $app);
if (!is_array($data)) $data = $GLOBALS['menuData'];
//error_log(__METHOD__."() app $app returned ".array2string($data));
foreach($data as $item)
@ -209,7 +212,7 @@ class admin_ui
),
);
// generate urls for add/edit accounts via addressbook
$edit = Api\Link::get_registry('addressbook', 'edit');
$edit = Link::get_registry('addressbook', 'edit');
$edit['account_id'] = '$id';
foreach($edit as $name => $val)
{
@ -223,11 +226,11 @@ class admin_ui
}
++$group;
// supporting both old way using $GLOBALS['menuData'] and new just returning data in hook
$apps = array_unique(array_merge(array('admin'), $GLOBALS['egw']->hooks->hook_implemented('edit_user')));
$apps = array_unique(array_merge(array('admin'), Api\Hooks::implemented('edit_user')));
foreach($apps as $app)
{
$GLOBALS['menuData'] = $data = array();
$data = $GLOBALS['egw']->hooks->single('edit_user', $app);
$data = Api\Hooks::single('edit_user', $app);
if (!is_array($data)) $data = $GLOBALS['menuData'];
foreach($data as $item)
{
@ -321,7 +324,7 @@ class admin_ui
*/
public static function ajax_tree()
{
Api\Etemplate\Widget\Tree::send_quote_json(self::tree_data(!empty($_GET['id']) ? $_GET['id'] : '/'));
Etemplate\Widget\Tree::send_quote_json(self::tree_data(!empty($_GET['id']) ? $_GET['id'] : '/'));
}
/**
@ -376,7 +379,7 @@ class admin_ui
}
if (!empty($data['icon']))
{
$icon = Api\Etemplate\Widget\Tree::imagePath($data['icon']);
$icon = Etemplate\Widget\Tree::imagePath($data['icon']);
if ($data['child'] || $data['item'])
{
$data['im1'] = $data['im2'] = $icon;
@ -397,7 +400,7 @@ class admin_ui
$path .= ($path == '/' ? '' : '/').$part;
if (!isset($parent[$path]))
{
$icon = Api\Etemplate\Widget\Tree::imagePath($part == 'apps' ? Api\Image::find('phpgwapi', 'home') :
$icon = Etemplate\Widget\Tree::imagePath($part == 'apps' ? Api\Image::find('phpgwapi', 'home') :
(($i=Api\Image::find($part, 'navbar')) ? $i : Api\Image::find('phpgwapi', 'nonav')));
$parent[$path] = array(
'id' => $path,
@ -493,9 +496,9 @@ class admin_ui
admin_ui::$hook_data[$appname] = $file2 ? $file2 : $file;
//error_log(__METHOD__."(".array2string(func_get_args()).")");
}
self::$hook_data = array_merge($GLOBALS['egw']->hooks->process('admin', array('admin')), self::$hook_data);
self::$hook_data = array_merge(Api\Hooks::process('admin', array('admin')), self::$hook_data);
// sort apps alphabetic by their title / translation of app-name
// sort apps alphabetic by their title / Api\Translation of app-name
uksort(self::$hook_data, function($a, $b)
{
return strcasecmp(lang($a), lang($b));

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare - Wizard for Groups CSV export
* EGroupware - Wizard for Groups CSV export
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package admin
@ -10,6 +10,8 @@
* @version $Id$
*/
use EGroupware\Api;
class admin_wizard_export_groups_csv extends importexport_wizard_basic_export_csv
{
public function __construct() {
@ -24,7 +26,7 @@ class admin_wizard_export_groups_csv extends importexport_wizard_basic_export_cs
// Custom fields - not really used in admin...
unset($this->export_fields['customfields']);
$custom = config::get_customfields('admin', true);
$custom = Api\Storage\Customfields::get('admin', true);
foreach($custom as $name => $data) {
$this->export_fields['#'.$name] = $data['label'];
}

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare - Wizard for User CSV export
* EGroupware - Wizard for User CSV export
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package admin
@ -10,6 +10,8 @@
* @version $Id$
*/
use EGroupware\Api;
class admin_wizard_export_users_csv extends importexport_wizard_basic_export_csv
{
public function __construct() {
@ -33,7 +35,7 @@ class admin_wizard_export_users_csv extends importexport_wizard_basic_export_csv
// Custom fields - not really used in admin...
unset($this->export_fields['customfields']);
$custom = config::get_customfields('admin', true);
$custom = Api\Storage\Customfields::get('admin', true);
foreach($custom as $name => $data) {
$this->export_fields['#'.$name] = $data['label'];
}

View File

@ -1,98 +0,0 @@
<?php
/**************************************************************************\
* eGroupWare - configuration administration *
* http://www.egroupware.org *
* Copyright (C) 2001 Loic Dachary *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class boconfig
{
var $public_functions = array();
var $xml_functions = array();
var $soap_functions = array(
'rpc_values' => array(
'in' => array('struct', 'struct'),
'out' => array()
)
);
function list_methods($_type='xmlrpc')
{
/*
This handles introspection or discovery by the logged in client,
in which case the input might be an array. The server always calls
this function to fill the server dispatch map using a string.
*/
if (is_array($_type))
{
$_type = $_type['type'] ? $_type['type'] : $_type[0];
}
switch($_type)
{
case 'xmlrpc':
$xml_functions = array(
'rpc_values' => array(
'function' => 'rpc_values',
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
'docstring' => lang('Set preference values.')
),
'list_methods' => array(
'function' => 'list_methods',
'signature' => array(array(xmlrpcStruct,xmlrpcString)),
'docstring' => lang('Read this list of methods.')
)
);
return $xml_functions;
break;
case 'soap':
return $this->soap_functions;
break;
default:
return array();
break;
}
}
// xmlrpc functions
function rpc_values($data)
{
exit;
$newsettings = $data['newsettings'];
if (!$data['appname'])
{
$errors[] = "Missing appname";
}
if (!is_array($newsettings))
{
$errors[] = "Missing newsettings or not an array";
}
if (is_array($errors))
{
return $errors;
}
$conf =& CreateObject('phpgwapi.config', $data['appname']);
$conf->read_repository();
reset($newsettings);
while(list($key,$val) = each($newsettings))
{
$conf->value($key, $val);
}
$conf->save_repository();
return True;
}
}
?>

View File

@ -11,6 +11,8 @@
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Etemplate;
/**
* Customfields class - manages customfield definitions in egw_config table
@ -125,11 +127,11 @@ class customfields
// Read fields, constructor doesn't always know appname
$this->fields = Api\Storage\Customfields::get($this->appname,true);
$this->tmpl = new etemplate_new();
$this->tmpl = new Etemplate();
$this->tmpl->read('admin.customfields');
// do we manage content-types?
$test = new etemplate_new();
$test = new Etemplate();
if($test->read($this->appname.'.admin.types')) $this->manage_content_types = true;
// Handle incoming - types, options, etc.
@ -142,7 +144,7 @@ class customfields
if (count($this->content_types)==0)
{
// if you define your default types of your app with the search_link hook, they are available here, if no types were found
$this->content_types = (array)egw_link::get_registry($this->appname,'default_types');
$this->content_types = (array)Api\Link::get_registry($this->appname,'default_types');
}
// Set this now, we need to know it for updates
$this->content_type = $content['content_types']['types'] ? $content['content_types']['types'] : (array_key_exists(0,$this->content_types) ? $this->content_types[0] : key($this->content_types));
@ -182,7 +184,7 @@ class customfields
$this->save_repository();
}
$content['nm']= $GLOBALS['egw']->session->appsession('customfield-index','admin');
$content['nm']= Api\Cache::getSession('admin', 'customfield-index');
if (!is_array($content['nm']))
{
// Initialize nextmatch
@ -256,7 +258,7 @@ class customfields
static::app_index($content, $sel_options, $readonlys, $preserve);
// Make sure app css gets loaded, extending app might cause et2 to miss it
egw_framework::includeCSS('admin','app');
Framework::includeCSS('admin','app');
$GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps'][$this->appname]['title'].' - '.lang('Custom fields');
@ -304,14 +306,14 @@ class customfields
{
case 'delete':
$this->so->delete($cf_id);
egw_framework::refresh_opener('Deleted', 'admin', $cf_id /* Conflicts with accounts 'delete'*/);
egw_framework::window_close();
Framework::refresh_opener('Deleted', 'admin', $cf_id /* Conflicts with Api\Accounts 'delete'*/);
Framework::window_close();
break;
case 'save':
case 'apply':
if(!$cf_id && $this->fields[$content['cf_name']])
{
egw_framework::message(lang("Field '%1' already exists !!!",$content['cf_name']),'error');
Framework::message(lang("Field '%1' already exists !!!",$content['cf_name']),'error');
$content['cf_name'] = '';
break;
}
@ -351,14 +353,14 @@ class customfields
$this->fields = Api\Storage\Customfields::get($this->appname,true);
$cf_id = (int)$this->fields[$content['cf_name']]['id'];
}
egw_framework::refresh_opener('Saved', 'admin', $cf_id, 'edit');
Framework::refresh_opener('Saved', 'admin', $cf_id, 'edit');
if ($action != 'save')
{
break;
}
//fall through
case 'cancel':
egw_framework::window_close();
Framework::window_close();
}
}
else
@ -368,13 +370,13 @@ class customfields
// do we manage content-types?
$test = new etemplate_new();
$test = new Etemplate();
if($test->read($this->appname.'.admin.types')) $this->manage_content_types = true;
$this->tmpl = new etemplate_new();
$this->tmpl = new Etemplate();
$this->tmpl->read('admin.customfield_edit');
translation::add_app('infolog'); // til we move the translations
Api\Translation::add_app('infolog'); // til we move the translations
$GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps'][$this->appname]['title'].' - '.lang('Custom fields');
$sel_options = array();
@ -590,7 +592,7 @@ class customfields
function save_repository()
{
//echo '<p>uicustomfields::save_repository() \$this->fields=<pre style="text-aling: left;">'; print_r($this->fields); echo "</pre>\n";
$config = new config($this->appname);
$config = new Api\Config($this->appname);
$config->read_repository();
$config->value('types',$this->content_types);
$config->save_repository();

View File

@ -9,6 +9,9 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Egw;
/**
* Class to admin cron-job like timed calls of eGroupWare methods
*/
@ -22,11 +25,11 @@ class uiasyncservice
{
if ($GLOBALS['egw']->acl->check('asyncservice_acc',1,'admin'))
{
egw::redirect_link('/index.php');
Egw::redirect_link('/index.php');
}
$GLOBALS['egw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Asynchronous timed services');
common::egw_header();
$GLOBALS['egw']->framework->header();
echo parse_navbar();
$async = $GLOBALS['egw']->asyncservice; // use an own instance, as we might set debug=True
@ -88,12 +91,12 @@ class uiasyncservice
echo '<div style="text-align: left; margin: 10px;">'."\n";
$last_run = $async->last_check_run();
$lr_date = $last_run['end'] ? common::show_date($last_run['end']) : lang('never');
$lr_date = $last_run['end'] ? Api\DateTime::server2user($last_run['end']) : lang('never');
echo '<p><b>'.lang('Async services last executed').'</b>: '.$lr_date.' ('.$last_run['run_by'].")</p>\n<hr>\n";
if (isset($_POST['asyncservice']) && $_POST['asyncservice'] != $GLOBALS['egw_info']['server']['asyncservice'])
{
config::save_value('asyncservice', $GLOBALS['egw_info']['server']['asyncservice']=$_POST['asyncservice'], 'phpgwapi');
Api\Config::save_value('asyncservice', $GLOBALS['egw_info']['server']['asyncservice']=$_POST['asyncservice'], 'phpgwapi');
}
if (!$async->only_fallback)
{
@ -158,7 +161,7 @@ class uiasyncservice
{
$next = $async->next_run($times,True);
echo "<p>asyncservice::next_run(";print_r($times);echo")=".($next === False ? 'False':"'$next'=".common::show_date($next))."</p>\n";
echo "<p>asyncservice::next_run(";print_r($times);echo")=".($next === False ? 'False':"'$next'=".Api\DateTime::server2user($next))."</p>\n";
}
echo '<hr><p><input type="submit" name="cancel" value="'.lang('Cancel TestJob!')."\"> &nbsp;\n";
echo '<input type="submit" name="test" value="'.lang('Start TestJob!')."\">\n";
@ -171,7 +174,7 @@ class uiasyncservice
echo "<table border=1>\n<tr>\n<th>Id</th><th>".lang('Next run').'</th><th>'.lang('Times').'</th><th>'.lang('Method').'</th><th>'.lang('Data')."</th><th>".lang('LoginID')."</th></tr>\n";
foreach($jobs as $job)
{
echo "<tr>\n<td>$job[id]</td><td>".common::show_date($job['next'])."</td><td>";
echo "<tr>\n<td>$job[id]</td><td>".Api\DateTime::server2user($job['next'])."</td><td>";
print_r($job['times']);
echo "</td><td>$job[method]</td><td>";
print_r($job['data']);

View File

@ -10,6 +10,8 @@
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Egw;
/**
* Site configuration for all apps using an $app/templates/default/config.tpl
@ -27,7 +29,7 @@ class uiconfig
return $new_config->index();
}
// allowing inline js
egw_framework::csp_script_src_attrs('unsafe-inline');
Api\Header\ContentSecurityPolicy::add('script-src', 'unsafe-inline');
// for POST requests validate CSRF token (or terminate request)
if ($_SERVER['REQUEST_METHOD'] == 'POST')
@ -46,7 +48,7 @@ class uiconfig
}
if ($GLOBALS['egw']->acl->check('site_config_acce',1,'admin'))
{
egw::redirect_link('/index.php');
Egw::redirect_link('/index.php');
}
// load the translations of the app we show too, so they dont need to be in admin!
@ -75,8 +77,8 @@ class uiconfig
break;
case 'phpgwapi':
case '':
/* This keeps the admin from getting into what is a setup-only config */
egw::redirect_link('/admin/index.php');
/* This keeps the admin from getting into what is a setup-only Api\Config */
Egw::redirect_link('/admin/index.php');
break;
default:
$appname = $_appname;
@ -84,7 +86,7 @@ class uiconfig
break;
}
if (ob_get_contents()) ob_end_flush(); // if there is output in buffer, flush it now.
$t = new Template(common::get_tpl_dir($appname));
$t = new Framework\Template(Framework\Template::get_dir($appname));
$t->set_unknowns('keep');
$t->set_file(array('config' => 'config.tpl'));
$t->set_block('config','header','header');
@ -115,13 +117,13 @@ class uiconfig
$c->read_repository();
if ($_POST['cancel'] || ($_POST['submit'] || $_POST['save'] || $_POST['apply']) && $GLOBALS['egw']->acl->check('site_config_acce',2,'admin'))
{
egw::redirect_link('/admin/index.php?ajax=true');
Egw::redirect_link('/admin/index.php?ajax=true');
}
if ($_POST['submit'] || $_POST['save'] || $_POST['apply'])
{
/* Load hook file with functions to validate each config (one/none/all) */
$GLOBALS['egw']->hooks->single('config_validate',$appname);
/* Load hook file with functions to validate each Api\Config (one/none/all) */
Api\Hooks::single('config_validate',$appname);
foreach($_POST['newsettings'] as $key => $config)
{
@ -160,8 +162,8 @@ class uiconfig
if(!$errors && !$_POST['apply'])
{
egw_framework::message(lang('Configuration saved.'), 'success');
egw::redirect_link('/index.php', array(
Framework::message(lang('Configuration saved.'), 'success');
Egw::redirect_link('/index.php', array(
'menuaction' => 'admin.admin_ui.index',
'ajax' => 'true'
), 'admin');
@ -171,13 +173,13 @@ class uiconfig
$t->set_var('error','');
if($errors)
{
egw_framework::message(lang('Error') . ': ' . $errors, 'error');
Framework::message(lang('Error') . ': ' . $errors, 'error');
unset($errors);
unset($GLOBALS['config_error']);
}
elseif ($_POST['apply'])
{
egw_framework::message(lang('Configuration saved.'), 'success');
Framework::message(lang('Configuration saved.'), 'success');
}
$t->set_var('title',lang('Site Configuration'));
$t->set_var('action_url',$GLOBALS['egw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname));
@ -185,11 +187,11 @@ class uiconfig
$t->set_var('th_text', $GLOBALS['egw_info']['theme']['th_text']);
$t->set_var('row_on', $GLOBALS['egw_info']['theme']['row_on']);
$t->set_var('row_off', $GLOBALS['egw_info']['theme']['row_off']);
$t->set_var('hidden_vars', html::input_hidden('csrf_token', Api\Csrf::token(__CLASS__)));
$t->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__CLASS__)));
$vars = $t->get_undefined('body');
if ($GLOBALS['egw']->hooks->single('config',$appname)) // reload the config-values, they might have changed
if (Api\Hooks::single('config',$appname)) // reload the config-values, they might have changed
{
$c->read_repository();
}
@ -270,9 +272,9 @@ class uiconfig
}
$t->set_var('submit', '<div class="dialogFooterToolbar" style="text-align: left">'.
($GLOBALS['egw']->acl->check('site_config_acce',2,'admin') ? '' :
html::submit_button('save', 'Save')."\n".
html::submit_button('apply', 'Apply')));
$t->set_var('cancel', html::submit_button('cancel', 'Cancel').'</div>');
Api\Html::submit_button('save', 'Save')."\n".
Api\Html::submit_button('apply', 'Apply')));
$t->set_var('cancel', Api\Html::submit_button('cancel', 'Cancel').'</div>');
$GLOBALS['egw_info']['flags']['app_header'] = lang('Site configuration').
($appname != 'admin' ? ': '.lang($appname) : '');

View File

@ -8,6 +8,9 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
class uimainscreen
{
var $public_functions = array('index' => True);
@ -32,7 +35,7 @@ class uimainscreen
$GLOBALS['egw']->redirect_link('/admin/index.php');
}
egw_framework::validate_file('ckeditor','ckeditor','phpgwapi');
Framework::includeJS('ckeditor','ckeditor','phpgwapi');
$GLOBALS['egw']->template->set_file(array('message' => 'mainscreen_message.tpl'));
$GLOBALS['egw']->template->set_block('message','form','form');
@ -41,8 +44,8 @@ class uimainscreen
if ($_POST['save'])
{
translation::write($select_lang,$section,$section.'_message',$message);
egw_framework::message(lang('message has been updated'));
Api\Translation::write($select_lang,$section,$section.'_message',$message);
Framework::message(lang('message has been updated'));
$section = '';
}
@ -64,16 +67,16 @@ class uimainscreen
}
if (empty($section))
{
common::egw_header();
$GLOBALS['egw']->framework->header();
echo parse_navbar();
$GLOBALS['egw']->template->set_var('form_action',$GLOBALS['egw']->link('/index.php','menuaction=admin.uimainscreen.index'));
$GLOBALS['egw']->template->set_var('value','&nbsp;');
$GLOBALS['egw']->template->fp('rows','row_2',True);
$langs = translation::get_installed_langs();
$langs = Api\Translation::get_installed_langs();
$langs['en'] .= ' ('.lang('All languages').')';
$lang_select = html::select('select_lang', 'en', $langs);
$lang_select = Api\Html::select('select_lang', 'en', $langs);
$GLOBALS['egw']->template->set_var('label',lang('Language'));
$GLOBALS['egw']->template->set_var('value',$lang_select);
@ -92,26 +95,26 @@ class uimainscreen
$GLOBALS['egw']->template->fp('rows','row',True);
$GLOBALS['egw']->template->set_var('value',
html::submit_button('edit', lang('Edit'))."\n".html::submit_button('cancel', lang('Cancel')));
Api\Html::submit_button('edit', lang('Edit'))."\n".Api\Html::submit_button('cancel', lang('Cancel')));
$GLOBALS['egw']->template->fp('rows','row_2',True);
}
else
{
$current_message = translation::read($select_lang,$section,$section.'_message');
$current_message = Api\Translation::read($select_lang,$section,$section.'_message');
if ($_POST['no']) $current_message = strip_tags($current_message);
if (empty($_POST['no']) && ($_POST['yes'] || empty($current_message) ||
strlen($current_message) != strlen(strip_tags($current_message))))
{
$text_or_htmlarea = html::fckEditorQuick('message','advanced',$current_message,'400px','800px');
$htmlarea_button = html::submit_button("no", lang('disable WYSIWYG-editor'));
$text_or_htmlarea = Api\Html::fckEditorQuick('message','advanced',$current_message,'400px','800px');
$htmlarea_button = Api\Html::submit_button("no", lang('disable WYSIWYG-editor'));
}
else
{
$text_or_htmlarea='<textarea name="message" style="width:100%; min-width:350px; height:300px;" wrap="virtual">' .
html::htmlspecialchars($current_message) . '</textarea>';
$htmlarea_button = html::submit_button("yes", lang('activate WYSIWYG-editor'));
Api\Html::htmlspecialchars($current_message) . '</textarea>';
$htmlarea_button = Api\Html::submit_button("yes", lang('activate WYSIWYG-editor'));
}
common::egw_header();
$GLOBALS['egw']->framework->header();
echo parse_navbar();
$GLOBALS['egw']->template->set_var('form_action',$GLOBALS['egw']->link('/index.php','menuaction=admin.uimainscreen.index'));
@ -125,7 +128,7 @@ class uimainscreen
$GLOBALS['egw']->template->fp('rows','row_2',True);
$GLOBALS['egw']->template->set_var('value',
html::submit_button('save', lang('Save'))."\n".html::submit_button('cancel', lang('Cancel')).
Api\Html::submit_button('save', lang('Save'))."\n".Api\Html::submit_button('cancel', lang('Cancel')).
"\n".$htmlarea_button);
$GLOBALS['egw']->template->fp('rows','row_2',True);
}

View File

@ -8,11 +8,13 @@
* @version $Id$
*/
use EGroupware\Api;
$GLOBALS['acl_manager']['admin']['site_config_acce'] = array(
'name' => 'Deny access to site configuration',
'rights' => array(
'List config settings' => 1,
'Change config settings' => 2
'List Api\Config settings' => 1,
'Change Api\Config settings' => 2
)
); // added and working ralfbecker

View File

@ -10,6 +10,7 @@
*/
use EGroupware\Api;
use EGroupware\Api\Vfs;
/*
Set global flag to indicate for which config settings we have equally named validation methods
@ -26,7 +27,7 @@ function vfs_image_dir($vfs_image_dir)
//error_log(__FUNCTION__.'() vfs_image_dir='.array2string($vfs_image_dir).' was '.array2string($GLOBALS['egw_info']['server']['vfs_image_dir']));
if (!empty($vfs_image_dir))
{
if (!Api\Vfs::file_exists($vfs_image_dir) || !Api\Vfs::is_dir($vfs_image_dir))
if (!Vfs::file_exists($vfs_image_dir) || !Vfs::is_dir($vfs_image_dir))
{
$GLOBALS['config_error'] = lang('VFS directory "%1" NOT found!',$vfs_image_dir);
return;

View File

@ -1,35 +1,23 @@
<?php
/**************************************************************************\
* eGroupWare - administration *
* http://www.egroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/**
* EGgroupware administration
*
* @link http://www.egroupware.org
* @package admin
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
/* $Id$ */
$GLOBALS['egw_info']['flags'] = array(
'noheader' => True,
'nonavbar' => True,
'currentapp' => 'admin'
);
include('../header.inc.php');
$GLOBALS['egw_info']['flags'] = array(
'noheader' => True,
'nonavbar' => True,
'currentapp' => 'admin'
);
include('../header.inc.php');
if ($GLOBALS['egw']->acl->check('info_access',1,'admin'))
{
$GLOBALS['egw']->redirect_link('/index.php');
}
if ($GLOBALS['egw']->acl->check('info_access',1,'admin'))
{
$GLOBALS['egw']->redirect_link('/index.php');
}
// Throw a little notice out if PHPaccelerator is enabled.
if($GLOBALS['_PHPA']['ENABLED'])
{
echo 'PHPaccelerator enabled:</br>'."\n";
echo 'PHPaccelerator Version: '.$GLOBALS['_PHPA']['VERSION'].'</br></p>'."\n";
}
phpinfo();
// $GLOBALS['egw']->common->egw_footer();
?>
phpinfo();

View File

@ -43,11 +43,12 @@ $setup_info['admin']['hooks']['config'] = 'admin_hooks::config';
// add account tab to addressbook.edit
$setup_info['admin']['hooks']['addressbook_edit'] = 'admin.admin_account.addressbook_edit';
/* Dependencies for this app to work */
// Dependencies for this app to work
$setup_info['admin']['depends'][] = array(
'appname' => 'phpgwapi',
'versions' => Array('14.1')
'appname' => 'api',
'versions' => Array('16.1')
);
// still using old etemplate in: admin_cmds, admin_customtranslation admin admin_statistics
$setup_info['admin']['depends'][] = array(
'appname' => 'etemplate',
'versions' => Array('14.1')