예제 #1
0
 function plugins($id, $mode)
 {
     global $config, $db, $user, $auth, $template;
     global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
     if (blog_plugins::load_all_plugins() === false) {
         trigger_error('PLUGINS_DISABLED');
     }
     $submit = isset($_POST['submit']) ? true : false;
     $action = request_var('action', '');
     $action_to = request_var('name', '');
     $this->tpl_name = 'acp_blog_plugins';
     $this->page_title = 'ACP_BLOG_PLUGINS';
     $template->assign_vars(array('U_ACTION' => $this->u_action));
     switch ($action) {
         case 'activate':
             blog_plugins::plugin_enable($action_to);
             break;
         case 'deactivate':
             blog_plugins::plugin_disable($action_to);
             break;
         case 'install':
             blog_plugins::plugin_install($action_to);
             break;
         case 'uninstall':
             if (confirm_box(true)) {
                 blog_plugins::plugin_uninstall($action_to);
             } else {
                 confirm_box(false, 'PLUGIN_UNINSTALL');
             }
             break;
         case 'update':
             blog_plugins::plugin_update($action_to);
             break;
         case 'move_up':
         case 'move_down':
             blog_plugins::plugin_move($action_to, $action);
             // We need to do a redirect here because the plugins list is not shown correctly after one is moved...and I see no easy way to resync the list
             redirect($this->u_action);
             break;
     }
     $i = 0;
     $installed_plugins = array();
     foreach (blog_plugins::$available_plugins as $name => $data) {
         $i++;
         $installed = array_key_exists($name, blog_plugins::$plugins) ? true : false;
         $active = $installed && blog_plugins::$plugins[$name]['plugin_enabled'] ? true : false;
         $s_actions = array();
         if ($installed) {
             if ($active) {
                 $s_actions[] = '<a href="' . $this->u_action . "&amp;action=deactivate&amp;name=" . $name . '">' . $user->lang['PLUGIN_DEACTIVATE'] . '</a>';
                 $s_actions[] = '<a href="' . $this->u_action . "&amp;action=uninstall&amp;name=" . $name . '">' . $user->lang['PLUGIN_UNINSTALL'] . '</a>';
             } else {
                 $s_actions[] = '<a href="' . $this->u_action . "&amp;action=activate&amp;name=" . $name . '">' . $user->lang['PLUGIN_ACTIVATE'] . '</a>';
                 $s_actions[] = '<a href="' . $this->u_action . "&amp;action=uninstall&amp;name=" . $name . '">' . $user->lang['PLUGIN_UNINSTALL'] . '</a>';
             }
             if ($i > 1) {
                 $s_actions[] = '<a href="' . $this->u_action . "&amp;action=move_up&amp;name=" . $name . '">' . $user->lang['MOVE_UP'] . '</a>';
             }
             if ($i != sizeof(blog_plugins::$plugins)) {
                 $s_actions[] = '<a href="' . $this->u_action . "&amp;action=move_down&amp;name=" . $name . '">' . $user->lang['MOVE_DOWN'] . '</a>';
             }
             if ($data['plugin_version'] != blog_plugins::$plugins[$name]['plugin_version']) {
                 $version = array('files' => explode('.', $data['plugin_version']), 'db' => explode('.', blog_plugins::$plugins[$name]['plugin_version']));
                 $i = 0;
                 $newer_files = false;
                 foreach ($version['files'] as $v) {
                     if ($v > $version['db'][$i]) {
                         $newer_files = true;
                         break;
                     } else {
                         if ($v < $version['db'][$i]) {
                             break;
                         }
                     }
                     $i++;
                 }
                 if ($newer_files) {
                     $s_actions[] = '<a href="' . $this->u_action . "&amp;action=update&amp;name=" . $name . '">' . $user->lang['PLUGIN_UPDATE'] . '</a>';
                 }
             }
         } else {
             $s_actions[] = '<a href="' . $this->u_action . "&amp;action=install&amp;name=" . $name . '">' . $user->lang['PLUGIN_INSTALL'] . '</a>';
         }
         if ($installed) {
             $installed_plugins[$name] = array('NAME' => isset($data['plugin_title']) ? $data['plugin_title'] : $name, 'DESCRIPTION' => isset($data['plugin_description']) ? $data['plugin_description'] : '', 'S_ACTIONS' => implode(' | ', $s_actions), 'COPYRIGHT' => isset($data['plugin_copyright']) ? $data['plugin_copyright'] : '', 'DATABASE_VERSION' => $installed ? blog_plugins::$plugins[$name]['plugin_version'] : false, 'FILES_VERSION' => isset($data['plugin_version']) ? $data['plugin_version'] : '');
         } else {
             $template->assign_block_vars('uninstalled', array('NAME' => isset($data['plugin_title']) ? $data['plugin_title'] : $name, 'DESCRIPTION' => isset($data['plugin_description']) ? $data['plugin_description'] : '', 'S_ACTIONS' => implode(' | ', $s_actions), 'COPYRIGHT' => isset($data['plugin_copyright']) ? $data['plugin_copyright'] : '', 'DATABASE_VERSION' => $installed ? blog_plugins::$plugins[$name]['plugin_version'] : false, 'FILES_VERSION' => isset($data['plugin_version']) ? $data['plugin_version'] : ''));
         }
     }
     foreach (blog_plugins::$plugins as $name => $row) {
         $template->assign_block_vars('installed', $installed_plugins[$name]);
     }
 }