<?php
/**
 * MB1 Install script. It's not necessary to run this at all, it just adds a menu entry under MTC only.
 * @author Rihards Siliņš
 * @version 1 29/03/2016
 */
$path = '../../../';
require_once $path.'core/includes/header.inc.php';

use Illuminate\Database\Capsule\Manager as Capsule;

// Get the path to the admin folder without public_html / fork directory
$path_to_admin_folder = str_replace(SITE_PATH, '', dirname(__DIR__)).'/admin/';

// Check if menu entry already exists
$mb_admin_menu_row = Capsule::table('admin_menu')->where('title', 'Module Builder')->first();
if (empty($mb_admin_menu_row)) {
    // Create the admin menu item
    Capsule::table('admin_menu')->insert(
        [
            'sub_id' => 1, // MTC Only menu entry. Should be a constant in the mtc. core
            'title' => 'Module Builder',
            'path' => $path_to_admin_folder,
            'activePath' => $path_to_admin_folder,
            'constant' => '',
            'icon' => 'fa fa-rocket',
            'new_window' => 0,
            'order' => 2,
        ]
    );
    ?>
    Admin menu entry added!<br/>
    <?php
} else {
    ?>Admin menu entry already there!<br/><?php
}

?>
Have fun! &lt;3<br/><br/>
<a href="http://wiki.mtcmedia.co.uk/index.php?title=Module_Builder_1" target="_blank">Wiki</a><br/>
<a href="<?=SITE_URL?>/modules/ModuleBuilder/admin/" target="_blank">Start now!</a><br/>
