From 318d3ae71ae56a69710e03d37414712ad324f533 Mon Sep 17 00:00:00 2001 From: cdelambert Date: Mon, 30 Apr 2007 08:35:47 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20gestion=20des=20menus=20par?= =?UTF-8?q?=20table=20Modification=20des=20tables=20et=20ajout=20de=20donn?= =?UTF-8?q?=C3=A9es=20Ajout=20du=20th=C3=A8me=20Auguria=20utilisant=20le?= =?UTF-8?q?=20syst=C3=A8me=20de=20menus=20en=20base?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/menus/edit.php | 521 ++++++++ htdocs/admin/menus/images/arbre-deplier.png | Bin 0 -> 309 bytes htdocs/admin/menus/images/arbre-plier.png | Bin 0 -> 315 bytes htdocs/admin/menus/images/arbre-puce.png | Bin 0 -> 288 bytes htdocs/admin/menus/images/arbre-trait.png | Bin 0 -> 157 bytes htdocs/admin/menus/index.php | 375 ++++++ htdocs/admin/menus/menu.js | 171 +++ htdocs/admin/menus/module_menudb.php | 255 ++++ htdocs/admin/menus/pre.inc.php | 191 +++ .../menus/barre_left/auguria_backoffice.php | 229 ++++ .../menus/barre_left/auguria_frontoffice.php | 321 +++++ .../menus/barre_top/auguria_backoffice.php | 117 ++ .../menus/barre_top/auguria_frontoffice.php | 117 ++ htdocs/includes/modules/modMenuDb.class.php | 114 ++ htdocs/theme/auguria/.cvsignore | 1 + htdocs/theme/auguria/AUTHOR | 1 + htdocs/theme/auguria/auguria.css.php | 1142 +++++++++++++++++ htdocs/theme/auguria/fckeditor/fck_dialog.css | 132 ++ htdocs/theme/auguria/fckeditor/fck_editor.css | 467 +++++++ htdocs/theme/auguria/fckeditor/fck_strip.gif | Bin 0 -> 4578 bytes htdocs/theme/auguria/fckeditor/fckconfig.js | 260 ++++ .../theme/auguria/fckeditor/images/.cvsignore | 2 + .../fckeditor/images/toolbar.arrowright.gif | Bin 0 -> 53 bytes .../fckeditor/images/toolbar.buttonarrow.gif | Bin 0 -> 46 bytes .../fckeditor/images/toolbar.buttonbg.gif | Bin 0 -> 829 bytes .../fckeditor/images/toolbar.collapse.gif | Bin 0 -> 152 bytes .../auguria/fckeditor/images/toolbar.end.gif | Bin 0 -> 43 bytes .../fckeditor/images/toolbar.expand.gif | Bin 0 -> 152 bytes .../fckeditor/images/toolbar.separator.gif | Bin 0 -> 58 bytes .../fckeditor/images/toolbar.start.gif | Bin 0 -> 105 bytes htdocs/theme/auguria/graph-color.php | 36 + htdocs/theme/auguria/img/.cvsignore | 1 + htdocs/theme/auguria/img/1downarrow.png | Bin 0 -> 1021 bytes htdocs/theme/auguria/img/1leftarrow.png | Bin 0 -> 1026 bytes htdocs/theme/auguria/img/1rightarrow.png | Bin 0 -> 1026 bytes htdocs/theme/auguria/img/1uparrow.png | Bin 0 -> 1021 bytes htdocs/theme/auguria/img/2.png | Bin 0 -> 3156 bytes htdocs/theme/auguria/img/addfile.png | Bin 0 -> 827 bytes htdocs/theme/auguria/img/bg-bas-rubrique.png | Bin 0 -> 355 bytes htdocs/theme/auguria/img/bg-rubrique.png | Bin 0 -> 153 bytes .../theme/auguria/img/bg-titre-rubrique.png | Bin 0 -> 474 bytes .../auguria/img/bouton/menu_l_title_bg.png | Bin 0 -> 147 bytes .../auguria/img/bouton/round_black_tr.png | Bin 0 -> 1080 bytes htdocs/theme/auguria/img/button_bg.png | Bin 0 -> 199 bytes htdocs/theme/auguria/img/button_edit.png | Bin 0 -> 1076 bytes htdocs/theme/auguria/img/calendar.png | Bin 0 -> 308 bytes htdocs/theme/auguria/img/call.png | Bin 0 -> 336 bytes htdocs/theme/auguria/img/call_out.png | Bin 0 -> 398 bytes htdocs/theme/auguria/img/delete.png | Bin 0 -> 1068 bytes htdocs/theme/auguria/img/disable.png | Bin 0 -> 1002 bytes htdocs/theme/auguria/img/edit.png | Bin 0 -> 1199 bytes htdocs/theme/auguria/img/edit_add.png | Bin 0 -> 232 bytes htdocs/theme/auguria/img/edit_remove.png | Bin 0 -> 931 bytes htdocs/theme/auguria/img/editdelete.png | Bin 0 -> 1002 bytes htdocs/theme/auguria/img/error.png | Bin 0 -> 669 bytes htdocs/theme/auguria/img/file.png | Bin 0 -> 1033 bytes htdocs/theme/auguria/img/filenew.png | Bin 0 -> 1066 bytes htdocs/theme/auguria/img/filter.png | Bin 0 -> 253 bytes htdocs/theme/auguria/img/folder-open.png | Bin 0 -> 814 bytes htdocs/theme/auguria/img/folder.png | Bin 0 -> 736 bytes htdocs/theme/auguria/img/help.png | Bin 0 -> 1161 bytes htdocs/theme/auguria/img/high.png | Bin 0 -> 669 bytes htdocs/theme/auguria/img/history.png | Bin 0 -> 1640 bytes htdocs/theme/auguria/img/info.png | Bin 0 -> 1161 bytes htdocs/theme/auguria/img/liste_menu.gif | Bin 0 -> 54 bytes htdocs/theme/auguria/img/liste_titre.png | Bin 0 -> 220 bytes htdocs/theme/auguria/img/lock.png | Bin 0 -> 719 bytes htdocs/theme/auguria/img/login_background.png | Bin 0 -> 229 bytes htdocs/theme/auguria/img/login_logo.png | Bin 0 -> 3211 bytes htdocs/theme/auguria/img/logout.png | Bin 0 -> 1046 bytes htdocs/theme/auguria/img/nav.jpg | Bin 0 -> 329 bytes htdocs/theme/auguria/img/next.png | Bin 0 -> 1186 bytes htdocs/theme/auguria/img/object_account.png | Bin 0 -> 470 bytes htdocs/theme/auguria/img/object_action.png | Bin 0 -> 1094 bytes htdocs/theme/auguria/img/object_barcode.png | Bin 0 -> 974 bytes htdocs/theme/auguria/img/object_bill.png | Bin 0 -> 1021 bytes htdocs/theme/auguria/img/object_billa.png | Bin 0 -> 1024 bytes htdocs/theme/auguria/img/object_billr.png | Bin 0 -> 1026 bytes htdocs/theme/auguria/img/object_book.png | Bin 0 -> 426 bytes htdocs/theme/auguria/img/object_bookmark.png | Bin 0 -> 307 bytes htdocs/theme/auguria/img/object_calendar.png | Bin 0 -> 266 bytes .../theme/auguria/img/object_commercial.png | Bin 0 -> 1032 bytes htdocs/theme/auguria/img/object_company.png | Bin 0 -> 492 bytes htdocs/theme/auguria/img/object_contact.png | Bin 0 -> 1124 bytes .../theme/auguria/img/object_contact_all.png | Bin 0 -> 1248 bytes htdocs/theme/auguria/img/object_contract.png | Bin 0 -> 1010 bytes htdocs/theme/auguria/img/object_email.png | Bin 0 -> 1063 bytes htdocs/theme/auguria/img/object_energie.png | Bin 0 -> 376 bytes htdocs/theme/auguria/img/object_generic.png | Bin 0 -> 1009 bytes htdocs/theme/auguria/img/object_group.png | Bin 0 -> 863 bytes .../theme/auguria/img/object_intervention.png | Bin 0 -> 340 bytes htdocs/theme/auguria/img/object_order.png | Bin 0 -> 1011 bytes htdocs/theme/auguria/img/object_payment.png | Bin 0 -> 455 bytes htdocs/theme/auguria/img/object_phoning.png | Bin 0 -> 1032 bytes htdocs/theme/auguria/img/object_product.png | Bin 0 -> 1045 bytes htdocs/theme/auguria/img/object_project.png | Bin 0 -> 736 bytes htdocs/theme/auguria/img/object_propal.png | Bin 0 -> 342 bytes htdocs/theme/auguria/img/object_reduc.png | Bin 0 -> 1009 bytes htdocs/theme/auguria/img/object_rss.png | Bin 0 -> 578 bytes htdocs/theme/auguria/img/object_sending.png | Bin 0 -> 340 bytes htdocs/theme/auguria/img/object_service.png | Bin 0 -> 1040 bytes htdocs/theme/auguria/img/object_stock.png | Bin 0 -> 1070 bytes htdocs/theme/auguria/img/object_task.png | Bin 0 -> 1048 bytes htdocs/theme/auguria/img/object_trip.png | Bin 0 -> 337 bytes htdocs/theme/auguria/img/object_user.png | Bin 0 -> 1145 bytes htdocs/theme/auguria/img/pdf.png | Bin 0 -> 744 bytes htdocs/theme/auguria/img/previous.png | Bin 0 -> 1182 bytes htdocs/theme/auguria/img/puce.png | Bin 0 -> 1187 bytes htdocs/theme/auguria/img/recent.png | Bin 0 -> 1073 bytes htdocs/theme/auguria/img/refresh.png | Bin 0 -> 802 bytes htdocs/theme/auguria/img/reload.png | Bin 0 -> 1205 bytes htdocs/theme/auguria/img/search.png | Bin 0 -> 1017 bytes htdocs/theme/auguria/img/searchclear.png | Bin 0 -> 1021 bytes htdocs/theme/auguria/img/setup.png | Bin 0 -> 405 bytes htdocs/theme/auguria/img/star.png | Bin 0 -> 1068 bytes htdocs/theme/auguria/img/statut0.png | Bin 0 -> 200 bytes htdocs/theme/auguria/img/statut1.png | Bin 0 -> 201 bytes htdocs/theme/auguria/img/statut2.png | Bin 0 -> 191 bytes htdocs/theme/auguria/img/statut3.png | Bin 0 -> 242 bytes htdocs/theme/auguria/img/statut4.png | Bin 0 -> 201 bytes htdocs/theme/auguria/img/statut5.png | Bin 0 -> 203 bytes htdocs/theme/auguria/img/statut6.png | Bin 0 -> 251 bytes htdocs/theme/auguria/img/statut7.png | Bin 0 -> 215 bytes htdocs/theme/auguria/img/stcomm-1.png | Bin 0 -> 763 bytes htdocs/theme/auguria/img/stcomm0.png | Bin 0 -> 843 bytes htdocs/theme/auguria/img/stcomm1.png | Bin 0 -> 890 bytes htdocs/theme/auguria/img/stcomm2.png | Bin 0 -> 657 bytes htdocs/theme/auguria/img/stcomm3.png | Bin 0 -> 932 bytes htdocs/theme/auguria/img/stcomm4.png | Bin 0 -> 928 bytes htdocs/theme/auguria/img/test.gif | Bin 0 -> 813 bytes htdocs/theme/auguria/img/tick.png | Bin 0 -> 980 bytes htdocs/theme/auguria/img/tmenu.jpg | Bin 0 -> 640 bytes htdocs/theme/auguria/img/tmenu_inverse.jpg | Bin 0 -> 646 bytes htdocs/theme/auguria/img/transparent.png | Bin 0 -> 128 bytes htdocs/theme/auguria/img/unlock.png | Bin 0 -> 761 bytes htdocs/theme/auguria/img/uparrow.png | Bin 0 -> 237 bytes htdocs/theme/auguria/img/warning.png | Bin 0 -> 618 bytes htdocs/theme/auguria/thumb.png | Bin 0 -> 2520 bytes 138 files changed, 4453 insertions(+) create mode 100644 htdocs/admin/menus/edit.php create mode 100644 htdocs/admin/menus/images/arbre-deplier.png create mode 100644 htdocs/admin/menus/images/arbre-plier.png create mode 100644 htdocs/admin/menus/images/arbre-puce.png create mode 100644 htdocs/admin/menus/images/arbre-trait.png create mode 100644 htdocs/admin/menus/index.php create mode 100644 htdocs/admin/menus/menu.js create mode 100644 htdocs/admin/menus/module_menudb.php create mode 100644 htdocs/admin/menus/pre.inc.php create mode 100644 htdocs/includes/menus/barre_left/auguria_backoffice.php create mode 100644 htdocs/includes/menus/barre_left/auguria_frontoffice.php create mode 100644 htdocs/includes/menus/barre_top/auguria_backoffice.php create mode 100644 htdocs/includes/menus/barre_top/auguria_frontoffice.php create mode 100644 htdocs/includes/modules/modMenuDb.class.php create mode 100644 htdocs/theme/auguria/.cvsignore create mode 100644 htdocs/theme/auguria/AUTHOR create mode 100644 htdocs/theme/auguria/auguria.css.php create mode 100644 htdocs/theme/auguria/fckeditor/fck_dialog.css create mode 100644 htdocs/theme/auguria/fckeditor/fck_editor.css create mode 100644 htdocs/theme/auguria/fckeditor/fck_strip.gif create mode 100644 htdocs/theme/auguria/fckeditor/fckconfig.js create mode 100644 htdocs/theme/auguria/fckeditor/images/.cvsignore create mode 100644 htdocs/theme/auguria/fckeditor/images/toolbar.arrowright.gif create mode 100644 htdocs/theme/auguria/fckeditor/images/toolbar.buttonarrow.gif create mode 100644 htdocs/theme/auguria/fckeditor/images/toolbar.buttonbg.gif create mode 100644 htdocs/theme/auguria/fckeditor/images/toolbar.collapse.gif create mode 100644 htdocs/theme/auguria/fckeditor/images/toolbar.end.gif create mode 100644 htdocs/theme/auguria/fckeditor/images/toolbar.expand.gif create mode 100644 htdocs/theme/auguria/fckeditor/images/toolbar.separator.gif create mode 100644 htdocs/theme/auguria/fckeditor/images/toolbar.start.gif create mode 100755 htdocs/theme/auguria/graph-color.php create mode 100644 htdocs/theme/auguria/img/.cvsignore create mode 100644 htdocs/theme/auguria/img/1downarrow.png create mode 100644 htdocs/theme/auguria/img/1leftarrow.png create mode 100644 htdocs/theme/auguria/img/1rightarrow.png create mode 100644 htdocs/theme/auguria/img/1uparrow.png create mode 100755 htdocs/theme/auguria/img/2.png create mode 100644 htdocs/theme/auguria/img/addfile.png create mode 100644 htdocs/theme/auguria/img/bg-bas-rubrique.png create mode 100644 htdocs/theme/auguria/img/bg-rubrique.png create mode 100644 htdocs/theme/auguria/img/bg-titre-rubrique.png create mode 100644 htdocs/theme/auguria/img/bouton/menu_l_title_bg.png create mode 100644 htdocs/theme/auguria/img/bouton/round_black_tr.png create mode 100644 htdocs/theme/auguria/img/button_bg.png create mode 100644 htdocs/theme/auguria/img/button_edit.png create mode 100644 htdocs/theme/auguria/img/calendar.png create mode 100644 htdocs/theme/auguria/img/call.png create mode 100644 htdocs/theme/auguria/img/call_out.png create mode 100644 htdocs/theme/auguria/img/delete.png create mode 100644 htdocs/theme/auguria/img/disable.png create mode 100644 htdocs/theme/auguria/img/edit.png create mode 100755 htdocs/theme/auguria/img/edit_add.png create mode 100755 htdocs/theme/auguria/img/edit_remove.png create mode 100644 htdocs/theme/auguria/img/editdelete.png create mode 100644 htdocs/theme/auguria/img/error.png create mode 100644 htdocs/theme/auguria/img/file.png create mode 100644 htdocs/theme/auguria/img/filenew.png create mode 100644 htdocs/theme/auguria/img/filter.png create mode 100644 htdocs/theme/auguria/img/folder-open.png create mode 100644 htdocs/theme/auguria/img/folder.png create mode 100644 htdocs/theme/auguria/img/help.png create mode 100644 htdocs/theme/auguria/img/high.png create mode 100644 htdocs/theme/auguria/img/history.png create mode 100644 htdocs/theme/auguria/img/info.png create mode 100644 htdocs/theme/auguria/img/liste_menu.gif create mode 100644 htdocs/theme/auguria/img/liste_titre.png create mode 100644 htdocs/theme/auguria/img/lock.png create mode 100644 htdocs/theme/auguria/img/login_background.png create mode 100644 htdocs/theme/auguria/img/login_logo.png create mode 100644 htdocs/theme/auguria/img/logout.png create mode 100644 htdocs/theme/auguria/img/nav.jpg create mode 100644 htdocs/theme/auguria/img/next.png create mode 100644 htdocs/theme/auguria/img/object_account.png create mode 100644 htdocs/theme/auguria/img/object_action.png create mode 100644 htdocs/theme/auguria/img/object_barcode.png create mode 100755 htdocs/theme/auguria/img/object_bill.png create mode 100644 htdocs/theme/auguria/img/object_billa.png create mode 100644 htdocs/theme/auguria/img/object_billr.png create mode 100755 htdocs/theme/auguria/img/object_book.png create mode 100644 htdocs/theme/auguria/img/object_bookmark.png create mode 100644 htdocs/theme/auguria/img/object_calendar.png create mode 100644 htdocs/theme/auguria/img/object_commercial.png create mode 100755 htdocs/theme/auguria/img/object_company.png create mode 100755 htdocs/theme/auguria/img/object_contact.png create mode 100644 htdocs/theme/auguria/img/object_contact_all.png create mode 100755 htdocs/theme/auguria/img/object_contract.png create mode 100644 htdocs/theme/auguria/img/object_email.png create mode 100644 htdocs/theme/auguria/img/object_energie.png create mode 100644 htdocs/theme/auguria/img/object_generic.png create mode 100644 htdocs/theme/auguria/img/object_group.png create mode 100644 htdocs/theme/auguria/img/object_intervention.png create mode 100755 htdocs/theme/auguria/img/object_order.png create mode 100644 htdocs/theme/auguria/img/object_payment.png create mode 100644 htdocs/theme/auguria/img/object_phoning.png create mode 100755 htdocs/theme/auguria/img/object_product.png create mode 100644 htdocs/theme/auguria/img/object_project.png create mode 100755 htdocs/theme/auguria/img/object_propal.png create mode 100644 htdocs/theme/auguria/img/object_reduc.png create mode 100644 htdocs/theme/auguria/img/object_rss.png create mode 100644 htdocs/theme/auguria/img/object_sending.png create mode 100644 htdocs/theme/auguria/img/object_service.png create mode 100644 htdocs/theme/auguria/img/object_stock.png create mode 100644 htdocs/theme/auguria/img/object_task.png create mode 100644 htdocs/theme/auguria/img/object_trip.png create mode 100644 htdocs/theme/auguria/img/object_user.png create mode 100644 htdocs/theme/auguria/img/pdf.png create mode 100644 htdocs/theme/auguria/img/previous.png create mode 100644 htdocs/theme/auguria/img/puce.png create mode 100644 htdocs/theme/auguria/img/recent.png create mode 100644 htdocs/theme/auguria/img/refresh.png create mode 100644 htdocs/theme/auguria/img/reload.png create mode 100644 htdocs/theme/auguria/img/search.png create mode 100644 htdocs/theme/auguria/img/searchclear.png create mode 100644 htdocs/theme/auguria/img/setup.png create mode 100644 htdocs/theme/auguria/img/star.png create mode 100644 htdocs/theme/auguria/img/statut0.png create mode 100644 htdocs/theme/auguria/img/statut1.png create mode 100644 htdocs/theme/auguria/img/statut2.png create mode 100644 htdocs/theme/auguria/img/statut3.png create mode 100644 htdocs/theme/auguria/img/statut4.png create mode 100644 htdocs/theme/auguria/img/statut5.png create mode 100644 htdocs/theme/auguria/img/statut6.png create mode 100644 htdocs/theme/auguria/img/statut7.png create mode 100644 htdocs/theme/auguria/img/stcomm-1.png create mode 100644 htdocs/theme/auguria/img/stcomm0.png create mode 100644 htdocs/theme/auguria/img/stcomm1.png create mode 100644 htdocs/theme/auguria/img/stcomm2.png create mode 100644 htdocs/theme/auguria/img/stcomm3.png create mode 100644 htdocs/theme/auguria/img/stcomm4.png create mode 100755 htdocs/theme/auguria/img/test.gif create mode 100644 htdocs/theme/auguria/img/tick.png create mode 100644 htdocs/theme/auguria/img/tmenu.jpg create mode 100644 htdocs/theme/auguria/img/tmenu_inverse.jpg create mode 100644 htdocs/theme/auguria/img/transparent.png create mode 100644 htdocs/theme/auguria/img/unlock.png create mode 100644 htdocs/theme/auguria/img/uparrow.png create mode 100644 htdocs/theme/auguria/img/warning.png create mode 100644 htdocs/theme/auguria/thumb.png diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php new file mode 100644 index 00000000000..c4d5026ed4a --- /dev/null +++ b/htdocs/admin/menus/edit.php @@ -0,0 +1,521 @@ + + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/admin/menus/edit.php + \ingroup admin + \brief Edition des menus + \version $Revision$ +*/ + + + require("./pre.inc.php"); + + + + if (!$user->admin) + accessforbidden(); + + + + +if (isset($_GET["action"]) && $_GET["action"] == 'update') +{ + + + if(!$_POST['cancel']) + { + + $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m SET m.titre = '".$_POST['titre']."', m.leftmenu = '".$_POST['leftmenu']."', m.url = '".$_POST['url']."', m.langs = '".$_POST['langs']."', m.right = '".$_POST['right']."',m.target = '".$_POST['target']."', m.user = ".$_POST['user']." WHERE m.rowid = ".$_POST['menuId']; + $db->query($sql); + } + + if($_GET['return']) + { + header("location: index.php"); + } + else + { + header("location: edit.php?action=edit&menuId=".$_POST['menuId']); + } + + +} + +if (isset($_GET["action"]) && $_GET["action"] == 'add') +{ + + if($_POST['cancel']) + { + header("location:index.php"); + } + else + { + + if($_POST['level'] == -1) + { + $sql = "SELECT max(m.rowid) as maxId FROM ".MAIN_DB_PREFIX."menu as m WHERE m.level = ".$_POST['level']; + $result = $db->query($sql); + $lastMenu = $db->fetch_object($result); + $rowid = $lastMenu->maxId + 1; + + $sql = "SELECT max(m.order) as maxOrder FROM ".MAIN_DB_PREFIX."menu as m WHERE m.level = ".$_POST['level']; + $result = $db->query($sql); + $lastMenu = $db->fetch_object($result); + $order = $lastMenu->maxOrder + 1; + + } + elseif($_POST['level'] == 0) + { + + $sql = "SELECT max(m.rowid) as maxId FROM ".MAIN_DB_PREFIX."menu as m WHERE m.level = ".$_POST['level']; + $result = $db->query($sql); + $lastMenu = $db->fetch_object($result); + + $rowid = $lastMenu->maxId + 100 ; + + $sql = "SELECT max(m.order) as maxOrder FROM ".MAIN_DB_PREFIX."menu as m WHERE m.fk_menu = ".$_GET['menuId']; + $result = $db->query($sql); + $lastMenu = $db->fetch_object($result); + if(isset($lastMenu->maxOrder)) + { + $order = ($lastMenu->maxOrder) + 1; + } + else + { + $order = 0; + } + + } + elseif($_POST['level'] > 0) + { + + $parentId = round($_GET['menuId'] / 100); + + $sql = "SELECT max(m.rowid) as maxId FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid LIKE '".$parentId."__' AND m.rowid <> '".$parentId."00'"; + $result = $db->query($sql); + $lastMenu = $db->fetch_object($result); + + if(isset($lastMenu->maxId)) + { + $rowid = ($lastMenu->maxId) + 1; + } + else + { + $rowid = ($parentId * 100) + 1; + } + + $sql = "SELECT max(m.order) as maxOrder FROM ".MAIN_DB_PREFIX."menu as m WHERE m.fk_menu = ".$_GET['menuId']; + $result = $db->query($sql); + $lastMenu = $db->fetch_object($result); + if(isset($lastMenu->maxOrder)) + { + $order = ($lastMenu->maxOrder) + 1; + } + else + { + $order = 0; + } + + } + + + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."menu VALUES($rowid, '".$_POST['mainmenu']."','".$_POST['leftmenu']."',".$_GET['menuId'].",'".$_POST['url']."','".$_POST['titre']."',".$_POST['level'].",'".$_POST['langs']."','".$_POST['right']."','',".$_POST['user'].",".$order.")"; + $db->query($sql); + + header("location: edit.php?action=edit&menuId=".$rowid); + } +} + + +if (isset($_GET["action"]) && $_GET["action"] == 'add_const') +{ + + if($_POST['type'] == 'prede') + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."menu_const(fk_menu, fk_constraint, user) VALUES(".$_POST['menuId'].",".$_POST['constraint'].",".$_POST['user'].")"; + } + else + { + + $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, user) VALUES(".$_POST['menuId'].",".$constraint.",".$_POST['user'].")"; + } + + $db->query($sql); + + header("location:edit.php?action=edit&menuId=".$_POST['menuId']); + +} + +if (isset($_GET["action"]) && $_GET["action"] == 'del_const') +{ + $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) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu_constraint WHERE rowid = ".$_GET['constId']; + $db->query($sql); + } + + header("location:edit.php?action=edit&menuId=".$_GET['menuId']); +} + + + +if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') +{ + + + $sql = "SELECT c.rowid, c.fk_constraint FROM ".MAIN_DB_PREFIX."menu_const as c WHERE c.fk_menu = ".$_GET['menuId']; + $res = $db->query($sql); + if ($res) + { + + while ($obj = $db->fetch_object ($res)) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu_const WHERE rowid = ".$obj->rowid; + $db->query($sql); + + $sql = "SELECT count(rowid) as countId FROM ".MAIN_DB_PREFIX."menu_const WHERE fk_constraint = ".$obj->fk_constraint; + $result = $db->query($sql); + $objc = $db->fetch_object($result); + + if($objc->countId == 0) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu_constraint WHERE rowid = ".$obj->fk_constraint; + $db->query($sql); + } + } + + + + } +; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".$_GET['menuId']; + $db->query($sql); + + if ($result == 0) + { + llxHeader(); + print '
'.$langs->trans("MenuDeleted").'
'; + llxFooter(); + exit ; + } + else + { + $reload = 0; + $_GET["action"]=''; + } +} + + + +/* + * Affichage page + */ + +llxHeader(); + + + +if (isset($_GET["action"]) && $_GET["action"] == 'create') +{ + print_titre($langs->trans("NewMenu"),'','setup'); + + print '
'; + + print ''; + + if($_GET['menuId'] == 0) + { + $parent_rowid = $_GET['menuId']; + $parent_level = -2; + } + else + { + $sql = "SELECT m.rowid, m.mainmenu, m.level, m.langs FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".$_GET['menuId']; + $res = $db->query($sql); + + if ($res) + { + + while ($menu = $db->fetch_array ($res)) + { + $parent_rowid = $menu['rowid']; + $parent_mainmenu = $menu['mainmenu']; + $parent_langs = $menu['langs']; + $parent_level = $menu['level']; + } + } + } + //Titre + print ''; + //Mainmenu + print ''; + //Level + print ''; + //URL + print ''; + //Leftmenu + print ''; + //Langs + print ''; + //Right + print ''; + //User + print ''; + print ''; + print ''; + // target + print ''; + print ''; + + print '
'.$langs->trans('Titre').''.$langs->trans('DetailTitre').'
'.$langs->trans('Mainmenu').''.$langs->trans('DetailMainmenu').'
'.$langs->trans('URL').''.$langs->trans('DetailUrl').'
'.$langs->trans('Leftmenu').''.$langs->trans('DetailLeftmenu').'
'.$langs->trans('Langs').''.$langs->trans('DetailLangs').'
'.$langs->trans('Right').''.$langs->trans('DetailRight').'
'.$langs->trans('User').''.$langs->trans('DetailUser').'
'.$langs->trans('Target').''.$langs->trans('DetailTarget').'
'; + print ' '; + print '
'; + + + + + + + + + print '
'; + + +} + +elseif (isset($_GET["action"]) && $_GET["action"] == 'edit') +{ + print_titre($langs->trans("ModifMenu"),'','setup'); + + print '
'; + + print ''; + + + $sql = "SELECT m.rowid, m.titre, m.mainmenu, m.leftmenu, m.fk_menu, m.url, m.langs, m.level, m.right, m.target, m.user, m.order FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".$_GET['menuId']; + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows(); + $i = 0; + + while($i < $num) + { + $menu = $db->fetch_object($result); + + + // rowid + print ''; + print ''; + // titre + print ''; + // mainmenu + print ''; + // Niveau + print ''; + // url + print ''; + // Leftmenu + print ''; + // langs + print ''; + // right + print ''; + // user + print ''; + // target + print ''; + + // Bouton + print ''; + + $i++; + } + } + + print ''; + + /* + * Lignes de contraintes + */ + $sql = 'SELECT c.rowid, c.action, mc.user '; + $sql.= 'FROM '.MAIN_DB_PREFIX.'menu_constraint as c, '.MAIN_DB_PREFIX.'menu_const as mc '; + $sql.= 'WHERE c.rowid = mc.fk_constraint '; + $sql.= 'AND mc.fk_menu = '.$_GET['menuId']; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + print '
'.$langs->trans('rowid').''.$menu->rowid.''.$langs->trans('DetailId').'
'.$langs->trans('Titre').''.$langs->trans('DetailTitre').'
'.$langs->trans('Mainmenu').''.$langs->trans('DetailMainmenu').'
'.$langs->trans('Level').''.$menu->level.''.$langs->trans('DetailLevel').'
'.$langs->trans('URL').''.$langs->trans('DetailUrl').'
'.$langs->trans('Leftmenu').''.$langs->trans('DetailLeftmenu').'
'.$langs->trans('Langs').''.$langs->trans('DetailLangs').'
'.$langs->trans('Right').''.$langs->trans('DetailRight').'
'.$langs->trans('User').''.$langs->trans('DetailUser').'
'.$langs->trans('Target').''.$langs->trans('DetailTarget').'
'; + print ' '; + print '
'; + if ($num) + { + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + $var=true; + + $var = true; + while ($i < $num) + { + $objc = $db->fetch_object($resql); + + $var = !$var; + print ''; + print ''; + print ''; + print ''; + + $i++; + } + + print ''; + print ''; + print ''; + print ''; + print "\n"; + + + // Ajout de contraintes personalisés + print ''; + print ''; + print ''; + + $var=true; + print ''; + print ' '; + print ''; + print ''; + print ''; + print ''; + + + // Ajout de contraintes prédéfinis + print ''; + print ''; + print ''; + + $var=!$var; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + + print '
'.$langs->trans('Constraint').''.$langs->trans('User').' 
'.$objc->action.''; + + switch ($objc->user) + { + case 0: print 'Interne'; + break; + case 1: print 'Externe'; + break; + case 2: print 'Tous'; + break; + } + print ''.img_delete().'
'.$langs->trans('Constraint').''.$langs->trans('User').' 
'; + print '
'; + print ''; + print ''; + print '
'; + $db->free($resql); + } + + + print ''; + + + + print '
'; + + print ''.$langs->trans('Valid').''; + print ''.$langs->trans('Supprimer').''; + print '
'; + + +} + + + + + +?> diff --git a/htdocs/admin/menus/images/arbre-deplier.png b/htdocs/admin/menus/images/arbre-deplier.png new file mode 100644 index 0000000000000000000000000000000000000000..31fcf9beee667f59aff91dd10c6eb70b31b3d097 GIT binary patch literal 309 zcmeAS@N?(olHy`uVBq!ia0vp@Ak4uAB#T}@sR2@KN#5=*48K7zG%|M@P=vF!y3en*`A$Gj*&+lnVMHu!msC=%n`_JN~x$??F2czHn z{xj)Veq-U(>|mI=tpxRt!zVs)qCW?lcscMjWk zqzn1J-DIKs;wxinMevNvFVAE*Wv!L}yH{TLybP0l+XkKqL6tA literal 0 HcmV?d00001 diff --git a/htdocs/admin/menus/images/arbre-plier.png b/htdocs/admin/menus/images/arbre-plier.png new file mode 100644 index 0000000000000000000000000000000000000000..88836226b9cdb41c3f242b6e78c4b9eae0ae87b1 GIT binary patch literal 315 zcmeAS@N?(olHy`uVBq!ia0vp@Ak4uAB#T}@sR2@KN#5=*48K57?vGqMP=vFLSeJX-ncF?T zGI*bGGMco(ef3160!(~B>4HuEh+`9n{OFEO@!mvaAm z$nJBjkvGo%H;((iKKN~e8bdp0{M+9epKVHBe_<-Wy|ba|&H9a~CUd*1y&r8%B+Y1{((iNVv=&t;uc GLK6UwVSUyB literal 0 HcmV?d00001 diff --git a/htdocs/admin/menus/images/arbre-puce.png b/htdocs/admin/menus/images/arbre-puce.png new file mode 100644 index 0000000000000000000000000000000000000000..90b2120f9e859649b7d19fca630fb31f2d8d18a0 GIT binary patch literal 288 zcmeAS@N?(olHy`uVBq!ia0vp@Ak4uAB#T}@sR2@KN#5=*48K57?vGqMP=vFd}**IW)fVV#PcYA&yO5_ z8wo~9Ii75`6WP7%7i%n2b>Eh|J40jXgbp7c<45L~!zS$9>+`l|^RmD%&X)~0&UY2} zE!^-o=X^r#<&cXL95nmiE&snL=r!l9TeD3}Lw@J=gmdKI;Vst0A!)^mS#w#=^mEBydEu sz!NAW;OXKR!f`!0BcZ{OjZMXj!BK*h@%-l<>_9mNPgg&ebxsLQ0J1nA$N&HU literal 0 HcmV?d00001 diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php new file mode 100644 index 00000000000..f1a5a7920c6 --- /dev/null +++ b/htdocs/admin/menus/index.php @@ -0,0 +1,375 @@ + + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/admin/menus/index.php + \ingroup admin + \brief Gestion des menus + \version $Revision$ +*/ + + + require("./pre.inc.php"); + + + + if (!$user->rights->menudb->creer) + accessforbidden(); + + +if (isset($_GET["action"]) && $_GET["action"] == 'up') +{ + + $sql = "SELECT m.rowid, m.order FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".$_GET["menuId"]; + $result = $db->query($sql); + + $num = $db->num_rows(); + $i = 0; + + while($i < $num) + { + $obj = $db->fetch_object($result); + $precedent['rowid'] = $obj->rowid; + $precedent['order'] = $obj->order; + $i++; + } + + $sql = "SELECT m.rowid, m.order FROM ".MAIN_DB_PREFIX."menu as m WHERE m.order = ".($precedent['order'] - 1)." AND m.level = -1"; + $result = $db->query($sql); + + $num = $db->num_rows(); + $i = 0; + + while($i < $num) + { + $obj = $db->fetch_object($result); + $suivant['rowid'] = $obj->rowid; + $suivant['order'] = $obj->order; + $i++; + } + + $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m SET m.order = ".$suivant['order']." WHERE m.rowid = ".$precedent['rowid'].""; // Monte celui select + $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m SET m.order = ".$precedent['order']." WHERE m.rowid = ".$suivant['rowid'].""; // Descend celui du dessus + $db->query($sql); +} + +if (isset($_GET["action"]) && $_GET["action"] == 'down') +{ + + $sql = "SELECT m.rowid, m.order FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".$_GET["menuId"]; + $result = $db->query($sql); + + $num = $db->num_rows(); + $i = 0; + + while($i < $num) + { + $obj = $db->fetch_object($result); + $precedent['rowid'] = $obj->rowid; + $precedent['order'] = $obj->order; + $i++; + } + + $sql = "SELECT m.rowid, m.order FROM ".MAIN_DB_PREFIX."menu as m WHERE m.order = ".($precedent['order'] + 1)." AND m.level = -1"; + $result = $db->query($sql); + + $num = $db->num_rows(); + $i = 0; + + while($i < $num) + { + $obj = $db->fetch_object($result); + $suivant['rowid'] = $obj->rowid; + $suivant['order'] = $obj->order; + $i++; + } + + $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m SET m.order = ".$suivant['order']." WHERE m.rowid = ".$precedent['rowid'].""; // Monte celui select + $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."menu as m SET m.order = ".$precedent['order']." WHERE m.rowid = ".$suivant['rowid'].""; // Descend celui du dessus + $db->query($sql); +} + + + +/* + * Affichage page + */ + +llxHeader(); + + + +print_fiche_titre($langs->trans("Admin Menu"),'','setup'); + +print '
'; + +if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') +{ + + + $sql = "SELECT c.rowid, c.fk_constraint FROM ".MAIN_DB_PREFIX."menu_const as c WHERE c.fk_menu = ".$_GET['menuId']; + $res = $db->query($sql); + if ($res) + { + + while ($obj = $db->fetch_object ($res)) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu_const WHERE rowid = ".$obj->rowid; + $db->query($sql); + + $sql = "SELECT count(rowid) as countId FROM ".MAIN_DB_PREFIX."menu_const WHERE fk_constraint = ".$obj->fk_constraint; + $result = $db->query($sql); + $objc = $db->fetch_object($result); + + if($objc->countId == 0) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu_constraint WHERE rowid = ".$obj->fk_constraint; + $db->query($sql); + } + } + + + + } +; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".$_GET['menuId']; + $db->query($sql); + + if ($result == 0) + { + llxHeader(); + print '
'.$langs->trans("MenuDeleted").'
'; + llxFooter(); + exit ; + } + else + { + $reload = 0; + $_GET["action"]=''; + } +} + +// Confirmation de la suppression de la facture +if ($_GET["action"] == 'delete') +{ + + $sql = "SELECT m.titre FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".$_GET['menuId']; + $result = $db->query($sql); + $obj = $db->fetch_object($result); + + $html = new Form($db); + $html->form_confirm("index.php?menuId=".$_GET['menuId'],$langs->trans("DeleteMenu"),$langs->trans("ConfirmDeleteMenu")." ".$obj->titre,"confirm_delete"); + print "
\n"; +} + + + + + +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; + + print ''; + + print '
'.$langs->trans("TreeMenu").'
'; + + +/************************* + * ARBORESCENCE * + *************************/ + + +/* cette fonction gère le décallage des éléments + suivant leur position dans l'arborescence +*/ + + + +$rangLast = 0; +$idLast = -1; +if ($conf->use_javascript) +{ + print ''; +} + +function affiche($tab,$rang) +{ + global $rangLast, $idLast; + + if ($conf->use_javascript) + { + if($rang == $rangLast) + { + print ''; + } + elseif($rang > $rangLast) + { + + print '
    • '; + + } + elseif($rang < $rangLast) + { + print ''; + + for($i=$rang; $i < $rangLast; $i++) + { + print '
  • '; + echo "\n"; + } + + } + } + else + { + if($rang > $rangLast) + { + + print '
    • '; + + } + elseif($rang < $rangLast) + { + + for($i=$rang; $i < $rangLast; $i++) + { + print '
  • '; + echo "\n"; + } + + } + } + + print '
  • '; + print ''.$tab[2].''; + print ''; + print ''; + print ''; + print ''; + print '
  • '; + echo "\n"; + + $rangLast = $rang; + $idLast = $tab[0]; + + + + + +} + +/*fonction récursive d'affichage de l'arbre + $tab :tableau des éléments + $pere :index de l'élément courrant + $rang :décallage de l'élément +*/ +function recur($tab,$pere,$rang) { + + //ballayage du tableau + for ($x=0;$xquery($sql); + +if ($res) +{ + $num = $db->num_rows(); + + $i = 1; + while ($menu = $db->fetch_array ($res)) + { + $langs->load($menu['langs']); + $titre = $langs->trans($menu['titre']); + $data[] = array($menu['rowid'],$menu['fk_menu'],$titre); + $i++; + } +} + + //appelle de la fonction récursive (ammorce) + //avec recherche depuis la racine. + print '
      '; + recur($data,0,0); + print ''; + print '
    '; + + + + + print '
    '; + print '
    '; + + + + +print ''; + +print '
    '; +print ''.$langs->trans("NewMenu").''; +print '
    '; + + + + + + + +?> diff --git a/htdocs/admin/menus/menu.js b/htdocs/admin/menus/menu.js new file mode 100644 index 00000000000..19e0ee82462 --- /dev/null +++ b/htdocs/admin/menus/menu.js @@ -0,0 +1,171 @@ +/* ----------------------------------------------------- + +-------------------------------------------------------- */ +// Tests pour navigateurs +var OPE = (window.opera) ? true : false; +var IE = (document.all && !OPE) ? true : false; +var MOZ = (!IE && !OPE) ? true : false; +// ----------------------------------------------------- +// Fonction d'initialisation de l'arbre +function arbre() { + // Choix de la balise contenant le texte. par defaut. + balise = "STRONG"; + // Presentation de l'arbre au depart : deployee ('yes') ou fermee ('no') + extend = "yes"; + // Textes du lien plier / deplier + plier_text = 'Replier tout'; + plier_title = 'Replier tous les noeuds de l\'arbre' + deplier_text = 'Deplier tout'; + deplier_title = 'Deplier tous les noeuds de l\'arbre' + // Recuperation de tous les arbres de la page + uls = getElBy('ul','class','arbre'); + for (uli=0;uli + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * or see http://www.gnu.org/ + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/includes/modules/menudb/modules_menudb.php + \ingroup menudb + \brief Fichier contenant la classe mère d'affichage des menus' + \version $Revision$ +*/ + +class menuDb { + var $newmenu; + var $mainmenu; + var $leftmenu; + + function menuDb($db) { + $this->db = $db; + } + + function menuCharger($mainmenu, $newmenu,$type_user, $leftmenu) + { + + global $langs,$user, $conf; + + $this->mainmenu = $mainmenu; + $this->newmenu = $newmenu; + $this->leftmenu = $leftmenu; + + $sql = "SELECT m.rowid, m.titre, m.level FROM " . MAIN_DB_PREFIX . "menu as m WHERE m.mainmenu = '" . $this->mainmenu . "'"; + $result = $this->db->query($sql); + $menuTop = $this->db->fetch_object($result); + + $data[] = array ($menutop->rowid,-1,$this->mainmenu); + + $sql = "SELECT m.rowid, m.fk_menu, m.url, m.titre, m.langs, m.right, m.target, m.mainmenu, m.leftmenu FROM " . MAIN_DB_PREFIX . "menu as m "; + if($type_user == 0)$sql.= "WHERE m.user <> 1 "; + else $sql.= "WHERE m.user > 0 "; + $sql.= "ORDER BY m.order, m.rowid"; + $res = $this->db->query($sql); + + if ($res) { + $num = $this->db->num_rows(); + + $i = 1; + while ($menu = $this->db->fetch_array($res)) { + $langs->load($menu['langs']); + $titre = $langs->trans($menu['titre']); + $rights = $this->verifRights($menu['right']); + $data[] = array ( + $menu['rowid'], + $menu['fk_menu'], + $menu['url'], + $titre, + $rights, + $menu['target'], + $menu['leftmenu'] + ); + $i++; + + } + + } + + $this->recur($data, $menuTop->rowid, 1); + + return $this->newmenu; + + } + + function recur($tab, $pere, $rang) { + $leftmenu = $this->leftmenu; + //ballayage du tableau + for ($x = 0; $x < count($tab); $x++) { + + //si un élément a pour père : $pere + if ($tab[$x][1] == $pere) { + + //on affiche le menu + + if ($this->verifConstraint($tab[$x][0], $tab[$x][6], $tab[$x][7]) != 0) { + + if ($tab[$x][6]) { + + $leftmenuConstraint = false; + $str = "if(" . $tab[$x][6] . ") \$leftmenuConstraint = true;"; + + eval ($str); + if ($leftmenuConstraint == true) { + $this->newmenu->add_submenu(DOL_URL_ROOT . $tab[$x][2], $tab[$x][3], $rang -1, $tab[$x][4], $tab[$x][5]); + $this->recur($tab, $tab[$x][0], $rang +1); + } + } else { + $this->newmenu->add_submenu(DOL_URL_ROOT . $tab[$x][2], $tab[$x][3], $rang -1, $tab[$x][4], $tab[$x][5]); + $this->recur($tab, $tab[$x][0], $rang +1); + } + + } + } + } + } + + function verifConstraint($rowid, $mainmenu = "", $leftmenu = "") + { + global $user, $conf, $user; + + $constraint = true; + + $sql = "SELECT c.rowid, c.action, mc.user FROM " . MAIN_DB_PREFIX . "menu_constraint as c, " . MAIN_DB_PREFIX . "menu_const as mc WHERE mc.fk_constraint = c.rowid AND (mc.user = 0 OR mc.user = 2 ) AND mc.fk_menu = '" . $rowid . "'"; + $result = $this->db->query($sql); + + if ($result) + { + //echo $sql; + $num = $this->db->num_rows(); + $i = 0; + while (($i < $num) && $constraint == true) + { + $obj = $this->db->fetch_object($result); + $strconstraint = "if(!(" . $obj->action . ")) { \$constraint = false;}"; + + eval ($strconstraint); + $i++; + } + } + + return $constraint; + } + + function verifRights($strRights) { + + global $user,$conf,$user; + + if ($strRights != "") { + $rights = true; + + $tab_rights = explode(" || ", $strRights); + $i = 0; + while (($i < count($tab_rights)) && ($rights == true)) { + $str = "if(!(" . $strRights . ")) { \$rights = false;}"; + eval ($str); + $i++; + } + } else + $rights = true; + + return $rights; + } + + function listeMainmenu() { + $sql = "SELECT DISTINCT m.mainmenu FROM " . MAIN_DB_PREFIX . "menu as m"; + $res = $this->db->query($sql); + + if ($res) { + $i = 0; + while ($menu = $this->db->fetch_array($res)) { + $overwritemenufor[$i] = $menu['mainmenu']; + $i++; + } + } + + return $overwritemenufor; + } + + + function menutopCharger($type_user,$mainmenu) + { + + global $langs, $user, $conf; + + $sql = "SELECT m.rowid, m.mainmenu, m.titre, m.url, m.langs, m.right FROM ".MAIN_DB_PREFIX."menu as m WHERE m.level = -1 "; + if($type_user == 0)$sql.= "AND m.user <> 1 "; + else $sql.= "AND m.user > 0 "; + $sql.= "ORDER BY m.order"; + $result = $this->db->query($sql); + + if ($result) + { + + $numa = $this->db->num_rows(); + + $a = 0; + $b = 0; + while ($a < $numa) + { + // Affichage entete menu + $objm = $this->db->fetch_object($result); + + if ($this->verifConstraint($objm->rowid)) + { + $langs->load($objm->langs); + + $class=""; + if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == $objm->mainmenu) + { + $class='id="sel"'; + } + $chaine=""; + + $right = true; + + if ($objm->right) + { + $str = "if(!(".$objm->right.")) \$right = false;"; + eval($str); + } + + if(eregi("/",$objm->titre)) + { + $tab_titre = explode("/",$objm->titre); + $chaine = $langs->trans($tab_titre[0])."/".$langs->trans($tab_titre[1]); + } + else + { + $chaine = $langs->trans($objm->titre); + } + + $tabMenu[$b]['titre'] = $chaine; + $tabMenu[$b]['url'] = $objm->url; + $tabMenu[$b]['atarget'] = $this->atarget; + $tabMenu[$b]['class'] = $class; + $tabMenu[$b]['right'] = $right; + + $b++; + + } + + $a++; + } + } + + return $tabMenu; + + } +} +?> diff --git a/htdocs/admin/menus/pre.inc.php b/htdocs/admin/menus/pre.inc.php new file mode 100644 index 00000000000..3ab20ed9509 --- /dev/null +++ b/htdocs/admin/menus/pre.inc.php @@ -0,0 +1,191 @@ + + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + + +/** + \file htdocs/admin/menus/pre.inc.php + \brief Fichier gestionnaire du menu de gauche de l'accueil + \version $Revision$ +*/ + +require ("../../main.inc.php"); +$user->getrights(); + +function llxHeader($head = "") +{ + global $user, $conf, $langs; + + top_menu($head); + + $menu = new Menu(); + + if ($conf->societe->enabled && $user->rights->societe->lire) + { + $langs->load("companies"); + $menu->add(DOL_URL_ROOT."/societe.php", $langs->trans("Companies")); + + if ($user->rights->societe->creer) + { + $menu->add_submenu(DOL_URL_ROOT."/soc.php?action=create", $langs->trans("MenuNewCompany")); + } + + if(is_dir("societe/groupe")) + { + $menu->add_submenu(DOL_URL_ROOT."/societe/groupe/index.php", $langs->trans("MenuSocGroup")); + } + $menu->add_submenu(DOL_URL_ROOT."/contact/index.php",$langs->trans("Contacts")); + } + + if ($conf->commercial->enabled && $user->rights->commercial->lire) + { + $langs->load("commercial"); + $menu->add(DOL_URL_ROOT."/comm/index.php",$langs->trans("Commercial")); + + $menu->add_submenu(DOL_URL_ROOT."/comm/clients.php",$langs->trans("Customers")); + $menu->add_submenu(DOL_URL_ROOT."/comm/prospect/prospects.php",$langs->trans("Prospects")); + + if ($user->rights->propale->lire) + { + $langs->load("propal"); + $menu->add_submenu(DOL_URL_ROOT."/comm/propal.php", $langs->trans("Prop")); + } + } + + if ($conf->compta->enabled || $conf->comptaexpert->enabled) + { + $langs->load("compta"); + $menu->add(DOL_URL_ROOT."/compta/index.php", $langs->trans("MenuFinancial")); + + if ($user->rights->facture->lire) { + $langs->load("bills"); + $menu->add_submenu(DOL_URL_ROOT."/compta/facture.php", $langs->trans("Bills")); + } + } + + if ($conf->fichinter->enabled && $user->rights->ficheinter->lire) + { + $langs->trans("interventions"); + $menu->add(DOL_URL_ROOT."/fichinter/index.php", $langs->trans("Interventions")); + } + + if (($conf->produit->enabled || $conf->service->enabled) && $user->rights->produit->lire) + { + $langs->load("products"); + $chaine=""; + if ($conf->produit->enabled) { $chaine.= $langs->trans("Products"); } + if ($conf->produit->enabled && $conf->service->enabled) { $chaine.="/"; } + if ($conf->service->enabled) { $chaine.= $langs->trans("Services"); } + $menu->add(DOL_URL_ROOT."/product/index.php", "$chaine"); + +/* + if ($conf->boutique->enabled) + { + if ($conf->boutique->livre->enabled) + { + $menu->add_submenu(DOL_URL_ROOT."/boutique/livre/index.php", "Livres"); + } + + if ($conf->boutique->album->enabled) + { + $menu->add_submenu(DOL_URL_ROOT."/product/album/index.php", "Albums"); + } + } +*/ + } + + + if ($conf->commande->enabled && $user->rights->commande->lire) + { + $langs->load("orders"); + $menu->add(DOL_URL_ROOT."/commande/index.php", $langs->trans("Orders")); + } + + if ($conf->expedition->enabled && $user->rights->expedition->lire) + { + $langs->load("sendings"); + $menu->add(DOL_URL_ROOT."/expedition/index.php", $langs->trans("Sendings")); + } + + if ($conf->mailing->enabled && $user->rights->mailing->lire) + { + $langs->load("mails"); + $menu->add(DOL_URL_ROOT."/comm/mailing/index.php",$langs->trans("EMailings")); + } + + if ($conf->telephonie->enabled) + { + $menu->add(DOL_URL_ROOT."/telephonie/index.php", "Téléphonie"); + } + + if ($conf->don->enabled) + { + $menu->add(DOL_URL_ROOT."/compta/dons/index.php", $langs->trans("Donations")); + } + + if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) + { + $langs->load("suppliers"); + $menu->add(DOL_URL_ROOT."/fourn/index.php", $langs->trans("Suppliers")); + } + + if ($conf->voyage->enabled && $user->societe_id == 0) + { + $menu->add(DOL_URL_ROOT."/compta/voyage/index.php","Voyages"); + $menu->add_submenu(DOL_URL_ROOT."/compta/voyage/index.php","Voyages"); + $menu->add_submenu(DOL_URL_ROOT."/compta/voyage/reduc.php","Reduc"); + } + + if ($conf->domaine->enabled) + { + $menu->add(DOL_URL_ROOT."/domain/index.php", "Domaines"); + } + + if ($conf->postnuke->enabled) + { + $menu->add(DOL_URL_ROOT."/postnuke/articles/index.php", "Editorial"); + } + + if ($conf->bookmark->enabled && $user->rights->bookmark->lire) + { + $menu->add(DOL_URL_ROOT."/bookmarks/liste.php", $langs->trans("Bookmarks")); + } + + if ($conf->export->enabled) + { + $langs->load("exports"); + $menu->add(DOL_URL_ROOT."/exports/index.php", $langs->trans("Exports")); + } + + if ($user->rights->user->user->lire || $user->admin) + { + $langs->load("users"); + $menu->add(DOL_URL_ROOT."/user/home.php", $langs->trans("MenuUsersAndGroups")); + } + + if ($user->admin) + { + $menu->add(DOL_URL_ROOT."/admin/index.php", $langs->trans("Setup")); + } + + + left_menu($menu->liste); +} +?> diff --git a/htdocs/includes/menus/barre_left/auguria_backoffice.php b/htdocs/includes/menus/barre_left/auguria_backoffice.php new file mode 100644 index 00000000000..8c8c01b53b2 --- /dev/null +++ b/htdocs/includes/menus/barre_left/auguria_backoffice.php @@ -0,0 +1,229 @@ + + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/includes/menus/barre_left/auguria_backoffice.php + \brief Gestionnaire du menu du gauche Auguria + \version $Revision$ + + \remarks La construction d'un gestionnaire pour le menu de gauche est simple: + \remarks A l'aide d'un objet $newmenu=new Menu() et des méthode add et add_submenu, + \remarks définir la liste des entrées menu à faire apparaitre. + \remarks En fin de code, mettre la ligne $menu=$newmenu->liste. + \remarks Ce qui est défini dans un tel gestionnaire sera alors prioritaire sur + \remarks les définitions de menu des fichiers pre.inc.php +*/ + + +/** + \class MenuLeft + \brief Classe permettant la gestion du menu du gauche Auguria +*/ + +class MenuLeft { + + var $require_top=array("auguria_backoffice"); // Si doit etre en phase avec un gestionnaire de menu du haut particulier + var $newmenu; + var $menuArbo; + + var $overwritemenufor = array(); + var $leftmenu; + + + /** + * \brief Constructeur + * \param db Handler d'accès base de donnée + * \param menu_array Tableau des entrée de menu défini dans les fichier pre.inc.php + */ + function MenuLeft($db,&$menu_array) + { + + require_once(DOL_DOCUMENT_ROOT."/admin/menus/module_menudb.php"); + + $this->db=$db; + $this->menu_array=$menu_array; + $this->newmenu = new Menu(); + + $this->menuArbo = new menudb($this->db); + $this->overwritemenufor = $this->menuArbo->listeMainmenu(); + + } + + + /** + * \brief Affiche le menu + */ + function showmenu() + { + global $user,$conf,$langs,$dolibarr_main_db_name; + + + + + if (! session_id()) { + session_name("DOLSESSID_".$dolibarr_main_db_name); + session_start(); // En mode authentification PEAR, la session a déjà été ouverte + } + + $user->getrights(""); + + // On récupère mainmenu et leftmenu qui définissent le menu à afficher + if (isset($_GET["mainmenu"])) { + // On sauve en session le menu principal choisi + $mainmenu=$_GET["mainmenu"]; + $_SESSION["mainmenu"]=$mainmenu; + $_SESSION["leftmenuopened"]=""; + } else { + // On va le chercher en session si non défini par le lien + $mainmenu=$_SESSION["mainmenu"]; + } + + if (isset($_GET["leftmenu"])) { + // On sauve en session le menu principal choisi + $this->leftmenu=$_GET["leftmenu"]; + $_SESSION["leftmenu"]=$this->leftmenu; + if ($_SESSION["leftmenuopened"]==$this->leftmenu) { + //$leftmenu=""; + $_SESSION["leftmenuopened"]=""; + } + else { + $_SESSION["leftmenuopened"]=$this->leftmenu; + } + } else { + // On va le chercher en session si non défini par le lien + $this->leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; + } + + + + /** + * On definit newmenu en fonction de mainmenu et leftmenu + * ------------------------------------------------------ + */ + if ($mainmenu) + { + + + $this->newmenu = $this->menuArbo->menuCharger($mainmenu, $this->newmenu,0,$this->leftmenu); + + + /* + * Menu AUTRES (Pour les menus du haut qui ne serait pas gérés) + */ + + if ($mainmenu && ! in_array($mainmenu,$this->overwritemenufor)) { $mainmenu=""; } + + } + + + + /** + * Si on est sur un cas géré de surcharge du menu, on ecrase celui par defaut + */ + if ($mainmenu) { + $this->menu_array=$this->newmenu->liste; + } + + + + + // Affichage du menu + $alt=0; + if (! sizeof($this->menu_array)) + { + print '
    '."\n"; + print $langs->trans("NoPermission"); + print '
    '; + } + else + { + $contenu = 0; + for ($i = 0 ; $i < sizeof($this->menu_array) ; $i++) + { + $alt++; + if ($this->menu_array[$i]['level']==0) { + if (($alt%2==0)) + { + print '