2006-04-23 16:40:31 +02:00
< ? php
2006-06-13 23:53:00 +02:00
/**
2008-04-25 20:59:00 +02:00
* 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 >
2013-02-01 18:38:08 +01:00
* @ copyright ( c ) 2006 - 13 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
/**
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' )
{
$file = array (
2010-06-02 19:11:48 +02:00
'Add' => " javascript:egw_openWindowCentered2(' " .
egw :: link ( '/index.php' , array ( 'menuaction' => 'addressbook.addressbook_ui.edit' ), false ) .
2010-09-16 23:02:37 +02:00
" ','_blank',870,480,'yes') " ,
2010-06-02 19:11:48 +02:00
'Advanced search' => " javascript:egw_openWindowCentered2(' " .
egw :: link ( '/index.php' , array ( 'menuaction' => 'addressbook.addressbook_ui.search' ), false ) .
2010-09-16 23:02:37 +02:00
" ','_blank',870,480,'yes') " ,
2006-04-23 16:40:31 +02:00
);
display_sidebox ( $appname , lang ( 'Addressbook menu' ), $file );
}
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'preferences' ] && $location != 'admin' )
{
$file = array (
2009-05-14 19:11:17 +02:00
'Preferences' => egw :: link ( '/index.php' , 'menuaction=preferences.uisettings.index&appname=' . $appname ),
'Grant Access' => egw :: link ( '/index.php' , 'menuaction=preferences.uiaclprefs.index&acl_app=' . $appname ),
2011-06-21 23:14:51 +02:00
'Edit Categories' => egw :: link ( '/index.php' , 'menuaction=preferences.preferences_categories_ui.index&cats_app=' . $appname . '&cats_level=True&global_cats=True' )
2006-04-23 16:40:31 +02:00
);
2008-04-25 20:59:00 +02:00
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'contact_repository' ] == 'ldap' || $GLOBALS [ 'egw_info' ][ 'server' ][ 'deny_user_grants_access' ])
2006-04-23 16:40:31 +02:00
{
unset ( $file [ 'Grant Access' ]);
}
if ( $location == 'preferences' )
{
display_section ( $appname , $file );
}
else
{
display_sidebox ( $appname , lang ( 'Preferences' ), $file );
}
}
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'admin' ] && $location != 'preferences' )
{
$file = Array (
2009-05-14 19:11:17 +02:00
'Site configuration' => egw :: link ( '/index.php' , array (
2006-04-23 16:40:31 +02:00
'menuaction' => 'admin.uiconfig.index' ,
'appname' => $appname ,
)),
2009-05-14 19:11:17 +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 ,
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' )
{
2009-05-14 19:11:17 +02:00
$file [ 'Custom fields' ] = egw :: link ( '/index.php' , array (
2006-06-17 20:50:07 +02:00
'menuaction' => 'admin.customfields.edit' ,
'appname' => $appname ,
2008-01-19 06:41:04 +01:00
'use_private' => 1 ,
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
/**
2009-04-29 08:26:04 +02:00
* populates $settings for the 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.' ,
2009-10-18 14:58:38 +02:00
'values' => ! $hook_data [ 'setup' ] ? ExecMethod ( 'addressbook.addressbook_ui.get_addressbooks' , EGW_ACL_ADD ) : array (),
2006-10-07 11:17:30 +02:00
'xmlrpc' => True ,
'admin' => False ,
);
2009-10-19 19:04:11 +02:00
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'hide_birthdays' ] != 'yes' ) // calendar config
2009-06-15 15:48:09 +02:00
{
$settings [ 'mainscreen_showbirthdays' ] = array (
'type' => 'select' ,
'label' => 'Show birthday reminders on main screen' ,
'name' => 'mainscreen_showbirthdays' ,
'help' => 'Displays a remider for birthdays on the startpage (page you get when you enter eGroupWare or click on the homepage icon).' ,
'values' => array (
0 => lang ( 'No' ),
1 => lang ( 'Yes, for today and tomorrow' ),
3 => lang ( 'Yes, for the next three days' ),
7 => lang ( 'Yes, for the next week' ),
14 => lang ( 'Yes, for the next two weeks' ),
),
'xmlrpc' => True ,
'admin' => False ,
2009-10-19 19:04:11 +02:00
'default' => 3 ,
2009-06-15 15:48:09 +02:00
);
}
2013-01-21 21:37:59 +01:00
$settings [ 'distributionListPreferredMail' ] = array (
2006-04-26 23:23:38 +02:00
'type' => 'select' ,
2013-01-21 21:37:59 +01:00
'label' => 'Preferred email address to use in distribution lists' ,
'name' => 'distributionListPreferredMail' ,
2006-04-26 23:23:38 +02:00
'values' => array (
2013-01-21 21:37:59 +01:00
'email' => lang ( " Work email if given, else home email " ),
'email_home' => lang ( " Home email if given, else work email " ),
2008-04-25 20:59:00 +02:00
),
2013-01-21 21:37:59 +01:00
'help' => 'Defines which email address (business or home) to use as the preferred one for distribution lists in mail.' ,
2010-04-13 19:44:09 +02:00
'xmlrpc' => True ,
2013-01-21 21:37:59 +01:00
'admin' => False ,
'forced' => 'email' ,
2010-04-13 19:44:09 +02:00
);
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 (
'type' => 'check' ,
'label' => 'Hide accounts from addressbook' ,
'name' => 'hide_accounts' ,
'help' => 'Hides accounts completly from the adressbook.' ,
'xmlrpc' => True ,
'admin' => false ,
);
$settings [ 'no_auto_hide' ] = array (
'type' => 'check' ,
'label' => 'Don\'t hide empty columns' ,
'name' => 'no_auto_hide' ,
'help' => 'Should the columns photo and home address always be displayed, even if they are empty.' ,
'xmlrpc' => True ,
'admin' => false ,
'forced' => false ,
);
2010-11-10 10:35:10 +01:00
$fileas_options = ExecMethod ( 'addressbook.addressbook_bo.fileas_options' );
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
);
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
);
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-05-14 19:11:17 +02:00
$link = egw :: link ( '/index.php' , 'menuaction=addressbook.addressbook_merge.show_replacements' );
2007-04-15 15:06:21 +02:00
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' )) . ' ' .
lang ( 'The document can contain placeholder like {{%3}}, to be replaced with the data (%1full list of placeholder names%2).' , '<a href="' . $link . '" target="_blank">' , '</a>' , 'n_fn' ) . ' ' .
lang ( 'The following document-types are supported:' ) . implode ( ',' , bo_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' )) . ' ' .
lang ( 'The document can contain placeholder like {{%3}}, to be replaced with the data (%1full list of placeholder names%2).' , '<a href="' . $link . '" target="_blank">' , '</a>' , 'n_fn' ) . ' ' .
lang ( 'The following document-types are supported:' ) . implode ( ',' , bo_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-01-21 21:37:59 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'felamimail' ])
{
$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' ])
{
$definitions = new importexport_definitions_bo ( array (
'type' => 'export' ,
'application' => 'addressbook'
));
2011-11-18 17:01:57 +01:00
$options = array (
2011-11-21 11:01:08 +01:00
'~nextmatch~' => lang ( 'Old fixed definition' )
2011-11-18 17:01:57 +01:00
);
2011-03-21 16:58:08 +01:00
$default_def = 'export-addressbook' ;
foreach (( array ) $definitions -> get_definitions () as $identifier )
{
try
{
2011-02-28 19:10:43 +01:00
$definition = new importexport_definition ( $identifier );
2011-03-21 16:58:08 +01:00
}
catch ( Exception $e )
{
2011-02-28 19:10:43 +01:00
// permission error
continue ;
}
2011-03-21 16:58:08 +01:00
if ( $title = $definition -> get_title ())
{
2011-02-28 19:10:43 +01:00
$options [ $title ] = $title ;
}
unset ( $definition );
}
$settings [ 'nextmatch-export-definition' ] = array (
'type' => 'select' ,
'values' => $options ,
2011-07-04 22:00:26 +02:00
'label' => 'Export definition to use for nextmatch export' ,
2011-02-28 19:10:43 +01:00
'name' => 'nextmatch-export-definition' ,
'help' => lang ( 'If you specify an export definition, it will be used when you export' ),
'run_lang' => false ,
'xmlrpc' => True ,
'admin' => False ,
2011-03-21 16:58:08 +01:00
'default' => isset ( $options [ $default_def ]) ? $default_def : false ,
2011-02-28 19:10:43 +01:00
);
2013-01-21 21:37:59 +01:00
$settings [ 'csv_fields' ] = array (
'type' => 'select' ,
'label' => 'Fields for the CSV export' ,
'name' => 'csv_fields' ,
'values' => array (
'all' => lang ( 'All' ),
'business' => lang ( 'Business address' ),
'home' => lang ( 'Home address' ),
),
'help' => 'Which fields should be exported. All means every field stored in the addressbook incl. the custom fields. The business or home address only contains name, company and the selected address.' ,
2012-01-13 06:22:18 +01:00
'xmlrpc' => True ,
2013-01-21 21:37:59 +01:00
'admin' => false ,
'default' => 'business' ,
);
$settings [ 'vcard_charset' ] = array (
'type' => 'select' ,
'label' => 'Charset for the vCard import and export' ,
'name' => 'vcard_charset' ,
'values' => translation :: get_installed_charsets (),
'help' => 'Which charset should be used for the vCard import and export.' ,
'xmlrpc' => True ,
'admin' => false ,
'default' => 'iso-8859-1' ,
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
}
/**
* add an Addressbook tab to Admin >> Edit user
*/
2008-04-25 20:59:00 +02:00
static function edit_user ()
2006-04-23 16:40:31 +02:00
{
global $menuData ;
$menuData [] = array (
'description' => 'Addressbook' ,
'url' => '/index.php' ,
2008-05-10 14:02:49 +02:00
'extradata' => 'menuaction=addressbook.addressbook_ui.edit' ,
2010-09-16 23:02:37 +02:00
'options' => " onclick= \" egw_openWindowCentered2(this,'_blank',870,440,'yes'); return false; \" " .
2006-04-23 16:40:31 +02:00
' title="' . htmlspecialchars ( lang ( 'Edit extra account-data in the addressbook' )) . '"' ,
);
}
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 )
{
return array (
2008-05-10 14:02:49 +02:00
'query' => 'addressbook.addressbook_bo.link_query' ,
'title' => 'addressbook.addressbook_bo.link_title' ,
'titles' => 'addressbook.addressbook_bo.link_titles' ,
2008-04-25 20:59:00 +02:00
'view' => array (
2008-05-10 14:02:49 +02:00
'menuaction' => 'addressbook.addressbook_ui.view'
2008-04-25 20:59:00 +02:00
),
'view_id' => 'contact_id' ,
2009-12-08 22:27:56 +01:00
'view_list' => 'addressbook.addressbook_ui.index' ,
2011-06-02 18:57:33 +02:00
'edit' => array (
'menuaction' => 'addressbook.addressbook_ui.edit'
),
'edit_id' => 'contact_id' ,
'edit_popup' => '870x440' ,
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' ,
2010-09-16 23:02:37 +02:00
'add_popup' => '870x440' ,
2011-06-26 15:55:25 +02:00
'file_access_user' => true , // file_access supports 4th parameter $user
2008-10-07 11:05:48 +02:00
'file_access' => 'addressbook.addressbook_bo.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 (
'query' => 'addressbook.addressbook_bo.link_query_email' ,
2012-11-27 16:48:13 +01:00
'view' => array (
'menuaction' => 'addressbook.addressbook_ui.view'
),
'view_id' => 'contact_id' ,
2010-09-22 11:36:26 +02:00
),
2012-07-04 19:00:03 +02:00
),
'merge' => true ,
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 )
{
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 )
{
return array (
'type' => 'c' , // one char type-identifiy for this resources
2008-05-10 14:02:49 +02:00
'info' => 'addressbook.addressbook_bo.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 )
{
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 )
{
return true ;
}
2006-04-23 16:40:31 +02:00
}