Fixing style errors.
This commit is contained in:
parent
5a8742b3eb
commit
48dffaaa53
@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
|
|||||||
dol_include_once('partnership/lib/partnership.lib.php');
|
dol_include_once('partnership/lib/partnership.lib.php');
|
||||||
dol_include_once('/partnership/class/partnership.class.php');
|
dol_include_once('/partnership/class/partnership.class.php');
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.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.class.php';
|
||||||
/**
|
/**
|
||||||
* Class with cron tasks of Partnership module
|
* Class with cron tasks of Partnership module
|
||||||
@ -83,8 +83,7 @@ class PartnershipUtils
|
|||||||
$partnershipsprocessed = array();
|
$partnershipsprocessed = array();
|
||||||
|
|
||||||
$gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL;
|
$gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL;
|
||||||
if ($gracedelay < 1)
|
if ($gracedelay < 1) {
|
||||||
{
|
|
||||||
$this->error='BadValueForDelayBeforeCancelCheckSetup';
|
$this->error='BadValueForDelayBeforeCancelCheckSetup';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -108,23 +107,19 @@ class PartnershipUtils
|
|||||||
// Limit is managed into loop later
|
// Limit is managed into loop later
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$numofexpiredmembers = $this->db->num_rows($resql);
|
$numofexpiredmembers = $this->db->num_rows($resql);
|
||||||
|
|
||||||
$somethingdoneonpartnership = 0;
|
$somethingdoneonpartnership = 0;
|
||||||
$ifetchpartner = 0;
|
$ifetchpartner = 0;
|
||||||
while ($ifetchpartner < $numofexpiredmembers)
|
while ($ifetchpartner < $numofexpiredmembers) {
|
||||||
{
|
|
||||||
$ifetchpartner++;
|
$ifetchpartner++;
|
||||||
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
if ($obj)
|
if ($obj) {
|
||||||
{
|
|
||||||
if (! empty($partnershipsprocessed[$obj->rowid])) continue;
|
if (! empty($partnershipsprocessed[$obj->rowid])) continue;
|
||||||
|
|
||||||
if ($somethingdoneonpartnership >= $MAXPERCALL)
|
if ($somethingdoneonpartnership >= $MAXPERCALL) {
|
||||||
{
|
|
||||||
dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doCancelStatusOfMemberPartnership to avoid to reach email quota.", LOG_WARNING);
|
dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doCancelStatusOfMemberPartnership to avoid to reach email quota.", LOG_WARNING);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -135,23 +130,19 @@ class PartnershipUtils
|
|||||||
// Get expiration date
|
// Get expiration date
|
||||||
$expirationdate = $obj->datefin;
|
$expirationdate = $obj->datefin;
|
||||||
|
|
||||||
if ($expirationdate && $expirationdate < $now) // If contract expired (we already had a test into main select, this is a security)
|
if ($expirationdate && $expirationdate < $now) { // If contract expired (we already had a test into main select, this is a security)
|
||||||
{
|
|
||||||
$somethingdoneonpartnership++;
|
$somethingdoneonpartnership++;
|
||||||
|
|
||||||
$result = $object->cancel($user, 0);
|
$result = $object->cancel($user, 0);
|
||||||
// $conf->global->noapachereload = null;
|
// $conf->global->noapachereload = null;
|
||||||
if ($result < 0)
|
if ($result < 0) {
|
||||||
{
|
|
||||||
$error++;
|
$error++;
|
||||||
$this->error = $object->error;
|
$this->error = $object->error;
|
||||||
if (is_array($object->errors) && count($object->errors)) {
|
if (is_array($object->errors) && count($object->errors)) {
|
||||||
if (is_array($this->errors)) $this->errors = array_merge($this->errors, $object->errors);
|
if (is_array($this->errors)) $this->errors = array_merge($this->errors, $object->errors);
|
||||||
else $this->errors = $object->errors;
|
else $this->errors = $object->errors;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$partnershipsprocessed[$object->id]=$object->ref;
|
$partnershipsprocessed[$object->id]=$object->ref;
|
||||||
|
|
||||||
// Send an email to inform member
|
// Send an email to inform member
|
||||||
@ -189,32 +180,25 @@ class PartnershipUtils
|
|||||||
|
|
||||||
$cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1);
|
$cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1);
|
||||||
$result = $cmail->sendfile();
|
$result = $cmail->sendfile();
|
||||||
if (! $result || $cmail->error)
|
if (! $result || $cmail->error) {
|
||||||
{
|
|
||||||
$erroremail .= ($erroremail ? ', ' : '').$cmail->error;
|
$erroremail .= ($erroremail ? ', ' : '').$cmail->error;
|
||||||
$this->errors[] = $cmail->error;
|
$this->errors[] = $cmail->error;
|
||||||
if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors;
|
if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$error++;
|
$error++;
|
||||||
$this->error = $this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error) {
|
||||||
{
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
$this->output = $numofexpiredmembers.' expired partnership members found'."\n";
|
$this->output = $numofexpiredmembers.' expired partnership members found'."\n";
|
||||||
if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail;
|
if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
$this->output = "Rollback after error\n";
|
$this->output = "Rollback after error\n";
|
||||||
$this->output.= $numofexpiredmembers.' expired partnership members found'."\n";
|
$this->output.= $numofexpiredmembers.' expired partnership members found'."\n";
|
||||||
@ -250,8 +234,7 @@ class PartnershipUtils
|
|||||||
$partnershipsprocessed = array();
|
$partnershipsprocessed = array();
|
||||||
|
|
||||||
$gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL;
|
$gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL;
|
||||||
if ($gracedelay < 1)
|
if ($gracedelay < 1) {
|
||||||
{
|
|
||||||
$this->error='BadValueForDelayBeforeCancelCheckSetup';
|
$this->error='BadValueForDelayBeforeCancelCheckSetup';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -286,22 +269,18 @@ class PartnershipUtils
|
|||||||
// Limit is managed into loop later
|
// Limit is managed into loop later
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$numofexpiredmembers = $this->db->num_rows($resql);
|
$numofexpiredmembers = $this->db->num_rows($resql);
|
||||||
$somethingdoneonpartnership = 0;
|
$somethingdoneonpartnership = 0;
|
||||||
$ifetchpartner = 0;
|
$ifetchpartner = 0;
|
||||||
while ($ifetchpartner < $numofexpiredmembers)
|
while ($ifetchpartner < $numofexpiredmembers) {
|
||||||
{
|
|
||||||
$ifetchpartner++;
|
$ifetchpartner++;
|
||||||
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
if ($obj)
|
if ($obj) {
|
||||||
{
|
|
||||||
if (! empty($partnershipsprocessed[$obj->rowid])) continue;
|
if (! empty($partnershipsprocessed[$obj->rowid])) continue;
|
||||||
|
|
||||||
if ($somethingdoneonpartnership >= $MAXPERCALL)
|
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);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
@ -329,12 +308,9 @@ class PartnershipUtils
|
|||||||
$tmpcount = $object->count_last_url_check_error + 1;
|
$tmpcount = $object->count_last_url_check_error + 1;
|
||||||
|
|
||||||
if ($tmpcount == 3) { // Send Warning Email
|
if ($tmpcount == 3) { // Send Warning Email
|
||||||
|
|
||||||
if (!empty($obj->email)) {
|
if (!empty($obj->email)) {
|
||||||
$emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n";
|
$emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$labeltemplate = '(SendingEmailOnPartnershipWillExpire)';
|
$labeltemplate = '(SendingEmailOnPartnershipWillExpire)';
|
||||||
|
|
||||||
dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate);
|
dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate);
|
||||||
@ -367,22 +343,18 @@ class PartnershipUtils
|
|||||||
|
|
||||||
$cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1);
|
$cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1);
|
||||||
$result = $cmail->sendfile();
|
$result = $cmail->sendfile();
|
||||||
if (! $result || $cmail->error)
|
if (! $result || $cmail->error) {
|
||||||
{
|
|
||||||
$erroremail .= ($erroremail ? ', ' : '').$cmail->error;
|
$erroremail .= ($erroremail ? ', ' : '').$cmail->error;
|
||||||
$this->errors[] = $cmail->error;
|
$this->errors[] = $cmail->error;
|
||||||
if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors;
|
if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} elseif ($tmpcount > 4) { // Cancel Partnership
|
} elseif ($tmpcount > 4) { // Cancel Partnership
|
||||||
$object->status = $object::STATUS_CANCELED;
|
$object->status = $object::STATUS_CANCELED;
|
||||||
$object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite');
|
$object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite');
|
||||||
}
|
}
|
||||||
|
|
||||||
$object->count_last_url_check_error = $tmpcount;
|
$object->count_last_url_check_error = $tmpcount;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$object->count_last_url_check_error = 0;
|
$object->count_last_url_check_error = 0;
|
||||||
$object->reason_decline_or_cancel = '';
|
$object->reason_decline_or_cancel = '';
|
||||||
@ -395,23 +367,18 @@ class PartnershipUtils
|
|||||||
$object->update($user);
|
$object->update($user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$error++;
|
$error++;
|
||||||
$this->error = $this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error) {
|
||||||
{
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
$this->output = $numofexpiredmembers.' partnership checked'."\n";
|
$this->output = $numofexpiredmembers.' partnership checked'."\n";
|
||||||
if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n";
|
if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n";
|
||||||
if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n";
|
if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n";
|
||||||
if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n";
|
if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
$this->output = "Rollback after error\n";
|
$this->output = "Rollback after error\n";
|
||||||
$this->output.= $numofexpiredmembers.' partnership checked'."\n";
|
$this->output.= $numofexpiredmembers.' partnership checked'."\n";
|
||||||
@ -464,8 +431,7 @@ class PartnershipUtils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($webcontent && !empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK) && preg_match('/'.$conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK.'/', $webcontent))
|
if ($webcontent && !empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK) && preg_match('/'.$conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK.'/', $webcontent)) {
|
||||||
{
|
|
||||||
$found = 1;
|
$found = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user