Example #1
0
 public function plugin_deactivate($slug)
 {
     $plugin_data = Plugins::get_plugin($slug);
     $plugin = Plugin::where('slug', '=', $slug)->first();
     $plugin->active = 0;
     $plugin->save();
     return Redirect::to('admin?section=plugins')->with(array('note' => 'Successfully De-activated ' . $plugin_data['name'], 'note_type' => 'success'));
 }
 function save_data()
 {
     if (class_exists('Plugin')) {
         $p = new Plugin();
         $p->where('path', $this->get_key())->get();
         $p->data = serialize((array) $this->get_data());
         $p->save();
     } else {
         return false;
     }
 }
Example #3
0
 function index()
 {
     if (!$this->auth) {
         $this->error('401', 'Not authorized to perform this action.');
         return;
     }
     list($params, $id) = $this->parse_params(func_get_args());
     $plugins = $this->parse_plugins();
     $db_config = Shutter::get_db_configuration();
     switch ($this->method) {
         case 'delete':
             $p = new Plugin();
             $p->where('id', $id)->get();
             if ($p->exists()) {
                 $p->run_plugin_method('after_uninstall', $plugins);
                 $plugin = $p->init($plugins);
                 if ($plugin->database_fields) {
                     $this->load->dbforge();
                     foreach ($plugin->database_fields as $table => $fields) {
                         $table = $db_config['prefix'] . $table;
                         foreach ($fields as $column => $info) {
                             $this->dbforge->drop_column($table, $column);
                         }
                     }
                     $this->_clear_datamapper_cache();
                 }
                 $p->delete();
             }
             $this->_compile_plugins();
             exit;
             break;
         case 'post':
             $p = new Plugin();
             $p->path = $_POST['path'];
             $p->setup = $p->run_plugin_method('require_setup', $plugins) === false;
             if ($p->save()) {
                 $plugin = $p->init($plugins);
                 if ($plugin->database_fields) {
                     $this->load->dbforge();
                     foreach ($plugin->database_fields as $table => $fields) {
                         $table = $db_config['prefix'] . $table;
                         foreach ($fields as $column => $info) {
                             $this->dbforge->add_column($table, array($column => $info));
                         }
                     }
                     $this->_clear_datamapper_cache();
                 }
                 $p->run_plugin_method('after_install', $plugins);
             }
             $this->_compile_plugins();
             $this->redirect('/plugins');
             break;
         case 'put':
             unset($_POST['_method']);
             $data = serialize($_POST);
             $p = new Plugin();
             $p->where('id', $id)->get();
             $p->save_data($plugins, $_POST);
             $validate = $p->run_plugin_method('confirm_setup', $plugins, $data);
             if ($validate === true) {
                 $p->setup = 1;
                 $p->save();
                 $this->_compile_plugins();
                 exit;
             } else {
                 $this->error(400, $validate);
                 return;
             }
             break;
         default:
             $data = array('plugins' => $plugins);
             function sortByName($a, $b)
             {
                 return $a['name'] > $b['name'];
             }
             usort($data['plugins'], 'sortByName');
             $data['plugins'] = Shutter::filter('api.plugins', array($data['plugins']));
             $data['custom_sources'] = Shutter::$custom_sources;
             $this->set_response_data($data);
             break;
     }
 }
Example #4
0
<table class="table plugins">
    <thead>
    <tr>
        <th>Plugin Name</th>
        <th>Status</th>
        <th>Action</th>
    </tr>
    </thead>
    <tbody>

        @foreach($plugins_available as $plugin)

            <?php 
$this_plugin = Plugin::where('slug', '=', $plugin['slug'])->first();
?>
           
                <tr>
                    <td><h2 style="margin-bottom:0px; padding-bottom:0px;">{{ $plugin['name'] }} <span style="font-size:14px;">V.{{ $plugin['version'] }}</span></h2>
                        <small>{{ $plugin['description'] }}</small>
                    </td>
                    @if(!empty($this_plugin->active) && $this_plugin->active == 1) 
                        <td><p>Active</p></td>
                        <td><a href="plugin/deactivate/{{ $plugin['slug'] }}" class="btn btn-danger" style="display:inline; float:left; margin-right:10px;">De-activate</a><a href="plugin/{{ $plugin['slug'] }}" class="btn btn-success ajax" data-header="<i class='ion ion-outlet'></i> Plugin Settings" data-section="plugins"><i class="fa fa-cog"></i></a></td>
                    @else 
                        <td><p>Inactive</p></td>
                        <td><a href="plugin/activate/{{ $plugin['slug'] }}" class="btn btn-primary">Activate</a></td> 
                    @endif</p></td>
                   
                </tr>

        @endforeach
Example #5
0
 function plugin()
 {
     if ($this->method !== 'post') {
         $this->error('403', 'Forbidden');
         return;
     }
     $local = $this->input->post('local_path');
     $guid = $this->input->post('guid');
     $install_id = $this->input->post('uuid');
     $purchase = $this->input->post('purchase');
     $is_new = $this->input->post('new');
     $plugin_id = $this->input->post('id');
     $base = FCPATH . 'storage' . DIRECTORY_SEPARATOR;
     $tmp_path = $base . 'tmp';
     $remote = KOKEN_STORE_URL . '/plugins/download/' . $guid . '/for/' . $install_id . ($purchase ? '/' . $purchase : '');
     $local_zip = $tmp_path . DIRECTORY_SEPARATOR . 'update.zip';
     $updated_theme = $tmp_path . DIRECTORY_SEPARATOR . $guid;
     $current_path = $base . $local;
     if (is_dir("{$current_path}.off")) {
         delete_files("{$current_path}.off", true, 1);
     }
     if (is_dir("{$current_path}/.git")) {
         delete_files("{$current_path}/.git", true, 1);
     }
     make_child_dir($tmp_path);
     $success = false;
     $old_mask = umask(0);
     if (ENVIRONMENT === 'development' && !$is_new) {
         $success = true;
         sleep(3);
     } else {
         if ($this->_download($remote, $local_zip)) {
             $this->load->library('unzip');
             $this->unzip->extract($local_zip);
             if (file_exists($updated_theme . DIRECTORY_SEPARATOR . 'info.json') || file_exists($updated_theme . DIRECTORY_SEPARATOR . 'pulse.json') || file_exists($updated_theme . DIRECTORY_SEPARATOR . 'plugin.json')) {
                 if ($is_new || rename($current_path, "{$current_path}.off")) {
                     if (rename($updated_theme, $current_path)) {
                         // Hack for watermark update issue. Can removed this eventually (0.15.1 was when this was implemented)
                         if (file_exists("{$current_path}.off/image.png")) {
                             copy("{$current_path}.off/image.png", "{$current_path}/storage/image.png");
                         }
                         // /Hack
                         // Copy storage folder to ensure userland files survive update
                         if (is_dir("{$current_path}.off/storage")) {
                             delete_files("{$current_path}/storage", true, 1);
                             rename("{$current_path}.off/storage", "{$current_path}/storage");
                         }
                         delete_files("{$current_path}.off", true, 1);
                         $success = true;
                         if (file_exists($current_path . DIRECTORY_SEPARATOR . 'info.json')) {
                             $json = $current_path . DIRECTORY_SEPARATOR . 'info.json';
                         } else {
                             if (file_exists($current_path . DIRECTORY_SEPARATOR . 'pulse.json')) {
                                 $json = $current_path . DIRECTORY_SEPARATOR . 'pulse.json';
                             } else {
                                 $json = $current_path . DIRECTORY_SEPARATOR . 'plugin.json';
                             }
                         }
                         $json = json_decode(file_get_contents($json, true));
                     } else {
                         $json = 'Could not rename folder.';
                     }
                 } else {
                     $json = 'Could not rename old version before upgrading';
                 }
             } else {
                 $json = 'Could not download plugin ZIP.';
             }
             unlink($local_zip);
             delete_files($updated_theme, true, 1);
         }
     }
     umask($old_mask);
     if ($plugin_id) {
         $p = new Plugin();
         $p->where('id', $plugin_id)->get();
         if ($p->exists()) {
             $plugins = $this->parse_plugins();
             $plugin = $p->init($plugins);
             if ($plugin->database_fields) {
                 $db_config = Shutter::get_db_configuration();
                 $this->load->dbforge();
                 foreach ($plugin->database_fields as $table => $fields) {
                     $table = $db_config['prefix'] . $table;
                     foreach ($fields as $column => $info) {
                         if (in_array(strtolower($info['type']), array('text', 'varchar', 'longtext'))) {
                             $info['null'] = true;
                         }
                         $this->dbforge->add_column($table, array($column => $info));
                     }
                 }
                 $this->_clear_datamapper_cache();
             }
             $p->run_plugin_method('after_upgrade', $plugins);
         }
     }
     $this->_compile_plugins();
     die(json_encode(array('done' => $success, 'info' => isset($json) ? $json : array())));
 }
Example #6
0
     return Redirect::to('/');
 }
 if (Cookie::get('theme')) {
     Config::set('site.theme', Cookie::get('theme'));
 } else {
     if ($settings->theme) {
         Config::set('site.theme', $settings->theme);
     }
 }
 View::addNamespace('Theme', 'content/themes/' . Config::get('site.theme'));
 $theme_functions = 'content/themes/' . Config::get('site.theme') . '/functions.php';
 if (file_exists($theme_functions)) {
     include $theme_functions;
 }
 if (Config::get('database.connections.mysql.host') != '') {
     $plugins = Plugin::where('active', '=', 1)->get();
     //print_r($plugins); die();
     foreach ($plugins as $plugin) {
         $plugin_name = $plugin->slug;
         $include_file = 'content/plugins/' . $plugin_name . '/functions.php';
         // Create Settings Route for Plugin
         Route::group(array('before' => 'admin'), function () {
             Route::get('admin/plugin/{plugin_name}', function ($plugin_name) {
                 $data = array('plugin_data' => PluginData::where('plugin_slug', '=', $plugin_name)->get());
                 return View::make('plugins.' . $plugin_name . '.index', $data);
             });
             Route::post('admin/plugin/{plugin_name}', function ($plugin_name) {
                 $input = Input::all();
                 foreach ($input as $key => $value) {
                     $pluginData = PluginData::where('plugin_slug', '=', $plugin_name)->where('key', '=', $key)->first();
                     if (!empty($pluginData->id)) {