@@ -87,8 +87,7 @@ discard block |
||
| 87 | 87 | if ( defined('PHP_OS') ) |
| 88 | 88 | { |
| 89 | 89 | $os = PHP_OS ; |
| 90 | - } |
|
| 91 | - else |
|
| 90 | + } else |
|
| 92 | 91 | { |
| 93 | 92 | $os = php_uname(); |
| 94 | 93 | } |
@@ -96,8 +95,7 @@ discard block |
||
| 96 | 95 | if (strtoupper(substr($os, 0, 3)) === 'WIN' || FindBadUtf8($value)) |
| 97 | 96 | { |
| 98 | 97 | return (utf8_encode(htmlspecialchars($value))); |
| 99 | - } |
|
| 100 | - else |
|
| 98 | + } else |
|
| 101 | 99 | { |
| 102 | 100 | return (htmlspecialchars($value)); |
| 103 | 101 | } |
@@ -46,13 +46,15 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 48 | 48 | { |
| 49 | - if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing |
|
| 49 | + if (empty($conf->blockedlog->enabled)) { |
|
| 50 | + return 0; |
|
| 51 | + } |
|
| 52 | + // Module not active, we do nothing |
|
| 50 | 53 | |
| 51 | 54 | if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' |
| 52 | 55 | || $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW') { |
| 53 | 56 | $amounts= (double) $object->total_ttc; |
| 54 | - } |
|
| 55 | - else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') { |
|
| 57 | + } else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') { |
|
| 56 | 58 | $amounts = 0; |
| 57 | 59 | if(!empty($object->amounts)) { |
| 58 | 60 | foreach($object->amounts as $amount) { |
@@ -61,11 +63,9 @@ discard block |
||
| 61 | 63 | } |
| 62 | 64 | |
| 63 | 65 | |
| 64 | - } |
|
| 65 | - else if(strpos($action,'PAYMENT')!==false) { |
|
| 66 | + } else if(strpos($action,'PAYMENT')!==false) { |
|
| 66 | 67 | $amounts= (double) $object->amount; |
| 67 | - } |
|
| 68 | - else { |
|
| 68 | + } else { |
|
| 69 | 69 | return 0; // not implemented action log |
| 70 | 70 | } |
| 71 | 71 | |
@@ -80,8 +80,7 @@ discard block |
||
| 80 | 80 | setEventMessage($b->error,'errors'); |
| 81 | 81 | |
| 82 | 82 | return -1; |
| 83 | - } |
|
| 84 | - else { |
|
| 83 | + } else { |
|
| 85 | 84 | |
| 86 | 85 | return 1; |
| 87 | 86 | } |
@@ -49,13 +49,22 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 51 | 51 | { |
| 52 | - if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0; // Log events is disabled (hidden features) |
|
| 52 | + if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) { |
|
| 53 | + return 0; |
|
| 54 | + } |
|
| 55 | + // Log events is disabled (hidden features) |
|
| 53 | 56 | |
| 54 | 57 | $key='MAIN_LOGEVENTS_'.$action; |
| 55 | 58 | //dol_syslog("xxxxxxxxxxx".$key); |
| 56 | - if (empty($conf->global->$key)) return 0; // Log events not enabled for this action |
|
| 59 | + if (empty($conf->global->$key)) { |
|
| 60 | + return 0; |
|
| 61 | + } |
|
| 62 | + // Log events not enabled for this action |
|
| 57 | 63 | |
| 58 | - if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form) |
|
| 64 | + if (empty($conf->entity)) { |
|
| 65 | + $conf->entity = $entity; |
|
| 66 | + } |
|
| 67 | + // forcing of the entity if it's not defined (ex: in login form) |
|
| 59 | 68 | |
| 60 | 69 | $date = dol_now(); |
| 61 | 70 | |
@@ -96,8 +105,7 @@ discard block |
||
| 96 | 105 | // Initialisation donnees (date,duree,texte,desc) |
| 97 | 106 | $text=$langs->transnoentities("NewUserCreated",$object->login); |
| 98 | 107 | $desc=$langs->transnoentities("NewUserCreated",$object->login); |
| 99 | - } |
|
| 100 | - elseif ($action == 'USER_MODIFY') |
|
| 108 | + } elseif ($action == 'USER_MODIFY') |
|
| 101 | 109 | { |
| 102 | 110 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); |
| 103 | 111 | $langs->load("users"); |
@@ -105,8 +113,7 @@ discard block |
||
| 105 | 113 | // Initialisation donnees (date,duree,texte,desc) |
| 106 | 114 | $text=$langs->transnoentities("EventUserModified",$object->login); |
| 107 | 115 | $desc=$langs->transnoentities("EventUserModified",$object->login); |
| 108 | - } |
|
| 109 | - elseif ($action == 'USER_NEW_PASSWORD') |
|
| 116 | + } elseif ($action == 'USER_NEW_PASSWORD') |
|
| 110 | 117 | { |
| 111 | 118 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); |
| 112 | 119 | $langs->load("users"); |
@@ -114,8 +121,7 @@ discard block |
||
| 114 | 121 | // Initialisation donnees (date,duree,texte,desc) |
| 115 | 122 | $text=$langs->transnoentities("NewUserPassword",$object->login); |
| 116 | 123 | $desc=$langs->transnoentities("NewUserPassword",$object->login); |
| 117 | - } |
|
| 118 | - elseif ($action == 'USER_ENABLEDISABLE') |
|
| 124 | + } elseif ($action == 'USER_ENABLEDISABLE') |
|
| 119 | 125 | { |
| 120 | 126 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); |
| 121 | 127 | $langs->load("users"); |
@@ -130,8 +136,7 @@ discard block |
||
| 130 | 136 | $text=$langs->transnoentities("UserDisabled",$object->login); |
| 131 | 137 | $desc=$langs->transnoentities("UserDisabled",$object->login); |
| 132 | 138 | } |
| 133 | - } |
|
| 134 | - elseif ($action == 'USER_DELETE') |
|
| 139 | + } elseif ($action == 'USER_DELETE') |
|
| 135 | 140 | { |
| 136 | 141 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); |
| 137 | 142 | $langs->load("users"); |
@@ -148,16 +153,14 @@ discard block |
||
| 148 | 153 | // Initialisation donnees (date,duree,texte,desc) |
| 149 | 154 | $text=$langs->transnoentities("NewGroupCreated",$object->name); |
| 150 | 155 | $desc=$langs->transnoentities("NewGroupCreated",$object->name); |
| 151 | - } |
|
| 152 | - elseif ($action == 'GROUP_MODIFY') |
|
| 156 | + } elseif ($action == 'GROUP_MODIFY') |
|
| 153 | 157 | { |
| 154 | 158 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); |
| 155 | 159 | $langs->load("users"); |
| 156 | 160 | // Initialisation donnees (date,duree,texte,desc) |
| 157 | 161 | $text=$langs->transnoentities("GroupModified",$object->name); |
| 158 | 162 | $desc=$langs->transnoentities("GroupModified",$object->name); |
| 159 | - } |
|
| 160 | - elseif ($action == 'GROUP_DELETE') |
|
| 163 | + } elseif ($action == 'GROUP_DELETE') |
|
| 161 | 164 | { |
| 162 | 165 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); |
| 163 | 166 | $langs->load("users"); |
@@ -176,7 +179,9 @@ discard block |
||
| 176 | 179 | */ |
| 177 | 180 | |
| 178 | 181 | // Add more information into desc from the context property |
| 179 | - if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit']; |
|
| 182 | + if (! empty($desc) && ! empty($object->context['audit'])) { |
|
| 183 | + $desc.=' - '.$object->context['audit']; |
|
| 184 | + } |
|
| 180 | 185 | |
| 181 | 186 | // Add entry in event table |
| 182 | 187 | include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; |
@@ -192,8 +197,7 @@ discard block |
||
| 192 | 197 | if ($result > 0) |
| 193 | 198 | { |
| 194 | 199 | return 1; |
| 195 | - } |
|
| 196 | - else |
|
| 200 | + } else |
|
| 197 | 201 | { |
| 198 | 202 | $error ="Failed to insert security event: ".$event->error; |
| 199 | 203 | $this->error=$error; |
@@ -61,12 +61,17 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 63 | 63 | { |
| 64 | - if (empty($conf->notification->enabled)) return 0; // Module not active, we do nothing |
|
| 64 | + if (empty($conf->notification->enabled)) { |
|
| 65 | + return 0; |
|
| 66 | + } |
|
| 67 | + // Module not active, we do nothing |
|
| 65 | 68 | |
| 66 | 69 | require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; |
| 67 | 70 | $notify = new Notify($this->db); |
| 68 | 71 | |
| 69 | - if (! in_array($action, $notify->arrayofnotifsupported)) return 0; |
|
| 72 | + if (! in_array($action, $notify->arrayofnotifsupported)) { |
|
| 73 | + return 0; |
|
| 74 | + } |
|
| 70 | 75 | |
| 71 | 76 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); |
| 72 | 77 | |
@@ -102,7 +107,9 @@ discard block |
||
| 102 | 107 | |
| 103 | 108 | $qualified=0; |
| 104 | 109 | // Check is this event is supported by notification module |
| 105 | - if (in_array($obj->code,$this->listofmanagedevents)) $qualified=1; |
|
| 110 | + if (in_array($obj->code,$this->listofmanagedevents)) { |
|
| 111 | + $qualified=1; |
|
| 112 | + } |
|
| 106 | 113 | // Check if module for this event is active |
| 107 | 114 | if ($qualified) |
| 108 | 115 | { |
@@ -110,12 +117,19 @@ discard block |
||
| 110 | 117 | $element=$obj->elementtype; |
| 111 | 118 | |
| 112 | 119 | // Exclude events if related module is disabled |
| 113 | - if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0; |
|
| 114 | - elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0; |
|
| 115 | - elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0; |
|
| 116 | - elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0; |
|
| 117 | - elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0; |
|
| 118 | - elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member')) && empty($conf->$element->enabled)) $qualified=0; |
|
| 120 | + if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) { |
|
| 121 | + $qualified=0; |
|
| 122 | + } elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) { |
|
| 123 | + $qualified=0; |
|
| 124 | + } elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) { |
|
| 125 | + $qualified=0; |
|
| 126 | + } elseif ($element == 'shipping' && empty($conf->expedition->enabled)) { |
|
| 127 | + $qualified=0; |
|
| 128 | + } elseif ($element == 'member' && empty($conf->adherent->enabled)) { |
|
| 129 | + $qualified=0; |
|
| 130 | + } elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member')) && empty($conf->$element->enabled)) { |
|
| 131 | + $qualified=0; |
|
| 132 | + } |
|
| 119 | 133 | } |
| 120 | 134 | |
| 121 | 135 | if ($qualified) |
@@ -125,8 +139,9 @@ discard block |
||
| 125 | 139 | |
| 126 | 140 | $i++; |
| 127 | 141 | } |
| 142 | + } else { |
|
| 143 | + dol_print_error($this->db); |
|
| 128 | 144 | } |
| 129 | - else dol_print_error($this->db); |
|
| 130 | 145 | |
| 131 | 146 | return $ret; |
| 132 | 147 | } |
@@ -49,7 +49,10 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) |
| 51 | 51 | { |
| 52 | - if (empty($conf->mailmanspip->enabled)) return 0; // Module not active, we do nothing |
|
| 52 | + if (empty($conf->mailmanspip->enabled)) { |
|
| 53 | + return 0; |
|
| 54 | + } |
|
| 55 | + // Module not active, we do nothing |
|
| 53 | 56 | |
| 54 | 57 | if ($action == 'CATEGORY_LINK') |
| 55 | 58 | { |
@@ -61,15 +64,13 @@ discard block |
||
| 61 | 64 | $this->error=$object->linkto->error; |
| 62 | 65 | $this->errors=$object->linkto->errors; |
| 63 | 66 | $return=-1; |
| 64 | - } |
|
| 65 | - else |
|
| 67 | + } else |
|
| 66 | 68 | { |
| 67 | 69 | $return=1; |
| 68 | 70 | } |
| 69 | 71 | |
| 70 | 72 | return $return; |
| 71 | - } |
|
| 72 | - elseif ($action == 'CATEGORY_UNLINK') |
|
| 73 | + } elseif ($action == 'CATEGORY_UNLINK') |
|
| 73 | 74 | { |
| 74 | 75 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); |
| 75 | 76 | |
@@ -79,8 +80,7 @@ discard block |
||
| 79 | 80 | $this->error=$object->unlinkoff->error; |
| 80 | 81 | $this->errors=$object->unlinkoff->errors; |
| 81 | 82 | $return=-1; |
| 82 | - } |
|
| 83 | - else |
|
| 83 | + } else |
|
| 84 | 84 | { |
| 85 | 85 | $return=1; |
| 86 | 86 | } |
@@ -95,17 +95,18 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | $return=0; |
| 97 | 97 | // Add user into some linked tools (mailman, spip, etc...) |
| 98 | - if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) // TODO Do del/add also if type change |
|
| 98 | + if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) { |
|
| 99 | + // TODO Do del/add also if type change |
|
| 99 | 100 | { |
| 100 | 101 | if (is_object($object->oldcopy) && ($object->oldcopy->email != $object->email)) // If email has changed we delete mailman subscription for old email |
| 101 | 102 | { |
| 102 | 103 | if ($object->oldcopy->del_to_abo() < 0) |
| 103 | 104 | { |
| 104 | 105 | if (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error; |
| 106 | + } |
|
| 105 | 107 | $this->errors=$object->oldcopy->errors; |
| 106 | 108 | $return=-1; |
| 107 | - } |
|
| 108 | - else |
|
| 109 | + } else |
|
| 109 | 110 | { |
| 110 | 111 | $return=1; |
| 111 | 112 | } |
@@ -113,19 +114,19 @@ discard block |
||
| 113 | 114 | // We add subscription if new email or new type (new type may means more mailing-list to subscribe) |
| 114 | 115 | if ($object->add_to_abo() < 0) |
| 115 | 116 | { |
| 116 | - if (! empty($object->error)) $this->error=$object->error; |
|
| 117 | + if (! empty($object->error)) { |
|
| 118 | + $this->error=$object->error; |
|
| 119 | + } |
|
| 117 | 120 | $this->errors=$object->errors; |
| 118 | 121 | $return=-1; |
| 119 | - } |
|
| 120 | - else |
|
| 122 | + } else |
|
| 121 | 123 | { |
| 122 | 124 | $return=1; |
| 123 | 125 | } |
| 124 | 126 | } |
| 125 | 127 | |
| 126 | 128 | return $return; |
| 127 | - } |
|
| 128 | - elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE') |
|
| 129 | + } elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE') |
|
| 129 | 130 | { |
| 130 | 131 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); |
| 131 | 132 | |
@@ -133,11 +134,12 @@ discard block |
||
| 133 | 134 | // Remove from external tools (mailman, spip, etc...) |
| 134 | 135 | if ($object->del_to_abo() < 0) |
| 135 | 136 | { |
| 136 | - if (! empty($object->error)) $this->error=$object->error; |
|
| 137 | + if (! empty($object->error)) { |
|
| 138 | + $this->error=$object->error; |
|
| 139 | + } |
|
| 137 | 140 | $this->errors=$object->errors; |
| 138 | 141 | $return=-1; |
| 139 | - } |
|
| 140 | - else |
|
| 142 | + } else |
|
| 141 | 143 | { |
| 142 | 144 | $return=1; |
| 143 | 145 | } |
@@ -29,7 +29,9 @@ |
||
| 29 | 29 | |
| 30 | 30 | // Security check |
| 31 | 31 | $socid=0; |
| 32 | -if ($user->societe_id > 0) $socid=$user->societe_id; |
|
| 32 | +if ($user->societe_id > 0) { |
|
| 33 | + $socid=$user->societe_id; |
|
| 34 | +} |
|
| 33 | 35 | |
| 34 | 36 | |
| 35 | 37 | |
@@ -85,7 +85,9 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | if ($mode == 'top') |
| 87 | 87 | { |
| 88 | - if (empty($noout)) print_start_menu_array_empty(); |
|
| 88 | + if (empty($noout)) { |
|
| 89 | + print_start_menu_array_empty(); |
|
| 90 | + } |
|
| 89 | 91 | |
| 90 | 92 | $usemenuhider = (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)); |
| 91 | 93 | |
@@ -113,16 +115,28 @@ discard block |
||
| 113 | 115 | // Output menu entries |
| 114 | 116 | foreach($this->menu->liste as $menkey => $menuval) |
| 115 | 117 | { |
| 116 | - if (empty($noout)) print_start_menu_entry_empty($menuval['idsel'],$menuval['classname'],$menuval['enabled']); |
|
| 117 | - if (empty($noout)) print_text_menu_entry_empty($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); |
|
| 118 | - if (empty($noout)) print_end_menu_entry_empty($menuval['enabled']); |
|
| 118 | + if (empty($noout)) { |
|
| 119 | + print_start_menu_entry_empty($menuval['idsel'],$menuval['classname'],$menuval['enabled']); |
|
| 120 | + } |
|
| 121 | + if (empty($noout)) { |
|
| 122 | + print_text_menu_entry_empty($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); |
|
| 123 | + } |
|
| 124 | + if (empty($noout)) { |
|
| 125 | + print_end_menu_entry_empty($menuval['enabled']); |
|
| 126 | + } |
|
| 119 | 127 | } |
| 120 | 128 | |
| 121 | 129 | $showmode=1; |
| 122 | - if (empty($noout)) print_start_menu_entry_empty('','class="tmenuend"',$showmode); |
|
| 123 | - if (empty($noout)) print_end_menu_entry_empty($showmode); |
|
| 130 | + if (empty($noout)) { |
|
| 131 | + print_start_menu_entry_empty('','class="tmenuend"',$showmode); |
|
| 132 | + } |
|
| 133 | + if (empty($noout)) { |
|
| 134 | + print_end_menu_entry_empty($showmode); |
|
| 135 | + } |
|
| 124 | 136 | |
| 125 | - if (empty($noout)) print_end_menu_array_empty(); |
|
| 137 | + if (empty($noout)) { |
|
| 138 | + print_end_menu_array_empty(); |
|
| 139 | + } |
|
| 126 | 140 | |
| 127 | 141 | if ($mode == 'jmobile') |
| 128 | 142 | { |
@@ -131,10 +145,12 @@ discard block |
||
| 131 | 145 | } |
| 132 | 146 | } |
| 133 | 147 | |
| 134 | - if ($mode == 'jmobile') // Used to get menu in xml ul/li |
|
| 148 | + if ($mode == 'jmobile') { |
|
| 149 | + // Used to get menu in xml ul/li |
|
| 135 | 150 | { |
| 136 | 151 | // Home |
| 137 | 152 | $showmode=1; |
| 153 | + } |
|
| 138 | 154 | $classname='class="tmenusel"'; |
| 139 | 155 | $idsel='home'; |
| 140 | 156 | |
@@ -145,9 +161,11 @@ discard block |
||
| 145 | 161 | //var_dump($this->menu->liste);exit; |
| 146 | 162 | $lastlevel = array(); |
| 147 | 163 | print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
| 148 | - foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
| 164 | + foreach($this->menu->liste as $key => $val) { |
|
| 165 | + // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
| 149 | 166 | { |
| 150 | 167 | print '<ul class="ulmenu" data-inset="true">'; |
| 168 | + } |
|
| 151 | 169 | print '<li class="lilevel0">'; |
| 152 | 170 | |
| 153 | 171 | if ($val['enabled'] == 1) |
@@ -160,7 +178,9 @@ discard block |
||
| 160 | 178 | print '<a class="alilevel0" href="#">'; |
| 161 | 179 | |
| 162 | 180 | // Add font-awesome |
| 163 | - if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
| 181 | + if ($val['level'] == 0 && $val['mainmenu'] == 'home') { |
|
| 182 | + print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
| 183 | + } |
|
| 164 | 184 | |
| 165 | 185 | print $val['titre']; |
| 166 | 186 | print '</a>'."\n"; |
@@ -204,12 +224,16 @@ discard block |
||
| 204 | 224 | // We add sub entry |
| 205 | 225 | print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
| 206 | 226 | print '<a href="'.$relurl.'">'; |
| 207 | - if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
|
| 227 | + if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") { |
|
| 228 | + // No translation |
|
| 208 | 229 | { |
| 209 | 230 | if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); |
| 210 | - else print $langs->trans("Dashboard"); |
|
| 231 | + } else { |
|
| 232 | + print $langs->trans("Dashboard"); |
|
| 233 | + } |
|
| 234 | + } else { |
|
| 235 | + print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
| 211 | 236 | } |
| 212 | - else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
| 213 | 237 | print '</a>'; |
| 214 | 238 | print '</li>'."\n"; |
| 215 | 239 | } |
@@ -219,22 +243,26 @@ discard block |
||
| 219 | 243 | if ($val['enabled']) |
| 220 | 244 | { |
| 221 | 245 | $lastlevel[0]='enabled'; |
| 222 | - } |
|
| 223 | - else if ($showmenu) // Not enabled but visible (so greyed) |
|
| 246 | + } else if ($showmenu) { |
|
| 247 | + // Not enabled but visible (so greyed) |
|
| 224 | 248 | { |
| 225 | 249 | $lastlevel[0]='greyed'; |
| 226 | 250 | } |
| 227 | - else |
|
| 251 | + } else |
|
| 228 | 252 | { |
| 229 | 253 | $lastlevel[0]='hidden'; |
| 230 | 254 | } |
| 231 | 255 | } |
| 232 | 256 | |
| 233 | 257 | $lastlevel2 = array(); |
| 234 | - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
| 258 | + foreach($submenu->liste as $key2 => $val2) { |
|
| 259 | + // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
| 235 | 260 | { |
| 236 | 261 | $showmenu=true; |
| 237 | - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
|
| 262 | + } |
|
| 263 | + if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) { |
|
| 264 | + $showmenu=false; |
|
| 265 | + } |
|
| 238 | 266 | |
| 239 | 267 | // If at least one parent is not enabled, we do not show any menu of all children |
| 240 | 268 | if ($val2['level'] > 0) |
@@ -242,19 +270,25 @@ discard block |
||
| 242 | 270 | $levelcursor = $val2['level']-1; |
| 243 | 271 | while ($levelcursor >= 0) |
| 244 | 272 | { |
| 245 | - if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
| 273 | + if ($lastlevel2[$levelcursor] != 'enabled') { |
|
| 274 | + $showmenu=false; |
|
| 275 | + } |
|
| 246 | 276 | $levelcursor--; |
| 247 | 277 | } |
| 248 | 278 | } |
| 249 | 279 | |
| 250 | - if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
|
| 280 | + if ($showmenu) { |
|
| 281 | + // Visible (option to hide when not allowed is off or allowed) |
|
| 251 | 282 | { |
| 252 | 283 | $relurl2=dol_buildpath($val2['url'],1); |
| 284 | + } |
|
| 253 | 285 | $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); |
| 254 | 286 | $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); |
| 255 | 287 | $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
| 256 | 288 | //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
| 257 | - if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
| 289 | + if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) { |
|
| 290 | + $relurl2=''; |
|
| 291 | + } |
|
| 258 | 292 | |
| 259 | 293 | $disabled=''; |
| 260 | 294 | if (! $val2['enabled']) |
@@ -264,30 +298,34 @@ discard block |
||
| 264 | 298 | |
| 265 | 299 | print str_pad('',$val2['level']+1); |
| 266 | 300 | print '<li class="lilevel'.($val2['level']+1); |
| 267 | - if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
| 301 | + if ($val2['level']==0) { |
|
| 302 | + print ' ui-btn-icon-right ui-btn'; |
|
| 303 | + } |
|
| 304 | + // ui-btn to highlight on clic |
|
| 268 | 305 | print $disabled.'">'; // ui-btn to highlight on clic |
| 269 | 306 | if ($relurl2) |
| 270 | 307 | { |
| 271 | - if ($val2['enabled']) // Allowed |
|
| 308 | + if ($val2['enabled']) { |
|
| 309 | + // Allowed |
|
| 272 | 310 | { |
| 273 | 311 | print '<a href="'.$relurl2.'"'; |
| 312 | + } |
|
| 274 | 313 | //print ' data-ajax="false"'; |
| 275 | 314 | print '>'; |
| 276 | 315 | $lastlevel2[$val2['level']]='enabled'; |
| 277 | - } |
|
| 278 | - else // Not allowed but visible (greyed) |
|
| 316 | + } else // Not allowed but visible (greyed) |
|
| 279 | 317 | { |
| 280 | 318 | print '<a href="#" class="vsmenudisabled">'; |
| 281 | 319 | $lastlevel2[$val2['level']]='greyed'; |
| 282 | 320 | } |
| 283 | - } |
|
| 284 | - else |
|
| 321 | + } else |
|
| 285 | 322 | { |
| 286 | - if ($val2['enabled']) // Allowed |
|
| 323 | + if ($val2['enabled']) { |
|
| 324 | + // Allowed |
|
| 287 | 325 | { |
| 288 | 326 | $lastlevel2[$val2['level']]='enabled'; |
| 289 | 327 | } |
| 290 | - else |
|
| 328 | + } else |
|
| 291 | 329 | { |
| 292 | 330 | $lastlevel2[$val2['level']]='greyed'; |
| 293 | 331 | } |
@@ -297,10 +335,12 @@ discard block |
||
| 297 | 335 | print $val2['titre']; |
| 298 | 336 | if ($relurl2) |
| 299 | 337 | { |
| 300 | - if ($val2['enabled']) // Allowed |
|
| 338 | + if ($val2['enabled']) { |
|
| 339 | + // Allowed |
|
| 301 | 340 | print '</a>'; |
| 302 | - else |
|
| 303 | - print '</a>'; |
|
| 341 | + } else { |
|
| 342 | + print '</a>'; |
|
| 343 | + } |
|
| 304 | 344 | } |
| 305 | 345 | print '</li>'."\n"; |
| 306 | 346 | } |
@@ -361,15 +401,16 @@ discard block |
||
| 361 | 401 | $lastopened=true; |
| 362 | 402 | for($j = ($i + 1); $j < $num; $j++) |
| 363 | 403 | { |
| 364 | - if (empty($menu_array[$j]['level'])) $lastopened=false; |
|
| 404 | + if (empty($menu_array[$j]['level'])) { |
|
| 405 | + $lastopened=false; |
|
| 406 | + } |
|
| 365 | 407 | } |
| 366 | 408 | $alt = 0; // For menu manager "empty", we force to not have blockvmenufirst defined |
| 367 | 409 | $lastopened = 1; // For menu manager "empty", we force to not have blockvmenulast defined |
| 368 | 410 | if (($alt%2==0)) |
| 369 | 411 | { |
| 370 | 412 | print '<div class="blockvmenub lockvmenuimpair blockvmenuunique'.($lastopened?' blockvmenulast':'').($alt == 1 ? ' blockvmenufirst':'').'">'."\n"; |
| 371 | - } |
|
| 372 | - else |
|
| 413 | + } else |
|
| 373 | 414 | { |
| 374 | 415 | print '<div class="blockvmenu blockvmenupair blockvmenuunique'.($lastopened?' blockvmenulast':'').($alt == 1 ? ' blockvmenufirst':'').'">'."\n"; |
| 375 | 416 | } |
@@ -390,8 +431,7 @@ discard block |
||
| 390 | 431 | if ($this->menu->liste[$i]['enabled']) |
| 391 | 432 | { |
| 392 | 433 | print '<div class="menu_titre">'.$tabstring.'<a class="vmenu" href="'.dol_buildpath($this->menu->liste[$i]['url'],1).'"'.($this->menu->liste[$i]['target']?' target="'.$this->menu->liste[$i]['target'].'"':'').'>'.$this->menu->liste[$i]['titre'].'</a></div>'."\n"; |
| 393 | - } |
|
| 394 | - else |
|
| 434 | + } else |
|
| 395 | 435 | { |
| 396 | 436 | print '<div class="menu_titre">'.$tabstring.'<font class="vmenudisabled">'.$this->menu->liste[$i]['titre'].'</font></div>'."\n"; |
| 397 | 437 | } |
@@ -401,25 +441,34 @@ discard block |
||
| 401 | 441 | if ($this->menu->liste[$i]['level'] > 0) |
| 402 | 442 | { |
| 403 | 443 | $cssmenu = ''; |
| 404 | - if ($this->menu->liste[$i]['url']) $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/','',$this->menu->liste[$i]['url'])); |
|
| 444 | + if ($this->menu->liste[$i]['url']) { |
|
| 445 | + $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/','',$this->menu->liste[$i]['url'])); |
|
| 446 | + } |
|
| 405 | 447 | |
| 406 | 448 | print '<div class="menu_contenu'.$cssmenu.'">'; |
| 407 | 449 | |
| 408 | 450 | if ($this->menu->liste[$i]['enabled']) |
| 409 | 451 | { |
| 410 | 452 | print $tabstring; |
| 411 | - if ($this->menu->liste[$i]['url']) print '<a class="vsmenu" href="'.dol_buildpath($this->menu->liste[$i]['url'],1).'"'.($this->menu->liste[$i]['target']?' target="'.$this->menu->liste[$i]['target'].'"':'').'>'; |
|
| 412 | - else print '<span class="vsmenu">'; |
|
| 413 | - if ($this->menu->liste[$i]['url']) print $this->menu->liste[$i]['titre'].'</a>'; |
|
| 414 | - else print '</span>'; |
|
| 415 | - } |
|
| 416 | - else |
|
| 453 | + if ($this->menu->liste[$i]['url']) { |
|
| 454 | + print '<a class="vsmenu" href="'.dol_buildpath($this->menu->liste[$i]['url'],1).'"'.($this->menu->liste[$i]['target']?' target="'.$this->menu->liste[$i]['target'].'"':'').'>'; |
|
| 455 | + } else { |
|
| 456 | + print '<span class="vsmenu">'; |
|
| 457 | + } |
|
| 458 | + if ($this->menu->liste[$i]['url']) { |
|
| 459 | + print $this->menu->liste[$i]['titre'].'</a>'; |
|
| 460 | + } else { |
|
| 461 | + print '</span>'; |
|
| 462 | + } |
|
| 463 | + } else |
|
| 417 | 464 | { |
| 418 | 465 | print $tabstring.'<font class="vsmenudisabled vsmenudisabledmargin">'.$this->menu->liste[$i]['titre'].'</font>'; |
| 419 | 466 | } |
| 420 | 467 | |
| 421 | 468 | // If title is not pure text and contains a table, no carriage return added |
| 422 | - if (! strstr($this->menu->liste[$i]['titre'],'<table')) print '<br>'; |
|
| 469 | + if (! strstr($this->menu->liste[$i]['titre'],'<table')) { |
|
| 470 | + print '<br>'; |
|
| 471 | + } |
|
| 423 | 472 | print '</div>'."\n"; |
| 424 | 473 | } |
| 425 | 474 | |
@@ -431,7 +480,9 @@ discard block |
||
| 431 | 480 | } |
| 432 | 481 | } |
| 433 | 482 | |
| 434 | - if ($altok) print '<div class="blockvmenuend"></div>'; |
|
| 483 | + if ($altok) { |
|
| 484 | + print '<div class="blockvmenuend"></div>'; |
|
| 485 | + } |
|
| 435 | 486 | } |
| 436 | 487 | |
| 437 | 488 | if ($mode == 'jmobile') |
@@ -61,8 +61,12 @@ discard block |
||
| 61 | 61 | function loadMenu($forcemainmenu='',$forceleftmenu='') |
| 62 | 62 | { |
| 63 | 63 | // On sauve en session le menu principal choisi |
| 64 | - if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
| 65 | - if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
| 64 | + if (isset($_GET["mainmenu"])) { |
|
| 65 | + $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
| 66 | + } |
|
| 67 | + if (isset($_GET["idmenu"])) { |
|
| 68 | + $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
| 69 | + } |
|
| 66 | 70 | |
| 67 | 71 | // Read mainmenu and leftmenu that define which menu to show |
| 68 | 72 | if (isset($_GET["mainmenu"])) |
@@ -71,13 +75,14 @@ discard block |
||
| 71 | 75 | $mainmenu=$_GET["mainmenu"]; |
| 72 | 76 | $_SESSION["mainmenu"]=$mainmenu; |
| 73 | 77 | $_SESSION["leftmenuopened"]=""; |
| 74 | - } |
|
| 75 | - else |
|
| 78 | + } else |
|
| 76 | 79 | { |
| 77 | 80 | // On va le chercher en session si non defini par le lien |
| 78 | 81 | $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; |
| 79 | 82 | } |
| 80 | - if (! empty($forcemainmenu)) $mainmenu=$forcemainmenu; |
|
| 83 | + if (! empty($forcemainmenu)) { |
|
| 84 | + $mainmenu=$forcemainmenu; |
|
| 85 | + } |
|
| 81 | 86 | |
| 82 | 87 | if (isset($_GET["leftmenu"])) |
| 83 | 88 | { |
@@ -85,12 +90,13 @@ discard block |
||
| 85 | 90 | $leftmenu=$_GET["leftmenu"]; |
| 86 | 91 | $_SESSION["leftmenu"]=$leftmenu; |
| 87 | 92 | |
| 88 | - if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse |
|
| 93 | + if ($_SESSION["leftmenuopened"]==$leftmenu) { |
|
| 94 | + // To collapse |
|
| 89 | 95 | { |
| 90 | 96 | //$leftmenu=""; |
| 91 | 97 | $_SESSION["leftmenuopened"]=""; |
| 92 | 98 | } |
| 93 | - else |
|
| 99 | + } else |
|
| 94 | 100 | { |
| 95 | 101 | $_SESSION["leftmenuopened"]=$leftmenu; |
| 96 | 102 | } |
@@ -98,7 +104,9 @@ discard block |
||
| 98 | 104 | // On va le chercher en session si non defini par le lien |
| 99 | 105 | $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; |
| 100 | 106 | } |
| 101 | - if (! empty($forceleftmenu)) $leftmenu=$forceleftmenu; |
|
| 107 | + if (! empty($forceleftmenu)) { |
|
| 108 | + $leftmenu=$forceleftmenu; |
|
| 109 | + } |
|
| 102 | 110 | |
| 103 | 111 | require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; |
| 104 | 112 | $tabMenu=array(); |
@@ -134,14 +142,21 @@ discard block |
||
| 134 | 142 | |
| 135 | 143 | if (empty($conf->global->MAIN_MENU_INVERT)) |
| 136 | 144 | { |
| 137 | - if ($mode == 'top') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
| 138 | - if ($mode == 'left') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
| 139 | - } |
|
| 140 | - else |
|
| 145 | + if ($mode == 'top') { |
|
| 146 | + print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
| 147 | + } |
|
| 148 | + if ($mode == 'left') { |
|
| 149 | + print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
| 150 | + } |
|
| 151 | + } else |
|
| 141 | 152 | { |
| 142 | 153 | $conf->global->MAIN_SHOW_LOGO=0; |
| 143 | - if ($mode == 'top') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0); |
|
| 144 | - if ($mode == 'left') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
| 154 | + if ($mode == 'top') { |
|
| 155 | + print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0); |
|
| 156 | + } |
|
| 157 | + if ($mode == 'left') { |
|
| 158 | + print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
| 159 | + } |
|
| 145 | 160 | } |
| 146 | 161 | |
| 147 | 162 | if ($mode == 'topnb') |
@@ -150,17 +165,22 @@ discard block |
||
| 150 | 165 | return $this->menu->getNbOfVisibleMenuEntries(); |
| 151 | 166 | } |
| 152 | 167 | |
| 153 | - if ($mode == 'jmobile') // Used to get menu in xml ul/li |
|
| 168 | + if ($mode == 'jmobile') { |
|
| 169 | + // Used to get menu in xml ul/li |
|
| 154 | 170 | { |
| 155 | - print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // Fill this->menu that is empty with top menu |
|
| 171 | + print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); |
|
| 172 | + } |
|
| 173 | + // Fill this->menu that is empty with top menu |
|
| 156 | 174 | |
| 157 | 175 | // $this->menu->liste is top menu |
| 158 | 176 | //var_dump($this->menu->liste);exit; |
| 159 | 177 | $lastlevel = array(); |
| 160 | 178 | print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
| 161 | - foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
| 179 | + foreach($this->menu->liste as $key => $val) { |
|
| 180 | + // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
| 162 | 181 | { |
| 163 | 182 | print '<ul class="ulmenu" data-inset="true">'; |
| 183 | + } |
|
| 164 | 184 | print '<li class="lilevel0">'; |
| 165 | 185 | |
| 166 | 186 | if ($val['enabled'] == 1) |
@@ -173,7 +193,9 @@ discard block |
||
| 173 | 193 | print '<a class="alilevel0" href="#">'; |
| 174 | 194 | |
| 175 | 195 | // Add font-awesome |
| 176 | - if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
| 196 | + if ($val['level'] == 0 && $val['mainmenu'] == 'home') { |
|
| 197 | + print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
| 198 | + } |
|
| 177 | 199 | |
| 178 | 200 | print $val['titre']; |
| 179 | 201 | print '</a>'."\n"; |
@@ -198,12 +220,16 @@ discard block |
||
| 198 | 220 | // We add sub entry |
| 199 | 221 | print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
| 200 | 222 | print '<a href="'.$relurl.'">'; |
| 201 | - if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
|
| 223 | + if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") { |
|
| 224 | + // No translation |
|
| 202 | 225 | { |
| 203 | 226 | if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); |
| 204 | - else print $langs->trans("Dashboard"); |
|
| 227 | + } else { |
|
| 228 | + print $langs->trans("Dashboard"); |
|
| 229 | + } |
|
| 230 | + } else { |
|
| 231 | + print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
| 205 | 232 | } |
| 206 | - else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
| 207 | 233 | print '</a>'; |
| 208 | 234 | print '</li>'."\n"; |
| 209 | 235 | } |
@@ -213,22 +239,26 @@ discard block |
||
| 213 | 239 | if ($val['enabled']) |
| 214 | 240 | { |
| 215 | 241 | $lastlevel[0]='enabled'; |
| 216 | - } |
|
| 217 | - else if ($showmenu) // Not enabled but visible (so greyed) |
|
| 242 | + } else if ($showmenu) { |
|
| 243 | + // Not enabled but visible (so greyed) |
|
| 218 | 244 | { |
| 219 | 245 | $lastlevel[0]='greyed'; |
| 220 | 246 | } |
| 221 | - else |
|
| 247 | + } else |
|
| 222 | 248 | { |
| 223 | 249 | $lastlevel[0]='hidden'; |
| 224 | 250 | } |
| 225 | 251 | } |
| 226 | 252 | |
| 227 | 253 | $lastlevel2 = array(); |
| 228 | - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
| 254 | + foreach($submenu->liste as $key2 => $val2) { |
|
| 255 | + // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
| 229 | 256 | { |
| 230 | 257 | $showmenu=true; |
| 231 | - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
|
| 258 | + } |
|
| 259 | + if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) { |
|
| 260 | + $showmenu=false; |
|
| 261 | + } |
|
| 232 | 262 | |
| 233 | 263 | // If at least one parent is not enabled, we do not show any menu of all children |
| 234 | 264 | if ($val2['level'] > 0) |
@@ -236,19 +266,25 @@ discard block |
||
| 236 | 266 | $levelcursor = $val2['level']-1; |
| 237 | 267 | while ($levelcursor >= 0) |
| 238 | 268 | { |
| 239 | - if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
| 269 | + if ($lastlevel2[$levelcursor] != 'enabled') { |
|
| 270 | + $showmenu=false; |
|
| 271 | + } |
|
| 240 | 272 | $levelcursor--; |
| 241 | 273 | } |
| 242 | 274 | } |
| 243 | 275 | |
| 244 | - if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
|
| 276 | + if ($showmenu) { |
|
| 277 | + // Visible (option to hide when not allowed is off or allowed) |
|
| 245 | 278 | { |
| 246 | 279 | $relurl2=dol_buildpath($val2['url'],1); |
| 280 | + } |
|
| 247 | 281 | $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); |
| 248 | 282 | $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); |
| 249 | 283 | $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
| 250 | 284 | //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
| 251 | - if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
| 285 | + if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) { |
|
| 286 | + $relurl2=''; |
|
| 287 | + } |
|
| 252 | 288 | |
| 253 | 289 | $disabled=''; |
| 254 | 290 | if (! $val2['enabled']) |
@@ -258,30 +294,34 @@ discard block |
||
| 258 | 294 | |
| 259 | 295 | print str_pad('',$val2['level']+1); |
| 260 | 296 | print '<li class="lilevel'.($val2['level']+1); |
| 261 | - if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
| 297 | + if ($val2['level']==0) { |
|
| 298 | + print ' ui-btn-icon-right ui-btn'; |
|
| 299 | + } |
|
| 300 | + // ui-btn to highlight on clic |
|
| 262 | 301 | print $disabled.'">'; // ui-btn to highlight on clic |
| 263 | 302 | if ($relurl2) |
| 264 | 303 | { |
| 265 | - if ($val2['enabled']) // Allowed |
|
| 304 | + if ($val2['enabled']) { |
|
| 305 | + // Allowed |
|
| 266 | 306 | { |
| 267 | 307 | print '<a href="'.$relurl2.'"'; |
| 308 | + } |
|
| 268 | 309 | //print ' data-ajax="false"'; |
| 269 | 310 | print '>'; |
| 270 | 311 | $lastlevel2[$val2['level']]='enabled'; |
| 271 | - } |
|
| 272 | - else // Not allowed but visible (greyed) |
|
| 312 | + } else // Not allowed but visible (greyed) |
|
| 273 | 313 | { |
| 274 | 314 | print '<a href="#" class="vsmenudisabled">'; |
| 275 | 315 | $lastlevel2[$val2['level']]='greyed'; |
| 276 | 316 | } |
| 277 | - } |
|
| 278 | - else |
|
| 317 | + } else |
|
| 279 | 318 | { |
| 280 | - if ($val2['enabled']) // Allowed |
|
| 319 | + if ($val2['enabled']) { |
|
| 320 | + // Allowed |
|
| 281 | 321 | { |
| 282 | 322 | $lastlevel2[$val2['level']]='enabled'; |
| 283 | 323 | } |
| 284 | - else |
|
| 324 | + } else |
|
| 285 | 325 | { |
| 286 | 326 | $lastlevel2[$val2['level']]='greyed'; |
| 287 | 327 | } |
@@ -291,10 +331,12 @@ discard block |
||
| 291 | 331 | print $val2['titre']; |
| 292 | 332 | if ($relurl2) |
| 293 | 333 | { |
| 294 | - if ($val2['enabled']) // Allowed |
|
| 295 | - print '</a>'; |
|
| 296 | - else |
|
| 334 | + if ($val2['enabled']) { |
|
| 335 | + // Allowed |
|
| 297 | 336 | print '</a>'; |
| 337 | + } else { |
|
| 338 | + print '</a>'; |
|
| 339 | + } |
|
| 298 | 340 | } |
| 299 | 341 | print '</li>'."\n"; |
| 300 | 342 | } |
@@ -64,8 +64,12 @@ discard block |
||
| 64 | 64 | global $conf, $user, $langs; |
| 65 | 65 | |
| 66 | 66 | // On sauve en session le menu principal choisi |
| 67 | - if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
| 68 | - if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
| 67 | + if (isset($_GET["mainmenu"])) { |
|
| 68 | + $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
| 69 | + } |
|
| 70 | + if (isset($_GET["idmenu"])) { |
|
| 71 | + $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
| 72 | + } |
|
| 69 | 73 | |
| 70 | 74 | // Read mainmenu and leftmenu that define which menu to show |
| 71 | 75 | if (isset($_GET["mainmenu"])) |
@@ -74,13 +78,14 @@ discard block |
||
| 74 | 78 | $mainmenu=$_GET["mainmenu"]; |
| 75 | 79 | $_SESSION["mainmenu"]=$mainmenu; |
| 76 | 80 | $_SESSION["leftmenuopened"]=""; |
| 77 | - } |
|
| 78 | - else |
|
| 81 | + } else |
|
| 79 | 82 | { |
| 80 | 83 | // On va le chercher en session si non defini par le lien |
| 81 | 84 | $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; |
| 82 | 85 | } |
| 83 | - if (! empty($forcemainmenu)) $mainmenu=$forcemainmenu; |
|
| 86 | + if (! empty($forcemainmenu)) { |
|
| 87 | + $mainmenu=$forcemainmenu; |
|
| 88 | + } |
|
| 84 | 89 | |
| 85 | 90 | if (isset($_GET["leftmenu"])) |
| 86 | 91 | { |
@@ -88,12 +93,13 @@ discard block |
||
| 88 | 93 | $leftmenu=$_GET["leftmenu"]; |
| 89 | 94 | $_SESSION["leftmenu"]=$leftmenu; |
| 90 | 95 | |
| 91 | - if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse |
|
| 96 | + if ($_SESSION["leftmenuopened"]==$leftmenu) { |
|
| 97 | + // To collapse |
|
| 92 | 98 | { |
| 93 | 99 | //$leftmenu=""; |
| 94 | 100 | $_SESSION["leftmenuopened"]=""; |
| 95 | 101 | } |
| 96 | - else |
|
| 102 | + } else |
|
| 97 | 103 | { |
| 98 | 104 | $_SESSION["leftmenuopened"]=$leftmenu; |
| 99 | 105 | } |
@@ -101,7 +107,9 @@ discard block |
||
| 101 | 107 | // On va le chercher en session si non defini par le lien |
| 102 | 108 | $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; |
| 103 | 109 | } |
| 104 | - if (! empty($forceleftmenu)) $leftmenu=$forceleftmenu; |
|
| 110 | + if (! empty($forceleftmenu)) { |
|
| 111 | + $leftmenu=$forceleftmenu; |
|
| 112 | + } |
|
| 105 | 113 | |
| 106 | 114 | require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; |
| 107 | 115 | $tabMenu=array(); |
@@ -134,8 +142,12 @@ discard block |
||
| 134 | 142 | require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; |
| 135 | 143 | $this->menu=new Menu(); |
| 136 | 144 | |
| 137 | - if ($mode == 'top') print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
| 138 | - if ($mode == 'left') print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
| 145 | + if ($mode == 'top') { |
|
| 146 | + print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
| 147 | + } |
|
| 148 | + if ($mode == 'left') { |
|
| 149 | + print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
| 150 | + } |
|
| 139 | 151 | |
| 140 | 152 | if ($mode == 'topnb') |
| 141 | 153 | { |
@@ -143,17 +155,21 @@ discard block |
||
| 143 | 155 | return $this->menu->getNbOfVisibleMenuEntries(); |
| 144 | 156 | } |
| 145 | 157 | |
| 146 | - if ($mode == 'jmobile') // Used to get menu in xml ul/li |
|
| 158 | + if ($mode == 'jmobile') { |
|
| 159 | + // Used to get menu in xml ul/li |
|
| 147 | 160 | { |
| 148 | 161 | print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); |
| 162 | + } |
|
| 149 | 163 | |
| 150 | 164 | // $this->menu->liste is top menu |
| 151 | 165 | //var_dump($this->menu->liste);exit; |
| 152 | 166 | $lastlevel = array(); |
| 153 | 167 | print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
| 154 | - foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
| 168 | + foreach($this->menu->liste as $key => $val) { |
|
| 169 | + // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
| 155 | 170 | { |
| 156 | 171 | print '<ul class="ulmenu" data-inset="true">'; |
| 172 | + } |
|
| 157 | 173 | print '<li class="lilevel0">'; |
| 158 | 174 | if ($val['enabled'] == 1) |
| 159 | 175 | { |
@@ -165,7 +181,9 @@ discard block |
||
| 165 | 181 | print '<a class="alilevel0" href="#">'; |
| 166 | 182 | |
| 167 | 183 | // Add font-awesome |
| 168 | - if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
| 184 | + if ($val['level'] == 0 && $val['mainmenu'] == 'home') { |
|
| 185 | + print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
| 186 | + } |
|
| 169 | 187 | |
| 170 | 188 | print $val['titre']; |
| 171 | 189 | print '</a>'."\n"; |
@@ -188,12 +206,16 @@ discard block |
||
| 188 | 206 | // We add sub entry |
| 189 | 207 | print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
| 190 | 208 | print '<a href="'.$relurl.'">'; |
| 191 | - if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
|
| 209 | + if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") { |
|
| 210 | + // No translation |
|
| 192 | 211 | { |
| 193 | 212 | if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); |
| 194 | - else print $langs->trans("Dashboard"); |
|
| 195 | - } |
|
| 196 | - else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
| 213 | + } else { |
|
| 214 | + print $langs->trans("Dashboard"); |
|
| 215 | + } |
|
| 216 | + } else { |
|
| 217 | + print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
| 218 | + } |
|
| 197 | 219 | print '</a>'; |
| 198 | 220 | print '</li>'."\n"; |
| 199 | 221 | } |
@@ -203,22 +225,26 @@ discard block |
||
| 203 | 225 | if ($val['enabled']) |
| 204 | 226 | { |
| 205 | 227 | $lastlevel[0]='enabled'; |
| 206 | - } |
|
| 207 | - else if ($showmenu) // Not enabled but visible (so greyed) |
|
| 228 | + } else if ($showmenu) { |
|
| 229 | + // Not enabled but visible (so greyed) |
|
| 208 | 230 | { |
| 209 | 231 | $lastlevel[0]='greyed'; |
| 210 | 232 | } |
| 211 | - else |
|
| 233 | + } else |
|
| 212 | 234 | { |
| 213 | 235 | $lastlevel[0]='hidden'; |
| 214 | 236 | } |
| 215 | 237 | } |
| 216 | 238 | |
| 217 | 239 | $lastlevel2 = array(); |
| 218 | - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
| 240 | + foreach($submenu->liste as $key2 => $val2) { |
|
| 241 | + // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
| 219 | 242 | { |
| 220 | 243 | $showmenu=true; |
| 221 | - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
|
| 244 | + } |
|
| 245 | + if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) { |
|
| 246 | + $showmenu=false; |
|
| 247 | + } |
|
| 222 | 248 | |
| 223 | 249 | // If at least one parent is not enabled, we do not show any menu of all children |
| 224 | 250 | if ($val2['level'] > 0) |
@@ -226,19 +252,25 @@ discard block |
||
| 226 | 252 | $levelcursor = $val2['level']-1; |
| 227 | 253 | while ($levelcursor >= 0) |
| 228 | 254 | { |
| 229 | - if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
| 255 | + if ($lastlevel2[$levelcursor] != 'enabled') { |
|
| 256 | + $showmenu=false; |
|
| 257 | + } |
|
| 230 | 258 | $levelcursor--; |
| 231 | 259 | } |
| 232 | 260 | } |
| 233 | 261 | |
| 234 | - if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
|
| 262 | + if ($showmenu) { |
|
| 263 | + // Visible (option to hide when not allowed is off or allowed) |
|
| 235 | 264 | { |
| 236 | 265 | $relurl2=dol_buildpath($val2['url'],1); |
| 266 | + } |
|
| 237 | 267 | $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); |
| 238 | 268 | $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2); |
| 239 | 269 | $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
| 240 | 270 | //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
| 241 | - if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
| 271 | + if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) { |
|
| 272 | + $relurl2=''; |
|
| 273 | + } |
|
| 242 | 274 | |
| 243 | 275 | $disabled=''; |
| 244 | 276 | if (! $val2['enabled']) |
@@ -248,30 +280,34 @@ discard block |
||
| 248 | 280 | |
| 249 | 281 | print str_pad('',$val2['level']+1); |
| 250 | 282 | print '<li class="lilevel'.($val2['level']+1); |
| 251 | - if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
| 283 | + if ($val2['level']==0) { |
|
| 284 | + print ' ui-btn-icon-right ui-btn'; |
|
| 285 | + } |
|
| 286 | + // ui-btn to highlight on clic |
|
| 252 | 287 | print $disabled.'">'; // ui-btn to highlight on clic |
| 253 | 288 | if ($relurl2) |
| 254 | 289 | { |
| 255 | - if ($val2['enabled']) // Allowed |
|
| 290 | + if ($val2['enabled']) { |
|
| 291 | + // Allowed |
|
| 256 | 292 | { |
| 257 | 293 | print '<a href="'.$relurl2.'"'; |
| 294 | + } |
|
| 258 | 295 | //print ' data-ajax="false"'; |
| 259 | 296 | print '>'; |
| 260 | 297 | $lastlevel2[$val2['level']]='enabled'; |
| 261 | - } |
|
| 262 | - else // Not allowed but visible (greyed) |
|
| 298 | + } else // Not allowed but visible (greyed) |
|
| 263 | 299 | { |
| 264 | 300 | print '<a href="#" class="vsmenudisabled">'; |
| 265 | 301 | $lastlevel2[$val2['level']]='greyed'; |
| 266 | 302 | } |
| 267 | - } |
|
| 268 | - else |
|
| 303 | + } else |
|
| 269 | 304 | { |
| 270 | - if ($val2['enabled']) // Allowed |
|
| 305 | + if ($val2['enabled']) { |
|
| 306 | + // Allowed |
|
| 271 | 307 | { |
| 272 | 308 | $lastlevel2[$val2['level']]='enabled'; |
| 273 | 309 | } |
| 274 | - else |
|
| 310 | + } else |
|
| 275 | 311 | { |
| 276 | 312 | $lastlevel2[$val2['level']]='greyed'; |
| 277 | 313 | } |
@@ -279,10 +315,12 @@ discard block |
||
| 279 | 315 | print $val2['titre']; |
| 280 | 316 | if ($relurl2) |
| 281 | 317 | { |
| 282 | - if ($val2['enabled']) // Allowed |
|
| 283 | - print '</a>'; |
|
| 284 | - else |
|
| 318 | + if ($val2['enabled']) { |
|
| 319 | + // Allowed |
|
| 285 | 320 | print '</a>'; |
| 321 | + } else { |
|
| 322 | + print '</a>'; |
|
| 323 | + } |
|
| 286 | 324 | } |
| 287 | 325 | print '</li>'."\n"; |
| 288 | 326 | } |