2006-04-23 16:40:31 +02:00
< ? php
2006-06-13 23:53:00 +02:00
/**
2016-04-29 12:41:53 +02:00
* EGroupware Addressbook - admin , preferences and sidebox - menus and other hooks
2006-06-13 23:53:00 +02:00
*
* @ link http :// www . egroupware . org
* @ package addressbook
* @ author Ralf Becker < RalfBecker @ outdoor - training . de >
2016-04-06 11:49:50 +02:00
* @ copyright ( c ) 2006 - 16 by Ralf Becker < RalfBecker @ outdoor - training . de >
2006-06-13 23:53:00 +02:00
* @ license http :// opensource . org / licenses / gpl - license . php GPL - GNU General Public License
2008-04-25 20:59:00 +02:00
* @ version $Id $
2006-06-13 23:53:00 +02:00
*/
2006-04-23 16:40:31 +02:00
2016-04-25 17:57:38 +02:00
use EGroupware\Api ;
2016-04-29 12:41:53 +02:00
use EGroupware\Api\Link ;
use EGroupware\Api\Framework ;
use EGroupware\Api\Egw ;
use EGroupware\Api\Acl ;
2016-04-25 17:57:38 +02:00
2006-04-23 16:40:31 +02:00
/**
2008-04-25 20:59:00 +02:00
* Class containing admin , preferences and sidebox - menus and other hooks
2006-04-23 16:40:31 +02:00
*/
2008-04-25 20:59:00 +02:00
class addressbook_hooks
2006-04-23 16:40:31 +02:00
{
/**
* hooks to build projectmanager ' s sidebox - menu plus the admin and preferences sections
*
* @ param string / array $args hook args
*/
2008-04-25 20:59:00 +02:00
static function all_hooks ( $args )
2006-04-23 16:40:31 +02:00
{
$appname = 'addressbook' ;
$location = is_array ( $args ) ? $args [ 'location' ] : $args ;
//echo "<p>contacts_admin_prefs::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n";
if ( $location == 'sidebox_menu' )
{
2014-03-06 19:39:52 +01:00
if ( $_GET [ 'menuaction' ] == 'addressbook.addressbook_ui.view' )
{
display_sidebox ( $appname , lang ( 'Contact data' ), array (
array (
'text' => '<div id="addressbook_view_sidebox"/>' ,
'no_lang' => true ,
'link' => false ,
'icon' => false ,
),
'menuOpened' => true , // display it open by default
));
}
2013-03-06 01:04:08 +01:00
// Magic etemplate2 favorites menu (from nextmatch widget)
2016-04-29 12:41:53 +02:00
display_sidebox ( $appname , lang ( 'Favorites' ), Framework\Favorites :: list_favorites ( 'addressbook' ));
2014-02-12 22:51:25 +01:00
2006-04-23 16:40:31 +02:00
$file = array (
2016-04-29 12:41:53 +02:00
'Addressbook list' => Egw :: link ( '/index.php' , array (
2015-09-10 00:20:25 +02:00
'menuaction' => 'addressbook.addressbook_ui.index' ,
'ajax' => 'true' )),
array (
2016-04-29 12:41:53 +02:00
'text' => lang ( 'Add %1' , lang ( Link :: get_registry ( $appname , 'entry' ))),
2015-09-10 00:20:25 +02:00
'no_lang' => true ,
'link' => " javascript:egw.open('',' $appname ','add') "
),
2010-06-02 19:11:48 +02:00
'Advanced search' => " javascript:egw_openWindowCentered2(' " .
2016-04-29 12:41:53 +02:00
Egw :: link ( '/index.php' , array ( 'menuaction' => 'addressbook.addressbook_ui.search' ), false ) .
2016-05-06 17:12:27 +02:00
" ','_blank',870,610,'yes') " ,
2016-04-29 12:41:53 +02:00
'Placeholders' => Egw :: link ( '/index.php' , 'menuaction=api.EGroupware\\Api\\Contacts\\Merge.show_replacements' )
2006-04-23 16:40:31 +02:00
);
display_sidebox ( $appname , lang ( 'Addressbook menu' ), $file );
}
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'admin' ] && $location != 'preferences' )
{
$file = Array (
2016-04-29 12:41:53 +02:00
'Site configuration' => Egw :: link ( '/index.php' , array (
2006-04-23 16:40:31 +02:00
'menuaction' => 'admin.uiconfig.index' ,
'appname' => $appname ,
2016-06-29 19:10:22 +02:00
'ajax' => 'true' ,
2006-04-23 16:40:31 +02:00
)),
2016-04-29 12:41:53 +02:00
'Global Categories' => Egw :: link ( '/index.php' , array (
2011-06-21 23:14:51 +02:00
'menuaction' => 'admin.admin_categories.index' ,
2006-04-23 16:40:31 +02:00
'appname' => $appname ,
2006-06-17 20:50:07 +02:00
'global_cats' => True ,
2016-06-29 19:10:22 +02:00
'ajax' => 'true' ,
2006-04-23 16:40:31 +02:00
)),
);
2006-06-17 20:50:07 +02:00
// custom fields are not availible in LDAP
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'contact_repository' ] != 'ldap' )
{
2016-04-29 12:41:53 +02:00
$file [ 'Custom fields' ] = Egw :: link ( '/index.php' , array (
2016-08-12 11:35:30 +02:00
'menuaction' => 'admin.admin_customfields.index' ,
2006-06-17 20:50:07 +02:00
'appname' => $appname ,
2008-01-19 06:41:04 +01:00
'use_private' => 1 ,
2014-10-22 21:55:27 +02:00
'ajax' => 'true'
2006-06-17 20:50:07 +02:00
));
}
2006-04-23 16:40:31 +02:00
if ( $location == 'admin' )
{
display_section ( $appname , $file );
}
else
{
display_sidebox ( $appname , lang ( 'Admin' ), $file );
}
}
}
2008-04-25 20:59:00 +02:00
2006-04-23 16:40:31 +02:00
/**
2016-04-29 12:41:53 +02:00
* populates $settings for the Api\Preferences
2009-08-26 19:09:44 +02:00
*
2009-10-18 14:58:38 +02:00
* @ param array | string $hook_data
2009-08-26 19:09:44 +02:00
* @ return array
2006-04-23 16:40:31 +02:00
*/
2009-10-18 14:58:38 +02:00
static function settings ( $hook_data )
2006-04-23 16:40:31 +02:00
{
2013-01-21 21:37:59 +01:00
$settings = array (
array (
'type' => 'section' ,
'title' => lang ( 'General settings' ),
'no_lang' => true ,
'xmlrpc' => False ,
'admin' => False
),
);
2009-04-29 08:26:04 +02:00
$settings [ 'add_default' ] = array (
2006-10-07 11:17:30 +02:00
'type' => 'select' ,
'label' => 'Default addressbook for adding contacts' ,
'name' => 'add_default' ,
'help' => 'Which addressbook should be selected when adding a contact AND you have no add rights to the current addressbook.' ,
2016-04-29 12:41:53 +02:00
'values' => ! $hook_data [ 'setup' ] ? ExecMethod ( 'addressbook.addressbook_ui.get_addressbooks' , Acl :: ADD ) : array (),
2006-10-07 11:17:30 +02:00
'xmlrpc' => True ,
'admin' => False ,
);
2008-04-25 20:59:00 +02:00
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'contact_repository' ] != 'ldap' )
2006-04-23 16:40:31 +02:00
{
2009-04-29 08:26:04 +02:00
$settings [ 'private_addressbook' ] = array (
2006-04-23 16:40:31 +02:00
'type' => 'check' ,
'label' => 'Enable an extra private addressbook' ,
'name' => 'private_addressbook' ,
'help' => 'Do you want a private addressbook, which can not be viewed by users, you grant access to your personal addressbook?' ,
'xmlrpc' => True ,
'admin' => False ,
2009-10-19 19:04:11 +02:00
'forced' => false ,
2006-04-23 16:40:31 +02:00
);
}
2013-01-21 21:37:59 +01:00
$settings [ 'hide_accounts' ] = array (
2017-11-15 19:29:10 +01:00
'type' => 'select' ,
2017-11-21 19:07:50 +01:00
'values' => array ( '1' => lang ( 'Hide all accounts' ), '0' => lang ( 'Show active accounts' ), 'none' => lang ( 'Show all accounts' )),
2013-01-21 21:37:59 +01:00
'label' => 'Hide accounts from addressbook' ,
'name' => 'hide_accounts' ,
'help' => 'Hides accounts completly from the adressbook.' ,
'xmlrpc' => True ,
'admin' => false ,
2017-11-29 17:11:46 +01:00
'default' => '0'
2013-01-21 21:37:59 +01:00
);
2018-04-17 17:35:08 +02:00
$settings [ 'hide_groups_as_lists' ] = array (
'type' => 'check' ,
'label' => 'Hide user groups as distribution lists' ,
'name' => 'hide_groups_as_lists' ,
'help' => 'User groups are automatically shown as distribution lists.' ,
'xmlrpc' => False ,
'admin' => false ,
'default' => '0'
);
2016-05-06 18:16:10 +02:00
$contacts = new Api\Contacts ();
$fileas_options = $contacts -> fileas_options ();
2017-03-13 19:11:37 +01:00
foreach ( Api\Contacts\Storage :: $duplicate_fields as $key => $label )
{
$duplicate_options [ $key ] = lang ( $label );
}
2009-04-29 08:26:04 +02:00
$settings [ 'link_title' ] = array (
2006-10-19 10:50:25 +02:00
'type' => 'select' ,
'label' => 'Link title for contacts show' ,
'name' => 'link_title' ,
'values' => array (
'n_fileas' => lang ( 'own sorting' ) . ' (' . lang ( 'default' ) . ': ' . lang ( 'Company' ) . ': ' . lang ( 'lastname' ) . ', ' . lang ( 'firstname' ) . ')' ,
2010-11-10 10:35:10 +01:00
) + $fileas_options , // plus all fileas types
2006-10-19 10:50:25 +02:00
'help' => 'What should links to the addressbook display in other applications. Empty values will be left out. You need to log in anew, if you change this setting!' ,
'xmlrpc' => True ,
'admin' => false ,
2009-10-19 19:04:11 +02:00
'default' => 'org_name: n_family, n_given' ,
2006-10-19 10:50:25 +02:00
);
2016-05-06 18:16:10 +02:00
if (( $cf_opts = Api\Contacts :: cf_options ()))
{
$settings [ 'link_title_cf' ] = array (
2018-08-08 17:18:23 +02:00
'type' => 'multiselect' ,
2016-05-06 18:16:10 +02:00
'label' => 'Add a customfield to link title' ,
'name' => 'link_title_cf' ,
'values' => $cf_opts ,
'help' => 'Add customfield to links of addressbook, which displays in other applications. The default value is none customfield.' ,
'xmlrpc' => True ,
'admin' => false ,
);
}
2009-04-29 08:26:04 +02:00
$settings [ 'addr_format' ] = array (
2007-05-03 10:17:31 +02:00
'type' => 'select' ,
'label' => 'Default address format' ,
'name' => 'addr_format' ,
'values' => array (
'postcode_city' => lang ( 'zip code' ) . ' ' . lang ( 'City' ),
'city_state_postcode' => lang ( 'City' ) . ' ' . lang ( 'State' ) . ' ' . lang ( 'zip code' ),
2008-04-25 20:59:00 +02:00
),
2007-05-03 10:17:31 +02:00
'help' => 'Which address format should the addressbook use for countries it does not know the address format. If the address format of a country is known, it uses it independent of this setting.' ,
'xmlrpc' => True ,
'admin' => false ,
2009-10-19 19:04:11 +02:00
'default' => 'postcode_city' ,
2007-05-03 10:17:31 +02:00
);
2009-04-29 08:26:04 +02:00
$settings [ 'fileas_default' ] = array (
2008-10-10 13:25:35 +02:00
'type' => 'select' ,
'label' => 'Default file as format' ,
'name' => 'fileas_default' ,
2010-11-10 10:35:10 +01:00
'values' => $fileas_options ,
2008-10-10 13:25:35 +02:00
'help' => 'Default format for fileas, eg. for new entries.' ,
'xmlrpc' => True ,
'admin' => false ,
2009-10-19 19:04:11 +02:00
'default' => 'org_name: n_family, n_given' ,
2008-10-10 13:25:35 +02:00
);
2017-03-13 19:11:37 +01:00
$settings [ 'duplicate_fields' ] = array (
'type' => 'multiselect' ,
'label' => 'Fields to check for duplicates' ,
'name' => 'duplicate_fields' ,
'values' => $duplicate_options ,
'help' => 'Fields to consider when looking for duplicate contacts.' ,
'admin' => false ,
2018-01-24 17:10:45 +01:00
'default' => 'n_family,org_name,contact_email'
2017-03-13 19:11:37 +01:00
);
$settings [ 'duplicate_threshold' ] = array (
'type' => 'input' ,
'size' => 5 ,
'label' => 'Duplicate threshold' ,
'name' => 'duplicate_threshold' ,
'help' => 'How many fields must match for the record to be considered a duplicate.' ,
'xmlrpc' => True ,
'default' => 3 ,
'admin' => False
);
2014-03-12 23:42:06 +01:00
$crm_list_options = array (
2014-04-07 17:13:03 +02:00
'~edit~' => lang ( 'Edit contact' ),
'infolog' => lang ( 'Open %1 CRM view' , lang ( 'infolog' )),
2019-10-22 18:57:00 +02:00
'infolog-organisation' => lang ( 'infolog-organisation' ),
2014-03-12 23:42:06 +01:00
);
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'tracker' ])
{
2014-04-07 17:13:03 +02:00
$crm_list_options [ 'tracker' ] = lang ( 'Open %1 CRM view' , lang ( 'tracker' ));
2014-03-12 23:42:06 +01:00
}
$settings [ 'crm_list' ] = array (
'type' => 'select' ,
2014-04-07 18:23:23 +02:00
'label' => 'Default action on double-click' ,
2014-03-12 23:42:06 +01:00
'name' => 'crm_list' ,
'values' => $crm_list_options ,
'help' => 'When viewing a contact, show linked entries from the selected application' ,
'xmlrpc' => True ,
'admin' => false ,
'default' => 'infolog' ,
);
2016-05-25 12:50:18 +02:00
$settings [ 'geolocation_src' ] = array (
'type' => 'select' ,
2016-05-25 16:44:23 +02:00
'label' => 'Default GeoLocation source address' ,
2016-05-25 12:50:18 +02:00
'name' => 'geolocation_src' ,
'values' => array (
'browser' => lang ( 'Browser location' ),
'one' => lang ( 'Business address' ),
'two' => lang ( 'Private address' )
),
2016-05-25 16:44:23 +02:00
'help' => 'Select a source address to be used in GeoLocation routing system' ,
2016-05-25 12:50:18 +02:00
'xmlrpc' => True ,
'admin' => false ,
'default' => 'browser' ,
);
2013-01-21 21:37:59 +01:00
$settings [] = array (
'type' => 'section' ,
'title' => lang ( 'Data exchange settings' ),
'no_lang' => true ,
'xmlrpc' => False ,
'admin' => False
2007-11-06 16:45:40 +01:00
);
2013-01-21 21:37:59 +01:00
// CSV Export
2007-06-17 15:55:43 +02:00
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'filemanager' ])
{
2009-04-29 08:26:04 +02:00
$settings [ 'default_document' ] = array (
2012-05-22 15:51:30 +02:00
'type' => 'vfs_file' ,
2007-06-17 15:55:43 +02:00
'size' => 60 ,
'label' => 'Default document to insert contacts' ,
'name' => 'default_document' ,
2011-07-04 20:12:12 +02:00
'help' => lang ( 'If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.' , lang ( 'addressbook' )) . ' ' .
2014-06-24 11:47:08 +02:00
lang ( 'The document can contain placeholder like {{%1}}, to be replaced with the data.' , 'n_fn' ) . ' ' .
2016-04-29 12:41:53 +02:00
lang ( 'The following document-types are supported:' ) . implode ( ',' , Api\Storage\Merge :: get_file_extensions ()),
2007-10-19 11:47:06 +02:00
'run_lang' => false ,
2007-06-17 15:55:43 +02:00
'xmlrpc' => True ,
'admin' => False ,
);
2009-04-29 08:26:04 +02:00
$settings [ 'document_dir' ] = array (
2012-05-22 15:51:30 +02:00
'type' => 'vfs_dirs' ,
2007-06-17 15:55:43 +02:00
'size' => 60 ,
'label' => 'Directory with documents to insert contacts' ,
'name' => 'document_dir' ,
2011-07-04 20:12:12 +02:00
'help' => lang ( 'If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the data inserted.' , lang ( 'addressbook' )) . ' ' .
2014-06-24 11:47:08 +02:00
lang ( 'The document can contain placeholder like {{%1}}, to be replaced with the data.' , 'n_fn' ) . ' ' .
2016-04-29 12:41:53 +02:00
lang ( 'The following document-types are supported:' ) . implode ( ',' , Api\Storage\Merge :: get_file_extensions ()),
2007-10-19 11:47:06 +02:00
'run_lang' => false ,
2007-06-17 15:55:43 +02:00
'xmlrpc' => True ,
'admin' => False ,
2011-06-11 13:57:51 +02:00
'default' => '/templates/addressbook' ,
2008-04-25 20:59:00 +02:00
);
2007-06-17 15:55:43 +02:00
}
2011-02-28 19:10:43 +01:00
2013-10-05 12:13:31 +02:00
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'felamimail' ] || $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'mail' ])
2013-01-21 21:37:59 +01:00
{
$settings [ 'force_mailto' ] = array (
'type' => 'check' ,
'label' => 'Open EMail addresses in external mail program' ,
'name' => 'force_mailto' ,
'help' => 'Default is to open EMail addresses in EGroupware EMail application, if user has access to it.' ,
'xmlrpc' => True ,
'admin' => False ,
'default' => false ,
);
}
2011-02-28 19:10:43 +01:00
// Import / Export for nextmatch
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'importexport' ])
{
2013-01-21 21:37:59 +01:00
$settings [ 'vcard_charset' ] = array (
'type' => 'select' ,
'label' => 'Charset for the vCard import and export' ,
'name' => 'vcard_charset' ,
2016-04-29 12:41:53 +02:00
'values' => Api\Translation :: get_installed_charsets (),
2013-01-21 21:37:59 +01:00
'help' => 'Which charset should be used for the vCard import and export.' ,
'xmlrpc' => True ,
'admin' => false ,
2016-04-29 09:51:13 +02:00
'default' => 'utf-8' ,
2012-01-13 06:22:18 +01:00
);
}
2009-04-29 08:26:04 +02:00
return $settings ;
2006-04-23 16:40:31 +02:00
}
2008-04-25 20:59:00 +02:00
/**
* Hook called by link - class to include calendar in the appregistry of the linkage
*
* @ param array / string $location location and other parameters ( not used )
* @ return array with method - names
*/
static function search_link ( $location )
{
2016-04-06 11:49:50 +02:00
unset ( $location ); // not used, but required by function signature
2014-04-08 19:23:38 +02:00
$links = array (
2016-04-06 11:49:50 +02:00
'query' => 'api.EGroupware\\Api\\Contacts.link_query' ,
'title' => 'api.EGroupware\\Api\\Contacts.link_title' ,
'titles' => 'api.EGroupware\\Api\\Contacts.link_titles' ,
2008-04-25 20:59:00 +02:00
'view' => array (
2013-11-27 01:12:11 +01:00
'menuaction' => 'addressbook.addressbook_ui.view' ,
'ajax' => 'true'
2008-04-25 20:59:00 +02:00
),
'view_id' => 'contact_id' ,
2013-11-27 01:12:11 +01:00
'list' => array (
'menuaction' => 'addressbook.addressbook_ui.index' ,
'ajax' => 'true'
),
2011-06-02 18:57:33 +02:00
'edit' => array (
'menuaction' => 'addressbook.addressbook_ui.edit'
),
'edit_id' => 'contact_id' ,
2016-05-06 17:12:27 +02:00
'edit_popup' => '870x610' ,
2008-04-25 20:59:00 +02:00
'add' => array (
2008-05-10 14:02:49 +02:00
'menuaction' => 'addressbook.addressbook_ui.edit'
2008-04-25 20:59:00 +02:00
),
'add_app' => 'link_app' ,
'add_id' => 'link_id' ,
2016-05-06 17:12:27 +02:00
'add_popup' => '870x610' ,
2011-06-26 15:55:25 +02:00
'file_access_user' => true , // file_access supports 4th parameter $user
2016-04-06 11:49:50 +02:00
'file_access' => 'api.EGroupware\\Api\\Contacts.file_access' ,
2010-02-10 15:27:14 +01:00
'default_types' => array ( 'n' => array ( 'name' => 'contact' , 'options' => array ( 'icon' => 'navbar.png' , 'template' => 'addressbook.edit' ))),
2010-09-22 11:36:26 +02:00
// registers an addtional type 'addressbook-email', returning only contacts with email, title has email appended
'additional' => array (
'addressbook-email' => array (
2016-04-06 11:49:50 +02:00
'query' => 'api.EGroupware\\Api\\Contacts.link_query_email' ,
2012-11-27 16:48:13 +01:00
'view' => array (
2013-11-27 01:12:11 +01:00
'menuaction' => 'addressbook.addressbook_ui.view' ,
'ajax' => 'true'
2012-11-27 16:48:13 +01:00
),
'view_id' => 'contact_id' ,
2010-09-22 11:36:26 +02:00
),
2012-07-04 19:00:03 +02:00
),
'merge' => true ,
2014-10-21 15:51:37 +02:00
'entry' => 'Contact' ,
'entries' => 'Contacts' ,
2019-05-17 18:36:04 +02:00
'modification_time' => array (
'key' => 'contact_id' ,
'column' => 'egw_addressbook.contact_modified' ,
'type' => 'int'
2019-07-30 19:47:58 +02:00
),
'owner' => array (
'key' => 'egw_addressbook.contact_id' ,
'column' => 'egw_addressbook.contact_owner'
2019-05-17 18:36:04 +02:00
)
2008-04-25 20:59:00 +02:00
);
2014-04-08 19:23:38 +02:00
return $links ;
2008-04-25 20:59:00 +02:00
}
2011-09-15 16:46:56 +02:00
/**
* Hook called to retrieve a app specific exportLimit
*
* @ param array / string $location location and other parameters ( not used )
* @ return the export_limit to be applied for the app , may be empty , int or string
*/
static function getAppExportLimit ( $location )
{
2016-04-06 11:49:50 +02:00
unset ( $location ); // not used, but required by function signature
2011-09-16 15:03:46 +02:00
return $GLOBALS [ 'egw_info' ][ 'server' ][ 'contact_export_limit' ];
2011-09-15 16:46:56 +02:00
}
2008-04-25 20:59:00 +02:00
/**
* Register contacts as calendar resources ( items which can be sheduled by the calendar )
*
* @ param array $args hook - params ( not used )
* @ return array
*/
static function calendar_resources ( $args )
{
2016-04-06 11:49:50 +02:00
unset ( $args ); // not used, but required by function signature
2008-04-25 20:59:00 +02:00
return array (
'type' => 'c' , // one char type-identifiy for this resources
2016-04-06 11:49:50 +02:00
'info' => 'api.EGroupware\\Api\\Contacts.calendar_info' , // info method, returns array with id, type & name for a given id
2008-04-25 20:59:00 +02:00
);
}
2008-06-27 12:04:05 +02:00
/**
* Register addressbook for group - acl
*
* @ param array $args hook - params ( not used )
* @ return boolean | string true = standard group acl link , of string with link
*/
static function group_acl ( $args )
{
2016-04-06 11:49:50 +02:00
unset ( $args ); // not used, but required by function signature
2008-06-30 18:46:01 +02:00
// addressbook uses group-acl, only if contacts-backend is NOT LDAP, as the ACL can not be modified there
return $GLOBALS [ 'egw_info' ][ 'server' ][ 'contact_repository' ] != 'ldap' ;
2008-06-27 12:04:05 +02:00
}
2010-04-20 08:58:28 +02:00
/**
* For which groups should no group acl be used : addressbook always
*
* @ param string | array $data
* @ return boolean | array true , false or array with group - account_id ' s
*/
static function not_enum_group_acls ( $data )
{
2016-04-06 11:49:50 +02:00
unset ( $data ); // not used, but required by function signature
2010-04-20 08:58:28 +02:00
return true ;
}
2013-08-26 20:25:43 +02:00
/**
* ACL rights and labels used
*
2016-04-29 12:41:53 +02:00
* @ param string | array string with location or array with parameters incl . " location " , specially " owner " for selected Acl owner
* @ return array Acl :: ( READ | ADD | EDIT | DELETE | PRIVAT | CUSTOM ( 1 | 2 | 3 )) => $label pairs
2013-08-26 20:25:43 +02:00
*/
public static function acl_rights ( $params )
{
2016-04-06 11:49:50 +02:00
unset ( $params ); // not used, but required by function signature
2013-08-26 20:25:43 +02:00
return array (
2016-04-29 12:41:53 +02:00
Acl :: READ => 'read' ,
Acl :: EDIT => 'edit' ,
Acl :: ADD => 'add' ,
Acl :: DELETE => 'delete' ,
2013-08-26 20:25:43 +02:00
);
}
2013-10-03 11:23:18 +02:00
/**
* Hook to tell framework we use standard categories method
*
* @ param string | array $data hook - data or location
* @ return boolean
*/
public static function categories ( $data )
{
2016-04-06 11:49:50 +02:00
unset ( $data ); // not used, but required by function signature
2013-10-03 11:23:18 +02:00
return true ;
}
2014-02-28 11:13:26 +01:00
/**
2016-04-25 17:57:38 +02:00
* Called before displaying site configuration
2014-02-28 11:13:26 +01:00
*
* @ param array $config
2016-04-25 17:57:38 +02:00
* @ return array with additional config to merge and " sel_options " values
2014-02-28 11:13:26 +01:00
*/
2016-04-25 17:57:38 +02:00
public static function config ( array $config )
2014-02-28 11:13:26 +01:00
{
2016-04-25 17:57:38 +02:00
$bocontacts = new Api\Contacts ();
// get the list of account fields
$own_account_acl = array ();
foreach ( $bocontacts -> contact_fields as $field => $label )
{
// some fields the user should never be allowed to edit or are covert by an other attribute (n_fn for all n_*)
if ( ! in_array ( $field , array ( 'id' , 'tid' , 'owner' , 'created' , 'creator' , 'modified' , 'modifier' , 'private' , 'n_prefix' , 'n_given' , 'n_middle' , 'n_family' , 'n_suffix' )))
{
$own_account_acl [ $field ] = $label ;
}
}
$own_account_acl [ 'link_to' ] = 'Links' ;
if ( $config [ 'account_repository' ] != 'ldap' ) // no custom-fields in ldap
{
foreach ( Api\Storage\Customfields :: get ( 'addressbook' ) as $name => $data )
{
$own_account_acl [ '#' . $name ] = $data [ 'label' ];
}
}
$org_fields = $own_account_acl ;
unset ( $org_fields [ 'n_fn' ], $org_fields [ 'account_id' ]);
// Remove country codes as an option, it will be added by BO constructor
unset ( $org_fields [ 'adr_one_countrycode' ], $org_fields [ 'adr_two_countrycode' ]);
2014-02-28 11:13:26 +01:00
2016-04-25 17:57:38 +02:00
$supported_fields = $bocontacts -> get_fields ( 'supported' , null , 0 ); // fields supported by the backend (ldap schemas!)
// get the list of account fields
$copy_fields = array ();
foreach ( $bocontacts -> contact_fields as $field => $label )
{
// some fields the user should never be allowed to copy or are coverted by an other attribute (n_fn for all n_*)
if ( ! in_array ( $field , array ( 'id' , 'tid' , 'created' , 'creator' , 'modified' , 'modifier' , 'account_id' , 'uid' , 'etag' , 'n_fn' )))
{
$copy_fields [ $field ] = $label ;
}
}
if ( $config [ 'contact_repository' ] != 'ldap' ) // no custom-fields in ldap
{
foreach ( Api\Storage\Customfields :: get ( 'addressbook' ) as $name => $data )
{
$copy_fields [ '#' . $name ] = $data [ 'label' ];
}
}
// Remove country codes as an option, it will be added by UI constructor
if ( in_array ( 'adr_one_countrycode' , $supported_fields ))
{
unset ( $copy_fields [ 'adr_one_countrycode' ], $copy_fields [ 'adr_two_countrycode' ]);
}
$repositories = array ( 'sql' => 'SQL' );
// check account-repository, contact-repository LDAP is only availible for account-repository == ldap
if ( $config [ 'account_repository' ] == 'ldap' || ! $config [ 'account_repository' ] && $config [ 'auth_type' ] == 'ldap' )
{
$repositories [ 'ldap' ] = 'LDAP' ;
$repositories [ 'sql-ldap' ] = 'SQL --> LDAP (' . lang ( 'read only' ) . ')' ;
}
2016-05-20 15:50:26 +02:00
// geolocation pre-defined maps
$geoLocation = array (
2016-05-30 16:22:41 +02:00
array ( 'value' => 'https://maps.here.com/directions/drive{{%rs=/%rs}}%r0,%t0,%z0,%c0{{%d=/%d}}%r1,%t1,%z1+%c1' , 'label' => 'Here Maps' ),
array ( 'value' => 'http://maps.google.com/{{%rs=?saddr=%rs}}%r0+%t0+%z0+%c0{{%d=&daddr=%d}}%r1+%t1+%z1+%c1' , 'label' => 'Google Maps' ),
array ( 'value' => 'https://www.bing.com/maps/{{%rs=?rtp=adr.%rs}}%r0+%t0+%z0+%c0{{%d=~adr.%d}}%r1+%t1+%z1+%c1' , 'label' => 'Bing Maps' )
2016-05-20 15:50:26 +02:00
);
2016-04-25 17:57:38 +02:00
$ret = array (
'sel_options' => array (
'own_account_acl' => $own_account_acl ,
'org_fileds_to_update' => $org_fields , // typo has to stay, as it was there allways and we would loose existing config :(
'copy_fields' => $copy_fields ,
'fileas' => $bocontacts -> fileas_options (),
'contact_repository' => $repositories ,
2019-10-07 22:16:04 +02:00
'geolocation_url' => $geoLocation ,
2016-05-31 17:25:08 +02:00
)
2016-04-25 17:57:38 +02:00
);
2019-10-07 22:16:04 +02:00
foreach ( Api\Storage\Customfields :: get ( 'addressbook' ) as $tid => $data )
{
$ret [ 'sel_options' ][ 'index_load_cfs' ][ $tid ] = $data [ 'name' ];
}
2016-05-31 17:25:08 +02:00
if ( empty ( $config [ 'geolocation_url' ])) $ret [ 'geolocation_url' ] = $geoLocation [ 0 ][ 'value' ];
2016-04-25 17:57:38 +02:00
return $ret ;
2014-02-28 11:13:26 +01:00
}
2020-04-23 17:31:33 +02:00
/**
* get actions
*
* @ return array return an array of actions
*/
public static function status_get_actions ()
{
$config = Api\Config :: read ( 'stylite' );
return [
'addressbook_phonecall' => [
'caption' => 'Phone Call' ,
'icon' => 'call' ,
'group' => 2 ,
'enabled' => ! empty ( $config [ 'pbx_type' ]) && ! empty ( $config [ 'pbx_api_key' ]),
'disableIfNoEPL' => ! $GLOBALS [ 'egw_info' ][ 'apps' ][ 'stylite' ],
'children' => [
'addressbook_tel_work' => [
'caption' => lang ( 'Business phone' ),
'icon' => 'phone' ,
'onExecute' => 'javaScript:app.status.phoneCall' ,
'enabled' => 'javaScript:app.status.phoneIsAvailable'
],
'addressbook_tel_cell' => [
'caption' => lang ( 'Mobile phone' ),
'icon' => 'personal' ,
'onExecute' => 'javaScript:app.status.phoneCall' ,
'enabled' => 'javaScript:app.status.phoneIsAvailable'
],
'addressbook_tel_home' => [
'caption' => lang ( 'Home phone' ),
'icon' => 'home' ,
'onExecute' => 'javaScript:app.status.phoneCall' ,
'enabled' => 'javaScript:app.status.phoneIsAvailable'
],
'addressbook_tel_prefer' => [
'caption' => lang ( 'Favorite phone' ),
'icon' => 'fav_filter' ,
'onExecute' => 'javaScript:app.status.phoneCall' ,
'enabled' => 'javaScript:app.status.phoneIsAvailable'
]
]
]
];
}
2006-04-23 16:40:31 +02:00
}