Debug v16

This commit is contained in:
Laurent Destailleur 2022-06-13 10:58:21 +02:00
parent 2b5b9957c3
commit e9d5ba5de3
2 changed files with 17 additions and 5 deletions

View File

@ -68,6 +68,19 @@ $hookmanager->initHooks(array('intracommcard', 'globalcard'));
$error = 0;
$permissiontoread = $user->rights->intracommreport->read;
$permissiontoadd = $user->rights->intracommreport->write;
$permissiontodelete = $user->rights->intracommreport->delete;
// Security check (enable the most restrictive one)
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
if (empty($conf->intracommreport->enabled)) accessforbidden();
if (!$permissiontoread) accessforbidden();
/*
* Actions
@ -80,7 +93,7 @@ if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if ($user->rights->intracommreport->delete && $action == 'confirm_delete' && $confirm == 'yes') {
if ($permissiontodelete && $action == 'confirm_delete' && $confirm == 'yes') {
$result = $object->delete($id, $user);
if ($result > 0) {
if (!empty($backtopage)) {
@ -95,7 +108,7 @@ if ($user->rights->intracommreport->delete && $action == 'confirm_delete' && $co
}
}
if ($action == 'add' && $user->rights->intracommreport->write) {
if ($action == 'add' && $permissiontoadd) {
$object->label = trim($label);
$object->type = trim($exporttype);
$object->type_declaration = $type_declaration;

View File

@ -124,7 +124,6 @@ class IntracommReport extends CommonObject
*/
public function getXML($mode = 'O', $type = 'introduction', $period_reference = '')
{
global $conf, $mysoc;
/**************Construction de quelques variables********************/
@ -437,7 +436,8 @@ class IntracommReport extends CommonObject
*/
public function getNextDeclarationNumber()
{
$resql = $this->db->query('SELECT MAX(numero_declaration) as max_declaration_number FROM '.MAIN_DB_PREFIX.$this->table_element." WHERE exporttype='".$this->db->escape($this->exporttype)."'");
$sql = 'SELECT MAX(numero_declaration) as max_declaration_number FROM '.MAIN_DB_PREFIX.$this->table_element." WHERE exporttype='".$this->db->escape($this->exporttype)."'";
$resql = $this->db->query($sql);
if ($resql) {
$res = $this->db->fetch_object($resql);
}
@ -463,7 +463,6 @@ class IntracommReport extends CommonObject
*/
public function generateXMLFile()
{
$name = $this->periode.'.xml';
$fname = sys_get_temp_dir().'/'.$name;
$f = fopen($fname, 'w+');