From 6a55295b77a9d7083e1f8382e08a4b0597d47a01 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 17 Mar 2014 15:28:20 +0000 Subject: [PATCH] first version of new account editing via accounts tab in addressbook (not yet saving!) --- addressbook/inc/class.addressbook_ui.inc.php | 39 +++++++++++- admin/inc/class.admin_account.inc.php | 65 +++++++++++++++++++ admin/setup/setup.inc.php | 7 ++- admin/templates/default/account.xet | 66 ++++++++++++++++++++ 4 files changed, 173 insertions(+), 4 deletions(-) create mode 100644 admin/inc/class.admin_account.inc.php create mode 100644 admin/templates/default/account.xet diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index a103de576c..e0e3e59a8b 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -5,7 +5,7 @@ * @link www.egroupware.org * @author Cornelius Weiss * @author Ralf Becker - * @copyright (c) 2005-13 by Ralf Becker + * @copyright (c) 2005-14 by Ralf Becker * @copyright (c) 2005/6 by Cornelius Weiss * @package addressbook * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License @@ -1776,6 +1776,7 @@ window.egw_LAB.wait(function() { { $view = true; } + $content['jpegphoto'] = !empty($content['jpegphoto']); // unused and messes up json encoding (not utf-8) } else // not found { @@ -1997,7 +1998,41 @@ window.egw_LAB.wait(function() { $content['msg'] .= lang('Please update the templatename in your customfields section!'); $this->tmpl->read('addressbook.edit'); } - return $this->tmpl->exec('addressbook.addressbook_ui.edit',$content,$sel_options,$readonlys,$content, 2); + + // allow other apps to add tabs to addressbook edit + $preserve = $content; + $this->tmpl->setElementAttribute('tabs', 'add_tabs', true); + $tabs =& $this->tmpl->getElementAttribute('tabs', 'tabs'); + if (true) $tabs = array(); + $hook_data = $GLOBALS['egw']->hooks->process(array('location' => 'addressbook_edit')+$content); + //error_log(__METHOD__."() hook_data=".array2string($hook_data)); + foreach($hook_data as $extra_tabs) + { + if (!$extra_tabs) continue; + + foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) + { + $tabs[] = array( + 'label' => $extra_tab['label'], + 'template' => $extra_tab['name'], + 'prepend' => $extra_tab['prepend'], + ); + //error_log(__METHOD__."() changed tabs=".array2string($tabs)); + if ($extra_tab['data'] && is_array($extra_tab['data'])) + { + $content = array_merge($content, $extra_tab['data']); + } + if ($extra_tab['preserve'] && is_array($extra_tab['preserve'])) + { + $preserve = array_merge($preserve, $extra_tab['preserve']); + } + if ($extra_tab['readonlys'] && is_array($extra_tab['readonlys'])) + { + $readonlys = array_merge($readonlys, $extra_tab['readonlys']); + } + } + } + return $this->tmpl->exec('addressbook.addressbook_ui.edit', $content, $sel_options, $readonlys, $preserve, 2); } /** diff --git a/admin/inc/class.admin_account.inc.php b/admin/inc/class.admin_account.inc.php new file mode 100644 index 0000000000..30d21eaf9a --- /dev/null +++ b/admin/inc/class.admin_account.inc.php @@ -0,0 +1,65 @@ + + * @package admin + * @copyright (c) 2014 by Ralf Becker + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License + * @version $Id$ + */ + +/** + * UI for admin: edit/add account + */ +class admin_account +{ + public function addressbook_edit(array $content) + { + if ((string)$content['owner'] === '0') + { + // load our translations + translation::add_app('admin'); + + if ($content['id']) // existing account + { + if (!($account = $GLOBALS['egw']->accounts->read($content['account_id']))) + { + throw new egw_exception_not_found('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->read_repository(); + $account['anonymous'] = $acl->check('anonymous', 1, 'phpgwapi'); + $account['changepassword'] = !$acl->check('nopasswordchange', 1, 'preferences'); + $auth = new auth(); + if (($account['account_lastpwd_change'] = $auth->getLastPwdChange($account['account_lid'])) === false) + { + $account['account_lastpwd_change'] = null; + } + $account['mustchangepassword'] = isset($account['account_lastpwd_change']) && + (string)$account['account_lastpwd_change'] === '0'; + } + else // new account + { + $account = array( + 'account_status' => 'A', + 'memberships' => array(), + 'anonymous' => false, + 'changepassword' => (bool)$GLOBALS['egw_info']['server']['change_pwd_every_x_days'], + 'mustchangepassword' => false, + ); + } + return array( + 'name' => 'admin.account?'.filemtime(EGW_SERVER_ROOT.'/admin/templates/default/account.xet'), + 'prepend' => true, + 'label' => 'Account', + 'data' => $account, + 'callback' => 'admin_account::addressbook_save', + ); + } + } +} diff --git a/admin/setup/setup.inc.php b/admin/setup/setup.inc.php index ca1506b120..a103542e95 100755 --- a/admin/setup/setup.inc.php +++ b/admin/setup/setup.inc.php @@ -42,8 +42,11 @@ $setup_info['admin']['hooks'] = array( 'group_manager' => 'admin.uiaccounts.edit_group_hook', 'topmenu_info' ); -$setup_info['admin']['hooks']['admin'] =$setup_info['admin']['name'].'.admin_prefs_sidebox_hooks.all_hooks'; -$setup_info['admin']['hooks']['sidebox_menu'] =$setup_info['admin']['name'].'.admin_prefs_sidebox_hooks.all_hooks'; +$setup_info['admin']['hooks']['admin'] = 'admin.admin_prefs_sidebox_hooks.all_hooks'; +$setup_info['admin']['hooks']['sidebox_menu'] = 'admin.admin_prefs_sidebox_hooks.all_hooks'; + +// add account tab to addressbook.edit +$setup_info['admin']['hooks']['addressbook_edit'] = 'admin.admin_account.addressbook_edit'; /* Dependencies for this app to work */ $setup_info['admin']['depends'][] = array( diff --git a/admin/templates/default/account.xet b/admin/templates/default/account.xet new file mode 100644 index 0000000000..29c0ee592e --- /dev/null +++ b/admin/templates/default/account.xet @@ -0,0 +1,66 @@ + + + + + + \ No newline at end of file