using static methods of egw_link and config, implemented titles link

This commit is contained in:
Ralf Becker 2008-03-09 07:33:42 +00:00
parent e96a4401f2
commit 641475d08b
4 changed files with 70 additions and 64 deletions

View File

@ -5,13 +5,11 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package timesheet
* @copyright (c) 2005/6 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php');
if (!defined('TIMESHEET_APP'))
{
define('TIMESHEET_APP','timesheet');
@ -24,14 +22,6 @@ if (!defined('TIMESHEET_APP'))
*/
class botimesheet extends so_sql
{
/**
* Timesheets config data
*
* @var array
*/
var $config = array();
/**
* Timesheets config data
*
@ -89,12 +79,6 @@ class botimesheet extends so_sql
'2 years ago' => array(-2,0,0,0, -1,0,0,0),
'3 years ago' => array(-3,0,0,0, -2,0,0,0),
);
/**
* Reference to the (bo)link class instanciated at $GLOBALS['egw']->link
*
* @var bolink
*/
var $link;
/**
* Grants: $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP);
*
@ -120,9 +104,7 @@ class botimesheet extends so_sql
{
$this->so_sql(TIMESHEET_APP,'egw_timesheet');
$this->config =& CreateObject('phpgwapi.config',TIMESHEET_APP);
$this->config->read_repository();
$this->config_data =& $this->config->config_data;
$this->config_data = config::read(TIMESHEET_APP);
$this->quantity_sum = $this->config_data['quantity_sum'] == 'true';
if (isset($this->config_data['customfields']) && is_array($this->config_data['customfields']))
@ -143,13 +125,6 @@ class botimesheet extends so_sql
{
$GLOBALS['botimesheet'] =& $this;
}
// instanciation of link-class has to be after making us globaly availible, as it calls us to get the search_link
if (!is_object($GLOBALS['egw']->link))
{
$GLOBALS['egw']->link =& CreateObject('phpgwapi.bolink');
}
$this->link =& $GLOBALS['egw']->link;
$this->grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP);
}
@ -441,7 +416,7 @@ class botimesheet extends so_sql
$this->save_extra();
// notify the link-class about the update, as other apps may be subscribt to it
$this->link->notify_update(TIMESHEET_APP,$this->data['ts_id'],$this->data);
egw_link::notify_update(TIMESHEET_APP,$this->data['ts_id'],$this->data);
}
return $err;
}
@ -507,7 +482,7 @@ class botimesheet extends so_sql
$this->delete_extra($ts_id);
// delete all links to timesheet entry $ts_id
$this->link->unlink(0,TIMESHEET_APP,$ts_id);
egw_link::unlink(0,TIMESHEET_APP,$ts_id);
}
return $ret;
}
@ -588,7 +563,7 @@ class botimesheet extends so_sql
}
/**
* get title for an timesheet entry identified by $entry
* get title for a timesheet entry identified by $entry
*
* Is called as hook to participate in the linking
*
@ -613,6 +588,35 @@ class botimesheet extends so_sql
return date($format,$entry['ts_start']).': '.$entry['ts_title'];
}
/**
* get title for multiple timesheet entries identified by $ids
*
* Is called as hook to participate in the linking
*
* @param array $ids array with ts_id's
* @return array with titles, see link_title
*/
function link_titles( array $ids )
{
$titles = array();
if (($entries = $this->search(array('ts_id' => $ids),'ts_id,ts_title,ts_start')))
{
foreach($entries as $entry)
{
$titles[$entry['ts_id']] = $this->link_title($entry);
}
}
// we assume all not returned entries are not readable by the user, as we notify egw_link about all deletes
foreach($ids as $id)
{
if (!isset($titles[$id]))
{
$titles[$id] = false;
}
}
return $titles;
}
/**
* query timesheet for entries matching $pattern
*
@ -647,6 +651,7 @@ class botimesheet extends so_sql
return array(
'query' => TIMESHEET_APP.'.botimesheet.link_query',
'title' => TIMESHEET_APP.'.botimesheet.link_title',
'titles'=> TIMESHEET_APP.'.botimesheet.link_titles',
'view' => array(
'menuaction' => TIMESHEET_APP.'.uitimesheet.view',
),
@ -671,7 +676,7 @@ class botimesheet extends so_sql
*/
function cumulate($param)
{
$links = $this->link->get_3links(TIMESHEET_APP,'projectmanager',$param['pm_id']);
$links = egw_link::get_3links(TIMESHEET_APP,'projectmanager',$param['pm_id']);
$rows = array();
foreach($links as $link)

View File

@ -5,12 +5,11 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package timesheet
* @copyright (c) 2005/6 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.uietemplate.inc.php');
require_once('class.botimesheet.inc.php');
/**
@ -41,10 +40,8 @@ class uitimesheet extends botimesheet
{
$this->botimesheet();
$config =& CreateObject('phpgwapi.config',TIMESHEET_APP);
$config->read_repository();
$this->pm_integration = $config->config_data['pm_integration'];
$this->ts_viewtype = $config->config_data['ts_viewtype'];
$this->pm_integration = $this->config_data['pm_integration'];
$this->ts_viewtype = $this->config_data['ts_viewtype'];
// our javascript
// to be moved in a seperate file if rewrite is over
@ -167,17 +164,17 @@ class uitimesheet extends botimesheet
// update links accordingly
if ($this->data['pm_id'])
{
$this->link->link(TIMESHEET_APP,$content['link_to']['to_id'],'projectmanager',$this->data['pm_id']);
egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],'projectmanager',$this->data['pm_id']);
}
if ($this->data['old_pm_id'])
{
$this->link->unlink2(0,TIMESHEET_APP,$content['link_to']['to_id'],0,'projectmanager',$this->data['old_pm_id']);
egw_link::unlink2(0,TIMESHEET_APP,$content['link_to']['to_id'],0,'projectmanager',$this->data['old_pm_id']);
unset($this->data['old_pm_id']);
}
}
if (is_array($content['link_to']['to_id']) && count($content['link_to']['to_id']))
{
$this->link->link(TIMESHEET_APP,$this->data['ts_id'],$content['link_to']['to_id']);
egw_link::link(TIMESHEET_APP,$this->data['ts_id'],$content['link_to']['to_id']);
}
}
$js = "opener.location.href='".$GLOBALS['egw']->link('/index.php',array(
@ -192,9 +189,9 @@ class uitimesheet extends botimesheet
if (!is_array($content['link_to']['to_id'])) // set links again, so new entry gets the same links as the existing one
{
$content['link_to']['to_id'] = 0;
foreach($this->link->get_links(TIMESHEET_APP,$this->data['ts_id'],'!'.$this->link->vfs_appname) as $link)
foreach(egw_link::get_links(TIMESHEET_APP,$this->data['ts_id'],'!'.egw_link::vfs_appname) as $link)
{
$this->link->link(TIMESHEET_APP,$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']);
egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']);
}
}
// create a new entry
@ -258,7 +255,7 @@ class uitimesheet extends botimesheet
$link_id = $link_ids[$n];
if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // gard against XSS
{
$this->link->link(TIMESHEET_APP,$content['link_to']['to_id'],$link_app,$link_id);
egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link_app,$link_id);
switch ($link_app)
{
case 'projectmanager':
@ -266,7 +263,7 @@ class uitimesheet extends botimesheet
break;
case 'infolog':
// a preserved title blur is only set for other (non-project) links, it stays with Save&New!
$preserv['ts_title_blur'] = $this->link->title('infolog',$link_id);
$preserv['ts_title_blur'] = egw_link::title('infolog',$link_id);
break;
}
}
@ -274,7 +271,7 @@ class uitimesheet extends botimesheet
}
elseif ($this->data['ts_id'])
{
$links = $this->link->get_links(TIMESHEET_APP,$this->data['ts_id'],'projectmanager');
$links = egw_link::get_links(TIMESHEET_APP,$this->data['ts_id'],'projectmanager');
}
// make all linked projects availible for the pm-pricelist widget, to be able to choose prices from all
$content['all_pm_ids'] = array_values($links);
@ -290,7 +287,7 @@ class uitimesheet extends botimesheet
}
if ($content['pm_id'])
{
$preserv['ts_project_blur'] = $content['ts_project_blur'] = $this->link->title('projectmanager',$content['pm_id']);
$preserv['ts_project_blur'] = $content['ts_project_blur'] = egw_link::title('projectmanager',$content['pm_id']);
}
if ($this->pm_integration == 'full')
{
@ -414,7 +411,7 @@ class uitimesheet extends botimesheet
// PM project filter for the PM integration
if ((string)$query['col_filter']['pm_id'] != '')
{
//$query['col_filter']['ts_id'] = $this->link->get_links('projectmanager',$query['col_filter']['pm_id'],'timesheet');
//$query['col_filter']['ts_id'] = egw_link::get_links('projectmanager',$query['col_filter']['pm_id'],'timesheet');
$query['col_filter']['ts_id'] = $this->get_ts_links($query['col_filter']['pm_id']);
if (!$query['col_filter']['ts_id']) $query['col_filter']['ts_id'] = 0;
}
@ -503,23 +500,24 @@ class uitimesheet extends botimesheet
}
$total = parent::get_rows($query,$rows,$readonlys);
$ids = array();
foreach($rows as $row)
{
$ids[] = $row['ts_id'];
}
if ($id_only)
{
foreach($rows as $n => $row)
{
$rows[$n] = $row['ts_id'];
}
$rows = $ids;
return $this->total; // no need to set other fields or $readonlys
}
$links = egw_link::get_links_multiple(TIMESHEET_APP,$ids);
unset($query['col_filter'][0]);
$readonlys = array();
$have_cats = false;
foreach($rows as $n => $val)
foreach($rows as &$row)
{
$row =& $rows[$n];
if ($row['cat_id']) $have_cats = true;
$row['class'] = 'row';
@ -561,16 +559,17 @@ class uitimesheet extends botimesheet
{
unset($row['ts_project']); // dont need or want to show it
}
else
elseif ($links[$row['ts_id']])
{
if (($links = $this->link->get_links(TIMESHEET_APP,$row['ts_id'],'projectmanager')))
foreach($links[$row['ts_id']] as $link)
{
$row['ts_link'] = array(
'app' => 'projectmanager',
'id' => array_shift($links),
);
if ($link['app'] == 'projectmanager')
{
$row['ts_link'] = $link;
$row['ts_link']['title'] = $row['ts_project'];
break;
}
}
$row['ts_link']['title'] = $row['ts_project'];
}
if (!$query['filter2'])
{

View File

@ -2,7 +2,7 @@
/**
* eGroupWare - eTemplates for Application timesheet
* http://www.egroupware.org
* generated by soetemplate::dump4setup() 2007-07-10 09:39
* generated by soetemplate::dump4setup() 2008-03-09 08:53
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package timesheet
@ -75,6 +75,8 @@ $templ_data[] = array('name' => 'timesheet.index','template' => '','lang' => '',
$templ_data[] = array('name' => 'timesheet.index','template' => '','lang' => '','group' => '0','version' => '1.3.002','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:6:{i:0;a:3:{s:2:"h1";s:6:",!@msg";s:2:"h2";s:2:",1";s:2:"c4";s:7:"noPrint";}i:1;a:1:{s:1:"A";a:5:{s:4:"type";s:5:"label";s:4:"span";s:13:"all,redItalic";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";s:5:"align";s:6:"center";}}i:2;a:1:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:2:{s:4:"type";s:8:"template";s:4:"name";s:5:"dates";}i:2;a:3:{s:4:"type";s:8:"template";s:4:"name";s:3:"add";s:5:"align";s:5:"right";}}}i:3;a:1:{s:1:"A";a:3:{s:4:"type";s:9:"nextmatch";s:4:"name";s:2:"nm";s:4:"size";s:20:"timesheet.index.rows";}}i:4;a:1:{s:1:"A";a:4:{s:4:"type";s:6:"button";s:5:"label";s:3:"Add";s:4:"name";s:3:"add";s:7:"onclick";s:163:"window.open(egw::link(\'/index.php\',\'menuaction=timesheet.uitimesheet.edit\'),\'_blank\',\'dependent=yes,width=600,height=400,scrollbars=yes,status=yes\'); return false;";}}i:5;a:1:{s:1:"A";a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Export";s:7:"onclick";s:33:"timesheet_export(); return false;";s:4:"name";s:6:"export";}}}s:4:"rows";i:5;s:4:"cols";i:1;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '','modified' => '1164373176',);
$templ_data[] = array('name' => 'timesheet.index','template' => '','lang' => '','group' => '0','version' => '1.5.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:6:{i:0;a:4:{s:2:"h1";s:6:",!@msg";s:2:"h2";s:2:",1";s:2:"c4";s:7:"noPrint";s:2:"h5";s:2:",1";}i:1;a:1:{s:1:"A";a:5:{s:4:"type";s:5:"label";s:4:"span";s:13:"all,redItalic";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";s:5:"align";s:6:"center";}}i:2;a:1:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:2:{s:4:"type";s:8:"template";s:4:"name";s:5:"dates";}i:2;a:3:{s:4:"type";s:8:"template";s:4:"name";s:3:"add";s:5:"align";s:5:"right";}}}i:3;a:1:{s:1:"A";a:3:{s:4:"type";s:9:"nextmatch";s:4:"name";s:2:"nm";s:4:"size";s:20:"timesheet.index.rows";}}i:4;a:1:{s:1:"A";a:4:{s:4:"type";s:6:"button";s:5:"label";s:3:"Add";s:4:"name";s:3:"add";s:7:"onclick";s:163:"window.open(egw::link(\'/index.php\',\'menuaction=timesheet.uitimesheet.edit\'),\'_blank\',\'dependent=yes,width=600,height=400,scrollbars=yes,status=yes\'); return false;";}}i:5;a:1:{s:1:"A";a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Export";s:7:"onclick";s:33:"timesheet_export(); return false;";s:4:"name";s:6:"export";}}}s:4:"rows";i:5;s:4:"cols";i:1;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '','modified' => '1164373176',);
$templ_data[] = array('name' => 'timesheet.index.add','template' => '','lang' => '','group' => '0','version' => '1.3.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:6:"button";s:5:"label";s:3:"Add";s:4:"name";s:3:"add";s:7:"onclick";s:163:"window.open(egw::link(\'/index.php\',\'menuaction=timesheet.uitimesheet.edit\'),\'_blank\',\'dependent=yes,width=600,height=400,scrollbars=yes,status=yes\'); return false;";}}','size' => '','style' => '','modified' => '1158042543',);
$templ_data[] = array('name' => 'timesheet.index.dates','template' => '','lang' => '','group' => '0','version' => '1.2.001','data' => 'a:1:{i:0;a:10:{s:4:"type";s:4:"hbox";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:1;s:4:"cols";i:1;s:4:"size";s:1:"4";i:1;a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"Start";}i:2;a:2:{s:4:"type";s:4:"date";s:4:"name";s:9:"startdate";}i:3;a:2:{s:4:"type";s:5:"label";s:5:"label";s:3:"End";}i:4;a:3:{s:4:"type";s:4:"date";s:4:"name";s:7:"enddate";s:4:"help";s:30:"Leave it empty for a full week";}s:4:"span";s:12:",custom_hide";}}','size' => '','style' => '.custom_hide { visibility: hidden; }','modified' => '1142973260',);

View File

@ -90,7 +90,7 @@
</rows>
</grid>
</template>
<template id="timesheet.index" template="" lang="" group="0" version="1.3.002">
<template id="timesheet.index" template="" lang="" group="0" version="1.5.001">
<grid width="100%">
<columns>
<column/>
@ -111,7 +111,7 @@
<row class="noPrint">
<button label="Add" id="add" onclick="window.open(egw::link('/index.php','menuaction=timesheet.uitimesheet.edit'),'_blank','dependent=yes,width=600,height=400,scrollbars=yes,status=yes'); return false;"/>
</row>
<row>
<row disabled="1">
<button label="Export" onclick="timesheet_export(); return false;" id="export"/>
</row>
</rows>