Fix conflict between option login and logina and logint in agenda export

This commit is contained in:
Laurent Destailleur 2017-07-04 10:29:38 +02:00
parent cb1c461b69
commit 0ee93fb00c
4 changed files with 52 additions and 40 deletions

View File

@ -174,8 +174,8 @@ $message.='<br>';
print $message;
$message=$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'<br>';
//$message.=$langs->trans("AgendaUrlOptions2",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptions3",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptionsNotAdmin",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login);

View File

@ -38,7 +38,7 @@ class ActionComm extends CommonObject
public $table_rowid = 'id';
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
public $picto='action';
/**
* Id of the event
* @var int
@ -168,7 +168,7 @@ class ActionComm extends CommonObject
var $email_subject;
var $errors_to;
/**
* Constructor
*
@ -444,7 +444,7 @@ class ActionComm extends CommonObject
$u->fetch($fuser);
$fuser = $u;
}
else
else
{
$fuser = $user;
}
@ -657,11 +657,11 @@ class ActionComm extends CommonObject
$this->error=$this->db->lasterror();
$error++;
}
if (! $error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources";
$sql.= " WHERE fk_actioncomm=".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$res=$this->db->query($sql);
if ($res < 0) {
@ -669,7 +669,7 @@ class ActionComm extends CommonObject
$error++;
}
}
// Removed extrafields
if (! $error) {
$result=$this->deleteExtraFields();
@ -1091,7 +1091,7 @@ class ActionComm extends CommonObject
else if ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%','statut3');
else if ($percent >= 100) return img_picto($langs->trans('StatusActionDone'),'statut6');
}
return '';
}
@ -1112,20 +1112,20 @@ class ActionComm extends CommonObject
global $conf, $langs, $user, $hookmanager;
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$label = $this->label;
if (empty($label)) $label=$this->libelle; // For backward compatibility
$result='';
// Set label of typ
$labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code)?$langs->transnoentities("Action".$this->type_code):$this->type_label;
if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
if ($this->type_code != 'AC_OTH_AUTO') $labeltype = $langs->trans('ActionAC_MANUAL');
}
$tooltip = '<u>' . $langs->trans('ShowAction'.$objp->code) . '</u>';
if (! empty($this->ref))
$tooltip .= '<br><b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
@ -1137,7 +1137,7 @@ class ActionComm extends CommonObject
$tooltip .= '<br><b>' . $langs->trans('Location') . ':</b> ' . $this->location;
$linkclose='';
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color)
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color)
$linkclose = ' style="background-color:#'.$this->type_color.'"';
if (empty($notooltip))
@ -1149,7 +1149,7 @@ class ActionComm extends CommonObject
}
$linkclose.=' title="'.dol_escape_htmltag($tooltip, 1).'"';
$linkclose.=' class="'.$classname.' classfortooltip"';
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
@ -1161,17 +1161,17 @@ class ActionComm extends CommonObject
$linkclose = ($hookmanager->resPrint ? $hookmanager->resPrint : $linkclose);
}
else $linkclose.=' class="'.$classname.'"';
$url='';
if ($option=='birthday')
if ($option=='birthday')
$url = DOL_URL_ROOT.'/contact/perso.php?id='.$this->id;
else
else
$url = DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id;
$linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
//print 'rrr'.$this->libelle.'-'.$withpicto;
if ($withpicto == 2)
@ -1279,7 +1279,7 @@ class ActionComm extends CommonObject
$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";
// We must filter on assignement table
if ($filters['logint'] || $filters['login']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
if ($filters['logint']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
$sql.= " WHERE a.fk_action=c.id";
$sql.= " AND a.entity IN (".getEntity('agenda').")";
foreach ($filters as $key => $value)
@ -1291,20 +1291,34 @@ class ActionComm extends CommonObject
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 == 'logint' || $key == 'login') $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
if ($key == 'logint') $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
if ($key == 'logina')
{
$logina=$value;
$condition='=';
if (preg_match('/^!/',$logina))
{
$logina=preg_replace('/^!/','',$logina);
$condition='<>';
}
$userforfilter=new User($this->db);
$result=$userforfilter->fetch('',$value);
$sql.= " AND a.fk_user_author = ".$userforfilter->id;
$result=$userforfilter->fetch('',$logina);
if ($result > 0) $sql.= " AND a.fk_user_author ".$condition." ".$userforfilter->id;
elseif ($result < 0 || $condition == '=') $sql.= " AND a.fk_user_author = 0";
}
if ($key == 'logint' || $key == 'login')
if ($key == 'logint')
{
$logint=$value;
$condition='=';
if (preg_match('/^!/',$logint))
{
$logint=preg_replace('/^!/','',$logint);
$condition='<>';
}
$userforfilter=new User($this->db);
$result=$userforfilter->fetch('',$value);
$sql.= " AND ar.fk_element = ".$userforfilter->id;
$result=$userforfilter->fetch('',$logint);
if ($result > 0) $sql.= " AND ar.fk_element = ".$userforfilter->id;
elseif ($result < 0 || $condition == '=') $sql.= " AND ar.fk_element = 0";
}
}
$sql.= " AND a.datep IS NOT NULL"; // To exclude corrupted events and avoid errors in lightning/sunbird import

View File

@ -80,9 +80,9 @@ AgendaModelModule=Document templates for event
DateActionStart=Start date
DateActionEnd=End date
AgendaUrlOptions1=You can also add following parameters to filter output:
AgendaUrlOptions2=<b>login=%s</b> to restrict output to actions created by or assigned to user <b>%s</b>.
AgendaUrlOptions3=<b>logina=%s</b> to restrict output to actions owned by a user <b>%s</b>.
AgendaUrlOptions4=<b>logint=%s</b> to restrict output to actions assigned to user <b>%s</b>.
AgendaUrlOptionsNotAdmin=<b>logina=!%s</b> to restrict output to actions not owned by user <b>%s</b>.
AgendaUrlOptions4=<b>logint=%s</b> to restrict output to actions assigned to user <b>%s</b> (owner and others).
AgendaUrlOptionsProject=<b>project=PROJECT_ID</b> to restrict output to actions associated to project <b>PROJECT_ID</b>.
AgendaShowBirthdayEvents=Show birthdays of contacts
AgendaHideBirthdayEvents=Hide birthdays of contacts

View File

@ -65,19 +65,18 @@ if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_A
// Define format, type and filter
$format='ical';
$type='event';
if (! empty($_GET["format"])) $format=$_GET["format"];
if (! empty($_GET["type"])) $type=$_GET["type"];
if (GETPOST("format",'alpha')) $format=GETPOST("format",'apha');
if (GETPOST("type",'apha')) $type=GETPOST("type",'alpha');
$filters=array();
if (! empty($_GET["year"])) $filters['year']=$_GET["year"];
if (! empty($_GET["id"])) $filters['id']=$_GET["id"];
if (! empty($_GET["idfrom"])) $filters['idfrom']=$_GET["idfrom"];
if (! empty($_GET["idto"])) $filters['idto']=$_GET["idto"];
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 (GETPOST("notolderthan")) $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("notolderthan",'int')) $filters['notolderthan']=GETPOST("notolderthan","int");
else $filters['notolderthan']=$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY;
// Check config
@ -115,7 +114,6 @@ foreach ($filters as $key => $value)
if ($key == 'idfrom') $filename.='-idfrom'.$value;
if ($key == 'idto') $filename.='-idto'.$value;
if ($key == 'project') $filename.='-project'.$value;
if ($key == 'login') $filename.='-login'.$value;
if ($key == 'logina') $filename.='-logina'.$value; // Author
if ($key == 'logint') $filename.='-logint'.$value; // Assigned to
}