Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
39a9b41c42
@ -86,10 +86,9 @@ class Skeleton_Class extends CommonObject
|
|||||||
*
|
*
|
||||||
* @param DoliDb $db Database handler
|
* @param DoliDb $db Database handler
|
||||||
*/
|
*/
|
||||||
public function __construct( DoliDB $db )
|
public function __construct(DoliDB $db)
|
||||||
{
|
{
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,18 +100,18 @@ class Skeleton_Class extends CommonObject
|
|||||||
*
|
*
|
||||||
* @return int <0 if KO, Id of created object if OK
|
* @return int <0 if KO, Id of created object if OK
|
||||||
*/
|
*/
|
||||||
public function create( User $user, $notrigger = false )
|
public function create(User $user, $notrigger = false)
|
||||||
{
|
{
|
||||||
dol_syslog( __METHOD__, LOG_DEBUG );
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
if (isset( $this->prop1 )) {
|
if (isset($this->prop1)) {
|
||||||
$this->prop1 = trim( $this->prop1 );
|
$this->prop1 = trim($this->prop1);
|
||||||
}
|
}
|
||||||
if (isset( $this->prop2 )) {
|
if (isset($this->prop2)) {
|
||||||
$this->prop2 = trim( $this->prop2 );
|
$this->prop2 = trim($this->prop2);
|
||||||
}
|
}
|
||||||
//...
|
//...
|
||||||
|
|
||||||
@ -132,15 +131,15 @@ class Skeleton_Class extends CommonObject
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$resql = $this->db->query( $sql );
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
$error ++;
|
$error ++;
|
||||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
dol_syslog( __METHOD__ . ' ' . join( ',', $this->errors ), LOG_ERR );
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$this->id = $this->db->last_insert_id( MAIN_DB_PREFIX . $this->table_element );
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
|
||||||
|
|
||||||
if (!$notrigger) {
|
if (!$notrigger) {
|
||||||
// Uncomment this and change MYOBJECT to your own tag if you
|
// Uncomment this and change MYOBJECT to your own tag if you
|
||||||
@ -173,9 +172,9 @@ class Skeleton_Class extends CommonObject
|
|||||||
*
|
*
|
||||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function fetch( $id, $ref = null )
|
public function fetch($id, $ref = null)
|
||||||
{
|
{
|
||||||
dol_syslog( __METHOD__, LOG_DEBUG );
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
$sql = 'SELECT';
|
$sql = 'SELECT';
|
||||||
$sql .= ' t.rowid,';
|
$sql .= ' t.rowid,';
|
||||||
@ -189,18 +188,18 @@ class Skeleton_Class extends CommonObject
|
|||||||
$sql .= ' WHERE t.rowid = ' . $id;
|
$sql .= ' WHERE t.rowid = ' . $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$resql = $this->db->query( $sql );
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$numrows = $this->db->num_rows( $resql );
|
$numrows = $this->db->num_rows($resql);
|
||||||
if ($numrows) {
|
if ($numrows) {
|
||||||
$obj = $this->db->fetch_object( $resql );
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
$this->prop1 = $obj->field1;
|
$this->prop1 = $obj->field1;
|
||||||
$this->prop2 = $obj->field2;
|
$this->prop2 = $obj->field2;
|
||||||
//...
|
//...
|
||||||
}
|
}
|
||||||
$this->db->free( $resql );
|
$this->db->free($resql);
|
||||||
|
|
||||||
if ($numrows) {
|
if ($numrows) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -209,7 +208,7 @@ class Skeleton_Class extends CommonObject
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
dol_syslog( __METHOD__ . ' ' . join( ',', $this->errors ), LOG_ERR );
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||||
|
|
||||||
return - 1;
|
return - 1;
|
||||||
}
|
}
|
||||||
@ -226,9 +225,9 @@ class Skeleton_Class extends CommonObject
|
|||||||
*
|
*
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function fetchAll( $sortorder, $sortfield, $limit, $offset, array $filter = array() )
|
public function fetchAll($sortorder, $sortfield, $limit, $offset, array $filter = array())
|
||||||
{
|
{
|
||||||
dol_syslog( __METHOD__, LOG_DEBUG );
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
$sql = 'SELECT';
|
$sql = 'SELECT';
|
||||||
$sql .= ' t.rowid,';
|
$sql .= ' t.rowid,';
|
||||||
@ -239,23 +238,23 @@ class Skeleton_Class extends CommonObject
|
|||||||
|
|
||||||
// Manage filter
|
// Manage filter
|
||||||
$sqlwhere = array();
|
$sqlwhere = array();
|
||||||
if (count( $filter ) > 0) {
|
if (count($filter) > 0) {
|
||||||
foreach ($filter as $key => $value) {
|
foreach ($filter as $key => $value) {
|
||||||
$sqlwhere [] = ' AND ' . $key . ' LIKE \'%' . $this->db->escape( $value ) . '%\'';
|
$sqlwhere [] = ' AND ' . $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count( $sqlwhere ) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' WHERE ' . implode( ' AND ', $sqlwhere );
|
$sql .= ' WHERE ' . implode(' AND ', $sqlwhere);
|
||||||
}
|
}
|
||||||
$sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder . ' ' . $this->db->plimit( $limit + 1, $offset );
|
$sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder . ' ' . $this->db->plimit($limit + 1, $offset);
|
||||||
|
|
||||||
$this->lines = array();
|
$this->lines = array();
|
||||||
|
|
||||||
$resql = $this->db->query( $sql );
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $this->db->num_rows( $resql );
|
$num = $this->db->num_rows($resql);
|
||||||
|
|
||||||
while ($obj = $this->db->fetch_object( $resql )) {
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
$line = new Skeleton_ClassLine();
|
$line = new Skeleton_ClassLine();
|
||||||
|
|
||||||
$line->id = $obj->rowid;
|
$line->id = $obj->rowid;
|
||||||
@ -265,12 +264,12 @@ class Skeleton_Class extends CommonObject
|
|||||||
$this->lines[] = $line;
|
$this->lines[] = $line;
|
||||||
//...
|
//...
|
||||||
}
|
}
|
||||||
$this->db->free( $resql );
|
$this->db->free($resql);
|
||||||
|
|
||||||
return $num;
|
return $num;
|
||||||
} else {
|
} else {
|
||||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
dol_syslog( __METHOD__ . ' ' . join( ',', $this->errors ), LOG_ERR );
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||||
|
|
||||||
return - 1;
|
return - 1;
|
||||||
}
|
}
|
||||||
@ -284,18 +283,18 @@ class Skeleton_Class extends CommonObject
|
|||||||
*
|
*
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function update( User $user, $notrigger = false )
|
public function update(User $user, $notrigger = false)
|
||||||
{
|
{
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
dol_syslog( __METHOD__, LOG_DEBUG );
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
if (isset( $this->prop1 )) {
|
if (isset($this->prop1)) {
|
||||||
$this->prop1 = trim( $this->prop1 );
|
$this->prop1 = trim($this->prop1);
|
||||||
}
|
}
|
||||||
if (isset( $this->prop2 )) {
|
if (isset($this->prop2)) {
|
||||||
$this->prop2 = trim( $this->prop2 );
|
$this->prop2 = trim($this->prop2);
|
||||||
}
|
}
|
||||||
//...
|
//...
|
||||||
|
|
||||||
@ -304,13 +303,13 @@ class Skeleton_Class extends CommonObject
|
|||||||
|
|
||||||
// Update request
|
// Update request
|
||||||
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
|
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
|
||||||
if (isset( $this->field1 )) {
|
if (isset($this->field1)) {
|
||||||
$sql .= ' field1=\'' . $this->db->escape( $this->field1 ) . '\',';
|
$sql .= ' field1=\'' . $this->db->escape($this->field1) . '\',';
|
||||||
} else {
|
} else {
|
||||||
$sql .= ' field1=null' . ',';
|
$sql .= ' field1=null' . ',';
|
||||||
}
|
}
|
||||||
if (isset( $this->field2 )) {
|
if (isset($this->field2)) {
|
||||||
$sql .= ' field2=\'' . $this->db->escape( $this->field2 ) . '\'';
|
$sql .= ' field2=\'' . $this->db->escape($this->field2) . '\'';
|
||||||
} else {
|
} else {
|
||||||
$sql .= ' field2=null';
|
$sql .= ' field2=null';
|
||||||
}
|
}
|
||||||
@ -319,11 +318,11 @@ class Skeleton_Class extends CommonObject
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$resql = $this->db->query( $sql );
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
$error ++;
|
$error ++;
|
||||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
dol_syslog( __METHOD__ . ' ' . join( ',', $this->errors ), LOG_ERR );
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error && !$notrigger) {
|
if (!$error && !$notrigger) {
|
||||||
@ -356,9 +355,9 @@ class Skeleton_Class extends CommonObject
|
|||||||
*
|
*
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function delete( User $user, $notrigger = false )
|
public function delete(User $user, $notrigger = false)
|
||||||
{
|
{
|
||||||
dol_syslog( __METHOD__, LOG_DEBUG );
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
@ -380,11 +379,11 @@ class Skeleton_Class extends CommonObject
|
|||||||
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element;
|
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element;
|
||||||
$sql .= ' WHERE rowid=' . $this->id;
|
$sql .= ' WHERE rowid=' . $this->id;
|
||||||
|
|
||||||
$resql = $this->db->query( $sql );
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
$error ++;
|
$error ++;
|
||||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
dol_syslog( __METHOD__ . ' ' . join( ',', $this->errors ), LOG_ERR );
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,18 +406,18 @@ class Skeleton_Class extends CommonObject
|
|||||||
*
|
*
|
||||||
* @return int New id of clone
|
* @return int New id of clone
|
||||||
*/
|
*/
|
||||||
public function createFromClone( $fromid )
|
public function createFromClone($fromid)
|
||||||
{
|
{
|
||||||
dol_syslog( __METHOD__, LOG_DEBUG );
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
global $user;
|
global $user;
|
||||||
$error = 0;
|
$error = 0;
|
||||||
$object = new Skeleton_Class( $this->db );
|
$object = new Skeleton_Class($this->db);
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Load source object
|
// Load source object
|
||||||
$object->fetch( $fromid );
|
$object->fetch($fromid);
|
||||||
// Reset object
|
// Reset object
|
||||||
$object->id = 0;
|
$object->id = 0;
|
||||||
|
|
||||||
@ -426,13 +425,13 @@ class Skeleton_Class extends CommonObject
|
|||||||
// ...
|
// ...
|
||||||
|
|
||||||
// Create clone
|
// Create clone
|
||||||
$result = $object->create( $user );
|
$result = $object->create($user);
|
||||||
|
|
||||||
// Other options
|
// Other options
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error ++;
|
||||||
$this->errors = $object->errors;
|
$this->errors = $object->errors;
|
||||||
dol_syslog( __METHOD__ . ' ' . join( ',', $this->errors ), LOG_ERR );
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// End
|
// End
|
||||||
|
|||||||
@ -366,7 +366,7 @@ class CMailFile
|
|||||||
*/
|
*/
|
||||||
function sendfile()
|
function sendfile()
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf,$db;
|
||||||
|
|
||||||
$errorlevel=error_reporting();
|
$errorlevel=error_reporting();
|
||||||
error_reporting($errorlevel ^ E_WARNING); // Desactive warnings
|
error_reporting($errorlevel ^ E_WARNING); // Desactive warnings
|
||||||
@ -375,6 +375,20 @@ class CMailFile
|
|||||||
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_ALL_MAILS))
|
if (empty($conf->global->MAIN_DISABLE_ALL_MAILS))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
dol_include_once('/core/class/hookmanager.class.php');
|
||||||
|
$hookmanager=new HookManager($db);
|
||||||
|
$hookmanager->initHooks(array('maildao'));
|
||||||
|
$reshook=$hookmanager->executeHooks('doactions',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if (!empty($reshook))
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->error="Error in hook maildao doactions ".$reshook;
|
||||||
|
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
|
||||||
|
|
||||||
|
return $reshook;
|
||||||
|
}
|
||||||
|
|
||||||
// Action according to choosed sending method
|
// Action according to choosed sending method
|
||||||
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail')
|
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail')
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3537,7 +3537,7 @@ class Form
|
|||||||
$ret.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
$ret.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
$ret.='<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
$ret.='<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
||||||
$ret.='<tr><td>';
|
$ret.='<tr><td>';
|
||||||
$ret.=$this->select_date($selected,$htmlname,$displayhour,$displaymin,1,'form'.$htmlname);
|
$ret.=$this->select_date($selected,$htmlname,$displayhour,$displaymin,1,'form'.$htmlname,1,0,1);
|
||||||
$ret.='</td>';
|
$ret.='</td>';
|
||||||
$ret.='<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
$ret.='<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
||||||
$ret.='</tr></table></form>';
|
$ret.='</tr></table></form>';
|
||||||
|
|||||||
@ -837,13 +837,13 @@ function unActivateModule($value, $requiredby=1)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO Cannot instantiate abstract class
|
// TODO Replace this afte DolibarrModules is moved as abstract class with a try catch to show module is bugged
|
||||||
//$genericMod = new DolibarrModul($db);
|
$genericMod = new DolibarrModules($db);
|
||||||
//$genericMod->name=preg_replace('/^mod/i','',$modName);
|
$genericMod->name=preg_replace('/^mod/i','',$modName);
|
||||||
//$genericMod->rights_class=strtolower(preg_replace('/^mod/i','',$modName));
|
$genericMod->rights_class=strtolower(preg_replace('/^mod/i','',$modName));
|
||||||
//$genericMod->const_name='MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',$modName));
|
$genericMod->const_name='MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',$modName));
|
||||||
dol_syslog("modules::unActivateModule Failed to find module file, we use generic function with name " . $modName);
|
dol_syslog("modules::unActivateModule Failed to find module file, we use generic function with name " . $modName);
|
||||||
//$genericMod->_remove();
|
$genericMod->_remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Desactivation des modules qui dependent de lui
|
// Desactivation des modules qui dependent de lui
|
||||||
|
|||||||
@ -257,6 +257,8 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
|||||||
global $conf,$langs,$db;
|
global $conf,$langs,$db;
|
||||||
global $bc;
|
global $bc;
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
|
||||||
|
|
||||||
$formother = new FormOther($db);
|
$formother = new FormOther($db);
|
||||||
|
|
||||||
//$dirthemes=array(empty($conf->global->MAIN_FORCETHEMEDIR)?'/theme':$conf->global->MAIN_FORCETHEMEDIR.'/theme');
|
//$dirthemes=array(empty($conf->global->MAIN_FORCETHEMEDIR)?'/theme':$conf->global->MAIN_FORCETHEMEDIR.'/theme');
|
||||||
|
|||||||
@ -199,7 +199,10 @@ abstract class DolibarrModules
|
|||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
*/
|
*/
|
||||||
abstract public function __construct($db);
|
//public function __construct($db);
|
||||||
|
// We should but can't set this as abstract because this will make dolibarr hang
|
||||||
|
// after migration due to old module not implementing. We must wait PHP is able to make
|
||||||
|
// a try catch on Fatal error to manage this correctly.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables a module.
|
* Enables a module.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user