Cancel new feature add to get back a stable version for 2.6
This commit is contained in:
parent
a88dd655bc
commit
62971614d0
@ -146,8 +146,7 @@ class modMyModule extends DolibarrModules
|
||||
// 'position'=>100,
|
||||
// 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||
// 'target'=>'',
|
||||
// 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
|
||||
// 'constraint'=>'$conf->mymodule->enabled'); // Add constraint
|
||||
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
// $r++;
|
||||
//
|
||||
// Example to declare a Left Menu entry:
|
||||
|
||||
@ -182,35 +182,44 @@ if (isset($_GET["action"]) && $_GET["action"] == 'add')
|
||||
|
||||
if (isset($_GET["action"]) && $_GET["action"] == 'add_const')
|
||||
{
|
||||
$langs->load("errors");
|
||||
$menu = new Menubase($db);
|
||||
$result=$menu->addConstraint($_POST['menuId'], $_POST['constraint'], $_POST['type']);
|
||||
if ($result > 0)
|
||||
|
||||
if($_POST['type'] == 'prede')
|
||||
{
|
||||
$mesg='<div class="ok">'.$langs->trans("RecordModifiedSuccessfully").'</div>';
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."menu_const(fk_menu, fk_constraint) VALUES(".$_POST['menuId'].",".$_POST['constraint'].")";
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$menu->error.'</div>';
|
||||
|
||||
$sql = "SELECT max(rowid) as maxId FROM ".MAIN_DB_PREFIX."menu_constraint";
|
||||
$result = $db->query($sql);
|
||||
$objc = $db->fetch_object($result);
|
||||
$constraint = ($objc->maxId) + 1;
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."menu_constraint(rowid,action) VALUES(".$constraint.",'".$_POST['constraint']."')";
|
||||
$db->query($sql);
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."menu_const(fk_menu, fk_constraint) VALUES(".$_POST['menuId'].",".$constraint.")";
|
||||
}
|
||||
|
||||
$db->query($sql);
|
||||
|
||||
header("location:edit.php?action=edit&menuId=".$_POST['menuId']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_GET["action"]) && $_GET["action"] == 'del_const')
|
||||
{
|
||||
$langs->load("errors");
|
||||
$menu = new Menubase($db);
|
||||
$result=$menu->delConstraint($_GET['menuId'], $_GET['constId']);
|
||||
if ($result > 0)
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu_const WHERE fk_menu = ".$_GET['menuId']." AND fk_constraint = ".$_GET['constId'];
|
||||
$db->query($sql);
|
||||
|
||||
$sql = "SELECT count(rowid) as countId FROM ".MAIN_DB_PREFIX."menu_const WHERE fk_constraint = ".$_GET['constId'];
|
||||
$result = $db->query($sql);
|
||||
$objc = $db->fetch_object($result);
|
||||
if($objc->countId == 0)
|
||||
{
|
||||
$mesg='<div class="ok">'.$langs->trans("RecordModifiedSuccessfully").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$menu->error.'</div>';
|
||||
}
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu_constraint WHERE rowid = ".$_GET['constId'];
|
||||
$db->query($sql);
|
||||
}
|
||||
|
||||
header("location:edit.php?action=edit&menuId=".$_GET['menuId']);
|
||||
exit;
|
||||
@ -520,7 +529,7 @@ elseif (isset($_GET["action"]) && $_GET["action"] == 'edit')
|
||||
// Ajout de contraintes predefinis
|
||||
print '<form action="edit.php?action=add_const" method="post">';
|
||||
print '<input type="hidden" name="menuId" value="'.$_GET['menuId'].'">';
|
||||
print '<input type="hidden" name="type" value="predefined">';
|
||||
print '<input type="hidden" name="type" value="prede">';
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
@ -661,114 +660,6 @@ class Menubase
|
||||
|
||||
return $tabMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Add constraint menu
|
||||
* \param menuId Menu id
|
||||
* \param constraint Value or id for constraint
|
||||
* \param type type of constraint
|
||||
* \return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function addConstraint($menuId, $constraint, $type='')
|
||||
{
|
||||
if($type == 'predefined')
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."menu_const(fk_menu, fk_constraint) VALUES(".$menuId.",".$constraint.")";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."menu_constraint";
|
||||
$sql.= " WHERE action = '".$constraint."'";
|
||||
$resSql = $this->db->query($sql);
|
||||
if (! $resSql)
|
||||
{
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
dol_syslog("Menubase::addConstraint::4 ".$this->error, LOG_ERR);
|
||||
return -4;
|
||||
}
|
||||
$num = $this->db->num_rows($resSql);
|
||||
if ($num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resSql);
|
||||
$constraintId = $obj->rowid;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT max(rowid) as maxId FROM ".MAIN_DB_PREFIX."menu_constraint";
|
||||
$resultId = $this->db->query($sql);
|
||||
if (! $resultId)
|
||||
{
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
dol_syslog("Menubase::addConstraint::3 ".$this->error, LOG_ERR);
|
||||
return -3;
|
||||
}
|
||||
|
||||
$objc = $this->db->fetch_object($resultId);
|
||||
$constraintId = ($objc->maxId) + 1;
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."menu_constraint(rowid,action) VALUES(".$constraintId.",'".$constraint."')";
|
||||
$result = $this->db->query($sql);
|
||||
if (! $result)
|
||||
{
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
dol_syslog("Menubase::addConstraint::2 sql = ".$sql." ".$this->error, LOG_ERR);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."menu_const(fk_menu, fk_constraint) VALUES(".$menuId.",".$constraintId.")";
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if (! $result)
|
||||
{
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
dol_syslog("Menubase::addConstraint::1 sql = ".$sql." ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Delete constraint menu
|
||||
* \param menuId Menu id
|
||||
* \param constId Constraint id
|
||||
* \return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function delConstraint($menuId, $constId)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu_const WHERE fk_menu = ".$menuId." AND fk_constraint = ".$constId;
|
||||
$result = $this->db->query($sql);
|
||||
if (! $result)
|
||||
{
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
dol_syslog("Menubase::delConstraint::3 ".$this->error, LOG_ERR);
|
||||
return -3;
|
||||
}
|
||||
|
||||
$sql = "SELECT count(rowid) as countId FROM ".MAIN_DB_PREFIX."menu_const WHERE fk_constraint = ".$constId;
|
||||
$result = $this->db->query($sql);
|
||||
if (! $result)
|
||||
{
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
dol_syslog("Menubase::delConstraint::2 ".$this->error, LOG_ERR);
|
||||
return -2;
|
||||
}
|
||||
|
||||
$objc = $this->db->fetch_object($result);
|
||||
if($objc->countId == 0)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu_constraint WHERE rowid = ".$constId;
|
||||
$result = $this->db->query($sql);
|
||||
if (! $result)
|
||||
{
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
dol_syslog("Menubase::delConstraint::1 ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user