Ejemplo n.º 1
0
 function sql($config)
 {
     // let's set this module active
     Modules::enable('aauth');
     extract($config);
     // Creatin Auth Group
     $this->db->query("DROP TABLE IF EXISTS `{$database_prefix}aauth_groups`;");
     $this->db->query("CREATE TABLE `{$database_prefix}aauth_groups` (\n\t\t  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t  `name` varchar(100),\n\t\t  `definition` text,\n\t\t  PRIMARY KEY (`id`)\n\t\t) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;");
     // Creating Auth Permission
     $this->db->query("DROP TABLE IF EXISTS `{$database_prefix}aauth_perms`;");
     $this->db->query("\n\t\tCREATE TABLE `{$database_prefix}aauth_perms` (\n\t\t  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t  `name` varchar(100),\n\t\t  `definition` text,\n\t\t  PRIMARY KEY (`id`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\t\t");
     // Creating Permission to Group
     $this->db->query("DROP TABLE IF EXISTS `{$database_prefix}aauth_perm_to_group`;");
     $this->db->query("CREATE TABLE `{$database_prefix}aauth_perm_to_group` (\n\t\t  `perm_id` int(11) unsigned DEFAULT NULL,\n\t\t  `group_id` int(11) unsigned DEFAULT NULL,\n\t\t  PRIMARY KEY (`perm_id`,`group_id`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
     // Auth Permission to User
     $this->db->query("DROP TABLE IF EXISTS `{$database_prefix}aauth_perm_to_user`;");
     $this->db->query("CREATE TABLE `{$database_prefix}aauth_perm_to_user` (\n\t\t  `perm_id` int(11) unsigned DEFAULT NULL,\n\t\t  `user_id` int(11) unsigned DEFAULT NULL,\n\t\t  PRIMARY KEY (`perm_id`,`user_id`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
     // Auth PMS
     $this->db->query("DROP TABLE IF EXISTS `{$database_prefix}aauth_pms`;");
     $this->db->query("CREATE TABLE `{$database_prefix}aauth_pms` (\n\t\t  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t  `sender_id` int(11) unsigned NOT NULL,\n\t\t  `receiver_id` int(11) unsigned NOT NULL,\n\t\t  `title` varchar(255) NOT NULL,\n\t\t  `message` text,\n\t\t  `date` datetime DEFAULT NULL,\n\t\t  `read` tinyint(1) DEFAULT '0',\n\t\t  PRIMARY KEY (`id`),\n\t\t  KEY `full_index` (`id`,`sender_id`,`receiver_id`,`read`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
     // System Variables
     $this->db->query("DROP TABLE IF EXISTS `{$database_prefix}aauth_system_variables`;");
     $this->db->query("CREATE TABLE `{$database_prefix}aauth_system_variables` (\n\t\t  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t  `key` varchar(100) NOT NULL,\n\t\t  `value` text,\n\t\t  PRIMARY KEY (`id`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
     // Auth User Table
     $this->db->query("DROP TABLE IF EXISTS `{$database_prefix}aauth_users`;");
     $this->db->query("CREATE TABLE `{$database_prefix}aauth_users` (\n\t\t  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t  `email` varchar(100) COLLATE utf8_general_ci NOT NULL,\n\t\t  `pass` varchar(100) COLLATE utf8_general_ci NOT NULL,\n\t\t  `name` varchar(100) COLLATE utf8_general_ci,\n\t\t  `banned` tinyint(1) DEFAULT '0',\n\t\t  `last_login` datetime DEFAULT NULL,\n\t\t  `last_activity` datetime DEFAULT NULL,\n\t\t  `last_login_attempt` datetime DEFAULT NULL,\n\t\t  `forgot_exp` text COLLATE utf8_general_ci,\n\t\t  `remember_time` datetime DEFAULT NULL,\n\t\t  `remember_exp` text COLLATE utf8_general_ci,\n\t\t  `verification_code` text COLLATE utf8_general_ci,\n\t\t  `ip_address` text COLLATE utf8_general_ci,\n\t\t  `login_attempts` int(11) DEFAULT '0',\n\t\t  PRIMARY KEY (`id`)\n\t\t) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
     // User Auth Group
     $this->db->query("DROP TABLE IF EXISTS `{$database_prefix}aauth_user_to_group`;");
     $this->db->query("CREATE TABLE `{$database_prefix}aauth_user_to_group` (\n\t\t  `user_id` int(11) unsigned NOT NULL DEFAULT '0',\n\t\t  `group_id` int(11) unsigned NOT NULL DEFAULT '0',\n\t\t  PRIMARY KEY (`user_id`,`group_id`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
     // Auth User Variable
     $this->db->query("DROP TABLE IF EXISTS `{$database_prefix}aauth_user_variables`;");
     $this->db->query("CREATE TABLE `{$database_prefix}aauth_user_variables` (\n\t\t  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t  `user_id` int(11) unsigned NOT NULL,\n\t\t  `key` varchar(100) NOT NULL,\n\t\t  `value` text,\n\t\t  PRIMARY KEY (`id`),\n\t\t  KEY `user_id_index` (`user_id`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
 }
Ejemplo n.º 2
0
 function __construct()
 {
     $this->version = '1.0';
     parent::__construct();
     $this->events->add_action('after_app_init', array($this, 'loader'));
     $this->events->add_action('tendoo_settings_tables', function () {
         Modules::enable('post_type');
     });
 }
Ejemplo n.º 3
0
 /**
  * Module List and management controller
  *
  *
  * @access       public
  * @author       Blair Jersyer
  * @copyright    name date
  * @param        string $page
  * @param		  string $arg2
  * @since        3.0.1
  */
 function modules($page = 'list', $arg2 = null)
 {
     if ($page === 'list') {
         $this->events->add_filter('gui_page_title', function ($title) {
             return '<section class="content-header"><h1>' . strip_tags($title) . ' <a class="btn btn-primary btn-sm pull-right" href="' . site_url(array('dashboard', 'modules', 'install_zip')) . '">' . __('Upload a zip file') . '</a></h1></section>';
         });
         $this->events->add_action('displays_dashboard_errors', function () {
             if (isset($_GET['extra'])) {
                 echo tendoo_error(__('An error occured during module installation. There was a file conflict during module installation process.<br>This file seems to be already installed : ' . $_GET['extra']));
             }
         });
         $this->gui->set_title(sprintf(__('Module List &mdash; %s'), get('core_signature')));
         $this->load->view('dashboard/modules/list');
     } else {
         if ($page === 'install_zip') {
             $this->events->add_filter('gui_page_title', function ($title) {
                 return '<section class="content-header"><h1>' . strip_tags($title) . ' <a class="btn btn-primary btn-sm pull-right" href="' . site_url(array('dashboard', 'modules')) . '">' . __('Back to modules list') . '</a></h1></section>';
             });
             if (isset($_FILES['extension_zip'])) {
                 $notice = Modules::install('extension_zip');
                 // it means that module has been installed
                 if (is_array($notice)) {
                     // redirecting
                     redirect(array('dashboard', 'modules', 'list?highlight=' . $notice['namespace'] . '&notice=' . $notice['msg'] . (isset($notice['extra']) ? '&extra=' . $notice['extra'] : '') . '#module-' . $notice['namespace']));
                 } else {
                     $this->notice->push_notice($this->lang->line($notice));
                 }
             }
             $this->gui->set_title(sprintf(__('Add a new extension &mdash; %s'), get('core_signature')));
             $this->load->view('dashboard/modules/install');
         } else {
             if ($page === 'enable') {
                 /**
                  * Module should be enabled before trigger this action
                  **/
                 Modules::enable($arg2);
                 // Enabling recently active module
                 Modules::init('unique', $arg2);
                 // Run the action
                 $this->events->do_action('do_enable_module', $arg2);
                 redirect(array('dashboard', 'modules?notice=' . $this->events->apply_filters('module_activation_status', 'module-enabled')));
             } else {
                 if ($page === 'disable') {
                     $this->events->add_action('do_disable_module', function ($arg2) {
                         Modules::disable($arg2);
                     });
                     //
                     $this->events->do_action('do_disable_module', $arg2);
                     redirect(array('dashboard', 'modules?notice=' . $this->events->apply_filters('module_disabling_status', 'module-disabled')));
                 } else {
                     if ($page === 'remove') {
                         $this->events->add_action('do_remove_module', function ($arg2) {
                             Modules::uninstall($arg2);
                             redirect(array('dashboard', 'modules?notice=module-removed'));
                         });
                         $this->events->do_action('do_remove_module', $arg2);
                     } else {
                         if ($page === 'extract') {
                             $this->events->add_action('do_extract_module', function ($arg2) {
                                 Modules::extract($arg2);
                             });
                             $this->events->do_action('do_extract_module', $arg2);
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
 function indexAction()
 {
     $modules_table = new Modules("nuts");
     $request = new Bolts_Request($this->getRequest());
     if ($request->has("id") and $request->has("perform")) {
         switch ($request->perform) {
             case "enable":
                 if (!$modules_table->isEnabled($request->id)) {
                     if ($modules_table->enable($request->id)) {
                         if (!is_null($modules_table->success)) {
                             $this->view->success = $modules_table->success;
                         } else {
                             $this->view->success = "Module \"" . $request->id . "\" enabled.";
                         }
                     }
                 } else {
                     $this->view->notice = "Module \"" . $request->id . "\" is already enabled.";
                 }
                 break;
             case "disable":
                 if ($modules_table->isEnabled($request->id)) {
                     if ($modules_table->disable($request->id)) {
                         if (!is_null($modules_table->success)) {
                             $this->view->success = $modules_table->success;
                         } else {
                             $this->view->success = "Module \"" . $request->id . "\" disabled.";
                         }
                     }
                 } else {
                     $this->view->notice = "Module \"" . $request->id . "\" is already disabled.";
                 }
                 break;
             case "install":
                 if (!$modules_table->exists($request->id)) {
                     if ($modules_table->install($request->id)) {
                         if (!is_null($modules_table->success)) {
                             $this->view->success = $modules_table->success;
                         } else {
                             $this->view->success = "Module \"" . $request->id . "\" installed.";
                         }
                     }
                 } else {
                     $this->view->notice = "Module \"" . $request->id . "\" is already installed.";
                 }
                 break;
             case "uninstall":
                 if ($modules_table->exists($request->id)) {
                     if ($modules_table->disable($request->id)) {
                         if ($modules_table->uninstall($request->id)) {
                             if (!is_null($modules_table->success)) {
                                 $this->view->success = $modules_table->success;
                             } else {
                                 $this->view->success = "Module \"" . $request->id . "\" disabled and uninstalled.";
                             }
                         }
                     }
                 } else {
                     $this->view->notice = "Module \"" . $request->id . "\" is not installed.";
                 }
                 break;
         }
         if (count($modules_table->errors) > 0) {
             $this->view->errors = $modules_table->errors;
         }
         if (!is_null($modules_table->notice)) {
             $this->view->notice = $modules_table->notice;
         }
     }
     $basepath = Zend_Registry::get('basepath');
     $module_dir = $basepath . "/nuts";
     $o_module_dir = dir($module_dir);
     $available_modules = array();
     while (false !== ($entry = $o_module_dir->read())) {
         if (substr($entry, 0, 1) != ".") {
             if ($entry != "default") {
                 $full_dir = $module_dir . "/" . $entry;
                 if (file_exists($full_dir . "/module.ini") and !$modules_table->exists($entry)) {
                     $tmp_module = $modules_table->parseIni($entry);
                     $tmp_module['id'] = $entry;
                     $tmp_module['available'] = true;
                     $available_modules[] = $tmp_module;
                 }
             }
         }
     }
     $o_module_dir->close();
     $tmp_modules = array();
     $modules = $modules_table->fetchAll(null, "id");
     if (count($modules) > 0) {
         $tmp_modules = array();
         foreach ($modules as $module) {
             $module = $module->toArray();
             try {
                 $config = $modules_table->parseIni($module['id']);
                 foreach ($config as $key => $val) {
                     $module[$key] = $val;
                 }
                 $module['available'] = false;
                 $tmp_modules[] = $module;
             } catch (Exception $e) {
                 Bolts_Log::report("Could not set up " . $module, $e, Zend_Log::ERR);
             }
         }
     }
     $this->view->modules = array_merge($tmp_modules, $available_modules);
 }
Ejemplo n.º 5
0
 function set_tables()
 {
     Modules::enable('dashboard');
 }
Ejemplo n.º 6
0
<div class="table-responsive">
    <table class="table table-bordered table-hover table-striped">
        <thead>
            <tr>
                <td>Модуль</td>
                <td>Статус</td>
                <td>Включить</td>
                <td>Отключить</td>
            </tr>
        </thead>
        <tbody>

            <?php 
$class = new Modules();
if (isset($_GET['enable'])) {
    $class->enable($_GET['enable']);
    $class->save();
    echo "<div class='alert alert-success'>Модуль включён</div>";
}
if (isset($_GET['disable'])) {
    $class->disable($_GET['disable']);
    $class->save();
    echo "<div class='alert alert-success'>Модуль отключён</div>";
}
$mods = $class->getModules();
$skip = array('.', '..', '.htaccess', '.conf');
$files = scandir(MODS_ROOT);
foreach ($files as $file) {
    if (!in_array($file, $skip)) {
        $status = in_array($file, $mods) ? "Включён" : "Отключён";
        echo "<tr><td> <b><font size=3>" . $file . "</font></b> </td><td> <b>" . $status . "</b> </td><td> [<a href='?enable=" . $file . "'>Включить</a>] </td><td> [<a href='?disable=" . $file . "'>Отключить</a>] </td></tr>";