Skip to content

Commit

Permalink
Fix regression db => this->db
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Sep 15, 2017
1 parent ac1d701 commit 3c95328
Show file tree
Hide file tree
Showing 21 changed files with 59 additions and 60 deletions.
4 changes: 2 additions & 2 deletions htdocs/core/modules/cheque/mod_chequereceipt_mint.php
Expand Up @@ -73,7 +73,7 @@ function canBeActivated()
$posindice=9;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down Expand Up @@ -107,7 +107,7 @@ function getNextValue($objsoc,$object)
$posindice=9;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque";
$sql.= " WHERE ref like '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref like '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/commande/mod_commande_marbre.php
Expand Up @@ -73,7 +73,7 @@ function canBeActivated()
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down Expand Up @@ -107,7 +107,7 @@ function getNextValue($objsoc,$object)
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/contract/mod_contract_serpis.php
Expand Up @@ -72,7 +72,7 @@ function canBeActivated()
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."contrat";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down Expand Up @@ -105,7 +105,7 @@ function getNextValue($objsoc,$contract)
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."contrat";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/expedition/mod_expedition_safor.php
Expand Up @@ -71,7 +71,7 @@ function canBeActivated()
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down Expand Up @@ -104,7 +104,7 @@ function getNextValue($objsoc,$shipment)
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/expensereport/mod_expensereport_jade.php
Expand Up @@ -72,7 +72,7 @@ function canBeActivated()
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down Expand Up @@ -105,7 +105,7 @@ function getNextValue($object)
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/facture/mod_facture_mars.php
Expand Up @@ -89,7 +89,7 @@ function canBeActivated()
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$this->db->escape($this->prefixinvoice)."____-%'";
$sql.= " WHERE facnumber LIKE '".$db->escape($this->prefixinvoice)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand All @@ -111,7 +111,7 @@ function canBeActivated()
$posindice=8;
$sql = "SELECT MAX(SUBSTRING(facnumber FROM ".$posindice.")) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$this->db->escape($this->prefixcreditnote)."____-%'";
$sql.= " WHERE facnumber LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/modules/facture/mod_facture_terre.php
Expand Up @@ -87,7 +87,7 @@ function canBeActivated()
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$this->db->escape($this->prefixinvoice)."____-%'";
$sql.= " WHERE facnumber LIKE '".$db->escape($this->prefixinvoice)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand All @@ -109,7 +109,7 @@ function canBeActivated()
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$this->db->escape($this->prefixcreditnote)."____-%'";
$sql.= " WHERE facnumber LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand All @@ -130,7 +130,7 @@ function canBeActivated()
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$this->db->escape($this->prefixdeposit)."____-%'";
$sql.= " WHERE facnumber LIKE '".$db->escape($this->prefixdeposit)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/fichinter/mod_pacific.php
Expand Up @@ -74,7 +74,7 @@ function canBeActivated()
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " WHERE entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down Expand Up @@ -110,7 +110,7 @@ function getNextValue($objsoc=0,$object='')
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down
3 changes: 1 addition & 2 deletions htdocs/core/modules/fichinter/modules_fichinter.php
Expand Up @@ -60,8 +60,7 @@ static function liste_modeles($db,$maxfilenamelength=0)


/**
* \class ModeleNumRefFicheinter
* \brief Classe mere des modeles de numerotation des references de fiches d'intervention
* Classe mere des modeles de numerotation des references de fiches d'intervention
*/
abstract class ModeleNumRefFicheinter
{
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/modules/livraison/mod_livraison_jade.php
Expand Up @@ -80,7 +80,7 @@ function canBeActivated()
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."livraison";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down Expand Up @@ -114,7 +114,7 @@ function getNextValue($objsoc,$object)
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."livraison";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand All @@ -133,7 +133,7 @@ function getNextValue($objsoc,$object)
$date=$object->date_delivery;
if (empty($date)) $date=dol_now();
$yymm = strftime("%y%m",$date);

if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s",$max+1);

Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/payment/mod_payment_cicada.php
Expand Up @@ -73,7 +73,7 @@ function canBeActivated()
$posindice=9;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."paiement";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down Expand Up @@ -107,7 +107,7 @@ function getNextValue($objsoc,$object)
$posindice=9;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."paiement";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down
26 changes: 13 additions & 13 deletions htdocs/core/modules/printing/printgcp.modules.php
Expand Up @@ -47,7 +47,7 @@ class printing_printgcp extends PrintingDriver
var $db;

private $OAUTH_SERVICENAME_GOOGLE = 'Google';

const LOGIN_URL = 'https://accounts.google.com/o/oauth2/token';
const PRINTERS_SEARCH_URL = 'https://www.google.com/cloudprint/search';
const PRINTERS_GET_JOBS = 'https://www.google.com/cloudprint/jobs';
Expand All @@ -68,11 +68,11 @@ function __construct($db)
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current

$this->db = $db;

if (!$conf->oauth->enabled) {
$this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>$langs->transnoentitiesnoconv("WarningModuleNotActive", "OAuth"), 'type'=>'info');
} else {

$this->google_id = $conf->global->OAUTH_GOOGLE_ID;
$this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET;
// Token storage
Expand All @@ -95,7 +95,7 @@ function __construct($db)
$token_ok = false;
}
//var_dump($this->errors);exit;

$expire = false;
// Is token expired or will token expire in the next 30 seconds
if ($token_ok) {
Expand All @@ -119,9 +119,9 @@ function __construct($db)
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'delete'=>($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):''));
if ($token_ok) {
$expiredat='';

$refreshtoken = $token->getRefreshToken();

$endoflife=$token->getEndOfLife();

if ($endoflife == $token::EOL_NEVER_EXPIRES)
Expand All @@ -136,7 +136,7 @@ function __construct($db)
{
$expiredat=dol_print_date($endoflife, "dayhour");
}

$this->conf[] = array('varname'=>'TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info');
$this->conf[] = array('varname'=>'TOKEN_EXPIRED', 'info'=>($expire?'Yes':'No'), 'type'=>'info');
$this->conf[] = array('varname'=>'TOKEN_EXPIRE_AT', 'info'=>($expiredat), 'type'=>'info');
Expand Down Expand Up @@ -284,7 +284,7 @@ function print_file($file, $module, $subdir='')
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

global $conf, $user, $db;
global $conf, $user;
$error = 0;

$fileprint=$conf->{$module}->dir_output;
Expand All @@ -293,7 +293,7 @@ function print_file($file, $module, $subdir='')
$mimetype = dol_mimetype($fileprint);
// select printer uri for module order, propal,...
$sql = "SELECT rowid, printer_id, copy FROM ".MAIN_DB_PREFIX."printing WHERE module='".$module."' AND driver='printgcp' AND userid=".$user->id;
$result = $db->query($sql);
$result = $this->db->query($sql);
if ($result)
{
$obj = $this->db->fetch_object($result);
Expand All @@ -315,7 +315,7 @@ function print_file($file, $module, $subdir='')
}
}
}
else dol_print_error($db);
else dol_print_error($this->db);

$ret = $this->sendPrintToPrinter($printer_id, $file, $fileprint, $mimetype);
$this->errors = 'PRINTGCP: '.mb_convert_encoding($ret['errormessage'], "UTF-8");
Expand Down Expand Up @@ -399,7 +399,7 @@ public function sendPrintToPrinter($printerid, $printjobtitle, $filepath, $conte
function list_jobs()
{
global $conf, $db, $langs, $bc;

$error = 0;
$html = '';
// Token storage
Expand Down Expand Up @@ -489,9 +489,9 @@ function list_jobs()
}
$html .= '</table>';
$html .= '</div>';

$this->resprint = $html;

return $error;
}

Expand Down
8 changes: 4 additions & 4 deletions htdocs/core/modules/printing/printipp.modules.php
Expand Up @@ -77,7 +77,7 @@ function __construct($db)
*/
function print_file($file, $module, $subdir='')
{
global $conf, $user, $db;
global $conf, $user;
$error = 0;

include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
Expand All @@ -92,7 +92,7 @@ function print_file($file, $module, $subdir='')

// select printer uri for module order, propal,...
$sql = "SELECT rowid,printer_id,copy FROM ".MAIN_DB_PREFIX."printing WHERE module = '".$module."' AND driver = 'printipp' AND userid = ".$user->id;
$result = $db->query($sql);
$result = $this->db->query($sql);
if ($result)
{
$obj = $this->db->fetch_object($result);
Expand All @@ -116,7 +116,7 @@ function print_file($file, $module, $subdir='')
}
}
}
else dol_print_error($db);
else dol_print_error($this->db);

// Set number of copy
$ipp->setCopies($obj->copy);
Expand Down Expand Up @@ -163,7 +163,7 @@ function listAvailablePrinters()
$var = true;
foreach ($list as $value)
{

$printer_det = $this->get_printer_detail($value);
$html.= "<tr ".$bc[$var].">";
$html.= '<td>'.$value.'</td>';
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/project/mod_project_simple.php
Expand Up @@ -75,7 +75,7 @@ function canBeActivated()
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."projet";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
Expand Down Expand Up @@ -111,7 +111,7 @@ function getNextValue($objsoc,$project)
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."projet";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/project/task/mod_task_simple.php
Expand Up @@ -76,7 +76,7 @@ function canBeActivated()
$sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM " . $posindice . ") AS SIGNED)) as max";
$sql .= " FROM " . MAIN_DB_PREFIX . "projet_task AS task, ";
$sql .= MAIN_DB_PREFIX . "projet AS project WHERE task.fk_projet=project.rowid";
$sql .= " AND task.ref LIKE '" . $this->db->escape($this->prefix) . "____-%'";
$sql .= " AND task.ref LIKE '" . $db->escape($this->prefix) . "____-%'";
$sql .= " AND project.entity = " . $conf->entity;
$resql=$db->query($sql);
if ($resql)
Expand Down Expand Up @@ -112,7 +112,7 @@ function getNextValue($objsoc,$object)
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

$resql=$db->query($sql);
if ($resql)
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/propale/mod_propale_marbre.php
Expand Up @@ -75,7 +75,7 @@ function canBeActivated()
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down Expand Up @@ -112,7 +112,7 @@ function getNextValue($objsoc,$propal)
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
$sql.= " WHERE ref LIKE '".$this->db->escape($this->prefix)."____-%'";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;

$resql=$db->query($sql);
Expand Down

0 comments on commit 3c95328

Please sign in to comment.