plugins/admin/PluginManager.php
author Dan
Thu, 10 Apr 2008 07:58:56 -0400
changeset 529 7803c9db3506
parent 527 21e11f564463
child 531 510160f15a69
permissions -rw-r--r--
Implemented security logging for plugin management
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
519
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
     1
<?php
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
     2
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
     3
/*
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
     4
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
     5
 * Version 1.1.3 (Caoineag alpha 3)
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
     6
 * Copyright (C) 2006-2007 Dan Fuhry
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
     7
 *
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
     8
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
     9
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    10
 *
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    11
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    12
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    13
 */
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    14
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    15
/**
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    16
 * SYNOPSIS OF PLUGIN FRAMEWORK
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    17
 *
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    18
 * The new plugin manager is making an alternative approach to managing plugin files by allowing metadata to be embedded in them
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    19
 * or optionally included from external files. This method is API- and format-compatible with old plugins. The change is being
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    20
 * made because we believe this will provide greater flexibility within plugin files.
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    21
 * 
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    22
 * Plugin files can contain one or more specially formatted comment blocks with metadata, language strings, and installation or
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    23
 * upgrade SQL schemas. For this to work, plugins need to define their version numbers in an Enano-readable and standardized
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    24
 * format, and we think the best way to do this is with JSON. It is important that plugins define both the current version and
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    25
 * a list of all past versions, and then have upgrade sections telling which version they go from and which one they go to.
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    26
 * 
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    27
 * The format for the special comment blocks is:
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    28
 <code>
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
    29
 /**!blocktype( param1 = "value1"; [ param2 = "value2"; ... ] )**
519
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    30
 
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    31
 ... block content ...
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    32
 
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    33
 **!* / (remove that last space)
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    34
 </code>
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    35
 * The format inside blocks varies. Metadata and language strings will be in JSON; installation and upgrade schemas will be in
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    36
 * SQL. You can include an external file into a block using the following syntax inside of a block:
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    37
 <code>
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    38
 !include "path/to/file"
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    39
 </code>
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    40
 * The file will always be relative to the Enano root. So if your plugin has a language file in ENANO_ROOT/plugins/fooplugin/,
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    41
 * you would use "plugins/fooplugin/language.json".
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    42
 *
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    43
 * The format for plugin metadata is as follows:
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    44
 <code>
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    45
 /**!info**
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    46
 {
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    47
   "Plugin Name" : "Foo plugin",
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    48
   "Plugin URI" : "http://fooplugin.enanocms.org/",
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    49
   "Description" : "Some short descriptive text",
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    50
   "Author" : "John Doe",
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    51
   "Version" : "0.1",
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    52
   "Author URI" : "http://yourdomain.com/",
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    53
   "Version list" : [ "0.1-alpha1", "0.1-alpha2", "0.1-beta1", "0.1" ]
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    54
 }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    55
 **!* /
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    56
 </code>
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    57
 * This is the format for language data:
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    58
 <code>
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    59
 /**!language**
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    60
 {
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
    61
   // each entry at this level should be an ISO-639-1 language code.
519
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    62
   eng: {
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
    63
     // from here on in is the standard langauge file format
519
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    64
     categories: [ 'meta', 'foo', 'bar' ],
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    65
     strings: {
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    66
       meta: {
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    67
         foo: "Foo strings",
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    68
         bar: "Bar strings"
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    69
       },
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    70
       foo: {
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    71
         string_name: "string value",
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    72
         string_name_2: "string value 2"
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    73
       }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    74
     }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    75
   }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    76
 }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    77
 **!* / (once more, remove the space in there)
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    78
 </code>
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    79
 * Here is the format for installation schemas:
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    80
 <code>
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    81
 /**!install**
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    82
 
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    83
 CREATE TABLE {{TABLE_PREFIX}}foo_table(
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    84
   ...
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    85
 )
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    86
 
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    87
 **!* /
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    88
 </code>
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    89
 * And finally, the format for upgrade schemas:
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    90
 <code>
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
    91
 /**!upgrade from = "0.1-alpha1"; to = "0.1-alpha2"; **
519
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    92
 
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    93
 **!* /
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    94
 </code>
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
    95
 * As a courtesy to your users, we ask that you also include an "uninstall" block that reverses any changes your plugin makes
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
    96
 * to the database upon installation. The syntax is identical to that of the install block.
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
    97
 * 
519
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    98
 * Remember that upgrades will always be done incrementally, so if the user is upgrading 0.1-alpha2 to 0.1, Enano's plugin
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
    99
 * engine will run the 0.1-alpha2 to 0.1-beta1 upgrader, then the 0.1-beta1 to 0.1 upgrader, going by the versions listed in
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   100
 * the example metadata block above. As with the standard Enano installer, prefixing a query with '@' will cause it to be
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   101
 * performed "blindly", e.g. not checked for errors.
519
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   102
 * 
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   103
 * All of this information is effective as of Enano 1.1.4.
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   104
 */
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   105
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   106
// Plugin manager "2.0"
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   107
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   108
function page_Admin_PluginManager()
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   109
{
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   110
  global $db, $session, $paths, $template, $plugins; // Common objects
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   111
  global $lang;
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   112
  if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   113
  {
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   114
    $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true);
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   115
    echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>';
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   116
    echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>';
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   117
    return;
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   118
  }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   119
  
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   120
  $plugin_list = $plugins->get_plugin_list();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   121
  
519
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   122
  // Are we processing an AJAX request from the smartform?
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   123
  if ( $paths->getParam(0) == 'action.json' )
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   124
  {
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   125
    // Set to application/json to discourage advertisement scripts
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   126
    header('Content-Type: application/json');
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   127
    
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   128
    // Init return data
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   129
    $return = array('mode' => 'error', 'error' => 'undefined');
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   130
    
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   131
    // Start parsing process
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   132
    try
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   133
    {
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   134
      // Is the request properly sent on POST?
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   135
      if ( isset($_POST['r']) )
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   136
      {
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   137
        // Try to decode the request
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   138
        $request = enano_json_decode($_POST['r']);
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   139
        // Is the action to perform specified?
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   140
        if ( isset($request['mode']) )
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   141
        {
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   142
          switch ( $request['mode'] )
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   143
          {
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   144
            case 'install':
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   145
              // did they specify a plugin to operate on?
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   146
              if ( !isset($request['plugin']) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   147
              {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   148
                $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   149
                  'mode' => 'error',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   150
                  'error' => 'No plugin specified.',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   151
                );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   152
                break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   153
              }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   154
              
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   155
              $return = $plugins->install_plugin($request['plugin'], $plugin_list);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   156
              break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   157
            case 'upgrade':
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   158
              // did they specify a plugin to operate on?
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   159
              if ( !isset($request['plugin']) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   160
              {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   161
                $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   162
                  'mode' => 'error',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   163
                  'error' => 'No plugin specified.',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   164
                );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   165
                break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   166
              }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   167
              
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   168
              $return = $plugins->upgrade_plugin($request['plugin'], $plugin_list);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   169
              break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   170
            case 'uninstall':
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   171
              // did they specify a plugin to operate on?
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   172
              if ( !isset($request['plugin']) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   173
              {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   174
                $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   175
                  'mode' => 'error',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   176
                  'error' => 'No plugin specified.',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   177
                );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   178
                break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   179
              }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   180
              
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   181
              $return = $plugins->uninstall_plugin($request['plugin'], $plugin_list);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   182
              break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   183
            case 'disable':
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   184
            case 'enable':
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   185
              $flags_col = ( $request['mode'] == 'disable' ) ?
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   186
                            "plugin_flags | "  . PLUGIN_DISABLED :
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   187
                            "plugin_flags & ~" . PLUGIN_DISABLED;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   188
              // did they specify a plugin to operate on?
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   189
              if ( !isset($request['plugin']) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   190
              {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   191
                $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   192
                  'mode' => 'error',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   193
                  'error' => 'No plugin specified.',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   194
                );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   195
                break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   196
              }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   197
              // is the plugin in the directory and already installed?
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   198
              if ( !isset($plugin_list[$request['plugin']]) || (
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   199
                  isset($plugin_list[$request['plugin']]) && !$plugin_list[$request['plugin']]['installed']
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   200
                ))
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   201
              {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   202
                $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   203
                  'mode' => 'error',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   204
                  'error' => 'Invalid plugin specified.',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   205
                );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   206
                break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   207
              }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   208
              // get plugin id
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   209
              $dataset =& $plugin_list[$request['plugin']];
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   210
              if ( empty($dataset['plugin id']) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   211
              {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   212
                $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   213
                  'mode' => 'error',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   214
                  'error' => 'Couldn\'t retrieve plugin ID.',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   215
                );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   216
                break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   217
              }
529
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 527
diff changeset
   218
              
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 527
diff changeset
   219
              // log action
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 527
diff changeset
   220
              $time        = time();
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 527
diff changeset
   221
              $ip_db       = $db->escape($_SERVER['REMOTE_ADDR']);
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 527
diff changeset
   222
              $username_db = $db->escape($session->username);
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 527
diff changeset
   223
              $file_db     = $db->escape($request['plugin']);
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 527
diff changeset
   224
              // request['mode'] is TRUSTED - the case statement will only process if it is one of {enable,disable}.
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 527
diff changeset
   225
              $q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, page_text) VALUES\n"
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 527
diff changeset
   226
                                . "  ('security', 'plugin_{$request['mode']}', $time, '$ip_db', '$username_db', '$file_db');");
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 527
diff changeset
   227
              if ( !$q )
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 527
diff changeset
   228
                $db->_die();
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 527
diff changeset
   229
              
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   230
              // perform update
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   231
              $q = $db->sql_query('UPDATE ' . table_prefix . "plugins SET plugin_flags = $flags_col WHERE plugin_id = {$dataset['plugin id']};");
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   232
              if ( !$q )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   233
                $db->die_json();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   234
              
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   235
              $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   236
                'success' => true
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   237
              );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   238
              break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   239
            case 'import':
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   240
              // import all of the plugin_* config entries
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   241
              $q = $db->sql_query('SELECT config_name, config_value FROM ' . table_prefix . "config WHERE config_name LIKE 'plugin_%';");
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   242
              if ( !$q )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   243
                $db->die_json();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   244
              
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   245
              while ( $row = $db->fetchrow($q) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   246
              {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   247
                $plugin_filename = preg_replace('/^plugin_/', '', $row['config_name']);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   248
                if ( isset($plugin_list[$plugin_filename]) && !@$plugin_list[$plugin_filename]['installed'] )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   249
                {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   250
                  $return = $plugins->install_plugin($plugin_filename, $plugin_list);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   251
                  if ( !$return['success'] )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   252
                    break 2;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   253
                  if ( $row['config_value'] == '0' )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   254
                  {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   255
                    $fn_db = $db->escape($plugin_filename);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   256
                    $q = $db->sql_query('UPDATE ' . table_prefix . "plugins SET plugin_flags = plugin_flags | " . PLUGIN_DISABLED . " WHERE plugin_filename = '$fn_db';");
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   257
                    if ( !$q )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   258
                      $db->die_json();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   259
                  }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   260
                }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   261
              }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   262
              $db->free_result($q);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   263
              
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   264
              $q = $db->sql_query('DELETE FROM ' . table_prefix . "config WHERE config_name LIKE 'plugin_%';");
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   265
              if ( !$q )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   266
                $db->die_json();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   267
              
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   268
              $return = array('success' => true);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   269
              break;
519
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   270
            default:
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   271
              // The requested action isn't something this script knows how to do
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   272
              $return = array(
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   273
                'mode' => 'error',
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   274
                'error' => 'Unknown mode "' . $request['mode'] . '" sent in request'
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   275
              );
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   276
              break;
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   277
          }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   278
        }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   279
        else
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   280
        {
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   281
          // Didn't specify action
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   282
          $return = array(
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   283
            'mode' => 'error',
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   284
            'error' => 'Missing key "mode" in request'
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   285
          );
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   286
        }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   287
      }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   288
      else
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   289
      {
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   290
        // Didn't send a request
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   291
        $return = array(
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   292
          'mode' => 'error',
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   293
          'error' => 'No request specified'
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   294
        );
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   295
      }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   296
    }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   297
    catch ( Exception $e )
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   298
    {
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   299
      // Sent a request but it's not valid JSON
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   300
      $return = array(
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   301
          'mode' => 'error',
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   302
          'error' => 'Invalid request - JSON parsing failed'
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   303
        );
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   304
    }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   305
    
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   306
    echo enano_json_encode($return);
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   307
    
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   308
    return true;
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   309
  }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   310
  
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   311
  //
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   312
  // Not a JSON request, output normal HTML interface
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   313
  //
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   314
  
526
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   315
  // start printing things out
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   316
  ?>
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   317
  <div class="tblholder">
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   318
    <table border="0" cellspacing="1" cellpadding="5">
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   319
      <?php
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   320
      $rowid = '2';
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   321
      foreach ( $plugin_list as $filename => $data )
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   322
      {
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   323
        // print out all plugins
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   324
        $rowid = ( $rowid == '1' ) ? '2' : '1';
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   325
        $plugin_name = ( preg_match('/^[a-z0-9_]+$/', $data['plugin name']) ) ? $lang->get($data['plugin name']) : $data['plugin name'];
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   326
        $plugin_basics = $lang->get('acppl_lbl_plugin_name', array(
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   327
            'plugin' => $plugin_name,
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   328
            'author' => $data['author']
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   329
          ));
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   330
        $color = '';
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   331
        $buttons = '';
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   332
        if ( $data['system plugin'] )
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   333
        {
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   334
          $status = $lang->get('acppl_lbl_status_system');
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   335
        }
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   336
        else if ( $data['installed'] && !( $data['status'] & PLUGIN_DISABLED ) && !( $data['status'] & PLUGIN_OUTOFDATE ) )
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   337
        {
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   338
          // this plugin is all good
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   339
          $color = '_green';
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   340
          $status = $lang->get('acppl_lbl_status_installed');
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   341
          $buttons = 'uninstall|disable';
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   342
        }
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   343
        else if ( $data['installed'] && $data['status'] & PLUGIN_OUTOFDATE )
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   344
        {
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   345
          $color = '_red';
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   346
          $status = $lang->get('acppl_lbl_status_need_upgrade');
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   347
          $buttons = 'uninstall|upgrade';
526
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   348
        }
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   349
        else if ( $data['installed'] && $data['status'] & PLUGIN_DISABLED )
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   350
        {
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   351
          $color = '_red';
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   352
          $status = $lang->get('acppl_lbl_status_disabled');
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   353
          $buttons = 'uninstall|enable';
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   354
        }
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   355
        else
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   356
        {
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   357
          $color = '_red';
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   358
          $status = $lang->get('acppl_lbl_status_uninstalled');
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   359
          $buttons = 'install';
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   360
        }
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   361
        $uuid = md5($data['plugin name'] . $data['version'] . $filename);
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   362
        $desc = ( preg_match('/^[a-z0-9_]+$/', $data['description']) ) ? $lang->get($data['description']) : $data['description'];
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   363
        $desc = sanitize_html($desc);
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   364
        
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   365
        $additional = '';
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   366
        
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   367
        // filename
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   368
        $additional .= '<b>' . $lang->get('acppl_lbl_filename') . '</b> ' . "{$filename}<br />";
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   369
        
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   370
        // plugin's site
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   371
        $data['plugin uri'] = htmlspecialchars($data['plugin uri']);
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   372
        $additional .= '<b>' . $lang->get('acppl_lbl_plugin_site') . '</b> ' . "<a href=\"{$data['plugin uri']}\">{$data['plugin uri']}</a><br />";
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   373
        
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   374
        // author's site
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   375
        $data['author uri'] = htmlspecialchars($data['author uri']);
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   376
        $additional .= '<b>' . $lang->get('acppl_lbl_author_site') . '</b> ' . "<a href=\"{$data['author uri']}\">{$data['author uri']}</a><br />";
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   377
        
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   378
        // version
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   379
        $additional .= '<b>' . $lang->get('acppl_lbl_version') . '</b> ' . "{$data['version']}<br />";
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   380
        
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   381
        // installed version
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   382
        if ( $data['status'] & PLUGIN_OUTOFDATE )
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   383
        {
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   384
          $additional .= '<b>' . $lang->get('acppl_lbl_installed_version') . '</b> ' . "{$data['version installed']}<br />";
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   385
        }
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   386
        
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   387
        // build list of buttons
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   388
        $buttons_html = '';
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   389
        if ( !empty($buttons) )
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   390
        {
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   391
          $filename_js = addslashes($filename);
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   392
          $buttons = explode('|', $buttons);
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   393
          $colors = array(
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   394
              'install' => 'green',
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   395
              'disable' => 'blue',
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   396
              'enable' => 'blue',
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   397
              'upgrade' => 'green',
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   398
              'uninstall' => 'red'
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   399
            );
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   400
          foreach ( $buttons as $button )
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   401
          {
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   402
            $btnface = $lang->get("acppl_btn_$button");
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   403
            $buttons_html .= "<a href=\"#\" onclick=\"ajaxPluginAction('$button', '$filename_js', this); return false;\" class=\"abutton_{$colors[$button]} abutton\">$btnface</a>\n";
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   404
          }
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   405
        }
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   406
        
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   407
        echo "<tr>
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   408
                <td class=\"row{$rowid}$color\">
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   409
                  <div style=\"float: right;\">
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   410
                    <b>$status</b>
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   411
                  </div>
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   412
                  <div style=\"cursor: pointer;\" onclick=\"if ( !this.fx ) this.fx = new Spry.Effect.Blind('plugininfo_$uuid', { duration: 500, from: '0%', to: '100%', toggle: true }); this.fx.start();\">
526
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   413
                    $plugin_basics
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   414
                  </div>
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   415
                  <span class=\"menuclear\"></span>
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   416
                  <div id=\"plugininfo_$uuid\" style=\"display: none;\">
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   417
                    $desc
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   418
                    <div style=\"padding: 5px;\">
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   419
                      $additional
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   420
                      <div style=\"float: right; position: relative; top: -10px;\">
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   421
                        $buttons_html
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   422
                      </div>
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   423
                      <span class=\"menuclear\"></span>
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   424
                    </div>
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   425
                  </div>
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   426
                </td>
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   427
              </tr>";
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   428
      }
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   429
      ?>
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   430
    </table>
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   431
  </div>
b2fb50d572c7 New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents: 524
diff changeset
   432
  <?php
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   433
  // are there still old style plugin entries?
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   434
  $q = $db->sql_query('SELECT 1 FROM ' . table_prefix . "config WHERE config_name LIKE 'plugin_%';");
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   435
  if ( !$q )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   436
    $db->_die();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   437
  
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   438
  $count = $db->numrows();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   439
  $db->free_result($q);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   440
  
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   441
  if ( $count > 0 )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   442
  {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   443
    echo '<h3>' . $lang->get('acppl_msg_old_entries_title') . '</h3>';
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   444
    echo '<p>' . $lang->get('acppl_msg_old_entries_body') . '</p>';
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   445
    echo '<p><a class="abutton abutton_green" href="#" onclick="ajaxPluginAction(\'import\', \'\', false); return false;">' . $lang->get('acppl_btn_import_old') . '</a></p>';
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 526
diff changeset
   446
  }
519
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
diff changeset
   447
}