From f545d2a134c7f3424d1746d12be72b9ad9befd08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Feb 2018 20:06:28 +0100 Subject: [PATCH] NEW Can add filter actiontype and notactiontype on event ical export --- htdocs/admin/agenda_xcal.php | 5 +++-- htdocs/comm/action/class/actioncomm.class.php | 6 ++++-- htdocs/langs/en_US/agenda.lang | 1 + htdocs/public/agenda/agendaexport.php | 19 +++++++++++-------- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index 68561d4390b..ac19eb24c03 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -173,11 +173,12 @@ $message.='
'; $message.='
'; print $message; -$message=$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'
'; +$message =$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'
'; $message.=$langs->trans("AgendaUrlOptions3",$user->login,$user->login).'
'; $message.=$langs->trans("AgendaUrlOptionsNotAdmin",$user->login,$user->login).'
'; $message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'
'; -$message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login); +$message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login).'
'; +$message.=$langs->trans("AgendaUrlOptionsNotAutoEvent",'systemauto','systemauto').'
'; print info_admin($message); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 5f094856e1c..ed0950826b8 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1329,7 +1329,7 @@ class ActionComm extends CommonObject * @param string $type 'event' or 'journal' * @param int $cachedelay Do not rebuild file if date older than cachedelay seconds * @param string $filename Force filename - * @param array $filters Array of filters + * @param array $filters Array of filters. Exemple array('notolderthan'=>99, 'year'=>..., 'idfrom'=>..., 'notactiontype'=>'systemauto', 'project'=>123, ...) * @return int <0 if error, nb of events in new file if ok */ function build_exportfile($format,$type,$cachedelay,$filename,$filters) @@ -1410,7 +1410,9 @@ 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); - // We must filter on assignement table + if ($key == 'actiontype') $sql.=" AND c.type = '".$this->db->escape($value)."'"; + if ($key == 'notactiontype') $sql.=" AND c.type <> '".$this->db->escape($value)."'"; + // We must filter on assignement table if ($key == 'logint') $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($key == 'logina') { diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index c7278554192..0c70a160204 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -98,6 +98,7 @@ AgendaUrlOptions3=logina=%s to restrict output to actions owned by a user AgendaUrlOptionsNotAdmin=logina=!%s to restrict output to actions not owned by user %s. AgendaUrlOptions4=logint=%s to restrict output to actions assigned to user %s (owner and others). AgendaUrlOptionsProject=project=__PROJECT_ID__ to restrict output to actions linked to project __PROJECT_ID__. +AgendaUrlOptionsNotAutoEvent=notactiontype=systemauto to exclude automatic event. AgendaShowBirthdayEvents=Show birthdays of contacts AgendaHideBirthdayEvents=Hide birthdays of contacts Busy=Busy diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index 81a67204fdb..c8f7f05ff23 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -69,14 +69,16 @@ if (GETPOST("format",'alpha')) $format=GETPOST("format",'apha'); if (GETPOST("type",'apha')) $type=GETPOST("type",'alpha'); $filters=array(); -if (GETPOST("year",'int')) $filters['year']=GETPOST("year",'int'); -if (GETPOST("id",'int')) $filters['id']=GETPOST("id",'int'); -if (GETPOST("idfrom",'int')) $filters['idfrom']=GETPOST("idfrom",'int'); -if (GETPOST("idto",'int')) $filters['idto']=GETPOST("idto",'int'); -if (GETPOST("project",'apha')) $filters['project']=GETPOST("project",'apha'); -if (GETPOST("logina",'apha')) $filters['logina']=GETPOST("logina",'apha'); -if (GETPOST("logint",'apha')) $filters['logint']=GETPOST("logint",'apha'); -if (GETPOST("notolderthan",'int')) $filters['notolderthan']=GETPOST("notolderthan","int"); +if (GETPOST("year",'int')) $filters['year']=GETPOST("year",'int'); +if (GETPOST("id",'int')) $filters['id']=GETPOST("id",'int'); +if (GETPOST("idfrom",'int')) $filters['idfrom']=GETPOST("idfrom",'int'); +if (GETPOST("idto",'int')) $filters['idto']=GETPOST("idto",'int'); +if (GETPOST("project",'apha')) $filters['project']=GETPOST("project",'apha'); +if (GETPOST("logina",'apha')) $filters['logina']=GETPOST("logina",'apha'); +if (GETPOST("logint",'apha')) $filters['logint']=GETPOST("logint",'apha'); +if (GETPOST("notactiontype",'apha')) $filters['notactiontype']=GETPOST("notactiontype",'apha'); +if (GETPOST("actiontype",'apha')) $filters['actiontype']=GETPOST("actiontype",'apha'); +if (GETPOST("notolderthan",'int')) $filters['notolderthan']=GETPOST("notolderthan","int"); else $filters['notolderthan']=$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY; // Check config @@ -116,6 +118,7 @@ foreach ($filters as $key => $value) if ($key == 'project') $filename.='-project'.$value; if ($key == 'logina') $filename.='-logina'.$value; // Author if ($key == 'logint') $filename.='-logint'.$value; // Assigned to + if ($key == 'notactiontype') $filename.='-notactiontype'.$value; } // Add extension if ($format == 'vcal') { $shortfilename.='.vcs'; $filename.='.vcs'; }