noalyss Version-9
profile_menu.class.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19// Copyright Author Dany De Bontridder danydb@aevalys.eu
20
21require_once NOALYSS_INCLUDE.'/database/profile_menu_sql.class.php';
22
23/**
24 * @file
25 * @brief Manage the menu of a profile
26 *
27 * @author dany
28 */
29/**
30 * @class Profile_Menu
31 * @brief Manage the menu of a profile
32 */
34{
35
36
37 function __construct($p_cn, $p_id=-1)
38 {
39 $this->cn=$p_cn;
40 parent::__construct($p_cn, $p_id);
41 }
42
43 /**
44 * @brief Display the content of a profile menu for printing
45 * @param type $resource
46 * @param type $p_id
47 */
48 function sub_menu($resource, $p_id)
49 {
50 if (Database::num_row($resource)!=0)
51 {
52 ////
53 // If there are submenus
55 echo '<td>';
56 for ($e=0; $e<Database::num_row($resource); $e++)
57 {
58 $menu=Database::fetch_array($resource, $e);
59 $me_code=$menu['me_code'];
60
61 $me_code_dep=$menu['me_code_dep'];
62
63 $mp_type=$menu['p_type_display'];
64
65 $me_menu=$menu['me_menu'];
66 $me_desc=$menu['me_description'];
67 $me_def=($menu['pm_default']=='1')?'<span class="notice" style="display:inline">Défaut</span>':'';
68 ?>
69 <li id="sub<?php echo $menu['pm_id'] ?>">
70
71 <?php echo $me_code ?>
72 <?php echo $me_menu ?>
73 <?php echo $me_desc ?> <?php echo $me_def ?>
74 <?php $ret2=$this->cn->exec_sql("
75 SELECT pm_id,
76 pm.me_code,
77 me_code_dep,
78 p_id,
79 p_order,
80 p_type_display,
81 pm_default,
82 pm_desc,
83 me_menu,
84 me_description
85 FROM profile_menu as pm
86 join profile_menu_type on (p_type_display=pm_type)
87 join menu_ref as mr on (mr.me_code=pm.me_code)
88 where
89 p_id=$1 and me_code_dep=$2
90 order by p_order asc
91 ", array($p_id, $me_code)); ?>
92 <span>
93 <?php
94 echo Icon_Action::trash(uniqid(), sprintf (" remove_sub_menu(%d,%d)", Dossier::id(),
95 $menu['pm_id']))
96 ?>
97 </span>
98 <?php
99 echo "</li>";
100 } //end loop e
101 echo '</ul>';
102 } // end if
103 }
104
105 /**
106 * @brief Show a table with all the menu and the type
107 * @param type $p_id profile.p_id
108 */
110 {
111 $a_module=$this->cn->get_array("
112 SELECT pm_id,
113 pm.me_code,
114 me_code_dep,
115 p_id,
116 p_order,
117 p_type_display,
118 pm_default,
119 pm_desc,
120 me_menu,
121 me_description,
122 me_url,
123 me_file,
124 me_javascript
125 FROM profile_menu as pm
126 join profile_menu_type on (p_type_display=pm_type)
127 join menu_ref as mr on (mr.me_code=pm.me_code)
128 where
129 p_id=$1 and p_type_display='M'
130 order by p_order asc
131 ", array($this->p_id));
132 ////////////////////////////////////////////////////////////
133 // With a module
134 ////////////////////////////////////////////////////////////
136
137 //*******************************************
138 // show also menu without a module
139 //*******************************************
140 $ret=$this->cn->exec_sql("
141 SELECT pm_id,
142 pm.me_code,
143 me_code_dep,
144 p_id,
145 p_order,
146 p_type_display,
147 pm_default,
148 pm_desc,
149 me_menu,
150 me_description
151 FROM profile_menu as pm
152 join profile_menu_type on (p_type_display=pm_type)
153 join menu_ref as mr on (mr.me_code=pm.me_code)
154 where
155 p_id=$1 and p_type_display not in ('M','P') and me_code_dep is null
156 order by p_order asc
157 ", array($this->p_id));
158 }
159
160 /**
161 * @brief Display the module, with a javascript inside to show the menu
162 * contained in the module
163 * Used for setting the configuration
164 * @param $ap_module $array of module received from display_profile_menu_detail
165 * @see Profile_menu::display_profile_menu_detail
166 */
167 function display_module($ap_module)
168 {
169 include NOALYSS_TEMPLATE.'/profile_menu_display_module.php';
170 }
171
172 /**
173 * @brief Display all menu and submenu of a module.
174 * @see display_profile_module
175 *
176 */
177 function display_module_menu($p_module_id, $p_level)
178 {
179 // Get the submenu
180 $a_module=$this->cn->get_array('
181 SELECT pm_id,
182 me_code,
183 me_code_dep,
184 p_id,
185 p_order,
186 p_type_display,
187 pm_default,
188 me_menu,
189 me_file,
190 me_url,
191 me_javascript,
192 me_parameter,
193 me_description
194 FROM profile_menu
195 join menu_ref using (me_code)
196 where
197 p_id = $1 and
198 pm_id_dep = $2 order by p_order',
199 array($this->p_id, $p_module_id));
200 require NOALYSS_TEMPLATE.'/profile_menu_display_submenu.php';
201 }
202
203 /**
204 * display all the accessible export of a profile $p_id
205 * @param type $p_id profile.p_id
206 */
207 function printing()
208 {
209 $ret=$this->cn->exec_sql("
210 SELECT pm_id,
211 pm.me_code,
212 me_code_dep,
213 p_id,
214 p_order,
215 p_type_display,
216 pm_default,
217 pm_desc,
218 me_menu,
219 me_description
220 FROM profile_menu as pm
221 join profile_menu_type on (p_type_display=pm_type)
222 join menu_ref as mr on (mr.me_code=pm.me_code)
223 where
224 p_id=$1 and me_type='PR'
225 order by p_order asc
226 ", array($this->p_id));
227 // Menu by module
229 $this->sub_menu($ret, $this->p_id);
230 }
231
232 /**
233 * @brief Show the available profile for the profile $p_id, it concerns only the action of management (action-gestion)
234 * @param $p_id is the profile p_id
235 */
237 {
238 $array=$this->cn->get_array("
239 select p.p_id,p.p_name,s.p_granted,s.ua_id,s.ua_right
240 from profile as p
241 join user_sec_action_profile as s on (s.p_granted=p.p_id)
242 where s.p_id=$1
243 union
244 select p2.p_id, p2.p_name,null,null,'X'
245 from profile as p2
246 where
247 p2.p_id not in (select p_granted from user_sec_action_profile where p_id = $1) order by p_name;
248 ", array($this->p_id));
249 $aright_value=array(
250 array('value'=>'R', 'label'=>_('Lecture')),
251 array('value'=>'W', 'label'=>_('Ecriture et suppression')),
252 array('value'=>'O', 'label'=>_('Ecriture')),
253 array('value'=>'X', 'label'=>_('Aucun accès'))
254 );
255 require_once NOALYSS_TEMPLATE.'/user_sec_profile.php';
256 }
257
258 /**
259 * @brief Show the available repository for the profile $p_id
260 * @param $p_id is the profile p_id
261 */
263 {
264 $array=$this->cn->get_array("
265 select p.r_id,p.r_name,s.ur_id,s.ur_right
266 from stock_repository as p
267 join profile_sec_repository as s on (s.r_id=p.r_id)
268 where s.p_id=$1
269 union
270 select p2.r_id, p2.r_name,null,'X'
271 from stock_repository as p2
272 where
273 p2.r_id not in (select r_id from profile_sec_repository where p_id = $1) order by r_name;
274 ", array($this->p_id));
275 $aright_value=array(
276 array('value'=>'R', 'label'=>_('Lecture')),
277 array('value'=>'W', 'label'=>_('Ecriture')),
278 array('value'=>'X', 'label'=>_('Aucun accès'))
279 );
280 require_once NOALYSS_TEMPLATE.'/profile_sec_repository.php';
281 }
282 /**
283 * @brief menu for device
284 */
285 function mobile_device() {
287 $profile_mobile->display_table("where p_id=$1 order by pmo_order",[ $this->p_id ]);
288 echo create_script("profile_menu_mtable.param_add({profile_id:{$this->p_id}});");
289 }
290
291 }
292
293 //end class
294 ?>
span($p_string, $p_extra='')
Definition: ac_common.php:43
$p_level
$profile p_id
$input_from cn
Definition: balance.inc.php:66
$input_from id
Definition: balance.inc.php:63
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
static id()
return the 'gDossier' value after a check
static trash($p_id, $p_javascript)
Display the icon of a trashbin.
static build($p_id, $profile_id)
Manage the table public.profile_menu.
Manage the menu of a profile.
available_repository()
Show the available repository for the profile $p_id.
__construct($p_cn, $p_id=-1)
display_profile_menu_detail()
Show a table with all the menu and the type.
sub_menu($resource, $p_id)
Display the content of a profile menu for printing.
display_module($ap_module)
Display the module, with a javascript inside to show the menu contained in the module Used for settin...
available_profile()
Show the available profile for the profile $p_id, it concerns only the action of management (action-g...
printing()
display all the accessible export of a profile $p_id
display_module_menu($p_module_id, $p_level)
Display all menu and submenu of a module.
mobile_device()
menu for device
create_script($p_string)
create the HTML for adding the script tags around of the script
$profile_mobile
$a_module[$i]['p_order']