2005-12-19 05:23:14 +01:00
< ? php
2006-08-26 18:32:29 +02:00
/**
2008-10-07 10:57:09 +02:00
* TimeSheet - diverse hooks : Admin - , Preferences - and SideboxMenu - Hooks
2006-08-26 18:32:29 +02:00
*
* @ link http :// www . egroupware . org
* @ author Ralf Becker < RalfBecker - AT - outdoor - training . de >
* @ package timesheet
2016-04-24 15:48:45 +02:00
* @ copyright ( c ) 2005 - 16 by Ralf Becker < RalfBecker - AT - outdoor - training . de >
2006-08-26 18:32:29 +02:00
* @ license http :// opensource . org / licenses / gpl - license . php GPL - GNU General Public License
2008-10-07 10:57:09 +02:00
* @ version $Id $
2006-08-26 18:32:29 +02:00
*/
2005-12-19 05:23:14 +01:00
2016-04-26 20:27:29 +02:00
use EGroupware\Api ;
use EGroupware\Api\Link ;
use EGroupware\Api\Framework ;
use EGroupware\Api\Egw ;
use EGroupware\Api\Acl ;
2005-12-19 05:23:14 +01:00
if ( ! defined ( 'TIMESHEET_APP' ))
{
define ( 'TIMESHEET_APP' , 'timesheet' );
}
2008-10-07 10:57:09 +02:00
/**
* diverse hooks as static methods
*
*/
class timesheet_hooks
2005-12-19 05:23:14 +01:00
{
2009-10-19 19:04:11 +02:00
/**
* Instance of timesheet_bo class
*
* @ var timesheet_bo
*/
static $timesheet_bo ;
2008-10-07 10:57:09 +02:00
/**
* Hook called by link - class to include timesheet 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-24 15:48:45 +02:00
unset ( $location ); // not used, but required by function signature
2008-10-07 10:57:09 +02:00
return array (
'query' => TIMESHEET_APP . '.timesheet_bo.link_query' ,
'title' => TIMESHEET_APP . '.timesheet_bo.link_title' ,
'titles' => TIMESHEET_APP . '.timesheet_bo.link_titles' ,
'view' => array (
2011-06-02 19:10:26 +02:00
'menuaction' => TIMESHEET_APP . '.timesheet_ui.edit' ,
2008-10-07 10:57:09 +02:00
),
'view_id' => 'ts_id' ,
2016-05-06 17:12:27 +02:00
'view_popup' => '630x480' ,
'edit_popup' => '630x480' ,
2016-11-22 19:41:51 +01:00
'list' => array (
2011-06-02 19:10:26 +02:00
'menuaction' => 'timesheet.timesheet_ui.index' ,
2016-11-22 19:41:51 +01:00
'ajax' => 'true'
2011-06-02 19:10:26 +02:00
),
2008-10-07 10:57:09 +02:00
'add' => array (
'menuaction' => TIMESHEET_APP . '.timesheet_ui.edit' ,
),
'add_app' => 'link_app' ,
'add_id' => 'link_id' ,
2016-05-06 17:12:27 +02:00
'add_popup' => '630x480' ,
2008-10-07 10:57:09 +02:00
'file_access' => TIMESHEET_APP . '.timesheet_bo.file_access' ,
2011-06-26 16:29:35 +02:00
'file_access_user' => true , // file_access supports 4th parameter $user
2012-05-30 10:21:18 +02:00
'notify' => TIMESHEET_APP . '.timesheet_bo.notify' ,
2020-01-23 11:26:44 +01:00
'merge' => true ,
'push_data' => 'ts_owner' ,
2008-10-07 10:57:09 +02:00
);
}
2005-12-19 05:23:14 +01:00
2008-10-07 10:57:09 +02:00
/**
* Return the timesheets linked with given project ( s ) AND with entries of other apps , which are also linked to the same project
*
* Projectmanager will cumulate them in the other apps entries .
*
* @ param array $param int / array $param [ 'pm_id' ] project - id ( s )
* @ return array with pm_id , pe_id , pe_app ( 'timesheet' ), pe_app_id ( ts_id ), other_id , other_app , other_app_id
*/
static function cumulate ( $param )
2005-12-19 05:23:14 +01:00
{
2016-04-26 20:27:29 +02:00
$links = Link :: get_3links ( TIMESHEET_APP , 'projectmanager' , $param [ 'pm_id' ]);
2008-10-07 10:57:09 +02:00
$rows = array ();
foreach ( $links as $link )
{
$rows [ $link [ 'id' ]] = array (
'pm_id' => $link [ 'id2' ],
'pe_id' => $link [ 'id' ],
'pe_app' => $link [ 'app1' ],
'pe_app_id' => $link [ 'id1' ],
'other_id' => $link [ 'link3' ],
'other_app' => $link [ 'app3' ],
'other_app_id' => $link [ 'id3' ],
);
}
return $rows ;
2005-12-19 05:23:14 +01:00
}
/**
2016-04-26 20:27:29 +02:00
* hooks to build projectmanager ' s sidebox - menu plus the admin and Api\Preferences sections
2005-12-19 05:23:14 +01:00
*
* @ param string / array $args hook args
*/
2008-10-07 10:57:09 +02:00
static function all_hooks ( $args )
2005-12-19 05:23:14 +01:00
{
$appname = TIMESHEET_APP ;
$location = is_array ( $args ) ? $args [ 'location' ] : $args ;
//echo "<p>ts_admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n";
if ( $location == 'sidebox_menu' )
{
2013-08-29 10:25:46 +02:00
// Magic etemplate2 favorites menu (from nextmatch widget)
2016-04-26 20:27:29 +02:00
display_sidebox ( $appname , lang ( 'Favorites' ), Framework\Favorites :: list_favorites ( $appname ));
2014-02-12 22:51:25 +01:00
2005-12-19 05:23:14 +01:00
$file = array (
2016-04-26 20:27:29 +02:00
'Timesheet list' => Egw :: link ( '/index.php' , array (
2015-09-10 00:20:25 +02:00
'menuaction' => 'timesheet.timesheet_ui.index' ,
'ajax' => 'true' )),
array (
2016-04-26 20:27:29 +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') "
),
2005-12-19 05:23:14 +01:00
);
2021-04-20 00:02:41 +02:00
$file [] = [ 'text' => '--' ];
2016-04-26 20:27:29 +02:00
$file [ 'Placeholders' ] = Egw :: link ( '/index.php' , 'menuaction=timesheet.timesheet_merge.show_replacements' );
2005-12-19 05:23:14 +01:00
display_sidebox ( $appname , $GLOBALS [ 'egw_info' ][ 'apps' ][ $appname ][ 'title' ] . ' ' . lang ( 'Menu' ), $file );
}
2013-10-03 11:23:18 +02:00
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'admin' ])
2005-12-19 05:23:14 +01:00
{
$file = Array (
2016-04-26 20:27:29 +02:00
'Site Configuration' => Egw :: link ( '/index.php' , 'menuaction=admin.admin_config.index&appname=' . $appname , '&ajax=true' ),
2017-01-17 18:24:56 +01:00
'Custom fields' => Egw :: link ( '/index.php' , 'menuaction=admin.admin_customfields.index&appname=' . $appname . '&use_private=1&ajax=true' ),
2016-04-26 20:27:29 +02:00
'Global Categories' => Egw :: link ( '/index.php' , array (
2011-06-21 23:14:51 +02:00
'menuaction' => 'admin.admin_categories.index' ,
2005-12-19 05:23:14 +01:00
'appname' => $appname ,
2016-08-12 11:35:30 +02:00
'global_cats' => True ,
'ajax' => 'true' ,
)),
'Edit Status' => Egw :: link ( '/index.php' , 'menuaction=timesheet.timesheet_ui.editstatus&ajax=true' ),
2005-12-19 05:23:14 +01:00
);
if ( $location == 'admin' )
{
display_section ( $appname , $file );
}
else
{
display_sidebox ( $appname , lang ( 'Admin' ), $file );
}
}
}
2008-10-07 10:57:09 +02:00
2005-12-19 05:23:14 +01:00
/**
2016-04-26 20:27:29 +02:00
* populates $GLOBALS [ 'settings' ] for the Api\Preferences
2005-12-19 05:23:14 +01:00
*/
2008-10-07 10:57:09 +02:00
static function settings ()
2005-12-19 05:23:14 +01:00
{
2011-02-04 21:03:42 +01:00
$settings = array ();
2009-10-19 19:04:11 +02:00
if ( is_null ( self :: $timesheet_bo )) self :: $timesheet_bo = new timesheet_bo ();
2011-02-04 21:03:42 +01:00
if ( self :: $timesheet_bo -> status_labels )
{
$settings [ 'predefined_status' ] = array (
2009-10-19 19:04:11 +02:00
'type' => 'select' ,
'label' => 'Status of created timesheets' ,
'name' => 'predefined_status' ,
'values' => self :: $timesheet_bo -> status_labels ,
'help' => 'Select the predefined status, when creating a new timesheet ' ,
'xmlrpc' => True ,
'admin' => False ,
2011-02-04 21:03:42 +01:00
);
}
// Merge print
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'filemanager' ])
{
$settings [ 'default_document' ] = array (
2012-05-22 15:51:30 +02:00
'type' => 'vfs_file' ,
2011-02-04 21:03:42 +01:00
'size' => 60 ,
'label' => 'Default document to insert entries' ,
'name' => 'default_document' ,
2011-07-04 21:23:28 +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 ( 'timesheet' )) . ' ' .
2014-06-24 11:47:08 +02:00
lang ( 'The document can contain placeholder like {{%1}}, to be replaced with the data.' , 'ts_title' ) . ' ' .
2016-04-26 20:27:29 +02:00
lang ( 'The following document-types are supported:' ) . implode ( ',' , Api\Storage\Merge :: get_file_extensions ()),
2011-02-04 21:03:42 +01:00
'run_lang' => false ,
'xmlrpc' => True ,
'admin' => False ,
);
$settings [ 'document_dir' ] = array (
2021-10-06 19:58:39 +02:00
'type' => 'vfs_dirs' ,
'size' => 60 ,
'label' => 'Directory with documents to insert entries' ,
'name' => 'document_dir' ,
'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 %1 data inserted.' , lang ( 'timesheet' )) . ' ' .
lang ( 'The document can contain placeholder like {{%1}}, to be replaced with the data.' , 'ts_title' ) . ' ' .
lang ( 'The following document-types are supported:' ) . implode ( ',' , Api\Storage\Merge :: get_file_extensions ()),
2011-02-04 21:03:42 +01:00
'run_lang' => false ,
2021-10-06 19:58:39 +02:00
'xmlrpc' => True ,
'admin' => False ,
'default' => '/templates/timesheet' ,
);
$settings [ Api\Storage\Merge :: PREF_DOCUMENT_FILENAME ] = array (
'type' => 'taglist' ,
'label' => 'Document download filename' ,
'name' => 'document_download_name' ,
'values' => Api\Storage\Merge :: DOCUMENT_FILENAME_OPTIONS ,
'help' => 'Choose the default filename for downloaded documents.' ,
'xmlrpc' => True ,
'admin' => False ,
'default' => 'document' ,
2011-02-04 21:03:42 +01:00
);
}
return $settings ;
2005-12-19 05:23:14 +01:00
}
2013-08-26 20:25:43 +02:00
/**
* ACL rights and labels used by Calendar
*
* @ param string | array string with location or array with parameters incl . " location " , specially " owner " for selected acl owner
*/
public static function acl_rights ( $params )
{
2016-04-24 15:48:45 +02:00
unset ( $params ); // not used, but required by function signature
2013-08-26 20:25:43 +02:00
return array (
2016-04-26 20:27:29 +02:00
Acl :: READ => 'read' ,
Acl :: EDIT => 'edit' ,
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-24 15:48:45 +02:00
unset ( $data ); // not used, but required by function signature
2013-10-03 11:23:18 +02:00
return true ;
}
2009-12-09 00:19:06 +01:00
}