2009-10-12 11:41:46 +02:00
< ? php
/**
* EGroupware - Preferences hooks
*
* @ link http :// www . egroupware . org
* @ license http :// opensource . org / licenses / gpl - license . php GPL - GNU General Public License
* @ package preferences
* @ version $Id $
*/
/**
* Static hooks for preferences class
*/
class preferences_hooks
{
/**
* Hook return common preferences settings
*
* @ param string | array $hook_data
* @ return array
*/
static public function settings ( $hook_data )
{
$navbar_format = array (
'icons' => lang ( 'Icons only' ),
'icons_and_text' => lang ( 'Icons and text' ),
'text' => lang ( 'Text only' )
);
$link_list_format = array (
'icons' => lang ( 'Icons only' ),
'icons_and_text' => lang ( 'Icons and text' ),
'text' => lang ( 'Text only' )
);
2009-10-19 20:17:59 +02:00
if ( ! $hook_data [ 'setup' ])
{
$langs = translation :: get_installed_langs ();
2009-10-19 22:45:23 +02:00
$tzs = egw_time :: getTimezones ();
2009-10-19 20:17:59 +02:00
}
2009-10-12 11:41:46 +02:00
$date_formats = array (
'd.m.Y' => 'd.m.Y' ,
'Y-m-d' => 'Y-m-d' ,
'm/d/Y' => 'm/d/Y' ,
'm-d-Y' => 'm-d-Y' ,
'm.d.Y' => 'm.d.Y' ,
'Y/d/m' => 'Y/d/m' ,
'Y-d-m' => 'Y-d-m' ,
'Y.d.m' => 'Y.d.m' ,
'Y/m/d' => 'Y/m/d' ,
'Y.m.d' => 'Y.m.d' ,
'd/m/Y' => 'd/m/Y' ,
'd-m-Y' => 'd-m-Y' ,
'd-M-Y' => 'd-M-Y'
);
$time_formats = array (
'12' => lang ( '12 hour' ),
'24' => lang ( '24 hour' )
);
$html_enter_mode = array (
'p' => lang ( 'p: Paragraph' ),
'div' => lang ( 'div' ),
'br' => lang ( 'br' )
);
$rich_text_editor_skins = array (
2010-05-25 09:49:24 +02:00
'kama' => lang ( 'Default theme' ),
2013-10-21 13:33:39 +02:00
'moono' => lang ( 'Moono theme' ),
'moonocolor' => lang ( 'Moono color theme' ),
2009-10-12 11:41:46 +02:00
);
$account_sels = array (
'selectbox' => lang ( 'Selectbox' ),
'primary_group' => lang ( 'Selectbox with primary group and search' ),
'popup' => lang ( 'Popup with search' ),
'groupmembers' => lang ( 'Selectbox with groupmembers' ),
'none' => lang ( 'No user-selection at all' ),
);
$account_display = array (
'firstname' => lang ( 'Firstname' ) . ' ' . lang ( 'Lastname' ),
'lastname' => lang ( 'Lastname' ) . ', ' . lang ( 'Firstname' ),
'username' => lang ( 'username' ),
'firstall' => lang ( 'Firstname' ) . ' ' . lang ( 'Lastname' ) . ' [' . lang ( 'username' ) . ']' ,
'lastall' => lang ( 'Lastname' ) . ', ' . lang ( 'Firstname' ) . ' [' . lang ( 'username' ) . ']' ,
'allfirst' => '[' . lang ( 'username' ) . '] ' . lang ( 'Firstname' ) . ' ' . lang ( 'Lastname' ),
'all' => '[' . lang ( 'username' ) . '] ' . lang ( 'Lastname' ) . ',' . lang ( 'Firstname' ),
);
2009-10-18 14:57:30 +02:00
if ( $hook_data [ 'setup' ]) // called via setup
{
$lang = get_var ( 'ConfigLang' , Array ( 'POST' , 'COOKIE' ), 'en' );
list (, $country ) = explode ( '-' , $lang );
if ( empty ( $country )) $country = $lang ;
}
2013-02-21 14:19:15 +01:00
// check for old rte_font_size pref including px and split it in size and unit
if ( ! isset ( $GLOBALS [ 'egw_setup' ]) &&
substr ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'rte_font_size' ], - 2 ) == 'px' )
2013-02-21 12:32:46 +01:00
{
2013-02-21 14:19:15 +01:00
$prefs = $GLOBALS [ 'egw' ] -> preferences ;
2013-02-21 12:32:46 +01:00
foreach ( array ( 'user' , 'default' , 'forced' ) as $type )
{
if ( substr ( $prefs -> { $type }[ 'common' ][ 'rte_font_size' ], - 2 ) == 'px' )
{
2013-02-21 14:19:15 +01:00
egw_ckeditor_config :: font_size_from_prefs ( $prefs -> { $type }, $prefs -> { $type }[ 'common' ][ 'rte_font_size' ],
$prefs -> { $type }[ 'common' ][ 'rte_font_unit' ]);
2013-02-21 12:32:46 +01:00
$prefs -> save_repository ( false , $type );
}
}
2013-02-21 14:19:15 +01:00
egw_ckeditor_config :: font_size_from_prefs ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ],
$GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'rte_font_size' ],
$GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'rte_font_unit' ]);
2013-02-21 12:32:46 +01:00
}
2009-10-12 11:41:46 +02:00
// Settings array for this app
$settings = array (
2012-12-04 23:21:59 +01:00
array (
'type' => 'section' ,
'title' => 'Look & feel'
),
2009-10-12 11:41:46 +02:00
'maxmatchs' => array (
'type' => 'input' ,
'label' => 'Max matches per page' ,
'name' => 'maxmatchs' ,
'help' => 'Any listing in eGW will show you this number of entries or lines per page.<br>To many slow down the page display, to less will cost you the overview.' ,
'size' => 3 ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2009-10-19 19:04:11 +02:00
'default' => 20 ,
2009-10-12 11:41:46 +02:00
),
'template_set' => array (
'type' => 'select' ,
'label' => 'Interface/Template Selection' ,
'name' => 'template_set' ,
2010-06-02 12:59:58 +02:00
'values' => egw_framework :: list_templates (),
2009-10-12 11:41:46 +02:00
'help' => 'A template defines the layout of eGroupWare and it contains icons for each application.' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2009-10-19 19:04:11 +02:00
'forced' => 'idots' ,
2009-10-12 11:41:46 +02:00
),
'theme' => array (
'type' => 'select' ,
'label' => 'Theme (colors/fonts) Selection' ,
'name' => 'theme' ,
2013-05-03 15:08:08 +02:00
'values' => ! $hook_data [ 'setup' ] ? $GLOBALS [ 'egw' ] -> framework -> list_themes () : array (),
2009-10-12 11:41:46 +02:00
'help' => 'A theme defines the colors and fonts used by the template.' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2009-10-19 19:04:11 +02:00
'forced' => 'idots' ,
2009-10-12 11:41:46 +02:00
),
'navbar_format' => array (
'type' => 'select' ,
'label' => 'Show navigation bar as' ,
'name' => 'navbar_format' ,
'values' => $navbar_format ,
'help' => 'You can show the applications as icons only, icons with app-name or both.' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
'default' => 'icons_and_text' ,
2009-10-12 11:41:46 +02:00
),
'link_list_format' => array (
'type' => 'select' ,
'label' => 'Show links between eGroupWare aps as' ,
'name' => 'link_list_format' ,
'values' => $link_list_format ,
'help' => 'You can show the linked entries with icons only, icons with app-name or both.' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2009-10-19 19:04:11 +02:00
'forced' => 'icons' ,
2009-10-12 11:41:46 +02:00
),
'link_list_thumbnail' => array (
'type' => 'select' ,
'label' => 'Display thumbnails for linked images' ,
'name' => 'link_list_thumbnail' ,
'values' => array (
'1' => lang ( 'Yes' ),
'0' => lang ( 'No' ),
),
'help' => 'Images linked to an entry can be displayed as thumbnails. You can turn this off to speed up page display.' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2009-10-19 19:04:11 +02:00
'forced' => '1' ,
2009-10-12 11:41:46 +02:00
),
2011-06-15 17:50:16 +02:00
'select_mode' => array (
'type' => 'select' ,
'label' => 'Select additional lines in lists by' ,
'name' => 'select_mode' ,
'values' => array (
2011-06-15 17:59:13 +02:00
'EGW_SELECTMODE_DEFAULT' => lang ( 'holding Ctrl/Cmd key and click on the line' ),
'EGW_SELECTMODE_TOGGLE' => lang ( 'just clicking on the line, like a checkbox' ),
2011-06-15 17:50:16 +02:00
),
'help' => 'If a line is already selected, further lines get either selected by holding Ctrl/Cmd key and clicking on them (to not unselect the current selected line), or by just clicking on them as for a checkbox. If no line is selected clicking on one allways selects it. Holding down Shift key selects everything between current select line and the one clicked.' ,
'xmlrpc' => True ,
'admin' => False ,
'default' => 'EGW_SELECTMODE_DEFAULT' ,
),
2012-12-04 23:21:59 +01:00
'account_selection' => array (
'type' => 'select' ,
'label' => 'How do you like to select accounts' ,
'name' => 'account_selection' ,
'values' => $account_sels ,
'help' => lang ( 'The selectbox shows all available users (can be very slow on big installs with many users). The popup can search users by name or group.' ) . ' ' .
lang ( 'The two last options limit the visibility of other users. Therefore they should be forced and apply NOT to administrators.' ),
'run_lang' => false ,
'xmlrpc' => True ,
'admin' => False ,
2014-04-17 12:53:56 +02:00
'default' => 'selectbox'
2012-12-04 23:21:59 +01:00
),
'account_display' => array (
'type' => 'select' ,
'label' => 'How do you like to display accounts' ,
'name' => 'account_display' ,
'values' => $account_display ,
'help' => 'Set this to your convenience. For security reasons, you might not want to show your Loginname in public.' ,
'xmlrpc' => True ,
'admin' => False ,
'default' => 'lastname' ,
),
'show_currentusers' => array (
'type' => 'check' ,
'label' => 'Show number of current users' ,
'name' => 'show_currentusers' ,
'help' => 'Should the number of active sessions be displayed for you all the time.' ,
'xmlrpc' => False ,
'admin' => True ,
'forced' => true ,
),
array (
'type' => 'section' ,
'title' => 'Formatting & general settings'
),
'lang' => array (
'type' => 'select' ,
'label' => 'Language' ,
'name' => 'lang' ,
'values' => $langs ,
'help' => 'Select the language of texts and messages within eGroupWare.<br>Some languages may not contain all messages, in that case you will see an english message.' ,
'xmlrpc' => True ,
'admin' => False ,
'default' => $lang ,
),
'country' => array (
'type' => 'select' ,
'label' => 'Country' ,
'name' => 'country' ,
'values' => ExecMethod ( 'phpgwapi.country.countries' ),
'help' => 'In which country are you. This is used to set certain defaults for you.' ,
'xmlrpc' => True ,
'admin' => False ,
'default' => strtoupper ( $country ),
),
2009-10-12 11:41:46 +02:00
'tz' => array (
'type' => 'select' ,
'label' => 'Time zone' ,
'name' => 'tz' ,
'values' => $tzs ,
'help' => 'Please select your timezone.' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
'default' => date_default_timezone_get (),
2009-10-12 11:41:46 +02:00
),
'tz_selection' => array (
'type' => 'multiselect' ,
'label' => 'Permanent time zone selection' ,
'name' => 'tz_selection' ,
2009-11-14 18:39:35 +01:00
'values' => $tzs ? call_user_func_array ( 'array_merge' , $tzs ) : null , // only flat arrays supported
2009-10-12 11:41:46 +02:00
'help' => 'Please select timezones, you want to be able to quickly switch between. Switch is NOT shown, if less then two are selected.' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2009-10-19 19:04:11 +02:00
'forced' => date_default_timezone_get (),
2009-10-12 11:41:46 +02:00
),
'dateformat' => array (
'type' => 'select' ,
'label' => 'Date format' ,
'name' => 'dateformat' ,
'values' => $date_formats ,
'help' => 'How should eGroupWare display dates for you.' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
'default' => $lang == 'en' ? 'Y/m/d' : 'd.m.Y' ,
2009-10-12 11:41:46 +02:00
),
'timeformat' => array (
'type' => 'select' ,
'label' => 'Time format' ,
'name' => 'timeformat' ,
'values' => $time_formats ,
'help' => 'Do you prefer a 24 hour time format, or a 12 hour one with am/pm attached.' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
'default' => 24 ,
2009-10-12 11:41:46 +02:00
),
2012-12-04 23:21:59 +01:00
'number_format' => array (
2009-10-12 11:41:46 +02:00
'type' => 'select' ,
2012-12-04 23:21:59 +01:00
'label' => 'Number format' ,
'name' => 'number_format' ,
'values' => array (
'.' => '1234.56' ,
',' => '1234,56' ,
'.,' => '1,234.56' ,
',.' => '1.234,56' ,
'. ' => '1 234.56' ,
', ' => '1 234,56' ,
),
'help' => 'Thousands separator is only used for displaying and not for editing numbers.' ,
'xmlrpc' => True ,
'admin' => false ,
'default' => '.' ,
),
'currency' => array (
'type' => 'input' ,
'label' => 'Currency' ,
'name' => 'currency' ,
'help' => 'Which currency symbol or name should be used in eGroupWare.' ,
2009-10-12 11:41:46 +02:00
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2012-12-04 23:21:59 +01:00
'default' => $lang == 'en' ? '$' : 'EUR' ,
2009-10-12 11:41:46 +02:00
),
2012-12-04 23:21:59 +01:00
'csv_charset' => array (
2009-10-12 11:41:46 +02:00
'type' => 'select' ,
2012-12-04 23:21:59 +01:00
'label' => 'Charset for the CSV export/import' ,
'name' => 'csv_charset' ,
'values' => translation :: get_installed_charsets (),
'help' => 'Which charset should be used for the CSV export. The system default is the charset of this eGroupWare installation.' ,
2009-10-12 11:41:46 +02:00
'xmlrpc' => True ,
2012-12-04 23:21:59 +01:00
'admin' => false ,
'default' => 'iso-8859-1' ,
),
array (
'type' => 'section' ,
'title' => 'Text editor settings'
),
'rte_font' => array (
'type' => 'select' ,
'label' => 'Default font' ,
'name' => 'rte_font' ,
'values' => egw_ckeditor_config :: $font_options ,
'help' => 'Automatically start with this font' ,
'xmlrpc' => True ,
'admin' => false
),
2013-02-21 12:32:46 +01:00
'rte_font_unit' => array (
'type' => 'select' ,
'label' => 'Font size unit' ,
'name' => 'rte_font_unit' ,
'values' => array_map ( 'lang' , egw_ckeditor_config :: $font_unit_options ),
'help' => 'Unit of displayed font sizes: either "px" as used eg. for web-pages or "pt" as used in text processing.' ,
2013-02-21 14:19:15 +01:00
'default' => 'pt' ,
2013-02-21 12:32:46 +01:00
'xmlrpc' => True ,
'admin' => false
),
2012-12-04 23:21:59 +01:00
'rte_font_size' => array (
'type' => 'select' ,
'label' => 'Default font size' ,
'name' => 'rte_font_size' ,
'values' => egw_ckeditor_config :: $font_size_options ,
'help' => 'Automatically start with this font size' ,
'xmlrpc' => True ,
'admin' => false
2009-10-12 11:41:46 +02:00
),
'spellchecker_lang' => array (
'type' => 'select' ,
'label' => 'Spellchecker language' ,
'name' => 'spellchecker_lang' ,
'values' => $langs ,
'help' => 'Select the language of the spellchecker integrated into the rich text editor.' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
'default' => $lang ,
2009-10-12 11:41:46 +02:00
),
'rte_enter_mode' => array (
'type' => 'select' ,
'label' => 'Rich text editor enter mode' ,
'name' => 'rte_enter_mode' ,
'values' => $html_enter_mode ,
'help' => 'Select how the rich text editor will generate the enter (linebreak) tag.' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2009-10-19 19:04:11 +02:00
'forced' => 'br' ,
2009-10-12 11:41:46 +02:00
),
'rte_skin' => array (
'type' => 'select' ,
'label' => 'Rich text editor theme' ,
'name' => 'rte_skin' ,
'values' => $rich_text_editor_skins ,
'help' => 'Select the theme (visualization) of the rich text editor.' ,
'xmlrpc' => True ,
2009-10-18 14:57:30 +02:00
'admin' => False ,
2009-10-19 19:04:11 +02:00
'forced' => 'office2003' ,
2009-10-12 11:41:46 +02:00
),
2012-12-04 23:21:59 +01:00
'rte_features' => array (
'type' => 'select' ,
'label' => 'Features of the editor' ,
'name' => 'rte_features' ,
'values' => array ( 'simple' => 'simple' , 'extended' => 'regular' , 'advanced' => 'everything' ),
2012-12-05 20:36:03 +01:00
'help' => 'How many toolbar buttons are available' ,
2012-12-04 23:21:59 +01:00
'admin' => false ,
2012-12-06 18:14:18 +01:00
'default' => 'extended'
2009-10-12 11:41:46 +02:00
),
);
// disable thumbnails, if no size configured by admin
if ( ! $GLOBALS [ 'egw_info' ][ 'server' ][ 'link_list_thumbnail' ]) unset ( $settings [ 'link_list_thumbnail' ]);
return $settings ;
}
/**
* Hook called when a user gets deleted , to delete his preferences
*
2010-01-27 06:44:31 +01:00
* @ param string | array $data
2009-10-12 11:41:46 +02:00
*/
2010-01-27 06:44:31 +01:00
public static function deleteaccount ( $data )
2009-10-12 11:41:46 +02:00
{
2010-01-27 06:44:31 +01:00
$account_id = ( int ) $data [ 'account_id' ];
if ( $account_id > 0 ) // user
{
$GLOBALS [ 'egw' ] -> preferences -> delete_user ( $account_id );
}
elseif ( $account_id < 0 ) // group
2009-10-12 11:41:46 +02:00
{
2010-01-27 06:44:31 +01:00
$GLOBALS [ 'egw' ] -> preferences -> delete_group ( $account_id );
2009-10-12 11:41:46 +02:00
}
}
2013-05-11 10:51:06 +02:00
/**
* Preferences link to Admin >> Edit user
*/
public static function edit_user ()
{
global $menuData ;
$menuData [] = array (
2014-04-01 17:49:08 +02:00
'description' => 'Preferences' ,
'url' => '/index.php' ,
'extradata' => 'menuaction=preferences.preferences_settings.index' ,
'popup' => '900x450' ,
2013-05-11 10:51:06 +02:00
);
}
2013-10-02 18:29:08 +02:00
/**
* hooks to build sidebox - menu plus the admin and preferences sections
*
* @ param string | array $args hook args
*/
static function admin ( $args )
{
2014-04-01 17:49:08 +02:00
unset ( $args ); // unused, but required by function signature
2013-10-02 18:29:08 +02:00
$appname = 'preferences' ;
$file = Array (
'Site configuration' => egw :: link ( '/index.php' , 'menuaction=admin.uiconfig.index&appname=' . $appname ),
);
display_section ( $appname , $file );
}
/**
* Hook returning options for deny_acl groups
*
* @ param array $config
*/
public static function deny_prefs ( $config )
{
$accountsel = new uiaccountsel ();
return '<input type="hidden" value="" name="newsettings[deny_prefs]" />' .
$accountsel -> selection ( 'newsettings[deny_prefs]' , 'deny_prefs' , $config [ 'deny_prefs' ], 'groups' , 4 );
}
/**
* Hook returning options for deny_acl groups
*
* @ param array $config
*/
public static function deny_acl ( $config )
{
$accountsel = new uiaccountsel ();
return '<input type="hidden" value="" name="newsettings[deny_acl]" />' .
$accountsel -> selection ( 'newsettings[deny_acl]' , 'deny_acl' , $config [ 'deny_acl' ], 'groups' , 4 );
}
/**
* Hook returning options for deny_cats groups
*
* @ param array $config
*/
public static function deny_cats ( $config )
{
$accountsel = new uiaccountsel ();
return '<input type="hidden" value="" name="newsettings[deny_cats]" />' .
$accountsel -> selection ( 'newsettings[deny_cats]' , 'deny_cats' , $config [ 'deny_cats' ], 'groups' , 4 );
}
2009-10-12 11:41:46 +02:00
}