Issues (1177)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

application/modules/admin/components.php (10 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
use CMSFactory\Events;
4
5
if (!defined('BASEPATH')) {
6
    exit('No direct script access allowed');
7
}
8
9
/**
10
 * Image CMS
11
 * Components Class
12
 * @property Cms_hooks $cms_hooks
13
 * @property Lib_admin $lib_admin
14
 */
15
class Components extends BaseAdminController
16
{
17
18
    /**
19
     * array of installed modules
20
     * @var array
21
     */
22
    private $installed = [];
23
24
    /**
25
     * @var array
26
     */
27
    private $permited = [];
28
29 View Code Duplication
    public function __construct() {
30
        parent::__construct();
31
32
        $this->load->library('DX_Auth');
33
34
        admin_or_redirect();
35
36
        $this->load->library('lib_admin');
37
        $this->lib_admin->init_settings();
38
        $this->setInstalled();
39
        $this->setPermited();
40
    }
41
42
    public function index() {
43
        $this->modules_table();
44
    }
45
46
    public function modules_table() {
47
        $not_installed = [];
48
49
        $fs_modules = $this->find_components();
50
        $db_modules = $this->db->order_by('position', 'asc')->not_like('identif', 'payment_method_')->get('components')->result_array();
51
52
        // Find not installed modules
53
        $count = count($fs_modules);
54
        for ($i = 0; $i < $count; $i++) {
55
            if ($this->is_installed($fs_modules[$i]['com_name']) == 0) {
56
                $info = $this->get_module_info($fs_modules[$i]['com_name']);
57
58
                $fs_modules[$i]['name'] = $info['menu_name'];
59
                $fs_modules[$i]['version'] = $info['version'];
60
                $fs_modules[$i]['description'] = $info['description'];
61
                $fs_modules[$i]['icon_class'] = $info['icon_class'];
62
63
                array_push($not_installed, $fs_modules[$i]);
64
            }
65
        }
66
67
        // process modules info
68
        $count = count($db_modules);
69
        for ($i = 0; $i < $count; $i++) {
70
            $module_name = $db_modules[$i]['name'];
71
            if ($this->module_exists($module_name)) {
72
73
                $info = $this->get_module_info($module_name);
74
                $db_modules[$i]['menu_name'] = $info['menu_name'];
75
                $db_modules[$i]['version'] = $info['version'];
76
                $db_modules[$i]['description'] = $info['description'];
77
                $db_modules[$i]['icon_class'] = $info['icon_class'];
78
                $db_modules[$i]['identif'] = $db_modules[$i]['identif'];
79
                $modulePath = getModulePath($module_name);
80
                if (file_exists($modulePath . 'admin.php')) {
81
                    $db_modules[$i]['admin_file'] = 1;
82
                } else {
83
                    $db_modules[$i]['admin_file'] = 0;
84
                }
85
            } else {
86
                unset($db_modules[$i]);
87
            }
88
        }
89
90
        if (MAINSITE != '') {
91
            list($db_modules, $not_installed) = $this->isPermitedModules($db_modules, $not_installed);
92
        }
93
94
        Events::create()->registerEvent(
95
            [
96
             'installed'     => $db_modules,
97
             'not_installed' => $not_installed,
98
            ],
99
            'Components:modules_table'
100
        )->runFactory();
101
102
        $frozen_autoload = [
103
                            'template_manager',
104
                            'admin_menu',
105
                            'xbanners',
106
                            'menu',
107
                            'cmsemail',
108
                            'shop',
109
                           ];
110
        $frozen_delete = [
111
                          'template_manager',
112
                          'admin_menu',
113
                          'xbanners',
114
                          'menu',
115
                          'cmsemail',
116
                          'shop',
117
                          'mod_discount',
118
                          'auth',
119
                         ];
120
121
        $this->template->assign('frozen_autoload', $frozen_autoload);
122
        $this->template->assign('frozen_delete', $frozen_delete);
123
        $this->template->assign('installed', $db_modules);
124
        $this->template->assign('not_installed', $not_installed);
125
        $this->template->show('module_table', FALSE);
126
    }
127
128
    /**
129
     * @param string $moduleName
130
     * @return bool
131
     */
132
    private function isNotPermited($moduleName) {
133
        if (MAINSITE != '') {
134
            return !in_array($moduleName, $this->permited);
135
        } else {
136
            return FALSE;
137
        }
138
    }
139
140
    /**
141
     * @param array $db_modules
142
     * @param array $not_installed
143
     * @return array
0 ignored issues
show
Consider making the return type a bit more specific; maybe use array[].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
144
     */
145
    private function isPermitedModules($db_modules, $not_installed) {
146
        foreach ($db_modules as $key => $db_module) {
147
            if ($this->isNotPermited($db_module['name'])) {
148
                unset($db_modules[$key]);
149
            }
150
        }
151
        foreach ($not_installed as $key => $db_module) {
152
            if ($this->isNotPermited($db_module['com_name'])) {
153
                unset($not_installed[$key]);
154
            }
155
        }
156
        return [
157
                $db_modules,
158
                $not_installed,
159
               ];
160
    }
161
162
    private function setInstalled() {
163
        $installed = $this->db->select('name')->get('components')->result_array();
164
        $this->installed = array_column($installed, 'name');
165
    }
166
167
    private function setPermited() {
168
        if (MAINSITE != '' and $this->load->module('mainsaas')) {
169
            $this->permited = $this->load->module('mainsaas')->getNotPermited();
170
            $this->permited = array_map('trim', $this->permited);
171
        }
172
    }
173
174
    /**
175
     * @param $mod_name
176
     * @return bool
177
     */
178
    public function is_installed($mod_name) {
179
        return in_array($mod_name, $this->installed);
180
    }
181
182
    public function install($module = '') {
183
        //cp_check_perm('module_install');
184
185
        $module = strtolower($module);
186
187
        ($hook = get_hook('admin_install_module')) ? eval($hook) : NULL;
0 ignored issues
show
The call to get_hook() has too many arguments starting with 'admin_install_module'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
188
189
        $modulePath = getModulePath($module);
190
191
        if (file_exists($modulePath . $module . '.php') AND $this->is_installed($module) === false) {
192
            // Make module install
193
            $data = [
194
                     'name'    => $module,
195
                     'identif' => $module,
196
                    ];
197
198
            $this->db->insert('components', $data);
199
200
            if ($this->db->_error_message()) {
201
                echo json_encode(['result' => false]);
202
203
                $this->lib_admin->log($this->db->_error_message() . ' ' . $data['name']);
204
                return false;
205
            }
206
207
            $this->load->module($module);
208
209
            if (method_exists($module, '_install') === TRUE) {
210
                $this->$module->_install();
211
            }
212
213
            // Update hooks
214
            $this->load->library('cms_hooks');
215
            $this->cms_hooks->build_hooks();
216
217
            $this->lib_admin->log(lang('Installed a module', 'admin') . ' ' . $data['name']);
218
219 View Code Duplication
            if ($this->input->server('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest') {
220
                $result = true;
221
                echo json_encode(['result' => $result]);
222
            } else {
223
                return TRUE;
224
            }
225 View Code Duplication
        } else {
226
            if ($this->input->server('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest') {
227
                $result = true;
228
                echo json_encode(['result' => $result]);
229
            } else {
230
                return FALSE;
231
            }
232
        }
233
    }
234
235
    /**
236
     * @param string $moduleName
237
     * @return bool
0 ignored issues
show
Should the return type not be boolean|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
238
     */
239
    public function deinstall($moduleName) {
240
        $modules = $this->input->post('ids') ?: [$moduleName];
241
242
        foreach ($modules as $module) {
243
            $module = strtolower($module);
244
245
            ($hook = get_hook('admin_deinstall_module')) ? eval($hook) : NULL;
0 ignored issues
show
The call to get_hook() has too many arguments starting with 'admin_deinstall_module'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
246
247
            $modulePath = getModulePath($module);
248
249
            if (file_exists($modulePath . $module . '.php') AND $this->is_installed($module) === true) {
250
                $this->load->module($module);
251
252
                if (method_exists($module, '_deinstall') === TRUE) {
253
                    $this->$module->_deinstall();
254
                }
255
256
                $this->db->limit(1);
257
                $this->db->delete('components', ['name' => $module]);
258
                $this->lib_admin->log(lang('Deleted a module', 'admin') . ' ' . $module);
259
                if (PHP_SAPI == 'cli') {
260
                    return true;
261
                }
262
                showMessage(lang('The module successfully uninstall', 'admin'));
263
                pjax('/admin/components/modules_table');
264
            } else {
265
                if (PHP_SAPI == 'cli') {
266
                    return false;
267
                }
268
                showMessage(lang('Module deletion error', 'admin'), false, 'r');
269
                pjax('/admin/components/modules_table');
270
            }
271
272
            // Update hooks
273
            $this->load->library('cms_hooks');
274
            $this->cms_hooks->build_hooks();
275
        }
276
    }
277
278
    /**
279
     * Check is module exists
280
     * @param string $module_name module name
281
     * @return boolean
282
     */
283
    public function module_exists($module_name) {
284
        return moduleExists($module_name);
285
    }
286
287
    public function find_components($in_menu = FALSE) {
288
        $components = [];
289
        if ($in_menu == TRUE) {
290
            $this->db->where('in_menu', 1);
291
        }
292
        $this->db->not_like('identif', 'payment_method_');
293
        $installed = $this->db->get('components')->result_array();
294
295
        $modulesPaths = getModulesPaths();
296
        foreach ($modulesPaths as $moduleName => $modulePath) {
297
298
            $info_file = $modulePath . 'module_info.php';
299
            $com_file_admin = $modulePath . 'admin.php';
300
301
            $lang = new MY_Lang();
302
            $lang->load($moduleName);
303
304
            if (file_exists($info_file)) {
305
                include $info_file;
306
307
                if (file_exists($com_file_admin)) {
308
                    $admin_file = 1;
309
                } else {
310
                    $admin_file = 0;
311
                }
312
313
                $ins = FALSE;
314
315
                foreach ($installed as $k) {
316
                    if ($k['name'] == $moduleName) {
317
                        $ins = TRUE;
318
                    }
319
                }
320
321
                $new_com = [
322
                            'menu_name'  => $com_info['menu_name'],
0 ignored issues
show
The variable $com_info does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
323
                            'com_name'   => $moduleName,
324
                            'admin_file' => $admin_file,
325
                            'installed'  => $ins,
326
                            'type'       => $com_info['type'],
327
                           ];
328
329
                array_push($components, $new_com);
330
            }
331
        }
332
        return $components;
333
    }
334
335
    /**
336
     * Get components which show in menu and have admin.php
337
     * @return array|boolean
338
     */
339
    public function find_components_for_menu_list() {
340
        /** Get all components which show in menu */
341
        $components = $this->db->where('in_menu', 1);
342
343
        if (MAINSITE) {
344
            $components = $components->order_by('name', 'asc');
345
        } else {
346
            $components = $components->order_by('position', 'asc');
347
        }
348
349
        $components = $components->get('components')
350
            ->result_array();
351
352
        if (MAINSITE != '') {
353
            $components = $this->isPermitedModules($components, []);
354
            $components = $components[0];
355
        }
356
        /*         * If not components for show in menu */
357
        if (!$components) {
358
            return false;
359
        } else {
360
            /** Delete components which not have admin.php */
361
            foreach ($components as $key => $value) {
362
                if (!file_exists(getModulePath($value['name']) . 'admin.php')) {
363
                    unset($components[$key]);
364
                } else {
365
                    $info_file = getModulePath($value['name']) . 'module_info.php';
366
                    $lang = new MY_Lang();
367
                    $lang->load($value['name']);
368
369
                    if (file_exists($info_file)) {
370
                        include $info_file;
371
                        $components[$key]['type'] = $com_info['type'];
0 ignored issues
show
The variable $com_info does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
372
                        $components[$key] = array_merge($components[$key], $com_info);
373
                    }
374
                }
375
            }
376
        }
377
        return $components;
378
    }
379
380
    /**
381
     * @param string $component
382
     */
383
    public function component_settings($component) {
384
385
        $this->db->where('name', $component);
386
        $query = $this->db->get('components', 1);
387
388
        if ($query->num_rows() == 1) {
389
            $com = $query->row_array();
390
            $this->template->add_array($com);
391
        } else {
392
            $this->template->assign('com_name', $component);
393
            $this->template->assign('identif', $component);
394
            $this->template->assign('status', 0);
395
        }
396
397
        $this->template->show('component_settings', FALSE);
398
    }
399
400
    /**
401
     * Save component settings
402
     * @param string $component
403
     */
404
    public function save_settings($component) {
405
        //cp_check_perm('module_admin');
406
407
        $this->db->where('name', $component);
408
        $query = $this->db->get('components', 1);
409
410
        $com = $query->row_array();
411
412
        ($hook = get_hook('admin_component_save_settings')) ? eval($hook) : NULL;
0 ignored issues
show
The call to get_hook() has too many arguments starting with 'admin_component_save_settings'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
413
414
        if ($query->num_rows() >= 1) {
415
            $data = [
416
                     'enabled'  => (int) $this->input->post('status'),
417
                //'identif' => $this->input->post('identif'),
418
                     'identif'  => $com['name'],
419
                     'autoload' => (int) $this->input->post('autoload'),
420
                     'in_menu'  => (int) $this->input->post('in_menu'),
421
                    ];
422
423
            $this->db->where('name', $component);
424
            $this->db->update('components', $data);
425
426
            $this->lib_admin->log(lang('Changed the module settings', 'admin') . ' ' . $com['name']);
427
        }
428
429
        jsCode("ajax_div('modules_table',base_url + 'admin/components/modules_table/');");
430
    }
431
432
    /**
433
     * @param string $module
434
     */
435
    private function checkPerm($module) {
436
        if ($this->isNotPermited($module)) {
437
            $msg = count($this->permited) ? lang('Error checking permissions') : lang('Please wait for a few minutes. Your configuration file is being created.');
438
            die($msg);
439
        }
440
    }
441
442
    /**
443
     * Load component admin class in iframe/xhr
444
     * @param string $module
445
     */
446
    public function init_window($module) {
447
        $this->checkPerm($module);
448
        $lang = new MY_Lang();
449
        $lang->load($module);
450
451
        // buildWindow($id,$title,$contentURL,$width,$height,$method = 'iframe')
452
        //$module = $this->input->post('component');
453
        $info_file = getModulePath($module) . 'module_info.php';
454
455
        if (file_exists($info_file)) {
456
            include_once $info_file;
457
458
            switch ($com_info['admin_type']) {
0 ignored issues
show
The variable $com_info does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
459
                case 'window':
460
                    //buildWindow($module . '_window', lang('Module','admin') . ': ' . $com_info['menu_name'], site_url('admin/components/cp/' . $module), $com_info['w'], $com_info['h'], $com_info['window_type']);
461
                    //pjax('/admin/components/cp/'.$module, '.row-fluid');
462
                    $this->cp($module);
463
                    break;
464
465
                case 'inside':
466
                    //pjax('/admin/components/cp/'.$module, '.row-fluid');
467
                    $this->cp($module);
468
                    //updateDiv('page', site_url('admin/components/cp/' . $module));
469
                    break;
470
            }
471
        }
472
    }
473
474
    /**
475
     * @param string $module
476
     */
477
    public function cp($module) {
478
        $this->checkPerm($module);
479
        $func = $this->uri->segment(5);
480
481
        if ($func == FALSE) {
482
            $func = 'index';
483
        }
484
485
        $this->load->module('core/core');
486
        $args = $this->core->grab_variables(6);
487
488
        $this->template->assign('SELF_URL', site_url('admin/components/cp/' . $module));
489
490
        //echo '<div id="' . $module . '_module_block">' . modules::run($module . '/admin/' . $func, $args) . '</div>';
491
        echo modules::run($module . '/admin/' . $func, $args);
492
493
        //ajax_links($module);
494
    }
495
496
    /**
497
     * @param string $module
498
     */
499
    public function run($module) {
500
        $this->checkPerm($module);
501
502
        $func = $this->uri->segment(5);
503
        if ($func == FALSE) {
504
            $func = 'index';
505
        }
506
507
        ($hook = get_hook('admin_run_module_admin')) ? eval($hook) : NULL;
0 ignored issues
show
The call to get_hook() has too many arguments starting with 'admin_run_module_admin'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
508
509
        $this->load->module('core/core');
510
        $args = $this->core->grab_variables(6);
511
512
        $this->template->assign('SELF_URL', site_url('admin/components/cp/' . $module));
513
514
        echo modules::run($module . '/admin/' . $func, $args);
515
    }
516
517
    public function com_info() {
518
        $com_info = $this->get_module_info($this->input->post('component'));
519
520
        if ($com_info != FALSE) {
521
            $info_text = '<h1>' . $com_info['menu_name'] . '</h1><p>' . $com_info['description'] . '</p><p><b>' . lang('Author', 'admin') . '</b> ' . $com_info['author'] . '<br/><b>' . lang('Version ', 'admin') . '</b> ' . $com_info['version'] . '</p>';
522
523
            jsCode("alertBox.info('" . $info_text . "');");
524
        } else {
525
            showMessage(lang("Can't load module info file", 'admin'), false . 'r');
526
        }
527
    }
528
529
    /**
530
     * @param $mod_name
531
     * @return bool|string
532
     */
533
    public function get_module_info($mod_name) {
534
        $info_file = getModulePath($mod_name) . 'module_info.php';
535
        $lang = new MY_Lang();
536
        $lang->load($mod_name);
537
        if (file_exists($info_file)) {
538
            include $info_file;
539
            return $com_info;
0 ignored issues
show
The variable $com_info does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
540
        } else {
541
            return FALSE;
542
        }
543
    }
544
545
    public function change_autoload() {
546
        if ($this->input->post('mid')) {
547
            $mid = $this->input->post('mid');
548
            $row = $this->db->where('id', $mid)->get('components')->row();
549
            if (count($row) > 0) {
550
                $autoload = $row->autoload;
551
                if ($autoload) {
552
                    $autoload = 0;
553
                    $status = lang('Disable', 'admin');
554
                } else {
555
                    $autoload = 1;
556
                    $status = lang('Enable', 'admin');
557
                }
558
                $this->db->where('id', $mid)->set('autoload', $autoload)->update('components');
559
                $row->autoload = $autoload;
560
561
                $nameModule = $this->get_module_info($row->identif)['menu_name'];
562
563
                $message = lang('Change Autoload. Module : ', 'admin') . ' '
564
                    . $nameModule . '. ' . lang('Status', 'admin') . ' : ' . $status . '.';
565
                $this->lib_admin->log($message);
566
                echo json_encode(['result' => $row]);
567
            } else {
568
                $result = false;
569
                echo json_encode(['result' => $result]);
570
            }
571
        }
572
    }
573
574
    public function change_url_access() {
575
        if ($this->input->post('mid')) {
576
            $mid = $this->input->post('mid');
577
            $row = $this->db->where('id', $mid)->get('components')->row();
578
579 View Code Duplication
            if (count($row) > 0) {
580
                $enabled = $row->enabled;
581
                if ($enabled) {
582
                    $enabled = 0;
583
                    $status = lang('Disable', 'admin');
584
                } else {
585
                    $enabled = 1;
586
                    $status = lang('Enable', 'admin');
587
                }
588
589
                $this->db->where('id', $mid)->set('enabled', $enabled)->update('components');
590
591
                $row->enabled = $enabled;
592
                $nameModule = $this->get_module_info($row->identif)['menu_name'];
593
594
                $message = lang('Change URL access. Module : ', 'admin') . ' '
595
                    . $nameModule . '. ' . lang('Status', 'admin') . ' : ' . $status . '.';
596
                $this->lib_admin->log($message);
597
            }
598
        }
599
    }
600
601
    public function change_show_in_menu() {
602
        $id = $this->input->post('id');
603
        $row = $this->db->where('id', (int) $id)->get('components')->row();
604 View Code Duplication
        if (count($row) > 0) {
605
            $in_menu = $row->in_menu;
606
            if ($in_menu == 1) {
607
                $in_menu = 0;
608
                $status = lang('Disable', 'admin');
609
            } else {
610
                $in_menu = 1;
611
                $status = lang('Enable', 'admin');
612
            }
613
            $this->db->where('id', (int) $id)->set('in_menu', $in_menu)->update('components');
614
615
            $nameModule = $this->get_module_info($row->identif)['menu_name'];
616
617
            $message = lang('Change Show in menu. Module : ', 'admin') . ' '
618
                . $nameModule . '. ' . lang('Status', 'admin') . ' : ' . $status . '.';
619
            $this->lib_admin->log($message);
620
        }
621
    }
622
623
    public function save_components_positions() {
624
        $positions = $this->input->post('positions');
625
        if (is_array($positions)) {
626
            foreach ($positions as $key => $value) {
627
                if ($this->db->where('name', $value)->set('position', $key)->update('components')) {
628
                    $result = true;
629
                } else {
630
                    $result = false;
631
                }
632
            }
633
            if ($result) {
634
                showMessage(lang('Positions updated', 'admin'));
635
            } else {
636
                showMessage(lang('Fail', 'admin'));
637
            }
638
        }
639
    }
640
641
}
642
643
/* End of components.php */