From 362167f31974f2367faa4989ba896e6fd956ea33 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jan 2015 02:32:15 +0100 Subject: [PATCH] Fixed: Export was not using user assigned --- htdocs/admin/agenda_xcal.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 32 ++++++------------- htdocs/langs/en_US/agenda.lang | 2 +- htdocs/public/agenda/agendaexport.php | 4 +-- 4 files changed, 12 insertions(+), 28 deletions(-) diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index 40454ed1302..fd8c3092c0d 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -171,7 +171,7 @@ $message.='
'; print $message; $message=$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'
'; -$message.=$langs->trans("AgendaUrlOptions2",$user->login,$user->login).'
'; +//$message.=$langs->trans("AgendaUrlOptions2",$user->login,$user->login).'
'; $message.=$langs->trans("AgendaUrlOptions3",$user->login,$user->login).'
'; $message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'
'; $message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index bf668be6daa..9a750daa015 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -976,7 +976,7 @@ class ActionComm extends CommonObject $sql.= " a.label, a.code, a.note, a.fk_action as type_id,"; $sql.= " a.fk_soc,"; $sql.= " a.fk_user_author, a.fk_user_mod,"; - $sql.= " a.fk_user_action, a.fk_user_done,"; + $sql.= " a.fk_user_action,"; $sql.= " a.fk_contact, a.percent as percentage,"; $sql.= " a.fk_element, a.elementtype,"; $sql.= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; @@ -984,9 +984,11 @@ class ActionComm extends CommonObject $sql.= " s.nom as socname,"; $sql.= " c.id as type_id, c.code as type_code, c.libelle"; $sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; // Link to get author of event for export $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; - $sql.= " WHERE a.fk_action=c.id"; + // We must filter on assignement table + if ($filters['logint'] || $filters['login']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; + $sql.= " WHERE a.fk_action=c.id"; $sql.= " AND a.entity = ".$conf->entity; foreach ($filters as $key => $value) { @@ -996,17 +998,8 @@ class ActionComm extends CommonObject if ($key == 'idfrom') $sql.=" AND a.id >= ".(is_numeric($value)?$value:0); if ($key == 'idto') $sql.=" AND a.id <= ".(is_numeric($value)?$value:0); if ($key == 'project') $sql.=" AND a.fk_project=".(is_numeric($value)?$value:0); - if ($key == 'login') - { - $login=$value; - $userforfilter=new User($this->db); - $result=$userforfilter->fetch('',$value); - $sql.= " AND ("; - $sql.= " a.fk_user_author = ".$userforfilter->id; - $sql.= " OR a.fk_user_action = ".$userforfilter->id; - $sql.= " OR a.fk_user_done = ".$userforfilter->id; - $sql.= ")"; - } + // We must filter on assignement table + if ($key == 'logint' || $key == 'login') $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($key == 'logina') { $logina=$value; @@ -1014,19 +1007,12 @@ class ActionComm extends CommonObject $result=$userforfilter->fetch('',$value); $sql.= " AND a.fk_user_author = ".$userforfilter->id; } - if ($key == 'logint') + if ($key == 'logint' || $key == 'login') { $logint=$value; $userforfilter=new User($this->db); $result=$userforfilter->fetch('',$value); - $sql.= " AND a.fk_user_action = ".$userforfilter->id; - } - if ($key == 'logind') - { - $logind=$value; - $userforfilter=new User($this->db); - $result=$userforfilter->fetch('',$value); - $sql.= " AND a.fk_user_done = ".$userforfilter->id; + $sql.= " AND ar.fk_element = ".$userforfilter->id; } } $sql.= " AND a.datep IS NOT NULL"; // To exclude corrupted events and avoid errors in lightning/sunbird import diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 1cc01ec2e7b..9ed2d79edd2 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -68,7 +68,7 @@ DateActionDoneEnd= Real end date DateActionStart= Start date DateActionEnd= End date AgendaUrlOptions1=You can also add following parameters to filter output: -AgendaUrlOptions2=login=%s to restrict output to actions created by, assigned to or done by user %s. +AgendaUrlOptions2=login=%s to restrict output to actions created by or assigned to user %s. AgendaUrlOptions3=logina=%s to restrict output to actions owned by a user %s. AgendaUrlOptions4=logint=%s to restrict output to actions assigned to user %s. AgendaUrlOptionsProject=project=PROJECT_ID to restrict output to actions associated to project PROJECT_ID. diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index c36766e2777..2b1d02ef493 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -69,7 +69,6 @@ if (! empty($_GET["project"])) $filters['project']=$_GET["project"]; if (! empty($_GET["login"])) $filters['login']=$_GET["login"]; if (! empty($_GET["logina"])) $filters['logina']=$_GET["logina"]; if (! empty($_GET["logint"])) $filters['logint']=$_GET["logint"]; -if (! empty($_GET["logind"])) $filters['logind']=$_GET["logind"]; // Not older than if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100; $filters['notolderthan']=$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY; @@ -111,8 +110,7 @@ foreach ($filters as $key => $value) if ($key == 'project') $filename.='-project'.$value; if ($key == 'login') $filename.='-login'.$value; if ($key == 'logina') $filename.='-logina'.$value; // Author - if ($key == 'logind') $filename.='-logind'.$value; // Affected to - if ($key == 'logint') $filename.='-logint'.$value; // Done by + if ($key == 'logint') $filename.='-logint'.$value; // Assigned to } // Add extension if ($format == 'vcal') { $shortfilename.='.vcs'; $filename.='.vcs'; }