@@ -15,6 +15,7 @@ class linkedobject extends module
1515{
1616 var $ property_field ;
1717 var $ method_field ;
18+
1819 /**
1920 * linkedobject
2021 *
@@ -40,16 +41,16 @@ function __construct()
4041 function saveParams ($ data = 0 )
4142 {
4243 $ p = array ();
43- if (IsSet ($ this ->id )) {
44+ if (isset ($ this ->id )) {
4445 $ p ["id " ] = $ this ->id ;
4546 }
46- if (IsSet ($ this ->view_mode )) {
47+ if (isset ($ this ->view_mode )) {
4748 $ p ["view_mode " ] = $ this ->view_mode ;
4849 }
49- if (IsSet ($ this ->edit_mode )) {
50+ if (isset ($ this ->edit_mode )) {
5051 $ p ["edit_mode " ] = $ this ->edit_mode ;
5152 }
52- if (IsSet ($ this ->tab )) {
53+ if (isset ($ this ->tab )) {
5354 $ p ["tab " ] = $ this ->tab ;
5455 }
5556 return parent ::saveParams ($ p );
@@ -102,10 +103,10 @@ function run()
102103 } else {
103104 $ this ->usual ($ out );
104105 }
105- if (IsSet ($ this ->owner ->action )) {
106+ if (isset ($ this ->owner ->action )) {
106107 $ out ['PARENT_ACTION ' ] = $ this ->owner ->action ;
107108 }
108- if (IsSet ($ this ->owner ->name )) {
109+ if (isset ($ this ->owner ->name )) {
109110 $ out ['PARENT_NAME ' ] = $ this ->owner ->name ;
110111 }
111112
@@ -122,9 +123,9 @@ function run()
122123 }
123124
124125 if (isset ($ this ->width )) {
125- $ ifPX = substr ($ this ->width , -1 );
126- if ($ ifPX != 'x ' && $ ifPX != '% ' ) $ this ->width = $ this ->width . 'px ' ;
127-
126+ $ ifPX = substr ($ this ->width , -1 );
127+ if ($ ifPX != 'x ' && $ ifPX != '% ' ) $ this ->width = $ this ->width . 'px ' ;
128+
128129 $ out ['WIDTH ' ] = $ this ->width ;
129130 } else {
130131 $ out ['WIDTH ' ] = '90% ' ;
@@ -137,8 +138,13 @@ function run()
137138 }
138139
139140 if ($ op == 'redirect ' ) {
140- global $ object ;
141- global $ sub ;
141+ $ device_id = gr ('device_id ' , 'int ' );
142+ if ($ device_id ) {
143+ redirect (ROOTHTML . 'panel/devices/ ' . $ device_id . '.html?tab=settings ' );
144+ }
145+
146+ $ object = gr ('object ' );
147+ $ sub = gr ('sub ' );
142148 if (!$ object ) {
143149 redirect (ROOTHTML );
144150 }
@@ -162,7 +168,7 @@ function run()
162168 for ($ i = 0 ; $ i < $ total ; $ i ++) {
163169 $ res [] = $ tmp [$ i ];
164170 }
165- $ res []= array ('ID ' => 'scripts ' ,'TITLE ' => 'AllScripts ' ,'DESCRIPTION ' => LANG_SCRIPTS );
171+ $ res [] = array ('ID ' => 'scripts ' , 'TITLE ' => 'AllScripts ' , 'DESCRIPTION ' => LANG_SCRIPTS );
166172 $ res ['OBJECTS ' ] = $ res ;
167173
168174 //$tmp=SQLSelectOne("SELECT TITLE FROM objects ORDER BY ID DESC LIMIT 1");
@@ -177,8 +183,11 @@ function run()
177183 $ properties = array ();
178184 do {
179185 if (!$ object ) break ;
180- if ($ object== 'AllScripts ' ) break ;
186+ if ($ object == 'AllScripts ' ) break ;
181187 $ obj = getObject ($ object );
188+ if ($ obj ->device_id ) {
189+ $ res ['DEVICE_ID ' ] = $ obj ->device_id ;
190+ }
182191 if (!$ obj ) break ;
183192 $ parent_properties = $ obj ->getParentProperties ($ obj ->class_id , '' , 1 );
184193 if ($ parent_properties && is_array ($ parent_properties )) {
@@ -203,8 +212,8 @@ function run()
203212 $ properties = array ();
204213 do {
205214 if (!$ object ) break ;
206- if ($ object== 'AllScripts ' ) {
207- $ properties= SQLSelect ("SELECT TITLE FROM scripts ORDER BY TITLE " );
215+ if ($ object == 'AllScripts ' ) {
216+ $ properties = SQLSelect ("SELECT TITLE FROM scripts ORDER BY TITLE " );
208217 break ;
209218 }
210219 $ obj = getObject ($ object );
@@ -238,36 +247,39 @@ function run()
238247 }
239248
240249 if ($ this ->object_field ) {
241- $ objects = SQLSelect ("SELECT objects.CLASS_ID, objects.TITLE, objects.DESCRIPTION, classes.TITLE AS CLASS_NAME FROM objects JOIN classes WHERE CLASS_ID=classes.ID ORDER BY CLASS_ID, TITLE " );
250+ $ objects = SQLSelect ("SELECT objects.CLASS_ID, objects.TITLE, objects.DESCRIPTION, classes.TITLE AS CLASS_NAME FROM objects JOIN classes ON CLASS_ID=classes.ID ORDER BY CLASS_ID, TITLE " );
242251
243- $ objects []= array ('ID ' => 'scripts ' ,'TITLE ' => 'AllScripts ' ,'DESCRIPTION ' => LANG_SCRIPTS );
252+ $ objects [] = array ('ID ' => 'scripts ' , 'TITLE ' => 'AllScripts ' , 'DESCRIPTION ' => LANG_SCRIPTS );
244253
245254 $ total = count ($ objects );
246- $ old_class_id= 0 ;
255+ $ old_class_id = 0 ;
247256
248- $ list_result= '' ;
257+ $ list_result = '' ;
249258
250259 if ($ total ) {
251- $ objects [0 ]['FIRST ' ]= 1 ;
252- $ objects [$ total- 1 ]['LAST ' ]= 1 ;
253- for ($ i= 0 ; $ i < $ total ;$ i ++) {
254- if (isset ($ objects [$ i ]['CLASS_ID ' ]) && $ objects [$ i ]['CLASS_ID ' ]!= $ old_class_id ) {
255- $ objects [$ i ]['NEW_GROUP ' ]= 1 ;
256- $ old_class_id= $ objects [$ i ]['CLASS_ID ' ];
257- if ($ i> 0 ) {
258- $ list_result.= '</optgroup> ' ;
260+ $ objects [0 ]['FIRST ' ] = 1 ;
261+ $ objects [$ total - 1 ]['LAST ' ] = 1 ;
262+ for ($ i = 0 ; $ i < $ total ; $ i ++) {
263+ if (isset ($ objects [$ i ]['CLASS_ID ' ]) && $ objects [$ i ]['CLASS_ID ' ] != $ old_class_id ) {
264+ $ objects [$ i ]['NEW_GROUP ' ] = 1 ;
265+ $ old_class_id = $ objects [$ i ]['CLASS_ID ' ];
266+ if ($ i > 0 ) {
267+ $ list_result .= '</optgroup> ' ;
259268 }
260- $ list_result.= '<optgroup label=" ' . $ objects [$ i ]['CLASS_NAME ' ]. '"> ' ;
269+ $ list_result .= '<optgroup label=" ' . $ objects [$ i ]['CLASS_NAME ' ] . '"> ' ;
261270 }
262- $ list_result .='<option value=" ' .$ objects [$ i ]['TITLE ' ].'"> ' .$ objects [$ i ]['TITLE ' ];
263- if ($ objects [$ i ]['DESCRIPTION ' ]!='' ) {
264- $ list_result .=' - ' .$ objects [$ i ]['DESCRIPTION ' ];
271+
272+ $ value = $ objects [$ i ]['TITLE ' ];
273+ $ list_result .= '<option value=" ' . $ value . '"> ' ;
274+ $ list_result .= $ objects [$ i ]['TITLE ' ];
275+ if ($ objects [$ i ]['DESCRIPTION ' ] != '' ) {
276+ $ list_result .= ' - ' . $ objects [$ i ]['DESCRIPTION ' ];
265277 }
266- $ list_result.= '</option> ' ;
278+ $ list_result .= '</option> ' ;
267279 }
268- $ list_result.= '</optgroup> ' ;
280+ $ list_result .= '</optgroup> ' ;
269281 }
270- $ out ['OBJECTS_LIST_RESULT ' ]= $ list_result ;
282+ $ out ['OBJECTS_LIST_RESULT ' ] = $ list_result ;
271283
272284 /*
273285 foreach($objects as $key => $object) {
@@ -283,12 +295,11 @@ function run()
283295 }
284296 }
285297 */
286-
287298
288- //echo '<pre>';
289- //var_dump($objects);
290- //die();
291299
300+ //echo '<pre>';
301+ //var_dump($objects);
302+ //die();
292303
293304
294305 $ out ['OBJECTS ' ] = $ objects ;
0 commit comments