Author: ralfbecker
New Revision: 55901
URL: http://svn.stylite.de/viewvc/egroupware?rev=55901&view=rev
Log:
using new api for admin, though 3 classes still use old etemplate
Removed:
trunk/admin/inc/class.admin_prefs_sidebox_hooks.inc.php
trunk/admin/inc/class.boconfig.inc.php
Modified:
trunk/admin/inc/class.admin_accesslog.inc.php
trunk/admin/inc/class.admin_account.inc.php
trunk/admin/inc/class.admin_acl.inc.php
trunk/admin/inc/class.admin_categories.inc.php
trunk/admin/inc/class.admin_cmd.inc.php
trunk/admin/inc/class.admin_cmd_account_app.inc.php
trunk/admin/inc/class.admin_cmd_change_account_id.inc.php
trunk/admin/inc/class.admin_cmd_change_pw.inc.php
trunk/admin/inc/class.admin_cmd_check_acl.inc.php
trunk/admin/inc/class.admin_cmd_check_cats.inc.php
trunk/admin/inc/class.admin_cmd_delete_account.inc.php
trunk/admin/inc/class.admin_cmd_edit_group.inc.php
trunk/admin/inc/class.admin_cmd_edit_user.inc.php
trunk/admin/inc/class.admin_cmds.inc.php
trunk/admin/inc/class.admin_customtranslation.inc.php
trunk/admin/inc/class.admin_db_backup.inc.php
trunk/admin/inc/class.admin_egw_group_record.inc.php
trunk/admin/inc/class.admin_egw_user_record.inc.php
trunk/admin/inc/class.admin_export_groups_csv.inc.php
trunk/admin/inc/class.admin_export_users_csv.inc.php
trunk/admin/inc/class.admin_hooks.inc.php
trunk/admin/inc/class.admin_import_groups_csv.inc.php (contents, props changed)
trunk/admin/inc/class.admin_import_users_csv.inc.php
trunk/admin/inc/class.admin_mail.inc.php
trunk/admin/inc/class.admin_statistics.inc.php
trunk/admin/inc/class.admin_ui.inc.php
trunk/admin/inc/class.admin_wizard_export_groups_csv.inc.php
trunk/admin/inc/class.admin_wizard_export_users_csv.inc.php
trunk/admin/inc/class.customfields.inc.php
trunk/admin/inc/class.uiasyncservice.inc.php
trunk/admin/inc/class.uiconfig.inc.php
trunk/admin/inc/class.uimainscreen.inc.php
trunk/admin/inc/hook_acl_manager.inc.php
trunk/admin/inc/hook_config_validate.inc.php
trunk/admin/phpinfo.php
trunk/admin/setup/setup.inc.php
ā trunk/admin/inc/class.admin_accesslog.inc.php (original)
+++ trunk/admin/inc/class.admin_accesslog.inc.php Wed Apr 27 21:12:20 2016
@@ -1,14 +1,17 @@
<?php
/**
- * EGgroupware admin - access- and session-log
+ * EGroupware admin - access- and session-log
*
* @link http://www.egroupware.org
* @author Ralf Becker
* @package admin
- * @copyright (c) 2009-14 by Ralf Becker
+ * @copyright (c) 2009-16 by Ralf Becker
* @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 @@
/**
* Our storage object
*
- * @var so_sql
+ * @var Api\Storage\Base
*/
protected $so;
@@ -47,7 +50,7 @@
*/
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 @@
*/
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 @@
}
$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 @@
}
$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 @@
'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'],
));
Modified: trunk/admin/inc/class.admin_account.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/admin/inc/class.admin_account.inc.php?rev=55901&r1=55900&r2=55901&view=diff
==============================================================================
--- trunk/admin/inc/class.admin_account.inc.php (original)
+++ trunk/admin/inc/class.admin_account.inc.php Wed Apr 27 21:12:20 2016
@@ -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 @@
*
* @param array $content
* @return array
- * @throws egw_exception_not_found
+ * @throws Api\Exception\NotFound
*/
public function addressbook_edit(array $content)
{
@@ -39,27 +44,27 @@
$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 @@
$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');
-
- $addressbook_bo = new addressbook_bo();
- if (!($content['id'] = accounts::id2name($cmd->account, 'person_id')) ||
+ Api\Json\Response::get()->call('egw.refresh', '', 'admin', $cmd->account, $content['account_id'] ? 'edit' : 'add');
+
+ $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 @@
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 @@
$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');
- }
- egw_framework::window_close();
- }
- $tpl = new etemplate_new('admin.account.delete');
+ Framework::refresh_opener($msg, 'admin', $content['account_id'], 'delete');
+ }
+ Framework::window_close();
+ }
+ $tpl = new Etemplate('admin.account.delete');
$tpl->exec('admin_account::delete', $content, array(), array(), $content, 2);
}
@@ -246,10 +251,10 @@
*/
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 @@
*/
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 @@
}
catch(Exception $e)
{
- egw_json_response::get()->data($e->getMessage());
+ Api\Json\Response::get()->data($e->getMessage());
}
}
}
Modified: trunk/admin/inc/class.admin_acl.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/admin/inc/class.admin_acl.inc.php?rev=55901&r1=55900&r2=55901&view=diff
==============================================================================
--- trunk/admin/inc/class.admin_acl.inc.php (original)
+++ trunk/admin/inc/class.admin_acl.inc.php Wed Apr 27 21:12:20 2016
@@ -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 @@
);
/**
- * Reference to global acl class (instanciated for current user)
- *
- * @var acl
+ * Reference to global Acl class (instanciated for current user)
+ *
+ * @var Acl
*/
protected $acl;
@@ -70,15 +75,15 @@
}
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 @@
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');
- }
- }
- }
-
- /**
- * Callback for nextmatch to fetch acl
+ Framework::refresh_opener(lang('ACL added.'), 'admin', $id, 'add');
+ }
+ }
+ }
+
+ /**
+ * Callback for nextmatch to fetch Acl
*
* @param array $query
* @param array &$rows=null
@@ -131,7 +136,7 @@
*/
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 @@
$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 @@
$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 @@
//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 @@
}
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 @@
$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 @@
* @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 @@
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 @@
{
$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 @@
*
* @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 @@
{
$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 @@
{
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 @@
'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),
Modified: trunk/admin/inc/class.admin_categories.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/admin/inc/class.admin_categories.inc.php?rev=55901&r1=55900&r2=55901&view=diff
==============================================================================
--- trunk/admin/inc/class.admin_categories.inc.php (original)
+++ trunk/admin/inc/class.admin_categories.inc.php Wed Apr 27 21:12:20 2016
@@ -1,14 +1,20 @@
<?php
/**
- * EGgroupware admin - Edit global categories
+ * EGroupware admin - Edit global categories
*
* @link http://www.egroupware.org
* @author Ralf Becker
* @package admin
- * @copyright (c) 2010-14 by Ralf Becker
+ * @copyright (c) 2010-16 by Ralf Becker
* @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 @@
{
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 @@
{
// 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 @@
}
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 @@
}
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 @@
$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 @@
// 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 @@
}
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 @@
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 @@
$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 @@
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 @@
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 @@
{
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 @@
{
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 @@
$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 @@
*
* @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 @@
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 @@
// 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 @@
{
$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 @@
}
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 @@
$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 @@
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 @@
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 @@
{
$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 @@
{
$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 @@
$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 @@
}
$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 @@
$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 @@
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 @@
$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])
{
Modified: trunk/admin/inc/class.admin_cmd.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/admin/inc/class.admin_cmd.inc.php?rev=55901&r1=55900&r2=55901&view=diff
==============================================================================
--- trunk/admin/inc/class.admin_cmd.inc.php (original)
+++ trunk/admin/inc/class.admin_cmd.inc.php Wed Apr 27 21:12:20 2016
@@ -1,14 +1,17 @@
<?php
/**
- * eGgroupWare admin - admin command base class
+ * EGroupware admin - admin command base class
*
* @link http://www.egroupware.org
* @author Ralf Becker
* @package admin
- * @copyright (c) 2007-13 by Ralf Becker
+ * @copyright (c) 2007-16 by Ralf Becker
* @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 @@
private $data = array();
/**
- * Instance of the accounts class, after calling instanciate_accounts!
- *
- * @var accounts
+ * Instance of the Api\Accounts class, after calling instanciate_accounts!
+ *
+ * @var Api\Accounts
*/
static protected $accounts;
/**
- * Instance of the acl class, after calling instanciate_acl!
- *
- * @var acl
+ * Instance of the Acl class, after calling instanciate_acl!
+ *
+ * @var Acl
*/
static protected $acl;
/**
- * Instance of so_sql for egw_admin_queue
- *
- * @var so_sql
+ * Instance of Api\Storage\Base for egw_admin_queue
+ *
+ * @var Api\Storage\Base
*/
static private $sql;
/**
- * Instance of so_sql for egw_admin_remote
- *
- * @var so_sql
+ * Instance of Api\Storage\Base for egw_admin_remote
+ *
+ * @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 @@
*
* 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 @@
}
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 @@
* 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 @@
$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 @@
);
$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 @@
}
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 @@
/**
* 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 @@
* 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 @@
* @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 @@
}
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 @@
{
return $cmd;
}
- throw new egw_exception_wrong_parameter(lang('%1 is no command!',$class),0);
- }
-
- /**
- * calling get_rows of our static so_sql instance
+ throw new Api\Exception\WrongParameter(lang('%1 is no command!',$class),0);
+ }
+
+ /**
+ * calling get_rows of our static Api\Storage\Base instance
*
* @static
* @param array $query
@@ -397,19 +402,19 @@
}
/**
- * 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'