Merge branch 'develop' of github.com:Dolibarr/dolibarr into develop_NEW_Service_DefaultWorkstation

This commit is contained in:
atm-lena 2022-08-11 12:11:41 +02:00
commit 2fbba30e2a
289 changed files with 3715 additions and 2730 deletions

View File

@ -52,7 +52,7 @@ Ace 1.4.14 BSD Yes
ChartJS 3.7.1 MIT License Yes JS library for graph
CKEditor 4.18 LGPL-2.1+ Yes Editor WYSIWYG
jQuery 3.6.0 MIT License Yes JS library
jQuery UI 1.13.1 GPL and MIT License Yes JS library plugin UI
jQuery UI 1.13.2 GPL and MIT License Yes JS library plugin UI
jQuery select2 4.0.13 GPL and Apache License Yes JS library plugin for sexier multiselect. Warning: 4.0.6+ create troubles without patching css
jQuery blockUI 2.70.0 GPL and MIT License Yes JS library plugin blockUI (to use ajax popups)
jQuery Colorpicker 1.1 MIT License Yes JS library for color picker for a defined list of colors

View File

@ -27,7 +27,9 @@ Following changes may create regressions for some external modules, but were nec
For users:
---------------
NEW: PHP 8.1 compatibility
NEW: PHP 8.1 compatibility.
Warning: Application works correctly with PHP8 and 8.1 but you may experience a lot of PHP warning into the PHP server log files (depending
on the PHP setup). Removal of all PHP warnings on server side is planned for v17.
NEW: Support for recurring purchase invoices.
NEW: #20292 Include German public holidays
NEW: Can show ZATCA QR-Code on PDFs

View File

@ -49,7 +49,7 @@ if (empty($user->rights->accounting->mouvements->lire)) {
if (empty($conf->comptabilite->enabled) && empty($conf->accounting->enabled) && empty($conf->asset->enabled) && empty($conf->intracommreport->enabled)) {
accessforbidden();
}
if (empty($user->rights->compta->resultat->lire) && empty($user->rights->accounting->comptarapport->lire) && empty($user->rights->accounting->mouvements->lire) && empty($user->rights->asset->read) && empty($user->rights->intracommreport->read)) {
if (empty($user->hasRight('compta', 'resultat', 'lire')) && empty($user->hasRight('accounting', 'comptarapport', 'lire')) && empty($user->hasRight('accounting', 'mouvements', 'lire')) && empty($user->hasRight('asset', 'read')) && empty($user->hasRight('intracommreport', 'read'))) {
accessforbidden();
}

View File

@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
@ -311,8 +312,8 @@ if (empty($reshook)) {
//$object->twitter = trim(GETPOST("twitter", 'alpha'));
//$object->facebook = trim(GETPOST("facebook", 'alpha'));
//$object->linkedin = trim(GETPOST("linkedin", 'alpha'));
$object->birth = $birthdate;
$object->birth = $birthdate;
$object->default_lang = GETPOST('default_lang', 'alpha');
$object->typeid = GETPOST("typeid", 'int');
//$object->note = trim(GETPOST("comment","alpha"));
$object->morphy = GETPOST("morphy", 'alpha');
@ -457,6 +458,7 @@ if (empty($reshook)) {
$userid = GETPOST("userid", 'int');
$socid = GETPOST("socid", 'int');
$default_lang = GETPOST('default_lang', 'alpha');
$object->civility_id = $civility_id;
$object->firstname = $firstname;
@ -498,7 +500,7 @@ if (empty($reshook)) {
$object->user_id = $userid;
$object->socid = $socid;
$object->public = $public;
$object->default_lang = $default_lang;
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) {
@ -621,6 +623,11 @@ if (empty($reshook)) {
}
}
$action = ($result < 0 || !$error) ? '' : 'create';
if (!$error && $backtopage) {
header("Location: ".$backtopage);
exit;
}
}
if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') {
@ -894,6 +901,7 @@ if (empty($reshook)) {
$form = new Form($db);
$formfile = new FormFile($db);
$formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db);
$title = $langs->trans("Member")." - ".$langs->trans("Card");
@ -1358,6 +1366,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc');
print "</td></tr>\n";
// Default language
if (!empty($conf->global->MAIN_MULTILANGS)) {
print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).'</td><td colspan="3">'."\n";
print img_picto('', 'language').$formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1);
print '</td>';
print '</tr>';
}
// Public profil
print "<tr><td>".$langs->trans("Public")."</td><td>\n";
print $form->selectyesno("public", (GETPOSTISSET("public") ? GETPOST("public", 'alphanohtml', 2) : $object->public), 1);
@ -1798,6 +1814,19 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Birth Date
print '<tr><td class="titlefield">'.$langs->trans("DateOfBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>';
// Default language
if (!empty($conf->global->MAIN_MULTILANGS)) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
print '<tr><td>'.$langs->trans("DefaultLang").'</td><td>';
//$s=picto_from_langcode($object->default_lang);
//print ($s?$s.' ':'');
$langs->load("languages");
$labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : '');
print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"');
print $labellang;
print '</td></tr>';
}
// Public
print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>';

View File

@ -215,6 +215,12 @@ class Adherent extends CommonObject
*/
public $public;
/**
* Default language code of member (en_US, ...)
* @var string
*/
public $default_lang;
/**
* @var string photo of member
*/
@ -328,6 +334,7 @@ class Adherent extends CommonObject
'photo' => array('type' => 'varchar(255)', 'label' => 'Photo', 'enabled' => 1, 'visible' => -1, 'position' => 135),
'public' => array('type' => 'smallint(6)', 'label' => 'Public', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 145),
'datefin' => array('type' => 'datetime', 'label' => 'DateEnd', 'enabled' => 1, 'visible' => -1, 'position' => 150),
'default_lang' =>array('type'=>'varchar(6)', 'label'=>'Default lang', 'enabled'=>1, 'visible'=>-1, 'position'=> 153),
'note_private' => array('type' => 'text', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 0, 'position' => 155),
'note_public' => array('type' => 'text', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 0, 'position' => 160),
'datevalid' => array('type' => 'datetime', 'label' => 'DateValidation', 'enabled' => 1, 'visible' => -1, 'position' => 165),
@ -710,9 +717,11 @@ class Adherent extends CommonObject
$sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null");
$sql .= ", public = '".$this->db->escape($this->public)."'";
$sql .= ", statut = ".$this->db->escape($this->statut);
$sql .= ", default_lang = ".(!empty($this->default_lang) ? "'".$this->db->escape($this->default_lang)."'" : "null");
$sql .= ", fk_adherent_type = ".$this->db->escape($this->typeid);
$sql .= ", morphy = '".$this->db->escape($this->morphy)."'";
$sql .= ", birth = ".($this->birth ? "'".$this->db->idate($this->birth)."'" : "null");
if ($this->datefin) {
$sql .= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription
}
@ -833,6 +842,8 @@ class Adherent extends CommonObject
$luser->office_phone = $this->phone;
$luser->user_mobile = $this->phone_mobile;
$luser->lang = $this->default_lang;
$luser->fk_member = $this->id;
$result = $luser->update($user, 0, 1, 1); // Use nosync to 1 to avoid cyclic updates
@ -868,6 +879,7 @@ class Adherent extends CommonObject
$lthirdparty->state_id = $this->state_id;
$lthirdparty->country_id = $this->country_id;
//$lthirdparty->phone_mobile=$this->phone_mobile;
$lthirdparty->default_lang = $this->default_lang;
$result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1, 'update'); // Use sync to 0 to avoid cyclic updates
@ -1314,7 +1326,7 @@ class Adherent extends CommonObject
$sql .= " d.photo, d.fk_adherent_type, d.morphy, d.entity,";
$sql .= " d.datec as datec,";
$sql .= " d.tms as datem,";
$sql .= " d.datefin as datefin,";
$sql .= " d.datefin as datefin, d.default_lang,";
$sql .= " d.birth as birthday,";
$sql .= " d.datevalid as datev,";
$sql .= " d.country,";
@ -1407,6 +1419,8 @@ class Adherent extends CommonObject
$this->date_validation = $this->db->jdate($obj->datev);
$this->birth = $this->db->jdate($obj->birthday);
$this->default_lang = $obj->default_lang;
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->morphy = $obj->morphy;
@ -2556,6 +2570,7 @@ class Adherent extends CommonObject
$this->datefin = $now;
$this->datevalid = $now;
$this->default_lang = '';
$this->typeid = 1; // Id type adherent
$this->type = 'Type adherent'; // Libelle type adherent

View File

@ -5,7 +5,7 @@
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2019 Thibault Foucart <support@ptibogxiv.net>
* Copyright (C) 2019-2022 Thibault Foucart <support@ptibogxiv.net>
* Copyright (C) 2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2021 Waël Almoman <info@almoman.com>
*
@ -141,6 +141,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
} else {
$sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'";
$sql .= " WHERE entity IN (".getEntity('member_type').")";
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);

View File

@ -622,34 +622,33 @@ $sourceList = array();
if ($id == 11) {
$elementList = array(
'' => '',
'societe' => $langs->trans('ThirdParty'),
'agenda' => img_picto('', 'action', 'class="pictofixedwidth"').$langs->trans('Agenda'),
'dolresource' => img_picto('', 'resource', 'class="pictofixedwidth"').$langs->trans('Resource'),
'societe' => img_picto('', 'company', 'class="pictofixedwidth"').$langs->trans('ThirdParty'),
// 'proposal' => $langs->trans('Proposal'),
// 'order' => $langs->trans('Order'),
// 'invoice' => $langs->trans('Bill'),
'supplier_proposal' => $langs->trans('SupplierProposal'),
'order_supplier' => $langs->trans('SupplierOrder'),
'invoice_supplier' => $langs->trans('SupplierBill'),
// 'intervention' => $langs->trans('InterventionCard'),
// 'contract' => $langs->trans('Contract'),
'project' => $langs->trans('Project'),
'project_task' => $langs->trans('Task'),
'ticket' => $langs->trans('Ticket'),
'agenda' => $langs->trans('Agenda'),
'dolresource' => $langs->trans('Resource'),
// old deprecated
'propal' => $langs->trans('Proposal'),
'commande' => $langs->trans('Order'),
'facture' => $langs->trans('Bill'),
'fichinter' => $langs->trans('InterventionCard'),
'contrat' => $langs->trans('Contract'),
'project' => img_picto('', 'project', 'class="pictofixedwidth"').$langs->trans('Project'),
'project_task' => img_picto('', 'projecttask', 'class="pictofixedwidth"').$langs->trans('Task'),
'propal' => img_picto('', 'propal', 'class="pictofixedwidth"').$langs->trans('Proposal'),
'commande' => img_picto('', 'order', 'class="pictofixedwidth"').$langs->trans('Order'),
'facture' => img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans('Bill'),
'fichinter' => img_picto('', 'intervention', 'class="pictofixedwidth"').$langs->trans('InterventionCard'),
'contrat' => img_picto('', 'contract', 'class="pictofixedwidth"').$langs->trans('Contract'),
'ticket' => img_picto('', 'ticket', 'class="pictofixedwidth"').$langs->trans('Ticket'),
'supplier_proposal' => img_picto('', 'supplier_proposal', 'class="pictofixedwidth"').$langs->trans('SupplierProposal'),
'order_supplier' => img_picto('', 'supplier_order', 'class="pictofixedwidth"').$langs->trans('SupplierOrder'),
'invoice_supplier' => img_picto('', 'supplier_invoice', 'class="pictofixedwidth"').$langs->trans('SupplierBill'),
);
if (!empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) {
$elementList["societe"] = $langs->trans('ThirdParty');
if (!empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) {
$elementList['conferenceorbooth'] = img_picto('', 'eventorganization', 'class="pictofixedwidth"').$langs->trans('ConferenceOrBooth');
}
complete_elementList_with_modules($elementList);
asort($elementList);
//asort($elementList);
$sourceList = array(
'internal' => $langs->trans('Internal'),
'external' => $langs->trans('External')
@ -1202,7 +1201,6 @@ if (GETPOST('from')) {
if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'rowid='.urlencode($rowid).'&code='.urlencode($code).$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
}
//var_dump($elementList);
/*
@ -1222,14 +1220,16 @@ if ($id > 0) {
$sql .= natural_search("code_iso", $search_code);
} elseif ($search_code != '' && $id == 28) {
$sql .= natural_search("h.code", $search_code);
} elseif ($search_code != '' && $id == 32) {
} elseif ($search_code != '' && ($id == 7 || $id == 32)) {
$sql .= natural_search("a.code", $search_code);
} elseif ($search_code != '' && $id == 3) {
$sql .= natural_search("r.code_region", $search_code);
} elseif ($search_code != '' && $id == 7) {
$sql .= natural_search("a.code", $search_code);
} elseif ($search_code != '' && $id == 10) {
} elseif ($search_code != '' && ($id == 8 || $id == 10)) {
$sql .= natural_search("t.code", $search_code);
} elseif ($search_code != '' && $id == 1) {
$sql .= natural_search("f.code", $search_code);
} elseif ($search_code != '' && $id == 2) {
$sql .= natural_search("d.code_departement", $search_code);
} elseif ($search_code != '' && $id != 9) {
$sql .= natural_search("code", $search_code);
}
@ -1960,7 +1960,7 @@ if ($id > 0) {
$valuetoshow = price($valuetoshow);
}
if ($value == 'private') {
$valuetoshow = yn($elementList[$valuetoshow]);
$valuetoshow = yn($valuetoshow);
} elseif ($value == 'libelle_facture') {
$langs->load("bills");
$key = $langs->trans("PaymentCondition".strtoupper($obj->code));
@ -2375,9 +2375,15 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
print '<td>';
print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'lang');
print '</td>';
} elseif (in_array($value, array('element', 'source'))) { //Example: the type and source of the element (for contact types)
} elseif (in_array($value, array('element', 'source'))) { // Example: the type and source of the element (for contact types)
$tmparray = array();
if ($value == 'element') {
$tmparray = $elementList;
} else {
$tmparray = $sourceList;
}
print '<td>';
print $form->selectarray($value, $elementList, (!empty($obj->{$value}) ? $obj->{$value}:''));
print $form->selectarray($value, $tmparray, (!empty($obj->{$value}) ? $obj->{$value}:''), 0, 0, 0, '', 0, 0, 0, '', 'maxwidth250');
print '</td>';
} elseif (in_array($value, array('public', 'use_default'))) {
// Fields 0/1 with a combo select Yes/No

View File

@ -378,33 +378,54 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$connectstringserver = $object->getConnectStringIMAP($usessl);
try {
if ($sourcedir) {
//$connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir);
$connectstringsource = $connectstringserver.$object->getEncodedUtf7($sourcedir);
}
if ($targetdir) {
//$connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir);
$connectstringtarget = $connectstringserver.$object->getEncodedUtf7($targetdir);
if ($action == 'scan') {
try {
if ($sourcedir) {
//$connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir);
$connectstringsource = $connectstringserver.$object->getEncodedUtf7($sourcedir);
}
if ($targetdir) {
//$connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir);
$connectstringtarget = $connectstringserver.$object->getEncodedUtf7($targetdir);
}
$timeoutconnect = empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 5 : $conf->global->MAIN_USE_CONNECT_TIMEOUT;
$timeoutread = empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 20 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT;
dol_syslog("imap_open connectstring=".$connectstringsource." login=".$object->login." password=".$object->password." timeoutconnect=".$timeoutconnect." timeoutread=".$timeoutread);
$result1 = imap_timeout(IMAP_OPENTIMEOUT, $timeoutconnect); // timeout seems ignored with ssl connect
$result2 = imap_timeout(IMAP_READTIMEOUT, $timeoutread);
$result3 = imap_timeout(IMAP_WRITETIMEOUT, 5);
$result4 = imap_timeout(IMAP_CLOSETIMEOUT, 5);
dol_syslog("result1=".$result1." result2=".$result2." result3=".$result3." result4=".$result4);
$connection = imap_open($connectstringsource, $object->login, $object->password);
//dol_syslog("end imap_open connection=".var_export($connection, true));
} catch (Exception $e) {
print $e->getMessage();
}
$timeoutconnect = empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 5 : $conf->global->MAIN_USE_CONNECT_TIMEOUT;
$timeoutread = empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 20 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT;
if (!$connection) {
$morehtml .= 'Failed to open IMAP connection '.$connectstringsource;
if (function_exists('imap_last_error')) {
$morehtml .= '<br>'.imap_last_error();
}
dol_syslog("Error ".$morehtml, LOG_WARNING);
//var_dump(imap_errors())
} else {
dol_syslog("Imap connected. Now we call imap_num_msg()");
$morehtml .= imap_num_msg($connection);
}
dol_syslog("imap_open connectstring=".$connectstringsource." login=".$object->login." password=".$object->password." timeoutconnect=".$timeoutconnect." timeoutread=".$timeoutread);
$result1 = imap_timeout(IMAP_OPENTIMEOUT, $timeoutconnect); // timeout seems ignored with ssl connect
$result2 = imap_timeout(IMAP_READTIMEOUT, $timeoutread);
$result3 = imap_timeout(IMAP_WRITETIMEOUT, 5);
$result4 = imap_timeout(IMAP_CLOSETIMEOUT, 5);
dol_syslog("result1=".$result1." result2=".$result2." result3=".$result3." result4=".$result4);
$connection = imap_open($connectstringsource, $object->login, $object->password);
//dol_syslog("end imap_open connection=".var_export($connection, true));
} catch (Exception $e) {
print $e->getMessage();
if ($connection) {
dol_syslog("Imap close");
imap_close($connection);
}
} else {
$morehtml .= '<a class="flat" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=scan&token='.newToken().'">'.img_picto('', 'refresh', 'class="paddingrightonly"').$langs->trans("Refresh").'</a>';
}
$morehtml .= $form->textwithpicto('', 'connect string '.$connectstringserver);
@ -412,23 +433,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$morehtml .= 'IMAP functions not available on your PHP. ';
}
if (!$connection) {
$morehtml .= 'Failed to open IMAP connection '.$connectstringsource;
if (function_exists('imap_last_error')) {
$morehtml .= '<br>'.imap_last_error();
}
dol_syslog("Error ".$morehtml, LOG_WARNING);
//var_dump(imap_errors())
} else {
dol_syslog("Imap connected. Now we call imap_num_msg()");
$morehtml .= imap_num_msg($connection);
}
if ($connection) {
dol_syslog("Imap close");
imap_close($connection);
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref.'<div class="refidno">'.$morehtml.'</div>', '', 0, '', '', 0, '');
print '<div class="fichecenter">';
@ -580,11 +584,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td>';
print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300', 1);
print '</td><td>';
print '<input type="text" name="operationparam">';
//print '<input type="text" name="operationparam">';
$htmltext = $langs->transnoentitiesnoconv("OperationParamDesc");
print $form->textwithpicto('<input type="text" name="operationparam">', $htmltext, 1, 'help', '', 0, 2, 'operationparamtt');
print '</td>';
print '<td>';
$htmltext = $langs->transnoentitiesnoconv("OperationParamDesc");
print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'operationparamtt');
print '</td>';
print '<td class="right"><input type="submit" name="addoperation" id="addoperation" class="flat button small" value="'.$langs->trans("Add").'"></td>';
print '</tr>';

View File

@ -88,7 +88,15 @@ if ($action == 'update' && !$cancel) {
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW", 'none'), 'chaine', 0, '', $conf->entity);
if (GETPOSTISSET("MAIN_MAIL_SMTPS_PW")) {
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW", 'none'), 'chaine', 0, '', $conf->entity);
}
if (GETPOSTISSET("MAIN_MAIL_SMTPS_AUTH_TYPE")) {
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_AUTH_TYPE", GETPOST("MAIN_MAIL_SMTPS_AUTH_TYPE", 'chaine'), 'chaine', 0, '', $conf->entity);
}
if (GETPOSTISSET("MAIN_MAIL_SMTPS_OAUTH_SERVICE")) {
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_OAUTH_SERVICE", GETPOST("MAIN_MAIL_SMTPS_OAUTH_SERVICE", 'chaine'), 'chaine', 0, '', $conf->entity);
}
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED", GETPOST("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED", 'int'), 'chaine', 0, '', $conf->entity);
@ -171,6 +179,24 @@ if (version_compare(phpversion(), '7.0', '>=')) {
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
}
// List of oauth services
$oauthservices = array();
foreach ($conf->global as $key => $val) {
if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
$key = preg_replace('/^OAUTH_/', '', $key);
$key = preg_replace('/_ID$/', '', $key);
if (preg_match('/^.*-/', $key)) {
$name = preg_replace('/^.*-/', '', $key);
} else {
$name = $langs->trans("NoName");
}
$provider = preg_replace('/-.*$/', '', $key);
$provider = ucfirst(strtolower($provider));
$oauthservices[$key] = $name." (".$provider.")";
}
}
if ($action == 'edit') {
if ($conf->use_javascript_ajax) {
@ -195,6 +221,7 @@ if ($action == 'edit') {
jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
jQuery(".smtp_method").hide();
jQuery(".dkim").hide();
jQuery(".smtp_auth_method").hide();
';
if ($linuxlike) {
print '
@ -237,6 +264,7 @@ if ($action == 'edit') {
jQuery("#smtp_port_mess").hide();
jQuery(".smtp_method").show();
jQuery(".dkim").hide();
jQuery(".smtp_auth_method").show();
}
if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
{
@ -264,12 +292,34 @@ if ($action == 'edit') {
jQuery("#smtp_port_mess").hide();
jQuery(".smtp_method").show();
jQuery(".dkim").show();
jQuery(".smtp_auth_method").show();
}
}
function change_smtp_auth_method() {
console.log(jQuery("#radio_pw").prop("checked"));
if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
jQuery(".smtp_oauth_service").show();
jQuery(".smtp_pw").hide();
} else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
jQuery(".smtp_oauth_service").show();
jQuery(".smtp_pw").hide();
} else if(jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\'){
jQuery(".smtp_oauth_service").hide();
jQuery(".smtp_pw").hide();
} else {
jQuery(".smtp_oauth_service").hide();
jQuery(".smtp_pw").show();
}
}
initfields();
change_smtp_auth_method();
jQuery("#MAIN_MAIL_SENDMODE").change(function() {
initfields();
change_smtp_auth_method();
});
jQuery("#radio_pw, #radio_oauth").change(function() {
change_smtp_auth_method();
});
jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
@ -413,10 +463,29 @@ if ($action == 'edit') {
print '</td></tr>';
}
// OAUTH
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
print '<tr class="oddeven smtp_auth_method"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>';
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
print '<input type="radio" id="radio_pw" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="LOGIN"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') == 'LOGIN' ? ' checked' : '').'> ';
print '<label for="radio_pw" >'.$langs->trans("UsePassword").'</label>';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="radio" id="radio_oauth" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="XOAUTH2"'.(getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') == 'XOAUTH2' ? ' checked' : '').'> ';
print '<label for="radio_oauth" >'.$form->textwithpicto($langs->trans("UseOauth"), $langs->trans("OauthNotAvailableForAllAndHadToBeCreatedBefore")).'</label>';
} else {
$value = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN');
$htmltext = $langs->trans("ContactSuperAdminForChange");
print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin');
print '<input type="hidden" id="MAIN_MAIL_SMTPS_AUTH_TYPE" name="MAIN_MAIL_SMTPS_AUTH_TYPE" value="'.$value.'">';
}
print '</td></tr>';
}
// PW
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
$mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW : '');
print '<tr class="drag drop oddeven"><td>';
print '<tr class="drag drop oddeven smtp_pw"><td>';
print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_PW"), $langs->trans("WithGMailYouCanCreateADedicatedPassword"));
print '</td><td>';
// SuperAdministrator access only
@ -430,6 +499,24 @@ if ($action == 'edit') {
print '</td></tr>';
}
// OAUTH service provider
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
print '<tr class="oddeven smtp_oauth_service"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>';
// SuperAdministrator access only
if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
print $form->selectarray('MAIN_MAIL_SMTPS_OAUTH_SERVICE', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE);
} else {
$text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE];
if (empty($text)) {
$text = $langs->trans("Undefined");
}
$htmltext = $langs->trans("ContactSuperAdminForChange");
print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
print '<input type="hidden" name="MAIN_MAIL_SMTPS_OAUTH_SERVICE" value="'.$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE.'">';
}
print '</td></tr>';
}
// TLS
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
@ -595,29 +682,46 @@ if ($action == 'edit') {
print '</td></tr>';
// Host server
if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) {
if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE') == 'mail')) {
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td><span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span></td></tr>';
} else {
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '').'</td></tr>';
}
// Port
if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) {
if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE') == 'mail')) {
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td><span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span></td></tr>';
} else {
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '').'</td></tr>';
}
// SMTPS ID
if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) {
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE'), array('smtps', 'swiftmailer'))) {
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID.'</td></tr>';
}
// AUTH method
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE'), array('smtps', 'swiftmailer'))) {
$authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN');
$text = ($authtype === "LOGIN") ? $langs->trans("UsePassword") : ($authtype === "XOAUTH2" ? $langs->trans("UseOauth") : '') ;
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td><td>'.$text.'</td></tr>';
}
// SMTPS PW
if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) {
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') != "XOAUTH2") {
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).'</td></tr>';
}
// SMTPS oauth service
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') === "XOAUTH2") {
$text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE];
if (empty($text)) {
$text = $langs->trans("Undefined").img_warning();
}
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td><td>'.$text.'</td></tr>';
}
// TLS
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) {

View File

@ -557,6 +557,7 @@ if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_a
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
$totalarray['nbfield'] = 0;
while ($i < ($limit ? min($num, $limit) : $num)) {
$obj = $db->fetch_object($resql);
if (empty($obj)) {

View File

@ -62,7 +62,7 @@ if ($action == 'add') { // $provider is OAUTH_XXX
setEventMessages($langs->trans("AOAuthEntryForThisProviderAndLabelAlreadyHasAKey"), null, 'errors');
$error++;
} else {
dolibarr_set_const($db, $constname, 'ToComplete', 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, $constname, $langs->trans('ToComplete'), 'chaine', 0, '', $conf->entity);
setEventMessages($langs->trans("OAuthProviderAdded"), null);
}
}
@ -78,6 +78,16 @@ if ($action == 'update') {
if (!dolibarr_set_const($db, $constvalue.'_SECRET', GETPOST($constvalue.'_ID') ? GETPOST($constvalue.'_SECRET') : '', 'chaine', 0, '', $conf->entity)) {
$error++;
}
if (GETPOSTISSET($constvalue.'_URLAUTHORIZE')) {
if (!dolibarr_set_const($db, $constvalue.'_URLAUTHORIZE', GETPOST($constvalue.'_URLAUTHORIZE'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
if (GETPOSTISSET($constvalue.'_SCOPE')) {
if (!dolibarr_set_const($db, $constvalue.'_SCOPE', GETPOST($constvalue.'_SCOPE'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
}
}
@ -147,11 +157,17 @@ print '<table class="noborder centpercent">';
$i = 0;
//var_dump($list);
// Define $listinsetup
foreach ($conf->global as $key => $val) {
if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
$provider = preg_replace('/_ID$/', '', $key);
$listinsetup[] = array($provider.'_NAME', $provider.'_ID', $provider.'_SECRET', 'OAUTH Provider '.str_replace('OAUTH_', '', $provider));
$listinsetup[] = array(
$provider.'_NAME',
$provider.'_ID',
$provider.'_SECRET',
$provider.'_URLAUTHORIZE', // For custom oauth links
$provider.'_SCOPE' // For custom oauth links
);
}
}
@ -178,12 +194,16 @@ foreach ($listinsetup as $key) {
$i++;
print '<tr class="liste_titre'.($i > 1 ? ' liste_titre_add' : '').'">';
// Api Name
$label = $langs->trans($keyforsupportedoauth2array);
print '<tr class="liste_titre'.($i > 1 ? ' liste_titre_add' : '').'">';
print '<td>';
print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"');
print $label;
if ($label == $keyforsupportedoauth2array) {
print $supportedoauth2array[$keyforsupportedoauth2array]['name'];
} else {
print $label;
}
if ($keyforprovider) {
print ' (<b>'.$keyforprovider.'</b>)';
} else {
@ -201,8 +221,15 @@ foreach ($listinsetup as $key) {
$redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php';
print '<tr class="oddeven value">';
print '<td>'.$langs->trans("UseTheFollowingUrlAsRedirectURI").'</td>';
print '<td><input style="width: 80%" type"text" name="uri'.$keyforsupportedoauth2array.'" value="'.$redirect_uri.'">';
print '<td><input style="width: 80%" type"text" name="uri'.$keyforsupportedoauth2array.'" value="'.$redirect_uri.'" disabled>';
print '</td></tr>';
if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') {
print '<tr class="oddeven value">';
print '<td>'.$langs->trans("URLOfServiceForAuthorization").'</td>';
print '<td><input style="width: 80%" type"text" name="'.$key[3].'" value="'.getDolGlobalString($key[3]).'" >';
print '</td></tr>';
}
} else {
print '<tr class="oddeven value">';
print '<td>'.$langs->trans("UseTheFollowingUrlAsRedirectURI").'</td>';
@ -213,14 +240,32 @@ foreach ($listinsetup as $key) {
// Api Id
print '<tr class="oddeven value">';
print '<td><label for="'.$key[1].'">'.$langs->trans("OAUTH_ID").'</label></td>';
print '<td><input type="text" size="100" id="'.$key[1].'" name="'.$key[1].'" value="'.$conf->global->{$key[1]}.'">';
print '<td><input type="text" size="100" id="'.$key[1].'" name="'.$key[1].'" value="'.getDolGlobalString($key[1]).'">';
print '</td></tr>';
// Api Secret
print '<tr class="oddeven value">';
print '<td><label for="'.$key[2].'">'.$langs->trans("OAUTH_SECRET").'</label></td>';
print '<td><input type="password" size="100" id="'.$key[2].'" name="'.$key[2].'" value="'.$conf->global->{$key[2]}.'">';
print '<td><input type="password" size="100" id="'.$key[2].'" name="'.$key[2].'" value="'.getDolGlobalString($key[2]).'">';
print '</td></tr>';
// TODO Move this into token generation
if ($supported) {
if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') {
print '<tr class="oddeven value">';
print '<td>'.$langs->trans("Scopes").'</td>';
print '<td>';
print '<input style="width: 80%" type"text" name="'.$key[4].'" value="'.getDolGlobalString($key[4]).'" >';
print '</td></tr>';
} else {
print '<tr class="oddeven value">';
print '<td>'.$langs->trans("Scopes").'</td>';
print '<td>';
//print '<input style="width: 80%" type"text" name="'.$key[4].'" value="'.getDolGlobalString($key[4]).'" >';
print $supportedoauth2array[$keyforsupportedoauth2array]['defaultscope'];
print '</td></tr>';
}
}
}
print '</table>'."\n";

View File

@ -138,11 +138,17 @@ if (GETPOST('error')) {
if ($mode == 'setup' && $user->admin) {
print '<span class="opacitymedium">'.$langs->trans("OAuthSetupForLogin")."</span><br><br>\n";
//var_dump($list);
// Define $listinsetup
foreach ($conf->global as $key => $val) {
if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
$provider = preg_replace('/_ID$/', '', $key);
$listinsetup[] = array($provider.'_NAME', $provider.'_ID', $provider.'_SECRET', 'OAUTH Provider '.str_replace('OAUTH_', '', $provider));
$listinsetup[] = array(
$provider.'_NAME',
$provider.'_ID',
$provider.'_SECRET',
$provider.'_URLAUTHORIZE', // For custom oauth links
$provider.'_SCOPE' // For custom oauth links
);
}
}
@ -165,46 +171,39 @@ if ($mode == 'setup' && $user->admin) {
$OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : ''));
// Define $shortscope, $urltorenew, $urltodelete, $urltocheckperms
$shortscope = $supportedoauth2array[$keyforsupportedoauth2array]['defaultscope'];
if (getDolGlobalString($key[4])) {
$shortscope = getDolGlobalString($key[4]);
}
$state = $shortscope; // TODO USe a better state
// Define $urltorenew, $urltodelete, $urltocheckperms
// TODO Use array $supportedoauth2array
if ($keyforsupportedoauth2array == 'OAUTH_GITHUB_NAME') {
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
// We pass this param list in to 'state' because we need it before and after the redirect.
$shortscope = 'user,public_repo';
// Note: github does not accept csrf key inside the state parameter (only know values)
$urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
// Note: github does not accept csrf key inside the state parameter (only known values)
$urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://github.com/settings/applications/';
} elseif ($keyforsupportedoauth2array == 'OAUTH_GOOGLE_NAME') {
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
// List of scopes for Google are here: https://developers.google.com/identity/protocols/oauth2/scopes
// We pass this key list into the param 'state' because we need it before and after the redirect.
$shortscope = 'userinfo_email,userinfo_profile';
$shortscope .= ',openid,email,profile'; // For openid connect
if (!empty($conf->printing->enabled)) {
$shortscope .= ',cloud_print';
}
if (!empty($conf->global->OAUTH_GOOGLE_GSUITE)) {
$shortscope .= ',admin_directory_user';
}
if (!empty($conf->global->OAUTH_GOOGLE_GMAIL)) {
$shortscope.=',gmail_full';
}
$urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'-'.$oauthstateanticsrf.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'-'.$oauthstateanticsrf.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://security.google.com/settings/security/permissions';
} elseif ($keyforsupportedoauth2array == 'OAUTH_STRIPE_TEST_NAME') {
$shortscope = 'none';
$urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = '';
$urltocheckperms = '';
} elseif ($keyforsupportedoauth2array == 'OAUTH_STRIPE_LIVE_NAME') {
$shortscope = 'none';
$urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = '';
$urltocheckperms = '';
} elseif ($keyforsupportedoauth2array = 'OAUTH_OTHER_NAME') {
$urltorenew = $urlwithroot.'/core/modules/oauth/generic_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = '';
$urltocheckperms = '';
} else {
@ -212,7 +211,8 @@ if ($mode == 'setup' && $user->admin) {
$urltodelete = '';
$urltocheckperms = '';
}
$urltorenew .= '&keyforprovider='.$keyforprovider;
$urltorenew .= '&keyforprovider='.urlencode($keyforprovider);
// Show value of token
$tokenobj = null;
@ -246,7 +246,7 @@ if ($mode == 'setup' && $user->admin) {
} elseif ($endoflife == $tokenobj::EOL_UNKNOWN) {
$expiredat = $langs->trans("Unknown");
} else {
$expiredat = dol_print_date($endoflife, "dayhour");
$expiredat = dol_print_date($endoflife, "dayhour", 'tzuserrel');
}
}
}
@ -260,10 +260,16 @@ if ($mode == 'setup' && $user->admin) {
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'."\n";
// Api Name
$label = $langs->trans($keyforsupportedoauth2array);
print '<tr class="liste_titre">';
print '<th class="titlefieldcreate">';
print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"');
print $langs->trans($keyforsupportedoauth2array);
if ($label == $keyforsupportedoauth2array) {
print $supportedoauth2array[$keyforsupportedoauth2array]['name'];
} else {
print $label;
}
if ($keyforprovider) {
print ' (<b>'.$keyforprovider.'</b>)';
} else {
@ -292,7 +298,8 @@ if ($mode == 'setup' && $user->admin) {
print '</td>';
print '<td>';
if (is_object($tokenobj)) {
print $langs->trans("HasAccessToken");
// TODO Read in database to get the date of creation of token
print $form->textwithpicto(yn(1), $langs->trans("HasAccessToken").' : ');
} else {
print '<span class="opacitymedium">'.$langs->trans("NoAccessToken").'</span>';
}
@ -305,7 +312,9 @@ if ($mode == 'setup' && $user->admin) {
}
// Request remote token
if ($urltorenew) {
print '<a class="button smallpaddingimp" href="'.$urltorenew.'">'.$langs->trans('RequestAccess').'</a><br>';
print '<a class="button smallpaddingimp" href="'.$urltorenew.'">'.$langs->trans('GetAccess').'</a>';
print $form->textwithpicto('', $langs->trans('RequestAccess'));
print '<br>';
}
// Check remote access
if ($urltocheckperms) {
@ -378,8 +387,8 @@ if ($mode == 'setup' && $user->admin) {
}
}
print '</form>';
print '<br>';
}
}

View File

@ -61,14 +61,17 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
dol_print_error($db);
}
} elseif ($action == 'updateform') {
$res1 = 1; $res2 = 1;
$res1 = 1; $res2 = 1; $res3 = 1;
if (GETPOSTISSET('MAIN_APPLICATION_TITLE')) {
$res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
}
if (GETPOSTISSET('MAIN_SESSION_TIMEOUT')) {
$res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
}
if ($res1 && $res2) {
if (GETPOSTISSET('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT')) {
$res3 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", GETPOST("MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 'alphanohtml'), 'int', 0, '', $conf->entity);
}
if ($res1 && $res2 && $res3) {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
}
}
@ -174,6 +177,14 @@ print '<input class="flat right width50" name="MAIN_SESSION_TIMEOUT" type="text"
print '</td>';
print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("MaxNumberOfImagesInGetPost").'</td><td class="right">';
print '</td>';
print '<td class="nowrap">';
print '<input class="flat right width50" name="MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT" type="text" value="'.dol_escape_htmltag($conf->global->MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT).'"> '.strtolower($langs->trans("Images"));
print '</td>';
print '</tr>';
/*
if (empty($conf->global->MAIN_APPLICATION_TITLE)) {
$conf->global->MAIN_APPLICATION_TITLE = "";

View File

@ -643,7 +643,7 @@ print '</tr>'."\n";
print '<tr class="oddeven">';
print '<td>'.$langs->trans("MainDefaultWarehouse").'</td>';
print '<td class="right">';
print $formproduct->selectWarehouses($conf->global->MAIN_DEFAULT_WAREHOUSE, 'default_warehouse', '', 1, 0, 0, '', 0, 0, array(), 'left reposition');
print $formproduct->selectWarehouses(!empty($conf->global->MAIN_DEFAULT_WAREHOUSE) ? $conf->global->MAIN_DEFAULT_WAREHOUSE : -1, 'default_warehouse', '', 1, 0, 0, '', 0, 0, array(), 'left reposition');
print '<input type="submit" class="button button-edit small" value="'.$langs->trans("Modify").'">';
print "</td>";
print "</tr>\n";

View File

@ -168,9 +168,10 @@ print '<td class="liste_titre">';
print $langs->trans("DatabaseName").' : <b>'.$dolibarr_main_db_name.'</b><br>';
print '</td>';
print '</tr>';
print '<tr class="oddeven nohover"><td style="padding-left: 8px" class="nohover">';
print '<tr class="oddeven nohover"><td style="class="nohover">';
print '<table class="centpercent noborderbottom">';
print '<tr>';
print '<td class="tdtop nopaddingleftimp">';
@ -195,27 +196,31 @@ print '</fieldset>';
print '</div>';
print '</td>';
print '<td class="tdtop nopaddingrightimp">';
print '</tr>';
print '<button id="btn" type="button" onclick="hideoptions()">'.$langs->trans("ShowAdvancedOptions").'</button>';
print '<tr>';
print '<td class="tdtop nopaddingleftimp">';
print '<div class="centpercent center"><a id="lnk" href="javascript:hideoptions()"> '.$langs->trans("ShowAdvancedOptions").'...</a></div>';
print '<script type="text/javascript">
function hideoptions(){
const btn = document.getElementById("btn");
const lnk = document.getElementById("lnk");
const div = document.getElementById("div_container_sub_exportoptions");
if (div.style.display === "none") {
div.style.display = "block";
btn.innerText="'.$langs->trans("HideAdvancedoptions").'";
lnk.innerText="'.$langs->trans("HideAdvancedoptions").'";
} else {
div.style.display = "none";
btn.innerText="'.$langs->trans("ShowAdvancedOptions").'";
lnk.innerText="'.$langs->trans("ShowAdvancedOptions").'...";
}
}
</script>';
print '<div id="div_container_sub_exportoptions" style="display: none;">';
print '<br>';
if (in_array($type, array('mysql', 'mysqli'))) {
print "<!-- Fieldset mysqldump -->\n";
print '<fieldset id="mysql_options"><legend>'.$langs->trans("MySqlExportParameters").'</legend>';

View File

@ -203,25 +203,30 @@ if ($action == 'builddoc') {
$forceimgscalewidth = (empty($conf->global->BARCODE_FORCEIMGSCALEWIDTH) ? 1 : $conf->global->BARCODE_FORCEIMGSCALEWIDTH);
$forceimgscaleheight = (empty($conf->global->BARCODE_FORCEIMGSCALEHEIGHT) ? 1 : $conf->global->BARCODE_FORCEIMGSCALEHEIGHT);
for ($i = 0; $i < $numberofsticker; $i++) {
$arrayofrecords[] = array(
'textleft'=>$textleft,
'textheader'=>$textheader,
'textfooter'=>$textfooter,
'textright'=>$textright,
'code'=>$code,
'encoding'=>$encoding,
'is2d'=>$is2d,
'photo'=>$barcodeimage // Photo must be a file that exists with format supported by TCPDF
);
$MAXSTICKERS = 1000;
if ($numberofsticker <= $MAXSTICKERS) {
for ($i = 0; $i < $numberofsticker; $i++) {
$arrayofrecords[] = array(
'textleft'=>$textleft,
'textheader'=>$textheader,
'textfooter'=>$textfooter,
'textright'=>$textright,
'code'=>$code,
'encoding'=>$encoding,
'is2d'=>$is2d,
'photo'=>$barcodeimage // Photo must be a file that exists with format supported by TCPDF
);
}
} else {
$mesg = $langs->trans("ErrorQuantityIsLimitedTo", $MAXSTICKERS);
$error++;
}
}
$i++;
$mesg = '';
// Build and output PDF
if ($mode == 'label') {
if (!$error && $mode == 'label') {
if (!count($arrayofrecords)) {
$mesg = $langs->trans("ErrorRecordNotFound");
}
@ -240,7 +245,7 @@ if ($action == 'builddoc') {
}
}
if ($result <= 0 || $mesg) {
if ($result <= 0 || $mesg || $error) {
if (empty($mesg)) {
$mesg = 'Error '.$result;
}
@ -272,8 +277,6 @@ print '<br>';
print '<span class="opacitymedium">'.$langs->trans("PageToGenerateBarCodeSheets", $langs->transnoentitiesnoconv("BuildPageToPrint")).'</span><br>';
print '<br>';
dol_htmloutput_errors($mesg);
//print img_picto('','puce').' '.$langs->trans("PrintsheetForOneBarCode").'<br>';
//print '<br>';

View File

@ -305,7 +305,8 @@ class Categories extends DolibarrApi
Categorie::TYPE_CUSTOMER,
Categorie::TYPE_SUPPLIER,
Categorie::TYPE_MEMBER,
Categorie::TYPE_PROJECT
Categorie::TYPE_PROJECT,
Categorie::TYPE_KNOWLEDGEMANAGEMENT
])) {
throw new RestException(401);
}
@ -322,6 +323,8 @@ class Categories extends DolibarrApi
throw new RestException(401);
} elseif ($type == Categorie::TYPE_PROJECT && !DolibarrApiAccess::$user->rights->projet->lire) {
throw new RestException(401);
} elseif ($type == Categorie::TYPE_KNOWLEDGEMANAGEMENT && !DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read) {
throw new RestException(401);
}
$categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page);

View File

@ -332,6 +332,7 @@ class Categorie extends CommonObject
// Check parameters
if (empty($id) && empty($label) && empty($ref_ext)) {
$this->error = "No category to search for";
return -1;
}
if (!is_null($type) && !is_numeric($type)) {
@ -389,6 +390,7 @@ class Categorie extends CommonObject
return 1;
} else {
$this->error = "No category found";
return 0;
}
} else {

View File

@ -103,7 +103,7 @@ if ($confirm == 'no') {
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Remove element from category
if ($id > 0 && $removeelem > 0) {
if ($id > 0 && $removeelem > 0 && $action == 'unlink') {
if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$tmpobject = new Product($db);
@ -521,7 +521,8 @@ if ($type == Categorie::TYPE_PRODUCT) {
print '<input type="hidden" name="action" value="list">';
print '<br>';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = ''; $newcardbutton = '';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = '';
$newcardbutton = dolGetButtonTitle($langs->trans("AddProduct"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&categories[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer);
print_barre_liste($langs->trans("ProductsAndServices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit);
@ -544,7 +545,7 @@ if ($type == Categorie::TYPE_PRODUCT) {
// Link to delete from category
print '<td class="right">';
if ($permission) {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$prod->id."'>";
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$prod->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
@ -597,7 +598,8 @@ if ($type == Categorie::TYPE_CUSTOMER) {
print '<input type="hidden" name="action" value="list">';
print '<br>';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = ''; $newcardbutton = '';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = '';
$newcardbutton = dolGetButtonTitle($langs->trans("AddThirdParty"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&client=3&custcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer);
print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
print '<table class="noborder centpercent">'."\n";
@ -618,7 +620,7 @@ if ($type == Categorie::TYPE_CUSTOMER) {
// Link to delete from category
print '<td class="right">';
if ($permission) {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$soc->id."'>";
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$soc->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
@ -671,7 +673,8 @@ if ($type == Categorie::TYPE_SUPPLIER) {
print '<input type="hidden" name="action" value="list">';
print '<br>';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = ''; $newcardbutton = '';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = '';
$newcardbutton = dolGetButtonTitle($langs->trans("AddSupplier"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&fournisseur=1&suppcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer);
print_barre_liste($langs->trans("Suppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
print '<table class="noborder centpercent">'."\n";
@ -692,7 +695,7 @@ if ($type == Categorie::TYPE_SUPPLIER) {
// Link to delete from category
print '<td class="right">';
if ($permission) {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$soc->id."'>";
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$soc->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
@ -748,7 +751,8 @@ if ($type == Categorie::TYPE_MEMBER) {
print '<input type="hidden" name="action" value="list">';
print '<br>';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = ''; $newcardbutton = '';
$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = '';
$newcardbutton = dolGetButtonTitle($langs->trans("AddMember"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create&memcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->adherent->creer);
print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit);
print "<table class='noborder' width='100%'>\n";
@ -772,7 +776,7 @@ if ($type == Categorie::TYPE_MEMBER) {
// Link to delete from category
print '<td class="right">';
if ($permission) {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$member->id."'>";
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$member->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
@ -788,7 +792,7 @@ if ($type == Categorie::TYPE_MEMBER) {
}
}
// Categorie contact
// List of contacts
if ($type == Categorie::TYPE_CONTACT) {
$permission = $user->rights->societe->creer;
@ -808,7 +812,7 @@ if ($type == Categorie::TYPE_CONTACT) {
print '<input type="hidden" name="action" value="addintocategory">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>';
print $langs->trans("AddContactIntoCategory").' &nbsp;';
print $langs->trans("AssignCategoryTo").' &nbsp;';
print $form->selectContacts('', '', 'elemid');
print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
print '</tr>';
@ -826,7 +830,7 @@ if ($type == Categorie::TYPE_CONTACT) {
$param = '&limit='.$limit.'&id='.$id.'&type='.$type;
$num = count($contacts);
$nbtotalofrecords = '';
$newcardbutton = '';
$newcardbutton = dolGetButtonTitle($langs->trans("AddContact"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create&contcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer);
$objsoc = new Societe($db);
print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contact', 0, $newcardbutton, '', $limit);
@ -853,7 +857,7 @@ if ($type == Categorie::TYPE_CONTACT) {
// Link to delete from category
print '<td class="right">';
if ($permission) {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$contact->id."'>";
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$contact->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
@ -931,7 +935,7 @@ if ($type == Categorie::TYPE_ACCOUNT) {
// Link to delete from category
print '<td class="right">';
if ($permission) {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$account->id."'>";
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$account->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
@ -1009,7 +1013,7 @@ if ($type == Categorie::TYPE_PROJECT) {
// Link to delete from category
print '<td class="right">';
if ($permission) {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$project->id."'>";
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$project->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
@ -1026,7 +1030,7 @@ if ($type == Categorie::TYPE_PROJECT) {
}
// List of users
if ($type == Categorie::TYPE_USER) {
if ($type == Categorie::TYPE_USER && $user->hasRight("user", "user", "read")) {
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
$users = $object->getObjectsInCateg($type);
@ -1081,7 +1085,7 @@ if ($type == Categorie::TYPE_USER) {
// Link to delete from category
print '<td class="right">';
if ($user->rights->user->user->creer) {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$type."&amp;removeelem=".$userentry->id."'>";
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$type."&action=unlink&token=".newToken()."&removeelem=".$userentry->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
@ -1095,6 +1099,9 @@ if ($type == Categorie::TYPE_USER) {
print '</form>'."\n";
}
} else {
print_barre_liste($langs->trans("Users"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'user');
accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0);
}
@ -1140,7 +1147,7 @@ if ($type == Categorie::TYPE_WAREHOUSE) {
// Link to delete from category
print '<td class="right">';
if ($permission) {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$project->id."'>";
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$project->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";
@ -1156,6 +1163,7 @@ if ($type == Categorie::TYPE_WAREHOUSE) {
}
}
// List of tickets
if ($type == Categorie::TYPE_TICKET) {
$permission = ($user->rights->categorie->creer || $user->rights->categorie->creer);
@ -1212,7 +1220,7 @@ if ($type == Categorie::TYPE_TICKET) {
// Link to delete from category
print '<td class="right">';
if ($permission) {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$ticket->id."'>";
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$ticket->id."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
print "</a>";

View File

@ -538,7 +538,7 @@ if (empty($reshook) && $action == 'add') {
$error++;
}
// End date
$repeateventlimitdate = dol_mktime('23', '59', '59', GETPOSTISSET("limitmonth", 'int') ? GETPOST("limitmonth", 'int') : 01, GETPOSTISSET("limitday", 'int') ? GETPOST("limitday", 'int') : 01, GETPOSTISSET("limityear", 'int') && GETPOST("limityear", 'int') < 2100 ? GETPOST("limityear", 'int') : 2100, $tzforfullday ? $tzforfullday : 'tzuser');
$repeateventlimitdate = dol_mktime('23', '59', '59', GETPOSTISSET("limitmonth") ? GETPOST("limitmonth", 'int') : 01, GETPOSTISSET("limitday", 'int') ? GETPOST("limitday", 'int') : 01, GETPOSTISSET("limityear", 'int') && GETPOST("limityear", 'int') < 2100 ? GETPOST("limityear", 'int') : 2100, $tzforfullday ? $tzforfullday : 'tzuser');
// Set date of end of event
$deltatime = num_between_day($object->datep, $datep);
$datef = dol_time_plus_duree($datef, $deltatime, 'd');

View File

@ -216,6 +216,9 @@ class CActionComm
if ($obj->module == 'shipping' && !empty($conf->expedition->enabled) && !empty($user->rights->expedition->lire)) {
$qualified = 1;
}
if (preg_split("/@/", $obj->module, -1)[1] == 'eventorganization' && !empty($conf->eventorganization->enabled)) {
$qualified = 1;
}
// For the generic case with type = 'module...' and module = 'myobject@mymodule'
$regs = array();
if (preg_match('/^module/', $obj->type)) {

View File

@ -75,7 +75,7 @@ if ($_socid > 0) {
// We load data of thirdparty
$objsoc = new Societe($db);
$objsoc->id = $_socid;
$objsoc->fetch($_socid, $to);
$objsoc->fetch($_socid);
$head = societe_prepare_head($objsoc);
@ -141,7 +141,6 @@ if ($_socid > 0) {
$resql = $db->query($sql);
if ($resql) {
print '<table class="noborder centpercent">';
$tag = !$tag;
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("PriceLevel").'</td>';

View File

@ -112,17 +112,17 @@ if ($id > 0 || !empty($ref)) {
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('propalcard', 'globalcard'));
$usercanread = $user->rights->propal->lire;
$usercancreate = $user->rights->propal->creer;
$usercandelete = $user->rights->propal->supprimer;
$usercanread = $user->hasRight("propal", "lire");
$usercancreate = $user->hasRight("propal", "creer");
$usercandelete = $user->hasRight("propal", "supprimer");
$usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->close)));
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->validate)));
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->send)));
$usercancreateorder = $user->rights->commande->creer;
$usercancreateinvoice = $user->rights->facture->creer;
$usercancreatecontract = $user->rights->contrat->creer;
$usercancreateorder = $user->hasRight('commande', 'creer');
$usercancreateinvoice = $user->hasRight('facture', 'creer');
$usercancreatecontract = $user->hasRight('contrat', 'creer');
$usercancreateintervention = $user->hasRight('ficheinter', 'creer');
$usercancreatepurchaseorder = ($user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer'));

View File

@ -108,9 +108,9 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
$usercanread = $user->hasRight('commande', 'lire');
$usercancreate = $user->hasRight('commande', 'creer');
$usercandelete = $user->hasRight('commande', 'supprimer');
$usercanread = $user->hasRight("commande", "lire");
$usercancreate = $user->hasRight("commande", "creer");
$usercandelete = $user->hasRight("commande", "supprimer");
// Advanced permissions
$usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->hasRight('commande', 'order_advance', 'close'))));

View File

@ -846,6 +846,9 @@ if ($action == 'create') {
$object = new Account($db);
$object->fetch(GETPOST('id', 'int'));
$title = $object->ref." - ".$langs->trans("Card");
llxHeader("", $title, $help_url);
print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'bank_account');
if ($conf->use_javascript_ajax) {
@ -1014,7 +1017,7 @@ if ($action == 'create') {
$tdextra = ' class="fieldrequired titlefieldcreate"';
}
print '<tr class="liste_titre_add"><td'.$tdextra.'>'.$langs->trans("AccountancyCode").'</td>';
print '<tr><td'.$tdextra.'>'.$langs->trans("AccountancyCode").'</td>';
print '<td>';
if (!empty($conf->accounting->enabled)) {
print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);

View File

@ -387,6 +387,10 @@ if (empty($numref)) {
* Show list of record into a bank statement
*/
$title = $langs->trans("FinancialAccount").' - '.$langs->trans("AccountStatements");
$helpurl = "";
llxHeader('', $title, $helpurl);
// Onglets
$head = account_statement_prepare_head($object, $numref);
print dol_get_fiche_head($head, 'statement', $langs->trans("AccountStatement"), -1, 'account');

View File

@ -128,11 +128,11 @@ if ($id > 0 || !empty($ref)) {
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('invoicecard', 'globalcard'));
$usercanread = $user->rights->facture->lire;
$usercancreate = $user->rights->facture->creer;
$usercanissuepayment = $user->rights->facture->paiement;
$usercandelete = $user->rights->facture->supprimer;
$usercancreatecontract = $user->rights->contrat->creer;
$usercanread = $user->hasRight("facture", "lire");
$usercancreate = $user->hasRight("facture", "creer");
$usercanissuepayment = $user->hasRight("facture", "paiement");
$usercandelete = $user->hasRight("facture", "supprimer");
$usercancreatecontract = $user->hasRight("contrat", "creer");
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->validate)));
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->send)));
$usercanreopen = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->reopen)));

View File

@ -363,11 +363,11 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter',
$search_datelimit_start = '';
$search_datelimit_end = '';
$search_fac_rec_source_title = '';
$option = '';
$filter = '';
$toselect = array();
$search_array_options = array();
$search_categ_cus = 0;
$option = '';
$socid = 0;
}
if (empty($reshook)) {
@ -919,7 +919,7 @@ if ($resql) {
llxHeader('', $langs->trans('CustomersInvoices'), 'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
if ($socid) {
if ($socid > 0) {
$soc = new Societe($db);
$soc->fetch($socid);
if (empty($search_company)) {
@ -1151,8 +1151,9 @@ if ($resql) {
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="search_status" value="'.$search_status.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<input type="hidden" name="socid" value="'.$socid.'">';
print_barre_liste($langs->trans('BillsCustomers').' '.($socid ? ' '.$soc->name : ''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1);
print_barre_liste($langs->trans('BillsCustomers').' '.($socid > 0 ? ' '.$soc->name : ''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1);
$topicmail = "SendBillRef";
$modelmail = "facture_send";
@ -1329,7 +1330,7 @@ if ($resql) {
}
// Thirdparty
if (!empty($arrayfields['s.nom']['checked'])) {
print '<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company" value="'.$search_company.'"></td>';
print '<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company" value="'.$search_company.'"'.($socid > 0 ? " disabled" : "").'></td>';
}
// Alias
if (!empty($arrayfields['s.name_alias']['checked'])) {
@ -2083,7 +2084,7 @@ if ($resql) {
// Amount HT
if (!empty($arrayfields['f.total_ht']['checked'])) {
print '<td class="right nowraponall">'.price($obj->total_ht)."</td>\n";
print '<td class="right nowraponall amount">'.price($obj->total_ht)."</td>\n";
if (!$i) {
$totalarray['nbfield']++;
}

View File

@ -102,19 +102,24 @@ print load_fiche_titre($langs->trans("AccountancyTreasuryArea"), '', 'bill');
print '<div class="fichecenter"><div class="fichethirdleft">';
print getNumberInvoicesPieChart('customers');
print '<br>';
if (isModEnabled('facture')) {
print getNumberInvoicesPieChart('customers');
print '<br>';
}
if (!empty($conf->fournisseur->enabled)) {
if (isModEnabled('fournisseur') || isModEnabled('supplier_invoice')) {
print getNumberInvoicesPieChart('fourn');
print '<br>';
}
print getCustomerInvoiceDraftTable($max, $socid);
if (!empty($conf->fournisseur->enabled)) {
if (isModEnabled('facture')) {
print getCustomerInvoiceDraftTable($max, $socid);
print '<br>';
}
if (isModEnabled('fournisseur') || isModEnabled('supplier_invoice')) {
print getDraftSupplierTable($max, $socid);
print '<br>';
}
print '</div><div class="fichetwothirdright">';
@ -273,7 +278,7 @@ if (isModEnabled('facture') && !empty($user->rights->facture->lire)) {
// Last modified supplier invoices
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)) {
if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) {
$langs->load("boxes");
$facstatic = new FactureFournisseur($db);
@ -400,7 +405,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
// Latest donations
if (!empty($conf->don->enabled) && !empty($user->rights->don->lire)) {
if (isModEnabled('don') && !empty($user->rights->don->lire)) {
include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
$langs->load("boxes");
@ -490,7 +495,7 @@ if (!empty($conf->don->enabled) && !empty($user->rights->don->lire)) {
/**
* Social contributions to pay
*/
if (!empty($conf->tax->enabled) && !empty($user->rights->tax->charges->lire)) {
if (isModEnabled('tax') && !empty($user->rights->tax->charges->lire)) {
if (!$socid) {
$chargestatic = new ChargeSociales($db);
@ -582,7 +587,7 @@ if (!empty($conf->tax->enabled) && !empty($user->rights->tax->charges->lire)) {
/*
* Customers orders to be billed
*/
if (isModEnabled('facture') && !empty($conf->commande->enabled) && $user->rights->commande->lire && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) {
if (isModEnabled('facture') && isModEnabled('commande') && $user->rights->commande->lire && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) {
$commandestatic = new Commande($db);
$langs->load("orders");

View File

@ -59,8 +59,15 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
$upload_dir = $conf->bank->multidir_output[$object->entity ? $object->entity : $conf->entity]."/checkdeposits";
$filterdate = dol_mktime(0, 0, 0, GETPOST('fdmonth'), GETPOST('fdday'), GETPOST('fdyear'));
// filter by dates from / to
$search_date_start_day = GETPOST('search_date_start_day', 'int');
$search_date_start_month = GETPOST('search_date_start_month', 'int');
$search_date_start_year = GETPOST('search_date_start_year', 'int');
$search_date_end_day = GETPOST('search_date_end_day', 'int');
$search_date_end_month = GETPOST('search_date_end_month', 'int');
$search_date_end_year = GETPOST('search_date_end_year', 'int');
$search_date_start = dol_mktime(0, 0, 0, $search_date_start_month, $search_date_start_day, $search_date_start_year);
$search_date_end = dol_mktime(23, 59, 59, $search_date_end_month, $search_date_end_day, $search_date_end_year);
$filteraccountid = GETPOST('accountid', 'int');
// Security check
@ -265,7 +272,15 @@ if ($action == 'builddoc' && $user->rights->banque->cheque) {
*/
if (GETPOST('removefilter')) {
$filterdate = '';
// filter by dates from / to
$search_date_start_day = '';
$search_date_start_month = '';
$search_date_start_year = '';
$search_date_end_day = '';
$search_date_end_month = '';
$search_date_end_year = '';
$search_date_start = '';
$search_date_end = '';
$filteraccountid = 0;
}
@ -352,7 +367,13 @@ if ($action == 'new') {
//print '<tr><td width="30%">'.$langs->trans('Date').'</td><td width="70%">'.dol_print_date($now,'day').'</td></tr>';
// Filter
print '<tr><td class="titlefieldcreate">'.$langs->trans("DateChequeReceived").'</td><td>';
print $form->selectDate($filterdate, 'fd', 0, 0, 1, '', 1, 1);
// filter by dates from / to
print '<div class="nowrap">';
print $form->selectDate($search_date_start, 'search_date_start_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('From'));
print '</div>';
print '<div class="nowrap">';
print $form->selectDate($search_date_end, 'search_date_end_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('to'));
print '</div>';
print '</td></tr>';
print '<tr><td>'.$langs->trans("BankAccount").'</td><td>';
$form->select_comptes($filteraccountid, 'accountid', 0, 'courant <> 2', 1);
@ -363,7 +384,7 @@ if ($action == 'new') {
print '<div class="center">';
print '<input type="submit" class="button" name="filter" value="'.dol_escape_htmltag($langs->trans("ToFilter")).'">';
if ($filterdate || $filteraccountid > 0) {
if ($search_date_start || $search_date_end || $filteraccountid > 0) {
print ' &nbsp; ';
print '<input type="submit" class="button" name="removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
}
@ -382,8 +403,11 @@ if ($action == 'new') {
$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
$sql .= " AND b.fk_bordereau = 0";
$sql .= " AND b.amount > 0";
if ($filterdate) {
$sql .= " AND b.dateo = '".$db->idate($filterdate)."'";
if ($search_date_start) {
$sql .= " AND b.dateo >= '".$db->idate($search_date_start)."'";
}
if ($search_date_end) {
$sql .= " AND b.dateo <= '".$db->idate($search_date_end)."'";
}
if ($filteraccountid > 0) {
$sql .= " AND ba.rowid = ".((int) $filteraccountid);

View File

@ -185,7 +185,7 @@ $dolibarr_main_instance_unique_id='84b5bc91f83b56e458db71e0adac2b62';
// values using a ",". In this case, Dolibarr will check login/pass for each value in
// order defined into value. However, note that this can't work with all values.
// Examples:
// $dolibarr_main_authentication='dolibarr'; // Use the password defined into application on user record.
// $dolibarr_main_authentication='dolibarr'; // Use the password defined into application on user file (default).
// $dolibarr_main_authentication='http'; // Use the HTTP Basic authentication
// $dolibarr_main_authentication='ldap'; // Check the password into a LDAP server
// $dolibarr_main_authentication='ldap,dolibarr'; // You can set several mode using a comma as a separator.

View File

@ -207,16 +207,16 @@ foreach ($object->fields as $key => $val) {
}
// Add none object fields to fields for list
$arrayfields['country.code_iso'] = array('label'=>"Country", 'position'=>22, 'checked'=>0);
$arrayfields['country.code_iso'] = array('label'=>"Country", 'position'=>66, 'checked'=>0);
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
$arrayfields['s.nom'] = array('label'=>"ThirdParty", 'position'=>25, 'checked'=>1);
$arrayfields['s.nom'] = array('label'=>"ThirdParty", 'position'=>113, 'checked'=> 1);
}
$arrayfields['unsubscribed'] = array(
'label'=>'No_Email',
'checked'=>0,
'enabled'=>(!empty($conf->mailing->enabled)),
'position'=>41);
'position'=>111);
if (!empty($conf->socialnetworks->enabled)) {
foreach ($socialnetworks as $key => $value) {

View File

@ -361,7 +361,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO
}
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext);
if ($mailfile->error) {
if (!empty($mailfile->error) || !empty($mailfile->errors)) {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
$action = 'presend';
} else {
@ -427,9 +427,14 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO
} else {
$langs->load("other");
$mesg = '<div class="error">';
if ($mailfile->error) {
if (!empty($mailfile->error) || !empty($mailfile->errors)) {
$mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
$mesg .= '<br>'.$mailfile->error;
if (!empty($mailfile->error)) {
$mesg .= '<br>'.$mailfile->error;
}
if (!empty($mailfile->errors) && is_array($mailfile->errors)) {
$mesg .= '<br>'.implode('<br>', $mailfile->errors);
}
} else {
$mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {

View File

@ -64,11 +64,11 @@ $arrayresult = array();
// Define $searchform
if (isModEnabled('adherent') && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) {
if (isModEnabled('adherent') && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->hasRight('adherent', 'lire')) {
$arrayresult['searchintomember'] = array('position'=>8, 'shortcut'=>'M', 'img'=>'object_member', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('', 'object_member', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (((!empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->rights->societe->lire) {
if (((isModEnabled('societe') && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled('supplier_order') || isModEnabled('supplier_invoice'))) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->hasRight('societe', 'lire')) {
$arrayresult['searchintothirdparty'] = array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('', 'object_company', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
@ -76,7 +76,7 @@ if (isModEnabled('societe') && empty($conf->global->MAIN_SEARCHFORM_CONTACT_DISA
$arrayresult['searchintocontact'] = array('position'=>15, 'shortcut'=>'A', 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('', 'object_contact', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (((!empty($conf->product->enabled) && $user->hasRight('produit', 'lire')) || (!empty($conf->service->enabled) && $user->hasRight('service', 'lire'))) && empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED)) {
if (((isModEnabled('product') && $user->hasRight('produit', 'lire')) || (isModEnabled('service') && $user->hasRight('service', 'lire'))) && empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED)) {
$arrayresult['searchintoproduct'] = array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'text'=>img_picto('', 'object_product', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
// search on lot/serial numbers
if (isModEnabled('productbatch')) {
@ -108,13 +108,13 @@ if (isModEnabled('facture') && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INV
$arrayresult['searchintoinvoice'] = array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_bill', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (isModEnabled('supplier_proposal') && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire) {
if (isModEnabled('supplier_proposal') && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->hasRight('supplier_proposal', 'lire')) {
$arrayresult['searchintosupplierpropal'] = array('position'=>100, 'img'=>'object_supplier_proposal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_proposal', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED)) {
if (((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight('fournisseur', 'commande', 'lire')) || (isModEnabled('supplier_order') && $user->hasRight('supplier_order', 'lire'))) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED)) {
$arrayresult['searchintosupplierorder'] = array('position'=>110, 'img'=>'object_supplier_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_order', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : ''));
}
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED)) {
if (((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight('fournisseur', 'facture', 'lire')) || (isModEnabled('supplier_invoice') && $user->hasRight('supplier_invoice', 'lire'))) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED)) {
$arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_supplier_invoice', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_invoice', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
@ -129,7 +129,7 @@ if (isModEnabled('facture') && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INV
}
// Vendor payments
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED)) {
if (((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight('fournisseur', 'facture', 'lire')) || (isModEnabled('supplier_invoice') && $user->hasRight('supplier_invoice', 'lire'))) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED)) {
$arrayresult['searchintovendorpayments'] = array(
'position'=>175,
'img'=>'object_payment',
@ -139,7 +139,7 @@ if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_S
}
// Miscellaneous payments
if (isModEnabled('banque') && empty($conf->global->MAIN_SEARCHFORM_MISC_PAYMENTS_DISABLED) && $user->rights->banque->lire) {
if (isModEnabled('banque') && empty($conf->global->MAIN_SEARCHFORM_MISC_PAYMENTS_DISABLED) && $user->hasRight('banque', 'lire')) {
$arrayresult['searchintomiscpayments'] = array(
'position'=>180,
'img'=>'object_payment',
@ -148,24 +148,24 @@ if (isModEnabled('banque') && empty($conf->global->MAIN_SEARCHFORM_MISC_PAYMENTS
'url'=>DOL_URL_ROOT.'/compta/bank/various_payment/list.php?leftmenu=tax_various'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
if (isModEnabled('contrat') && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) {
if (isModEnabled('contrat') && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->hasRight('contrat', 'lire')) {
$arrayresult['searchintocontract'] = array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('', 'object_contract', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (isModEnabled('ficheinter') && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->rights->ficheinter->lire) {
if (isModEnabled('ficheinter') && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->hasRight('ficheinter', 'lire')) {
$arrayresult['searchintointervention'] = array('position'=>140, 'img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('', 'object_intervention', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (isModEnabled('ticket') && empty($conf->global->MAIN_SEARCHFORM_TICKET_DISABLED) && $user->rights->ticket->read) {
if (isModEnabled('ticket') && empty($conf->global->MAIN_SEARCHFORM_TICKET_DISABLED) && $user->hasRight('ticket', 'read')) {
$arrayresult['searchintotickets'] = array('position'=>145, 'img'=>'object_ticket', 'label'=>$langs->trans("SearchIntoTickets", $search_boxvalue), 'text'=>img_picto('', 'object_ticket', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoTickets", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/ticket/list.php?mainmenu=ticket'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
// HR
if (isModEnabled('user') && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) {
if (isModEnabled('user') && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->hasRight('user', 'user', 'lire')) {
$arrayresult['searchintouser'] = array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('', 'object_user', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (isModEnabled('expensereport') && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire) {
if (isModEnabled('expensereport') && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->hasRight('expensereport', 'lire')) {
$arrayresult['searchintoexpensereport'] = array('position'=>210, 'img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('', 'object_trip', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
if (isModEnabled('holiday') && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->rights->holiday->read) {
if (isModEnabled('holiday') && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->hasRight('holiday', 'read')) {
$arrayresult['searchintoleaves'] = array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('', 'object_holiday', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}

View File

@ -85,13 +85,19 @@ class box_birthdays extends ModeleBoxes
if ($user->rights->user->user->lire) {
$tmparray = dol_getdate(dol_now(), true);
$sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth, u.email, u.statut as status";
$sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth as datea, 'birth' as typea, u.email, u.statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.entity IN (".getEntity('user').")";
$sql .= " AND u.statut = 1";
$sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0);
$sql .= " ORDER BY DAY(u.birth) ASC";
$sql .= $this->db->plimit($max, 0);
$sql .= ' UNION ';
$sql .= "SELECT u.rowid, u.firstname, u.lastname, u.dateemployment as datea, 'employment' as typea, u.email, u.statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.entity IN (".getEntity('user').")";
$sql .= " AND u.statut = 1";
$sql .= dolSqlDateFilter('u.dateemployment', 0, $tmparray['mon'], 0);
$sql .= " ORDER BY DAY(datea) ASC";
dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
$result = $this->db->query($sql);
@ -108,9 +114,13 @@ class box_birthdays extends ModeleBoxes
$userstatic->email = $objp->email;
$userstatic->statut = $objp->status;
$dateb = $this->db->jdate($objp->birth);
$dateb = $this->db->jdate($objp->datea);
$age = date('Y', dol_now()) - date('Y', $dateb);
$picb = '<i class="fas fa-birthday-cake inline-block"></i>';
$pice = '<i class="fas fa-briefcase inline-block"></i>';
$typea = ($objp->typea == 'birth') ? $picb : $pice;
$this->info_box_contents[$line][] = array(
'td' => '',
'text' => $userstatic->getNomUrl(1),
@ -119,7 +129,18 @@ class box_birthdays extends ModeleBoxes
$this->info_box_contents[$line][] = array(
'td' => 'class="center nowraponall"',
'text' => dol_print_date($dateb, "day", 'tzserver').' - '.$age.' '.$langs->trans('DurationYears')
'text' => dol_print_date($dateb, "day", 'tzserver')
);
$this->info_box_contents[$line][] = array(
'td' => 'class="right nowraponall"',
'text' => $age.' '.$langs->trans('DurationYears')
);
$this->info_box_contents[$line][] = array(
'td' => 'class="center nowraponall"',
'text' => $typea,
'asis' => 1
);
/*$this->info_box_contents[$line][] = array(

View File

@ -6,7 +6,7 @@
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2019-2020 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019-2022 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -30,6 +30,7 @@
* \brief File of class to send emails (with attachments or not)
*/
use OAuth\Common\Storage\DoliStorage;
/**
* Class to send emails (with attachments or not)
* Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto);
@ -71,9 +72,29 @@ class CMailFile
*/
public $error = '';
/**
* @var string[] Array of Error code (or message)
*/
public $errors = array();
public $smtps; // Contains SMTPs object (if this method is used)
public $phpmailer; // Contains PHPMailer object (if this method is used)
/**
* @var Swift_SmtpTransport
*/
public $transport;
/**
* @var Swift_Mailer
*/
public $mailer;
/**
* @var Swift_Plugins_Loggers_ArrayLogger
*/
public $logger;
/**
* @var string CSS
*/
@ -470,12 +491,12 @@ class CMailFile
$emailMatchs = preg_match_all($regexp, $from, $adressEmailFrom);
$adressEmailFrom = reset($adressEmailFrom);
if ($emailMatchs !== false && filter_var($conf->global->MAIN_MAIL_SMTPS_ID, FILTER_VALIDATE_EMAIL) && $conf->global->MAIN_MAIL_SMTPS_ID !== $adressEmailFrom) {
$result = $this->message->setFrom($conf->global->MAIN_MAIL_SMTPS_ID);
$this->message->setFrom($conf->global->MAIN_MAIL_SMTPS_ID);
} else {
$result = $this->message->setFrom($this->getArrayAddress($this->addr_from));
$this->message->setFrom($this->getArrayAddress($this->addr_from));
}
} else {
$result = $this->message->setFrom($this->getArrayAddress($this->addr_from));
$this->message->setFrom($this->getArrayAddress($this->addr_from));
}
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
@ -485,7 +506,7 @@ class CMailFile
// Set the To addresses with an associative array
if (!empty($this->addr_to)) {
try {
$result = $this->message->setTo($this->getArrayAddress($this->addr_to));
$this->message->setTo($this->getArrayAddress($this->addr_to));
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
@ -493,14 +514,14 @@ class CMailFile
if (!empty($this->reply_to)) {
try {
$result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to));
$this->message->SetReplyTo($this->getArrayAddress($this->reply_to));
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
}
try {
$result = $this->message->setCharSet($conf->file->character_set_client);
$this->message->setCharSet($conf->file->character_set_client);
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
@ -547,14 +568,26 @@ class CMailFile
}
if (!empty($this->addr_cc)) {
$this->message->setCc($this->getArrayAddress($this->addr_cc));
try {
$this->message->setCc($this->getArrayAddress($this->addr_cc));
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
}
if (!empty($this->addr_bcc)) {
$this->message->setBcc($this->getArrayAddress($this->addr_bcc));
try {
$this->message->setBcc($this->getArrayAddress($this->addr_bcc));
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
}
//if (! empty($this->errors_to)) $this->message->setErrorsTo($this->getArrayAddress($this->errors_to));
if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) {
$this->message->setReadReceiptTo($this->getArrayAddress($this->addr_from));
try {
$this->message->setReadReceiptTo($this->getArrayAddress($this->addr_from));
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
}
} else {
// Send mail method not correctly defined
@ -657,6 +690,8 @@ class CMailFile
}
$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER';
$keyforsmtpauthtype = "MAIN_MAIL_SMTPS_AUTH_TYPE";
$keyforsmtpoauthservice = "MAIN_MAIL_SMTPS_OAUTH_SERVICE";
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT';
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID';
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW';
@ -832,6 +867,36 @@ class CMailFile
$this->smtps->setPW($loginpass);
}
if (getDolGlobalString($keyforsmtpauthtype) === "XOAUTH2") {
require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array
$keyforsupportedoauth2array = $conf->global->$keyforsmtpoauthservice;
if (preg_match('/^.*-/', $keyforsupportedoauth2array)) {
$keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array);
} else {
$keyforprovider = '';
}
$keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array);
$keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME';
$OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : ''));
require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
$storage = new DoliStorage($db, $conf);
try {
$tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
if (is_object($tokenobj)) {
$this->smtps->setToken($tokenobj->getAccessToken());
} else {
$this->error = "Token not found";
}
} catch (Exception $e) {
// Return an error if token not found
$this->error = $e->getMessage();
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
}
}
$res = true;
$from = $this->smtps->getFrom('org');
if ($res && !$from) {
@ -852,7 +917,6 @@ class CMailFile
}
$result = $this->smtps->sendMsg();
//print $result;
if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
$this->dump_mail();
@ -898,9 +962,39 @@ class CMailFile
if (!empty($conf->global->$keyforsmtpid)) {
$this->transport->setUsername($conf->global->$keyforsmtpid);
}
if (!empty($conf->global->$keyforsmtppw)) {
if (!empty($conf->global->$keyforsmtppw) && getDolGlobalString($keyforsmtpauthtype) != "XOAUTH2") {
$this->transport->setPassword($conf->global->$keyforsmtppw);
}
if (getDolGlobalString($keyforsmtpauthtype) === "XOAUTH2") {
require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array
$keyforsupportedoauth2array = getDolGlobalString($keyforsmtpoauthservice);
if (preg_match('/^.*-/', $keyforsupportedoauth2array)) {
$keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array);
} else {
$keyforprovider = '';
}
$keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array);
$keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME';
$OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : ''));
require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
$storage = new DoliStorage($db, $conf);
try {
$tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
if (is_object($tokenobj)) {
$this->transport->setAuthMode('XOAUTH2');
$this->transport->setPassword($tokenobj->getAccessToken());
} else {
$this->errors[] = "Token not found";
}
} catch (Exception $e) {
// Return an error if token not found
$this->errors[] = $e->getMessage();
dol_syslog("CMailFile::sendfile: mail end error=".$e->getMessage(), LOG_ERR);
}
}
if (!empty($conf->global->$keyforsslseflsigned)) {
$this->transport->setStreamOptions(array('ssl' => array('allow_self_signed' => true, 'verify_peer' => false)));
}
@ -933,16 +1027,16 @@ class CMailFile
try {
$result = $this->mailer->send($this->message, $failedRecipients);
} catch (Exception $e) {
$this->error = $e->getMessage();
$this->errors[] = $e->getMessage();
}
if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
$this->dump_mail();
}
$res = true;
if (!empty($this->error) || !$result) {
if (!empty($this->error) || !empty($this->errors) || !$result) {
if (!empty($failedRecipients)) {
$this->error = 'Transport failed for the following addresses: "' . join('", "', $failedRecipients) . '".';
$this->errors[] = 'Transport failed for the following addresses: "' . join('", "', $failedRecipients) . '".';
}
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
$res = false;

View File

@ -744,6 +744,7 @@ abstract class CommonObject
public function setUpperOrLowerCase()
{
global $conf;
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) {
$this->lastname = dol_ucwords(dol_strtolower($this->lastname));
$this->firstname = dol_ucwords(dol_strtolower($this->firstname));
@ -759,8 +760,12 @@ abstract class CommonObject
$this->address = dol_strtoupper($this->address);
$this->town = dol_strtoupper($this->town);
}
$this->email = dol_strtolower($this->email);
$this->personal_email = dol_strtolower($this->personal_email);
if (isset($this->email)) {
$this->email = dol_strtolower($this->email);
}
if (isset($this->personal_email)) {
$this->personal_email = dol_strtolower($this->personal_email);
}
}
/**
@ -6019,7 +6024,7 @@ abstract class CommonObject
// Test fetch_array ! is_int($key) because fetch_array result is a mix table with Key as alpha and Key as int (depend db engine)
if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && !is_int($key)) {
// we can add this attribute to object
if (!empty($extrafields) && in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date', 'datetime'))) {
if (!empty($extrafields->attributes[$this->table_element]) && in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date', 'datetime'))) {
//var_dump($extrafields->attributes[$this->table_element]['type'][$key]);
$this->array_options["options_".$key] = $this->db->jdate($value);
} else {
@ -6032,7 +6037,7 @@ abstract class CommonObject
// If field is a computed field, value must become result of compute
foreach ($tab as $key => $value) {
if (!empty($extrafields) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) {
if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) {
//var_dump($conf->disable_compute);
if (empty($conf->disable_compute)) {
$this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, '');
@ -7760,12 +7765,12 @@ abstract class CommonObject
} else {
$value = '';
}
} elseif (preg_match('/^(text|html)/', $type)) {
$value = dol_htmlentitiesbr($value);
} elseif ($type == 'password') {
$value = preg_replace('/./i', '*', $value);
} elseif ($type == 'array') {
$value = implode('<br>', $value);
} else { // text|html|varchar
$value = dol_htmlentitiesbr($value);
}
//print $type.'-'.$size.'-'.$value;
@ -8446,8 +8451,8 @@ abstract class CommonObject
/**
* Get buy price to use for margin calculation. This function is called when buy price is unknown.
* Set buy price = sell price if ForceBuyingPriceIfNull configured,
* else if calculation MARGIN_TYPE = 'costprice' and costprice is defined, use costprice as buyprice
* else if calculation MARGIN_TYPE = 'pmp' and pmp is calculated, use pmp as buyprice
* elseif calculation MARGIN_TYPE = 'costprice' and costprice is defined, use costprice as buyprice
* elseif calculation MARGIN_TYPE = 'pmp' and pmp is calculated, use pmp as buyprice
* else set min buy price as buy price
*
* @param float $unitPrice Product unit price
@ -8801,7 +8806,7 @@ abstract class CommonObject
public function isInt($info)
{
if (is_array($info)) {
if (isset($info['type']) && ($info['type'] == 'int' || preg_match('/^integer/i', $info['type']))) {
if (isset($info['type']) && (preg_match('/(^int|int$)/i', $info['type']))) {
return true;
} else {
return false;
@ -9060,6 +9065,8 @@ abstract class CommonObject
return 'NULL';
} elseif (preg_match('/^(int|double|real|price)/i', $fieldsentry['type'])) {
return price2num("$value");
} elseif (preg_match('/int$/i', $fieldsentry['type'])) {
return (int) $value;
} elseif ($fieldsentry['type'] == 'boolean') {
if ($value) {
return 'true';

View File

@ -5156,8 +5156,9 @@ class Form
closeOnEscape: false,
buttons: {
"'.dol_escape_js($langs->transnoentities($labelbuttonyes)).'": function() {
var options = "&token='.urlencode(newToken()).'";
var options = "token='.urlencode(newToken()).'";
var inputok = '.json_encode($inputok).'; /* List of fields into form */
var page = "'.dol_escape_js(!empty($page) ? $page : '').'";
var pageyes = "'.dol_escape_js(!empty($pageyes) ? $pageyes : '').'";
if (inputok.length>0) {
$.each(inputok, function(i, inputname) {
@ -5174,13 +5175,19 @@ class Form
options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
});
}
var urljump = pageyes + (pageyes.indexOf("?") < 0 ? "?" : "") + options;
if (pageyes.length > 0) { location.href = urljump; }
if (pageyes.length > 0) {
var post = $.post(
pageyes,
options,
(data) => {$("body").html(data)}
);
}
$(this).dialog("close");
},
"'.dol_escape_js($langs->transnoentities($labelbuttonno)).'": function() {
var options = "&token='.urlencode(newToken()).'";
var options = "token='.urlencode(newToken()).'";
var inputko = '.json_encode($inputko).'; /* List of fields into form */
var page = "'.dol_escape_js(!empty($page) ? $page : '').'";
var pageno="'.dol_escape_js(!empty($pageno) ? $pageno : '').'";
if (inputko.length>0) {
$.each(inputko, function(i, inputname) {
@ -5191,9 +5198,13 @@ class Form
options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
});
}
var urljump=pageno + (pageno.indexOf("?") < 0 ? "?" : "") + options;
//alert(urljump);
if (pageno.length > 0) { location.href = urljump; }
if (pageno.length > 0) {
var post = $.post(
pageno,
options,
(data) => {$("body").html(data)}
);
}
$(this).dialog("close");
}
}

View File

@ -4,7 +4,7 @@
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015-2017 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015-2017 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
*
* This program is free software; you can redistribute it and/or modify
@ -85,7 +85,7 @@ class FormMail extends Form
public $toid;
/**
* @var string replyto name
* @var string Reply-to name
*/
public $replytoname;
@ -95,20 +95,25 @@ class FormMail extends Form
public $replytomail;
/**
* @var string to name
* @var string To name
*/
public $toname;
/**
* @var string to email
* @var string To email
*/
public $tomail;
/**
* @var string trackid
* @var string Track id
*/
public $trackid;
/**
* @var string If you know a MSGID of an email and want to send the email in reply to it. Will be added into header as In-Reply-To: <...>
*/
public $inreplyto;
public $withsubstit; // Show substitution array
public $withfrom;
@ -396,7 +401,7 @@ class FormMail extends Form
// Define output language
$outputlangs = $langs;
$newlang = '';
if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($this->param['langsmodels'])) {
$newlang = $this->param['langsmodels'];
}
if (!empty($newlang)) {
@ -423,7 +428,7 @@ class FormMail extends Form
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelselected') && GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) {
if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit'])) {
if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param['fileinit']) && is_array($this->param['fileinit'])) {
foreach ($this->param['fileinit'] as $file) {
$this->add_attached_files($file, basename($file), dol_mimetype($file));
}
@ -449,6 +454,7 @@ class FormMail extends Form
$out .= '<input style="display:none" type="submit" id="sendmailhidden" name="sendmail">';
$out .= '<input type="hidden" name="token" value="'.newToken().'" />';
$out .= '<input type="hidden" name="trackid" value="'.$this->trackid.'" />';
$out .= '<input type="hidden" name="inreplyto" value="'.$this->inreplyto.'" />';
}
if (!empty($this->withfrom)) {
if (!empty($this->withfromreadonly)) {
@ -458,7 +464,7 @@ class FormMail extends Form
}
foreach ($this->param as $key => $value) {
if (is_array($value)) {
$out .= "<!-- param key=".$key." is array, we do not output input filed for it -->\n";
$out .= "<!-- param key=".$key." is array, we do not output input field for it -->\n";
} else {
$out .= '<input type="hidden" id="'.$key.'" name="'.$key.'" value="'.$value.'" />'."\n";
}
@ -598,7 +604,7 @@ class FormMail extends Form
// Also add robot email
if (!empty($this->fromalsorobot)) {
if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && $conf->global->MAIN_MAIL_EMAIL_FROM != $conf->global->MAIN_INFO_SOCIETE_MAIL) {
if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && getDolGlobalString('MAIN_MAIL_EMAIL_FROM') != getDolGlobalString('MAIN_INFO_SOCIETE_MAIL')) {
$liste['robot'] = $conf->global->MAIN_MAIL_EMAIL_FROM;
if ($this->frommail) {
$liste['robot'] .= ' &lt;'.$conf->global->MAIN_MAIL_EMAIL_FROM.'&gt;';
@ -1176,7 +1182,7 @@ class FormMail extends Form
{
global $conf, $langs;
//if (! $this->errorstomail) $this->errorstomail=$this->frommail;
$errorstomail = (!empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail);
$errorstomail = getDolGlobalString('MAIN_MAIL_ERRORS_TO', (!empty($this->errorstomail) ? $this->errorstomail : ''));
if ($this->witherrorstoreadonly) {
$out = '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
$out .= '<input type="hidden" id="errorstomail" name="errorstomail" value="'.$errorstomail.'" />';

View File

@ -1093,6 +1093,7 @@ class FormSetupItem
$out.= $this->langs->trans("NorProspectNorCustomer");
}
} elseif ($this->type == 'product') {
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$product = new Product($this->db);
$resprod = $product->fetch($this->fieldValue);
if ($resprod > 0) {

View File

@ -119,7 +119,7 @@ class FormTicket
$this->action = 'add';
$this->withcompany = $conf->societe->enabled ? 1 : 0;
$this->withcompany = isModEnabled("societe");
$this->withfromsocid = 0;
$this->withfromcontactid = 0;
//$this->withreadid=0;
@ -169,7 +169,7 @@ class FormTicket
print dol_get_fiche_head(null, 'card', '', 0, '');
}
print '<form method="POST" '.($withdolfichehead ? '' : 'style="margin-bottom: 30px;" ').'name="ticket" id="form_create_ticket" enctype="multipart/form-data" action="'.$this->param["returnurl"].'">';
print '<form method="POST" '.($withdolfichehead ? '' : 'style="margin-bottom: 30px;" ').'name="ticket" id="form_create_ticket" enctype="multipart/form-data" action="'.(!empty($this->param["returnurl"]) ? $this->param["returnurl"] : "").'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="'.$this->action.'">';
foreach ($this->param as $key => $value) {
@ -315,7 +315,7 @@ class FormTicket
// Type
print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans("TicketTypeRequest").'</span></label></td><td>';
$this->selectTypesTickets((GETPOST('type_code', 'alpha') ? GETPOST('type_code', 'alpha') : $this->type_code), 'type_code', '', 2, 0, 0, 0, 'minwidth200');
$this->selectTypesTickets((GETPOST('type_code', 'alpha') ? GETPOST('type_code', 'alpha') : $this->type_code), 'type_code', '', 2, 1, 0, 0, 'minwidth200');
print '</td></tr>';
// Group
@ -324,12 +324,12 @@ class FormTicket
if ($public) {
$filter = 'public=1';
}
$this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', $filter, 2, 0, 0, 0, 'minwidth200');
$this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', $filter, 2, 1, 0, 0, 'minwidth200');
print '</td></tr>';
// Severity
print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans("TicketSeverity").'</span></label></td><td>';
$this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', 2, 0);
$this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', 2, 1);
print '</td></tr>';
// Subject
@ -341,10 +341,12 @@ class FormTicket
print $langs->trans('SubjectAnswerToTicket').' '.$this->topic_title;
print '</td></tr>';
} else {
if ($this->withreadid > 0) {
if (isset($this->withreadid) && $this->withreadid > 0) {
$subject = $langs->trans('SubjectAnswerToTicket').' '.$this->withreadid.' : '.$this->topic_title.'';
} else {
$subject = GETPOST('subject', 'alpha');
}
print '<input class="text minwidth500" id="subject" name="subject" value="'.(GETPOST('subject', 'alpha') ? GETPOST('subject', 'alpha') : $subject).'" autofocus />';
print '<input class="text minwidth500" id="subject" name="subject" value="'.$subject.'" autofocus />';
print '</td></tr>';
}
}
@ -643,7 +645,7 @@ class FormTicket
print '<br>';
print $form->buttonsSaveCancel((($this->withreadid > 0) ? "SendResponse" : "CreateTicket"), ($this->withcancel ? "Cancel" : ""));
print $form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ? "SendResponse" : "CreateTicket"), ($this->withcancel ? "Cancel" : ""));
/*
print '<div class="center">';
@ -733,6 +735,7 @@ class FormTicket
}
print '>';
$value = '&nbsp;';
if ($format == 0) {
$value = ($maxlength ? dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
@ -744,7 +747,7 @@ class FormTicket
$value = $arraytypes['code'];
}
print $value;
print $value ? $value : '&nbsp;';
print '</option>';
}
}
@ -839,6 +842,7 @@ class FormTicket
print '>';
$value = '';
if ($format == 0) {
$value = ($maxlength ? dol_trunc($label, $maxlength) : $label);
}
@ -1172,6 +1176,8 @@ class FormTicket
}
print '>';
$value = '';
if ($format == 0) {
$value = ($maxlength ? dol_trunc($arrayseverities['label'], $maxlength) : $arrayseverities['label']);
}

View File

@ -68,6 +68,11 @@ class SMTPs
*/
private $_smtpsPW = null;
/**
* Token in case we use OAUTH2
*/
private $_smtpsToken = null;
/**
* Who sent the Message
* This can be defined via a INI file or via a setter method
@ -565,13 +570,13 @@ class SMTPs
}
// Default authentication method is LOGIN
if (empty($conf->global->MAIL_SMTP_AUTH_TYPE)) {
$conf->global->MAIL_SMTP_AUTH_TYPE = 'LOGIN';
if (empty($conf->global->MAIN_MAIL_SMTPS_AUTH_TYPE)) {
$conf->global->MAIN_MAIL_SMTPS_AUTH_TYPE = 'LOGIN';
}
// Send Authentication to Server
// Check for errors along the way
switch ($conf->global->MAIL_SMTP_AUTH_TYPE) {
switch ($conf->global->MAIN_MAIL_SMTPS_AUTH_TYPE) {
case 'NONE':
// Do not send the 'AUTH type' message. For test purpose, if you don't need authentication, it is better to not enter login/pass into setup.
$_retVal = true;
@ -583,9 +588,10 @@ class SMTPs
break;
case 'XOAUTH2':
// "user=$email\1auth=Bearer $token\1\1"
$token = 'xxx';
$xxxx = "user=".$this->_smtpsID."\1auth=Bearer ".$token."\1\1";
$_retVal = $this->socket_send_str('AUTH XOAUTH2 '.base64_encode($xxxx), '235');
$user = $this->_smtpsID;
$token = $this->_smtpsToken;
$initRes = "user=".$user."\001auth=Bearer ".$token."\001\001";
$_retVal = $this->socket_send_str('AUTH XOAUTH2 '.base64_encode($initRes), '235');
if (!$_retVal) {
$this->_setErr(130, 'Error when asking for AUTH XOAUTH2');
}
@ -631,7 +637,7 @@ class SMTPs
// Connect to Server
if ($this->socket = $this->_server_connect()) {
// If a User ID *and* a password is given, assume Authentication is desired
if (!empty($this->_smtpsID) && !empty($this->_smtpsPW)) {
if (!empty($this->_smtpsID) && (!empty($this->_smtpsPW) || !empty($this->_smtpsToken))) {
// Send the RFC2554 specified EHLO.
$_retVal = $this->_server_authenticate();
} else {
@ -923,6 +929,27 @@ class SMTPs
return $this->_smtpsPW;
}
/**
* User token for OAUTH2
*
* @param string $_strToken User token
* @return void
*/
public function setToken($_strToken)
{
$this->_smtpsToken = $_strToken;
}
/**
* Retrieves the User token for OAUTH2
*
* @return string User token for OAUTH2
*/
public function getToken()
{
return $this->_smtpsToken;
}
/**
* Character set used for current message
* Character set is defaulted to 'iso-8859-1';
@ -1866,7 +1893,7 @@ class SMTPs
}
if (!(substr($server_response, 0, 3) == $response)) {
$this->_setErr(120, "Ran into problems sending Mail.\r\nResponse: $server_response");
$this->_setErr(120, "Ran into problems sending Mail.\r\nResponse:".$server_response);
$_retVal = false;
}

View File

@ -637,7 +637,11 @@ class Translate
);
if (strpos($key, 'Format') !== 0) {
$str = sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings.
try {
$str = sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings.
} catch (Exception $e) {
// No exception managed
}
}
// Crypt string into HTML

View File

@ -247,6 +247,7 @@ class Diff
$html = '';
// loop over the lines in the diff
$element = 'unknown';
foreach ($diff as $line) {
// extend the HTML with the line
switch ($line[1]) {
@ -260,10 +261,7 @@ class Diff
$element = 'ins';
break;
}
$html .=
'<'.$element.'>'
. htmlspecialchars($line[0])
. '</'.$element.'>';
$html .= '<'.$element.'>'.dol_escape_htmltag($line[0]).'</'.$element.'>';
// extend the HTML with the separator
$html .= $separator;
@ -286,6 +284,8 @@ class Diff
// initialise the HTML
$html = $indentation."<table class=\"diff\">\n";
$rightCell = $leftCell = '';
// loop over the lines in the diff
$index = 0;
$nbdiff = count($diff);

View File

@ -21,10 +21,12 @@
//define('NOTOKENRENEWAL',1); // Disables token renewal
//require '../../../../main.inc.php';
require '../../connectors/php/config.php'; // This include the define('NOTOKENRENEWAL',1) and the require main.in.php
require '../../connectors/php/config.inc.php'; // This include the define('NOTOKENRENEWAL',1) and the require main.in.php
global $Config;
top_httphead();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>

View File

@ -23,6 +23,8 @@ define('NOTOKENRENEWAL', 1); // Disables token renewal
require '../../../../main.inc.php';
top_httphead();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--

View File

@ -25,6 +25,8 @@ require '../../../../main.inc.php';
$langs->load("ecm");
top_httphead();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--

View File

@ -23,6 +23,8 @@ define('NOTOKENRENEWAL', 1); // Disables token renewal
require '../../../../main.inc.php';
top_httphead();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--

View File

@ -23,6 +23,8 @@ define('NOTOKENRENEWAL', 1); // Disables token renewal
require '../../../../main.inc.php';
top_httphead();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--

View File

@ -23,6 +23,8 @@ define('NOTOKENRENEWAL', 1); // Disables token renewal
require '../../../../main.inc.php';
top_httphead();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--

View File

@ -1,131 +0,0 @@
<?php
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2010 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
* - GNU General Public License Version 2 or later (the "GPL")
* https://www.gnu.org/licenses/gpl.html
*
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
* https://www.gnu.org/licenses/lgpl.html
*
* - Mozilla Public License Version 1.1 or later (the "MPL")
* http://www.mozilla.org/MPL/MPL-1.1.html
*
* == END LICENSE ==
*
* These functions define the base of the XML response sent by the PHP
* connector.
*/
/**
* SetXmlHeaders
*
* @return void
*/
function SetXmlHeaders()
{
ob_end_clean();
// Prevent the browser from caching the result.
// Date in the past
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
// always modified
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
// HTTP/1.1
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
// HTTP/1.0
header('Pragma: no-cache');
// Set the response format.
header('Content-Type: text/xml; charset=utf-8');
}
/**
* CreateXmlHeader
*
* @param string $command Command
* @param string $resourceType Resource type
* @param string $currentFolder Current folder
* @return void
*/
function CreateXmlHeader($command, $resourceType, $currentFolder)
{
SetXmlHeaders();
// Create the XML document header.
echo '<?xml version="1.0" encoding="utf-8" ?>';
// Create the main "Connector" node.
echo '<Connector command="'.$command.'" resourceType="'.$resourceType.'">';
// Add the current folder node.
echo '<CurrentFolder path="'.ConvertToXmlAttribute($currentFolder).'" url="'.ConvertToXmlAttribute(GetUrlFromPath($resourceType, $currentFolder, $command)).'" />';
$GLOBALS['HeaderSent'] = true;
}
/**
* CreateXmlFooter
*
* @return void
*/
function CreateXmlFooter()
{
echo '</Connector>';
}
/**
* SendError
*
* @param integer $number Number
* @param string $text Text
* @return void
*/
function SendError($number, $text)
{
if ($_GET['Command'] == 'FileUpload') {
SendUploadResults($number, "", "", $text);
}
if (isset($GLOBALS['HeaderSent']) && $GLOBALS['HeaderSent']) {
SendErrorNode($number, $text);
CreateXmlFooter();
} else {
SetXmlHeaders();
dol_syslog('Error: '.$number.' '.$text, LOG_ERR);
// Create the XML document header
echo '<?xml version="1.0" encoding="utf-8" ?>';
echo '<Connector>';
SendErrorNode($number, $text);
echo '</Connector>';
}
exit;
}
/**
* SendErrorNode
*
* @param integer $number Number
* @param string $text Text of error
* @return string Error node
*/
function SendErrorNode($number, $text)
{
if ($text) {
echo '<Error number="'.$number.'" text="'.htmlspecialchars($text).'" />';
} else {
echo '<Error number="'.$number.'" />';
}
}

View File

@ -1,325 +0,0 @@
<?php
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2010 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
* - GNU General Public License Version 2 or later (the "GPL")
* https://www.gnu.org/licenses/gpl.html
*
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
* https://www.gnu.org/licenses/lgpl.html
*
* - Mozilla Public License Version 1.1 or later (the "MPL")
* http://www.mozilla.org/MPL/MPL-1.1.html
*
* == END LICENSE ==
*
* This is the File Manager Connector for PHP.
*/
/**
* GetFolders
*
* @param string $resourceType Resource type
* @param string $currentFolder Current folder
* @return void
*/
function GetFolders($resourceType, $currentFolder)
{
// Map the virtual path to the local server path.
$sServerDir = ServerMapFolder($resourceType, $currentFolder, 'GetFolders');
// Array that will hold the folders names.
$aFolders = array();
$oCurrentFolder = @opendir($sServerDir);
if ($oCurrentFolder !== false) {
while ($sFile = readdir($oCurrentFolder)) {
if ($sFile != '.' && $sFile != '..' && is_dir($sServerDir.$sFile)) {
$aFolders[] = '<Folder name="'.ConvertToXmlAttribute($sFile).'" />';
}
}
closedir($oCurrentFolder);
}
// Open the "Folders" node.
echo "<Folders>";
natcasesort($aFolders);
foreach ($aFolders as $sFolder) {
echo $sFolder;
}
// Close the "Folders" node.
echo "</Folders>";
}
/**
* GetFoldersAndFiles
*
* @param string $resourceType Resource type
* @param string $currentFolder Current folder
* @return void
*/
function GetFoldersAndFiles($resourceType, $currentFolder)
{
// Map the virtual path to the local server path.
$sServerDir = ServerMapFolder($resourceType, $currentFolder, 'GetFoldersAndFiles');
// Arrays that will hold the folders and files names.
$aFolders = array();
$aFiles = array();
$oCurrentFolder = @opendir($sServerDir);
if ($oCurrentFolder !== false) {
while ($sFile = readdir($oCurrentFolder)) {
if ($sFile != '.' && $sFile != '..') {
if (is_dir($sServerDir.$sFile)) {
$aFolders[] = '<Folder name="'.ConvertToXmlAttribute($sFile).'" />';
} else {
$iFileSize = @filesize($sServerDir.$sFile);
if (!$iFileSize) {
$iFileSize = 0;
}
if ($iFileSize > 0) {
$iFileSize = round($iFileSize / 1024);
if ($iFileSize < 1) {
$iFileSize = 1;
}
}
$aFiles[] = '<File name="'.ConvertToXmlAttribute($sFile).'" size="'.$iFileSize.'" />';
}
}
}
closedir($oCurrentFolder);
}
// Send the folders
natcasesort($aFolders);
echo '<Folders>';
foreach ($aFolders as $sFolder) {
echo $sFolder;
}
echo '</Folders>';
// Send the files
natcasesort($aFiles);
echo '<Files>';
foreach ($aFiles as $sFiles) {
echo $sFiles;
}
echo '</Files>';
}
/**
* Create folder
*
* @param string $resourceType Resource type
* @param string $currentFolder Current folder
* @return void
*/
function CreateFolder($resourceType, $currentFolder)
{
if (!isset($_GET)) {
global $_GET;
}
$sErrorNumber = '0';
$sErrorMsg = '';
if (isset($_GET['NewFolderName'])) {
$sNewFolderName = $_GET['NewFolderName'];
$sNewFolderName = SanitizeFolderName($sNewFolderName);
if (strpos($sNewFolderName, '..') !== false) {
$sErrorNumber = '102'; // Invalid folder name.
} else {
// Map the virtual path to the local server path of the current folder.
$sServerDir = ServerMapFolder($resourceType, $currentFolder, 'CreateFolder');
if (is_writable($sServerDir)) {
$sServerDir .= $sNewFolderName;
$sErrorMsg = CreateServerFolder($sServerDir);
switch ($sErrorMsg) {
case '':
$sErrorNumber = '0';
break;
case 'Invalid argument':
case 'No such file or directory':
$sErrorNumber = '102'; // Path too long.
break;
default:
$sErrorNumber = '110';
break;
}
} else {
$sErrorNumber = '103';
}
}
} else {
$sErrorNumber = '102';
}
// Create the "Error" node.
echo '<Error number="'.$sErrorNumber.'" />';
}
// @CHANGE
//function FileUpload( $resourceType, $currentFolder, $sCommand )
/**
* FileUpload
*
* @param string $resourceType Resource type
* @param string $currentFolder Current folder
* @param string $sCommand Command
* @param string $CKEcallback Callback
* @return null
*/
function FileUpload($resourceType, $currentFolder, $sCommand, $CKEcallback = '')
{
if (!isset($_FILES)) {
global $_FILES;
}
$sErrorNumber = '0';
$sFileName = '';
if (isset($_FILES['NewFile']) && !is_null($_FILES['NewFile']['tmp_name'])
// This is for the QuickUpload tab box
or (isset($_FILES['upload']) && !is_null($_FILES['upload']['tmp_name']))) {
global $Config;
$oFile = isset($_FILES['NewFile']) ? $_FILES['NewFile'] : $_FILES['upload'];
// $resourceType should be 'Image';
$detectHtml = 0;
// Map the virtual path to the local server path.
$sServerDir = ServerMapFolder($resourceType, $currentFolder, $sCommand);
// Get the uploaded file name.
$sFileName = $oFile['name'];
//$sFileName = SanitizeFileName($sFileName);
$sFileName = dol_sanitizeFileName($sFileName);
$sOriginalFileName = $sFileName;
// Get the extension.
$sExtension = substr($sFileName, (strrpos($sFileName, '.') + 1));
$sExtension = strtolower($sExtension);
//var_dump($Config);
/*
if (isset($Config['SecureImageUploads'])) {
if (($isImageValid = IsImageValid($oFile['tmp_name'], $sExtension)) === false) {
$sErrorNumber = '202';
}
}
if (isset($Config['HtmlExtensions'])) {
if (!IsHtmlExtension($sExtension, $Config['HtmlExtensions']) &&
($detectHtml = DetectHtml($oFile['tmp_name'])) === true) {
$sErrorNumber = '202';
}
}
*/
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
//var_dump($sFileName); var_dump(image_format_supported($sFileName));exit;
$isImageValid = (image_format_supported($sFileName) >= 0 ? true : false);
if (!$isImageValid) {
$sErrorNumber = '202';
}
// Check if it is an allowed extension.
if (!$sErrorNumber) {
if (IsAllowedExt($sExtension, $resourceType)) {
$iCounter = 0;
while (true) {
$sFilePath = $sServerDir.$sFileName;
if (is_file($sFilePath)) {
$iCounter++;
$sFileName = RemoveExtension($sOriginalFileName).'('.$iCounter.').'.$sExtension;
$sErrorNumber = '201';
} else {
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_move_uploaded_file($oFile['tmp_name'], $sFilePath, 0, 0);
if (is_file($sFilePath)) {
if (isset($Config['ChmodOnUpload']) && !$Config['ChmodOnUpload']) {
break;
}
$permissions = '0777';
if (isset($Config['ChmodOnUpload']) && $Config['ChmodOnUpload']) {
$permissions = (string) $Config['ChmodOnUpload'];
}
$permissionsdec = octdec($permissions);
dol_syslog("commands.php permission = ".$permissions." ".$permissionsdec." ".decoct($permissionsdec));
$oldumask = umask(0);
chmod($sFilePath, $permissionsdec);
umask($oldumask);
}
break;
}
}
if (file_exists($sFilePath)) {
//previous checks failed, try once again
if (isset($isImageValid) && $isImageValid === -1 && IsImageValid($sFilePath, $sExtension) === false) {
dol_syslog("commands.php IsImageValid is ko");
@unlink($sFilePath);
$sErrorNumber = '202';
} elseif (isset($detectHtml) && $detectHtml === -1 && DetectHtml($sFilePath) === true) {
dol_syslog("commands.php DetectHtml is ko");
@unlink($sFilePath);
$sErrorNumber = '202';
}
}
} else {
$sErrorNumber = '202';
}
}
} else {
$sErrorNumber = '203';
}
$sFileUrl = CombinePaths(GetResourceTypePath($resourceType, $sCommand), $currentFolder);
$sFileUrl = CombinePaths($sFileUrl, $sFileName);
// @CHANGE
//SendUploadResults( $sErrorNumber, $sFileUrl, $sFileName );
if ($CKEcallback == '') {
// this line already exists so wrap the if block around it
SendUploadResults($sErrorNumber, $sFileUrl, $sFileName);
} else {
//issue the CKEditor Callback
SendCKEditorResults(
$CKEcallback,
$sFileUrl,
($sErrorNumber != 0 ? 'Error '.$sErrorNumber.' upload failed.' : 'Upload Successful')
);
}
exit;
}

File diff suppressed because it is too large Load Diff

View File

@ -19,19 +19,16 @@
*
* == END LICENSE ==
*
* This is the File Manager Connector for PHP.
* This is the File Manager Connector for PHP. It returns a XML file used by browser.php
*/
ob_start();
require 'config.php';
require 'util.php';
require 'io.php';
require 'basexml.php';
require 'commands.php';
require 'config.inc.php'; // This include the main.inc.php
require 'connector.lib.php';
if (!$Config['Enabled']) {
SendError(1, 'This connector is disabled. Please check the "editor/filemanager/connectors/php/config.php" file');
SendError(1, 'This connector is disabled. Please check the "editor/filemanager/connectors/php/config.inc.php" file');
}
DoResponse();

View File

@ -1,438 +0,0 @@
<?php
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2010 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
* - GNU General Public License Version 2 or later (the "GPL")
* https://www.gnu.org/licenses/gpl.html
*
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
* https://www.gnu.org/licenses/lgpl.html
*
* - Mozilla Public License Version 1.1 or later (the "MPL")
* http://www.mozilla.org/MPL/MPL-1.1.html
*
* == END LICENSE ==
*
* This is the File Manager Connector for PHP.
*/
/**
* CombinePaths
*
* @param string $sBasePath sBasePath
* @param string $sFolder sFolder
* @return string Combined path
*/
function CombinePaths($sBasePath, $sFolder)
{
return RemoveFromEnd($sBasePath, '/').'/'.RemoveFromStart($sFolder, '/');
}
/**
* GetResourceTypePath
*
* @param string $resourceType Resource type
* @param string $sCommand Command
* @return string Config
*/
function GetResourceTypePath($resourceType, $sCommand)
{
global $Config;
if ($sCommand == "QuickUpload") {
return $Config['QuickUploadPath'][$resourceType];
} else {
return $Config['FileTypesPath'][$resourceType];
}
}
/**
* GetResourceTypeDirectory
*
* @param string $resourceType Resource type
* @param string $sCommand Command
* @return string
*/
function GetResourceTypeDirectory($resourceType, $sCommand)
{
global $Config;
if ($sCommand == "QuickUpload") {
if (strlen($Config['QuickUploadAbsolutePath'][$resourceType]) > 0) {
return $Config['QuickUploadAbsolutePath'][$resourceType];
}
// Map the "UserFiles" path to a local directory.
return Server_MapPath($Config['QuickUploadPath'][$resourceType]);
} else {
if (strlen($Config['FileTypesAbsolutePath'][$resourceType]) > 0) {
return $Config['FileTypesAbsolutePath'][$resourceType];
}
// Map the "UserFiles" path to a local directory.
return Server_MapPath($Config['FileTypesPath'][$resourceType]);
}
}
/**
* GetUrlFromPath
*
* @param string $resourceType Resource type
* @param string $folderPath Path
* @param string $sCommand Command
* @return string Full url
*/
function GetUrlFromPath($resourceType, $folderPath, $sCommand)
{
return CombinePaths(GetResourceTypePath($resourceType, $sCommand), $folderPath);
}
/**
* RemoveExtension
*
* @param string $fileName Filename
* @return string String without extension
*/
function RemoveExtension($fileName)
{
return substr($fileName, 0, strrpos($fileName, '.'));
}
/**
* ServerMapFolder
*
* @param string $resourceType Resource type
* @param string $folderPath Folder
* @param string $sCommand Command
* @return string
*/
function ServerMapFolder($resourceType, $folderPath, $sCommand)
{
// Get the resource type directory.
$sResourceTypePath = GetResourceTypeDirectory($resourceType, $sCommand);
// Ensure that the directory exists.
$sErrorMsg = CreateServerFolder($sResourceTypePath);
if ($sErrorMsg != '') {
SendError(1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})");
}
// Return the resource type directory combined with the required path.
return CombinePaths($sResourceTypePath, $folderPath);
}
/**
* GetParentFolder
*
* @param string $folderPath Folder path
* @return string Parent folder
*/
function GetParentFolder($folderPath)
{
$sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-";
return preg_replace($sPattern, '', $folderPath);
}
/**
* CreateServerFolder
*
* @param string $folderPath Folder
* @param string $lastFolder Folder
* @return string ''=success, error message otherwise
*/
function CreateServerFolder($folderPath, $lastFolder = null)
{
global $Config;
$sParent = GetParentFolder($folderPath);
// Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms
while (strpos($folderPath, '//') !== false) {
$folderPath = str_replace('//', '/', $folderPath);
}
// Check if the parent exists, or create it.
if (!empty($sParent) && !file_exists($sParent)) {
//prevents agains infinite loop when we can't create root folder
if (!is_null($lastFolder) && $lastFolder === $sParent) {
return "Can't create $folderPath directory";
}
$sErrorMsg = CreateServerFolder($sParent, $folderPath);
if ($sErrorMsg != '') {
return $sErrorMsg;
}
}
if (!file_exists($folderPath)) {
// Turn off all error reporting.
error_reporting(0);
$php_errormsg = '';
// Enable error tracking to catch the error.
ini_set('track_errors', '1');
if (isset($Config['ChmodOnFolderCreate']) && !$Config['ChmodOnFolderCreate']) {
mkdir($folderPath);
} else {
$permissions = '0777';
if (isset($Config['ChmodOnFolderCreate']) && $Config['ChmodOnFolderCreate']) {
$permissions = (string) $Config['ChmodOnFolderCreate'];
}
$permissionsdec = octdec($permissions);
$permissionsdec |= octdec('0111'); // Set x bit required for directories
dol_syslog("io.php permission = ".$permissions." ".$permissionsdec." ".decoct($permissionsdec));
// To create the folder with 0777 permissions, we need to set umask to zero.
$oldumask = umask(0);
mkdir($folderPath, $permissionsdec);
umask($oldumask);
}
$sErrorMsg = $php_errormsg;
// Restore the configurations.
ini_restore('track_errors');
ini_restore('error_reporting');
return $sErrorMsg;
} else {
return '';
}
}
/**
* Get Root Path
*
* @return string real path
*/
function GetRootPath()
{
if (!isset($_SERVER)) {
global $_SERVER;
}
$sRealPath = realpath('./');
// #2124 ensure that no slash is at the end
$sRealPath = rtrim($sRealPath, "\\/");
$sSelfPath = $_SERVER['PHP_SELF'];
$sSelfPath = substr($sSelfPath, 0, strrpos($sSelfPath, '/'));
$sSelfPath = str_replace('/', DIRECTORY_SEPARATOR, $sSelfPath);
$position = strpos($sRealPath, $sSelfPath);
// This can check only that this script isn't run from a virtual dir
// But it avoids the problems that arise if it isn't checked
if ($position === false || $position <> strlen($sRealPath) - strlen($sSelfPath)) {
SendError(1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".');
}
return substr($sRealPath, 0, $position);
}
/**
* Emulate the asp Server.mapPath function.
* @param string $path given an url path return the physical directory that it corresponds to
* @return string Path
*/
function Server_MapPath($path)
{
// This function is available only for Apache
if (function_exists('apache_lookup_uri')) {
$info = apache_lookup_uri($path);
return $info->filename.$info->path_info;
}
// This isn't correct but for the moment there's no other solution
// If this script is under a virtual directory or symlink it will detect the problem and stop
return GetRootPath().$path;
}
/**
* Is Allowed Extension
*
* @param string $sExtension File extension
* @param string $resourceType ressource type
* @return boolean true or false
*/
function IsAllowedExt($sExtension, $resourceType)
{
global $Config;
// Get the allowed and denied extensions arrays.
$arAllowed = $Config['AllowedExtensions'][$resourceType];
$arDenied = $Config['DeniedExtensions'][$resourceType];
if (count($arAllowed) > 0 && !in_array($sExtension, $arAllowed)) {
return false;
}
if (count($arDenied) > 0 && in_array($sExtension, $arDenied)) {
return false;
}
return true;
}
/**
* Is Allowed Type
*
* @param string $resourceType ressource type
* @return boolean true or false
*/
function IsAllowedType($resourceType)
{
global $Config;
if (!in_array($resourceType, $Config['ConfigAllowedTypes'])) {
return false;
}
return true;
}
/**
* IsAllowedCommand
*
* @param string $sCommand Command
* @return boolean True or false
*/
function IsAllowedCommand($sCommand)
{
global $Config;
if (!in_array($sCommand, $Config['ConfigAllowedCommands'])) {
return false;
}
return true;
}
/**
* GetCurrentFolder
*
* @return string current folder
*/
function GetCurrentFolder()
{
if (!isset($_GET)) {
global $_GET;
}
$sCurrentFolder = isset($_GET['CurrentFolder']) ? GETPOST('CurrentFolder', '', 1) : '/';
// Check the current folder syntax (must begin and start with a slash).
if (!preg_match('|/$|', $sCurrentFolder)) {
$sCurrentFolder .= '/';
}
if (strpos($sCurrentFolder, '/') !== 0) {
$sCurrentFolder = '/'.$sCurrentFolder;
}
// Ensure the folder path has no double-slashes
while (strpos($sCurrentFolder, '//') !== false) {
$sCurrentFolder = str_replace('//', '/', $sCurrentFolder);
}
// Check for invalid folder paths (..)
if (strpos($sCurrentFolder, '..') || strpos($sCurrentFolder, "\\")) {
SendError(102, '');
}
if (preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $sCurrentFolder)) {
SendError(102, '');
}
return $sCurrentFolder;
}
/**
* Do a cleanup of the folder name to avoid possible problems
*
* @param string $sNewFolderName Folder
* @return string Folder sanitized
*/
function SanitizeFolderName($sNewFolderName)
{
$sNewFolderName = stripslashes($sNewFolderName);
// Remove . \ / | : ? * " < >
$sNewFolderName = preg_replace('/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFolderName);
return $sNewFolderName;
}
/**
* Do a cleanup of the file name to avoid possible problems
*
* @param string $sNewFileName Folder
* @return string Folder sanitized
*/
function SanitizeFileName($sNewFileName)
{
global $Config;
$sNewFileName = stripslashes($sNewFileName);
// Replace dots in the name with underscores (only one dot can be there... security issue).
if ($Config['ForceSingleExtension']) {
$sNewFileName = preg_replace('/\\.(?![^.]*$)/', '_', $sNewFileName);
}
// Remove \ / | : ? * " < >
$sNewFileName = preg_replace('/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName);
return $sNewFileName;
}
/**
* This is the function that sends the results of the uploading process.
*
* @param string $errorNumber errorNumber
* @param string $fileUrl fileUrl
* @param string $fileName fileName
* @param string $customMsg customMsg
* @return void
*/
function SendUploadResults($errorNumber, $fileUrl = '', $fileName = '', $customMsg = '')
{
// Minified version of the document.domain automatic fix script (#1919).
// The original script can be found at _dev/domain_fix_template.js
echo <<<EOF
<script type="text/javascript">
(function(){var d=document.domain;while (true){try{var A=window.parent.document.domain;break;}catch(e) {};d=d.replace(/.*?(?:\.|$)/,'');if (d.length==0) break;try{document.domain=d;}catch (e){break;}}})();
EOF;
if ($errorNumber && $errorNumber != 201) {
$fileUrl = "";
$fileName = "";
}
$rpl = array('\\' => '\\\\', '"' => '\\"');
echo 'console.log('.$errorNumber.');';
echo 'window.parent.OnUploadCompleted('.$errorNumber.', "'.strtr($fileUrl, $rpl).'", "'.strtr($fileName, $rpl).'", "'.strtr($customMsg, $rpl).'");';
echo '</script>';
exit;
}
// @CHANGE
// This is the function that sends the results of the uploading process to CKE.
/**
* SendCKEditorResults
*
* @param string $callback callback
* @param string $sFileUrl sFileUrl
* @param string $customMsg customMsg
* @return void
*/
function SendCKEditorResults($callback, $sFileUrl, $customMsg = '')
{
echo '<script type="text/javascript">';
$rpl = array('\\' => '\\\\', '"' => '\\"');
echo 'window.parent.CKEDITOR.tools.callFunction("'.$callback.'","'.strtr($sFileUrl, $rpl).'", "'.strtr($customMsg, $rpl).'");';
echo '</script>';
}

View File

@ -1,75 +0,0 @@
<?php
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2010 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
* - GNU General Public License Version 2 or later (the "GPL")
* https://www.gnu.org/licenses/gpl.html
*
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
* https://www.gnu.org/licenses/lgpl.html
*
* - Mozilla Public License Version 1.1 or later (the "MPL")
* http://www.mozilla.org/MPL/MPL-1.1.html
*
* == END LICENSE ==
*
* This is the "File Uploader" for PHP.
*/
require 'config.php'; // This include the main.inc.php
require 'util.php';
require 'io.php';
require 'commands.php';
/**
* SendError
*
* @param integer $number Number
* @param string $text Text
* @return void
*/
function SendError($number, $text)
{
SendUploadResults($number, '', '', $text);
}
// Check if this uploader has been enabled.
if (empty($Config['Enabled'])) {
SendUploadResults('1', '', '', 'This file uploader is disabled. Please check the "filemanagerdol/connectors/php/config.php" file');
}
$sCommand = 'QuickUpload';
// The file type (from the QueryString, by default 'File', can be 'Image' or 'Media').
$sType = GETPOSTISSET('Type') ? GETPOST('Type') : 'File';
$sCurrentFolder = "/";
// Is enabled the upload?
if (!IsAllowedCommand($sCommand)) {
SendUploadResults('1', '', '', 'The ""'.$sCommand.'"" command isn\'t allowed');
}
// Check if it is an allowed type.
if (!IsAllowedType($sType)) {
SendUploadResults(1, '', '', 'Invalid type specified');
}
// @CHANGE
//FileUpload( $sType, $sCurrentFolder, $sCommand )
// Get the CKEditor Callback
$CKEcallback = $_GET['CKEditorFuncNum'];
// Get uploaded filr and move it at correct place. Note: Some tests on file name are also included into this function
FileUpload($sType, $sCurrentFolder, $sCommand, $CKEcallback);

View File

@ -1,218 +0,0 @@
<?php
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2010 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
* - GNU General Public License Version 2 or later (the "GPL")
* https://www.gnu.org/licenses/gpl.html
*
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
* https://www.gnu.org/licenses/lgpl.html
*
* - Mozilla Public License Version 1.1 or later (the "MPL")
* http://www.mozilla.org/MPL/MPL-1.1.html
*
* == END LICENSE ==
*
* Utility functions for the File Manager Connector for PHP.
*/
/**
* RemoveFromStart
*
* @param string $sourceString Source
* @param string $charToRemove Char to remove
* @return string Result
*/
function RemoveFromStart($sourceString, $charToRemove)
{
$sPattern = '|^'.$charToRemove.'+|';
return preg_replace($sPattern, '', $sourceString);
}
/**
* RemoveFromEnd
*
* @param string $sourceString Source
* @param string $charToRemove Rhar to remove
* @return string Result
*/
function RemoveFromEnd($sourceString, $charToRemove)
{
$sPattern = '|'.$charToRemove.'+$|';
return preg_replace($sPattern, '', $sourceString);
}
/**
* FindBadUtf8
*
* @param string $string String
* @return boolean
*/
function FindBadUtf8($string)
{
$regex = '([\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]';
$regex .= '|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2}|(.{1}))';
$matches = array();
while (preg_match('/'.$regex.'/S', $string, $matches)) {
if (isset($matches[2])) {
return true;
}
$string = substr($string, strlen($matches[0]));
}
return false;
}
/**
* ConvertToXmlAttribute
*
* @param string $value Value
* @return string
*/
function ConvertToXmlAttribute($value)
{
if (defined('PHP_OS')) {
$os = PHP_OS;
} else {
$os = php_uname();
}
if (strtoupper(substr($os, 0, 3)) === 'WIN' || FindBadUtf8($value)) {
return (utf8_encode(htmlspecialchars($value)));
} else {
return (htmlspecialchars($value));
}
}
/**
* Check whether given extension is in html etensions list
*
* @param string $ext Extension
* @param array $formExtensions Array of extensions
* @return boolean
*/
function IsHtmlExtension($ext, $formExtensions)
{
if (!$formExtensions || !is_array($formExtensions)) {
return false;
}
$lcaseHtmlExtensions = array();
foreach ($formExtensions as $key => $val) {
$lcaseHtmlExtensions[$key] = strtolower($val);
}
return in_array($ext, $lcaseHtmlExtensions);
}
/**
* Detect HTML in the first KB to prevent against potential security issue with
* IE/Safari/Opera file type auto detection bug.
* Returns true if file contain insecure HTML code at the beginning.
*
* @param string $filePath absolute path to file
* @return boolean
*/
function DetectHtml($filePath)
{
$fp = @fopen($filePath, 'rb');
//open_basedir restriction, see #1906
if ($fp === false || !flock($fp, LOCK_SH)) {
return -1;
}
$chunk = fread($fp, 1024);
flock($fp, LOCK_UN);
fclose($fp);
$chunk = strtolower($chunk);
if (!$chunk) {
return false;
}
$chunk = trim($chunk);
if (preg_match("/<!DOCTYPE\W*X?HTML/sim", $chunk)) {
return true;
}
$tags = array('<body', '<head', '<html', '<img', '<pre', '<script', '<table', '<title');
foreach ($tags as $tag) {
if (false !== strpos($chunk, $tag)) {
return true;
}
}
//type = javascript
if (preg_match('!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!sim', $chunk)) {
return true;
}
//href = javascript
//src = javascript
//data = javascript
if (preg_match('!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk)) {
return true;
}
//url(javascript
if (preg_match('!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk)) {
return true;
}
return false;
}
/**
* Check file content.
* Currently this function validates only image files.
* Returns false if file is invalid.
*
* @param string $filePath Absolute path to file
* @param string $extension File extension
* @return boolean True or false
*/
function IsImageValid($filePath, $extension)
{
if (!@is_readable($filePath)) {
return -1;
}
$imageCheckExtensions = array(
'gif',
'jpeg',
'jpg',
'png',
'swf',
'psd',
'bmp',
'iff',
'tiff',
'tif',
'swc',
'jpc',
'jp2',
'jpx',
'jb2',
'xbm',
'wbmp'
);
if (!in_array($extension, $imageCheckExtensions)) {
return true;
}
if (@getimagesize($filePath) === false) {
return false;
}
return true;
}

307
htdocs/core/lib/ftp.lib.php Normal file
View File

@ -0,0 +1,307 @@
<?php
/* Copyright (C) 2022 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2022 Anthony Berton <bertonanthony@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* or see https://www.gnu.org/
*/
/**
* \file htdocs/core/lib/ftp.lib.php
* \brief Set of functions used for FTP
* \ingroup core
*/
/**
* Connect to FTP server
*
* @param string $ftp_server Server name
* @param string $ftp_port Server port
* @param string $ftp_user FTP user
* @param string $ftp_password FTP password
* @param string $section Directory
* @param integer $ftp_passive Use a passive mode
* @return int <0 if OK, >0 if KO
*/
function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $section, $ftp_passive = 0)
{
global $langs, $conf;
$ok = 1;
$error = 0;
$connect_id = null;
$newsectioniso = '';
$mesg="";
if (!is_numeric($ftp_port)) {
$mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServer", $ftp_server, $ftp_port);
$ok = 0;
}
if ($ok) {
$connecttimeout = (empty($conf->global->FTP_CONNECT_TIMEOUT) ? 40 : $conf->global->FTP_CONNECT_TIMEOUT);
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
dol_syslog('Try to connect with ssh2_connect');
$tmp_conn_id = ssh2_connect($ftp_server, $ftp_port);
} elseif (!empty($conf->global->FTP_CONNECT_WITH_SSL)) {
dol_syslog('Try to connect with ftp_ssl_connect');
$connect_id = ftp_ssl_connect($ftp_server, $ftp_port, $connecttimeout);
} else {
dol_syslog('Try to connect with ftp_connect');
$connect_id = ftp_connect($ftp_server, $ftp_port, $connecttimeout);
}
if (!empty($connect_id) || !empty($tmp_conn_id)) {
if ($ftp_user) {
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
dol_syslog('Try to authenticate with ssh2_auth_password');
if (ssh2_auth_password($tmp_conn_id, $ftp_user, $ftp_password)) {
// Turn on passive mode transfers (must be after a successful login
//if ($ftp_passive) ftp_pasv($connect_id, true);
// Change the dir
$newsectioniso = utf8_decode($section);
//ftp_chdir($connect_id, $newsectioniso);
$connect_id = ssh2_sftp($tmp_conn_id);
if (!$connect_id) {
dol_syslog('Failed to connect to SFTP after sssh authentication', LOG_DEBUG);
$mesg = $langs->transnoentitiesnoconv("FailedToConnectToSFTPAfterSSHAuthentication");
$ok = 0;
$error++;
}
} else {
dol_syslog('Failed to connect to FTP with login '.$ftp_user, LOG_DEBUG);
$mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials");
$ok = 0;
$error++;
}
} else {
if (ftp_login($connect_id, $ftp_user, $ftp_password)) {
// Turn on passive mode transfers (must be after a successful login
if ($ftp_passive) {
ftp_pasv($connect_id, true);
}
// Change the dir
$newsectioniso = utf8_decode($section);
ftp_chdir($connect_id, $newsectioniso);
} else {
$mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials");
$ok = 0;
$error++;
}
}
}
} else {
dol_syslog('FailedToConnectToFTPServer '.$ftp_server.' '.$ftp_port, LOG_ERR);
$mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServer", $ftp_server, $ftp_port);
$ok = 0;
}
}
$arrayresult = array('conn_id'=>$connect_id, 'ok'=>$ok, 'mesg'=>$mesg, 'curdir'=>$section, 'curdiriso'=>$newsectioniso);
return $arrayresult;
}
/**
* Tell if an entry is a FTP directory
*
* @param resource $connect_id Connection handler
* @param string $dir Directory
* @return int 1=directory, 0=not a directory
*/
function ftp_isdir($connect_id, $dir)
{
if (@ftp_chdir($connect_id, $dir)) {
ftp_cdup($connect_id);
return 1;
} else {
return 0;
}
}
/**
* Tell if an entry is a FTP directory
*
* @param resource $connect_id Connection handler
* @return result
*/
function dol_ftp_close($connect_id)
{
global $conf;
// Close FTP connection
if ($connect_id) {
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
} elseif (!empty($conf->global->FTP_CONNECT_WITH_SSL)) {
return ftp_close($connect_id);
} else {
return ftp_close($connect_id);
}
}
}
/**
* Delete a FTP file
*
* @param resource $connect_id Connection handler
* @param string $file File
* @param string $newsection $newsection
* @return result
*/
function dol_ftp_delete($connect_id, $file, $newsection)
{
global $conf;
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
$newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
// Remote file
$filename = $file;
$remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file;
$newremotefileiso = utf8_decode($remotefile);
//print "x".$newremotefileiso;
dol_syslog("ftp/index.php ftp_delete ".$newremotefileiso);
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
return ssh2_sftp_unlink($connect_id, $newremotefileiso);
} else {
return @ftp_delete($connect_id, $newremotefileiso);
}
}
/**
* Download a FTP file
*
* @param resource $connect_id Connection handler
* @param string $file File
* @param string $newsection $newsection
* @return result
*/
function dol_ftp_get($connect_id, $file, $newsection)
{
global $conf;
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
$newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
// Remote file
$filename = $file;
$remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file;
$newremotefileiso = utf8_decode($remotefile);
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
return fopen('ssh2.sftp://'.intval($connect_id).$newremotefileiso, 'r');
} else {
return ftp_get($connect_id, $localfile, $newremotefileiso, FTP_BINARY);
}
}
/**
* Upload a FTP file
*
* @param resource $connect_id Connection handler
* @param string $file File name
* @param string $localfile The path to the local file
* @param string $newsection $newsection
* @return result
*/
function dol_ftp_put($connect_id, $file, $localfile, $newsection)
{
global $conf;
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
$newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
// Remote file
$filename = $file;
$remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file;
$newremotefileiso = utf8_decode($remotefile);
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
return ssh2_scp_send($connect_id, $localfile, $newremotefileiso, 0644);
} else {
return ftp_put($connect_id, $newremotefileiso, $localfile, FTP_BINARY);
}
}
/**
* Remove FTP directory
*
* @param resource $connect_id Connection handler
* @param string $file File
* @param string $newsection $newsection
* @return result
*/
function dol_ftp_rmdir($connect_id, $file, $newsection)
{
global $conf;
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
$newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
// Remote file
$filename = $file;
$remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file;
$newremotefileiso = utf8_decode($remotefile);
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
return ssh2_sftp_rmdir($connect_id, $newremotefileiso);
} else {
return @ftp_rmdir($connect_id, $newremotefileiso);
}
}
/**
* Remove FTP directory
*
* @param resource $connect_id Connection handler
* @param string $newdir Dir create
* @param string $newsection $newsection
* @return result
*/
function dol_ftp_mkdir($connect_id, $newdir, $newsection)
{
global $conf;
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
$newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
// Remote file
$newremotefileiso = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$newdir;
$newremotefileiso = utf8_decode($newremotefileiso);
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
return ssh2_sftp_mkdir($connect_id, $newremotefileiso, 0777);
} else {
return @ftp_mkdir($connect_id, $newremotefileiso);
}
}

View File

@ -14,7 +14,7 @@
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019 Thibault Foucart <support@ptibogxiv.net>
* Copyright (C) 2019-2022 Thibault Foucart <support@ptibogxiv.net>
* Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
@ -955,6 +955,14 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options
// Restore entity &apos; into &#39; (restricthtml is for html content so we can use html entity)
$out = preg_replace('/&apos;/i', "&#39;", $out);
} while ($oldstringtoclean != $out);
// Check the limit of external links in a Rich text content. We count '<img' and 'url('
$reg = array();
preg_match_all('/(<img|url\()/i', $out, $reg);
if (count($reg[0]) > getDolGlobalInt("MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 1000)) {
return 'TooManyLinksIntoHTMLString';
}
break;
case 'custom':
if (empty($filter)) {
@ -6816,10 +6824,11 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes
for ($attrs = $els->item($i)->attributes, $ii = $attrs->length - 1; $ii >= 0; $ii--) {
//var_dump($attrs->item($ii));
if (! empty($attrs->item($ii)->name)) {
// Delete attribute if not into allowed_attributes
if (! in_array($attrs->item($ii)->name, $allowed_attributes)) {
// Delete attribute if not into allowed_attributes
$els->item($i)->removeAttribute($attrs->item($ii)->name);
} elseif (in_array($attrs->item($ii)->name, array('style'))) {
// If attribute is 'style'
$valuetoclean = $attrs->item($ii)->value;
if (isset($valuetoclean)) {
@ -6828,10 +6837,14 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes
$valuetoclean = preg_replace('/\/\*.*\*\//m', '', $valuetoclean); // clean css comments
$valuetoclean = preg_replace('/position\s*:\s*[a-z]+/mi', '', $valuetoclean);
if ($els->item($i)->tagName == 'a') { // more paranoiac cleaning for clickable tags.
$valuetoclean = preg_replace('/display\s*://m', '', $valuetoclean);
$valuetoclean = preg_replace('/z-index\s*://m', '', $valuetoclean);
$valuetoclean = preg_replace('/\s+(top|left|right|bottom)\s*://m', '', $valuetoclean);
$valuetoclean = preg_replace('/display\s*:/mi', '', $valuetoclean);
$valuetoclean = preg_replace('/z-index\s*:/mi', '', $valuetoclean);
$valuetoclean = preg_replace('/\s+(top|left|right|bottom)\s*:/mi', '', $valuetoclean);
}
// We do not allow logout|passwordforgotten.php and action= into the content of a "style" tag
$valuetoclean = preg_replace('/(logout|passwordforgotten)\.php/mi', '', $valuetoclean);
$valuetoclean = preg_replace('/action=/mi', '', $valuetoclean);
} while ($oldvaluetoclean != $valuetoclean);
}
@ -7388,6 +7401,9 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = 'Lowest data for planned expiration of service';
$substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = 'Lowest date and hour for planned expiration of service';
}
if (!empty($conf->propal->enabled) && (!is_object($object) || $object->element == 'propal')) {
$substitutionarray['__ONLINE_SIGN_URL__'] = 'ToOfferALinkForOnlineSignature';
}
$substitutionarray['__ONLINE_PAYMENT_URL__'] = 'UrlToPayOnlineIfApplicable';
$substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = 'TextAndUrlToPayOnlineIfApplicable';
$substitutionarray['__SECUREKEYPAYMENT__'] = 'Security key (if key is not unique per record)';
@ -9145,6 +9161,7 @@ function printCommonFooter($zone = 'private')
print "\n";
if (!empty($conf->use_javascript_ajax)) {
print "\n<!-- A script section to add menuhider handler on backoffice, manage focus and madatory fields, tuning info, ... -->\n";
print '<script>'."\n";
print 'jQuery(document).ready(function() {'."\n";
@ -10426,7 +10443,7 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
global $hookmanager, $action, $object, $langs;
//var_dump($params);
if ($params['isDropdown'])
if (!empty($params['isDropdown']))
$class = "dropdown-item";
else {
$class = 'butAction';

View File

@ -254,7 +254,9 @@ function supplier_invoice_rec_prepare_head($object)
function getNumberInvoicesPieChart($mode)
{
global $conf, $db, $langs, $user;
if (isModEnabled('facture') && !empty($user->rights->facture->lire)) {
if (($mode == 'customers' && isModEnabled('facture') && !empty($user->rights->facture->lire))
|| ($mode = 'suppliers') && (isModEnabled('fournisseur') || isModEnabled('supplier_invoice')) && !empty($user->rights->facture->lire)
) {
include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
$now = date_create(date('Y-m-d', dol_now()));

View File

@ -23,16 +23,30 @@
*/
$shortscopegoogle = 'userinfo_email,userinfo_profile';
$shortscopegoogle .= ',openid,email,profile'; // For openid connect
if (!empty($conf->printing->enabled)) {
$shortscopegoogle .= ',cloud_print';
}
if (!empty($conf->global->OAUTH_GOOGLE_GSUITE)) {
$shortscopegoogle .= ',admin_directory_user';
}
if (!empty($conf->global->OAUTH_GOOGLE_GMAIL)) {
$shortscopegoogle.=',gmail_full';
}
// Supported OAUTH (a provider is supported when a file xxx_oauthcallback.php is available into htdocs/core/modules/oauth)
$supportedoauth2array = array(
'OAUTH_GOOGLE_NAME'=>array('callbackfile' => 'google', 'picto' => 'google', 'urlforapp' => 'OAUTH_GOOGLE_DESC', 'name'=>'Google', 'urlforcredentials'=>'https://console.developers.google.com/'),
'OAUTH_GOOGLE_NAME'=>array('callbackfile' => 'google', 'picto' => 'google', 'urlforapp' => 'OAUTH_GOOGLE_DESC', 'name'=>'Google', 'urlforcredentials'=>'https://console.developers.google.com/', 'defaultscope'=>$shortscopegoogle),
);
if (!empty($conf->stripe->enabled)) {
$supportedoauth2array['OAUTH_STRIPE_TEST_NAME'] = array('callbackfile' => 'stripetest', 'picto' => 'stripe', 'urlforapp' => '', 'name'=>'StripeTest', 'urlforcredentials'=>'');
$supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = array('callbackfile' => 'stripelive', 'picto' => 'stripe', 'urlforapp' => '', 'name'=>'StripeLive', 'urlforcredentials'=>'');
$supportedoauth2array['OAUTH_STRIPE_TEST_NAME'] = array('callbackfile' => 'stripetest', 'picto' => 'stripe', 'urlforapp' => '', 'name'=>'StripeTest', 'urlforcredentials'=>'', 'defaultscope'=>'read_write');
$supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = array('callbackfile' => 'stripelive', 'picto' => 'stripe', 'urlforapp' => '', 'name'=>'StripeLive', 'urlforcredentials'=>'', 'defaultscope'=>'read_write');
}
$supportedoauth2array['OAUTH_GITHUB_NAME'] = array('callbackfile' => 'github', 'picto' => 'github', 'urlforapp' => 'OAUTH_GITHUB_DESC', 'name'=>'GitHub', 'urlforcredentials'=>'https://github.com/settings/developers', 'defaultscope'=>'user,public_repo');
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
$supportedoauth2array['OAUTH_OTHER_NAME'] = array('callbackfile' => 'generic', 'picto' => 'generic', 'urlforapp' => 'OAUTH_OTHER_DESC', 'name'=>'Other', 'urlforcredentials'=>'', 'defaultscope'=>'ToComplete');
}
$supportedoauth2array['OAUTH_GITHUB_NAME'] = array('callbackfile' => 'github', 'picto' => 'github', 'urlforapp' => 'OAUTH_GITHUB_DESC', 'name'=>'GitHub', 'urlforcredentials'=>'https://github.com/settings/developers');
// API access parameters OAUTH
@ -259,6 +273,11 @@ $list = array(
'OAUTH_YAMMER_ID',
'OAUTH_YAMMER_SECRET',
),
array(
'OAUTH_OTHER_NAME',
'OAUTH_OTHER_ID',
'OAUTH_OTHER_SECRET',
),
);

View File

@ -453,7 +453,7 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t
if (empty($reshook)) {
if ($mode == 'source') {
$withCountry = 0;
if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
if (isset($targetcompany->country_code) && !empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
$withCountry = 1;
}

View File

@ -56,7 +56,7 @@ function takepos_admin_prepare_head()
$numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS);
for ($i = 1; $i <= $numterminals; $i++) {
$head[$h][0] = DOL_URL_ROOT.'/takepos/admin/terminal.php?terminal='.$i;
$head[$h][1] = $langs->trans("Terminal")." ".$i;
$head[$h][1] = getDolGlobalString('TAKEPOS_TERMINAL_NAME_'.$i, $langs->trans("TerminalName", $i));
$head[$h][2] = 'terminal'.$i;
$h++;
}

View File

@ -84,7 +84,7 @@ function ticket_prepare_head($object)
$head[$h][2] = 'tabTicket';
$h++;
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid) && $conf->societe->enabled) {
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid) && isModEnabled("societe")) {
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
$head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id;
$head[$h][1] = $langs->trans('ContactsAddresses');

View File

@ -1154,7 +1154,7 @@ function get_left_menu_home($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu =
if ($user->rights->user->user->lire) {
if ($usemenuhider || empty($leftmenu) || $leftmenu == "users") {
$newmenu->add("", $langs->trans("Users"), 1, $user->rights->user->user->lire || $user->admin);
$newmenu->add("/user/card.php?leftmenu=users&action=create", $langs->trans("NewUser"), 2, ($user->rights->user->user->creer || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE), '', 'home');
$newmenu->add("/user/card.php?leftmenu=users&action=create", $langs->trans("NewUser"), 2, ($user->hasRight("user", "user", "write") || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE), '', 'home');
$newmenu->add("/user/list.php?leftmenu=users", $langs->trans("ListOfUsers"), 2, $user->rights->user->user->lire || $user->admin);
$newmenu->add("/user/hierarchy.php?leftmenu=users", $langs->trans("HierarchicView"), 2, $user->rights->user->user->lire || $user->admin);
if (isModEnabled('categorie')) {
@ -1162,7 +1162,7 @@ function get_left_menu_home($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu =
$newmenu->add("/categories/index.php?leftmenu=users&type=7", $langs->trans("UsersCategoriesShort"), 2, $user->rights->categorie->lire, '', $mainmenu, 'cat');
}
$newmenu->add("", $langs->trans("Groups"), 1, ($user->rights->user->user->lire || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
$newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) ? $user->rights->user->group_advance->write : $user->rights->user->user->creer) || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
$newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) ? $user->hasRight("user", "group_advance", "create") : $user->hasRight("user", "user", "create")) || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
$newmenu->add("/user/group/list.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) ? $user->rights->user->group_advance->read : $user->rights->user->user->lire) || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
}
}

View File

@ -284,8 +284,8 @@ class doc_generic_asset_odt extends ModelePDFAsset
dol_mkdir($conf->asset->dir_temp);
if (!is_writable($conf->asset->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->asset->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->asset->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -183,16 +183,16 @@ class modPhpbarcode extends ModeleBarCode
*/
public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0)
{
global $conf, $filebarcode;
global $conf, $filebarcode, $langs;
dol_mkdir($conf->barcode->dir_temp);
if (!is_writable($conf->barcode->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->barcode->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->barcode->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}
$file = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
$file = $conf->barcode->dir_temp . '/barcode_' . $code . '_' . $encoding . '.png';
$filebarcode = $file; // global var to be used in barcode_outimage called by barcode_print in buildBarCode

View File

@ -155,16 +155,16 @@ class modTcpdfbarcode extends ModeleBarCode
*/
public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0)
{
global $conf, $_GET;
global $conf, $langs, $_GET;
dol_mkdir($conf->barcode->dir_temp);
if (!is_writable($conf->barcode->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->barcode->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->barcode->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}
$file = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
$file = $conf->barcode->dir_temp . '/barcode_' . $code . '_' . $encoding . '.png';
$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
if (empty($tcpdfEncoding)) {

View File

@ -274,7 +274,7 @@ class doc_generic_bom_odt extends ModelePDFBom
$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -283,11 +283,11 @@ class doc_generic_bom_odt extends ModelePDFBom
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -295,8 +295,8 @@ class doc_generic_bom_odt extends ModelePDFBom
dol_mkdir($conf->bom->dir_temp);
if (!is_writable($conf->bom->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->bom->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->bom->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -280,7 +280,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -289,11 +289,11 @@ class doc_generic_order_odt extends ModelePDFCommandes
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -301,8 +301,8 @@ class doc_generic_order_odt extends ModelePDFCommandes
dol_mkdir($conf->commande->dir_temp);
if (!is_writable($conf->commande->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->commande->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->commande->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -266,7 +266,7 @@ class doc_generic_contract_odt extends ModelePDFContract
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -275,11 +275,11 @@ class doc_generic_contract_odt extends ModelePDFContract
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -287,8 +287,8 @@ class doc_generic_contract_odt extends ModelePDFContract
dol_mkdir($conf->contrat->dir_temp);
if (!is_writable($conf->contrat->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->contrat->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->contrat->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -278,7 +278,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -287,11 +287,11 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -299,8 +299,8 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
dol_mkdir($conf->expedition->dir_temp);
if (!is_writable($conf->expedition->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->expedition->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->expedition->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -278,7 +278,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -287,11 +287,11 @@ class doc_generic_invoice_odt extends ModelePDFFactures
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
//print "newdir=".$dir;
//print "newfile=".$newfile;
@ -300,8 +300,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures
dol_mkdir($conf->facture->dir_temp);
if (!is_writable($conf->facture->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->facture->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->facture->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -115,6 +115,32 @@ class pdf_sponge extends ModelePDFFactures
*/
public $marge_basse;
/**
* @var int heightforinfotot
*/
public $heightforinfotot;
/**
* @var int heightforfreetext
*/
public $heightforfreetext;
/**
* @var int heightforfooter
*/
public $heightforfooter;
/**
* @var int tab_top
*/
public $tab_top;
/**
* @var int tab_top_newpage
*/
public $tab_top_newpage;
/**
* Issuer
* @var Societe Object that emits
@ -345,9 +371,9 @@ class pdf_sponge extends ModelePDFFactures
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$pdf->SetAutoPageBreak(1, 0);
$heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
$this->heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
$this->heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$this->heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false);
@ -429,9 +455,9 @@ class pdf_sponge extends ModelePDFFactures
// $pdf->GetY() here can't be used. It is bottom of the second addresse box but first one may be higher
// $tab_top is y where we must continue content (90 = 42 + 48: 42 is height of logo and ref, 48 is address blocks)
$tab_top = 90 + $top_shift; // top_shift is an addition for linked objects or addons (0 in most cases)
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
// $this->tab_top is y where we must continue content (90 = 42 + 48: 42 is height of logo and ref, 48 is address blocks)
$this->tab_top = 90 + $top_shift; // top_shift is an addition for linked objects or addons (0 in most cases)
$this->tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
// You can add more thing under header here, if you increase $extra_under_address_shift too.
$extra_under_address_shift = 0;
@ -452,7 +478,7 @@ class pdf_sponge extends ModelePDFFactures
'module_width' => 1, // width of a single module in points
'module_height' => 1 // height of a single module in points
);
$pdf->write2DBarcode($qrcodestring, 'QRCODE,M', $this->marge_gauche, $tab_top - 5, 25, 25, $styleQr, 'N');
$pdf->write2DBarcode($qrcodestring, 'QRCODE,M', $this->marge_gauche, $this->tab_top - 5, 25, 25, $styleQr, 'N');
$extra_under_address_shift += 25;
}
@ -469,32 +495,32 @@ class pdf_sponge extends ModelePDFFactures
$extra_under_address_shift += $hookmanager->resArray['extra_under_header_shift'];
}
$tab_top += $extra_under_address_shift;
$tab_top_newpage += 0;
$this->tab_top += $extra_under_address_shift;
$this->tab_top_newpage += 0;
// Define heigth of table for lines (for first page)
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
$tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext;
$nexY = $tab_top - 1;
$nexY = $this->tab_top - 1;
// Incoterm
$height_incoterms = 0;
if (!empty($conf->incoterm->enabled)) {
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms) {
$tab_top -= 2;
$this->tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = max($pdf->GetY(), $nexY);
$height_incoterms = $nexY - $tab_top;
$height_incoterms = $nexY - $this->tab_top;
// Rect takes a length in 3rd parameter
$pdf->SetDrawColor(192, 192, 192);
$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
$pdf->Rect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
$tab_top = $nexY + 6;
$this->tab_top = $nexY + 6;
$height_incoterms += 4;
}
}
@ -521,7 +547,7 @@ class pdf_sponge extends ModelePDFFactures
$pagenb = $pdf->getPage();
if ($notetoshow) {
$tab_top -= 2;
$this->tab_top -= 2;
$tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
$pageposbeforenote = $pagenb;
@ -534,7 +560,7 @@ class pdf_sponge extends ModelePDFFactures
$pdf->startTransaction();
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
// Description
$pageposafternote = $pdf->getPage();
$posyafter = $pdf->GetY();
@ -553,29 +579,29 @@ class pdf_sponge extends ModelePDFFactures
$this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
}
// $this->_pagefoot($pdf,$object,$outputlangs,1);
$pdf->setTopMargin($tab_top_newpage);
$pdf->setTopMargin($this->tab_top_newpage);
// The only function to edit the bottom margin of current page to set it.
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
$pdf->setPageOrientation('', 1, $this->heightforfooter + $this->heightforfreetext);
}
// back to start
$pdf->setPage($pageposbeforenote);
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
$pdf->setPageOrientation('', 1, $this->heightforfooter + $this->heightforfreetext);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
$pageposafternote = $pdf->getPage();
$posyafter = $pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text
if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) { // There is no space left for total+free text
$pdf->AddPage('', '', true);
$pagenb++;
$pageposafternote++;
$pdf->setPage($pageposafternote);
$pdf->setTopMargin($tab_top_newpage);
$pdf->setTopMargin($this->tab_top_newpage);
// The only function to edit the bottom margin of current page to set it.
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
//$posyafter = $tab_top_newpage;
$pdf->setPageOrientation('', 1, $this->heightforfooter + $this->heightforfreetext);
//$posyafter = $this->tab_top_newpage;
}
@ -588,11 +614,11 @@ class pdf_sponge extends ModelePDFFactures
$pdf->SetDrawColor(128, 128, 128);
// Draw note frame
if ($i > $pageposbeforenote) {
$height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
$pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
$height_note = $this->page_hauteur - ($this->tab_top_newpage + $this->heightforfooter);
$pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
} else {
$height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
$pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
$height_note = $this->page_hauteur - ($this->tab_top + $this->heightforfooter);
$pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
}
// Add footer
@ -610,17 +636,17 @@ class pdf_sponge extends ModelePDFFactures
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
$this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
}
$height_note = $posyafter - $tab_top_newpage;
$pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
$height_note = $posyafter - $this->tab_top_newpage;
$pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
} else {
// No pagebreak
$pdf->commitTransaction();
$posyafter = $pdf->GetY();
$height_note = $posyafter - $tab_top;
$pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
$height_note = $posyafter - $this->tab_top;
$pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) {
// not enough space, need to add page
$pdf->AddPage('', '', true);
$pagenb++;
@ -633,12 +659,12 @@ class pdf_sponge extends ModelePDFFactures
$this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
}
$posyafter = $tab_top_newpage;
$posyafter = $this->tab_top_newpage;
}
}
$tab_height = $tab_height - $height_note;
$tab_top = $posyafter + 6;
$this->tab_top = $posyafter + 6;
} else {
$height_note = 0;
}
@ -648,10 +674,10 @@ class pdf_sponge extends ModelePDFFactures
// Table simulation to know the height of the title line (this set this->tableTitleHeight)
$pdf->startTransaction();
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
$this->pdfTabTitles($pdf, $this->tab_top, $tab_height, $outputlangs, $hidetop);
$pdf->rollbackTransaction(true);
$nexY = $tab_top + $this->tabTitleHeight;
$nexY = $this->tab_top + $this->tabTitleHeight;
// Loop on each lines
$pageposbeforeprintlines = $pdf->getPage();
@ -667,8 +693,8 @@ class pdf_sponge extends ModelePDFFactures
$imglinesize = pdf_getSizeForImage($realpatharray[$i]);
}
$pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pdf->setTopMargin($this->tab_top_newpage);
$pdf->setPageOrientation('', 1, $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore = $pdf->getPage();
$showpricebeforepagebreak = 1;
@ -677,14 +703,14 @@ class pdf_sponge extends ModelePDFFactures
if ($this->getColumnStatus('photo')) {
// We start with Photo of product line
if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) { // If photo too high, we moved completely on new page
$pdf->AddPage('', '', true);
if (!empty($tplidx)) {
$pdf->useTemplate($tplidx);
}
$pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
$curY = $this->tab_top_newpage;
// Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
@ -711,14 +737,14 @@ class pdf_sponge extends ModelePDFFactures
if ($pageposafter > $pageposbefore) { // There is a pagebreak
$pdf->rollbackTransaction(true);
$pageposafter = $pageposbefore;
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
$pdf->setPageOrientation('', 1, $this->heightforfooter); // The only function to edit the bottom margin of current page to set it.
$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
$pageposafter = $pdf->getPage();
$posyafter = $pdf->GetY();
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
//var_dump($posyafter); var_dump(($this->page_hauteur - ($this->heightforfooter+$this->heightforfreetext+$this->heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) { // There is no space left for total+free text
if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
$pdf->AddPage('', '', true);
if (!empty($tplidx)) {
@ -752,7 +778,7 @@ class pdf_sponge extends ModelePDFFactures
// We suppose that a too long description or photo were moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter);
$curY = $tab_top_newpage;
$curY = $this->tab_top_newpage;
}
$pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
@ -923,9 +949,9 @@ class pdf_sponge extends ModelePDFFactures
while ($pagenb < $pageposafter) {
$pdf->setPage($pagenb);
if ($pagenb == $pageposbeforeprintlines) {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
$this->_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
} else {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
$this->_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
$pagenb++;
@ -941,9 +967,9 @@ class pdf_sponge extends ModelePDFFactures
if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
if ($pagenb == $pageposafter) {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
$this->_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
} else {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
$this->_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
// New page
@ -960,11 +986,11 @@ class pdf_sponge extends ModelePDFFactures
// Show square
if ($pagenb == $pageposbeforeprintlines) {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
$this->_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
$bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
} else {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
$this->_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
$bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
}
// Display infos area
@ -1217,37 +1243,37 @@ class pdf_sponge extends ModelePDFFactures
if (empty($object->mode_reglement_code)
&& empty($conf->global->FACTURE_CHQ_NUMBER)
&& empty($conf->global->FACTURE_RIB_NUMBER)) {
$this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured");
$this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured");
} elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
|| ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))) {
// Avoid having any valid PDF with setup that is not complete
$outputlangs->load("errors");
|| ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))) {
// Avoid having any valid PDF with setup that is not complete
$outputlangs->load("errors");
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2);
$this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
$pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0, 'L', 0);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2);
$this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
$pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0, 'L', 0);
$pdf->SetTextColor(0, 0, 0);
$posy = $pdf->GetY() + 1;
$posy = $pdf->GetY() + 1;
}
// Show payment mode
if (!empty($object->mode_reglement_code)
&& $object->mode_reglement_code != 'CHQ'
&& $object->mode_reglement_code != 'VIR') {
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
$titre = $outputlangs->transnoentities("PaymentMode").':';
$pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0, 'L');
&& $object->mode_reglement_code != 'CHQ'
&& $object->mode_reglement_code != 'VIR') {
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
$titre = $outputlangs->transnoentities("PaymentMode").':';
$pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0, 'L');
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
$lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
$pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0, 'L');
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
$lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
$pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0, 'L');
$posy = $pdf->GetY();
$posy = $pdf->GetY();
}
// Show online payment link
@ -1432,10 +1458,15 @@ class pdf_sponge extends ModelePDFFactures
$posy = $pdf->GetY();
foreach ($TPreviousIncoice as &$fac) {
if ($posy > $this->page_hauteur - 4) {
if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
$this->_pagefoot($pdf, $object, $outputlangs, 1);
$pdf->addPage();
$pdf->setY($this->marge_haute);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
$this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
$pdf->setY($this->tab_top_newpage);
} else {
$pdf->setY($this->marge_haute);
}
$posy = $pdf->GetY();
}
@ -1495,9 +1526,15 @@ class pdf_sponge extends ModelePDFFactures
$posy += $tab2_hl;
if ($posy > $this->page_hauteur - 4) {
if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
$pdf->addPage();
$pdf->setY($this->marge_haute);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
$this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
$pdf->setY($this->tab_top_newpage);
} else {
$pdf->setY($this->marge_haute);
}
$posy = $pdf->GetY();
}

View File

@ -268,7 +268,7 @@ class doc_generic_member_odt extends ModelePDFMember
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -277,11 +277,11 @@ class doc_generic_member_odt extends ModelePDFMember
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -289,8 +289,8 @@ class doc_generic_member_odt extends ModelePDFMember
dol_mkdir($conf->adherent->dir_temp);
if (!is_writable($conf->adherent->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->adherent->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->adherent->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -250,7 +250,7 @@ class modAdherent extends DolibarrModules
$r++;
$this->rights[$r][0] = 78;
$this->rights[$r][1] = 'Read subscriptions';
$this->rights[$r][1] = 'Read membership fees';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'cotisation';
@ -258,7 +258,7 @@ class modAdherent extends DolibarrModules
$r++;
$this->rights[$r][0] = 79;
$this->rights[$r][1] = 'Create/modify/remove subscriptions';
$this->rights[$r][1] = 'Create/modify/remove membership fees';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'cotisation';

View File

@ -24,6 +24,7 @@
* \brief Description and activation file for the EventOrganization
*/
include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
/**
* Description and activation class for module EventOrganization
@ -257,7 +258,7 @@ class modEventOrganization extends DolibarrModules
'fk_menu'=>'fk_mainmenu=project,fk_leftmenu=eventorganization', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry
'titre'=>'New',
'url'=>'/projet/card.php?leftmenu=projects&action=create&usage_organize_event=1',
'url'=>'/projet/card.php?leftmenu=projects&action=create&usage_organize_event=1&usage_opportunity=0',
'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r,
'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
@ -367,7 +368,9 @@ class modEventOrganization extends DolibarrModules
}
}
return $this->_init($sql, $options);
$init = $this->_init($sql, $options);
return $init;
}
/**

View File

@ -164,6 +164,8 @@ class modWebsite extends DolibarrModules
{
global $conf, $langs;
$error = 0;
$result = $this->_load_tables('/install/mysql/', 'website');
if ($result < 0) {
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
@ -185,11 +187,16 @@ class modWebsite extends DolibarrModules
if ($result < 0) {
$langs->load("errors");
$this->error = $langs->trans('ErrorFailToCopyDir', $src, $dest);
return 0;
$this->errors[] = $langs->trans('ErrorFailToCopyDir', $src, $dest);
$error++;
}
}
}
if ($error) {
return 0;
}
// Website templates
$srcroot = DOL_DOCUMENT_ROOT.'/install/doctemplates/websites';
$destroot = DOL_DATA_ROOT.'/doctemplates/websites';
@ -205,9 +212,15 @@ class modWebsite extends DolibarrModules
if ($result < 0) {
$langs->load("errors");
$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
$this->errors[] = $langs->trans('ErrorFailToCopyFile', $src, $dest);
$error++;
}
}
if ($error) {
return 0;
}
$sql = array();
return $this->_init($sql, $options);

View File

@ -267,7 +267,7 @@ class doc_generic_mo_odt extends ModelePDFMo
$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -276,11 +276,11 @@ class doc_generic_mo_odt extends ModelePDFMo
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -288,8 +288,8 @@ class doc_generic_mo_odt extends ModelePDFMo
dol_mkdir($conf->mrp->dir_temp);
if (!is_writable($conf->mrp->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->mrp->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->mrp->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -0,0 +1,193 @@
<?php
/* Copyright (C) 2022 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/modules/oauth/generic_oauthcallback.php
* \ingroup oauth
* \brief Page to get oauth callback
*/
require '../../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
use OAuth\Common\Storage\DoliStorage;
use OAuth\Common\Consumer\Credentials;
use OAuth\OAuth2\Service\GitHub;
// Define $urlwithroot
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$action = GETPOST('action', 'aZ09');
$backtourl = GETPOST('backtourl', 'alpha');
$keyforprovider = GETPOST('keyforprovider', 'aZ09');
if (empty($keyforprovider) && !empty($_SESSION["oauthkeyforproviderbeforeoauthjump"]) && (GETPOST('code') || $action == 'delete')) {
$keyforprovider = $_SESSION["oauthkeyforproviderbeforeoauthjump"];
}
$genericstring = 'OTHER';
/**
* Create a new instance of the URI class with the current URI, stripping the query string
*/
$uriFactory = new \OAuth\Common\Http\Uri\UriFactory();
//$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER);
//$currentUri->setQuery('');
$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/generic_oauthcallback.php');
/**
* Load the credential for the service
*/
/** @var $serviceFactory \OAuth\ServiceFactory An OAuth service factory. */
$serviceFactory = new \OAuth\ServiceFactory();
$httpClient = new \OAuth\Common\Http\Client\CurlClient();
// TODO Set options for proxy and timeout
// $params=array('CURLXXX'=>value, ...)
//$httpClient->setCurlParameters($params);
$serviceFactory->setHttpClient($httpClient);
// Dolibarr storage
$storage = new DoliStorage($db, $conf);
// Setup the credentials for the requests
$keyforparamid = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_ID';
$keyforparamsecret = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_SECRET';
$credentials = new Credentials(
getDolGlobalString($keyforparamid),
getDolGlobalString($keyforparamsecret),
$currentUri->getAbsoluteUri()
);
$requestedpermissionsarray = array();
if (GETPOST('state')) {
$requestedpermissionsarray = explode(',', GETPOST('state')); // Example: 'user'. 'state' parameter is standard to retrieve some parameters back
}
if ($action != 'delete' && empty($requestedpermissionsarray)) {
print 'Error, parameter state is not defined';
exit;
}
//var_dump($requestedpermissionsarray);exit;
// Instantiate the Api service using the credentials, http client and storage mechanism for the token
$apiService = $serviceFactory->createService($genericstring, $credentials, $storage, $requestedpermissionsarray);
/*
var_dump($genericstring.($keyforprovider ? '-'.$keyforprovider : ''));
var_dump($credentials);
var_dump($storage);
var_dump($requestedpermissionsarray);
*/
if (empty($apiService)) {
print 'Error, failed to create serviceFactory';
exit;
}
// access type needed to have oauth provider refreshing token
//$apiService->setAccessType('offline');
$langs->load("oauth");
if (!getDolGlobalString($keyforparamid)) {
accessforbidden('Setup of service is not complete. Customer ID is missing');
}
if (!getDolGlobalString($keyforparamsecret)) {
accessforbidden('Setup of service is not complete. Secret key is missing');
}
/*
* Actions
*/
if ($action == 'delete') {
$storage->clearToken($genericstring);
setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs');
header('Location: '.$backtourl);
exit();
}
if (GETPOST('code')) { // We are coming from oauth provider page
// We should have
//$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16))
dol_syslog("We are coming from the oauth provider page");
//llxHeader('',$langs->trans("OAuthSetup"));
//$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
//print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup');
//print dol_get_fiche_head();
// retrieve the CSRF state parameter
$state = GETPOSTISSET('state') ? GETPOST('state') : null;
//print '<table>';
// This was a callback request from service, get the token
try {
//var_dump($_GET['code']);
//var_dump($state);
//var_dump($apiService); // OAuth\OAuth2\Service\GitHub
//$token = $apiService->requestAccessToken(GETPOST('code'), $state);
$token = $apiService->requestAccessToken(GETPOST('code'));
// Github is a service that does not need state to be stored.
// Into constructor of GitHub, the call
// parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri)
// has not the ending parameter to true like the Google class constructor.
setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token
$backtourl = $_SESSION["backtourlsavedbeforeoauthjump"];
unset($_SESSION["backtourlsavedbeforeoauthjump"]);
header('Location: '.$backtourl);
exit();
} catch (Exception $e) {
print $e->getMessage();
}
} else { // If entry on page with no parameter, we arrive here
$_SESSION["backtourlsavedbeforeoauthjump"] = $backtourl;
$_SESSION["oauthkeyforproviderbeforeoauthjump"] = $keyforprovider;
$_SESSION['oauthstateanticsrf'] = $state;
// This may create record into oauth_state before the header redirect.
// Creation of record with state in this tables depend on the Provider used (see its constructor).
if (GETPOST('state')) {
$url = $apiService->getAuthorizationUri(array('state' => GETPOST('state')));
} else {
$url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated
}
// we go on oauth provider authorization page
header('Location: '.$url);
exit();
}
/*
* View
*/
// No view at all, just actions
$db->close();

View File

@ -1,5 +1,5 @@
<?php
/*
/* Copyright (C) 2022 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -86,7 +86,7 @@ if ($action != 'delete' && empty($requestedpermissionsarray)) {
//var_dump($requestedpermissionsarray);exit;
// Instantiate the Api service using the credentials, http client and storage mechanism for the token
$apiService = $serviceFactory->createService('GitHub'.($keyforprovider ? '-'.$keyforprovider : ''), $credentials, $storage, $requestedpermissionsarray);
$apiService = $serviceFactory->createService('GitHub', $credentials, $storage, $requestedpermissionsarray);
// access type needed to have oauth provider refreshing token
//$apiService->setAccessType('offline');

View File

@ -1,5 +1,5 @@
<?php
/*
/* Copyright (C) 2022 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
<?php
/*
/* Copyright (C) 2022 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
*
* This program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
<?php
/*
/* Copyright (C) 2022 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify

View File

@ -278,7 +278,7 @@ class doc_generic_product_odt extends ModelePDFProduct
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -287,11 +287,11 @@ class doc_generic_product_odt extends ModelePDFProduct
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -299,8 +299,8 @@ class doc_generic_product_odt extends ModelePDFProduct
dol_mkdir($conf->product->dir_temp);
if (!is_writable($conf->product->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->product->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->product->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -556,7 +556,7 @@ class doc_generic_project_odt extends ModelePDFProjects
$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -565,11 +565,11 @@ class doc_generic_project_odt extends ModelePDFProjects
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -577,8 +577,8 @@ class doc_generic_project_odt extends ModelePDFProjects
dol_mkdir($conf->project->dir_temp);
if (!is_writable($conf->project->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->project->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->project->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -517,9 +517,9 @@ class doc_generic_task_odt extends ModelePDFTask
$newfiletmp = preg_replace('/\.(ods|odt)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
$file = $dir.'/'.$newfiletmp.'.odt';
$file = $dir . '/' . $newfiletmp . '.odt';
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -527,8 +527,8 @@ class doc_generic_task_odt extends ModelePDFTask
dol_mkdir($conf->project->dir_temp);
if (!is_writable($conf->project->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->project->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->project->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -311,7 +311,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -320,11 +320,11 @@ class doc_generic_proposal_odt extends ModelePDFPropales
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -332,8 +332,8 @@ class doc_generic_proposal_odt extends ModelePDFPropales
dol_mkdir($conf->propal->multidir_temp[$object->entity]);
if (!is_writable($conf->propal->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->propal->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->propal->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -271,7 +271,7 @@ class doc_generic_reception_odt extends ModelePdfReception
$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -280,11 +280,11 @@ class doc_generic_reception_odt extends ModelePdfReception
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -292,8 +292,8 @@ class doc_generic_reception_odt extends ModelePdfReception
dol_mkdir($conf->reception->dir_temp);
if (!is_writable($conf->reception->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->reception->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->reception->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -256,7 +256,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (!empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME)) {
$newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)).'-'.$newfiletmp;
$newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)) . '-' . $newfiletmp;
$newfiletmp = preg_replace('/__+/', '_', $newfiletmp); // Replace repeated _ into one _ (to avoid string with substitution syntax)
}
if (!empty($conf->global->MAIN_DOC_USE_TIMING)) {
@ -264,11 +264,11 @@ class doc_generic_odt extends ModeleThirdPartyDoc
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
$object->builddoc_filename = $filename; // For triggers
//print "newfileformat=".$newfileformat;
//print "newdir=".$dir;
@ -279,8 +279,8 @@ class doc_generic_odt extends ModeleThirdPartyDoc
dol_mkdir($conf->societe->multidir_temp[$object->entity]);
if (!is_writable($conf->societe->multidir_temp[$object->entity])) {
$this->error = "Failed to write in temp directory ".$conf->societe->multidir_temp[$object->entity];
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->societe->multidir_temp[$object->entity]);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -279,7 +279,7 @@ class doc_generic_stock_odt extends ModelePDFStock
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -288,11 +288,11 @@ class doc_generic_stock_odt extends ModelePDFStock
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -300,8 +300,8 @@ class doc_generic_stock_odt extends ModelePDFStock
dol_mkdir($conf->product->dir_temp);
if (!is_writable($conf->product->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->product->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->product->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -262,7 +262,7 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders
$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -271,11 +271,11 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -283,8 +283,8 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders
dol_mkdir($conf->fournisseur->commande->dir_temp);
if (!is_writable($conf->fournisseur->commande->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->fournisseur->commande->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->fournisseur->commande->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -297,7 +297,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -306,11 +306,11 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -318,8 +318,8 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
dol_mkdir($conf->supplier_proposal->dir_temp);
if (!is_writable($conf->supplier_proposal->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->supplier_proposal->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->supplier_proposal->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -266,7 +266,7 @@ class doc_generic_ticket_odt extends ModelePDFTicket
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -275,11 +275,11 @@ class doc_generic_ticket_odt extends ModelePDFTicket
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -287,8 +287,8 @@ class doc_generic_ticket_odt extends ModelePDFTicket
dol_mkdir($conf->ticket->dir_temp);
if (!is_writable($conf->ticket->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->ticket->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->ticket->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -297,7 +297,7 @@ class doc_generic_user_odt extends ModelePDFUser
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -306,11 +306,11 @@ class doc_generic_user_odt extends ModelePDFUser
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -318,8 +318,8 @@ class doc_generic_user_odt extends ModelePDFUser
dol_mkdir($conf->user->dir_temp);
if (!is_writable($conf->user->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->user->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->user->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -281,7 +281,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
$newfiletmp = $objectref . '_' . $newfiletmp;
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
@ -290,11 +290,11 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat;
} else {
$filename = $newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir.'/'.$filename;
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -302,8 +302,8 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
dol_mkdir($conf->user->dir_temp);
if (!is_writable($conf->user->dir_temp)) {
$this->error = "Failed to write in temp directory ".$conf->user->dir_temp;
dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->user->dir_temp);
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}

View File

@ -147,7 +147,8 @@ if ($action == 'presend') {
$formmail->fromtype = 'special';
}
$formmail->trackid = $trackid;
$formmail->trackid = empty($trackid) ? '' : $trackid;
$formmail->inreplyto = empty($inreplyto) ? '' : $inreplyto;
$formmail->withfrom = 1;
// Fill list of recipient with email inside <>.

View File

@ -387,10 +387,12 @@ class InterfaceTicketEmail extends DolibarrTriggers
$trackid = 'tic'.$object->id;
$old_MAIN_MAIL_AUTOCOPY_TO = getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO');
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject, $sendto, $from, $message_customer, $filepath, $mimetype, $filename, '', '', 0, -1, '', '', $trackid, '', 'ticket');
if ($mailfile->error) {

View File

@ -120,7 +120,7 @@ if ($user->socid > 0) {
// For some module part, dir may be privates
if (in_array($modulepart, array('facture_paiement', 'unpaid'))) {
if (empty($user->rights->societe->client->voir) || $socid) {
if (empty($user->hasRight('societe', 'client', 'voir')) || $socid) {
$original_file = 'private/'.$user->id.'/'.$original_file; // If user has no permission to see all, output dir is specific to user
}
}

Some files were not shown because too many files have changed in this diff Show More