Update menubase.class.php

This commit is contained in:
Frédéric FRANCE 2018-10-16 23:36:00 +02:00 committed by GitHub
parent 00dc78dd01
commit 70b6c502da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -59,15 +60,18 @@ class Menubase
public $fk_menu; public $fk_menu;
/** /**
* @var int ID * @var string fk_mainmenu
*/ */
public $fk_mainmenu; public $fk_mainmenu;
/** /**
* @var int ID * @var string fk_leftmenu
*/ */
public $fk_leftmenu; public $fk_leftmenu;
/**
* @var int position
*/
public $position; public $position;
public $url; public $url;
public $target; public $target;
@ -111,10 +115,10 @@ class Menubase
$this->type=trim($this->type); $this->type=trim($this->type);
$this->mainmenu=trim($this->mainmenu); $this->mainmenu=trim($this->mainmenu);
$this->leftmenu=trim($this->leftmenu); $this->leftmenu=trim($this->leftmenu);
$this->fk_menu=trim($this->fk_menu); // If -1, fk_mainmenu and fk_leftmenu must be defined $this->fk_menu = (int) $this->fk_menu; // If -1, fk_mainmenu and fk_leftmenu must be defined
$this->fk_mainmenu=trim($this->fk_mainmenu); $this->fk_mainmenu=trim($this->fk_mainmenu);
$this->fk_leftmenu=trim($this->fk_leftmenu); $this->fk_leftmenu=trim($this->fk_leftmenu);
$this->position=trim($this->position); $this->position = (int) $this->position;
$this->url=trim($this->url); $this->url=trim($this->url);
$this->target=trim($this->target); $this->target=trim($this->target);
$this->titre=trim($this->titre); $this->titre=trim($this->titre);
@ -155,7 +159,7 @@ class Menubase
$sql = "SELECT count(*)"; $sql = "SELECT count(*)";
$sql.= " FROM ".MAIN_DB_PREFIX."menu"; $sql.= " FROM ".MAIN_DB_PREFIX."menu";
$sql.= " WHERE menu_handler = '".$this->db->escape($this->menu_handler)."'"; $sql.= " WHERE menu_handler = '".$this->db->escape($this->menu_handler)."'";
$sql.= " AND fk_menu = ".((int) $this->db->escape($this->fk_menu)); $sql.= " AND fk_menu = ".((int) $this->fk_menu);
$sql.= " AND position = ".((int) $this->position); $sql.= " AND position = ".((int) $this->position);
$sql.= " AND url = '".$this->db->escape($this->url)."'"; $sql.= " AND url = '".$this->db->escape($this->url)."'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
@ -252,10 +256,10 @@ class Menubase
$this->type=trim($this->type); $this->type=trim($this->type);
$this->mainmenu=trim($this->mainmenu); $this->mainmenu=trim($this->mainmenu);
$this->leftmenu=trim($this->leftmenu); $this->leftmenu=trim($this->leftmenu);
$this->fk_menu=trim($this->fk_menu); $this->fk_menu = (int) $this->fk_menu;
$this->fk_mainmenu=trim($this->fk_mainmenu); $this->fk_mainmenu=trim($this->fk_mainmenu);
$this->fk_leftmenu=trim($this->fk_leftmenu); $this->fk_leftmenu=trim($this->fk_leftmenu);
$this->position=trim($this->position); $this->position = (int) $this->position;
$this->url=trim($this->url); $this->url=trim($this->url);
$this->target=trim($this->target); $this->target=trim($this->target);
$this->titre=trim($this->titre); $this->titre=trim($this->titre);
@ -274,7 +278,7 @@ class Menubase
$sql.= " type='".$this->db->escape($this->type)."',"; $sql.= " type='".$this->db->escape($this->type)."',";
$sql.= " mainmenu='".$this->db->escape($this->mainmenu)."',"; $sql.= " mainmenu='".$this->db->escape($this->mainmenu)."',";
$sql.= " leftmenu='".$this->db->escape($this->leftmenu)."',"; $sql.= " leftmenu='".$this->db->escape($this->leftmenu)."',";
$sql.= " fk_menu='".$this->db->escape($this->fk_menu)."',"; $sql.= " fk_menu=".$this->fk_menu.",";
$sql.= " fk_mainmenu=".($this->fk_mainmenu?"'".$this->db->escape($this->fk_mainmenu)."'":"null").","; $sql.= " fk_mainmenu=".($this->fk_mainmenu?"'".$this->db->escape($this->fk_mainmenu)."'":"null").",";
$sql.= " fk_leftmenu=".($this->fk_leftmenu?"'".$this->db->escape($this->fk_leftmenu)."'":"null").","; $sql.= " fk_leftmenu=".($this->fk_leftmenu?"'".$this->db->escape($this->fk_leftmenu)."'":"null").",";
$sql.= " position=".($this->position > 0 ? $this->position : 0).","; $sql.= " position=".($this->position > 0 ? $this->position : 0).",";