hook_home, plus some filters and preferences added

This commit is contained in:
Ralf Becker 2001-07-15 21:42:17 +00:00
parent 31b61cc52a
commit 58783d5464
5 changed files with 130 additions and 18 deletions

View File

@ -51,8 +51,8 @@
'both' => 'both' ), 'both' => 'both' ),
'type' => array( 'type' => array(
'task' => 'task','phone' => 'phone','note' => 'note', 'task' => 'task','phone' => 'phone','note' => 'note',
'confirm' => 'confirm','reject' => 'reject','email' => 'email', /* 'confirm' => 'confirm','reject' => 'reject','email' => 'email',
'fax' => 'fax' ) 'fax' => 'fax' no implemented so far */ )
); );
$this->so = CreateObject('infolog.soinfolog'); $this->so = CreateObject('infolog.soinfolog');
$this->data = &$this->so->data; $this->data = &$this->so->data;

View File

@ -18,6 +18,7 @@
var $db,$db2; var $db,$db2;
var $grants; var $grants;
var $data = array( ); var $data = array( );
var $filters = array( );
function soinfolog( $info_id = 0) function soinfolog( $info_id = 0)
{ {
@ -87,12 +88,16 @@
} }
// sql to be AND into a query to ensure ACL is respected (incl. _PRIVATE) // sql to be AND into a query to ensure ACL is respected (incl. _PRIVATE)
// filter: none - list all entrys user have rights to see // filter: none|all - list all entrys user have rights to see
// private - list only his personal entrys // private|own - list only his personal entrys
// (incl. those he is responsible for !!!) // (incl. those he is responsible for !!!)
function aclFilter($filter = 'none') function aclFilter($filter = 'none')
{ {
global $phpgw_info; global $phpgw_info;
ereg('.*(own|privat|all|none).*',$filter,$vars);
$filter = $vars[1];
if (isset($this->acl_filter[$filter])) if (isset($this->acl_filter[$filter]))
{ {
return $this->acl_filter[$filter]; // used cached filter if found return $this->acl_filter[$filter]; // used cached filter if found
@ -122,7 +127,7 @@
$filtermethod = " (info_owner=$user"; // user has all rights $filtermethod = " (info_owner=$user"; // user has all rights
// private: own entries plus the one user is responsible for // private: own entries plus the one user is responsible for
if ($filter == 'private') if ($filter == 'private' || $filter == 'own')
{ {
$filtermethod .= " OR info_responsible=$user AND (info_access='public'".($has_private_access?" OR $has_private_access":'').')'; $filtermethod .= " OR info_responsible=$user AND (info_access='public'".($has_private_access?" OR $has_private_access":'').')';
} }
@ -139,11 +144,40 @@
} }
$filtermethod .= ') '; $filtermethod .= ') ';
// echo "<p>aclFilter('$filter')(user='$user') = '$filtermethod'</p>";
return $this->acl_filter[$filter] = $filtermethod; // cache the filter return $this->acl_filter[$filter] = $filtermethod; // cache the filter
} }
function statusFilter($filter = '')
{
ereg('.*(done|open|offer).*',$filter,$vars);
$filter = $vars[1];
switch ($filter)
{
case 'done': return " AND info_status IN ('done','billed')";
case 'open': return " AND NOT (info_status IN ('done','billed'))";
case 'offer': return " AND info_status = 'offer'";
}
return '';
}
function dateFilter($filter = '')
{
ereg('.*(upcoming|today|overdue).*',$filter,$vars);
$filter = $vars[1];
$now = getdate(time());
$tomorrow = mktime(0,0,0,$now['mon'],$now['mday']+1,$now['year']);
switch ($filter)
{
case 'upcoming': return " AND info_startdate >= '$tomorrow'";
case 'today': return " AND info_startdate < '$tomorrow'";
case 'overdue': return " AND (info_enddate != 0 AND info_enddate < '$tomorrow')";
}
return '';
}
function init() function init()
{ {
global $phpgw_info; global $phpgw_info;
@ -236,11 +270,10 @@
{ {
$ordermethod = 'order by info_datecreated desc'; // newest first $ordermethod = 'order by info_datecreated desc'; // newest first
} }
if (!$filter)
{
$filter = 'none';
}
$filtermethod = $this->aclFilter($filter); $filtermethod = $this->aclFilter($filter);
$filtermethod .= $this->statusFilter($filter);
$filtermethod .= $this->dateFilter($filter);
// echo "<p>filtermethod='$filtermethod'</p>";
if ($cat_id) if ($cat_id)
{ {

View File

@ -59,6 +59,18 @@
'offer' => 'offer.gif', 'offer_alt' => 'offer' ) 'offer' => 'offer.gif', 'offer_alt' => 'offer' )
); );
$this->filters = array(
'none' => lang('no Filter'),
'done' => lang('done'),
'own' => lang('own'),
'own+open+today' => lang('own open'),
'own+open+overdue'=> lang('own overdue'),
'own+upcoming' => lang('own upcoming'),
'open+today' => lang('open'),
'open+overdue' => lang('overdue'),
'upcoming' => lang('upcoming'),
);
$this->html = CreateObject('infolog.html'); $this->html = CreateObject('infolog.html');
$this->template = CreateObject('phpgwapi.Template', $this->template = CreateObject('phpgwapi.Template',
$phpgw->common->get_tpl_dir('infolog')); $phpgw->common->get_tpl_dir('infolog'));
@ -274,6 +286,11 @@
if ($cat_filter) $cat_id = $cat_filter; if ($cat_filter) $cat_id = $cat_filter;
if (!$filter)
{
$filter = $phpgw_info['user']['preferences']['infolog']['defaultFilter'];
}
$hidden_vars = array( $hidden_vars = array(
'sort' => $sort,'order' => $order,'query' => $query, 'sort' => $sort,'order' => $order,'query' => $query,
'start' => $start,'filter' => $filter,'cat_id' => $cat_id 'start' => $start,'filter' => $filter,'cat_id' => $cat_id
@ -304,9 +321,13 @@
$this->bo->addr2name($addr)); $this->bo->addr2name($addr));
break; break;
default: default:
$t->set_var(lang_info_action,lang('Info Log')); if ($filter && $filter != 'none')
{
$filter_name = ': '.$this->filters[ $filter ];
}
$t->set_var(lang_info_action,lang('Info Log').$filter_name);
break; break;
} }
$t->set_var($this->setStyleSheet( )); $t->set_var($this->setStyleSheet( ));
if (!$for_include) if (!$for_include)
@ -344,8 +365,6 @@
$t->set_var(h_lang_action,lang('Action')); $t->set_var(h_lang_action,lang('Action'));
// -------------- end header declaration ----------------- // -------------- end header declaration -----------------
if (!$filter) $filter = 'none';
$ids = $this->bo->readIdArray($order,$sort,$filter,$cat_id,$query, $ids = $this->bo->readIdArray($order,$sort,$filter,$cat_id,$query,
$action,$addr_id,$proj_id,$info_id, $action,$addr_id,$proj_id,$info_id,
$ordermethod,$start,$total); $ordermethod,$start,$total);
@ -388,7 +407,7 @@
$t->set_block('info_list_t','cat_selection','cat_selectionhandle'); $t->set_block('info_list_t','cat_selection','cat_selectionhandle');
if (!$for_include || $total > $maxmatchs || if (!$for_include || $total > $maxmatchs ||
$query || $filter != 'none' || $cat_id) $query || $cat_id)
{ {
$t->parse('cat_selectionhandle','cat_selection',True); $t->parse('cat_selectionhandle','cat_selection',True);
@ -403,8 +422,13 @@
{ {
$q_string .= "&cat_id=$cat_id"; $q_string .= "&cat_id=$cat_id";
} }
while (list($f,$lang) = each ($this->filters))
{
$filters[] = array( $f,$lang );
}
$next_matchs = $this->nextmatchs->show_tpl('/index.php',$start, $next_matchs = $this->nextmatchs->show_tpl('/index.php',$start,
$total,'&'.$q_string,'95%',$phpgw_info['theme']['th_bg']); $total,'&'.$q_string,'95%',$phpgw_info['theme']['th_bg'],
0,$filters);
$t->set_var('next_matchs',$next_matchs); $t->set_var('next_matchs',$next_matchs);
@ -849,9 +873,14 @@
$prefs = array( $prefs = array(
'homeShowEvents' => 'Show open Events: Tasks/Calls/Notes on main screen', 'homeShowEvents' => 'Show open Events: Tasks/Calls/Notes on main screen',
'defaultFilter' => 'Default Filter for InfoLog',
'listNoSubs' => 'List no Subs/Childs', 'listNoSubs' => 'List no Subs/Childs',
'longNames' => 'Show full usernames' 'longNames' => 'Show full usernames'
); );
$allowed_values = array (
'defaultFilter' => $this->filters,
);
$phpgw->preferences->read_repository(); $phpgw->preferences->read_repository();
if ($save) if ($save)
@ -888,8 +917,20 @@
{ {
$t->set_var('bg_nm_color',$this->nextmatchs->alternate_row_color()); $t->set_var('bg_nm_color',$this->nextmatchs->alternate_row_color());
$t->set_var('field',lang($lang)); $t->set_var('field',lang($lang));
$t->set_var('data',$html->checkbox($pref,
if (is_array($allowed_values[$pref]))
{
if (!is_object($sbox)) $sbox = CreateObject('phpgwapi.sbox2');
$t->set_var('data',$sbox->getArrayItem($pref,
$phpgw_info['user']['preferences']['infolog'][$pref],
$allowed_values[$pref],1));
}
else
{
$t->set_var('data',$html->checkbox($pref,
$phpgw_info['user']['preferences']['infolog'][$pref])); $phpgw_info['user']['preferences']['infolog'][$pref]));
}
$t->parse('pref_linehandle','pref_line',True); $t->parse('pref_linehandle','pref_line',True);
} }
$t->pfp('out','info_prefs'); $t->pfp('out','info_prefs');

View File

@ -0,0 +1,29 @@
<?php
/**************************************************************************\
* phpGroupWare - Info Log administration *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
global $phpgw_info,$phpgw;
if ($phpgw_info['user']['preferences']['infolog']['homeShowEvents'])
{
$save_app = $phpgw_info['flags']['currentapp'];
$phpgw_info['flags']['currentapp'] = 'infolog';
$phpgw->translation->add_app('infolog');
global $filter;
$filter = 'own+open+today';
$infolog = CreateObject('infolog.uiinfolog');
$infolog->get_list(True);
$phpgw_info['flags']['currentapp'] = $save_app;
}

View File

@ -81,3 +81,12 @@ no entries found, try again ... infolog de Kein Eintr
Show open Events: Tasks/Calls/Notes on main screen infolog de Nicht erledigte Einträge: Aufgaben/Anrufe/Notizen auf Startseite anzeigen Show open Events: Tasks/Calls/Notes on main screen infolog de Nicht erledigte Einträge: Aufgaben/Anrufe/Notizen auf Startseite anzeigen
List no Subs/Childs infolog de Teilprojekte/Antwortdokumente nicht anzeigen List no Subs/Childs infolog de Teilprojekte/Antwortdokumente nicht anzeigen
Show full usernames infolog de Kompletten Benutzernamen anzeigen Show full usernames infolog de Kompletten Benutzernamen anzeigen
no Filter infolog de kein Filter
own infolog de eigene
own open infolog de eigene offen
own overdue infolog de eigene überfällig
own upcoming infolog de eigene zukünftig
open infolog de offen
overdue infolog de überfällig
upcoming infolog de zukünftig
Default Filter for InfoLog infolog de Standard-Filter für InfoLog