mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
using new egw_link class and reading all links of the whole index page in one go
This commit is contained in:
parent
37c3933e0b
commit
50f5c1b116
@ -27,12 +27,6 @@ class boinfolog
|
||||
* @var soinfolog
|
||||
*/
|
||||
var $so;
|
||||
/**
|
||||
* Instance of the link class
|
||||
*
|
||||
* @var bolink
|
||||
*/
|
||||
var $link;
|
||||
var $vfs;
|
||||
var $vfs_basedir='/infolog';
|
||||
var $link_pathes = array();
|
||||
@ -299,7 +293,7 @@ class boinfolog
|
||||
|
||||
if (is_null($link_types))
|
||||
{
|
||||
$link_types = array_keys($this->link->app_list());
|
||||
$link_types = array_keys(egw_link::app_list());
|
||||
$link_types[] = 'link-entry';
|
||||
}
|
||||
return $link_types;
|
||||
@ -383,10 +377,21 @@ class boinfolog
|
||||
{
|
||||
//echo "<p>boinfolog::link_id2from(subject='$info[info_subject]', link_id='$info[info_link_id]', from='$info[info_from]', not_app='$not_app', not_id='$not_id')";
|
||||
if ($info['info_link_id'] > 0 &&
|
||||
($link = $this->link->get_link($info['info_link_id'])) !== False)
|
||||
(isset($info['links']) && ($link = $info['links'][$info['info_link_id']]) || // use supplied links info
|
||||
!isset($info['links']) && ($link = egw_link::get_link($info['info_link_id'])) !== False))
|
||||
{
|
||||
$nr = $link['link_app1'] == 'infolog' && $link['link_id1'] == $info['info_id'] ? '2' : '1';
|
||||
$title = $this->link->title($link['link_app'.$nr],$link['link_id'.$nr]);
|
||||
if (isset($info['links']))
|
||||
{
|
||||
$app = $link['app'];
|
||||
$id = $link['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$nr = $link['link_app1'] == 'infolog' && $link['link_id1'] == $info['info_id'] ? '2' : '1';
|
||||
$app = $link['link_app'.$nr];
|
||||
$id = $link['link_id'.$nr];
|
||||
}
|
||||
$title = egw_link::title($app,$id);
|
||||
|
||||
if ((string)$info['info_custom_from'] === '') // old entry
|
||||
{
|
||||
@ -397,33 +402,31 @@ class boinfolog
|
||||
$info['info_from'] = '';
|
||||
$info['info_custom_from'] = 0;
|
||||
}
|
||||
if ($link['link_app'.$nr] == $not_app && $link['link_id'.$nr] == $not_id)
|
||||
if ($app == $not_app && $id == $not_id)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
$info['info_link'] = array(
|
||||
'app' => $link['link_app'.$nr],
|
||||
'id' => $link['link_id'.$nr],
|
||||
'app' => $app,
|
||||
'id' => $id,
|
||||
'title' => (!empty($info['info_from']) ? $info['info_from'] : $title),
|
||||
);
|
||||
$info['info_contact'] = $link['link_app'.$nr].':'.$link['link_id'.$nr];
|
||||
$info['info_contact'] = $app.':'.$id;
|
||||
|
||||
//echo " title='$title'</p>\n";
|
||||
return $info['blur_title'] = $title;
|
||||
}
|
||||
else
|
||||
{
|
||||
$info['info_link'] = array('title' => $info['info_from']);
|
||||
$info['info_link_id'] = 0; // link might have been deleted
|
||||
$info['info_custom_from'] = (int)!!$info['info_from'];
|
||||
}
|
||||
$info['info_link'] = array('title' => $info['info_from']);
|
||||
$info['info_link_id'] = 0; // link might have been deleted
|
||||
$info['info_custom_from'] = (int)!!$info['info_from'];
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a subject from a description: truncate it and add ' ...'
|
||||
*/
|
||||
function subject_from_des($des)
|
||||
static function subject_from_des($des)
|
||||
{
|
||||
return substr($des,0,60).' ...';
|
||||
}
|
||||
@ -544,13 +547,13 @@ class boinfolog
|
||||
|
||||
$this->so->write($deleted);
|
||||
|
||||
$this->link->unlink(0,'infolog',$info_id,'','!file'); // keep the file attachments, only delete the rest
|
||||
egw_link::unlink(0,'infolog',$info_id,'','!file'); // keep the file attachments, only delete the rest
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->so->delete($info_id,false); // we delete the children via bo to get all notifications!
|
||||
|
||||
$this->link->unlink(0,'infolog',$info_id);
|
||||
egw_link::unlink(0,'infolog',$info_id);
|
||||
}
|
||||
if ($info['info_status'] != 'deleted') // dont notify of final purge of already deleted items
|
||||
{
|
||||
@ -741,7 +744,7 @@ class boinfolog
|
||||
$this->update_customfield_links($values,$old);
|
||||
|
||||
// notify the link-class about the update, as other apps may be subscribt to it
|
||||
$this->link->notify_update('infolog',$info_id,$values);
|
||||
egw_link::notify_update('infolog',$info_id,$values);
|
||||
|
||||
// send email notifications and do the history logging
|
||||
require_once(EGW_INCLUDE_ROOT.'/infolog/inc/class.infolog_tracking.inc.php');
|
||||
@ -782,7 +785,7 @@ class boinfolog
|
||||
$app = $data['type'];
|
||||
$id = $old['#'.$name];
|
||||
}
|
||||
$this->link->unlink(false,'infolog',$values['info_id'],'',$app,$id);
|
||||
egw_link::unlink(false,'infolog',$values['info_id'],'',$app,$id);
|
||||
}
|
||||
if ($data['type'] == 'link-entry')
|
||||
{
|
||||
@ -795,7 +798,7 @@ class boinfolog
|
||||
}
|
||||
if ($id) // create new link, does nothing for already existing links
|
||||
{
|
||||
$this->link->link('infolog',$values['info_id'],$app,$id);
|
||||
egw_link::link('infolog',$values['info_id'],$app,$id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -923,7 +926,7 @@ class boinfolog
|
||||
// create the rest a "ordinary" links
|
||||
foreach ($contacts as $contact)
|
||||
{
|
||||
$this->link->link('infolog',$info['link_to']['to_id'],'addressbook',$contact['id']);
|
||||
egw_link::link('infolog',$info['link_to']['to_id'],'addressbook',$contact['id']);
|
||||
}
|
||||
}
|
||||
if (is_array($_attachments))
|
||||
@ -932,7 +935,7 @@ class boinfolog
|
||||
{
|
||||
if(is_readable($attachment['tmp_name']))
|
||||
{
|
||||
$this->link->link('infolog',$info['link_to']['to_id'],'file',$attachment);
|
||||
egw_link::link('infolog',$info['link_to']['to_id'],'file',$attachment);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -950,6 +953,7 @@ class boinfolog
|
||||
return array(
|
||||
'query' => 'infolog.boinfolog.link_query',
|
||||
'title' => 'infolog.boinfolog.link_title',
|
||||
'titles' => 'infolog.boinfolog.link_titles',
|
||||
'view' => array(
|
||||
'menuaction' => 'infolog.uiinfolog.index',
|
||||
'action' => 'sp'
|
||||
@ -984,7 +988,28 @@ class boinfolog
|
||||
return $info;
|
||||
}
|
||||
return !empty($info['info_subject']) ? $info['info_subject'] :
|
||||
$this->subject_from_des($info['info_descr']);
|
||||
self::subject_from_des($info['info_descr']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return multiple titles fetched by a single query
|
||||
*
|
||||
* @param array $ids
|
||||
*/
|
||||
function link_titles( array $ids )
|
||||
{
|
||||
$titles = array();
|
||||
foreach($this->search(array(
|
||||
'col_filter' => array('info_id' => $ids),
|
||||
)) as $info)
|
||||
{
|
||||
$titles[$info['id']] = $this->link_title($info);
|
||||
}
|
||||
foreach(array_diff($ids,array_keys($titles)) as $id)
|
||||
{
|
||||
$titles[$id] = false; // we assume every not returned entry to be not readable, as we notify the link class about all deletes
|
||||
}
|
||||
return $titles;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1068,7 +1093,7 @@ class boinfolog
|
||||
}*/
|
||||
$title = ($do_events?$GLOBALS['egw']->common->formattime(adodb_date('H',$info['info_startdate']),adodb_date('i',$info['info_startdate'])).' ':'').
|
||||
$info['info_subject'];
|
||||
$view = $this->link->view('infolog',$info['info_id']);
|
||||
$view = egw_link::view('infolog',$info['info_id']);
|
||||
$content=array();
|
||||
foreach($icons = array(
|
||||
$info['info_type'] => 'infolog',
|
||||
|
@ -31,12 +31,6 @@ class soinfolog // DB-Layer
|
||||
* @var egw_db
|
||||
*/
|
||||
var $db;
|
||||
/**
|
||||
* Instance of the solink class
|
||||
*
|
||||
* @var solink
|
||||
*/
|
||||
var $links;
|
||||
/**
|
||||
* Grants from other users
|
||||
*
|
||||
@ -106,8 +100,6 @@ class soinfolog // DB-Layer
|
||||
$this->grants =& $grants;
|
||||
$this->user = $GLOBALS['egw_info']['user']['account_id'];
|
||||
|
||||
$this->links =& new solink();
|
||||
|
||||
$this->tz_offset = $GLOBALS['egw_info']['user']['preferences']['common']['tz_offset'];
|
||||
$this->soextra =& CreateObject('etemplate.so_sql');
|
||||
$this->soextra->so_sql('infolog',$this->extra_table);
|
||||
@ -459,7 +451,7 @@ class soinfolog // DB-Layer
|
||||
}
|
||||
$this->db->delete($this->info_table,array('info_id'=>$info_id),__LINE__,__FILE__);
|
||||
$this->db->delete($this->extra_table,array('info_id'=>$info_id),__LINE__,__FILE__);
|
||||
$this->links->unlink(0,'infolog',$info_id);
|
||||
egw_link::unlink(0,'infolog',$info_id);
|
||||
|
||||
if ($this->data['info_id'] == $info_id)
|
||||
{
|
||||
@ -661,7 +653,7 @@ class soinfolog // DB-Layer
|
||||
|
||||
if ($action != '')
|
||||
{
|
||||
$links = $this->links->get_links($action=='sp'?'infolog':$action,$action_id,'infolog');
|
||||
$links = egw_link::get_links($action=='sp'?'infolog':$action,$action_id,'infolog');
|
||||
|
||||
if (count($links))
|
||||
{
|
||||
|
@ -40,12 +40,6 @@ class uiinfolog
|
||||
* @var boinfolog
|
||||
*/
|
||||
var $bo;
|
||||
/**
|
||||
* reference to instance of the link-class of bo
|
||||
*
|
||||
* @var bolink
|
||||
*/
|
||||
var $link;
|
||||
/**
|
||||
* instance of the etemplate class
|
||||
*
|
||||
@ -125,10 +119,8 @@ class uiinfolog
|
||||
{
|
||||
$this->bo =& new boinfolog();
|
||||
|
||||
$this->link = &$this->bo->link;
|
||||
|
||||
$this->tmpl =& CreateObject('etemplate.etemplate');
|
||||
$this->html =& $this->tmpl->html;
|
||||
$this->tmpl = new etemplate();
|
||||
$this->html = $this->tmpl->html;
|
||||
|
||||
$this->user = $GLOBALS['egw_info']['user']['account_id'];
|
||||
|
||||
@ -207,15 +199,15 @@ class uiinfolog
|
||||
|
||||
if (($show_links != 'none' && $show_links != 'no_describtion' ||
|
||||
$this->prefs['show_times'] || isset($GLOBALS['egw_info']['user']['apps']['timesheet'])) &&
|
||||
($links = $this->link->get_links('infolog',$info['info_id'])))
|
||||
(isset($info['links']) || ($info['links'] = egw_link::get_links('infolog',$info['info_id']))))
|
||||
{
|
||||
$timesheets = array();
|
||||
foreach ($links as $link)
|
||||
foreach ($info['links'] as $link)
|
||||
{
|
||||
if ($show_links != 'none' && $show_links != 'no_describtion' &&
|
||||
$link['link_id'] != $info['info_link_id'] &&
|
||||
($link['app'] != $action || $link['id'] != $action_id) &&
|
||||
($show_links == 'all' || ($show_links == 'links') === ($link['app'] != $this->link->vfs_appname)))
|
||||
($show_links == 'all' || ($show_links == 'links') === ($link['app'] != egw_link::VFS_APPNAME)))
|
||||
{
|
||||
$info['filelinks'][] = $link;
|
||||
}
|
||||
@ -225,7 +217,7 @@ class uiinfolog
|
||||
}
|
||||
if ($link['app'] == 'timesheet') $timesheets[] = $link['id'];
|
||||
|
||||
if ($link['app'] != 'timesheet' && $link['app'] != $this->link->vfs_appname)
|
||||
if ($link['app'] != 'timesheet' && $link['app'] != egw_link::VFS_APPNAME)
|
||||
{
|
||||
$info['extra_links'] .= '&link_app[]='.$link['app'].'&link_id[]='.$link['id'];
|
||||
}
|
||||
@ -353,10 +345,10 @@ class uiinfolog
|
||||
// do we need to query the cf's
|
||||
$query['custom_fields'] = $this->bo->customfields && (!$columselection || in_array('customfields',$columselection));
|
||||
|
||||
$ids = $this->bo->search($query);
|
||||
if (!is_array($ids))
|
||||
$infos = $this->bo->search($query);
|
||||
if (!is_array($infos))
|
||||
{
|
||||
$ids = array( );
|
||||
$infos = array( );
|
||||
}
|
||||
$details = $query['filter2'] == 'all';
|
||||
// add a '-details' to the name of the columnselection pref
|
||||
@ -373,11 +365,17 @@ class uiinfolog
|
||||
// set old show_times pref, that get_info calculates the cumulated time of the timesheets
|
||||
$this->prefs['show_times'] = strpos($this->prefs['nextmatch-'.$query['columnselection_pref']],'info_used_time_info_planned_time') !== false;
|
||||
|
||||
// query all links in one go
|
||||
if ($infos && !$query['csv_export'])
|
||||
{
|
||||
$links = bolink::get_links_multiple('infolog',array_keys($infos));
|
||||
}
|
||||
$readonlys = $rows = array();
|
||||
foreach($ids as $id => $info)
|
||||
foreach($infos as $id => $info)
|
||||
{
|
||||
if (!$query['csv_export'])
|
||||
{
|
||||
$info['links'] =& $links[$id];
|
||||
$info = $this->get_info($info,$readonlys,$query['action'],$query['action_id'],$query['filter2'],$details);
|
||||
|
||||
if (!$query['filter2'] && $this->prefs['show_links'] == 'no_describtion' ||
|
||||
@ -388,6 +386,8 @@ class uiinfolog
|
||||
}
|
||||
$rows[] = $info;
|
||||
}
|
||||
unset($links);
|
||||
|
||||
if ($query['cat_id']) $rows['no_cat_id'] = true;
|
||||
if ($query['no_actions']) $rows['no_actions'] = true;
|
||||
$rows['no_timesheet'] = !isset($GLOBALS['egw_info']['user']['apps']['timesheet']);
|
||||
@ -431,7 +431,7 @@ class uiinfolog
|
||||
{
|
||||
$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.lang($this->filters[$query['filter']]);
|
||||
}
|
||||
if ($query['action'] && ($title = $query['action_title'] ? $query['action_title'] : $this->link->title($query['action'],$query['action_id'])))
|
||||
if ($query['action'] && ($title = $query['action_title'] ? $query['action_title'] : egw_link::title($query['action'],$query['action_id'])))
|
||||
{
|
||||
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.$title;
|
||||
}
|
||||
@ -784,8 +784,8 @@ class uiinfolog
|
||||
{
|
||||
$old_link_id = (int)$content['info_link_id'];
|
||||
list($app,$id) = explode(':',$content['info_contact']);
|
||||
$content['info_link_id'] = (int)($info_link_id = $this->link->link('infolog',$content['link_to']['to_id'],$app,$id));
|
||||
if ($old_link_id && $old_link_id != $content['info_link_id']) $this->link->unlink($old_link_id);
|
||||
$content['info_link_id'] = (int)($info_link_id = egw_link::link('infolog',$content['link_to']['to_id'],$app,$id));
|
||||
if ($old_link_id && $old_link_id != $content['info_link_id']) egw_link::unlink($old_link_id);
|
||||
}
|
||||
if (is_array($content['link_to']['to_id']) && count($content['link_to']['to_id']))
|
||||
{
|
||||
@ -822,7 +822,7 @@ class uiinfolog
|
||||
if ($content['pm_id'])
|
||||
{
|
||||
//echo "<p>this->link->link('infolog',{$content['link_to']['to_id']},'projectmanager',{$content['pm_id']});</p>";
|
||||
$this->link->link('infolog',$content['link_to']['to_id'],'projectmanager',$content['pm_id']);
|
||||
egw_link::link('infolog',$content['link_to']['to_id'],'projectmanager',$content['pm_id']);
|
||||
// making the project the selected link, if no other link selected
|
||||
if (!$info_link_id || $info_link_id == 'projectmanager:'.$content['old_pm_id'])
|
||||
{
|
||||
@ -832,7 +832,7 @@ class uiinfolog
|
||||
if ($content['old_pm_id'])
|
||||
{
|
||||
//echo "<p>this->link->unlink2(0,infolog,{$content['link_to']['to_id']},0,'projectmanager',{$content['old_pm_id']});</p>\n";
|
||||
$this->link->unlink2(0,infolog,$content['link_to']['to_id'],0,'projectmanager',$content['old_pm_id']);
|
||||
egw_link::unlink2(0,infolog,$content['link_to']['to_id'],0,'projectmanager',$content['old_pm_id']);
|
||||
$content['old_pm_id'] = $content['pm_id'];
|
||||
}
|
||||
}
|
||||
@ -840,13 +840,13 @@ class uiinfolog
|
||||
if ($info_id && is_array($content['link_to']['to_id']) && count($content['link_to']['to_id']))
|
||||
{
|
||||
//echo "<p>writing links for new entry $info_id</p>\n"; _debug_array($content['link_to']['to_id']);
|
||||
$this->link->link('infolog',$info_id,$content['link_to']['to_id']);
|
||||
egw_link::link('infolog',$info_id,$content['link_to']['to_id']);
|
||||
$content['link_to']['to_id'] = $info_id;
|
||||
}
|
||||
if ($info_link_id && strpos($info_link_id,':') !== false) // updating info_link_id if necessary
|
||||
{
|
||||
list($app,$id) = explode(':',$info_link_id);
|
||||
$link = $this->link->get_link('infolog',$info_id,$app,$id);
|
||||
$link = egw_link::get_link('infolog',$info_id,$app,$id);
|
||||
if ((int) $content['info_link_id'] != (int) $link['link_id'])
|
||||
{
|
||||
$content['info_link_id'] = $link['link_id'];
|
||||
@ -929,7 +929,7 @@ class uiinfolog
|
||||
case 'datetime': $set_startdate = $this->bo->user_time_now; break;
|
||||
case 'empty': $set_startdate = 0; break;
|
||||
}
|
||||
if ((int)$content['info_link_id'] > 0 && !$this->link->get_link($content['info_link_id']))
|
||||
if ((int)$content['info_link_id'] > 0 && !egw_link::get_link($content['info_link_id']))
|
||||
{
|
||||
$content['info_link_id'] = 0; // link has been deleted
|
||||
if (!$content['info_custom_link']) $content['info_from'] = '';
|
||||
@ -993,10 +993,10 @@ class uiinfolog
|
||||
switch ($action)
|
||||
{
|
||||
case 'sp':
|
||||
$links = $this->link->get_links('infolog',$parent['info_id'],'!'.$this->link->vfs_appname);
|
||||
$links = egw_link::get_links('infolog',$parent['info_id'],'!'.egw_link::VFS_APPNAME);
|
||||
foreach($links as $link)
|
||||
{
|
||||
$link_id = $this->link->link('infolog',$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']);
|
||||
$link_id = egw_link::link('infolog',$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']);
|
||||
|
||||
if ($parent['info_link_id'] == $link['link_id'])
|
||||
{
|
||||
@ -1012,14 +1012,14 @@ class uiinfolog
|
||||
case 'calendar':
|
||||
default: // to allow other apps to participate
|
||||
$content['info_contact'] = $action.':'.$action_id;
|
||||
$content['blur_title'] = $this->link->title($action,$action_id);
|
||||
$content['blur_title'] = egw_link::title($action,$action_id);
|
||||
|
||||
case '':
|
||||
if ($info_id)
|
||||
{
|
||||
if (!isset($pm_links))
|
||||
{
|
||||
$pm_links = $this->link->get_links('infolog',$info_id,'projectmanager');
|
||||
$pm_links = egw_link::get_links('infolog',$info_id,'projectmanager');
|
||||
}
|
||||
break; // normal edit
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user