Fix emailcollector can't be used without syntax rules

This commit is contained in:
ldestailleur 2019-01-03 11:47:27 +01:00
parent ff582a38e1
commit dbbfdd984a
5 changed files with 71 additions and 54 deletions

View File

@ -384,7 +384,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$connectstringserver = ''; $connectstringserver = '';
$connectstringsource = ''; $connectstringsource = '';
$connectstringtarget = ''; $connectstringtarget = '';
if (function_exists('imap_open')) if (function_exists('imap_open'))
{ {
$connectstringserver = $object->getConnectStringIMAP(); $connectstringserver = $object->getConnectStringIMAP();
@ -397,7 +397,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
{ {
$morehtml .= 'IMAP functions not available on your PHP'; $morehtml .= 'IMAP functions not available on your PHP';
} }
if (! $connection) if (! $connection)
{ {
$morehtml .= 'Failed to open IMAP connection '.$connectstringsource; $morehtml .= 'Failed to open IMAP connection '.$connectstringsource;
@ -412,7 +412,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
{ {
imap_close($connection); imap_close($connection);
} }
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref.'<div class="refidno">'.$morehtml.'</div>', '', 0, '', '', 0, ''); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref.'<div class="refidno">'.$morehtml.'</div>', '', 0, '', '', 0, '');
print '<div class="fichecenter">'; print '<div class="fichecenter">';
@ -487,6 +487,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1); print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1);
print '</td><td>'; print '</td><td>';
print '<input type="text" name="operationparam">'; print '<input type="text" name="operationparam">';
$htmltext=$langs->transnoentitiesnoconv("OperationParamDesc");
//var_dump($htmltext);
print $form->textwithpicto('', $htmltext);
print '</td>'; print '</td>';
print '<td></td>'; print '<td></td>';
print '<td align="right"><input type="submit" name="addoperation" id="addoperation" class="flat button" value="'.$langs->trans("Add").'"></td>'; print '<td align="right"><input type="submit" name="addoperation" id="addoperation" class="flat button" value="'.$langs->trans("Add").'"></td>';

View File

@ -120,8 +120,6 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
/* /*
* Actions * Actions
*
* Put here all code to do according to value of "$action" parameter
*/ */
if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
@ -165,8 +163,6 @@ if (empty($reshook))
/* /*
* View * View
*
* Put here all code to render page
*/ */
$form=new Form($db); $form=new Form($db);
@ -212,20 +208,20 @@ $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object)
$sql.=$hookmanager->resPrint; $sql.=$hookmanager->resPrint;
/* If a group by is required /* If a group by is required
$sql.= " GROUP BY " $sql.= " GROUP BY "
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
$sql.='t.'.$key.', '; $sql.='t.'.$key.', ';
} }
// Add fields from extrafields // Add fields from extrafields
if (! empty($extrafields->attributes[$object->table_element]['label'])) { if (! empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
// Add where from hooks // Add where from hooks
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint; $sql.=$hookmanager->resPrint;
$sql=preg_replace('/, $/','', $sql); $sql=preg_replace('/, $/','', $sql);
*/ */
$sql.=$db->order($sortfield,$sortorder); $sql.=$db->order($sortfield,$sortorder);
@ -305,8 +301,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// List of mass actions available // List of mass actions available
$arrayofmassactions = array( $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($user->rights->emailcollector->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); if ($user->rights->emailcollector->delete) $arrayofmassactions['predelete']=$langs->trans("Delete");
if (GETPOST('nomassaction','int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); if (GETPOST('nomassaction','int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
@ -324,7 +320,7 @@ print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$newcardbutton=''; $newcardbutton='';
//if ($user->rights->emailcollector->creer) //if ($user->rights->emailcollector->creer)
//{ //{
$newcardbutton='<a class="butActionNew" href="emailcollector_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']).'"><span class="valignmiddle">'.$langs->trans('New').'</span>'; $newcardbutton='<a class="butActionNew" href="emailcollector_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']).'"><span class="valignmiddle">'.$langs->trans('New').'</span>';
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>'; $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
$newcardbutton.= '</a>'; $newcardbutton.= '</a>';
@ -333,6 +329,10 @@ $newcardbutton.= '</a>';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit);
// Add code for pre mass action (confirmation or email presend form) // Add code for pre mass action (confirmation or email presend form)
/*$topicmail="";
$modelmail="";
$objecttmp=new EmailCollector($db);
$trackid='xxxx'.$object->id;*/
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($sall) if ($sall)
@ -343,8 +343,8 @@ if ($sall)
$moreforfilter = ''; $moreforfilter = '';
/*$moreforfilter.='<div class="divsearchfield">'; /*$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">'; $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
$moreforfilter.= '</div>';*/ $moreforfilter.= '</div>';*/
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
@ -371,11 +371,11 @@ print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"")
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
$align=''; $cssforfield='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
if ($key == 'status') $align.=($align?' ':'').'center'; if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
} }
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
@ -397,11 +397,14 @@ print '</tr>'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
$align=''; $cssforfield='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
if ($key == 'status') $align.=($align?' ':'').'center'; if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; if (! empty($arrayfields['t.'.$key]['checked']))
{
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n";
}
} }
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
@ -444,15 +447,22 @@ while ($i < min($num, $limit))
print '<tr class="oddeven">'; print '<tr class="oddeven">';
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
$align=''; $cssforfield='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
{ elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap';
print '<td';
if ($align) print ' class="'.$align.'"'; if (! empty($arrayfields['t.'.$key]['checked']))
print '>'; {
print '<td';
if ($cssforfield || $val['css']) print ' class="';
print $cssforfield;
if ($cssforfield && $val['css']) print ' ';
print $val['css'];
if ($cssforfield || $val['css']) print '"';
print '>';
print $object->showOutputField($val, $key, $obj->$key, ''); print $object->showOutputField($val, $key, $obj->$key, '');
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;

View File

@ -450,7 +450,7 @@ class Form
if ($notabs == 2) $tag='div'; if ($notabs == 2) $tag='div';
if ($notabs == 3) $tag='span'; if ($notabs == 3) $tag='span';
// Sanitize tooltip // Sanitize tooltip
$htmltext=str_replace("\\","\\\\",$htmltext); //$htmltext=str_replace("\\","\\\\",$htmltext);
$htmltext=str_replace("\r","",$htmltext); $htmltext=str_replace("\r","",$htmltext);
$htmltext=str_replace("\n","",$htmltext); $htmltext=str_replace("\n","",$htmltext);

View File

@ -1846,6 +1846,7 @@ WithoutDolTrackingID=Dolibarr Tracking ID not found
FormatZip=Zip FormatZip=Zip
MainMenuCode=Menu entry code (mainmenu) MainMenuCode=Menu entry code (mainmenu)
ECMAutoTree=Show automatic ECM tree ECMAutoTree=Show automatic ECM tree
OperationParamDesc=Define values to use for action, or how to extract values. For example:<br>VALUE:abc<br>REGEX:SUBJECT:([^\s]*)<br>REGEX:BODY:My company name is\s([^\s]*)
##### Resource #### ##### Resource ####
ResourceSetup=Configuration du module Resource ResourceSetup=Configuration du module Resource
UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list).

View File

@ -88,13 +88,13 @@ $pagenext = $page + 1;
//if (! $sortorder) $sortorder="DESC"; //if (! $sortorder) $sortorder="DESC";
// Initialize technical objects // Initialize technical objects
$object=new MyObject($db); $object = new MyObject($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; $diroutputmassaction = $conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('myobjectlist')); // Note that conf->hooks_modules contains array $hookmanager->initHooks(array('myobjectlist')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels // Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('myobject'); // Load $extrafields->attributes['myobject'] $extralabels = $extrafields->fetch_name_optionals_label('myobject'); // Load $extrafields->attributes['myobject']
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,'','search_');
// Default sort order (if not yet defined by previous GETPOST) // Default sort order (if not yet defined by previous GETPOST)
if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition.
@ -474,11 +474,14 @@ while ($i < min($num, $limit))
print '<tr class="oddeven">'; print '<tr class="oddeven">';
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
$cssforfield=''; $cssforfield='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap';
if (! empty($arrayfields['t.'.$key]['checked']))
{ {
print '<td'; print '<td';
if ($cssforfield || $val['css']) print ' class="'; if ($cssforfield || $val['css']) print ' class="';