From 69b28c6aad960970c829378dd39a0343dccdb840 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 14 Jul 2005 07:35:11 +0000 Subject: [PATCH] 1) Possebility to filter by owner or responsible 2) new filter my: in contrast to own which filters by owner, my shows only entry where you are responsible for --- infolog/inc/class.soinfolog.inc.php | 54 ++++++--------- infolog/inc/class.uiinfolog.inc.php | 19 +++--- infolog/inc/hook_home.inc.php | 2 + infolog/index.php | 2 +- infolog/setup/etemplates.inc.php | 101 ++++++++++++++++------------ infolog/setup/phpgw_de.lang | 6 ++ infolog/setup/phpgw_en.lang | 6 ++ 7 files changed, 102 insertions(+), 88 deletions(-) diff --git a/infolog/inc/class.soinfolog.inc.php b/infolog/inc/class.soinfolog.inc.php index d2a6e293b6..836e29c352 100644 --- a/infolog/inc/class.soinfolog.inc.php +++ b/infolog/inc/class.soinfolog.inc.php @@ -93,18 +93,18 @@ * generate sql to be AND'ed into a query to ensure ACL is respected (incl. _PRIVATE) * * @param $filter: none|all - list all entrys user have rights to see
- * private|own - list only his personal entrys (incl. those he is responsible for !!!) + * private|own - list only his personal entrys (incl. those he is responsible for !!!), my = entries the user is responsible for * @return string the necesary sql */ function aclFilter($filter = False) { - preg_match('/(own|privat|all|none|user)([0-9]*)/',$filter_was=$filter,$vars); + preg_match('/(my|own|privat|all|none|user)([0-9]*)/',$filter_was=$filter,$vars); $filter = $vars[1]; $f_user = intval($vars[2]); - if (isset($this->acl_filter[$filter.$user])) + if (isset($this->acl_filter[$filter.$f_user])) { - return $this->acl_filter[$filter.$user]; // used cached filter if found + return $this->acl_filter[$filter.$f_user]; // used cached filter if found } if (is_array($this->grants)) { @@ -126,7 +126,11 @@ } } $filtermethod = " (info_owner=$this->user"; // user has all rights - + + if ($filter == 'my') + { + $filtermethod .= ' AND info_responsible=0'; + } // implicit read-rights for responsible user $filtermethod .= " OR (info_responsible=$this->user AND info_access='public')"; @@ -138,7 +142,7 @@ " OR info_status = 'offer' AND info_owner IN(" . implode(',',$public_user_list) . ')' : '').")". " AND (info_access='public'".($has_private_access?" OR $has_private_access":'').')'; } - else // none --> all entrys user has rights to see + elseif ($filter != 'my') // none --> all entrys user has rights to see { if ($has_private_access) { @@ -156,7 +160,7 @@ $filtermethod = " ((info_owner=$f_user AND info_responsible=0 OR info_responsible=$f_user) AND $filtermethod)"; } //echo "

aclFilter(filter='$filter_was',user='$user') = '$filtermethod', privat_user_list=".print_r($privat_user_list,True).", public_user_list=".print_r($public_user_list,True)."

\n"; - return $this->acl_filter[$filter.$user] = $filtermethod; // cache the filter + return $this->acl_filter[$filter.$f_user] = $filtermethod; // cache the filter } /** @@ -236,25 +240,6 @@ ); } - /** - * copy data after a query into $data - * - * copy only non-numeric keys - * - * @param $data array to copy the data - */ - function db2data(&$data) - { - $data = array(); - foreach ($this->db->Record as $key => $val) - { - if (!is_numeric($key)) - { - $data[$key] = $val; - } - } - } - /** * read InfoLog entry $info_id * @@ -265,19 +250,17 @@ */ function read($info_id) // did _not_ ensure ACL { - $info_id = intval($info_id); + $info_id = (int) $info_id; if ($info_id <= 0 || $info_id != $this->data['info_id'] && (!$this->db->select($this->info_table,'*',array('info_id'=>$info_id),__LINE__,__FILE__) || - !$this->db->next_record())) + !(($this->data = $this->db->row(true))))) { $this->init( ); return False; } if ($info_id != $this->data['info_id']) // data yet read in { - $this->db2data($this->data); - $this->db->select($this->extra_table,'info_extra_name,info_extra_value',array('info_id'=>$info_id),__LINE__,__FILE__); while ($this->db->next_record()) { @@ -483,13 +466,15 @@ if (is_array($query['col_filter'])) { + if (!$this->table_defs) $this->table_defs = $this->db->get_table_definitions('infolog',$this->info_table); foreach($query['col_filter'] as $col => $data) { - $data = $this->db->db_addslashes($data); if (substr($col,0,5) != 'info_') $col = 'info_'.$col; + $data = $this->db->quote($data,$this->table_defs['fd'][$col]['type']); if (!empty($data) && eregi('^[a-z_0-9]+$',$col)) { - $filtermethod .= " AND $col = '$data'"; + $filtermethod .= $col != 'info_responsible' ? " AND $col=$data" : + " AND (info_responsible=$data OR info_responsible=0 AND info_owner=$data)"; } } } @@ -555,10 +540,9 @@ } $this->db->limit_query($sql="SELECT $distinct $this->info_table.* $sql_query $ordermethod",$query['start'],__LINE__,__FILE__); //echo "

sql='$sql'

\n"; - while ($this->db->next_record()) + while (($info =& $this->db->row(true))) { - $this->db2data($info); - $ids[$info['info_id']] = $info; + $ids[$info['info_id']] =& $info; } } else diff --git a/infolog/inc/class.uiinfolog.inc.php b/infolog/inc/class.uiinfolog.inc.php index 2712cc3177..3339de935a 100644 --- a/infolog/inc/class.uiinfolog.inc.php +++ b/infolog/inc/class.uiinfolog.inc.php @@ -66,6 +66,10 @@ $this->filters = array( 'none' => 'no Filter', 'done' => 'done', + 'my' => 'my', + 'my-open-today' => 'my open', + 'my-open-overdue' => 'my overdue', + 'my-upcoming' => 'my upcoming', 'own' => 'own', 'own-open-today' => 'own open', 'own-open-overdue' => 'own overdue', @@ -88,6 +92,8 @@ $this->html = &$this->tmpl->html; $this->user = $GLOBALS['egw_info']['user']['account_id']; + + $GLOBALS['uiinfolog'] =& $this; // make ourself availible for ExecMethod of get_rows function } function get_info($info,&$readonlys,$action='',$action_id='') @@ -136,7 +142,7 @@ function save_sessiondata($values) { $for = @$values['session_for'] ? $values['session_for'] : @$this->called_by; - //echo "

$for: uiinfolog::save_sessiondata(".print_r($values,True).") called_by='$this->called_by'

\n"; + //echo "

$for: uiinfolog::save_sessiondata(".print_r($values,True).") called_by='$this->called_by', for='$for'
".function_backtrace()."

\n"; $GLOBALS['egw']->session->appsession($for.'session_data','infolog',array( 'search' => $values['search'], 'start' => $values['start'], @@ -157,7 +163,7 @@ $values['session_for'] = $this->called_by; $this->save_sessiondata($values); } - //echo "

$this->called_by: uiinfolog::read_sessiondata() = ".print_r($values,True)."

\n"; + //echo "

called_by='$this->called_by': uiinfolog::read_sessiondata() = ".print_r($values,True)."

\n"; return $values; } @@ -200,9 +206,10 @@ if (!is_array($values)) { $values = array('nm' => $this->read_sessiondata()); - if (isset($_GET['filter'])) + if (isset($_GET['filter']) && $_GET['filter'] != 'default' || !isset($values['nm']['filter'])) { - $values['nm']['filter'] = $_GET['filter']; // infolog/index.php sets defaultFilter that way + $values['nm']['filter'] = $_GET['filter'] && $_GET['filter'] != 'default' ? $_GET['filter'] : + $GLOBALS['egw_info']['user']['preferences']['infolog']['defaultFilter']; } if (!isset($values['nm']['order']) || !$values['nm']['order']) { @@ -258,10 +265,6 @@ } } } - else - { - $this->save_sessiondata($values['nm']); - } switch ($action) { case 'sp': diff --git a/infolog/inc/hook_home.inc.php b/infolog/inc/hook_home.inc.php index 7f5b407b8d..e7195031ca 100644 --- a/infolog/inc/hook_home.inc.php +++ b/infolog/inc/hook_home.inc.php @@ -22,6 +22,8 @@ $GLOBALS['portal_order'][] = $app_id; $infolog =& CreateObject('infolog.uiinfolog'); + $infolog->called_by = 'home'; + switch($showevents) { case 1: diff --git a/infolog/index.php b/infolog/index.php index 0e4bf98fb8..152e458921 100644 --- a/infolog/index.php +++ b/infolog/index.php @@ -22,7 +22,7 @@ $GLOBALS['egw']->redirect_link('/index.php',array( 'menuaction' => 'infolog.uiinfolog.index', - 'filter' => $GLOBALS['egw_info']['user']['preferences']['infolog']['defaultFilter'] +// 'filter' => 'default', )); $GLOBALS['egw']->common->egw_exit(); ?> diff --git a/infolog/setup/etemplates.inc.php b/infolog/setup/etemplates.inc.php index 4b9486825b..eea8d25a1e 100644 --- a/infolog/setup/etemplates.inc.php +++ b/infolog/setup/etemplates.inc.php @@ -1,82 +1,84 @@ 'infolog.customfields','template' => '','lang' => '','group' => '0','version' => '0.9.15.001','data' => 'a:7:{i:0;a:3:{s:1:"F";s:3:"80%";s:2:"c2";s:6:"header";s:2:"c4";s:6:"header";}i:1;a:6:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:3:"Typ";}s:1:"B";a:4:{s:4:"type";s:6:"select";s:4:"name";s:3:"typ";s:8:"onchange";s:1:"1";s:4:"help";s:52:"select a typ to edit it\'s status-values or delete it";}s:1:"C";a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Delete";s:4:"name";s:14:"button[delete]";s:4:"help";s:24:"deletes the selected typ";}s:1:"D";a:5:{s:4:"type";s:4:"text";s:4:"size";s:5:"10,10";s:4:"name";s:8:"new_name";s:4:"help";s:26:"name of new type to create";s:4:"blur";s:8:"new name";}s:1:"E";a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Create";s:4:"name";s:14:"button[create]";s:4:"help";s:37:"creates a new typ with the given name";}s:1:"F";a:5:{s:4:"type";s:5:"label";s:4:"span";s:10:",error_msg";s:7:"no_lang";s:1:"1";s:5:"align";s:6:"center";s:4:"name";s:9:"error_msg";}}i:2;a:6:{s:1:"A";a:4:{s:4:"type";s:5:"label";s:4:"span";s:3:"all";s:5:"label";s:21:"Custom status for typ";s:4:"name";s:3:"typ";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}i:3;a:6:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"size";s:6:"status";s:4:"span";s:3:"all";s:4:"name";s:6:"status";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}i:4;a:6:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:3:"all";s:5:"label";s:13:"Custom fields";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}i:5;a:6:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"size";s:6:"fields";s:4:"span";s:3:"all";s:4:"name";s:6:"fields";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}i:6;a:6:{s:1:"A";a:6:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";s:4:"span";s:3:"all";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:4:"Save";s:4:"name";s:12:"button[save]";s:4:"help";s:33:"saves the changes made and leaves";}i:2;a:4:{s:4:"type";s:6:"button";s:5:"label";s:5:"Apply";s:4:"name";s:13:"button[apply]";s:4:"help";s:19:"applies the changes";}i:3;a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Cancel";s:4:"name";s:14:"button[cancel]";s:4:"help";s:22:"leaves without saveing";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}}','size' => '','style' => '.header { font-weight: bold; font-size: 120%; } +$templ_version=1; + +$templ_data[] = array('name' => 'infolog.customfields','template' => '','lang' => '','group' => '0','version' => '0.9.15.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:7:{i:0;a:3:{s:1:"F";s:3:"80%";s:2:"c2";s:6:"header";s:2:"c4";s:6:"header";}i:1;a:6:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:3:"Typ";}s:1:"B";a:4:{s:4:"type";s:6:"select";s:4:"name";s:3:"typ";s:8:"onchange";s:1:"1";s:4:"help";s:52:"select a typ to edit it\'s status-values or delete it";}s:1:"C";a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Delete";s:4:"name";s:14:"button[delete]";s:4:"help";s:24:"deletes the selected typ";}s:1:"D";a:5:{s:4:"type";s:4:"text";s:4:"size";s:5:"10,10";s:4:"name";s:8:"new_name";s:4:"help";s:26:"name of new type to create";s:4:"blur";s:8:"new name";}s:1:"E";a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Create";s:4:"name";s:14:"button[create]";s:4:"help";s:37:"creates a new typ with the given name";}s:1:"F";a:5:{s:4:"type";s:5:"label";s:4:"span";s:10:",error_msg";s:7:"no_lang";s:1:"1";s:5:"align";s:6:"center";s:4:"name";s:9:"error_msg";}}i:2;a:6:{s:1:"A";a:4:{s:4:"type";s:5:"label";s:4:"span";s:3:"all";s:5:"label";s:21:"Custom status for typ";s:4:"name";s:3:"typ";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}i:3;a:6:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"size";s:6:"status";s:4:"span";s:3:"all";s:4:"name";s:6:"status";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}i:4;a:6:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:3:"all";s:5:"label";s:13:"Custom fields";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}i:5;a:6:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"size";s:6:"fields";s:4:"span";s:3:"all";s:4:"name";s:6:"fields";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}i:6;a:6:{s:1:"A";a:6:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";s:4:"span";s:3:"all";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:4:"Save";s:4:"name";s:12:"button[save]";s:4:"help";s:33:"saves the changes made and leaves";}i:2;a:4:{s:4:"type";s:6:"button";s:5:"label";s:5:"Apply";s:4:"name";s:13:"button[apply]";s:4:"help";s:19:"applies the changes";}i:3;a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Cancel";s:4:"name";s:14:"button[cancel]";s:4:"help";s:22:"leaves without saveing";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}s:1:"E";a:1:{s:4:"type";s:5:"label";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:6;s:4:"cols";i:6;}}','size' => '','style' => '.header { font-weight: bold; font-size: 120%; } .error_msg { color: red; font-style: italics; }','modified' => '1061729975',); -$templ_data[] = array('name' => 'infolog.customfields.fields','template' => '','lang' => '','group' => '0','version' => '0.9.15.001','data' => 'a:3:{i:0;a:2:{s:2:"c1";s:2:"th";s:2:"c2";s:7:"row,top";}i:1;a:7:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:3:"Typ";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:5:"label";s:4:"Name";}s:1:"C";a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"Label";}s:1:"D";a:2:{s:4:"type";s:5:"label";s:5:"label";s:20:"Values for selectbox";}s:1:"E";a:2:{s:4:"type";s:5:"label";s:5:"label";s:14:"Length
Rows";}s:1:"F";a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"Order";}s:1:"G";a:4:{s:4:"type";s:5:"label";s:5:"label";s:6:"Action";s:5:"align";s:6:"center";s:4:"help";s:18:"deletes this field";}}i:2;a:7:{s:1:"A";a:4:{s:4:"type";s:6:"select";s:4:"size";s:3:"All";s:4:"name";s:11:"${row}[typ]";s:4:"help";s:41:"for which types should this field be used";}s:1:"B";a:4:{s:4:"type";s:4:"text";s:4:"size";s:5:"20,32";s:4:"name";s:12:"${row}[name]";s:4:"help";s:83:"the name used internaly (<= 20 chars), changeing it makes existing data unavailible";}s:1:"C";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:4:"text";s:4:"size";s:4:",255";s:4:"name";s:13:"${row}[label]";s:4:"help";s:30:"the text displayed to the user";}i:2;a:2:{s:4:"type";s:5:"label";s:4:"name";s:13:"${row}[label]";}}s:1:"D";a:4:{s:4:"type";s:8:"textarea";s:4:"size";s:4:"2,30";s:4:"name";s:14:"${row}[values]";s:4:"help";s:40:"each value is a line like [=