diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 834a1e75a65..9b6dd8b9468 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1182,7 +1182,7 @@ class Adherent extends CommonObject if ($result >= 0) { $result = $luser->setPassword($user, $this->pass, 0, 0, 1); - if (is_numeric($result) && $result < 0) { + if (is_int($result) && $result < 0) { $this->error = $luser->error; dol_syslog(get_class($this)."::setPassword ".$this->error, LOG_ERR); $error++; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index aeb862541e1..8ae9600e5ae 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1590,6 +1590,7 @@ if ($object->id > 0) { if (isModEnabled('facture') && $object->status == 1) { if (empty($user->rights->facture->creer)) { + $langs->load("bills"); print '
'.$langs->trans("AddBill").'
'; } else { $langs->loadLangs(array("orders", "bills")); @@ -1602,7 +1603,7 @@ if ($object->id > 0) { print '
'.$langs->trans("CreateInvoiceForThisCustomer").'
'; } } else { - print '
'.$langs->trans("AddBill").'
'; + print '
'.$langs->trans("CreateInvoiceForThisCustomer").'
'; } } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 994a9bd9a63..e7dfdd4128b 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -156,11 +156,11 @@ if (empty($reshook)) { if ($result > 0) { $result2 = $nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha) - if ($result2) { - $db->commit(); - } else { + if (is_int($result2) && $result2 < 0) { $error = $nuser->error; $errors = $nuser->errors; $db->rollback(); + } else { + $db->commit(); } } else { $error = $nuser->error; $errors = $nuser->errors; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 893ab54ff4c..5d36a6fbd82 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -350,25 +350,23 @@ if (preg_match('/^set(\w+)$/', $action, $reg) && GETPOST('id', 'int') > 0 && !em if ($action == "update_extras" && GETPOST('id', 'int') > 0 && !empty($permissiontoadd)) { $object->fetch(GETPOST('id', 'int')); - $attributekey = GETPOST('attribute', 'alpha'); - $attributekeylong = 'options_'.$attributekey; + $error = 0; - if (GETPOSTISSET($attributekeylong.'day') && GETPOSTISSET($attributekeylong.'month') && GETPOSTISSET($attributekeylong.'year')) { - // This is properties of a date - $object->array_options['options_'.$attributekey] = dol_mktime(GETPOST($attributekeylong.'hour', 'int'), GETPOST($attributekeylong.'min', 'int'), GETPOST($attributekeylong.'sec', 'int'), GETPOST($attributekeylong.'month', 'int'), GETPOST($attributekeylong.'day', 'int'), GETPOST($attributekeylong.'year', 'int')); - //var_dump(dol_print_date($object->array_options['options_'.$attributekey]));exit; - } else { - $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, 'alpha'); - } - - $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); - if ($result > 0) { - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - $action = 'view'; - } else { + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); + if ($ret < 0) { $error++; - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($extrafields->error, $object->errors, 'errors'); $action = 'edit_extras'; + } else { + $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); + if ($result > 0) { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + $action = 'view'; + } else { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit_extras'; + } } } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 22510525a64..fb7477a16b4 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -565,8 +565,8 @@ if (!$error && $massaction == 'confirm_presend') { $resaction .= '
'.$mailfile->error.'
'; } else { $result = $mailfile->sendfile(); - if ($result) { - $resaction .= $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)).'
'; // Must not contain " + if ($result > 0) { + $resaction .= $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).'
'; // Must not contain " $error = 0; diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 6f951eff6ea..b3e71f4d543 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -241,7 +241,7 @@ class HookManager $actionclassinstance->error = 0; $actionclassinstance->errors = array(); - if (getDolGlobalInt('MAIN_DEBUG_HOOK')) { + if (getDolGlobalInt('MAIN_HOOK_DEBUG')) { // This his too much verbose, enabled if const enabled only dol_syslog(get_class($this)."::executeHooks Qualified hook found (hooktype=".$hooktype."). We call method ".get_class($actionclassinstance).'->'.$method.", context=".$context.", module=".$module.", action=".$action.((is_object($object) && property_exists($object, 'id')) ? ', object id='.$object->id : '').((is_object($object) && property_exists($object, 'element')) ? ', object element='.$object->element : ''), LOG_DEBUG); } @@ -283,7 +283,7 @@ class HookManager continue; } - if (getDolGlobalInt('MAIN_DEBUG_HOOK')) { + if (getDolGlobalInt('MAIN_HOOK_DEBUG')) { dol_syslog("Call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", hooktype=".$hooktype, LOG_DEBUG); } diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index e1356fb5dec..0be3b0dbaad 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -362,7 +362,7 @@ class FormOther public function select_percent($selected = 0, $htmlname = 'percent', $disabled = 0, $increment = 5, $start = 0, $end = 100, $showempty = 0) { // phpcs:enable - $return = ''; if ($showempty) { $return .= ''; } diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 7b20fa125bb..ad1299c91c1 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -384,7 +384,7 @@ class FormProjets include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); $out .= $comboenhancement; - $morecss .= ' minwidth150'; + $morecss .= ' minwidth150imp'; } if (empty($option_only)) { diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index 02e56ff9d71..6df4e6d11a1 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -190,7 +190,8 @@ interface Database public function escape($stringtoencode); /** - * Escape a string to insert data into a like + * Escape a string to insert data into a like. + * Can be used this way: LIKE '%".dbhandler->escapeforlike(dbhandler->escape(...))."%' * * @param string $stringtoencode String to escape * @return string String escaped diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 6255bd81710..9f19233dcad 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -238,9 +238,10 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $request = curl_getinfo($ch, CURLINFO_HEADER_OUT); // Reading of request must be done after sending request dol_syslog("getURLContent request=".$request); - if (!empty($conf->global->MAIN_GETURLCONTENT_OUTPUT_RESPONSE)) { + if (getDolGlobalInt('MAIN_CURL_DEBUG')) { // This may contains binary data, so we dont output reponse by default. - dol_syslog("getURLContent response =".$response); + dol_syslog("getURLContent request=".$request, LOG_DEBUG, 0, '_curl'); + dol_syslog("getURLContent response =".$response, LOG_DEBUG, 0, '_curl'); } dol_syslog("getURLContent response size=".strlen($response)); // This may contains binary data, so we dont output it diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index fe1cf9d6f16..68a8ba1910b 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1298,8 +1298,8 @@ class ExpenseReport extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql .= " SET ref = '".$this->db->escape($num)."',"; $sql .= " fk_statut = ".self::STATUS_VALIDATED.","; - $sql .= " date_valid='".$this->db->idate($this->date_valid)."',"; - $sql .= " fk_user_valid = ".$user->id; + $sql .= " date_valid = '".$this->db->idate($this->date_valid)."',"; + $sql .= " fk_user_valid = ".((int) $user->id); $sql .= " WHERE rowid = ".((int) $this->id); $resql = $this->db->query($sql); @@ -1322,7 +1322,7 @@ class ExpenseReport extends CommonObject // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'expensereport/".$this->db->escape($this->newref)."'"; - $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expensereport/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expensereport/".$this->db->escape($this->ref)."' AND entity = ".((int) $this->entity); $resql = $this->db->query($sql); if (!$resql) { $error++; $this->error = $this->db->lasterror(); @@ -1331,15 +1331,15 @@ class ExpenseReport extends CommonObject // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); - $dirsource = $conf->expensereport->dir_output.'/'.$oldref; - $dirdest = $conf->expensereport->dir_output.'/'.$newref; + $dirsource = $conf->expensereport->multidir_output[$this->entity].'/'.$oldref; + $dirdest = $conf->expensereport->multidir_output[$this->entity].'/'.$newref; if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::setValidate() rename dir ".$dirsource." into ".$dirdest); if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles = dol_dir_list($conf->expensereport->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + $listoffiles = dol_dir_list($dirdest, 'files', 1, '^'.preg_quote($oldref, '/')); foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 890c9c21f9e..43d9ce26c13 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1378,6 +1378,7 @@ if (empty($reshook)) { ); if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); $error++; break; } diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index 93e3c421c0c..cac5adb22ba 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -95,3 +95,5 @@ NewPartnershipRequest=New partnership request NewPartnershipRequestDesc=This form allows you to request to be part of one of our partnership program. If you need help to fill this form, please contact by email %s. ThisUrlMustContainsAtLeastOneLinkToWebsite=This page must contains at least one link to one of the following domain: %s +IPOfApplicant=IP of applicant + diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 69cb712d7fa..034cd1614ae 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -470,7 +470,7 @@ class MyObject extends CommonObject } elseif (strpos($value, '%') === false) { $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")"; } else { - $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; + $sqlwhere[] = $key." LIKE '%".$this->db->escapeforlike($this->db->escape($value))."%'"; } } } @@ -925,6 +925,9 @@ class MyObject extends CommonObject if (property_exists($this, 'label')) { $return .= '
'.$this->label.'
'; } + if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) { + $return .= '
'.$this->thirdparty->getNomUrl(1).'
'; + } if (property_exists($this, 'amount')) { $return .= '
'; $return .= ''.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency).''; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index db0a6ddf5d1..db7cdd34d67 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -700,6 +700,20 @@ while ($i < $imaxinloop) { // Store properties in $object $object->setVarsFromFetchObj($obj); + /* + $object->thirdparty = null; + if ($obj->fk_soc > 0) { + if (!empty($conf->cache['thirdparty'][$obj->fk_soc])) { + $companyobj = $conf->cache['thirdparty'][$obj->fk_soc]; + } else { + $companyobj = new Societe($db); + $companyobj->fetch($obj->fk_soc); + $conf->cache['thirdparty'][$obj->fk_soc] = $companyobj; + } + + $object->thirdparty = $companyobj; + }*/ + if ($mode == 'kanban') { if ($i == 0) { print ''; @@ -713,6 +727,7 @@ while ($i < $imaxinloop) { $selected = 1; } } + //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected)); print $object->getKanbanView('', array('selected' => $selected)); if ($i == ($imaxinloop - 1)) { print ''; diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index e86b0750ff0..8bb88021090 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -120,12 +120,12 @@ class Partnership extends CommonObject 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), 'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,), - 'url_to_check' => array('type'=>'url', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax150'), - 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), - 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,), + 'url_to_check' => array('type'=>'url', 'label'=>'UrlToCheck', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax150'), + 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>71, 'notnull'=>0, 'visible'=>-4, 'default'=>'0',), + 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>72, 'notnull'=>0, 'visible'=>-4,), 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,), - 'ip' => array('type'=>'ip', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,), - 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '8'=>'Suspended', '9'=>'Terminated'),), + 'ip' => array('type'=>'ip', 'label'=>'IPOfApplicant', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,), + 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '2'=>'Approved', '3'=>'Refused', '9'=>'Terminated'),), ); public $rowid; public $ref; @@ -1309,8 +1309,6 @@ class Partnership extends CommonObject */ public function doScheduledJob() { - global $conf, $langs; - //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; $error = 0; @@ -1319,7 +1317,7 @@ class Partnership extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); - $now = dol_now(); + //$now = dol_now(); $this->db->begin(); @@ -1352,6 +1350,9 @@ class Partnership extends CommonObject if (property_exists($this, 'label')) { $return .= '
'.$this->label.'
'; } + if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) { + $return .= '
'.$this->thirdparty->getNomUrl(1).'
'; + } if (method_exists($this, 'getLibStatut')) { $return .= '
'.$this->getLibStatut(3).'
'; } diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index c73bc4230d4..96ee748bae3 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -147,7 +147,7 @@ class PartnershipUtils $partnershipsprocessed[$object->id] = $object->ref; // Send an email to inform member - $labeltemplate = '(SendingEmailOnPartnershipCanceled)'; + $labeltemplate = '('.getDolGlobalString('PARTNERSHIP_SENDMAIL_IF_AUTO_CANCEL', 'SendingEmailOnPartnershipCanceled').')'; dol_syslog("Now we will send an email to member id=".$object->fk_member." with label ".$labeltemplate); @@ -175,16 +175,59 @@ class PartnershipUtils $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + // We are in the case of autocancellation subscription because of missing backlink + $fk_partner = $object->fk_member; + $adherent = new Adherent($this->db); $adherent->fetch($object->fk_member); - $to = $adherent->email; + $sendto = $adherent->email; + + $trackid = 'par'.$object->id; + $sendcontext = 'standard'; + + $cmail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', $trackid, '', $sendcontext); - $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); $result = $cmail->sendfile(); - if (!$result || $cmail->error) { + + if (!$result || !empty($cmail->error) || !empty($cmail->errors)) { $erroremail .= ($erroremail ? ', ' : '').$cmail->error; $this->errors[] = $cmail->error; if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; + } else { + // Initialisation of datas of object to call trigger + if (is_object($object)) { + $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically + $attachedfiles = array(); + + $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $object->actionmsg = $arraydefaultmessage->topic."\n".$arraydefaultmessage->content; // Long text + $object->actionmsg2 = $langs->transnoentities("PartnershipSentByEMail", $object->ref);; // Short text ($langs->transnoentities('MailSentBy')...); + if (!empty($conf->global->MAIN_MAIL_REPLACE_EVENT_TITLE_BY_EMAIL_SUBJECT)) { + $object->actionmsg2 = $subject; // Short text + } + + $object->trackid = $trackid; + $object->fk_element = $object->id; + $object->elementtype = $object->element; + if (is_array($attachedfiles) && count($attachedfiles) > 0) { + $object->attachedfiles = $attachedfiles; + } + + $object->email_from = $from; + $object->email_subject = $subject; + $object->email_to = $sendto; + $object->email_subject = $subject; + + $triggersendname = 'PARTNERSHIP_SENTBYMAIL'; + // Call of triggers (you should have set $triggersendname to execute trigger) + if (!empty($triggersendname)) { + $result = $object->call_trigger($triggersendname, $user); + if ($result < 0) { + $error++; + } + } + // End call of triggers + } } } } @@ -215,16 +258,19 @@ class PartnershipUtils * * CAN BE A CRON TASK * - * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + * @param int $maxpercall Max per call + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ - public function doWarningOfPartnershipIfDolibarrBacklinkNotfound() + public function doWarningOfPartnershipIfDolibarrBacklinkNotfound($maxpercall = 0) { global $conf, $langs, $user; $managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR'); $partnership = new Partnership($this->db); - $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) ? 10 : $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL); // Limit to 10 per call + if (empty($maxpercall)) { + $maxpercall = getDolGlobalInt('PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL', 10); + } $langs->loadLangs(array("partnership", "member")); @@ -236,23 +282,23 @@ class PartnershipUtils $emailnotfound = ''; $websitenotfound = ''; - $gracedelay = $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; + /*$gracedelay = getDolGlobalInt('PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL'); if ($gracedelay < 1) { $this->error = 'BadValueForDelayBeforeCancelCheckSetup'; return -1; - } + }*/ $fk_partner = ($managedfor == 'member') ? 'fk_member' : 'fk_soc'; dol_syslog(get_class($this)."::doWarningOfPartnershipIfDolibarrBacklinkNotfound Warning of partnership"); $now = dol_now(); - $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); + //$datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); $this->db->begin(); $sql = "SELECT p.rowid, p.status, p.".$fk_partner; - $sql .= ", p.last_check_backlink"; + $sql .= ", p.url_to_check, p.last_check_backlink"; $sql .= ', partner.url, partner.email'; $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; if ($managedfor == 'member') { @@ -276,10 +322,12 @@ class PartnershipUtils $obj = $this->db->fetch_object($resql); if ($obj) { - if (!empty($partnershipsprocessed[$obj->rowid])) continue; + if (!empty($partnershipsprocessed[$obj->rowid])) { + continue; + } - if ($somethingdoneonpartnership >= $MAXPERCALL) { - dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING); + if ($somethingdoneonpartnership >= $maxpercall) { + dol_syslog("We reach the limit of ".$maxpercall." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING); break; } @@ -294,7 +342,7 @@ class PartnershipUtils $fk_partner = $object->fk_soc; } - $website = $obj->url; + $website = (empty($obj->url_to_check) ? $obj->url : $obj->url_to_check); if (empty($website)) { $websitenotfound .= ($websitenotfound ? ', ' : '').'Website not found for id="'.$fk_partner.'"'."\n"; @@ -305,51 +353,101 @@ class PartnershipUtils if (!$backlinkfound) { $tmpcount = $object->count_last_url_check_error + 1; - if ($tmpcount > 2 && $tmpcount <= 4) { // Send Warning Email - if (!empty($obj->email)) { - $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n"; - } else { - $labeltemplate = '(SendingEmailOnPartnershipWillSoonBeCanceled)'; + $nbminbacklinkerrorforcancel = getDolGlobalString('PARTNERSHIP_MIN_BACKLINK_ERROR_FOR_CANCEL', 3); + $nbmaxbacklinkerrorforcancel = getDolGlobalString('PARTNERSHIP_MAX_BACKLINK_ERROR_FOR_CANCEL', $nbminbacklinkerrorforcancel + 2); - dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate); + // If $nbminbacklinkerrorforemail = 0, no autoemail + if ($nbminbacklinkerrorforcancel > 0) { + if ($tmpcount > $nbminbacklinkerrorforcancel && $tmpcount <= $nbmaxbacklinkerrorforcancel) { // Send Warning Email + if (!empty($obj->email)) { + $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n"; + } else { + // Example: 'SendingEmailOnPartnershipWillSoonBeCanceled' + $labeltemplate = '('.getDolGlobalString('PARTNERSHIP_SENDMAIL_IF_NO_LINK', 'SendingEmailOnPartnershipWillSoonBeCanceled').')'; - // Send deployment email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $formmail = new FormMail($this->db); + dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate); - // Define output language - $outputlangs = $langs; - $newlang = ''; - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - $outputlangs->loadLangs(array('main', 'member', 'partnership')); - } - - $arraydefaultmessage = $formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); - - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - - $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); - $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); - $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; - - $to = $obj->email; - - $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); - $result = $cmail->sendfile(); - if (!$result || $cmail->error) { - $erroremail .= ($erroremail ? ', ' : '').$cmail->error; - $this->errors[] = $cmail->error; - if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; + // Send deployment email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $formmail = new FormMail($this->db); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->loadLangs(array('main', 'member', 'partnership')); + } + + $arraydefaultmessage = $formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); + + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + + $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); + $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + + $sendto = $obj->email; + + $trackid = 'par'.$object->id; + $sendcontext = 'standard'; + + $cmail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', $trackid, '', $sendcontext); + + $result = $cmail->sendfile(); + + if (!$result || !empty($cmail->error) || !empty($cmail->errors)) { + $erroremail .= ($erroremail ? ', ' : '').$cmail->error; + $this->errors[] = $cmail->error; + if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; + } else { + // Initialisation of datas of object to call trigger + if (is_object($object)) { + $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically + $attachedfiles = array(); + + if ($managedfor != 'member') { + $object->socid = $fk_partner; // To link to a company + } + $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $object->actionmsg = $arraydefaultmessage->topic."\n".$arraydefaultmessage->content; // Long text + $object->actionmsg2 = $langs->transnoentities("PartnershipSentByEMail", $object->ref);; // Short text ($langs->transnoentities('MailSentBy')...); + if (!empty($conf->global->MAIN_MAIL_REPLACE_EVENT_TITLE_BY_EMAIL_SUBJECT)) { + $object->actionmsg2 = $subject; // Short text + } + + $object->trackid = $trackid; + $object->fk_element = $object->id; + $object->elementtype = $object->element; + if (is_array($attachedfiles) && count($attachedfiles) > 0) { + $object->attachedfiles = $attachedfiles; + } + + $object->email_from = $from; + $object->email_subject = $subject; + $object->email_to = $sendto; + $object->email_subject = $subject; + + $triggersendname = 'PARTNERSHIP_SENTBYMAIL'; + // Call of triggers (you should have set $triggersendname to execute trigger) + if (!empty($triggersendname)) { + $result = $object->call_trigger($triggersendname, $user); + if ($result < 0) { + $error++; + } + } + // End call of triggers + } + } } + } elseif ($tmpcount > $nbmaxbacklinkerrorforcancel) { // Cancel Partnership + $object->status = $object::STATUS_CANCELED; + $object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite'); } - } elseif ($tmpcount > 4) { // Cancel Partnership - $object->status = $object::STATUS_CANCELED; - $object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite'); } $object->count_last_url_check_error = $tmpcount; @@ -360,7 +458,7 @@ class PartnershipUtils $partnershipsprocessed[$object->id] = $object->ref; - $object->last_check_backlink = $this->db->idate($now); + $object->last_check_backlink = $now; $object->update($user); } @@ -394,7 +492,7 @@ class PartnershipUtils */ private function checkDolibarrBacklink($website = null) { - global $conf, $langs, $user; + global $conf; $found = 0; $error = 0; diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 27821a2b799..a6653c17a17 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php'; @@ -286,6 +287,7 @@ if (empty($reshook)) { */ $form = new Form($db); +$companystatic = new Societe($db); $now = dol_now(); @@ -863,13 +865,26 @@ while ($i < $imaxinloop) { // Store properties in $object $object->setVarsFromFetchObj($obj); + $object->thirdparty = null; + if ($obj->fk_soc > 0) { + if (!empty($conf->cache['thirdparty'][$obj->fk_soc])) { + $companyobj = $conf->cache['thirdparty'][$obj->fk_soc]; + } else { + $companyobj = new Societe($db); + $companyobj->fetch($obj->fk_soc); + $conf->cache['thirdparty'][$obj->fk_soc] = $companyobj; + } + + $object->thirdparty = $companyobj; + } + if ($mode == 'kanban') { if ($i == 0) { print ''; print '
'; } // Output Kanban - print $object->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected))); + print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => in_array($object->id, $arrayofselected))); if ($i == ($imaxinloop - 1)) { print '
'; print ''; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index b044b2a2a48..b9c03aa2610 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -729,6 +729,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print dol_get_fiche_head(''); + print '
'; print ''; $defaultref = ''; @@ -755,7 +756,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third // Label print ''; // Project @@ -774,12 +775,12 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print ''; @@ -819,7 +820,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) { $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT; } - $doleditor = new DolEditor('description', $object->description, '', 80, 'dolibarr_details', '', false, true, $cked_enabled, $nbrows); + $doleditor = new DolEditor('description', $object->description, '', 80, 'dolibarr_details', '', false, true, $cked_enabled, $nbrows, '90%'); print $doleditor->Create(); print ''; @@ -839,6 +840,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third } print '
'.$langs->trans("Label").''; - print ''; + print ''; print '
'.$langs->trans("AffectedTo").''; print img_picto('', 'user', 'class="pictofixedwidth"'); if (is_array($contactsofproject) && count($contactsofproject)) { - print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300'); + print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth500 widthcentpercentminusx'); } else { if ((isset($projectid) && $projectid > 0) || $object->id > 0) { print ''.$langs->trans("NoUserAssignedToTheProject").''; } else { - print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth500 widthcentpercentminusx'); } } print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 00598eab4a9..03746dcf72c 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1790,7 +1790,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($projectstatic->public) { $contactsofproject = array(); } - print $form->select_dolusers((GETPOST('userid', 'int') ? GETPOST('userid', 'int') : $userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200'); + print $form->select_dolusers((GETPOST('userid', 'int') ? GETPOST('userid', 'int') : $userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'minwidth150imp maxwidth200'); } else { if ($nboftasks) { print img_error($langs->trans('FirstAddRessourceToAllocateTime')) . ' ' . $langs->trans('FirstAddRessourceToAllocateTime'); diff --git a/htdocs/public/notice.php b/htdocs/public/notice.php index 57f47424501..c107fba3d3b 100644 --- a/htdocs/public/notice.php +++ b/htdocs/public/notice.php @@ -59,3 +59,5 @@ if (!GETPOST('transkey', 'alphanohtml') && !GETPOST('transphrase', 'alphanohtml' print dol_escape_htmltag($langs->trans(GETPOST('transkey', 'alphanohtml'))); } } + +$db->close(); diff --git a/htdocs/salaries/document.php b/htdocs/salaries/document.php index c90069ef8bf..f5be79b373d 100644 --- a/htdocs/salaries/document.php +++ b/htdocs/salaries/document.php @@ -92,6 +92,7 @@ if ($id > 0 || !empty($ref)) { if (!empty($user->rights->salaries->read) && $object->fk_user > 0 && in_array($object->fk_user, $childids)) { $canread = 1; } + if (!$canread) { accessforbidden(); } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 998b7daa756..354c5350a63 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -351,7 +351,7 @@ if (empty($reshook)) { if (GETPOST('password', 'none')) { $resPass = $object->setPassword($user, GETPOST('password', 'none')); } - if ($resPass < 0) { + if (is_int($resPass) && $resPass < 0) { $langs->load("errors"); $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); @@ -664,7 +664,7 @@ if (empty($reshook)) { $object->oldcopy = clone $object; $ret = $object->setPassword($user, GETPOST("password", "none")); - if ($ret < 0) { + if (is_int($ret) && $ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -679,7 +679,7 @@ if (empty($reshook)) { $object->fetch($id); $newpassword = $object->setPassword($user, ''); // This will generate a new password - if ($newpassword < 0) { + if (is_int($newpassword) && $newpassword < 0) { // Echec setEventMessages($langs->trans("ErrorFailedToSetNewPassword"), null, 'errors'); } else { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index b7e5bd76297..5b8eb1131b5 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1772,7 +1772,7 @@ class User extends CommonObject if ($result > 0) { if (!empty($this->pass)) { // If a clear password was received (this situation should not happen anymore now), we use it to save it into database $newpass = $this->setPassword($user, $this->pass); - if (is_numeric($newpass) && $newpass < 0) { + if (is_int($newpass) && $newpass < 0) { $result = -2; } } elseif (!empty($this->pass_crypted)) { // If a crypted password is already known, we save it directly into database because the previous create did not save it. @@ -2047,7 +2047,7 @@ class User extends CommonObject if ($this->pass != $this->pass_indatabase && !dol_verifyHash($this->pass, $this->pass_indatabase_crypted)) { // If a new value for password is set and different than the one crypted into database $result = $this->setPassword($user, $this->pass, 0, $notrigger, $nosyncmemberpass, 0, 1); - if (is_numeric($result) && $result < 0) { + if (is_int($result) && $result < 0) { return -5; } } @@ -2339,7 +2339,7 @@ class User extends CommonObject if ($result >= 0) { $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent - if (is_numeric($result) && $result < 0) { + if (is_int($result) && $result < 0) { $this->error = $adh->error; dol_syslog(get_class($this)."::setPassword ".$this->error, LOG_ERR); $error++; diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index ad66bc5987a..2a711208e8b 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -151,7 +151,7 @@ if (empty($reshook)) { $message .= $messagewarning; } else { $newpassword = $edituser->setPassword($user, '', 1); - if (is_numeric($newpassword) && $newpassword < 0) { + if (is_int($newpassword) && $newpassword < 0) { // Technical failure $message = '
'.$langs->trans("ErrorFailedToChangePassword").'
'; } else { diff --git a/htdocs/webservices/server_user.php b/htdocs/webservices/server_user.php index 21a9bbd23d4..5ef9055af8f 100644 --- a/htdocs/webservices/server_user.php +++ b/htdocs/webservices/server_user.php @@ -709,7 +709,7 @@ function setUserPassword($authentication, $shortuser) $res = $userstat->fetch('', $shortuser['login']); if ($res) { $res = $userstat->setPassword($userstat, $shortuser['password']); - if (is_numeric($res) && $res < 0) { + if (is_int($res) && $res < 0) { $error++; $errorcode = 'NOT_MODIFIED'; $errorlabel = 'Error when changing password'; } else {