2008-08-27 13:17:00 +02:00
< ? php
/**
* eGroupWare - Hooks for admin , preferences and sidebox - menus
*
* @ link http :// www . egroupware . org
* @ author Ralf Becker < RalfBecker - AT - outdoor - training . de >
* @ package filemanager
* @ license http :// opensource . org / licenses / gpl - license . php GPL - GNU General Public License
2008-10-05 19:07:36 +02:00
* @ version $Id : class . filemanager_hooks . inc . php 25002 2008 - 03 - 03 12 : 16 : 11 Z ralfbecker $
2008-08-27 13:17:00 +02:00
*/
/**
* Class containing admin , preferences and sidebox - menus ( used as hooks )
*/
class filemanager_hooks
{
static $appname = 'filemanager' ;
static $foldercount = 1 ;
2008-10-05 19:07:36 +02:00
2008-09-04 08:44:48 +02:00
/**
* Data for Filemanagers sidebox menu
*
* @ param array $args
*/
2008-08-27 13:17:00 +02:00
static function sidebox_menu ( $args )
{
$location = is_array ( $args ) ? $args [ 'location' ] : $args ;
2008-09-04 08:44:48 +02:00
$rootpath = '/' ;
$basepath = '/home' ;
2008-08-27 13:17:00 +02:00
$homepath = '/home/' . $GLOBALS [ 'egw_info' ][ 'user' ][ 'account_lid' ];
//echo "<p>admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n";
$config = config :: read ( self :: $appname );
if ( ! empty ( $config [ 'max_folderlinks' ])) self :: $foldercount = ( int ) $config [ 'max_folderlinks' ];
$file_prefs = & $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ self :: $appname ];
if ( $location == 'sidebox_menu' )
{
$title = $GLOBALS [ 'egw_info' ][ 'apps' ][ self :: $appname ][ 'title' ] . ' ' . lang ( 'Menu' );
2008-09-04 08:44:48 +02:00
$file = array (
'Your home directory' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , array ( 'menuaction' => self :: $appname . '.filemanager_ui.index' , 'path' => $homepath )),
2008-11-16 11:59:04 +01:00
'Users and groups' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , array ( 'menuaction' => self :: $appname . '.filemanager_ui.index' , 'path' => $basepath )),
2008-08-27 13:17:00 +02:00
);
2008-09-04 08:44:48 +02:00
if ( ! empty ( $file_prefs [ 'showbase' ]) && $file_prefs [ 'showbase' ] == 'yes' )
{
$file [ 'Basedirectory' ] = $GLOBALS [ 'egw' ] -> link ( '/index.php' , array ( 'menuaction' => self :: $appname . '.filemanager_ui.index' , 'path' => $rootpath ));
}
2008-08-27 13:17:00 +02:00
if ( ! empty ( $file_prefs [ 'startfolder' ])) $file [ 'Startfolder' ] = $GLOBALS [ 'egw' ] -> link ( '/index.php' , array ( 'menuaction' => self :: $appname . '.filemanager_ui.index' , 'path' => $file_prefs [ 'startfolder' ]));
2008-10-05 19:07:36 +02:00
for ( $i = 1 ; $i <= self :: $foldercount ; $i ++ )
2008-09-04 08:44:48 +02:00
{
2008-10-05 19:07:36 +02:00
if ( ! empty ( $file_prefs [ 'folderlink' . $i ]))
2008-09-04 08:44:48 +02:00
{
$foldername = array_pop ( explode ( '/' , $file_prefs [ 'folderlink' . $i ]));
$file [ lang ( 'Link %1: %2' , $i , $foldername )] = $GLOBALS [ 'egw' ] -> link ( '/index.php' , array (
'menuaction' => self :: $appname . '.filemanager_ui.index' ,
'path' => $file_prefs [ 'folderlink' . $i ],
'nolang' => true ,
));
2008-08-27 13:17:00 +02:00
}
}
display_sidebox ( self :: $appname , $title , $file );
}
2009-05-29 12:48:58 +02:00
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'preferences' ]) self :: preferences ( self :: $appname );
2008-08-27 13:17:00 +02:00
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'admin' ]) self :: admin ( self :: $appname );
}
/**
* Entries for filemanagers ' s admin menu
2009-05-29 12:48:58 +02:00
*
* @ param string | array $location = 'admin' hook name or params
2008-08-27 13:17:00 +02:00
*/
static function admin ( $location = 'admin' )
{
$file = Array (
'Site Configuration' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiconfig.index&appname=' . self :: $appname ),
2008-10-05 19:07:36 +02:00
'Custom fields' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.customfields.edit&appname=' . self :: $appname ),
2008-08-27 13:17:00 +02:00
);
2008-10-06 19:43:42 +02:00
if ( $location == 'admin' )
{
2008-08-27 13:17:00 +02:00
display_section ( self :: $appname , $file );
2008-10-06 19:43:42 +02:00
}
else
{
2008-08-27 13:17:00 +02:00
display_sidebox ( self :: $appname , lang ( 'Admin' ), $file );
}
}
2008-10-05 19:07:36 +02:00
2009-05-29 12:48:58 +02:00
/**
* Entries for filemanagers ' s preferences menu
*
* @ param string | array $location = 'preferences' hook name or params
*/
2008-10-05 19:07:36 +02:00
static function preferences ( $location = 'preferences' )
2008-08-27 13:17:00 +02:00
{
$file = array (
'Preferences' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=preferences.uisettings.index&appname=' . self :: $appname ),
);
2008-10-05 19:07:36 +02:00
if ( $location == 'preferences' )
2008-08-27 13:17:00 +02:00
{
display_section ( self :: $appname , $file );
2008-10-06 19:43:42 +02:00
}
else
{
2008-08-27 13:17:00 +02:00
display_sidebox ( self :: $appname , lang ( 'Preferences' ), $file );
}
}
2009-05-29 12:48:58 +02:00
/**
* Settings for preferences
*
* @ return array with settings
*/
2008-08-27 13:17:00 +02:00
static function settings ()
{
$config = config :: read ( self :: $appname );
if ( ! empty ( $config [ 'max_folderlinks' ])) self :: $foldercount = ( int ) $config [ 'max_folderlinks' ];
$upload_boxes = array (
'1' => '1' ,
'5' => '5' ,
'10' => '10' ,
'20' => '20' ,
'30' => '30'
);
$yes_no = array (
2008-08-28 13:09:09 +02:00
'no' => lang ( 'No' ),
'yes' => lang ( 'Yes' )
2008-08-27 13:17:00 +02:00
);
2008-10-05 19:07:36 +02:00
2009-05-29 12:48:58 +02:00
$settings = array (
2008-08-27 13:17:00 +02:00
'showbase' => array (
'type' => 'select' ,
'name' => 'showbase' ,
'values' => $yes_no ,
2008-08-28 13:09:09 +02:00
'label' => lang ( 'Show link to filemanagers basedirectory (/) in side box menu?' ),
2008-10-06 19:43:42 +02:00
'help' => lang ( 'Default behavior is NO. The link will not be shown, but you are still able to navigate to this location, or configure this paricular location as startfolder or folderlink.' ),
2008-08-27 13:17:00 +02:00
'xmlrpc' => True ,
'amin' => False
),
'startfolder' => array (
'type' => 'input' ,
'name' => 'startfolder' ,
2008-10-06 19:43:42 +02:00
'size' => 60 ,
2008-08-27 13:17:00 +02:00
'default' => '' ,
2008-08-28 13:09:09 +02:00
'label' => lang ( 'Enter the complete VFS path to specify your desired start folder.' ),
2008-10-06 19:43:42 +02:00
'help' => lang ( 'The default start folder is your personal Folder. The default is used, if you leave this empty, the path does not exist or you lack the neccessary access permissions.' ),
2008-08-27 13:17:00 +02:00
'xmlrpc' => True ,
'amin' => False
),
);
2008-10-06 19:43:42 +02:00
for ( $i = 1 ; $i <= self :: $foldercount ; $i ++ )
{
2009-05-29 12:48:58 +02:00
$settings [ 'folderlink' . $i ] = array (
2008-08-27 13:17:00 +02:00
'type' => 'input' ,
'name' => 'folderlink' . $i ,
2008-10-06 19:43:42 +02:00
'size' => 60 ,
2008-08-27 13:17:00 +02:00
'default' => '' ,
2008-08-28 13:09:09 +02:00
'label' => lang ( 'Enter the complete VFS path to specify a fast access link to a folder' ) . ' (' . $i . ').' ,
2008-08-27 13:17:00 +02:00
'xmlrpc' => True ,
'amin' => False
);
}
2009-05-29 12:48:58 +02:00
return $settings ;
2008-08-27 13:17:00 +02:00
}
}