45 public $errors = array();
165 $this->menu_handler = $menu_handler;
178 global $conf, $langs;
181 if (!isset($this->enabled)) {
182 $this->enabled =
'1';
184 $this->menu_handler = trim((
string) $this->menu_handler);
185 $this->module = trim((
string) $this->module);
186 $this->
type = trim((
string) $this->
type);
187 $this->mainmenu = trim((
string) $this->mainmenu);
188 $this->leftmenu = trim((
string) $this->leftmenu);
189 $this->fk_menu = (int) $this->fk_menu;
190 $this->fk_mainmenu = trim((
string) $this->fk_mainmenu);
191 $this->fk_leftmenu = trim((
string) $this->fk_leftmenu);
192 $this->position = (int) $this->position;
193 $this->url = trim((
string) $this->url);
194 $this->target = trim((
string) $this->target);
195 $this->title = trim((
string) $this->title);
196 $this->langs = trim((
string) $this->langs);
197 $this->perms = trim((
string) $this->perms);
198 $this->enabled = trim((
string) $this->enabled);
200 if (empty($this->position)) {
208 if (empty($this->menu_handler)) {
215 if (in_array($this->
db->type, array(
'pgsql'))) {
216 $sql =
"SELECT MAX(rowid) as maxrowid FROM ".$this->db->prefix().
"menu";
217 $resqlrowid = $this->
db->query($sql);
219 $obj = $this->
db->fetch_object($resqlrowid);
220 $maxrowid = $obj->maxrowid;
223 if (empty($maxrowid)) {
227 $sql =
"SELECT setval('".$this->db->prefix().
"menu_rowid_seq', ".($maxrowid).
")";
229 $resqlrowidset = $this->
db->query($sql);
230 if (!$resqlrowidset) {
239 $sql =
"SELECT count(*)";
240 $sql .=
" FROM ".$this->db->prefix().
"menu";
241 $sql .=
" WHERE menu_handler = '".$this->db->escape($this->menu_handler).
"'";
242 $sql .=
" AND fk_menu = ".((int) $this->fk_menu);
243 $sql .=
" AND position = ".((int) $this->position);
244 $sql .=
" AND url = '".$this->db->escape($this->url).
"'";
245 $sql .=
" AND entity = ".$conf->entity;
247 $result = $this->
db->query($sql);
249 $row = $this->
db->fetch_row($result);
253 $sql =
"INSERT INTO ".$this->db->prefix().
"menu(";
254 $sql .=
"menu_handler,";
261 $sql .=
"fk_mainmenu,";
262 $sql .=
"fk_leftmenu,";
272 $sql .=
") VALUES (";
273 $sql .=
" '".$this->db->escape($this->menu_handler).
"',";
274 $sql .=
" '".$this->db->escape($conf->entity).
"',";
275 $sql .=
" '".$this->db->escape($this->module).
"',";
276 $sql .=
" '".$this->db->escape($this->type).
"',";
277 $sql .=
" ".($this->mainmenu ?
"'".$this->db->escape($this->mainmenu).
"'" :
"''").
",";
278 $sql .=
" ".($this->leftmenu ?
"'".$this->db->escape($this->leftmenu).
"'" :
"null").
",";
279 $sql .=
" ".((int) $this->fk_menu).
",";
280 $sql .=
" ".($this->fk_mainmenu ?
"'".$this->db->escape($this->fk_mainmenu).
"'" :
"null").
",";
281 $sql .=
" ".($this->fk_leftmenu ?
"'".$this->db->escape($this->fk_leftmenu).
"'" :
"null").
",";
282 $sql .=
" ".((int) $this->position).
",";
283 $sql .=
" '".$this->db->escape($this->url).
"',";
284 $sql .=
" '".$this->db->escape($this->target).
"',";
285 $sql .=
" '".$this->db->escape($this->title).
"',";
286 $sql .=
" '".$this->db->escape($this->prefix).
"',";
287 $sql .=
" '".$this->db->escape($this->langs).
"',";
288 $sql .=
" '".$this->db->escape($this->perms).
"',";
289 $sql .=
" '".$this->db->escape($this->enabled).
"',";
290 $sql .=
" '".$this->db->escape($this->
user).
"'";
293 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
296 $this->
id = $this->
db->last_insert_id($this->
db->prefix().
"menu");
297 dol_syslog(get_class($this).
"::create record added has rowid=".((
int) $this->
id), LOG_DEBUG);
301 $this->error =
"Error ".$this->db->lasterror();
305 dol_syslog(get_class($this).
"::create menu entry already exists", LOG_WARNING);
306 $this->error =
'Error Menu entry already exists';
321 public function update($user =
null, $notrigger = 0)
327 $this->menu_handler = trim($this->menu_handler);
328 $this->module = trim($this->module);
330 $this->mainmenu = trim($this->mainmenu);
331 $this->leftmenu = trim($this->leftmenu);
332 $this->fk_menu = (int) $this->fk_menu;
333 $this->fk_mainmenu = trim($this->fk_mainmenu);
334 $this->fk_leftmenu = trim($this->fk_leftmenu);
335 $this->position = (int) $this->position;
336 $this->url = trim($this->url);
337 $this->target = trim($this->target);
338 $this->title = trim($this->title);
339 $this->prefix = trim($this->prefix);
340 $this->langs = trim($this->langs);
341 $this->perms = trim($this->perms);
342 $this->enabled = trim($this->enabled);
349 $sql =
"UPDATE ".$this->db->prefix().
"menu SET";
350 $sql .=
" menu_handler='".$this->db->escape($this->menu_handler).
"',";
351 $sql .=
" module='".$this->db->escape($this->module).
"',";
352 $sql .=
" type='".$this->db->escape($this->
type).
"',";
353 $sql .=
" mainmenu='".$this->db->escape($this->mainmenu).
"',";
354 $sql .=
" leftmenu='".$this->db->escape($this->leftmenu).
"',";
355 $sql .=
" fk_menu=".((int) $this->fk_menu).
",";
356 $sql .=
" fk_mainmenu=".($this->fk_mainmenu ?
"'".$this->db->escape($this->fk_mainmenu).
"'" :
"null").
",";
357 $sql .=
" fk_leftmenu=".($this->fk_leftmenu ?
"'".$this->db->escape($this->fk_leftmenu).
"'" :
"null").
",";
358 $sql .=
" position=".($this->position > 0 ? ((int) $this->position) : 0).
",";
359 $sql .=
" url='".$this->db->escape($this->url).
"',";
360 $sql .=
" target='".$this->db->escape($this->target).
"',";
361 $sql .=
" titre='".$this->db->escape($this->title).
"',";
362 $sql .=
" prefix='".$this->db->escape($this->prefix).
"',";
363 $sql .=
" langs='".$this->db->escape($this->langs).
"',";
364 $sql .=
" perms='".$this->db->escape($this->perms).
"',";
365 $sql .=
" enabled='".$this->db->escape($this->enabled).
"',";
366 $sql .=
" usertype='".$this->db->escape($this->
user).
"'";
367 $sql .=
" WHERE rowid=".((int) $this->
id);
369 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
372 $this->error =
"Error ".$this->db->lasterror();
387 public function fetch($id, $user =
null)
393 $sql .=
" t.menu_handler,";
394 $sql .=
" t.entity,";
395 $sql .=
" t.module,";
397 $sql .=
" t.mainmenu,";
398 $sql .=
" t.leftmenu,";
399 $sql .=
" t.fk_menu,";
400 $sql .=
" t.fk_mainmenu,";
401 $sql .=
" t.fk_leftmenu,";
402 $sql .=
" t.position,";
404 $sql .=
" t.target,";
405 $sql .=
" t.titre as title,";
406 $sql .=
" t.prefix,";
409 $sql .=
" t.enabled,";
410 $sql .=
" t.usertype as user,";
412 $sql .=
" FROM ".$this->db->prefix().
"menu as t";
413 $sql .=
" WHERE t.rowid = ".((int) $id);
415 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
419 $obj = $this->
db->fetch_object(
$resql);
421 $this->
id = $obj->rowid;
423 $this->menu_handler = $obj->menu_handler;
424 $this->entity = $obj->entity;
425 $this->module = $obj->module;
426 $this->
type = $obj->type;
427 $this->mainmenu = $obj->mainmenu;
428 $this->leftmenu = $obj->leftmenu;
429 $this->fk_menu = $obj->fk_menu;
430 $this->fk_mainmenu = $obj->fk_mainmenu;
431 $this->fk_leftmenu = $obj->fk_leftmenu;
432 $this->position = $obj->position;
433 $this->url = $obj->url;
434 $this->target = $obj->target;
435 $this->title = $obj->title;
436 $this->prefix = $obj->prefix;
437 $this->langs = $obj->langs;
438 $this->perms = $obj->perms;
439 $this->enabled = str_replace(
"\"",
"'", $obj->enabled);
440 $this->
user = $obj->user;
441 $this->tms = $this->
db->jdate($obj->tms);
447 $this->error =
"Error ".$this->db->lasterror();
459 public function delete($user)
463 $sql =
"DELETE FROM ".$this->db->prefix().
"menu";
464 $sql .=
" WHERE rowid=".((int) $this->
id);
466 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
469 $this->error =
"Error ".$this->db->lasterror();
488 $this->menu_handler =
'all';
489 $this->module =
'specimen';
491 $this->mainmenu =
'';
492 $this->fk_menu =
'0';
493 $this->position =
'';
494 $this->url =
'http://dummy';
496 $this->title =
'Specimen menu';
498 $this->leftmenu =
'';
516 public function menuTopCharger($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
518 global $langs, $user, $conf;
519 global $mainmenu, $leftmenu;
521 $mainmenu = $mymainmenu;
522 $leftmenu = $myleftmenu;
524 $newTabMenu = array();
525 foreach ($tabMenu as $val) {
526 if ($val[
'type'] ==
'top') {
527 $newTabMenu[] = $val;
546 public function menuLeftCharger($newmenu, $mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
548 global $langs, $user, $conf;
549 global $mainmenu, $leftmenu;
551 $mainmenu = $mymainmenu;
552 $leftmenu = $myleftmenu;
556 foreach ($tabMenu as $key => $val) {
558 if (empty($menutopid) && $val[
'type'] ==
'top' && $val[
'mainmenu'] == $mainmenu) {
559 $menutopid = $val[
'rowid'];
565 $this->newmenu = $newmenu;
568 $this->
recur($tabMenu, $menutopid, 1);
571 foreach ($tabMenu as $key => $val) {
572 if ($val[
'fk_menu'] == -1 && $val[
'fk_mainmenu'] == $mainmenu) {
576 if (empty($val[
'fk_leftmenu'])) {
577 $this->newmenu->add($val[
'url'], $val[
'titre'], 0, $val[
'perms'], $val[
'target'], $val[
'mainmenu'], $val[
'leftmenu'], $val[
'position'],
'',
'',
'', $val[
'prefix']);
585 foreach ($this->newmenu->liste as $keyparent => $valparent) {
587 if ($searchlastsub) {
588 if ($valparent[
'level'] >= $searchlastsub) {
589 $lastid = $keyparent;
591 if ($valparent[
'level'] < $searchlastsub) {
592 $nextid = $keyparent;
596 if ($valparent[
'mainmenu'] == $val[
'fk_mainmenu'] && $valparent[
'leftmenu'] == $val[
'fk_leftmenu']) {
599 $searchlastsub = ($valparent[
'level'] + 1);
600 $lastid = $keyparent;
606 $this->newmenu->insert($lastid, $val[
'url'], $val[
'titre'], $searchlastsub, $val[
'perms'], $val[
'target'], $val[
'mainmenu'], $val[
'leftmenu'], $val[
'position'],
'',
'',
'', $val[
'prefix']);
608 dol_syslog(
"Error. Modules ".$val[
'module'].
" has defined a menu entry with a parent='fk_mainmenu=".$val[
'fk_leftmenu'].
",fk_leftmenu=".$val[
'fk_leftmenu'].
"' and position=".$val[
'position'].
'. The parent was not found. May be you forget it into your definition of menu, or may be the parent has a "position" that is after the child (fix field "position" of parent or child in this case).', LOG_WARNING);
615 return $this->newmenu;
629 public function menuLoad($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
631 global $langs, $user, $conf;
632 global $mainmenu, $leftmenu;
634 $mainmenu = $mymainmenu;
635 $leftmenu = $myleftmenu;
637 $sql =
"SELECT m.rowid, m.type, m.module, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.url, m.titre, m.prefix, m.langs, m.perms, m.enabled, m.target, m.mainmenu, m.leftmenu, m.position";
638 $sql .=
" FROM ".$this->db->prefix().
"menu as m";
639 $sql .=
" WHERE m.entity IN (0,".$conf->entity.
")";
640 $sql .=
" AND m.menu_handler IN ('".$this->db->escape($menu_handler).
"','all')";
641 if ($type_user == 0) {
642 $sql .=
" AND m.usertype IN (0,2)";
644 if ($type_user == 1) {
645 $sql .=
" AND m.usertype IN (1,2)";
647 $sql .=
" ORDER BY m.position, m.rowid";
653 $numa = $this->
db->num_rows(
$resql);
659 $menu = $this->
db->fetch_array(
$resql);
663 if (isset($menu[
'perms'])) {
664 $tmpcond = $menu[
'perms'];
665 if ($leftmenu ==
'all') {
666 $tmpcond = preg_replace(
'/\$leftmenu\s*==\s*["\'a-zA-Z_]+/',
'1==1', $tmpcond);
674 if (isset($menu[
'enabled'])) {
675 $tmpcond = $menu[
'enabled'];
676 if ($leftmenu ==
'all') {
677 $tmpcond = preg_replace(
'/\$leftmenu\s*==\s*["\'a-zA-Z_]+/',
'1==1', $tmpcond);
684 $title = $langs->trans($menu[
'titre']);
686 if ($title == $menu[
'titre']) {
687 if (!empty($menu[
'langs'])) {
689 $langs->load($menu[
'langs']);
692 $substitarray = array(
'__LOGIN__' => $user->login,
'__USER_ID__' => $user->id,
'__USER_SUPERVISOR_ID__' => $user->fk_user);
695 if (preg_match(
"/\//", $menu[
'titre'])) {
696 $tab_titre = explode(
"/", $menu[
'titre']);
697 $title = $langs->trans($tab_titre[0]).
"/".$langs->trans($tab_titre[1]);
698 } elseif (preg_match(
'/\|\|/', $menu[
'titre'])) {
700 $tab_title = explode(
"||", $menu[
'titre']);
701 $alt_title = explode(
"@", $tab_title[1]);
702 $title_enabled =
verifCond($alt_title[1]);
703 $title = ($title_enabled ? $langs->trans($alt_title[0]) : $langs->trans($tab_title[0]));
705 $title = $langs->trans($menu[
'titre']);
712 $tabMenu[$b][
'rowid'] = $menu[
'rowid'];
713 $tabMenu[$b][
'module'] = $menu[
'module'];
714 $tabMenu[$b][
'fk_menu'] = $menu[
'fk_menu'];
715 $tabMenu[$b][
'url'] = $menu[
'url'];
716 if (!preg_match(
"/^(http:\/\/|https:\/\/)/i", $tabMenu[$b][
'url'])) {
717 if (preg_match(
'/\?/', $tabMenu[$b][
'url'])) {
718 $tabMenu[$b][
'url'] .=
'&idmenu='.$menu[
'rowid'];
720 $tabMenu[$b][
'url'] .=
'?idmenu='.$menu[
'rowid'];
723 $tabMenu[$b][
'titre'] = $title;
724 $tabMenu[$b][
'prefix'] = $menu[
'prefix'];
725 $tabMenu[$b][
'target'] = $menu[
'target'];
726 $tabMenu[$b][
'mainmenu'] = $menu[
'mainmenu'];
727 $tabMenu[$b][
'leftmenu'] = $menu[
'leftmenu'];
728 $tabMenu[$b][
'perms'] = $perms;
729 $tabMenu[$b][
'langs'] = $menu[
'langs'];
730 $tabMenu[$b][
'enabled'] = $enabled;
731 $tabMenu[$b][
'type'] = $menu[
'type'];
732 $tabMenu[$b][
'fk_mainmenu'] = $menu[
'fk_mainmenu'];
733 $tabMenu[$b][
'fk_leftmenu'] = $menu[
'fk_leftmenu'];
734 $tabMenu[$b][
'position'] = (int) $menu[
'position'];
762 private function recur($tab, $pere, $level)
766 for ($x = 0; $x < $num; $x++) {
768 if ((($tab[$x][
'fk_menu'] >= 0 && $tab[$x][
'fk_menu'] == $pere)) && $tab[$x][
'enabled']) {
769 $this->newmenu->add($tab[$x][
'url'], $tab[$x][
'titre'], ($level - 1), $tab[$x][
'perms'], $tab[$x][
'target'], $tab[$x][
'mainmenu'], $tab[$x][
'leftmenu'], 0,
'',
'',
'', $tab[$x][
'prefix']);
770 $this->
recur($tab, $tab[$x][
'rowid'], ($level + 1));
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
verifCond($strToEvaluate)
Verify if condition in string is ok or not.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db
API class for accounts.