Skip to content

Commit

Permalink
Fix conflict between option login and logina and logint in agenda export
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jul 4, 2017
1 parent cb1c461 commit 0ee93fb
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 40 deletions.
2 changes: 1 addition & 1 deletion htdocs/admin/agenda_xcal.php
Expand Up @@ -174,8 +174,8 @@
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);

Expand Down
64 changes: 39 additions & 25 deletions htdocs/comm/action/class/actioncomm.class.php
Expand Up @@ -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
Expand Down Expand Up @@ -168,7 +168,7 @@ class ActionComm extends CommonObject
var $email_subject;
var $errors_to;


/**
* Constructor
*
Expand Down Expand Up @@ -444,7 +444,7 @@ function createFromClone($fuser, $socid)
$u->fetch($fuser);
$fuser = $u;
}
else
else
{
$fuser = $user;
}
Expand Down Expand Up @@ -657,19 +657,19 @@ function delete($notrigger=0)
$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) {
$this->error=$this->db->lasterror();
$error++;
}
}

// Removed extrafields
if (! $error) {
$result=$this->deleteExtraFields();
Expand Down Expand Up @@ -1091,7 +1091,7 @@ function LibStatut($percent,$mode,$hidenastatus=0,$datestart='')
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 '';
}

Expand All @@ -1112,20 +1112,20 @@ function getNomUrl($withpicto=0,$maxlength=0,$classname='',$option='',$overwrite
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;
Expand All @@ -1137,7 +1137,7 @@ function getNomUrl($withpicto=0,$maxlength=0,$classname='',$option='',$overwrite
$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))
Expand All @@ -1149,7 +1149,7 @@ function getNomUrl($withpicto=0,$maxlength=0,$classname='',$option='',$overwrite
}
$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';
Expand All @@ -1161,17 +1161,17 @@ function getNomUrl($withpicto=0,$maxlength=0,$classname='',$option='',$overwrite
$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)
Expand Down Expand Up @@ -1279,7 +1279,7 @@ function build_exportfile($format,$type,$cachedelay,$filename,$filters)
$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)
Expand All @@ -1291,20 +1291,34 @@ function build_exportfile($format,$type,$cachedelay,$filename,$filters)
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
Expand Down
4 changes: 2 additions & 2 deletions htdocs/langs/en_US/agenda.lang
Expand Up @@ -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
Expand Down
22 changes: 10 additions & 12 deletions htdocs/public/agenda/agendaexport.php
Expand Up @@ -65,19 +65,18 @@ function llxFooterVierge() { print '</body></html>'; }
// 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
Expand Down Expand Up @@ -115,7 +114,6 @@ function llxFooterVierge() { print '</body></html>'; }
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
}
Expand Down

0 comments on commit 0ee93fb

Please sign in to comment.